Interface ITmfTimestamp
- All Superinterfaces:
Comparable<ITmfTimestamp>
- All Known Implementing Classes:
TmfTimestamp
,TmfTimestampDelta
The fundamental time reference in the TMF.
It defines a generic timestamp interface in its most basic form:
- timestamp = [value] * 10**[scale] +/- [precision]
- [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 Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The microsecond scale factor (10e-6)static final int
The millisecond scale factor (10e-3)static final int
The nanosecond scale factor (10e-9)static final int
The millisecond scale factor (10e0) -
Method Summary
Modifier and TypeMethodDescriptionint
@NonNull ITmfTimestamp
Returns the difference between [this] and [ts] as a timestampint
getScale()
long
getValue()
boolean
intersects
(TmfTimeRange range) Returns if this timestamp intersects the given time range.@NonNull ITmfTimestamp
normalize
(long offset, int scale) Normalize (adjust scale and offset) of the timestampdefault long
toNanos()
Gets the timestamp converted to nanoseconds, if the timestamp is larger thanLong.MAX_VALUE
or smaller thanLong.MIN_VALUE
it will be clamped to those values.toString
(TmfTimestampFormat format) Format the timestamp as per the format provided
-
Field Details
-
SECOND_SCALE
static final int SECOND_SCALEThe millisecond scale factor (10e0)- See Also:
-
MILLISECOND_SCALE
static final int MILLISECOND_SCALEThe millisecond scale factor (10e-3)- See Also:
-
MICROSECOND_SCALE
static final int MICROSECOND_SCALEThe microsecond scale factor (10e-6)- See Also:
-
NANOSECOND_SCALE
static final int NANOSECOND_SCALEThe 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 thanLong.MAX_VALUE
or smaller thanLong.MIN_VALUE
it will be clamped to those values.- Returns:
- the timestamp converted to a long value of nanoseconds
- Since:
- 2.0
-
normalize
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
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
Returns if this timestamp intersects the given time range. Borders are inclusive (for more fine-grained behavior, you can usecompareTo(ITmfTimestamp)
.- Parameters:
range
- The time range to compare to- Returns:
- True if this timestamp is part of the time range, false if not
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ITmfTimestamp>
-
toString
Format the timestamp as per the format provided- Parameters:
format
- the timestamp formatter- Returns:
- the formatted timestamp
-