TSDuck v3.46-4930
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::TSPacketMetadata Class Referencefinal

#include <tsTSPacketMetadata.h>

Public Member Functions

 TSPacketMetadata ()
uint8_t * auxData ()
const uint8_t * auxData () const
size_t auxDataSize () const
void clearAllLabels ()
void clearInputTimeStamp ()
void clearLabel (size_t label)
void clearLabels (const TSPacketLabelSet &mask)
bool deserialize (const ByteBlock &bin)
bool deserialize (const void *data, size_t size)
size_t getAuxData (void *data, size_t max_size) const
void getAuxData (void *data, size_t max_size, uint8_t pad) const
bool getBitrateChanged () const
bool getDatagram () const
bool getFlush () const
bool getInputStuffing () const
TimeSource getInputTimeSource () const
PCR getInputTimeStamp () const
bool getNullified () const
bool hasAllLabels (const TSPacketLabelSet &mask) const
bool hasAnyLabel () const
bool hasAnyLabel (const TSPacketLabelSet &mask) const
bool hasInputTimeStamp () const
bool hasLabel (size_t label) const
UString inputTimeStampString (const UString &none=u"none") const
TSPacketLabelSet labels () const
UString labelsString (const UString &separator=u" ", const UString &none=u"none") const
void reset ()
void serialize (ByteBlock &bin) const
size_t serialize (void *data, size_t size) const
void setAuxData (const void *data, size_t size)
void setBitrateChanged (bool on)
void setDatagram (bool on)
void setFlush (bool on)
void setInputStuffing (bool on)
template<class Rep, class Period>
void setInputTimeStamp (const cn::duration< Rep, Period > &timestamp, TimeSource source)
void setLabel (size_t label)
void setLabels (const TSPacketLabelSet &mask)
void setNullified (bool on)

Static Public Member Functions

static void Copy (TSPacketMetadata *dest, const TSPacketMetadata *source, size_t count)
static void DisplayLayout (std::ostream &out, const char *prefix="")
static void Reset (TSPacketMetadata *dest, size_t count)

Static Public Attributes

static constexpr size_t AUX_DATA_MAX_SIZE = 16
static constexpr uint8_t SERIALIZATION_MAGIC = SYNC_BYTE ^ 0xFF
static constexpr size_t SERIALIZATION_SIZE = 14

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.

Constructor & Destructor Documentation

◆ TSPacketMetadata()

ts::TSPacketMetadata::TSPacketMetadata ( )

Constructor.

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.

◆ setDatagram()

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

Specify if the packet was originally extracted from a datagram of several TS packets.

Parameters
[in]onWhen true, the packet was originally extracted from a datagram of several TS packets.

◆ getDatagram()

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

Check if the packet was originally extracted from a datagram of several TS packets.

Returns
True when the packet was originally extracted from a datagram of several TS packets.

◆ 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
inline

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 TSPacketLabelSet & mask) const
inline

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 TSPacketLabelSet & mask) const
inline

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.

◆ labels()

TSPacketLabelSet ts::TSPacketMetadata::labels ( ) const
inline

Get all labels from the TS packet.

Returns
The set of all labels from the TS packet.

◆ 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 TSPacketLabelSet & mask)
inline

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 TSPacketLabelSet & mask)
inline

Clear a specific set of labels for the TS packet.

Parameters
[in]maskThe mask of labels to clear.

◆ clearAllLabels()

void ts::TSPacketMetadata::clearAllLabels ( )
inline

Clear all labels for the TS packet.

◆ 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()

PCR 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.

◆ clearInputTimeStamp()

void ts::TSPacketMetadata::clearInputTimeStamp ( )

Clear the input time stamp.

◆ setInputTimeStamp()

template<class Rep, class Period>
void ts::TSPacketMetadata::setInputTimeStamp ( const cn::duration< Rep, Period > & timestamp,
TimeSource source )

Set the optional input time stamp of the packet.

Parameters
[in]timestampInput time stamp value. This value should be taken from a monotonic clock.
[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.

◆ setAuxData()

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

Copy bytes into the auxiliary data. The auxiliary data are made of up to 16 bytes and are attached to the packet metadata. There is no predefined usage for auxiliary data. In practice, they are read from the 16-byte trailer which can be found in some modulation systems, after the TS packet.

Parameters
data[in] Address of data to copy into the auxiliary data.
size[in] Size in bytes of the data to copy. Up to 16 bytes are used, the rest is ignored.

◆ getAuxData() [1/2]

size_t ts::TSPacketMetadata::getAuxData ( void * data,
size_t max_size ) const

Copy bytes from the auxiliary data.

Parameters
data[out] Address of user buffer to receive the auxiliary data.
max_size[in] Maximum size in bytes of the user buffer.
Returns
Number of copied bytes. Usually 0 or 16. Never more than 16.
See also
setAuxData()

◆ getAuxData() [2/2]

void ts::TSPacketMetadata::getAuxData ( void * data,
size_t max_size,
uint8_t pad ) const

Copy bytes from the auxiliary data and pad user buffer if necessary.

Parameters
data[out] Address of user buffer to receive the auxiliary data.
max_size[in] Maximum size in bytes of the user buffer.
pad[in] Pad value to copy in all additional bytes in the user's buffer if the auxiliary data are shorter than max_size.
See also
setAuxData()

◆ auxDataSize()

size_t ts::TSPacketMetadata::auxDataSize ( ) const
inline

Size in bytes of the auxiliary data.

Returns
The size in bytes of the auxiliary data.
See also
setAuxData()

◆ auxData() [1/2]

const uint8_t * ts::TSPacketMetadata::auxData ( ) const
inline

Direct access to the auxiliary data.

Returns
Address of the auxiliary data inside this object.
See also
setAuxData()

◆ auxData() [2/2]

uint8_t * ts::TSPacketMetadata::auxData ( )
inline

Direct access to the auxiliary data.

Returns
Address of the auxiliary data inside this object.
See also
setAuxData()

◆ Copy()

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()

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. The auxiliary data are not included in the serialized buffer.

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. The auxiliary data are not included in the serialized buffer.

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.

◆ DisplayLayout()

void ts::TSPacketMetadata::DisplayLayout ( std::ostream & out,
const char * prefix = "" )
static

Display the structure layout of the data structure (for debug only).

Parameters
[in,out]outOutput stream, where to display.
[in]prefixOptional prefix on each line.

Member Data Documentation

◆ AUX_DATA_MAX_SIZE

size_t ts::TSPacketMetadata::AUX_DATA_MAX_SIZE = 16
staticconstexpr

Maximum size in bytes of auxiliary data.

See also
setAuxData()

◆ SERIALIZATION_SIZE

size_t ts::TSPacketMetadata::SERIALIZATION_SIZE = 14
staticconstexpr

Size in bytes of the structure into which a TSPacketMetadata can be serialized.

◆ SERIALIZATION_MAGIC

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: