Commit 9ecf9596 by olly Committed by Oliver Woodman

Offset SIDX timestamps by presentationTimeOffset

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=199856613
parent 799d281e
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
* IMA: Don't advertise support for video/mpeg ad media, as we don't have an * 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)). 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 * Mitigate memory leaks when `MediaSource` loads are slow to cancel
([#4249](https://github.com/google/ExoPlayer/issues/4249)). ([#4249](https://github.com/google/ExoPlayer/issues/4249)).
* Fix inconsistent `Player.EventListener` invocations for recursive player state * Fix inconsistent `Player.EventListener` invocations for recursive player state
......
...@@ -25,12 +25,15 @@ import com.google.android.exoplayer2.source.dash.manifest.RangedUri; ...@@ -25,12 +25,15 @@ import com.google.android.exoplayer2.source.dash.manifest.RangedUri;
public final class DashWrappingSegmentIndex implements DashSegmentIndex { public final class DashWrappingSegmentIndex implements DashSegmentIndex {
private final ChunkIndex chunkIndex; private final ChunkIndex chunkIndex;
private final long timeOffsetUs;
/** /**
* @param chunkIndex The {@link ChunkIndex} to wrap. * @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.chunkIndex = chunkIndex;
this.timeOffsetUs = timeOffsetUs;
} }
@Override @Override
...@@ -45,7 +48,7 @@ public final class DashWrappingSegmentIndex implements DashSegmentIndex { ...@@ -45,7 +48,7 @@ public final class DashWrappingSegmentIndex implements DashSegmentIndex {
@Override @Override
public long getTimeUs(long segmentNum) { public long getTimeUs(long segmentNum) {
return chunkIndex.timesUs[(int) segmentNum]; return chunkIndex.timesUs[(int) segmentNum] - timeOffsetUs;
} }
@Override @Override
...@@ -61,7 +64,7 @@ public final class DashWrappingSegmentIndex implements DashSegmentIndex { ...@@ -61,7 +64,7 @@ public final class DashWrappingSegmentIndex implements DashSegmentIndex {
@Override @Override
public long getSegmentNum(long timeUs, long periodDurationUs) { public long getSegmentNum(long timeUs, long periodDurationUs) {
return chunkIndex.getChunkIndex(timeUs); return chunkIndex.getChunkIndex(timeUs + timeOffsetUs);
} }
@Override @Override
......
...@@ -354,7 +354,10 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -354,7 +354,10 @@ public class DefaultDashChunkSource implements DashChunkSource {
if (representationHolder.segmentIndex == null) { if (representationHolder.segmentIndex == null) {
SeekMap seekMap = representationHolder.extractorWrapper.getSeekMap(); SeekMap seekMap = representationHolder.extractorWrapper.getSeekMap();
if (seekMap != null) { if (seekMap != null) {
representationHolder.segmentIndex = new DashWrappingSegmentIndex((ChunkIndex) seekMap); representationHolder.segmentIndex =
new DashWrappingSegmentIndex(
(ChunkIndex) seekMap,
representationHolder.representation.presentationTimeOffsetUs);
} }
} }
} }
......
...@@ -167,7 +167,9 @@ public final class DashDownloader extends SegmentDownloader<DashManifest, Repres ...@@ -167,7 +167,9 @@ public final class DashDownloader extends SegmentDownloader<DashManifest, Repres
return index; return index;
} }
ChunkIndex seekMap = DashUtil.loadChunkIndex(dataSource, trackType, representation); ChunkIndex seekMap = DashUtil.loadChunkIndex(dataSource, trackType, representation);
return seekMap == null ? null : new DashWrappingSegmentIndex(seekMap); return seekMap == null
? null
: new DashWrappingSegmentIndex(seekMap, representation.presentationTimeOffsetUs);
} }
} }
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