-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,164 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...oid-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/VFileMediaDataSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.zoffcc.applications.trifa; | ||
|
||
import android.media.MediaDataSource; | ||
import android.os.Build; | ||
|
||
import java.io.IOException; | ||
|
||
import androidx.annotation.RequiresApi; | ||
|
||
@RequiresApi(api = Build.VERSION_CODES.M) | ||
public class VFileMediaDataSource extends MediaDataSource | ||
{ | ||
private info.guardianproject.iocipher.RandomAccessFile f; | ||
private long streamLength = -1, lastReadEndPosition; | ||
|
||
public VFileMediaDataSource(info.guardianproject.iocipher.RandomAccessFile f) | ||
{ | ||
this.f = f; | ||
try | ||
{ | ||
this.streamLength = f.length(); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new RuntimeException(e); | ||
} | ||
if (streamLength <= 0) | ||
{ | ||
throw new RuntimeException(); | ||
} | ||
} | ||
|
||
@Override | ||
public synchronized void close() | ||
{ | ||
} | ||
|
||
@Override | ||
public synchronized int readAt(long position, byte[] buffer, int offset, int size) | ||
{ | ||
if (position >= streamLength) | ||
{ | ||
return -1; | ||
} | ||
|
||
if (position + size > streamLength) | ||
{ | ||
size -= (position + size) - streamLength; | ||
} | ||
|
||
if (position < 0) | ||
{ | ||
position = 0; | ||
} | ||
|
||
try | ||
{ | ||
this.f.seek(position); | ||
return this.f.read(buffer, offset, size); | ||
} | ||
catch(Exception e) | ||
{ | ||
return -1; | ||
} | ||
} | ||
|
||
@Override | ||
public synchronized long getSize() | ||
{ | ||
return streamLength; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.