Package com.jogamp.common.av
Class PTS
- java.lang.Object
-
- com.jogamp.common.av.PTS
-
public final class PTS extends Object
Presentation Timestamp (PTS) with added System Clock Reference (SCR) viaset(long, int)
and its interpolation viaget(long)
, as well as giving raw access viagetLast()
.The relative millisecond PTS since start of the presentation stored in integer covers a time span of 2'147'483'647 ms (see
Integer.MAX_VALUE
or 2'147'483 seconds or 24.855 days.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
PTS.FloatValue
An external float value getter
-
Constructor Summary
Constructors Constructor Description PTS(PTS other)
Copy constructorPTS(PTS.FloatValue speed)
Create new instance, initializing pts withTimeFrameI.INVALID_PTS
and system-clock timestamp with zero.PTS(PTS.FloatValue speed, long scr, int pts)
Create new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
diff(long currentMillis, PTS rhs)
int
diffLast(PTS rhs)
int
get(long currentMillis)
Returns thelast updated PTS
, interpolated bySystem Clock Reference (SCR)
delta to givencurrentMillis
and playbackspeed
.int
getCurrent()
Returnsget(long)
passingClock.currentMillis()
.int
getLast()
Returns the last updated PTS value viaset(long, int)
w/o System Clock Reference (SCR) interpolation.String
getLastTimeStr(boolean addFractions)
ReturnsgetLast()
as time string representation viatoTimeStr(long, boolean)
.long
getSCR()
Returns the System Clock Reference (SCR) in milliseconds of last PTS update viaset(long, int)
.String
getSCRTimeStr(boolean addFractions)
ReturnsgetSCR()
as time string representation viatoTimeStr(long, boolean)
.float
getSpeed()
Returns the external playback speed.String
getTimeStr(long currentMillis, boolean addFractions)
Returnsget(long)
as time string representation viatoTimeStr(long, boolean)
.boolean
isEOS()
Returns true ifgetLast()
equals toTimeFrameI.END_OF_STREAM_PTS
, indicating end of stream (EOS).boolean
isValid()
Returns true ifgetLast()
is unequal toTimeFrameI.INVALID_PTS
.void
set(long scr, int pts)
Updates the PTS value with given System Clock Reference (SCR) in milliseconds.void
set(PTS other)
Updates the PTS value with values from otherPTS
instance.void
setPTS(int pts)
Sets the PTS value, seeset(long, int)
.void
setSCR(long currentMillis)
Sets the System Clock Reference (SCR) in milliseconds of last PTS update, seeset(long, int)
.static int
toMillis(String v)
Returns milliseconds from given string representation in '[H[H]:]m[m]:s[s][.S*]' or-1
for parsing error.static int
toMillis(String v, boolean throwException)
Returns milliseconds from given string representation in '[H[H]:]m[m]:s[s][.S*]'String
toString()
String
toString(long currentMillis)
static String
toTimeStr(long millis)
Returns a full time string representation 'HH:mm:ss.SSS'.static String
toTimeStr(long millis, boolean addFractions)
Returns a time string representation '[HH:]mm:ss[.SSS]', dropping unused hour quantities and fractions of seconds optionally.
-
-
-
Constructor Detail
-
PTS
public PTS(PTS.FloatValue speed)
Create new instance, initializing pts withTimeFrameI.INVALID_PTS
and system-clock timestamp with zero.- Parameters:
speed
- externalPTS.FloatValue
getter for playback speed.- See Also:
set(long, int)
-
PTS
public PTS(PTS.FloatValue speed, long scr, int pts)
Create new instance.- Parameters:
speed
- externalPTS.FloatValue
getter for playback speed.scr
- System Clock Reference (SCR) in milliseconds of taken pts value, i.e.Clock.currentMillis()
.pts
- the presentation timestamp (PTS) in milliseconds- See Also:
set(long, int)
-
PTS
public PTS(PTS other)
Copy constructor
-
-
Method Detail
-
isValid
public boolean isValid()
Returns true ifgetLast()
is unequal toTimeFrameI.INVALID_PTS
.
-
isEOS
public boolean isEOS()
Returns true ifgetLast()
equals toTimeFrameI.END_OF_STREAM_PTS
, indicating end of stream (EOS).
-
getSCR
public long getSCR()
Returns the System Clock Reference (SCR) in milliseconds of last PTS update viaset(long, int)
.
-
getSCRTimeStr
public String getSCRTimeStr(boolean addFractions)
ReturnsgetSCR()
as time string representation viatoTimeStr(long, boolean)
.
-
getLast
public int getLast()
Returns the last updated PTS value viaset(long, int)
w/o System Clock Reference (SCR) interpolation.
-
getLastTimeStr
public String getLastTimeStr(boolean addFractions)
ReturnsgetLast()
as time string representation viatoTimeStr(long, boolean)
.
-
getSpeed
public float getSpeed()
Returns the external playback speed.
-
set
public void set(long scr, int pts)
Updates the PTS value with given System Clock Reference (SCR) in milliseconds.- Parameters:
scr
- System Clock Reference (SCR) in milliseconds of taken PTS value, i.e.Clock.currentMillis()
.pts
- the presentation timestamp (PTS) in milliseconds
-
setPTS
public void setPTS(int pts)
Sets the PTS value, seeset(long, int)
.
-
setSCR
public void setSCR(long currentMillis)
Sets the System Clock Reference (SCR) in milliseconds of last PTS update, seeset(long, int)
.
-
get
public int get(long currentMillis)
Returns thelast updated PTS
, interpolated bySystem Clock Reference (SCR)
delta to givencurrentMillis
and playbackspeed
.last_pts + (int) ( ( currentMillis - SCR ) * speed + 0.5f )
- Parameters:
currentMillis
- current system clock in milliseconds, i.e.Clock.currentMillis()
.- See Also:
set(long, int)
-
getCurrent
public int getCurrent()
Returnsget(long)
passingClock.currentMillis()
.
-
getTimeStr
public String getTimeStr(long currentMillis, boolean addFractions)
Returnsget(long)
as time string representation viatoTimeStr(long, boolean)
.
-
diffLast
public int diffLast(PTS rhs)
-
diff
public int diff(long currentMillis, PTS rhs)
-
toString
public String toString(long currentMillis)
-
toTimeStr
public static String toTimeStr(long millis, boolean addFractions)
Returns a time string representation '[HH:]mm:ss[.SSS]', dropping unused hour quantities and fractions of seconds optionally.- Parameters:
millis
- complete time in millisecondsaddFractions
- toggle for fractions of seconds- See Also:
toTimeStr(long)
-
toTimeStr
public static String toTimeStr(long millis)
Returns a full time string representation 'HH:mm:ss.SSS'.- Parameters:
millis
- complete time in milliseconds- See Also:
toTimeStr(long, boolean)
-
toMillis
public static int toMillis(String v, boolean throwException)
Returns milliseconds from given string representation in '[H[H]:]m[m]:s[s][.S*]'- Parameters:
v
- the timestamp string to parse.throwException
- iftrue
, forwardsDateTimeParseException
to caller, otherwise return-1
.
-
toMillis
public static int toMillis(String v)
Returns milliseconds from given string representation in '[H[H]:]m[m]:s[s][.S*]' or-1
for parsing error.
-
-