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_VALUEor 2'147'483 seconds or 24.855 days.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePTS.FloatValueAn external float value getter
-
Constructor Summary
Constructors Constructor Description PTS(PTS other)Copy constructorPTS(PTS.FloatValue speed)Create new instance, initializing pts withTimeFrameI.INVALID_PTSand 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 intdiff(long currentMillis, PTS rhs)intdiffLast(PTS rhs)intget(long currentMillis)Returns thelast updated PTS, interpolated bySystem Clock Reference (SCR)delta to givencurrentMillisand playbackspeed.intgetCurrent()Returnsget(long)passingClock.currentMillis().intgetLast()Returns the last updated PTS value viaset(long, int)w/o System Clock Reference (SCR) interpolation.StringgetLastTimeStr(boolean addFractions)ReturnsgetLast()as time string representation viatoTimeStr(long, boolean).longgetSCR()Returns the System Clock Reference (SCR) in milliseconds of last PTS update viaset(long, int).StringgetSCRTimeStr(boolean addFractions)ReturnsgetSCR()as time string representation viatoTimeStr(long, boolean).floatgetSpeed()Returns the external playback speed.StringgetTimeStr(long currentMillis, boolean addFractions)Returnsget(long)as time string representation viatoTimeStr(long, boolean).booleanisEOS()Returns true ifgetLast()equals toTimeFrameI.END_OF_STREAM_PTS, indicating end of stream (EOS).booleanisValid()Returns true ifgetLast()is unequal toTimeFrameI.INVALID_PTS.voidset(long scr, int pts)Updates the PTS value with given System Clock Reference (SCR) in milliseconds.voidset(PTS other)Updates the PTS value with values from otherPTSinstance.voidsetPTS(int pts)Sets the PTS value, seeset(long, int).voidsetSCR(long currentMillis)Sets the System Clock Reference (SCR) in milliseconds of last PTS update, seeset(long, int).static inttoMillis(String v)Returns milliseconds from given string representation in '[H[H]:]m[m]:s[s][.S*]' or-1for parsing error.static inttoMillis(String v, boolean throwException)Returns milliseconds from given string representation in '[H[H]:]m[m]:s[s][.S*]'StringtoString()StringtoString(long currentMillis)static StringtoTimeStr(long millis)Returns a full time string representation 'HH:mm:ss.SSS'.static StringtoTimeStr(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_PTSand system-clock timestamp with zero.- Parameters:
speed- externalPTS.FloatValuegetter for playback speed.- See Also:
set(long, int)
-
PTS
public PTS(PTS.FloatValue speed, long scr, int pts)
Create new instance.- Parameters:
speed- externalPTS.FloatValuegetter 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 givencurrentMillisand 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, forwardsDateTimeParseExceptionto 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-1for parsing error.
-
-