Search in sources :

Example 1 with PositionHolder

use of androidx.media3.extractor.PositionHolder in project ExoPlayer by google.

the class TsExtractorTest method testCustomInitialSectionReader.

public void testCustomInitialSectionReader() throws Exception {
    CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(false, true);
    TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_NORMAL, new TimestampAdjuster(0), factory);
    FakeExtractorInput input = new FakeExtractorInput.Builder().setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample_with_sdt.ts")).setSimulateIOErrors(false).setSimulateUnknownLength(false).setSimulatePartialReads(false).build();
    tsExtractor.init(new FakeExtractorOutput());
    PositionHolder seekPositionHolder = new PositionHolder();
    int readResult = Extractor.RESULT_CONTINUE;
    while (readResult != Extractor.RESULT_END_OF_INPUT) {
        readResult = tsExtractor.read(input, seekPositionHolder);
    }
    assertEquals(1, factory.sdtReader.consumedSdts);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) PositionHolder(com.google.android.exoplayer2.extractor.PositionHolder) TimestampAdjuster(com.google.android.exoplayer2.util.TimestampAdjuster) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput)

Example 2 with PositionHolder

use of androidx.media3.extractor.PositionHolder in project ExoPlayer by google.

the class PsDurationReaderTest method setUp.

@Before
public void setUp() {
    tsDurationReader = new PsDurationReader();
    seekPositionHolder = new PositionHolder();
}
Also used : PositionHolder(com.google.android.exoplayer2.extractor.PositionHolder) Before(org.junit.Before)

Example 3 with PositionHolder

use of androidx.media3.extractor.PositionHolder in project ExoPlayer by google.

the class PsExtractorSeekTest method setUp.

@Before
public void setUp() throws IOException {
    expectedOutput = new FakeExtractorOutput();
    positionHolder = new PositionHolder();
    extractAllSamplesFromFileToExpectedOutput(ApplicationProvider.getApplicationContext(), PS_FILE_PATH);
    expectedTrackOutput = expectedOutput.trackOutputs.get(VIDEO_TRACK_ID);
    dataSource = new DefaultDataSource.Factory(ApplicationProvider.getApplicationContext()).createDataSource();
    totalInputLength = readInputLength();
}
Also used : PositionHolder(com.google.android.exoplayer2.extractor.PositionHolder) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Before(org.junit.Before)

Example 4 with PositionHolder

use of androidx.media3.extractor.PositionHolder in project ExoPlayer by google.

the class TsExtractorTest method customInitialSectionReader.

@Test
public void customInitialSectionReader() throws Exception {
    CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(false, true);
    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_with_sdt.ts")).setSimulateIOErrors(false).setSimulateUnknownLength(false).setSimulatePartialReads(false).build();
    tsExtractor.init(new FakeExtractorOutput());
    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);
        }
    }
    assertThat(factory.sdtReader.consumedSdts).isEqualTo(2);
}
Also used : FakeExtractorInput(com.google.android.exoplayer2.testutil.FakeExtractorInput) PositionHolder(com.google.android.exoplayer2.extractor.PositionHolder) TimestampAdjuster(com.google.android.exoplayer2.util.TimestampAdjuster) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Example 5 with PositionHolder

use of androidx.media3.extractor.PositionHolder in project ExoPlayer by google.

the class TsExtractorSeekTest method setUp.

@Before
public void setUp() throws IOException {
    positionHolder = new PositionHolder();
    expectedTrackOutput = TestUtil.extractAllSamplesFromFile(new TsExtractor(), ApplicationProvider.getApplicationContext(), TEST_FILE).trackOutputs.get(AUDIO_TRACK_ID);
    dataSource = new DefaultDataSource.Factory(ApplicationProvider.getApplicationContext()).createDataSource();
}
Also used : PositionHolder(com.google.android.exoplayer2.extractor.PositionHolder) Before(org.junit.Before)

Aggregations

PositionHolder (com.google.android.exoplayer2.extractor.PositionHolder)22 Test (org.junit.Test)22 PositionHolder (androidx.media3.extractor.PositionHolder)19 FakeExtractorInput (androidx.media3.test.utils.FakeExtractorInput)14 FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)12 Before (org.junit.Before)8 ExtractorInput (androidx.media3.extractor.ExtractorInput)7 DefaultExtractorInput (androidx.media3.extractor.DefaultExtractorInput)6 FakeExtractorOutput (com.google.android.exoplayer2.testutil.FakeExtractorOutput)6 IOException (java.io.IOException)6 Nullable (androidx.annotation.Nullable)5 ParserException (androidx.media3.common.ParserException)5 ParserException (com.google.android.exoplayer2.ParserException)5 ParsableByteArray (androidx.media3.common.util.ParsableByteArray)4 FakeExtractorOutput (androidx.media3.test.utils.FakeExtractorOutput)4 TimestampAdjuster (com.google.android.exoplayer2.util.TimestampAdjuster)4 SeekMap (androidx.media3.extractor.SeekMap)3 SeekPoint (androidx.media3.extractor.SeekPoint)3 TrackOutput (androidx.media3.extractor.TrackOutput)3 DefaultExtractorInput (com.google.android.exoplayer2.extractor.DefaultExtractorInput)3