Search in sources :

Example 96 with Extractor

use of androidx.media3.extractor.Extractor in project media by androidx.

the class FlacExtractorSeekTest method flacExtractorReads_unseekable_returnUnseekableSeekMap.

@Test
public void flacExtractorReads_unseekable_returnUnseekableSeekMap() throws IOException {
    Uri fileUri = TestUtil.buildAssetUri(TEST_FILE_UNSEEKABLE);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    assertThat(seekMap).isNotNull();
    assertThat(seekMap.getDurationUs()).isEqualTo(C.TIME_UNSET);
    assertThat(seekMap.isSeekable()).isFalse();
}
Also used : SeekMap(androidx.media3.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 97 with Extractor

use of androidx.media3.extractor.Extractor in project media by androidx.

the class ConstantBitrateSeekerTest method seeking_handlesSeekingBackward.

@Test
public void seeking_handlesSeekingBackward() throws IOException {
    String fileName = CONSTANT_FRAME_SIZE_TEST_FILE;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
    long firstSeekTimeUs = 1_234_000;
    TestUtil.seekToTimeUs(extractor, seekMap, firstSeekTimeUs, dataSource, trackOutput, fileUri);
    long targetSeekTimeUs = 987_000;
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
    assertFirstFrameAfterSeekIsExactFrame(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
}
Also used : FakeTrackOutput(androidx.media3.test.utils.FakeTrackOutput) SeekMap(androidx.media3.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 98 with Extractor

use of androidx.media3.extractor.Extractor in project media by androidx.

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(androidx.media3.test.utils.FakeTrackOutput) SeekMap(androidx.media3.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 99 with Extractor

use of androidx.media3.extractor.Extractor in project media by androidx.

the class IndexSeekerTest method seeking_handlesSeekingBackward.

@Test
public void seeking_handlesSeekingBackward() throws Exception {
    String fileName = TEST_FILE_NO_SEEK_TABLE;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
    long firstSeekTimeUs = 1_234_000;
    TestUtil.seekToTimeUs(extractor, seekMap, firstSeekTimeUs, dataSource, trackOutput, fileUri);
    long targetSeekTimeUs = 987_000;
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
    assertFirstFrameAfterSeekIsWithinMinDifference(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
    assertFirstFrameAfterSeekHasCorrectData(fileName, trackOutput, extractedFrameIndex);
}
Also used : FakeTrackOutput(androidx.media3.test.utils.FakeTrackOutput) SeekMap(androidx.media3.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 100 with Extractor

use of androidx.media3.extractor.Extractor in project media by androidx.

the class IndexSeekerTest method seeking_handlesSeekToZero.

@Test
public void seeking_handlesSeekToZero() throws Exception {
    String fileName = TEST_FILE_NO_SEEK_TABLE;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
    long targetSeekTimeUs = 0;
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
    assertFirstFrameAfterSeekIsWithinMinDifference(fileName, trackOutput, targetSeekTimeUs, extractedFrameIndex);
    assertFirstFrameAfterSeekHasCorrectData(fileName, trackOutput, extractedFrameIndex);
}
Also used : FakeTrackOutput(androidx.media3.test.utils.FakeTrackOutput) SeekMap(androidx.media3.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)87 SeekMap (androidx.media3.extractor.SeekMap)73 Uri (android.net.Uri)67 FakeTrackOutput (androidx.media3.test.utils.FakeTrackOutput)59 FakeExtractorOutput (androidx.media3.test.utils.FakeExtractorOutput)44 Extractor (com.google.android.exoplayer2.extractor.Extractor)18 Nullable (androidx.annotation.Nullable)12 ExtractorInput (androidx.media3.extractor.ExtractorInput)12 FakeExtractorInput (androidx.media3.test.utils.FakeExtractorInput)12 FragmentedMp4Extractor (com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor)10 DefaultExtractorInput (androidx.media3.extractor.DefaultExtractorInput)9 WebvttDecoder (androidx.media3.extractor.text.webvtt.WebvttDecoder)8 Mp3Extractor (com.google.android.exoplayer2.extractor.mp3.Mp3Extractor)8 Extractor (androidx.media3.extractor.Extractor)7 Ac3Extractor (com.google.android.exoplayer2.extractor.ts.Ac3Extractor)7 AdtsExtractor (com.google.android.exoplayer2.extractor.ts.AdtsExtractor)7 TsExtractor (com.google.android.exoplayer2.extractor.ts.TsExtractor)7 Format (androidx.media3.common.Format)6 Mp3Extractor (androidx.media3.extractor.mp3.Mp3Extractor)6 FragmentedMp4Extractor (androidx.media3.extractor.mp4.FragmentedMp4Extractor)6