Allow ContainerMediaChunks to provide their own TrackOutputProvider.

Adding a protected method for that allows to supply a customized
TrackOutputProvider to the ExtractorWrapper used by the ContainerMediaChunk
(e.g. for logging purposes).

The alternative would be to provide a  TrackOutputProvider through the
ChunkSampleStream constructor, but the extra initialization taking place
in the ChunkSampleStream constructor would need to move somewhere else and
some methods of BaseMediaChunkOutput would need to move to the
TrackOutputProvider interface. This seems too much effort for niche
customization case.

PiperOrigin-RevId: 242448776
This commit is contained in:
tonihei 2019-04-08 14:00:25 +01:00 committed by Oliver Woodman
parent 66e416b615
commit 2d7b9d876f

View File

@ -121,7 +121,7 @@ public class ContainerMediaChunk extends BaseMediaChunk {
BaseMediaChunkOutput output = getOutput();
output.setSampleOffsetUs(sampleOffsetUs);
extractorWrapper.init(
output,
getTrackOutputProvider(output),
clippedStartTimeUs == C.TIME_UNSET
? C.TIME_UNSET
: (clippedStartTimeUs - sampleOffsetUs),
@ -144,4 +144,17 @@ public class ContainerMediaChunk extends BaseMediaChunk {
loadCompleted = true;
}
/**
* Returns the {@link ChunkExtractorWrapper.TrackOutputProvider} to be used by the wrapped
* extractor.
*
* @param baseMediaChunkOutput The {@link BaseMediaChunkOutput} most recently passed to {@link
* #init(BaseMediaChunkOutput)}.
* @return A {@link ChunkExtractorWrapper.TrackOutputProvider} to be used by the wrapped
* extractor.
*/
protected ChunkExtractorWrapper.TrackOutputProvider getTrackOutputProvider(
BaseMediaChunkOutput baseMediaChunkOutput) {
return baseMediaChunkOutput;
}
}