TSDuck v3.40-4120
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::Descriptor Class Reference

Representation of a MPEG PSI/SI descriptors in binary format. More...

#include <tsDescriptor.h>

Public Member Functions

 Descriptor ()=default
 Default constructor.
 
 Descriptor (const ByteBlock &bb)
 Constructor from full binary content.
 
 Descriptor (const ByteBlockPtr &bb, ShareMode mode)
 Constructor from full binary content.
 
 Descriptor (const Descriptor &desc, ShareMode mode)
 Copy constructor.
 
 Descriptor (const void *data, size_t size)
 Constructor from full binary content.
 
 Descriptor (Descriptor &&desc) noexcept
 Move constructor.
 
 Descriptor (DID tag, const ByteBlock &data)
 Constructor from tag and payload.
 
 Descriptor (DID tag, const void *data, size_t size)
 Constructor from tag and payload.
 
const uint8_t * content () const
 Access to the full binary content of the descriptor.
 
Descriptorcopy (const Descriptor &desc)
 Duplication.
 
AbstractDescriptorPtr deserialize (DuckContext &duck, DescriptorContext &context) const
 Deserialize the descriptor.
 
AbstractDescriptorPtr deserialize (DuckContext &duck, EDID edid) const
 Deserialize the descriptor.
 
bool fromXML (DuckContext &duck, const xml::Element *node, TID tid=TID_NULL)
 This method converts an XML node as a binary descriptor.
 
void invalidate ()
 Invalidate descriptor content.
 
bool isValid () const
 Check if a descriptor has valid content.
 
Descriptoroperator= (const Descriptor &desc)
 Assignment operator.
 
Descriptoroperator= (Descriptor &&desc) noexcept
 Move assignment operator.
 
bool operator== (const Descriptor &desc) const
 Comparison operator.
 
uint8_t * payload ()
 Access to the payload of the descriptor.
 
const uint8_t * payload () const
 Access to the payload of the descriptor.
 
size_t payloadSize () const
 Size of the payload of the descriptor.
 
void replacePayload (const ByteBlock &payload)
 Replace the payload of the descriptor.
 
void replacePayload (const void *data, size_t size)
 Replace the payload of the descriptor.
 
void resizePayload (size_t size)
 Resize (truncate or extend) the payload of the descriptor.
 
size_t size () const
 Size of the binary content of the descriptor.
 
DID tag () const
 Get the descriptor tag.
 
xml::ElementtoXML (DuckContext &duck, xml::Element *parent, DescriptorContext &context, bool force_generic=false) const
 This method converts a descriptor to XML.
 
XDID xdid () const
 Get the extension descriptor id.
 

Detailed Description

Representation of a MPEG PSI/SI descriptors in binary format.

Constructor & Destructor Documentation

◆ Descriptor() [1/7]

ts::Descriptor::Descriptor ( const Descriptor desc,
ShareMode  mode 
)

Copy constructor.

Parameters
[in]descAnother instance to copy.
[in]modeThe descriptors' data are either shared (ShareMode::SHARE) between the two descriptors or duplicated (ShareMode::COPY).

◆ Descriptor() [2/7]

ts::Descriptor::Descriptor ( Descriptor &&  desc)
noexcept

Move constructor.

Parameters
[in,out]descAnother instance to move.

◆ Descriptor() [3/7]

ts::Descriptor::Descriptor ( DID  tag,
const void *  data,
size_t  size 
)

Constructor from tag and payload.

The content is copied into the section if valid.

Parameters
[in]tagDescriptor tag.
[in]dataAddress of the descriptor payload.
[in]sizeSize in bytes of the descriptor payload.

◆ Descriptor() [4/7]

ts::Descriptor::Descriptor ( DID  tag,
const ByteBlock data 
)

Constructor from tag and payload.

The content is copied into the section if valid.

Parameters
[in]tagDescriptor tag.
[in]dataDescriptor payload.

◆ Descriptor() [5/7]

ts::Descriptor::Descriptor ( const void *  data,
size_t  size 
)

Constructor from full binary content.

The content is copied into the section if valid.

Parameters
[in]dataAddress of the descriptor data.
[in]sizeSize in bytes of the descriptor data.

◆ Descriptor() [6/7]

ts::Descriptor::Descriptor ( const ByteBlock bb)

Constructor from full binary content.

The content is copied into the section if valid.

Parameters
[in]bbDescriptor binary data.

◆ Descriptor() [7/7]

ts::Descriptor::Descriptor ( const ByteBlockPtr bb,
ShareMode  mode 
)

Constructor from full binary content.

The content is copied into the section if valid.

Parameters
[in]bbDescriptor binary data.
[in]modeThe data are either shared (ShareMode::SHARE) between the descriptor and bb or duplicated (ShareMode::COPY).

Member Function Documentation

◆ operator=() [1/2]

Descriptor & ts::Descriptor::operator= ( const Descriptor desc)

Assignment operator.

The content is referenced, and thus shared between the two objects.

Parameters
[in]descAnother instance to copy.
Returns
A reference to this object.

