TSDuck v3.46-4964
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::TimeSourceTraits< T > Class Template Reference

#include <tsTS.h>

Public Types

using Duration = cn::duration<std::intmax_t, std::ratio<1, TICKS>>

Static Public Member Functions

static uint64_t Add (uint64_t t, int64_t offset)
static int64_t Diff (uint64_t t1, uint64_t t2)
static uint64_t Next (uint64_t last, PacketCounter distance, const BitRate &bitrate)
static bool Sequenced (uint64_t t1, uint64_t t2)
static UString ToString (uint64_t t, bool hexa=true, bool decimal=true, bool ms=true)
static bool Wrap (uint64_t t1, uint64_t t2)
static bool WrapUp (uint64_t t1, uint64_t t2)

Static Public Attributes

static constexpr size_t BIT_SIZE = TimeSourceSuperTraits<T>::BIT_SIZE
static constexpr size_t HEX_DIGITS = (BIT_SIZE + 3) / 4
static constexpr uint64_t INVALID = 0xFFFFFFFFFFFFFFFF
static constexpr uint64_t MAX = SCALE - 1
static constexpr uint64_t SCALE = TimeSourceSuperTraits<T>::SCALE
static constexpr uint64_t TICKS = TimeSourceSuperTraits<T>::TICKS
static constexpr TimeSource TYPE = T
static constexpr uint64_t WRAPUP_THRESHOLD = (4 * SCALE) / 5

Detailed Description

template<TimeSource T>
class ts::TimeSourceTraits< T >

Traits class for TimeSource values. The traits class is generic, based on a specialization of TimeSourceSuperTraits.

Member Typedef Documentation

◆ Duration

template<TimeSource T>
using ts::TimeSourceTraits< T >::Duration = cn::duration<std::intmax_t, std::ratio<1, TICKS>>

Definition of the time source as a std::chrono::duration type.

Member Function Documentation

◆ WrapUp()

template<TimeSource T>
bool ts::TimeSourceTraits< T >::WrapUp ( uint64_t t1,
uint64_t t2 )
inlinestatic

Check if time stamps t2 follows time t1 after wrap up.

Parameters
[in]t1First time value.
[in]t2Second 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()

template<TimeSource T>
bool ts::TimeSourceTraits< T >::Wrap ( uint64_t t1,
uint64_t t2 )
inlinestatic

Check if time stamps t1 and t2 follow each other, in any order, after wrap up.

Parameters
[in]t1First time value.
[in]t2Second time value.
Returns
True if t1 and t2 follow each other, in any order, after wrap up.

◆ Sequenced()

template<TimeSource T>
bool ts::TimeSourceTraits< T >::Sequenced ( uint64_t t1,
uint64_t t2 )
inlinestatic

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]t1First time value.
[in]t2Second time value.
Returns
True if t1 and t2 follow each other, possibly after wrapping down after max.

◆ Next()

template<ts::TimeSource T>
uint64_t ts::TimeSourceTraits< T >::Next ( uint64_t last,
PacketCounter distance,
const BitRate & bitrate )
static

Compute the time stamp of a packet, based on the equivalent time stamp of a previous packet.

Parameters
[in]lastTime stamp in a previous packet.
[in]distanceNumber of TS packets since the packet with last.
[in]bitrateConstant 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()

template<ts::TimeSource T>
uint64_t ts::TimeSourceTraits< T >::Add ( uint64_t t,
int64_t offset )
static

Add a signed offset to a time stamp.

Parameters
[in]tInitial time value.
[in]offsetSigned offset.
Returns
The adjusted time value or INVALID if a parameter is incorrect.

◆ Diff()

template<ts::TimeSource T>
int64_t ts::TimeSourceTraits< T >::Diff ( uint64_t t1,
uint64_t t2 )
static

Compute the difference between two time stamp values (t1 - t2).

Parameters
[in]t1First time value.
[in]t2Second time value.
Returns
The difference between the two values or INVALID if a parameter is incorrect.

◆ ToString()

template<ts::TimeSource T>
ts::UString ts::TimeSourceTraits< T >::ToString ( uint64_t t,
bool hexa = true,
bool decimal = true,
bool ms = true )
static

Convert a time stamp value to a string.

Parameters
[in]tThe time value.
[in]hexaIf true (the defaul), include hexadecimal value.
[in]decimalIf true (the defaul), include decimal value.
[in]msIf true (the defaul), include the equivalent duration in milliseconds.
Returns
The formatted string.

Member Data Documentation

◆ TYPE

template<TimeSource T>
TimeSource ts::TimeSourceTraits< T >::TYPE = T
staticconstexpr

Redefine the time source type as a local declaration.

◆ TICKS

template<TimeSource T>
uint64_t ts::TimeSourceTraits< T >::TICKS = TimeSourceSuperTraits<T>::TICKS
staticconstexpr

Clock frequency in Hz for the time source.

◆ BIT_SIZE

template<TimeSource T>
size_t ts::TimeSourceTraits< T >::BIT_SIZE = TimeSourceSuperTraits<T>::BIT_SIZE
staticconstexpr

Size in bits of the time source.

◆ SCALE

template<TimeSource T>
uint64_t ts::TimeSourceTraits< T >::SCALE = TimeSourceSuperTraits<T>::SCALE
staticconstexpr

Scale factor for the modular time source.

◆ MAX

template<TimeSource T>
uint64_t ts::TimeSourceTraits< T >::MAX = SCALE - 1
staticconstexpr

The maximum possible value for the time source.

◆ INVALID

template<TimeSource T>
uint64_t ts::TimeSourceTraits< T >::INVALID = 0xFFFFFFFFFFFFFFFF
staticconstexpr

An invalid PTS and DTS value, can be used as a marker.

◆ HEX_DIGITS

template<TimeSource T>
size_t ts::TimeSourceTraits< T >::HEX_DIGITS = (BIT_SIZE + 3) / 4
staticconstexpr

Number of required hexadecimal digits to represent the time source.

◆ WRAPUP_THRESHOLD

template<TimeSource T>
uint64_t ts::TimeSourceTraits< T >::WRAPUP_THRESHOLD = (4 * SCALE) / 5
staticconstexpr

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: