Offset SIDX timestamps by presentationTimeOffset

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=199856613
This commit is contained in:
olly 2018-06-08 15:03:39 -07:00 committed by Oliver Woodman
parent fcb9ca7b81
commit d6878f152c
4 changed files with 15 additions and 5 deletions

View File

@ -28,6 +28,8 @@
* IMA: Don't advertise support for video/mpeg ad media, as we don't have an
extractor for this ([#4297](https://github.com/google/ExoPlayer/issues/4297)).
* DASH: Fix playback getting stuck when playing representations that have both
sidx atoms and non-zero presentationTimeOffset values.
* Mitigate memory leaks when `MediaSource` loads are slow to cancel
([#4249](https://github.com/google/ExoPlayer/issues/4249)).
* Fix inconsistent `Player.EventListener` invocations for recursive player state

View File

@ -25,12 +25,15 @@ import com.google.android.exoplayer2.source.dash.manifest.RangedUri;
public final class DashWrappingSegmentIndex implements DashSegmentIndex {
private final ChunkIndex chunkIndex;
private final long timeOffsetUs;
/**
* @param chunkIndex The {@link ChunkIndex} to wrap.
* @param timeOffsetUs An offset to subtract from the times in the wrapped index, in microseconds.
*/
public DashWrappingSegmentIndex(ChunkIndex chunkIndex) {
public DashWrappingSegmentIndex(ChunkIndex chunkIndex, long timeOffsetUs) {
this.chunkIndex = chunkIndex;
this.timeOffsetUs = timeOffsetUs;
}
@Override
@ -45,7 +48,7 @@ public final class DashWrappingSegmentIndex implements DashSegmentIndex {
@Override
public long getTimeUs(long segmentNum) {
return chunkIndex.timesUs[(int) segmentNum];
return chunkIndex.timesUs[(int) segmentNum] - timeOffsetUs;
}
@Override
@ -61,7 +64,7 @@ public final class DashWrappingSegmentIndex implements DashSegmentIndex {
@Override
public long getSegmentNum(long timeUs, long periodDurationUs) {
return chunkIndex.getChunkIndex(timeUs);
return chunkIndex.getChunkIndex(timeUs + timeOffsetUs);
}
@Override

View File

@ -354,7 +354,10 @@ public class DefaultDashChunkSource implements DashChunkSource {
if (representationHolder.segmentIndex == null) {
SeekMap seekMap = representationHolder.extractorWrapper.getSeekMap();
if (seekMap != null) {
representationHolder.segmentIndex = new DashWrappingSegmentIndex((ChunkIndex) seekMap);
representationHolder.segmentIndex =
new DashWrappingSegmentIndex(
(ChunkIndex) seekMap,
representationHolder.representation.presentationTimeOffsetUs);
}
}
}

View File

@ -163,7 +163,9 @@ public final class DashDownloader extends SegmentDownloader<DashManifest> {
return index;
}
ChunkIndex seekMap = DashUtil.loadChunkIndex(dataSource, trackType, representation);
return seekMap == null ? null : new DashWrappingSegmentIndex(seekMap);
return seekMap == null
? null
: new DashWrappingSegmentIndex(seekMap, representation.presentationTimeOffsetUs);
}
}