TSDuck Version 3.32-2820 (TSDuck - The MPEG Transport Stream Toolkit)
ts::TSPacketMetadata Class Referencefinal

Metadata of an MPEG-2 transport packet for tsp plugins. More...

Public Types

typedef std::bitset< LABEL_COUNTLabelSet
 A set of labels for TS packets.
 

Public Member Functions

 TSPacketMetadata ()
 Constructor.
 
void clearAllLabels ()
 Clear all labels for the TS packet.
 
void clearInputTimeStamp ()
 Clear the input time stamp.
 
void clearLabel (size_t label)
 Clear a specific label for the TS packet. More...
 
void clearLabels (const LabelSet &mask)
 Clear a specific set of labels for the TS packet. More...
 
bool deserialize (const ByteBlock &bin)
 Deserialize the content of this instance from a byteblock. More...
 
bool deserialize (const void *data, size_t size)
 Deserialize the content of this instance from a byteblock. More...
 
bool getBitrateChanged () const
 Check if the plugin has changed the transport stream bitrate. More...
 
bool getFlush () const
 Check if the packet chain shall be flushed by tsp as soon as possible. More...
 
bool getInputStuffing () const
 Check if the packet was artificially inserted as input stuffing. More...
 
TimeSource getInputTimeSource () const
 Get the identification of the source of the input time stamp. More...
 
uint64_t getInputTimeStamp () const
 Get the optional input time stamp of the packet. More...
 
bool getNullified () const
 Check if the packet was explicitly turned into a null packet by a plugin. More...
 
bool hasAllLabels (const LabelSet &mask) const
 Check if the TS packet has all labels set from a set of labels. More...
 
bool hasAnyLabel () const
 Check if the TS packet has any label set. More...
 
bool hasAnyLabel (const LabelSet &mask) const
 Check if the TS packet has any label set from a set of labels. More...
 
bool hasInputTimeStamp () const
 Check if the packet has an input time stamp. More...
 
bool hasLabel (size_t label) const
 Check if the TS packet has a specific label set. More...
 
UString inputTimeStampString (const UString &none=u"none") const
 Get the input time stamp as a string, typically for debug messages. More...
 
UString labelsString (const UString &separator=u" ", const UString &none=u"none") const
 Get the list of labels as a string, typically for debug messages. More...
 
void reset ()
 Reset the content of this instance. More...
 
void serialize (ByteBlock &bin) const
 Serialize the content of this instance into a byteblock. More...
 
size_t serialize (void *data, size_t size) const
 Serialize the content of this instance into a memory area. More...
 
void setBitrateChanged (bool on)
 Specify if the plugin has changed the transport stream bitrate. More...
 
void setFlush (bool on)
 Specify if the packet chain shall be flushed by tsp as soon as possible. More...
 
void setInputStuffing (bool on)
 Specify if the packet was artificially inserted as input stuffing. More...
 
void setInputTimeStamp (uint64_t time_stamp, uint64_t ticks_per_second, TimeSource source)
 Set the optional input time stamp of the packet. More...
 
void setLabel (size_t label)
 Set a specific label for the TS packet. More...
 
void setLabels (const LabelSet &mask)
 Set a specific set of labels for the TS packet. More...
 
void setNullified (bool on)
 Specify if the packet was explicitly turned into a null packet by a plugin. More...
 

Static Public Member Functions

static void Copy (TSPacketMetadata *dest, const TSPacketMetadata *source, size_t count)
 Copy contiguous TS packet metadata. More...
 
static void Reset (TSPacketMetadata *dest, size_t count)
 Reset contiguous TS packet metadata. More...
 

Static Public Attributes

static const LabelSet AllLabels
 A set of labels where all labels are set.
 
static constexpr size_t LABEL_COUNT = 32
 Maximum numbers of labels per TS packet. More...
 
static constexpr size_t LABEL_MAX = LABEL_COUNT - 1
 Maximum value for labels.
 
static const LabelSet NoLabel
 A set of labels where all labels are cleared (no label).
 
static constexpr uint8_t SERIALIZATION_MAGIC = SYNC_BYTE ^ 0xFF
 First "magic" byte of the structure into which a TSPacketMetadata was serialized. More...
 
static constexpr size_t SERIALIZATION_SIZE = 14
 Size in bytes of the structure into which a TSPacketMetadata can be serialized.
 

Detailed Description

Metadata of an MPEG-2 transport packet for tsp plugins.

An instance of this class is passed with each TS packet to packet processor plugins.

Member Function Documentation

◆ reset()

void ts::TSPacketMetadata::reset ( )

Reset the content of this instance.

Return to initial empty state.

◆ setInputStuffing()