◆ operator=() [2/2]

Descriptor & ts::Descriptor::operator= ( Descriptor &&  desc)
noexcept

Move assignment operator.

Parameters
[in,out]descAnother instance to move.
Returns
A reference to this object.

◆ copy()

Descriptor & ts::Descriptor::copy ( const Descriptor desc)

Duplication.

Similar to assignment but the content is duplicated.

Parameters
[in]descAnother instance to copy.
Returns
A reference to this object.

◆ isValid()

bool ts::Descriptor::isValid ( ) const
inline

Check if a descriptor has valid content.

Returns
True if a descriptor has valid content.

◆ tag()

DID ts::Descriptor::tag ( ) const
inline

Get the descriptor tag.

Returns
The descriptor tag or the reserved value 0 if the descriptor is invalid.

◆ xdid()

XDID ts::Descriptor::xdid ( ) const

Get the extension descriptor id.

Returns
The extension descriptor id. For MPEG or DVB extension descriptors, this is a combination of the descriptor tag and the extension tag. For other descriptors, this is the descriptor tag only.

◆ content()

const uint8_t * ts::Descriptor::content ( ) const
inline

Access to the full binary content of the descriptor.

Returns
Address of the full binary content of the descriptor.

◆ size()

size_t ts::Descriptor::size ( ) const
inline

Size of the binary content of the descriptor.

Returns
Size of the binary content of the descriptor.

◆ payload() [1/2]

const uint8_t * ts::Descriptor::payload ( ) const
inline

Access to the payload of the descriptor.

Returns
Address of the payload of the descriptor.

◆ payload() [2/2]

uint8_t * ts::Descriptor::payload ( )
inline

Access to the payload of the descriptor.

Returns
Address of the payload of the descriptor.

◆ payloadSize()

size_t ts::Descriptor::payloadSize ( ) const
inline

Size of the payload of the descriptor.

Returns
Size in bytes of the payload of the descriptor.

◆ replacePayload() [1/2]

void ts::Descriptor::replacePayload ( const void *  data,
size_t  size 
)

Replace the payload of the descriptor.

The tag is unchanged, the size is adjusted.

Parameters
[in]dataAddress of the new payload data.
[in]sizeSize in bytes of the new payload data.

◆ replacePayload() [2/2]

void ts::Descriptor::replacePayload ( const ByteBlock payload)
inline

Replace the payload of the descriptor.

The tag is unchanged, the size is adjusted.

Parameters
[in]payloadThe new payload data.

◆ resizePayload()

void ts::Descriptor::resizePayload ( size_t  size)

Resize (truncate or extend) the payload of the descriptor.

The tag is unchanged, the size is adjusted. If the payload is extended, new bytes are zeroes.

Parameters
[in]sizeNew size in bytes of the payload.

◆ operator==()

bool ts::Descriptor::operator== ( const Descriptor desc) const

Comparison operator.

Parameters
[in]descAnother descriptor to compare.
Returns
True is the two descriptors are identical.

◆ deserialize() [1/2]

AbstractDescriptorPtr ts::Descriptor::deserialize ( DuckContext duck,
EDID  edid 
) const

Deserialize the descriptor.

Parameters
[in,out]duckTSDuck execution context.
[in]edidExtended descriptor id.
Returns
A safe pointer to an instance of a concrete subclass of AbstractDescriptor representing this descriptor. Return the null pointer if the descriptor could not be deserialized.

◆ deserialize() [2/2]

AbstractDescriptorPtr ts::Descriptor::deserialize ( DuckContext duck,
DescriptorContext context 
) const

Deserialize the descriptor.

Parameters
[in,out]duckTSDuck execution context.
[in,out]contextContext of the descriptor. Used to understand its identity.
Returns
A safe pointer to an instance of a concrete subclass of AbstractDescriptor representing this descriptor. Return the null pointer if the descriptor could not be deserialized.

◆ toXML()

xml::Element * ts::Descriptor::toXML ( DuckContext duck,
xml::Element parent,
DescriptorContext context,
bool  force_generic = false 
) const

This method converts a descriptor to XML.

If the descriptor has a specialized implementation, generate a specialized XML structure. Otherwise, generate a <generic_descriptor> node.

Parameters
[in,out]duckTSDuck execution context.
[in,out]parentThe parent node for the XML descriptor.
[in,out]contextContext of the descriptor. Used to understand its identity.
[in]force_genericForce a <generic_descriptor> node even if the descriptor can be specialized.
Returns
The new XML element or zero if the descriptor is not valid.

◆ fromXML()

bool ts::Descriptor::fromXML ( DuckContext duck,
const xml::Element node,
TID  tid = TID_NULL 
)

This method converts an XML node as a binary descriptor.

Parameters
[in,out]duckTSDuck execution context.
[in]nodeThe root of the XML descriptor.
[in]tidOptional table id of the table containing the descriptor.
Returns
True if the XML element name is a valid descriptor name, false otherwise. If the name is valid but the content is incorrect, true is returned and this object is invalidated.

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