Interface ITmfTimestamp

All Superinterfaces:
Comparable<ITmfTimestamp>
All Known Implementing Classes:
TmfTimestamp, TmfTimestampDelta

public interface ITmfTimestamp extends Comparable<ITmfTimestamp>
The fundamental time reference in the TMF.

It defines a generic timestamp interface in its most basic form:

  • timestamp = [value] * 10**[scale] +/- [precision]
Where:
  • [value] is an unstructured integer value
  • [scale] is the magnitude of the value wrt some application-specific base unit (e.g. the second)
  • [precision] indicates the error on the value (useful for comparing timestamps in different scales). Default: 0.
Author:
Francois Chouinard
See Also:
  • Field Details

    • SECOND_SCALE

      static final int SECOND_SCALE
      The millisecond scale factor (10e0)
      See Also:
    • MILLISECOND_SCALE

      static final int MILLISECOND_SCALE
      The millisecond scale factor (10e-3)
      See Also:
    • MICROSECOND_SCALE

      static final int MICROSECOND_SCALE
      The microsecond scale factor (10e-6)
      See Also:
    • NANOSECOND_SCALE

      static final int NANOSECOND_SCALE
      The nanosecond scale factor (10e-9)
      See Also:
  • Method Details

    • getValue

      long getValue()
      Returns:
      the timestamp value (magnitude)
    • getScale

      int getScale()
      Returns:
      the timestamp scale (exponent)
    • toNanos

      default long toNanos()
      Gets the timestamp converted to nanoseconds, if the timestamp is larger than Long.MAX_VALUE or smaller than Long.MIN_VALUE it will be clamped to those values.
      Returns:
      the timestamp converted to a long value of nanoseconds
      Since:
      2.0
    • normalize

      @NonNull ITmfTimestamp normalize(long offset, int scale)
      Normalize (adjust scale and offset) of the timestamp
      Parameters:
      offset - the offset to apply to the timestamp value (after scaling)
      scale - the new timestamp scale
      Returns:
      a new 'adjusted' ITmfTimestamp
    • getDelta

      @NonNull ITmfTimestamp getDelta(ITmfTimestamp ts)
      Returns the difference between [this] and [ts] as a timestamp
      Parameters:
      ts - the other timestamp
      Returns:
      the time difference (this - other) as an ITmfTimestamp
    • intersects

      boolean intersects(TmfTimeRange range)
      Returns if this timestamp intersects the given time range. Borders are inclusive (for more fine-grained behavior, you can use compareTo(ITmfTimestamp).
      Parameters:
      range - The time range to compare to
      Returns:
      True if this timestamp is part of the time range, false if not
    • compareTo

      int compareTo(ITmfTimestamp ts)
      Specified by:
      compareTo in interface Comparable<ITmfTimestamp>
    • toString

      String toString(TmfTimestampFormat format)
      Format the timestamp as per the format provided
      Parameters:
      format - the timestamp formatter
      Returns:
      the formatted timestamp