public final class TimestampAdjuster
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static long |
DO_NOT_OFFSET
A special
firstSampleTimestampUs value indicating that presentation timestamps should
not be offset. |
| Constructor and Description |
|---|
TimestampAdjuster(long firstSampleTimestampUs) |
| Modifier and Type | Method and Description |
|---|---|
long |
adjustSampleTimestamp(long timeUs)
Offsets a timestamp in microseconds.
|
long |
adjustTsTimestamp(long pts90Khz)
Scales and offsets an MPEG-2 TS presentation timestamp considering wraparound.
|
long |
getFirstSampleTimestampUs()
Returns the last value passed to
setFirstSampleTimestampUs(long). |
long |
getLastAdjustedTimestampUs()
Returns the last value obtained from
adjustSampleTimestamp(long). |
long |
getTimestampOffsetUs()
Returns the offset between the input of
adjustSampleTimestamp(long) and its output. |
static long |
ptsToUs(long pts)
Converts a 90 kHz clock timestamp to a timestamp in microseconds.
|
void |
reset()
Resets the instance to its initial state.
|
void |
setFirstSampleTimestampUs(long firstSampleTimestampUs)
Sets the desired result of the first call to
adjustSampleTimestamp(long). |
static long |
usToPts(long us)
Converts a timestamp in microseconds to a 90 kHz clock timestamp.
|
void |
waitUntilInitialized()
Blocks the calling thread until this adjuster is initialized.
|
public static final long DO_NOT_OFFSET
firstSampleTimestampUs value indicating that presentation timestamps should
not be offset.public TimestampAdjuster(long firstSampleTimestampUs)
firstSampleTimestampUs - See setFirstSampleTimestampUs(long).public void setFirstSampleTimestampUs(long firstSampleTimestampUs)
adjustSampleTimestamp(long). Can only be
called before any timestamps have been adjusted.firstSampleTimestampUs - The first adjusted sample timestamp in microseconds, or
DO_NOT_OFFSET if presentation timestamps should not be offset.public long getFirstSampleTimestampUs()
setFirstSampleTimestampUs(long).public long getLastAdjustedTimestampUs()
adjustSampleTimestamp(long). If adjustSampleTimestamp(long) has not been called, returns the result of calling getFirstSampleTimestampUs(). If this value is DO_NOT_OFFSET, returns C.TIME_UNSET.public long getTimestampOffsetUs()
adjustSampleTimestamp(long) and its output.
If DO_NOT_OFFSET was provided to the constructor, 0 is returned. If the timestamp
adjuster is yet not initialized, C.TIME_UNSET is returned.adjustSampleTimestamp(long)'s input and output.
C.TIME_UNSET if the adjuster is not yet initialized and 0 if timestamps should not
be offset.public void reset()
public long adjustTsTimestamp(long pts90Khz)
pts90Khz - A 90 kHz clock MPEG-2 TS presentation timestamp.public long adjustSampleTimestamp(long timeUs)
timeUs - The timestamp to adjust in microseconds.public void waitUntilInitialized()
throws java.lang.InterruptedException
java.lang.InterruptedException - If the thread was interrupted.public static long ptsToUs(long pts)
pts - A 90 kHz clock timestamp.public static long usToPts(long us)
us - A value in microseconds.