void ts::TSPacketMetadata::setInputStuffing ( bool  on)
inline

Specify if the packet was artificially inserted as input stuffing.

Parameters
[in]onWhen true, the packet was artificially inserted as input stuffing.

◆ getInputStuffing()

bool ts::TSPacketMetadata::getInputStuffing ( ) const
inline

Check if the packet was artificially inserted as input stuffing.

Returns
True when the packet was artificially inserted as input stuffing.

◆ setNullified()

void ts::TSPacketMetadata::setNullified ( bool  on)
inline

Specify if the packet was explicitly turned into a null packet by a plugin.

Parameters
[in]onWhen true, the packet was explicitly turned into a null packet by a plugin.

◆ getNullified()

bool ts::TSPacketMetadata::getNullified ( ) const
inline

Check if the packet was explicitly turned into a null packet by a plugin.

Returns
True when the packet was explicitly turned into a null packet by a plugin.

◆ setFlush()

void ts::TSPacketMetadata::setFlush ( bool  on)
inline

Specify if the packet chain shall be flushed by tsp as soon as possible.

This is typically called by a packet processing plugin.

Parameters
[in]onWhen set to true by a packet processing plugin, the packet and all previously processed and buffered packets should be passed to the next processor as soon as possible.

◆ getFlush()

bool ts::TSPacketMetadata::getFlush ( ) const
inline

Check if the packet chain shall be flushed by tsp as soon as possible.

Returns
True when the packet and all previously processed and buffered packets should be passed to the next processor as soon as possible

◆ setBitrateChanged()

void ts::TSPacketMetadata::setBitrateChanged ( bool  on)
inline

Specify if the plugin has changed the transport stream bitrate.

This is typically called by a packet processing plugin.

Parameters
[in]onWhen set to true by a packet processing plugin, tsp should call its getBitrate() callback as soon as possible.

◆ getBitrateChanged()

bool ts::TSPacketMetadata::getBitrateChanged ( ) const
inline

Check if the plugin has changed the transport stream bitrate.

Returns
True when tsp should call the getBitrate() callback of the plugin as soon as possible.

◆ hasLabel()

bool ts::TSPacketMetadata::hasLabel ( size_t  label) const

Check if the TS packet has a specific label set.

Parameters
[in]labelThe label to check.
Returns
True if the TS packet has label set.

◆ hasAnyLabel() [1/2]

bool ts::TSPacketMetadata::hasAnyLabel ( ) const
inline

Check if the TS packet has any label set.

Returns
True if the TS packet has any label.

◆ hasAnyLabel() [2/2]

bool ts::TSPacketMetadata::hasAnyLabel ( const LabelSet mask) const

Check if the TS packet has any label set from a set of labels.

Parameters
[in]maskThe mask of labels to check.
Returns
True if the TS packet has any label from mask.

◆ hasAllLabels()

bool ts::TSPacketMetadata::hasAllLabels ( const LabelSet mask) const

Check if the TS packet has all labels set from a set of labels.

Parameters
[in]maskThe mask of labels to check.
Returns
True if the TS packet has all labels from mask.

◆ setLabel()

void ts::TSPacketMetadata::setLabel ( size_t  label)
inline

Set a specific label for the TS packet.

Parameters
[in]labelThe label to set.

◆ setLabels()

void ts::TSPacketMetadata::setLabels ( const LabelSet mask)

Set a specific set of labels for the TS packet.

Parameters
[in]maskThe mask of labels to set.

◆ clearLabel()

void ts::TSPacketMetadata::clearLabel ( size_t  label)
inline

Clear a specific label for the TS packet.

Parameters
[in]labelThe label to clear.

◆ clearLabels()

void ts::TSPacketMetadata::clearLabels ( const LabelSet mask)

Clear a specific set of labels for the TS packet.

Parameters
[in]maskThe mask of labels to clear.

◆ labelsString()

UString ts::TSPacketMetadata::labelsString ( const UString separator = u" ",
const UString none = u"none" 
) const

Get the list of labels as a string, typically for debug messages.

Parameters
[in]separatorSeparator between labale values.
[in]noneString to display when there is no label set.
Returns
List of labels as a string.

◆ getInputTimeStamp()

uint64_t ts::TSPacketMetadata::getInputTimeStamp ( ) const
inline

Get the optional input time stamp of the packet.

