Search in sources :

Example 21 with AmrExtractor

use of com.google.android.exoplayer2.extractor.amr.AmrExtractor in project ExoPlayer by google.

the class AmrExtractorNonParameterizedTest method read_amrWb_returnParserException_forInvalidFrameHeader.

@Test
public void read_amrWb_returnParserException_forInvalidFrameHeader() throws IOException {
    AmrExtractor amrExtractor = setupAmrExtractorWithOutput();
    byte[] invalidHeaderFrame = newWideBandAmrFrameWithType(6);
    // The padding bits are at bit-1 positions in the following pattern: 1000 0011
    // Padding bits must be 0.
    invalidHeaderFrame[0] = (byte) (invalidHeaderFrame[0] | 0b01111110);
    byte[] data = joinData(amrSignatureWb(), invalidHeaderFrame);
    FakeExtractorInput input = fakeExtractorInputWithData(data);
    try {
        amrExtractor.read(input, new PositionHolder());
        fail();
    } catch (ParserException e) {
    // expected
    }
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) ParserException(com.google.android.exoplayer2.ParserException) PositionHolder(com.google.android.exoplayer2.extractor.PositionHolder) Test(org.junit.Test)

Example 22 with AmrExtractor

use of com.google.android.exoplayer2.extractor.amr.AmrExtractor in project ExoPlayer by google.

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();
}
Also used : SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)20 FakeExtractorOutput (com.google.android.exoplayer2.testutil.FakeExtractorOutput)13 Uri (android.net.Uri)12 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)12 FakeTrackOutput (com.google.android.exoplayer2.testutil.FakeTrackOutput)10 FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)8 PositionHolder (com.google.android.exoplayer2.extractor.PositionHolder)7 ParserException (com.google.android.exoplayer2.ParserException)5 Nullable (androidx.annotation.Nullable)1 AmrExtractor (com.google.android.exoplayer2.extractor.amr.AmrExtractor)1 FlacExtractor (com.google.android.exoplayer2.extractor.flac.FlacExtractor)1 FlvExtractor (com.google.android.exoplayer2.extractor.flv.FlvExtractor)1 JpegExtractor (com.google.android.exoplayer2.extractor.jpeg.JpegExtractor)1 MatroskaExtractor (com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor)1 Mp3Extractor (com.google.android.exoplayer2.extractor.mp3.Mp3Extractor)1 FragmentedMp4Extractor (com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor)1 Mp4Extractor (com.google.android.exoplayer2.extractor.mp4.Mp4Extractor)1 OggExtractor (com.google.android.exoplayer2.extractor.ogg.OggExtractor)1 Ac3Extractor (com.google.android.exoplayer2.extractor.ts.Ac3Extractor)1 Ac4Extractor (com.google.android.exoplayer2.extractor.ts.Ac4Extractor)1