Commit 5cf781ab by ojw28

Merge pull request #211 from google/dev

dev -> dev-hls
parents 83e80f98 7f91a6d4
......@@ -361,9 +361,12 @@ public final class AudioTrack {
* written data.
*/
public int handleBuffer(ByteBuffer buffer, int offset, int size, long presentationTimeUs) {
int result = 0;
if (size == 0) {
return RESULT_BUFFER_CONSUMED;
}
if (temporaryBufferSize == 0 && size != 0) {
int result = 0;
if (temporaryBufferSize == 0) {
if (isAc3 && ac3Bitrate == UNKNOWN_AC3_BITRATE) {
// Each AC-3 buffer contains 1536 frames of audio, so the AudioTrack playback position
// advances by 1536 per buffer (32 ms at 48 kHz). Calculate the bitrate in kbit/s.
......@@ -393,15 +396,11 @@ public final class AudioTrack {
// number of bytes submitted.
startMediaTimeUs += (bufferStartTime - expectedBufferStartTime);
startMediaTimeState = START_IN_SYNC;
result = RESULT_POSITION_DISCONTINUITY;
result |= RESULT_POSITION_DISCONTINUITY;
}
}
}
if (size == 0) {
return result;
}
if (temporaryBufferSize == 0) {
temporaryBufferSize = size;
buffer.position(offset);
......
......@@ -226,6 +226,19 @@ public class HttpDataSource implements DataSource {
}
}
/*
* TODO: If the server uses gzip compression when serving the response, this may end up returning
* the size of the compressed response, where-as it should be returning the decompressed size or
* -1. See: developer.android.com/reference/java/net/HttpURLConnection.html
*
* To fix this we should:
*
* 1. Explicitly require no compression for media requests (since media should be compressed
* already) by setting the Accept-Encoding header to "identity"
* 2. In other cases, for example when requesting manifests, we don't want to disable compression.
* For these cases we should ensure that we return -1 here (and avoid performing any sanity
* checks on the content length).
*/
@Override
public long open(DataSpec dataSpec) throws HttpDataSourceException {
this.dataSpec = dataSpec;
......@@ -380,7 +393,6 @@ public class HttpDataSource implements DataSource {
connection.setRequestProperty(property.getKey(), property.getValue());
}
}
connection.setRequestProperty("Accept-Encoding", "deflate");
connection.setRequestProperty("User-Agent", userAgent);
connection.setRequestProperty("Range", buildRangeHeader(dataSpec));
connection.connect();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment