mirror of
https://github.com/androidx/media.git
synced 2025-05-10 00:59:51 +08:00
Take period start time into account when calculating segment times.
This commit is contained in:
parent
2b27137e9e
commit
a626a5e5d4
@ -531,7 +531,8 @@ public class DashChunkSource implements ChunkSource {
|
|||||||
if (initializationChunk.hasSeekMap()) {
|
if (initializationChunk.hasSeekMap()) {
|
||||||
representationHolder.segmentIndex = new DashWrappingSegmentIndex(
|
representationHolder.segmentIndex = new DashWrappingSegmentIndex(
|
||||||
(ChunkIndex) initializationChunk.getSeekMap(),
|
(ChunkIndex) initializationChunk.getSeekMap(),
|
||||||
initializationChunk.dataSpec.uri.toString());
|
initializationChunk.dataSpec.uri.toString(),
|
||||||
|
representationHolder.representation.periodStartMs * 1000);
|
||||||
}
|
}
|
||||||
// The null check avoids overwriting drmInitData obtained from the manifest with drmInitData
|
// The null check avoids overwriting drmInitData obtained from the manifest with drmInitData
|
||||||
// obtained from the stream, as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
|
// obtained from the stream, as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
|
||||||
@ -638,7 +639,8 @@ public class DashChunkSource implements ChunkSource {
|
|||||||
DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
|
DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
|
||||||
representation.getCacheKey());
|
representation.getCacheKey());
|
||||||
|
|
||||||
long sampleOffsetUs = -1 * representation.presentationTimeOffsetUs;
|
long sampleOffsetUs = representation.periodStartMs * 1000
|
||||||
|
- representation.presentationTimeOffsetUs;
|
||||||
if (representation.format.mimeType.equals(MimeTypes.TEXT_VTT)) {
|
if (representation.format.mimeType.equals(MimeTypes.TEXT_VTT)) {
|
||||||
if (representationHolder.vttHeaderOffsetUs != sampleOffsetUs) {
|
if (representationHolder.vttHeaderOffsetUs != sampleOffsetUs) {
|
||||||
// Update the VTT header.
|
// Update the VTT header.
|
||||||
|
@ -26,14 +26,17 @@ public class DashWrappingSegmentIndex implements DashSegmentIndex {
|
|||||||
|
|
||||||
private final ChunkIndex chunkIndex;
|
private final ChunkIndex chunkIndex;
|
||||||
private final String uri;
|
private final String uri;
|
||||||
|
private final long startTimeUs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param chunkIndex The {@link ChunkIndex} to wrap.
|
* @param chunkIndex The {@link ChunkIndex} to wrap.
|
||||||
* @param uri The URI where the data is located.
|
* @param uri The URI where the data is located.
|
||||||
|
* @param startTimeUs The start time of the index, in microseconds.
|
||||||
*/
|
*/
|
||||||
public DashWrappingSegmentIndex(ChunkIndex chunkIndex, String uri) {
|
public DashWrappingSegmentIndex(ChunkIndex chunkIndex, String uri, long startTimeUs) {
|
||||||
this.chunkIndex = chunkIndex;
|
this.chunkIndex = chunkIndex;
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
|
this.startTimeUs = startTimeUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -48,7 +51,7 @@ public class DashWrappingSegmentIndex implements DashSegmentIndex {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTimeUs(int segmentNum) {
|
public long getTimeUs(int segmentNum) {
|
||||||
return chunkIndex.timesUs[segmentNum];
|
return chunkIndex.timesUs[segmentNum] + startTimeUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,7 +66,7 @@ public class DashWrappingSegmentIndex implements DashSegmentIndex {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSegmentNum(long timeUs) {
|
public int getSegmentNum(long timeUs) {
|
||||||
return chunkIndex.getChunkIndex(timeUs);
|
return chunkIndex.getChunkIndex(timeUs - startTimeUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -266,12 +266,12 @@ public abstract class Representation implements FormatWrapper {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSegmentNum(long timeUs) {
|
public int getSegmentNum(long timeUs) {
|
||||||
return segmentBase.getSegmentNum(timeUs);
|
return segmentBase.getSegmentNum(timeUs - periodStartMs * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTimeUs(int segmentIndex) {
|
public long getTimeUs(int segmentIndex) {
|
||||||
return segmentBase.getSegmentTimeUs(segmentIndex);
|
return segmentBase.getSegmentTimeUs(segmentIndex) + periodStartMs * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user