Search in sources :

Example 21 with ExtractorOutput

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

the class FlacExtractorSeekTest method seeking_binarySearch_handlesSeekingForward.

@Test
public void seeking_binarySearch_handlesSeekingForward() throws IOException {
    String fileName = TEST_FILE_BINARY_SEARCH;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
    long firstSeekTimeUs = 987_000;
    TestUtil.seekToTimeUs(extractor, seekMap, firstSeekTimeUs, dataSource, trackOutput, fileUri);
    long targetSeekTimeUs = 1_234_000;
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
    assertFirstFrameAfterSeekContainsTargetSeekTime(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 22 with ExtractorOutput

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

the class FlacExtractorSeekTest method seeking_binarySearch_handlesSeekToZero.

@Test
public void seeking_binarySearch_handlesSeekToZero() throws IOException {
    String fileName = TEST_FILE_BINARY_SEARCH;
    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);
    assertFirstFrameAfterSeekContainsTargetSeekTime(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 23 with ExtractorOutput

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

the class FlacExtractorSeekTest method seeking_seekTable_handlesSeekingBackward.

@Test
public void seeking_seekTable_handlesSeekingBackward() throws IOException {
    String fileName = TEST_FILE_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);
    assertFirstFrameAfterSeekPrecedesTargetSeekTime(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 24 with ExtractorOutput

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

the class FlacExtractorSeekTest method seeking_binarySearch_handlesSeekToEoF.

@Test
public void seeking_binarySearch_handlesSeekToEoF() throws IOException {
    String fileName = TEST_FILE_BINARY_SEARCH;
    Uri fileUri = TestUtil.buildAssetUri(fileName);
    SeekMap seekMap = TestUtil.extractSeekMap(extractor, extractorOutput, dataSource, fileUri);
    FakeTrackOutput trackOutput = extractorOutput.trackOutputs.get(0);
    long targetSeekTimeUs = seekMap.getDurationUs();
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
    assertFirstFrameAfterSeekContainsTargetSeekTime(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 25 with ExtractorOutput

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

the class FlacExtractorSeekTest method flacExtractorReads_seekTable_returnSeekableSeekMap.

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

Aggregations

SeekMap (androidx.media3.extractor.SeekMap)72 Test (org.junit.Test)66 Uri (android.net.Uri)59 FakeTrackOutput (androidx.media3.test.utils.FakeTrackOutput)57 FakeExtractorOutput (androidx.media3.test.utils.FakeExtractorOutput)31 Nullable (androidx.annotation.Nullable)8 TrackOutput (androidx.media3.extractor.TrackOutput)5 Format (androidx.media3.common.Format)4 Metadata (androidx.media3.common.Metadata)4 Before (org.junit.Before)4 ExtractorInput (androidx.media3.extractor.ExtractorInput)3 MotionPhotoMetadata (androidx.media3.extractor.metadata.mp4.MotionPhotoMetadata)3 TrackIdGenerator (androidx.media3.extractor.ts.TsPayloadReader.TrackIdGenerator)3 ExtractorOutput (com.google.android.exoplayer2.extractor.ExtractorOutput)3 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)3 ParsableByteArray (androidx.media3.common.util.ParsableByteArray)2 DefaultExtractorInput (androidx.media3.extractor.DefaultExtractorInput)2 Extractor (androidx.media3.extractor.Extractor)2 ExtractorOutput (androidx.media3.extractor.ExtractorOutput)2 IndexSeekMap (androidx.media3.extractor.IndexSeekMap)2