Remove re-entrancy from HlsMediaChunk initialization
HlsSampleStreamWrapper currently calls HlsMediaChunk.init, which calls back to HlsSampleStraemWrapper.init. This re-entrancy seems a bit confusing. PiperOrigin-RevId: 304139462
This commit is contained in:
parent
cd5ecd5c90
commit
6570d12c3c
@ -194,6 +194,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
/** The url of the playlist from which this chunk was obtained. */
|
/** The url of the playlist from which this chunk was obtained. */
|
||||||
public final Uri playlistUrl;
|
public final Uri playlistUrl;
|
||||||
|
|
||||||
|
/** Whether the samples parsed from this chunk should be spliced into already queued samples. */
|
||||||
|
public final boolean shouldSpliceIn;
|
||||||
|
|
||||||
@Nullable private final DataSource initDataSource;
|
@Nullable private final DataSource initDataSource;
|
||||||
@Nullable private final DataSpec initDataSpec;
|
@Nullable private final DataSpec initDataSpec;
|
||||||
@Nullable private final Extractor previousExtractor;
|
@Nullable private final Extractor previousExtractor;
|
||||||
@ -201,7 +204,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
private final boolean isMasterTimestampSource;
|
private final boolean isMasterTimestampSource;
|
||||||
private final boolean hasGapTag;
|
private final boolean hasGapTag;
|
||||||
private final TimestampAdjuster timestampAdjuster;
|
private final TimestampAdjuster timestampAdjuster;
|
||||||
private final boolean shouldSpliceIn;
|
|
||||||
private final HlsExtractorFactory extractorFactory;
|
private final HlsExtractorFactory extractorFactory;
|
||||||
@Nullable private final List<Format> muxedCaptionFormats;
|
@Nullable private final List<Format> muxedCaptionFormats;
|
||||||
@Nullable private final DrmInitData drmInitData;
|
@Nullable private final DrmInitData drmInitData;
|
||||||
@ -282,7 +284,6 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
*/
|
*/
|
||||||
public void init(HlsSampleStreamWrapper output) {
|
public void init(HlsSampleStreamWrapper output) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
output.init(uid, shouldSpliceIn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -515,5 +516,4 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
}
|
}
|
||||||
return dataSource;
|
return dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
private boolean tracksEnded;
|
private boolean tracksEnded;
|
||||||
private long sampleOffsetUs;
|
private long sampleOffsetUs;
|
||||||
@Nullable private DrmInitData drmInitData;
|
@Nullable private DrmInitData drmInitData;
|
||||||
private int chunkUid;
|
private int sourceId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param trackType The type of the track. One of the {@link C} {@code TRACK_TYPE_*} constants.
|
* @param trackType The type of the track. One of the {@link C} {@code TRACK_TYPE_*} constants.
|
||||||
@ -668,11 +668,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isMediaChunk(loadable)) {
|
if (isMediaChunk(loadable)) {
|
||||||
pendingResetPositionUs = C.TIME_UNSET;
|
initMediaChunkLoad((HlsMediaChunk) loadable);
|
||||||
HlsMediaChunk mediaChunk = (HlsMediaChunk) loadable;
|
|
||||||
mediaChunk.init(this);
|
|
||||||
mediaChunks.add(mediaChunk);
|
|
||||||
upstreamTrackFormat = mediaChunk.trackFormat;
|
|
||||||
}
|
}
|
||||||
long elapsedRealtimeMs =
|
long elapsedRealtimeMs =
|
||||||
loader.startLoading(
|
loader.startLoading(
|
||||||
@ -819,18 +815,21 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
// Called by the consuming thread, but only when there is no loading thread.
|
// Called by the consuming thread, but only when there is no loading thread.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the wrapper for loading a chunk.
|
* Performs initialization for a media chunk that's about to start loading.
|
||||||
*
|
*
|
||||||
* @param chunkUid The chunk's uid.
|
* @param mediaChunk The media chunk that's about to start loading.
|
||||||
* @param shouldSpliceIn Whether the samples parsed from the chunk should be spliced into any
|
|
||||||
* samples already queued to the wrapper.
|
|
||||||
*/
|
*/
|
||||||
public void init(int chunkUid, boolean shouldSpliceIn) {
|
private void initMediaChunkLoad(HlsMediaChunk mediaChunk) {
|
||||||
this.chunkUid = chunkUid;
|
sourceId = mediaChunk.uid;
|
||||||
|
upstreamTrackFormat = mediaChunk.trackFormat;
|
||||||
|
pendingResetPositionUs = C.TIME_UNSET;
|
||||||
|
mediaChunks.add(mediaChunk);
|
||||||
|
|
||||||
|
mediaChunk.init(this);
|
||||||
for (SampleQueue sampleQueue : sampleQueues) {
|
for (SampleQueue sampleQueue : sampleQueues) {
|
||||||
sampleQueue.sourceId(chunkUid);
|
sampleQueue.sourceId(sourceId);
|
||||||
}
|
}
|
||||||
if (shouldSpliceIn) {
|
if (mediaChunk.shouldSpliceIn) {
|
||||||
for (SampleQueue sampleQueue : sampleQueues) {
|
for (SampleQueue sampleQueue : sampleQueues) {
|
||||||
sampleQueue.splice();
|
sampleQueue.splice();
|
||||||
}
|
}
|
||||||
@ -914,7 +913,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
trackOutput.setDrmInitData(drmInitData);
|
trackOutput.setDrmInitData(drmInitData);
|
||||||
}
|
}
|
||||||
trackOutput.setSampleOffsetUs(sampleOffsetUs);
|
trackOutput.setSampleOffsetUs(sampleOffsetUs);
|
||||||
trackOutput.sourceId(chunkUid);
|
trackOutput.sourceId(sourceId);
|
||||||
trackOutput.setUpstreamFormatChangeListener(this);
|
trackOutput.setUpstreamFormatChangeListener(this);
|
||||||
sampleQueueTrackIds = Arrays.copyOf(sampleQueueTrackIds, trackCount + 1);
|
sampleQueueTrackIds = Arrays.copyOf(sampleQueueTrackIds, trackCount + 1);
|
||||||
sampleQueueTrackIds[trackCount] = id;
|
sampleQueueTrackIds[trackCount] = id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user