Class PTS


  • public final class PTS
    extends Object
    Presentation Timestamp (PTS) with added System Clock Reference (SCR) via set(long, int) and its interpolation via get(long), as well as giving raw access via getLast().

    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.

    • Method Detail

      • getSCR

        public long getSCR()
        Returns the System Clock Reference (SCR) in milliseconds of last PTS update via set(long, int).
      • getLast

        public int getLast()
        Returns the last updated PTS value via set(long, int) w/o System Clock Reference (SCR) interpolation.
      • 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, see set(long, int).
      • setSCR

        public void setSCR​(long currentMillis)
        Sets the System Clock Reference (SCR) in milliseconds of last PTS update, see set(long, int).
      • set

        public void set​(PTS other)
        Updates the PTS value with values from other PTS instance.
        Parameters:
        other - source PTS values
        See Also:
        get(long)
      • 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 milliseconds
        addFractions - 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 - if true, forwards DateTimeParseException 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.