use of androidx.media3.extractor.SeekPoint in project Telegram-FOSS by Telegram-FOSS-Team.
the class FlacDecoderJni method getSeekPoints.
/**
* Maps a seek position in microseconds to the corresponding {@link SeekMap.SeekPoints} in the
* stream.
*
* @param timeUs A seek position in microseconds.
* @return The corresponding {@link SeekMap.SeekPoints} obtained from the seek table, or {@code
* null} if the stream doesn't have a seek table.
*/
@Nullable
public SeekMap.SeekPoints getSeekPoints(long timeUs) {
long[] seekPoints = new long[4];
if (!flacGetSeekPoints(nativeDecoderContext, timeUs, seekPoints)) {
return null;
}
SeekPoint firstSeekPoint = new SeekPoint(seekPoints[0], seekPoints[1]);
SeekPoint secondSeekPoint = seekPoints[2] == seekPoints[0] ? firstSeekPoint : new SeekPoint(seekPoints[2], seekPoints[3]);
return new SeekMap.SeekPoints(firstSeekPoint, secondSeekPoint);
}
use of androidx.media3.extractor.SeekPoint in project media by androidx.
the class FlacDecoderJni method getSeekPoints.
/**
* Maps a seek position in microseconds to the corresponding {@link SeekMap.SeekPoints} in the
* stream.
*
* @param timeUs A seek position in microseconds.
* @return The corresponding {@link SeekMap.SeekPoints} obtained from the seek table, or {@code
* null} if the stream doesn't have a seek table.
*/
@Nullable
public SeekMap.SeekPoints getSeekPoints(long timeUs) {
long[] seekPoints = new long[4];
if (!flacGetSeekPoints(nativeDecoderContext, timeUs, seekPoints)) {
return null;
}
SeekPoint firstSeekPoint = new SeekPoint(seekPoints[0], seekPoints[1]);
SeekPoint secondSeekPoint = seekPoints[2] == seekPoints[0] ? firstSeekPoint : new SeekPoint(seekPoints[2], seekPoints[3]);
return new SeekMap.SeekPoints(firstSeekPoint, secondSeekPoint);
}
use of androidx.media3.extractor.SeekPoint in project media by androidx.
the class Mp4Extractor method getSeekPoints.
@Override
public SeekPoints getSeekPoints(long timeUs) {
if (checkNotNull(tracks).length == 0) {
return new SeekPoints(SeekPoint.START);
}
long firstTimeUs;
long firstOffset;
long secondTimeUs = C.TIME_UNSET;
long secondOffset = C.POSITION_UNSET;
// If we have a video track, use it to establish one or two seek points.
if (firstVideoTrackIndex != C.INDEX_UNSET) {
TrackSampleTable sampleTable = tracks[firstVideoTrackIndex].sampleTable;
int sampleIndex = getSynchronizationSampleIndex(sampleTable, timeUs);
if (sampleIndex == C.INDEX_UNSET) {
return new SeekPoints(SeekPoint.START);
}
long sampleTimeUs = sampleTable.timestampsUs[sampleIndex];
firstTimeUs = sampleTimeUs;
firstOffset = sampleTable.offsets[sampleIndex];
if (sampleTimeUs < timeUs && sampleIndex < sampleTable.sampleCount - 1) {
int secondSampleIndex = sampleTable.getIndexOfLaterOrEqualSynchronizationSample(timeUs);
if (secondSampleIndex != C.INDEX_UNSET && secondSampleIndex != sampleIndex) {
secondTimeUs = sampleTable.timestampsUs[secondSampleIndex];
secondOffset = sampleTable.offsets[secondSampleIndex];
}
}
} else {
firstTimeUs = timeUs;
firstOffset = Long.MAX_VALUE;
}
// Take into account other tracks.
for (int i = 0; i < tracks.length; i++) {
if (i != firstVideoTrackIndex) {
TrackSampleTable sampleTable = tracks[i].sampleTable;
firstOffset = maybeAdjustSeekOffset(sampleTable, firstTimeUs, firstOffset);
if (secondTimeUs != C.TIME_UNSET) {
secondOffset = maybeAdjustSeekOffset(sampleTable, secondTimeUs, secondOffset);
}
}
}
SeekPoint firstSeekPoint = new SeekPoint(firstTimeUs, firstOffset);
if (secondTimeUs == C.TIME_UNSET) {
return new SeekPoints(firstSeekPoint);
} else {
SeekPoint secondSeekPoint = new SeekPoint(secondTimeUs, secondOffset);
return new SeekPoints(firstSeekPoint, secondSeekPoint);
}
}
use of androidx.media3.extractor.SeekPoint in project media by androidx.
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);
}
}
use of androidx.media3.extractor.SeekPoint in project media by androidx.
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));
}
Aggregations