Java Code Examples for com.google.android.exoplayer2.extractor.DefaultExtractorInput#resetPeekPosition()
The following examples show how to use
com.google.android.exoplayer2.extractor.DefaultExtractorInput#resetPeekPosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HlsMediaChunk.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private DefaultExtractorInput prepareExtraction(DataSource dataSource, DataSpec dataSpec) throws IOException, InterruptedException { long bytesToRead = dataSource.open(dataSpec); DefaultExtractorInput extractorInput = new DefaultExtractorInput(dataSource, dataSpec.absoluteStreamPosition, bytesToRead); if (extractor == null) { long id3Timestamp = peekId3PrivTimestamp(extractorInput); extractorInput.resetPeekPosition(); HlsExtractorFactory.Result result = extractorFactory.createExtractor( previousExtractor, dataSpec.uri, trackFormat, muxedCaptionFormats, drmInitData, timestampAdjuster, dataSource.getResponseHeaders(), extractorInput); extractor = result.extractor; isExtractorReusable = result.isReusable; if (result.isPackedAudioExtractor) { output.setSampleOffsetUs( id3Timestamp != C.TIME_UNSET ? timestampAdjuster.adjustTsTimestamp(id3Timestamp) : startTimeUs); } else { // In case the container format changes mid-stream to non-packed-audio, we need to reset // the timestamp offset. output.setSampleOffsetUs(/* sampleOffsetUs= */ 0L); } output.init(uid, shouldSpliceIn, /* reusingExtractor= */ false); extractor.init(output); } return extractorInput; }
Example 2
Source File: HlsMediaChunk.java From Telegram with GNU General Public License v2.0 | 5 votes |
private DefaultExtractorInput prepareExtraction(DataSource dataSource, DataSpec dataSpec) throws IOException, InterruptedException { long bytesToRead = dataSource.open(dataSpec); DefaultExtractorInput extractorInput = new DefaultExtractorInput(dataSource, dataSpec.absoluteStreamPosition, bytesToRead); if (extractor == null) { long id3Timestamp = peekId3PrivTimestamp(extractorInput); extractorInput.resetPeekPosition(); HlsExtractorFactory.Result result = extractorFactory.createExtractor( previousExtractor, dataSpec.uri, trackFormat, muxedCaptionFormats, drmInitData, timestampAdjuster, dataSource.getResponseHeaders(), extractorInput); extractor = result.extractor; isExtractorReusable = result.isReusable; if (result.isPackedAudioExtractor) { output.setSampleOffsetUs( id3Timestamp != C.TIME_UNSET ? timestampAdjuster.adjustTsTimestamp(id3Timestamp) : startTimeUs); } else { // In case the container format changes mid-stream to non-packed-audio, we need to reset // the timestamp offset. output.setSampleOffsetUs(/* sampleOffsetUs= */ 0L); } output.init(uid, shouldSpliceIn, /* reusingExtractor= */ false); extractor.init(output); } return extractorInput; }
Example 3
Source File: HlsMediaChunk.java From MediaSDK with Apache License 2.0 | 4 votes |
@RequiresNonNull("output") @EnsuresNonNull("extractor") private DefaultExtractorInput prepareExtraction(DataSource dataSource, DataSpec dataSpec) throws IOException, InterruptedException { long bytesToRead = dataSource.open(dataSpec); DefaultExtractorInput extractorInput = new DefaultExtractorInput(dataSource, dataSpec.absoluteStreamPosition, bytesToRead); if (extractor == null) { long id3Timestamp = peekId3PrivTimestamp(extractorInput); extractorInput.resetPeekPosition(); HlsExtractorFactory.Result result = extractorFactory.createExtractor( previousExtractor, dataSpec.uri, trackFormat, muxedCaptionFormats, drmInitData, timestampAdjuster, dataSource.getResponseHeaders(), extractorInput); extractor = result.extractor; isExtractorReusable = result.isReusable; if (result.isPackedAudioExtractor) { output.setSampleOffsetUs( id3Timestamp != C.TIME_UNSET ? timestampAdjuster.adjustTsTimestamp(id3Timestamp) : startTimeUs); } else { // In case the container format changes mid-stream to non-packed-audio, we need to reset // the timestamp offset. output.setSampleOffsetUs(/* sampleOffsetUs= */ 0L); } output.init(uid, shouldSpliceIn, /* reusingExtractor= */ false); extractor.init(output); } return extractorInput; }