Fix a few issues with SmoothStreaming in V2.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=119049397
This commit is contained in:
olly 2016-04-05 07:59:25 -07:00 committed by Oliver Woodman
parent 3c1239826c
commit 7c35e38b4e
2 changed files with 18 additions and 5 deletions

View file

@ -32,6 +32,7 @@ import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DataSourceFactory;
import com.google.android.exoplayer.upstream.DefaultAllocator;
import com.google.android.exoplayer.util.ManifestFetcher;
import com.google.android.exoplayer.util.Util;
import android.net.Uri;
import android.os.Handler;
@ -55,7 +56,7 @@ public class SmoothStreamingSourceBuilder implements SourceBuilder {
public SmoothStreamingSourceBuilder(DataSourceFactory dataSourceFactory, String url,
MediaDrmCallback drmCallback) {
this.dataSourceFactory = dataSourceFactory;
this.url = url;
this.url = Util.toLowerInvariant(url).endsWith("/manifest") ? url : url + "/Manifest";
this.drmCallback = drmCallback;
}

View file

@ -275,10 +275,8 @@ public class SmoothStreamingChunkSource implements ChunkSource {
return;
}
boolean isLastChunk = !currentManifest.isLive && chunkIndex == streamElement.chunkCount - 1;
long chunkStartTimeUs = streamElement.getStartTimeUs(chunkIndex);
long chunkEndTimeUs = isLastChunk ? -1
: chunkStartTimeUs + streamElement.getChunkDurationUs(chunkIndex);
long chunkEndTimeUs = chunkStartTimeUs + streamElement.getChunkDurationUs(chunkIndex);
int currentAbsoluteChunkIndex = chunkIndex + currentManifestChunkOffset;
int trackGroupTrackIndex = getTrackGroupTrackIndex(trackGroup, selectedFormat);
@ -325,7 +323,8 @@ public class SmoothStreamingChunkSource implements ChunkSource {
extractorWrappers = new ChunkExtractorWrapper[formats.length];
for (int j = 0; j < formats.length; j++) {
int nalUnitLengthFieldLength = streamElementType == StreamElement.TYPE_VIDEO ? 4 : -1;
Track track = new Track(j, streamElementType, timescale, C.UNKNOWN_TIME_US, durationUs,
int mp4TrackType = getMp4TrackType(streamElementType);
Track track = new Track(j, mp4TrackType, timescale, C.UNKNOWN_TIME_US, durationUs,
formats[j], trackEncryptionBoxes, nalUnitLengthFieldLength, null, null);
FragmentedMp4Extractor extractor = new FragmentedMp4Extractor(
FragmentedMp4Extractor.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME
@ -430,4 +429,17 @@ public class SmoothStreamingChunkSource implements ChunkSource {
data[secondPosition] = temp;
}
private static int getMp4TrackType(int streamElementType) {
switch (streamElementType) {
case StreamElement.TYPE_AUDIO:
return Track.TYPE_soun;
case StreamElement.TYPE_VIDEO:
return Track.TYPE_vide;
case StreamElement.TYPE_TEXT:
return Track.TYPE_text;
default:
throw new IllegalArgumentException("Invalid stream type: " + streamElementType);
}
}
}