use of androidx.media3.extractor.amr.AmrExtractor in project media by androidx.
the class AmrExtractorSeekTest method seeking_handlesSeekToEoF_extractsLastFrame_forNarrowBandAmr.
@Test
public void seeking_handlesSeekToEoF_extractsLastFrame_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 targetSeekTimeUs = seekMap.getDurationUs();
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 seeking_handlesSeekingBackward_extractsCorrectFrames_forNarrowBandAmr.
@Test
public void seeking_handlesSeekingBackward_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 = 0;
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 bolan by qiusunshine.
the class MyDefaultExtractorsFactory method addExtractorsForFileType.
private void addExtractorsForFileType(int fileType, List<Extractor> extractors) {
switch(fileType) {
case -1:
case 13:
default:
break;
case 0:
extractors.add(new Ac3Extractor());
break;
case 1:
extractors.add(new Ac4Extractor());
break;
case 2:
extractors.add(new AdtsExtractor(this.adtsFlags | (this.constantBitrateSeekingEnabled ? 1 : 0)));
break;
case 3:
extractors.add(new AmrExtractor(this.amrFlags | (this.constantBitrateSeekingEnabled ? 1 : 0)));
break;
case 4:
if (FLAC_EXTENSION_EXTRACTOR_CONSTRUCTOR != null) {
try {
extractors.add((Extractor) FLAC_EXTENSION_EXTRACTOR_CONSTRUCTOR.newInstance(this.flacFlags));
} catch (Exception var4) {
throw new IllegalStateException("Unexpected error creating FLAC extractor", var4);
}
} else {
extractors.add(new FlacExtractor(this.flacFlags));
}
break;
case 5:
extractors.add(new FlvExtractor());
break;
case 6:
extractors.add(new MatroskaExtractor(this.matroskaFlags));
break;
case 7:
extractors.add(new Mp3Extractor(this.mp3Flags | (this.constantBitrateSeekingEnabled ? 1 : 0)));
break;
case 8:
extractors.add(new FragmentedMp4Extractor(this.fragmentedMp4Flags));
extractors.add(new Mp4Extractor(this.mp4Flags));
break;
case 9:
extractors.add(new OggExtractor());
break;
case 10:
extractors.add(new PsExtractor());
break;
case 11:
extractors.add(new TsExtractor(this.tsMode, this.tsFlags, this.tsTimestampSearchBytes));
break;
case 12:
extractors.add(new WavExtractor());
break;
case 14:
extractors.add(new JpegExtractor());
}
}
use of androidx.media3.extractor.amr.AmrExtractor in project Telegram-FOSS by Telegram-FOSS-Team.
the class DefaultExtractorsFactory method createExtractors.
@Override
public synchronized Extractor[] createExtractors() {
Extractor[] extractors = new Extractor[14];
extractors[0] = new MatroskaExtractor(matroskaFlags);
extractors[1] = new FragmentedMp4Extractor(fragmentedMp4Flags);
extractors[2] = new Mp4Extractor(mp4Flags);
extractors[3] = new OggExtractor();
extractors[4] = new Mp3Extractor(mp3Flags | (constantBitrateSeekingEnabled ? Mp3Extractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0));
extractors[5] = new AdtsExtractor(adtsFlags | (constantBitrateSeekingEnabled ? AdtsExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0));
extractors[6] = new Ac3Extractor();
extractors[7] = new TsExtractor(tsMode, tsFlags);
extractors[8] = new FlvExtractor();
extractors[9] = new PsExtractor();
extractors[10] = new WavExtractor();
extractors[11] = new AmrExtractor(amrFlags | (constantBitrateSeekingEnabled ? AmrExtractor.FLAG_ENABLE_CONSTANT_BITRATE_SEEKING : 0));
extractors[12] = new Ac4Extractor();
if (FLAC_EXTENSION_EXTRACTOR_CONSTRUCTOR != null) {
try {
extractors[13] = FLAC_EXTENSION_EXTRACTOR_CONSTRUCTOR.newInstance();
} catch (Exception e) {
// Should never happen.
throw new IllegalStateException("Unexpected error creating FLAC extractor", e);
}
} else {
extractors[13] = new FlacExtractor();
}
return extractors;
}
use of androidx.media3.extractor.amr.AmrExtractor in project media by androidx.
the class AmrExtractorNonParameterizedTest method read_amrNb_returnParserException_forInvalidFrameType.
@Test
public void read_amrNb_returnParserException_forInvalidFrameType() throws IOException {
AmrExtractor amrExtractor = setupAmrExtractorWithOutput();
// Frame type 12-14 for narrow band is reserved for future usage.
byte[] amrFrame = newNarrowBandAmrFrameWithType(12);
byte[] data = joinData(amrSignatureNb(), amrFrame);
FakeExtractorInput input = fakeExtractorInputWithData(data);
try {
amrExtractor.read(input, new PositionHolder());
fail();
} catch (ParserException e) {
// expected
}
}
Aggregations