Search in sources :

Example 96 with ExtractorOutput

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

the class FlvExtractorSeekTest method seeking_handlesSeekToZero.

@Test
public void seeking_handlesSeekToZero() throws Exception {
    String fileName = TEST_FILE_KEY_FRAME_INDEX;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    int trackId = extractorOutput.trackOutputs.keyAt(0);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(trackId);
    long targetSeekTimeUs = 0;
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
    assertFirstFrameAfterSeekIsWithinKeyFrameInterval(fileName, trackId, trackOutput, extractedFrameIndex, targetSeekTimeUs);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 97 with ExtractorOutput

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

the class FlvExtractorSeekTest method seeking_handlesSeekingBackward.

@Test
public void seeking_handlesSeekingBackward() throws Exception {
    String fileName = TEST_FILE_KEY_FRAME_INDEX;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    int trackId = extractorOutput.trackOutputs.keyAt(0);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(trackId);
    long firstSeekTimeUs = seekMap.getDurationUs() * 2 / 3;
    TestUtil.seekToTimeUs(extractor, seekMap, firstSeekTimeUs, dataSource, trackOutput, fileUri);
    long targetSeekTimeUs = seekMap.getDurationUs() / 3;
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
    assertFirstFrameAfterSeekIsWithinKeyFrameInterval(fileName, trackId, trackOutput, extractedFrameIndex, targetSeekTimeUs);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 98 with ExtractorOutput

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

the class ConstantBitrateSeekerTest method seeking_variableFrameSize_seeksNearlyExactlyToCorrectFrame.

@Test
public void seeking_variableFrameSize_seeksNearlyExactlyToCorrectFrame() throws IOException {
    String fileName = VARIABLE_FRAME_SIZE_TEST_FILE;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
    long targetSeekTimeUs = 1_234_000;
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
    assertFirstFrameAfterSeekIsWithin1FrameOfExactFrame(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 99 with ExtractorOutput

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

the class ConstantBitrateSeekerTest method mp3ExtractorReads_returnSeekableCbrSeeker.

@Test
public void mp3ExtractorReads_returnSeekableCbrSeeker() throws IOException {
    Uri fileUri = TestUtil.buildAssetUri(CONSTANT_FRAME_SIZE_TEST_FILE);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    assertThat(seekMap.getClass()).isEqualTo(ConstantBitrateSeeker.class);
    assertThat(seekMap.getDurationUs()).isEqualTo(2_784_000);
    assertThat(seekMap.isSeekable()).isTrue();
}
Also used : SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 100 with ExtractorOutput

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

the class AdtsExtractorSeekTest method seeking_handlesSeekingBackward_extractsCorrectSamples.

@Test
public void seeking_handlesSeekingBackward_extractsCorrectSamples() throws IOException {
    String fileName = TEST_FILE;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    expectedTrackOutput = TestUtil.extractAllSamplesFromFile(createAdtsExtractor(), ApplicationProvider.getApplicationContext(), fileName).trackOutputs.get(0);
    AdtsExtractor extractor = createAdtsExtractor();
    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 extractedSampleIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedSampleIndex).isNotEqualTo(-1);
    assertFirstSampleAfterSeekContainTargetSeekTime(trackOutput, targetSeekTimeUs, extractedSampleIndex);
}
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