Search in sources :

Example 16 with FakeTrackOutput

use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.

the class ConstantBitrateSeekerTest method seeking_handlesSeekToEoF.

@Test
public void seeking_handlesSeekToEoF() 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 targetSeekTimeUs = seekMap.getDurationUs();
    int extractedFrameIndex = TestUtil.seekToTimeUs(extractor, seekMap, targetSeekTimeUs, dataSource, trackOutput, fileUri);
    assertThat(extractedFrameIndex).isNotEqualTo(C.INDEX_UNSET);
    assertFirstFrameAfterSeekIsExactFrame(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 17 with FakeTrackOutput

use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.

the class ConstantBitrateSeekerTest method assertFirstFrameAfterSeekIsExactFrame.

private static void assertFirstFrameAfterSeekIsExactFrame(String fileName, FakeTrackOutput trackOutput, long targetSeekTimeUs, int firstFrameIndexAfterSeek) throws IOException {
    FakeTrackOutput expectedTrackOutput = getExpectedTrackOutput(fileName);
    int exactFrameIndex = getFrameIndex(expectedTrackOutput, targetSeekTimeUs);
    assertThat(trackOutput.getSampleData(firstFrameIndexAfterSeek)).isEqualTo(expectedTrackOutput.getSampleData(exactFrameIndex));
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput)

Example 18 with FakeTrackOutput

use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.

the class FlacExtractorSeekTest method assertFirstFrameAfterSeekPrecedesTargetSeekTime.

private static void assertFirstFrameAfterSeekPrecedesTargetSeekTime(String fileName, FakeTrackOutput trackOutput, long targetSeekTimeUs, int firstFrameIndexAfterSeek) throws IOException {
    FakeTrackOutput expectedTrackOutput = getExpectedTrackOutput(fileName);
    int maxFrameIndex = getFrameIndex(expectedTrackOutput, targetSeekTimeUs);
    long firstFrameAfterSeekTimeUs = trackOutput.getSampleTimeUs(firstFrameIndexAfterSeek);
    assertThat(firstFrameAfterSeekTimeUs).isAtMost(targetSeekTimeUs);
    boolean frameFound = false;
    for (int i = maxFrameIndex; i >= 0; i--) {
        if (firstFrameAfterSeekTimeUs == expectedTrackOutput.getSampleTimeUs(i)) {
            trackOutput.assertSample(firstFrameIndexAfterSeek, expectedTrackOutput.getSampleData(i), expectedTrackOutput.getSampleTimeUs(i), expectedTrackOutput.getSampleFlags(i), expectedTrackOutput.getSampleCryptoData(i));
            frameFound = true;
            break;
        }
    }
    assertThat(frameFound).isTrue();
}
Also used : FakeTrackOutput(com.google.android.exoplayer2.testutil.FakeTrackOutput)

Example 19 with FakeTrackOutput

use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.

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(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Example 20 with FakeTrackOutput

use of com.google.android.exoplayer2.testutil.FakeTrackOutput in project ExoPlayer by google.

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(com.google.android.exoplayer2.testutil.FakeTrackOutput) SeekMap(com.google.android.exoplayer2.extractor.SeekMap) Uri(android.net.Uri) Test(org.junit.Test)

Aggregations

FakeTrackOutput (com.google.android.exoplayer2.testutil.FakeTrackOutput)71 Test (org.junit.Test)60 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)58 Uri (android.net.Uri)50 FakeExtractorOutput (com.google.android.exoplayer2.testutil.FakeExtractorOutput)32 FakeExtractorInput (com.google.android.exoplayer2.testutil.FakeExtractorInput)6 PositionHolder (com.google.android.exoplayer2.extractor.PositionHolder)5 Format (com.google.android.exoplayer2.Format)4 DefaultExtractorInput (com.google.android.exoplayer2.extractor.DefaultExtractorInput)3 ExtractorInput (com.google.android.exoplayer2.extractor.ExtractorInput)3 WebvttDecoder (com.google.android.exoplayer2.text.webvtt.WebvttDecoder)3 TrackOutput (com.google.android.exoplayer2.extractor.TrackOutput)2 TimestampAdjuster (com.google.android.exoplayer2.util.TimestampAdjuster)2 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)1 IOException (java.io.IOException)1 Before (org.junit.Before)1