use of androidx.media3.extractor.amr.AmrExtractor in project media by androidx.
the class DefaultExtractorsFactory method addExtractorsForFileType.
private void addExtractorsForFileType(@FileTypes.Type int fileType, List<Extractor> extractors) {
switch(fileType) {
case FileTypes.AC3:
extractors.add(new Ac3Extractor());
break;
case FileTypes.AC4:
extractors.add(new Ac4Extractor());
break;
case FileTypes.ADTS:
extractors.add(new AdtsExtractor(adtsFlags | (constantBitrateSeekingEnabled ? AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0) | (constantBitrateSeekingAlwaysEnabled ? AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS : 0)));
break;
case FileTypes.AMR:
extractors.add(new AmrExtractor(amrFlags | (constantBitrateSeekingEnabled ? AmrExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0) | (constantBitrateSeekingAlwaysEnabled ? AmrExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS : 0)));
break;
case FileTypes.FLAC:
@Nullable Extractor flacExtractor = FLAC_EXTENSION_LOADER.getExtractor(flacFlags);
if (flacExtractor != null) {
extractors.add(flacExtractor);
} else {
extractors.add(new FlacExtractor(flacFlags));
}
break;
case FileTypes.FLV:
extractors.add(new FlvExtractor());
break;
case FileTypes.MATROSKA:
extractors.add(new MatroskaExtractor(matroskaFlags));
break;
case FileTypes.MP3:
extractors.add(new Mp3Extractor(mp3Flags | (constantBitrateSeekingEnabled ? Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0) | (constantBitrateSeekingAlwaysEnabled ? Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING_ALWAYS : 0)));
break;
case FileTypes.MP4:
extractors.add(new FragmentedMp4Extractor(fragmentedMp4Flags));
extractors.add(new Mp4Extractor(mp4Flags));
break;
case FileTypes.OGG:
extractors.add(new OggExtractor());
break;
case FileTypes.PS:
extractors.add(new PsExtractor());
break;
case FileTypes.TS:
extractors.add(new TsExtractor(tsMode, tsFlags, tsTimestampSearchBytes));
break;
case FileTypes.WAV:
extractors.add(new WavExtractor());
break;
case FileTypes.JPEG:
extractors.add(new JpegExtractor());
break;
case FileTypes.WEBVTT:
case FileTypes.UNKNOWN:
default:
break;
}
}
use of androidx.media3.extractor.amr.AmrExtractor in project media by androidx.
the class AmrExtractorNonParameterizedTest method read_amrWb_returnEndOfInput_ifInputEncountersEoF.
@Test
public void read_amrWb_returnEndOfInput_ifInputEncountersEoF() throws IOException {
AmrExtractor amrExtractor = setupAmrExtractorWithOutput();
byte[] amrFrame = newWideBandAmrFrameWithType(5);
byte[] data = joinData(amrSignatureWb(), amrFrame);
FakeExtractorInput input = fakeExtractorInputWithData(data);
// Read 1st frame, which will put the input at EoF.
amrExtractor.read(input, new PositionHolder());
int result = amrExtractor.read(input, new PositionHolder());
assertThat(result).isEqualTo(Extractor.RESULT_END_OF_INPUT);
}
use of androidx.media3.extractor.amr.AmrExtractor in project media by androidx.
the class AmrExtractorSeekTest method seeking_handlesSeekingForward_extractsCorrectFrames_forNarrowBandAmr.
@Test
public void seeking_handlesSeekingForward_extractsCorrectFrames_forNarrowBandAmr() throws IOException {
String fileName = NARROW_BAND_AMR_FILE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
AmrExtractor extractor = createAmrExtractor();
FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
long firstSeekTimeUs = 980_000;
TestUtil.seekToTimeUs(extractor, seekMap, firstSeekTimeUs, dataSource, trackOutput, fileUri);
long targetSeekTimeUs = 1_200_000;
int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedFrameIndex).isNotEqualTo(-1);
assertFirstFrameAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
use of androidx.media3.extractor.amr.AmrExtractor in project media by androidx.
the class AmrExtractorSeekTest method amrExtractorReads_returnSeekableSeekMap_forNarrowBandAmr.
@Test
public void amrExtractorReads_returnSeekableSeekMap_forNarrowBandAmr() throws IOException {
String fileName = NARROW_BAND_AMR_FILE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
AmrExtractor extractor = createAmrExtractor();
SeekMap seekMap = TestUtil.extractSeekMap(extractor, new FakeExtractorOutput(), dataSource, fileUri);
assertThat(seekMap).isNotNull();
assertThat(seekMap.getDurationUs()).isEqualTo(NARROW_BAND_FILE_DURATION_US);
assertThat(seekMap.isSeekable()).isTrue();
}
use of androidx.media3.extractor.amr.AmrExtractor in project media by androidx.
the class AmrExtractorSeekTest method seeking_handlesSeekToEoF_extractsLastFrame_forWideBandAmr.
@Test
public void seeking_handlesSeekToEoF_extractsLastFrame_forWideBandAmr() throws IOException {
String fileName = WIDE_BAND_AMR_FILE;
Uri fileUri = TestUtil.buildAssetUri(fileName);
expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAmrExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
AmrExtractor extractor = createAmrExtractor();
FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
long targetSeekTimeUs = seekMap.getDurationUs();
int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
assertThat(extractedFrameIndex).isNotEqualTo(-1);
assertFirstFrameAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
Aggregations