BinarySearchSeeker
@UnstableApi
abstract class BinarySearchSeeker
A seeker that supports seeking within a stream by searching for the target frame using binary search.
This seeker operates on a stream that contains multiple frames (or samples). Each frame is associated with some kind of timestamps, such as stream time, or frame indices. Given a target seek time, the seeker will find the corresponding target timestamp, and perform a search operation within the stream to identify the target frame and return the byte position in the stream of the target frame.
Summary
Nested types |
|---|
|
A |
|
A |
protected class BinarySearchSeeker.SeekOperationParamsContains parameters for a pending seek operation by |
protected interface BinarySearchSeeker.SeekTimestampConverterA converter that converts seek time in stream time into target timestamp for the |
|
Represents possible search results for |
protected interface BinarySearchSeeker.TimestampSeekerA seeker that looks for a given timestamp from an input. |
Protected constructors |
|---|
BinarySearchSeeker(Constructs an instance. |
Public functions |
|
|---|---|
SeekMap! |
Returns the seek map for the stream. |
Int |
handlePendingSeek(Continues to handle the pending seek operation. |
Boolean |
Returns whether the last operation set by |
Unit |
setSeekTargetUs(timeUs: Long)Sets the target time in microseconds within the stream to seek to. |
Protected functions |
|
|---|---|
BinarySearchSeeker.SeekOperationParams! |
createSeekParamsForTargetTimeUs(timeUs: Long) |
Unit |
markSeekOperationFinished( |
Unit |
onSeekOperationFinished(foundTargetFrame: Boolean, resultPosition: Long) |
Int |
seekToPosition( |
Boolean |
skipInputUntilPosition(input: ExtractorInput!, position: Long) |
Protected properties |
|
|---|---|
BinarySearchSeeker.BinarySearchSeekMap! |
|
BinarySearchSeeker.SeekOperationParams? |
|
BinarySearchSeeker.TimestampSeeker! |
Protected constructors
BinarySearchSeeker
protected BinarySearchSeeker(
seekTimestampConverter: BinarySearchSeeker.SeekTimestampConverter!,
timestampSeeker: BinarySearchSeeker.TimestampSeeker!,
durationUs: Long,
floorTimePosition: Long,
ceilingTimePosition: Long,
floorBytePosition: Long,
ceilingBytePosition: Long,
approxBytesPerFrame: Long,
minimumSearchRange: Int
)
Constructs an instance.
| Parameters | |
|---|---|
seekTimestampConverter: BinarySearchSeeker.SeekTimestampConverter! |
The |
timestampSeeker: BinarySearchSeeker.TimestampSeeker! |
A |
durationUs: Long |
The duration of the stream in microseconds. |
floorTimePosition: Long |
The minimum timestamp value (inclusive) in the stream. |
ceilingTimePosition: Long |
The minimum timestamp value (exclusive) in the stream. |
floorBytePosition: Long |
The starting position of the frame with minimum timestamp value (inclusive) in the stream. |
ceilingBytePosition: Long |
The position after the frame with maximum timestamp value in the stream. |
approxBytesPerFrame: Long |
Approximated bytes per frame. |
minimumSearchRange: Int |
The minimum byte range that this binary seeker will operate on. If the remaining search range is smaller than this value, the search will stop, and the seeker will return the position at the floor of the range as the result. |
Public functions
handlePendingSeek
fun handlePendingSeek(
input: ExtractorInput!,
seekPositionHolder: PositionHolder!
): Int
Continues to handle the pending seek operation. Returns one of the RESULT_ values from Extractor.
| Parameters | |
|---|---|
input: ExtractorInput! |
The |
seekPositionHolder: PositionHolder! |
If |
| Throws | |
|---|---|
java.io.IOException |
If an error occurred reading from the input. |
isSeeking
fun isSeeking(): Boolean
Returns whether the last operation set by setSeekTargetUs is still pending.
setSeekTargetUs
fun setSeekTargetUs(timeUs: Long): Unit
Sets the target time in microseconds within the stream to seek to.
| Parameters | |
|---|---|
timeUs: Long |
The target time in microseconds within the stream. |
Protected functions
createSeekParamsForTargetTimeUs
protected fun createSeekParamsForTargetTimeUs(timeUs: Long): BinarySearchSeeker.SeekOperationParams!
markSeekOperationFinished
protected fun markSeekOperationFinished(
foundTargetFrame: Boolean,
resultPosition: Long
): Unit
onSeekOperationFinished
protected fun onSeekOperationFinished(foundTargetFrame: Boolean, resultPosition: Long): Unit
seekToPosition
protected fun seekToPosition(
input: ExtractorInput!,
position: Long,
seekPositionHolder: PositionHolder!
): Int
skipInputUntilPosition
protected fun skipInputUntilPosition(input: ExtractorInput!, position: Long): Boolean
| Throws | |
|---|---|
java.io.IOException |