TSDuck v3.43-4441
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches

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

#include <tsDescriptor.h>

Inheritance diagram for ts::Descriptor:
Collaboration diagram for ts::Descriptor:

Public Types

using SuperClass = DataBlock< 8, 8 >
 Explicit reference to superclass.
 

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.
 
virtual ~Descriptor () override
 Virtual destructor.
 
virtual void clear ()
 Clear data content.
 
virtual const uint8_t * content () const
 Access to the full binary content of the data.
 
DataBlockcopy (const DataBlock &other)
 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.
 
bool fromXML (DuckContext &duck, EDID &edid, const xml::Element *node, TID tid=TID_NULL)
 This method converts an XML node as a binary descriptor.
 
void invalidate ()
 Invalidate descriptor content.
 
virtual bool isValid () const
 Check if the data structure has valid content.
 
bool matchContent (const ByteBlock &pattern, const ByteBlock &mask=ByteBlock()) const
 Check if the start of the data matches a given pattern.
 
bool operator== (const DataBlock &other) const
 Equality operator.
 
bool operator== (const Descriptor &other) 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.
 
size_t rawDataSize () const
 Size of the complete binary raw data containing the logical structure.
 
void reload (const ByteBlock &content)
 Reload from full binary content.
 
void reload (const ByteBlockPtr &content_ptr)
 Reload from full binary content.
 
void reload (const void *content, size_t content_size)
 Reload from full binary content.
 
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.
 
virtual size_t size () const
 Size of the logical binary content of the data.
 
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.
 

Static Public Member Functions

static size_t GetLengthField (const void *content, size_t content_size)
 Static method to extract the content of the length field.
 
static bool ValidateLengthField (const void *content, size_t content_size, bool allow_extra_data)
 Static method to validate the content of the length field.
 

Static Public Attributes

static constexpr size_t AFTER_LEN_BYTE_OFFSET
 Offset in bytes of the next byte after the length field.
 
static constexpr size_t LEN_BIT_OFFSET
 Offset in bits of the length field from the beginning of the structure.
 
static constexpr size_t LEN_BIT_SIZE
 Size in bits of the length field.
 
static constexpr bool UNBOUNDED_IS_ALLOWED
 If true, the length field allows zero as an "unbounded" value.
 

Protected Member Functions

void rwAppend (const void *data, size_t dsize)
 Append raw data to the full binary content of the data for subclasses.
 
uint8_t * rwContent ()
 Read/write access to the full binary content of the data for subclasses.
 
void rwResize (size_t s)
 Resize the full binary content of the data for subclasses.
 

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

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

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

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

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

Constructor from full binary content.

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

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

◆ 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==() [1/2]

bool ts::Descriptor::operator== ( const Descriptor other) const
inline

Comparison operator.

Parameters
[in]otherAnother 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() [1/2]

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.

◆ fromXML() [2/2]

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

This method converts an XML node as a binary descriptor.

Parameters
[in,out]duckTSDuck execution context.
[out]edidExtended descriptor id of the XML descriptor.
[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.

◆ isValid()

virtual bool ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::isValid ( ) const
virtualinherited

Check if the data structure has valid content.

The base implementation only checks that the binary data are allocated. The various constructors or methods which replace the binary content already check the validity of the length field, when there is one. Subclasses may override this method with additional checks.

Returns
True if the descriptor has valid content.

◆ reload() [1/3]

void ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::reload ( const void *  content,
size_t  content_size 
)
inherited

Reload from full binary content.

Parameters
[in]contentAddress of the binary packet data.
[in]content_sizeSize in bytes of the packet.

◆ reload() [2/3]

void ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::reload ( const ByteBlock content)
inherited

Reload from full binary content.

Parameters
[in]contentBinary packet data. The content is copied into a new byte block.

◆ reload() [3/3]

void ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::reload ( const ByteBlockPtr content_ptr)
inherited

Reload from full binary content.

Parameters
[in]content_ptrSafe pointer to the binary packet data. The content is referenced, and thus shared. Do not modify the referenced ByteBlock from outside the DataBlock.

◆ copy()

DataBlock & ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::copy ( const DataBlock< 8, 8 > &  other)
inherited

Duplication.

Similar to assignment but the data are duplicated.

Parameters
[in]otherOther data to duplicate into this object.
Returns
A reference to this object.

◆ operator==() [2/2]

bool ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::operator== ( const DataBlock< 8, 8 > &  other) const
inherited

Equality operator.

The source PID's are ignored, only the data contents are compared.

Parameters
[in]otherOther packet to compare.
Returns
True if the two packets are identical. False otherwise.

◆ content()

virtual const uint8_t * ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::content ( ) const
virtualinherited

Access to the full binary content of the data.

Do not modify content.

Returns
Address of the full binary content of the data. May be invalidated after modification.

◆ size()

virtual size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::size ( ) const
virtualinherited

Size of the logical binary content of the data.

For subclasses of DataBlock, this is the logical size of the data structure inside the DataBlock blob.

Returns
Size of the logical binary content of the data.
See also
rawDataSize()

◆ rawDataSize()

size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::rawDataSize ( ) const
inlineinherited

Size of the complete binary raw data containing the logical structure.

Non-virtual method, always return the same result.

Returns
Size of the complete binary raw data.
See also
size()

◆ matchContent()

bool ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::matchContent ( const ByteBlock pattern,
const ByteBlock mask = ByteBlock() 
) const
inherited

Check if the start of the data matches a given pattern.

Parameters
[in]patternA byte block to compare with the start of the data.
[in]maskOptional mask to select meaningful bits in pattern.
Returns
Size of the binary content of the data.

◆ GetLengthField()

static size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::GetLengthField ( const void *  content,
size_t  content_size 
)
staticinherited

Static method to extract the content of the length field.

Parameters
[in]contentAddress of the binary data. Can be the null pointer.
[in]content_sizeSize in bytes of the data.
Returns
The extracted length field or NPOS if the data structure does not contain a length field or if the length is "unbounded" (when allowed).

◆ ValidateLengthField()

static bool ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::ValidateLengthField ( const void *  content,
size_t  content_size,
bool  allow_extra_data 
)
staticinherited

Static method to validate the content of the length field.

Parameters
[in]contentAddress of the binary data. Can be the null pointer.
[in]content_sizeSize in bytes of the data.
[in]allow_extra_dataIf true, additional data are allowed after the declared length.
Returns
True if the length field is valid, or the length field does not exist, or the length field is "unbounded" (when allowed).

◆ rwContent()

uint8_t * ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::rwContent ( )
inlineprotectedinherited

Read/write access to the full binary content of the data for subclasses.

Returns
Address of the full binary content of the data.

◆ rwResize()

void ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::rwResize ( size_t  s)
protectedinherited

Resize the full binary content of the data for subclasses.

Parameters
[in]sNew size in bytes of the full binary content of the data.

◆ rwAppend()

void ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::rwAppend ( const void *  data,
size_t  dsize 
)
protectedinherited

Append raw data to the full binary content of the data for subclasses.

Parameters
[in]dataAddress of the new area to append.
[in]dsizeSize of the area to append.

Member Data Documentation

◆ LEN_BIT_SIZE

constexpr size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::LEN_BIT_SIZE
staticconstexprinherited

Size in bits of the length field.

If zero, there is no length field.

◆ AFTER_LEN_BYTE_OFFSET

constexpr size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, false >::AFTER_LEN_BYTE_OFFSET
staticconstexprinherited

Offset in bytes of the next byte after the length field.

Zero if there is no length field.


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