Returns
The input time stamp in PCR units (27 MHz) or INVALID_PCR if there is none.
  • The input time stamp is optional. It may be set by the input plugin or by tsp or not set at all.
  • Its precision, accuracy and reliability are unspecified. It may be set by tsp software (based on internal clock), by the receiving hardware (the NIC for instance) or by some external source (RTP or M2TS time stamp).
  • It is a monotonic clock which wraps up after MAX_PCR (at least).
  • It can also wrap up at any other input-specific value. For instance, M2TS files use 30-bit timestamps in PCR units. So, for M2TS the input time stamps wrap up every 39 seconds.
  • Although expressed in PCR units, it does not share the same reference clock with the various PCR in the transport stream. You can compare time stamp differences, not absolute values.

◆ getInputTimeSource()

TimeSource ts::TSPacketMetadata::getInputTimeSource ( ) const
inline

Get the identification of the source of the input time stamp.

Returns
An identifier for the source of the input time stamp.

◆ hasInputTimeStamp()

bool ts::TSPacketMetadata::hasInputTimeStamp ( ) const
inline

Check if the packet has an input time stamp.

Returns
True if the packet has an input time stamp.

◆ setInputTimeStamp()

void ts::TSPacketMetadata::setInputTimeStamp ( uint64_t  time_stamp,
uint64_t  ticks_per_second,
TimeSource  source 
)

Set the optional input time stamp of the packet.

Parameters
[in]time_stampInput time stamp value. This value should be taken from a monotonic clock. The time unit is specified in ticks_per_second.
[in]ticks_per_secondBase unit of the time_stamp value. This is the number of units per second. For instance, ticks_per_second should be 1000 when time_stamp is in milliseconds and it should be SYSTEM_CLOCK_FREQ when time_stamp is in PCR units. If ticks_per_second is zero, then the input time stamp is cleared.
[in]sourceIdentification of time stamp source.
See also
getInputTimeStamp()

◆ inputTimeStampString()

UString ts::TSPacketMetadata::inputTimeStampString ( const UString none = u"none") const

Get the input time stamp as a string, typically for debug messages.

Parameters
[in]noneString to display when there is no label set.
Returns
Input time stamp as a string.

◆ Copy()

static void ts::TSPacketMetadata::Copy ( TSPacketMetadata dest,
const TSPacketMetadata source,
size_t  count 
)
static

Copy contiguous TS packet metadata.

Parameters
[out]destAddress of the first contiguous TS packet metadata to write.
[in]sourceAddress of the first contiguous TS packet metadata to read.
[in]countNumber of TS packet metadata to copy.

◆ Reset()

static void ts::TSPacketMetadata::Reset ( TSPacketMetadata dest,
size_t  count 
)
static

Reset contiguous TS packet metadata.

Parameters
[out]destAddress of the first contiguous TS packet metadata to reset.
[in]countNumber of TS packet metadata to copy.

◆ serialize() [1/2]

void ts::TSPacketMetadata::serialize ( ByteBlock bin) const

Serialize the content of this instance into a byteblock.

The serialized data is a fixed size block of SERIALIZATION_SIZE bytes.

Parameters
[out]binReturned binary data.

◆ serialize() [2/2]

size_t ts::TSPacketMetadata::serialize ( void *  data,
size_t  size 
) const

Serialize the content of this instance into a memory area.

The serialized data is a fixed size block of SERIALIZATION_SIZE bytes.

Parameters
[out]dataAddress of the memory area.
[in]sizeSize in bytes of the memory area.
Returns
Size in bytes of the data, zero on error (buffer too short).

◆ deserialize() [1/2]

bool ts::TSPacketMetadata::deserialize ( const ByteBlock bin)
inline

Deserialize the content of this instance from a byteblock.

Parameters
[in]binBinary data containing a serialized instance of TSPacketMetadata.
Returns
True if everything has been deserialized. False if the input data block is too short. In the latter case, the missing field get their default value.

◆ deserialize() [2/2]

bool ts::TSPacketMetadata::deserialize ( const void *  data,
size_t  size 
)

Deserialize the content of this instance from a byteblock.

Parameters
[in]dataAddress of binary data containing a serialized instance of TSPacketMetadata.
[in]sizeSize in bytes of these data.
Returns
True if everything has been deserialized. False if the input data block is too short. In the latter case, the missing field get their default value.

Member Data Documentation

◆ LABEL_COUNT

constexpr size_t ts::TSPacketMetadata::LABEL_COUNT = 32
staticconstexpr

Maximum numbers of labels per TS packet.

A plugin can set label numbers, from 0 to 31, to any packet. Other plugins, downward in the processing chain, can check the labels of the packet.

◆ SERIALIZATION_MAGIC

constexpr uint8_t ts::TSPacketMetadata::SERIALIZATION_MAGIC = SYNC_BYTE ^ 0xFF
staticconstexpr

First "magic" byte of the structure into which a TSPacketMetadata was serialized.

Intentionally the opposite of the TS packet synchro byte.


The documentation for this class was generated from the following file: