Search in sources :

Example 1 with FakeTrackOutput

use of androidx.media3.test.utils.FakeTrackOutput in project media by androidx.

the class FlacExtractorSeekTest method assertFirstFrameAfterSeekContainsTargetSeekTime.

private static void assertFirstFrameAfterSeekContainsTargetSeekTime(String fileName, FakeTrackOutput trackOutput, long targetSeekTimeUs, int firstFrameIndexAfterSeek) throws IOException {
    FakeTrackOutput expectedTrackOutput = getExpectedTrackOutput(fileName);
    int expectedFrameIndex = getFrameIndex(expectedTrackOutput, targetSeekTimeUs);
    trackOutput.assertSample(firstFrameIndexAfterSeek, expectedTrackOutput.getSampleData(expectedFrameIndex), expectedTrackOutput.getSampleTimeUs(expectedFrameIndex), expectedTrackOutput.getSampleFlags(expectedFrameIndex), expectedTrackOutput.getSampleCryptoData(expectedFrameIndex));
}
Also used : FakeTrackOutput(androidx.media3.test.utils.FakeTrackOutput)

Example 2 with FakeTrackOutput

use of androidx.media3.test.utils.FakeTrackOutput in project media by androidx.

the class FlacExtractorSeekTest method seeking_seekTable_handlesSeekToZero.

@Test
public void seeking_seekTable_handlesSeekToZero() 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 targetSeekTimeUs = 0;
    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 3 with FakeTrackOutput

use of androidx.media3.test.utils.FakeTrackOutput in project media by androidx.

the class FlacExtractorSeekTest method seeking_seekTable_handlesSeekingForward.

@Test
public void seeking_seekTable_handlesSeekingForward() 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 = 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);
    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 4 with FakeTrackOutput

use of androidx.media3.test.utils.FakeTrackOutput 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 5 with FakeTrackOutput

use of androidx.media3.test.utils.FakeTrackOutput in project media by androidx.

the class FlacExtractorSeekTest method seeking_seekTable_handlesSeekToEoF.

@Test
public void seeking_seekTable_handlesSeekToEoF() 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 targetSeekTimeUs = seekMap.getDurationUs();
    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)

Aggregations

FakeTrackOutput (androidx.media3.test.utils.FakeTrackOutput)70 Test (org.junit.Test)60 SeekMap (androidx.media3.extractor.SeekMap)58 Uri (android.net.Uri)50 FakeExtractorOutput (androidx.media3.test.utils.FakeExtractorOutput)31 FakeExtractorInput (androidx.media3.test.utils.FakeExtractorInput)5 Format (androidx.media3.common.Format)4 PositionHolder (androidx.media3.extractor.PositionHolder)4 Cue (androidx.media3.common.text.Cue)3 DefaultExtractorInput (androidx.media3.extractor.DefaultExtractorInput)3 ExtractorInput (androidx.media3.extractor.ExtractorInput)3 WebvttDecoder (androidx.media3.extractor.text.webvtt.WebvttDecoder)3 ParsableByteArray (androidx.media3.common.util.ParsableByteArray)1 TimestampAdjuster (androidx.media3.common.util.TimestampAdjuster)1 TrackOutput (androidx.media3.extractor.TrackOutput)1 IOException (java.io.IOException)1 Before (org.junit.Before)1