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);
}
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);
}
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);
}
}
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);
}
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);
}
Aggregations