Search in sources :

Example 81 with ExtractorOutput

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

the class TsExtractorSeekTest method handlePendingSeek_handlesSeekingToPositionInFile_extractsCorrectFrame.

@Test
public void handlePendingSeek_handlesSeekingToPositionInFile_extractsCorrectFrame() throws IOException {
    TsExtractor extractor = new TsExtractor();
    Uri fileUri = TestUtil.buildAssetUri(TEST_FILE);
    FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(AUDIO_TRACK_ID);
    long targetSeekTimeUs = 987_000;
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(-1);
    assertFirstFrameAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Example 82 with ExtractorOutput

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

the class TsExtractorSeekTest method handlePendingSeek_handlesSeekingBackward_extractsCorrectFrame.

@Test
public void handlePendingSeek_handlesSeekingBackward_extractsCorrectFrame() throws IOException {
    TsExtractor extractor = new TsExtractor();
    Uri fileUri = TestUtil.buildAssetUri(TEST_FILE);
    FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(AUDIO_TRACK_ID);
    long firstSeekTimeUs = 987_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);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Example 83 with ExtractorOutput

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

the class TsExtractorSeekTest method handlePendingSeek_handlesSeekToEoF_extractsLastFrame.

@Test
public void handlePendingSeek_handlesSeekToEoF_extractsLastFrame() throws IOException {
    TsExtractor extractor = new TsExtractor();
    Uri fileUri = TestUtil.buildAssetUri(TEST_FILE);
    FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(AUDIO_TRACK_ID);
    long targetSeekTimeUs = seekMap.getDurationUs();
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(-1);
    assertFirstFrameAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Example 84 with ExtractorOutput

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

the class TsExtractorSeekTest method handlePendingSeek_handlesRandomSeeksAfterReadingFileOnce_extractsCorrectFrame.

@Test
public void handlePendingSeek_handlesRandomSeeksAfterReadingFileOnce_extractsCorrectFrame() throws IOException {
    TsExtractor extractor = new TsExtractor();
    Uri fileUri = TestUtil.buildAssetUri(TEST_FILE);
    FakeExtractorOutput extractorOutput = new FakeExtractorOutput();
    readInputFileOnce(extractor, extractorOutput, fileUri);
    SeekMap seekMap = extractorOutput.seekMap;
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(AUDIO_TRACK_ID);
    long numSeek = 100;
    for (long i = 0; i < numSeek; i++) {
        long targetSeekTimeUs = random.nextInt(DURATION_US + 1);
        int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
        assertThat(extractedFrameIndex).isNotEqualTo(-1);
        assertFirstFrameAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedFrameIndex);
    }
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Example 85 with ExtractorOutput

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

the class AmrExtractorSeekTest method seeking_handlesSeekingBackward_extractsCorrectFrames_forWideBandAmr.

@Test
public void seeking_handlesSeekingBackward_extractsCorrectFrames_forWideBandAmr() throws IOException {
    String fileName = WIDE_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);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) FakeExtractorOutput(com.google.android.exoplayer2.testutil.FakeExtractorOutput) Test(org.junit.Test)

Aggregations

SeekMap (com.google.android.exoplayer2.extractor.SeekMap)79 Test (org.junit.Test)66 Uri (android.net.Uri)59 FakeTrackOutput (com.google.android.exoplayer2.testutil.FakeTrackOutput)57 FakeExtractorOutput (com.google.android.exoplayer2.testutil.FakeExtractorOutput)31 Nullable (androidx.annotation.Nullable)12 TrackOutput (com.google.android.exoplayer2.extractor.TrackOutput)9 Format (com.google.android.exoplayer2.Format)6 TrackIdGenerator (com.google.android.exoplayer2.extractor.ts.TsPayloadReader.TrackIdGenerator)6 Metadata (com.google.android.exoplayer2.metadata.Metadata)6 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)5 Extractor (com.google.android.exoplayer2.extractor.Extractor)4 OutputFrameHolder (com.google.android.exoplayer2.ext.flac.FlacBinarySearchSeeker.OutputFrameHolder)3 ExtractorInput (com.google.android.exoplayer2.extractor.ExtractorInput)3 ExtractorOutput (com.google.android.exoplayer2.extractor.ExtractorOutput)3 Mp3Extractor (com.google.android.exoplayer2.extractor.mp3.Mp3Extractor)3 Before (org.junit.Before)3 CallSuper (androidx.annotation.CallSuper)2 Format (androidx.media3.common.Format)2 Metadata (androidx.media3.common.Metadata)2