Search in sources :

Example 56 with FakeExtractorOutput

use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.

the class SubtitleExtractorTest method seek_afterRelease_fails.

@Test
public void seek_afterRelease_fails() {
    SubtitleExtractor extractor = new SubtitleExtractor(new WebvttDecoder(), new Format.Builder().build());
    FakeExtractorOutput output = new FakeExtractorOutput();
    extractor.init(output);
    extractor.release();
    assertThrows(IllegalStateException.class, () -> extractor.seek(0, 0));
}
Also used : WebvttDecoder(com.google.android.exoplayer2.text.webvtt.WebvttDecoder) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Example 57 with FakeExtractorOutput

use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.

the class SubtitleExtractorTest method released_calledTwice.

@Test
public void released_calledTwice() {
    SubtitleExtractor extractor = new SubtitleExtractor(new WebvttDecoder(), new Format.Builder().build());
    FakeExtractorOutput output = new FakeExtractorOutput();
    extractor.init(output);
    extractor.release();
    extractor.release();
// Calling realease() twice does not throw an exception.
}
Also used : WebvttDecoder(com.google.android.exoplayer2.text.webvtt.WebvttDecoder) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Example 58 with FakeExtractorOutput

use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.

the class AdtsReaderTest method setUp.

@Before
public void setUp() throws Exception {
    FakeExtractorOutput fakeExtractorOutput = new FakeExtractorOutput();
    adtsOutput = fakeExtractorOutput.track(0, C.TRACK_TYPE_AUDIO);
    id3Output = fakeExtractorOutput.track(1, C.TRACK_TYPE_METADATA);
    adtsReader = new AdtsReader(true);
    TrackIdGenerator idGenerator = new TrackIdGenerator(0, 1);
    adtsReader.createTracks(fakeExtractorOutput, idGenerator);
    data = new ParsableByteArray(TEST_DATA);
    firstFeed = true;
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) TrackIdGenerator(com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Before(org.junit.Before)

Example 59 with FakeExtractorOutput

use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.

the class IndexSeekerTest method mp3ExtractorReads_correctsInexactDuration.

@Test
public void mp3ExtractorReads_correctsInexactDuration() throws Exception {
    FakeExtractorOutput extractorOutput = TestUtil.extractAllSamplesFromFile(extractor, ApplicationProvider.getApplicationContext(), TEST_FILE_NO_SEEK_TABLE);
    SeekMap seekMap = extractorOutput.seekMap;
    assertThat(seekMap.getDurationUs()).isEqualTo(TEST_FILE_NO_SEEK_TABLE_DURATION);
}
Also used : SeekMap(com.google.android.exoplayer2.extractor.SeekMap) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Example 60 with FakeExtractorOutput

use of com.google.android.exoplayer2.testutil.FakeExtractorOutput in project ExoPlayer by google.

the class TsExtractorTest method customPesReader.

@Test
public void customPesReader() throws Exception {
    CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(true, false);
    TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0), factory);
    FakeExtractorInput input = new FakeExtractorInput.Builder().setData(TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), "media/ts/sample_h262_mpeg_audio.ts")).setSimulateIOErrors(false).setSimulateUnknownLength(false).setSimulatePartialReads(false).build();
    FakeExtractorOutput output = new FakeExtractorOutput();
    tsExtractor.init(output);
    PositionHolder seekPositionHolder = new PositionHolder();
    int readResult = Extractor.RESULT_CONTINUE;
    while (readResult != Extractor.RESULT_END_OF_INPUT) {
        readResult = tsExtractor.read(input, seekPositionHolder);
        if (readResult == Extractor.RESULT_SEEK) {
            input.setPosition((int) seekPositionHolder.position);
        }
    }
    CustomEsReader reader = factory.esReader;
    assertThat(reader.packetsRead).isEqualTo(2);
    TrackOutput trackOutput = reader.getTrackOutput();
    assertThat(trackOutput == output.trackOutputs.get(257)).isTrue();
    assertThat(((FakeTrackOutput) trackOutput).lastFormat).isEqualTo(new Format.Builder().setId("1/257").setSampleMimeType("mime").setLanguage("und").build());
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) TimestampAdjuster(com.google.android.exoplayer2.util.TimestampAdjuster) Format(com.google.android.exoplayer2.Format) PositionHolder(com.google.android.exoplayer2.extractor.PositionHolder) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) TrackOutput(com.google.android.exoplayer2.extractor.TrackOutput) FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) Test(org.junit.Test)

Aggregations

FakeExtractorOutput (com.google.android.exoplayer2.testutil.FakeExtractorOutput)52 Test (org.junit.Test)43 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)35 FakeTrackOutput (com.google.android.exoplayer2.testutil.FakeTrackOutput)32 Uri (android.net.Uri)25 FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)11 PositionHolder (com.google.android.exoplayer2.extractor.PositionHolder)10 WebvttDecoder (com.google.android.exoplayer2.text.webvtt.WebvttDecoder)6 TimestampAdjuster (com.google.android.exoplayer2.util.TimestampAdjuster)6 Before (org.junit.Before)6 Format (com.google.android.exoplayer2.Format)4 ExtractorInput (com.google.android.exoplayer2.extractor.ExtractorInput)4 DefaultExtractorInput (com.google.android.exoplayer2.extractor.DefaultExtractorInput)3 TrackOutput (com.google.android.exoplayer2.extractor.TrackOutput)2 SimulatedIOException (com.google.android.exoplayer2.testutil.FakeExtractorInput.SimulatedIOException)2 IOException (java.io.IOException)2 TrackIdGenerator (com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator)1 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)1