Search in sources :

Example 1 with AmrExtractor

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

the class AmrExtractorNonParameterizedTest method read_amrNb_returnEndOfInput_ifInputEncountersEoF.

@Test
public void read_amrNb_returnEndOfInput_ifInputEncountersEoF() throws IOException {
    AmrExtractor amrExtractor = setupAmrExtractorWithOutput();
    byte[] amrFrame = newNarrowBandAmrFrameWithType(3);
    byte[] data = joinData(amrSignatureNb(), 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);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) PositionHolder(com.google.android.exoplayer2.extractor.PositionHolder) Test(org.junit.Test)

Example 2 with AmrExtractor

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

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
    }
}
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 3 with AmrExtractor

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

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

Example 4 with AmrExtractor

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

the class AmrExtractorNonParameterizedTest method read_amrWb_returnParserException_forInvalidFrameType.

@Test
public void read_amrWb_returnParserException_forInvalidFrameType() throws IOException {
    AmrExtractor amrExtractor = setupAmrExtractorWithOutput();
    // Frame type 10-13 for wide band is reserved for future usage.
    byte[] amrFrame = newWideBandAmrFrameWithType(13);
    byte[] data = joinData(amrSignatureWb(), amrFrame);
    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 5 with AmrExtractor

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

the class AmrExtractorNonParameterizedTest method setupAmrExtractorWithOutput.

private static AmrExtractor setupAmrExtractorWithOutput() {
    AmrExtractor amrExtractor = new AmrExtractor();
    FakeExtractorOutput output = new FakeExtractorOutput();
    amrExtractor.init(output);
    return amrExtractor;
}
Also used : FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput)

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