Search in sources :

Example 6 with SeekPoint

use of com.google.android.exoplayer2.extractor.SeekPoint 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 7 with SeekPoint

use of com.google.android.exoplayer2.extractor.SeekPoint in project ExoPlayer by google.

the class MlltSeeker method getSeekPoints.

@Override
public SeekPoints getSeekPoints(long timeUs) {
    timeUs = Util.constrainValue(timeUs, 0, durationUs);
    Pair<Long, Long> timeMsAndPosition = linearlyInterpolate(Util.usToMs(timeUs), referenceTimesMs, referencePositions);
    timeUs = Util.msToUs(timeMsAndPosition.first);
    long position = timeMsAndPosition.second;
    return new SeekPoints(new SeekPoint(timeUs, position));
}
Also used : SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint)

Example 8 with SeekPoint

use of com.google.android.exoplayer2.extractor.SeekPoint in project ExoPlayer by google.

the class VbriSeeker method getSeekPoints.

@Override
public SeekPoints getSeekPoints(long timeUs) {
    int tableIndex = Util.binarySearchFloor(timesUs, timeUs, true, true);
    SeekPoint seekPoint = new SeekPoint(timesUs[tableIndex], positions[tableIndex]);
    if (seekPoint.timeUs >= timeUs || tableIndex == timesUs.length - 1) {
        return new SeekPoints(seekPoint);
    } else {
        SeekPoint nextSeekPoint = new SeekPoint(timesUs[tableIndex + 1], positions[tableIndex + 1]);
        return new SeekPoints(seekPoint, nextSeekPoint);
    }
}
Also used : SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint) SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint)

Example 9 with SeekPoint

use of com.google.android.exoplayer2.extractor.SeekPoint in project ExoPlayer by google.

the class XingSeeker method getSeekPoints.

@Override
public SeekPoints getSeekPoints(long timeUs) {
    if (!isSeekable()) {
        return new SeekPoints(new SeekPoint(0, dataStartPosition + xingFrameSize));
    }
    timeUs = Util.constrainValue(timeUs, 0, durationUs);
    double percent = (timeUs * 100d) / durationUs;
    double scaledPosition;
    if (percent <= 0) {
        scaledPosition = 0;
    } else if (percent >= 100) {
        scaledPosition = 256;
    } else {
        int prevTableIndex = (int) percent;
        long[] tableOfContents = Assertions.checkStateNotNull(this.tableOfContents);
        double prevScaledPosition = tableOfContents[prevTableIndex];
        double nextScaledPosition = prevTableIndex == 99 ? 256 : tableOfContents[prevTableIndex + 1];
        // Linearly interpolate between the two scaled positions.
        double interpolateFraction = percent - prevTableIndex;
        scaledPosition = prevScaledPosition + (interpolateFraction * (nextScaledPosition - prevScaledPosition));
    }
    long positionOffset = Math.round((scaledPosition / 256) * dataSize);
    // Ensure returned positions skip the frame containing the XING header.
    positionOffset = Util.constrainValue(positionOffset, xingFrameSize, dataSize - 1);
    return new SeekPoints(new SeekPoint(timeUs, dataStartPosition + positionOffset));
}
Also used : SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint)

Example 10 with SeekPoint

use of com.google.android.exoplayer2.extractor.SeekPoint in project ExoPlayer by google.

the class IndexSeeker method getSeekPoints.

@Override
public SeekPoints getSeekPoints(long timeUs) {
    int targetIndex = Util.binarySearchFloor(timesUs, timeUs, /* inclusive= */
    true, /* stayInBounds= */
    true);
    SeekPoint seekPoint = new SeekPoint(timesUs.get(targetIndex), positions.get(targetIndex));
    if (seekPoint.timeUs == timeUs || targetIndex == timesUs.size() - 1) {
        return new SeekPoints(seekPoint);
    } else {
        SeekPoint nextSeekPoint = new SeekPoint(timesUs.get(targetIndex + 1), positions.get(targetIndex + 1));
        return new SeekPoints(seekPoint, nextSeekPoint);
    }
}
Also used : SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint) SeekPoint(com.google.android.exoplayer2.extractor.SeekPoint)

Aggregations

SeekPoint (com.google.android.exoplayer2.extractor.SeekPoint)10 SeekPoints (com.google.android.exoplayer2.extractor.SeekMap.SeekPoints)3 Test (org.junit.Test)3 Nullable (androidx.annotation.Nullable)1