mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Add END_OF_INPUT constant + start using it.
This commit is contained in:
parent
608d685b2c
commit
a085d2f29b
3 changed files with 14 additions and 7 deletions
|
|
@ -43,6 +43,12 @@ public final class C {
|
|||
*/
|
||||
public static final String UTF8_NAME = "UTF-8";
|
||||
|
||||
/**
|
||||
* @see MediaCodec#CRYPTO_MODE_AES_CTR
|
||||
*/
|
||||
@SuppressWarnings("InlinedApi")
|
||||
public static final int CRYPTO_MODE_AES_CTR = MediaCodec.CRYPTO_MODE_AES_CTR;
|
||||
|
||||
/**
|
||||
* @see MediaExtractor#SAMPLE_FLAG_SYNC
|
||||
*/
|
||||
|
|
@ -61,10 +67,9 @@ public final class C {
|
|||
public static final int SAMPLE_FLAG_DECODE_ONLY = 0x8000000;
|
||||
|
||||
/**
|
||||
* @see MediaCodec#CRYPTO_MODE_AES_CTR
|
||||
* A return value for methods where the end of an input was encountered.
|
||||
*/
|
||||
@SuppressWarnings("InlinedApi")
|
||||
public static final int CRYPTO_MODE_AES_CTR = MediaCodec.CRYPTO_MODE_AES_CTR;
|
||||
public static final int RESULT_END_OF_INPUT = -1;
|
||||
|
||||
private C() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@ public interface DataSource {
|
|||
* @param buffer The buffer into which the read data should be stored.
|
||||
* @param offset The start offset into {@code buffer} at which data should be written.
|
||||
* @param readLength The maximum number of bytes to read.
|
||||
* @return The number of bytes read, or -1 if the end of the opened range is reached.
|
||||
* @return The number of bytes read, or {@link C#RESULT_END_OF_INPUT} if the end of the opened
|
||||
* range is reached.
|
||||
* @throws IOException If an error occurs reading from the source.
|
||||
*/
|
||||
public int read(byte[] buffer, int offset, int readLength) throws IOException;
|
||||
|
|
|
|||
|
|
@ -401,7 +401,8 @@ public class DefaultHttpDataSource implements HttpDataSource {
|
|||
* @param buffer The buffer into which the read data should be stored.
|
||||
* @param offset The start offset into {@code buffer} at which data should be written.
|
||||
* @param readLength The maximum number of bytes to read.
|
||||
* @return The number of bytes read, or -1 if the end of the opened range is reached.
|
||||
* @return The number of bytes read, or {@link C#RESULT_END_OF_INPUT} if the end of the opened
|
||||
* range is reached.
|
||||
* @throws IOException If an error occurs reading from the source.
|
||||
*/
|
||||
private int readInternal(byte[] buffer, int offset, int readLength) throws IOException {
|
||||
|
|
@ -409,7 +410,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
|
|||
: (int) Math.min(readLength, bytesToRead - bytesRead);
|
||||
if (readLength == 0) {
|
||||
// We've read all of the requested data.
|
||||
return -1;
|
||||
return C.RESULT_END_OF_INPUT;
|
||||
}
|
||||
|
||||
int read = inputStream.read(buffer, offset, readLength);
|
||||
|
|
@ -418,7 +419,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
|
|||
// The server closed the connection having not sent sufficient data.
|
||||
throw new EOFException();
|
||||
}
|
||||
return -1;
|
||||
return C.RESULT_END_OF_INPUT;
|
||||
}
|
||||
|
||||
bytesRead += read;
|
||||
|
|
|
|||
Loading…
Reference in a new issue