Traits class for TimeSource values.
More...
#include <tsTS.h>
|
|
using | Duration = cn::duration< std::intmax_t, std::ratio< 1, TICKS > > |
| | Definition of the time source as a std::chrono::duration type.
|
| |
|
| static uint64_t | Add (uint64_t t, int64_t offset) |
| | Add a signed offset to a time stamp.
|
| |
| static int64_t | Diff (uint64_t t1, uint64_t t2) |
| | Compute the difference between two time stamp values (t1 - t2).
|
| |
| static uint64_t | Next (uint64_t last, PacketCounter distance, const BitRate &bitrate) |
| | Compute the time stamp of a packet, based on the equivalent time stamp of a previous packet.
|
| |
| static bool | Sequenced (uint64_t t1, uint64_t t2) |
| | Check if two time stamps are in sequence.
|
| |
| static UString | ToString (uint64_t t, bool hexa=true, bool decimal=true, bool ms=true) |
| | Convert a time stamp value to a string.
|
| |
| static bool | Wrap (uint64_t t1, uint64_t t2) |
| | Check if time stamps t1 and t2 follow each othen, in any order, after wrap up.
|
| |
| static bool | WrapUp (uint64_t t1, uint64_t t2) |
| | Check if time stamps t2 follows time t1 after wrap up.
|
| |
|
|
static constexpr size_t | BIT_SIZE = TimeSourceSuperTraits<T>::BIT_SIZE |
| | Size in bits of the time source.
|
| |
|
static constexpr size_t | HEX_DIGITS = (BIT_SIZE + 3) / 4 |
| | Number of required hexadecimal digits to represent the time source.
|
| |
|
static constexpr uint64_t | INVALID = 0xFFFFFFFFFFFFFFFF |
| | An invalid PTS and DTS value, can be used as a marker.
|
| |
|
static constexpr uint64_t | MAX = SCALE - 1 |
| | The maximum possible value for the time source.
|
| |
|
static constexpr uint64_t | SCALE = TimeSourceSuperTraits<T>::SCALE |
| | Scale factor for the modular time source.
|
| |
|
static constexpr uint64_t | TICKS = TimeSourceSuperTraits<T>::TICKS |
| | Clock frequency in Hz for the time source.
|
| |
|
static constexpr TimeSource | TYPE = T |
| | Redefine the time source type as a local declaration.
|
| |
| static constexpr uint64_t | WRAPUP_THRESHOLD = (4 * SCALE) / 5 |
| | Minimum distance between two time stamp values to consider them as wrapping up after the maximum value.
|
| |
template<
TimeSource T>
class ts::TimeSourceTraits< T >
Traits class for TimeSource values.
The traits class is generic, based on a specialization of TimeSourceSuperTraits.
◆ WrapUp()
Check if time stamps t2 follows time t1 after wrap up.
- Parameters
-
| [in] | t1 | First time value. |
| [in] | t2 | Second time value. |
- Returns
- True if t2 is probably following t1 after wrapping up. The exact criteria is that t2 wraps up after t1 and their distance is within 20% of a full time source range.
◆ Wrap()
Check if time stamps t1 and t2 follow each othen, in any order, after wrap up.
- Parameters
-
| [in] | t1 | First time value. |
| [in] | t2 | Second time value. |
- Returns
- True if t1 and t2 follow each othen, in any order, after wrap up.
◆ Sequenced()
Check if two time stamps are in sequence.
Sample application: In MPEG video, B-frames are transported out-of-sequence. Their PTS is typically lower than the previous D-frame or I-frame in the transport. A "sequenced" PTS is one that is higher than the previous sequenced PTS (with possible wrap up).
- Parameters
-
| [in] | t1 | First time value. |
| [in] | t2 | Second time value. |
- Returns
- True if t1 and t2 follow each othen, possibly after wrapping up at 2**33.
◆ Next()
Compute the time stamp of a packet, based on the equivalent time stamp of a previous packet.
- Parameters
-
| [in] | last | Time stamp in a previous packet. |
| [in] | distance | Number of TS packets since the packet with last. |
| [in] | bitrate | Constant bitrate of the stream in bits per second. |
- Returns
- The time stamp of the packet which is at the specified distance from the packet with last or INVALID if a parameter is incorrect.
◆ Add()
Add a signed offset to a time stamp.
- Parameters
-
| [in] | t | Initial time value. |
| [in] | offset | Signed offset. |
- Returns
- The adjusted time value or INVALID if a parameter is incorrect.
◆ Diff()
Compute the difference between two time stamp values (t1 - t2).
- Parameters
-
| [in] | t1 | First time value. |
| [in] | t2 | Second time value. |
- Returns
- The difference between the two values or INVALID if a parameter is incorrect.
◆ ToString()
Convert a time stamp value to a string.
- Parameters
-
| [in] | t | The time value. |
| [in] | hexa | If true (the defaul), include hexadecimal value. |
| [in] | decimal | If true (the defaul), include decimal value. |
| [in] | ms | If true (the defaul), include the equivalent duration in milliseconds. |
- Returns
- The formatted string.
◆ WRAPUP_THRESHOLD
Minimum distance between two time stamp values to consider them as wrapping up after the maximum value.
Because time sources are modular values, they wrap up after MAX. It is common to consider, for instance, that value 4 "follows" MAX-4, even though 4 < MAX-4. The exact criteria is that two time stamp values are considered as following each other if their distance is within 20% of a full time source range.
The documentation for this class was generated from the following file: