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 sample timestamp in microseconds.
|
long |
adjustTsTimestamp(long pts)
Scales and offsets an MPEG-2 TS presentation timestamp considering wraparound.
|
long |
getFirstSampleTimestampUs()
Returns the first adjusted sample timestamp in microseconds.
|
long |
getLastAdjustedTimestampUs()
Returns the last adjusted timestamp.
|
long |
getTimestampOffsetUs()
Returns the offset between the input of
adjustSampleTimestamp(long) and its output. |
static long |
ptsToUs(long pts)
Converts a value in MPEG-2 timestamp units to the corresponding value 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 value in microseconds to the corresponding values in MPEG-2 timestamp units.
|
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()
public long getLastAdjustedTimestampUs()
firstSampleTimestampUs as provided to the constructor. If this value is
DO_NOT_OFFSET, returns C.TIME_UNSET.firstSampleTimestampUs is
returned unless equal to DO_NOT_OFFSET, in which case C.TIME_UNSET is
returned.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 pts)
pts - The MPEG-2 TS presentation timestamp.public long adjustSampleTimestamp(long timeUs)
timeUs - The timestamp of a sample to adjust.public void waitUntilInitialized()
throws java.lang.InterruptedException
java.lang.InterruptedException - If the thread was interrupted.public static long ptsToUs(long pts)
pts - A value in MPEG-2 timestamp units.public static long usToPts(long us)
us - A value in microseconds.