use of androidx.media3.extractor.Extractor in project ExoPlayer by google.
the class HlsMediaChunk method buildPackedAudioExtractor.
private Extractor buildPackedAudioExtractor(long startTimeUs) {
Extractor extractor;
if (lastPathSegment.endsWith(AAC_FILE_EXTENSION)) {
extractor = new AdtsExtractor(startTimeUs);
} else if (lastPathSegment.endsWith(AC3_FILE_EXTENSION) || lastPathSegment.endsWith(EC3_FILE_EXTENSION)) {
extractor = new Ac3Extractor(startTimeUs);
} else if (lastPathSegment.endsWith(MP3_FILE_EXTENSION)) {
extractor = new Mp3Extractor(0, startTimeUs);
} else {
throw new IllegalArgumentException("Unkown extension for audio file: " + lastPathSegment);
}
extractor.init(extractorOutput);
return extractor;
}
use of androidx.media3.extractor.Extractor in project ExoPlayer by google.
the class DashUtil method newWrappedExtractor.
private static ChunkExtractorWrapper newWrappedExtractor(Format format) {
String mimeType = format.containerMimeType;
boolean isWebm = mimeType.startsWith(MimeTypes.VIDEO_WEBM) || mimeType.startsWith(MimeTypes.AUDIO_WEBM);
Extractor extractor = isWebm ? new MatroskaExtractor() : new FragmentedMp4Extractor();
return new ChunkExtractorWrapper(extractor, format);
}
use of androidx.media3.extractor.Extractor in project ExoPlayer by google.
the class BundledExtractorsAdapter method init.
@Override
public void init(DataReader dataReader, Uri uri, Map<String, List<String>> responseHeaders, long position, long length, ExtractorOutput output) throws IOException {
ExtractorInput extractorInput = new DefaultExtractorInput(dataReader, position, length);
this.extractorInput = extractorInput;
if (extractor != null) {
return;
}
Extractor[] extractors = extractorsFactory.createExtractors(uri, responseHeaders);
if (extractors.length == 1) {
this.extractor = extractors[0];
} else {
for (Extractor extractor : extractors) {
try {
if (extractor.sniff(extractorInput)) {
this.extractor = extractor;
break;
}
} catch (EOFException e) {
// Do nothing.
} finally {
Assertions.checkState(this.extractor != null || extractorInput.getPosition() == position);
extractorInput.resetPeekPosition();
}
}
if (extractor == null) {
throw new UnrecognizedInputFormatException("None of the available extractors (" + Util.getCommaDelimitedSimpleClassNames(extractors) + ") could read the stream.", Assertions.checkNotNull(uri));
}
}
extractor.init(output);
}
use of androidx.media3.extractor.Extractor in project ExoPlayer by google.
the class DashUtil method newChunkExtractor.
private static ChunkExtractor newChunkExtractor(int trackType, Format format) {
String mimeType = format.containerMimeType;
boolean isWebm = mimeType != null && (mimeType.startsWith(MimeTypes.VIDEO_WEBM) || mimeType.startsWith(MimeTypes.AUDIO_WEBM));
Extractor extractor = isWebm ? new MatroskaExtractor() : new FragmentedMp4Extractor();
return new BundledChunkExtractor(extractor, trackType, format);
}
use of androidx.media3.extractor.Extractor in project Telegram-FOSS by Telegram-FOSS-Team.
the class ContainerMediaChunk method load.
@SuppressWarnings("NonAtomicVolatileUpdate")
@Override
public final void load() throws IOException, InterruptedException {
if (nextLoadPosition == 0) {
// Configure the output and set it as the target for the extractor wrapper.
BaseMediaChunkOutput output = getOutput();
output.setSampleOffsetUs(sampleOffsetUs);
extractorWrapper.init(getTrackOutputProvider(output), clippedStartTimeUs == C.TIME_UNSET ? C.TIME_UNSET : (clippedStartTimeUs - sampleOffsetUs), clippedEndTimeUs == C.TIME_UNSET ? C.TIME_UNSET : (clippedEndTimeUs - sampleOffsetUs));
}
try {
// Create and open the input.
DataSpec loadDataSpec = dataSpec.subrange(nextLoadPosition);
ExtractorInput input = new DefaultExtractorInput(dataSource, loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec));
// Load and decode the sample data.
try {
Extractor extractor = extractorWrapper.extractor;
int result = Extractor.RESULT_CONTINUE;
while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
result = extractor.read(input, DUMMY_POSITION_HOLDER);
}
Assertions.checkState(result != Extractor.RESULT_SEEK);
} finally {
nextLoadPosition = input.getPosition() - dataSpec.absoluteStreamPosition;
}
} finally {
Util.closeQuietly(dataSource);
}
loadCompleted = true;
}
Aggregations