diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java index 057f0262d0..2877b2a1cc 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java @@ -42,6 +42,7 @@ import com.google.android.exoplayer2.source.chunk.SingleSampleMediaChunk; import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler; import com.google.android.exoplayer2.source.dash.manifest.AdaptationSet; import com.google.android.exoplayer2.source.dash.manifest.DashManifest; +import com.google.android.exoplayer2.source.dash.manifest.Descriptor; import com.google.android.exoplayer2.source.dash.manifest.RangedUri; import com.google.android.exoplayer2.source.dash.manifest.Representation; import com.google.android.exoplayer2.trackselection.TrackSelection; @@ -325,10 +326,34 @@ public class DefaultDashChunkSource implements DashChunkSource { return; } + List listDescriptors; + Integer lastSegmentNumberSchemeIdUri = Integer.MAX_VALUE; + String sampleMimeType = trackSelection.getFormat(periodIndex).sampleMimeType; + + if (sampleMimeType.contains("video") || sampleMimeType.contains("audio")) { + + int track_type = sampleMimeType.contains("video")? C.TRACK_TYPE_VIDEO : C.TRACK_TYPE_AUDIO; + + if (!manifest.getPeriod(periodIndex).adaptationSets.get(manifest.getPeriod(periodIndex) + .getAdaptationSetIndex(track_type)).supplementalProperties.isEmpty()) { + listDescriptors = manifest.getPeriod(periodIndex).adaptationSets + .get(manifest.getPeriod(periodIndex).getAdaptationSetIndex(track_type)) + .supplementalProperties; + for ( Descriptor descriptor: listDescriptors ) { + if (descriptor.schemeIdUri.equalsIgnoreCase + ("http://dashif.org/guidelines/last-segment-number")) { + lastSegmentNumberSchemeIdUri = Integer.valueOf(descriptor.value); + } + } + } + } + long firstAvailableSegmentNum = representationHolder.getFirstAvailableSegmentNum(manifest, periodIndex, nowUnixTimeUs); long lastAvailableSegmentNum = - representationHolder.getLastAvailableSegmentNum(manifest, periodIndex, nowUnixTimeUs); + Math.min(representationHolder. + getLastAvailableSegmentNum(manifest, periodIndex, nowUnixTimeUs), + lastSegmentNumberSchemeIdUri); updateLiveEdgeTimeUs(representationHolder, lastAvailableSegmentNum);