Search in sources :

Example 1 with SeekPoints

use of androidx.media3.extractor.SeekMap.SeekPoints in project ExoPlayer by google.

the class ProgressiveMediaPeriod method getAdjustedSeekPositionUs.

@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
    assertPrepared();
    if (!seekMap.isSeekable()) {
        // Treat all seeks into non-seekable media as being to t=0.
        return 0;
    }
    SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
    return seekParameters.resolveSeekPositionUs(positionUs, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
Also used : SeekPoints(com.google.android.exoplayer2.extractor.SeekMap.SeekPoints)

Example 2 with SeekPoints

use of androidx.media3.extractor.SeekMap.SeekPoints in project ExoPlayer by google.

the class XingSeekerTest method getSeekPointsAtStartOfStream.

@Test
public void getSeekPointsAtStartOfStream() {
    SeekPoints seekPoints = seeker.getSeekPoints(0);
    SeekPoint seekPoint = seekPoints.first;
    assertThat(seekPoint).isEqualTo(seekPoints.second);
    assertThat(seekPoint.timeUs).isEqualTo(0);
    assertThat(seekPoint.position).isEqualTo(XING_FRAME_POSITION + xingFrameSize);
}
Also used : SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint) SeekPoints(com.google.android.exoplayer2.extractor.SeekMap.SeekPoints) Test(org.junit.Test)

Example 3 with SeekPoints

use of androidx.media3.extractor.SeekMap.SeekPoints in project ExoPlayer by google.

the class XingSeekerTest method getTimeForAllPositions.

@Test
public void getTimeForAllPositions() {
    for (int offset = xingFrameSize; offset < DATA_SIZE_BYTES; offset++) {
        int position = XING_FRAME_POSITION + offset;
        // Test seeker.
        long timeUs = seeker.getTimeUs(position);
        SeekPoints seekPoints = seeker.getSeekPoints(timeUs);
        SeekPoint seekPoint = seekPoints.first;
        assertThat(seekPoint).isEqualTo(seekPoints.second);
        assertThat(seekPoint.position).isEqualTo(position);
        // Test seekerWithInputLength.
        timeUs = seekerWithInputLength.getTimeUs(position);
        seekPoints = seekerWithInputLength.getSeekPoints(timeUs);
        seekPoint = seekPoints.first;
        assertThat(seekPoint).isEqualTo(seekPoints.second);
        assertThat(seekPoint.position).isEqualTo(position);
    }
}
Also used : SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint) SeekPoints(com.google.android.exoplayer2.extractor.SeekMap.SeekPoints) SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint) Test(org.junit.Test)

Example 4 with SeekPoints

use of androidx.media3.extractor.SeekMap.SeekPoints in project ExoPlayer by google.

the class XingSeekerTest method getSeekPointsAtEndOfStream.

@Test
public void getSeekPointsAtEndOfStream() {
    SeekPoints seekPoints = seeker.getSeekPoints(STREAM_DURATION_US);
    SeekPoint seekPoint = seekPoints.first;
    assertThat(seekPoint).isEqualTo(seekPoints.second);
    assertThat(seekPoint.timeUs).isEqualTo(STREAM_DURATION_US);
    assertThat(seekPoint.position).isEqualTo(STREAM_LENGTH - 1);
}
Also used : SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint) SeekPoints(com.google.android.exoplayer2.extractor.SeekMap.SeekPoints) Test(org.junit.Test)

Example 5 with SeekPoints

use of androidx.media3.extractor.SeekMap.SeekPoints in project Telegram-FOSS by Telegram-FOSS-Team.

the class ProgressiveMediaPeriod method getAdjustedSeekPositionUs.

@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
    SeekMap seekMap = getPreparedState().seekMap;
    if (!seekMap.isSeekable()) {
        // Treat all seeks into non-seekable media as being to t=0.
        return 0;
    }
    SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
    return Util.resolveSeekPositionUs(positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
Also used : SeekPoints(com.google.android.exoplayer2.extractor.SeekMap.SeekPoints) SeekMap(com.google.android.exoplayer2.extractor.SeekMap)

Aggregations

SeekPoint (androidx.media3.extractor.SeekPoint)10 Test (org.junit.Test)6 SeekPoints (com.google.android.exoplayer2.extractor.SeekMap.SeekPoints)5 SeekPoints (androidx.media3.extractor.SeekMap.SeekPoints)4 SeekPoint (com.google.android.exoplayer2.extractor.SeekPoint)3 DefaultExtractorInput (androidx.media3.extractor.DefaultExtractorInput)2 ExtractorInput (androidx.media3.extractor.ExtractorInput)2 SeekMap (androidx.media3.extractor.SeekMap)2 Nullable (androidx.annotation.Nullable)1 PositionHolder (androidx.media3.extractor.PositionHolder)1 FakeExtractorInput (androidx.media3.test.utils.FakeExtractorInput)1 SeekMap (com.google.android.exoplayer2.extractor.SeekMap)1