mirror of
https://github.com/samsonjs/media.git
synced 2026-03-28 09:55:48 +00:00
Offset SIDX timestamps by presentationTimeOffset
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=199856613
This commit is contained in:
parent
799d281e58
commit
9ecf959613
4 changed files with 15 additions and 5 deletions
|
|
@ -4,6 +4,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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,9 @@ public final class DashDownloader extends SegmentDownloader<DashManifest, Repres
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue