![]() |
TSDuck v3.43-4441
MPEG Transport Stream Toolkit
|
Representation of a MPEG PSI/SI descriptors in binary format. More...
#include <tsDescriptor.h>
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. | |
DataBlock & | copy (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::Element * | toXML (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. | |
Representation of a MPEG PSI/SI descriptors in binary format.
|
inline |
Copy constructor.
[in] | desc | Another instance to copy. |
[in] | mode | The descriptors' data are either shared (ShareMode::SHARE) between the two descriptors or duplicated (ShareMode::COPY). |
|
inlinenoexcept |
Move constructor.
[in,out] | desc | Another instance to move. |
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.
[in] | tag | Descriptor tag. |
[in] | data | Address of the descriptor payload. |
[in] | size | Size in bytes of the descriptor payload. |
Constructor from tag and payload.
The content is copied into the section if valid.
[in] | tag | Descriptor tag. |
[in] | data | Descriptor payload. |
|
inline |
Constructor from full binary content.
The content is copied into the section if valid.
[in] | data | Address of the descriptor data. |
[in] | size | Size in bytes of the descriptor data. |
|
inline |
Constructor from full binary content.
The content is copied into the section if valid.
[in] | bb | Descriptor binary data. |
|
inline |
Constructor from full binary content.
[in] | bb | Descriptor binary data. |
[in] | mode | The data are either shared (ShareMode::SHARE) between the descriptor and bb or duplicated (ShareMode::COPY). |
|
inline |
Get the descriptor tag.
XDID ts::Descriptor::xdid | ( | ) | const |
Get the extension descriptor id.
|
inline |
Access to the payload of the descriptor.
|
inline |
Access to the payload of the descriptor.
|
inline |
Size of the payload of the descriptor.
void ts::Descriptor::replacePayload | ( | const void * | data, |
size_t | size | ||
) |
Replace the payload of the descriptor.
The tag is unchanged, the size is adjusted.
[in] | data | Address of the new payload data. |
[in] | size | Size in bytes of the new payload data. |
|
inline |
Replace the payload of the descriptor.
The tag is unchanged, the size is adjusted.
[in] | payload | The new payload data. |
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.
[in] | size | New size in bytes of the payload. |
|
inline |
Comparison operator.
[in] | other | Another descriptor to compare. |
AbstractDescriptorPtr ts::Descriptor::deserialize | ( | DuckContext & | duck, |
EDID | edid | ||
) | const |
Deserialize the descriptor.
[in,out] | duck | TSDuck execution context. |
[in] | edid | Extended descriptor id. |
AbstractDescriptorPtr ts::Descriptor::deserialize | ( | DuckContext & | duck, |
DescriptorContext & | context | ||
) | const |
Deserialize the descriptor.
[in,out] | duck | TSDuck execution context. |
[in,out] | context | Context of the descriptor. Used to understand its identity. |
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.
[in,out] | duck | TSDuck execution context. |
[in,out] | parent | The parent node for the XML descriptor. |
[in,out] | context | Context of the descriptor. Used to understand its identity. |
[in] | force_generic | Force a <generic_descriptor> node even if the descriptor can be specialized. |
bool ts::Descriptor::fromXML | ( | DuckContext & | duck, |
const xml::Element * | node, | ||
TID | tid = TID_NULL |
||
) |
This method converts an XML node as a binary descriptor.
[in,out] | duck | TSDuck execution context. |
[in] | node | The root of the XML descriptor. |
[in] | tid | Optional table id of the table containing the descriptor. |
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.
[in,out] | duck | TSDuck execution context. |
[out] | edid | Extended descriptor id of the XML descriptor. |
[in] | node | The root of the XML descriptor. |
[in] | tid | Optional table id of the table containing the descriptor. |
|
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.
|
inherited |
Reload from full binary content.
[in] | content | Address of the binary packet data. |
[in] | content_size | Size in bytes of the packet. |
|
inherited |
Reload from full binary content.
[in] | content | Binary packet data. The content is copied into a new byte block. |
|
inherited |
|
inherited |
Duplication.
Similar to assignment but the data are duplicated.
[in] | other | Other data to duplicate into this object. |
|
inherited |
Equality operator.
The source PID's are ignored, only the data contents are compared.
[in] | other | Other packet to compare. |
|
virtualinherited |
Access to the full binary content of the data.
Do not modify content.
|
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.
|
inlineinherited |
Size of the complete binary raw data containing the logical structure.
Non-virtual method, always return the same result.
|
inherited |
Check if the start of the data matches a given pattern.
[in] | pattern | A byte block to compare with the start of the data. |
[in] | mask | Optional mask to select meaningful bits in pattern. |
|
staticinherited |
Static method to extract the content of the length field.
[in] | content | Address of the binary data. Can be the null pointer. |
[in] | content_size | Size in bytes of the data. |
|
staticinherited |
Static method to validate the content of the length field.
[in] | content | Address of the binary data. Can be the null pointer. |
[in] | content_size | Size in bytes of the data. |
[in] | allow_extra_data | If true, additional data are allowed after the declared length. |
|
inlineprotectedinherited |
Read/write access to the full binary content of the data for subclasses.
|
protectedinherited |
Resize the full binary content of the data for subclasses.
[in] | s | New size in bytes of the full binary content of the data. |
|
protectedinherited |
Append raw data to the full binary content of the data for subclasses.
[in] | data | Address of the new area to append. |
[in] | dsize | Size of the area to append. |
|
staticconstexprinherited |
Size in bits of the length field.
If zero, there is no length field.
|
staticconstexprinherited |
Offset in bytes of the next byte after the length field.
Zero if there is no length field.