TSDuck v3.40-4025
MPEG Transport Stream Toolkit
|
Representation of MPEG PSI/SI tables in binary form (ie. More...
#include <tsBinaryTable.h>
Classes | |
class | XMLOptions |
Options to convert a binary table into XML. More... | |
Public Member Functions | |
BinaryTable ()=default | |
Default constructor. | |
BinaryTable (BinaryTable &&table) noexcept | |
Move constructor. | |
BinaryTable (const BinaryTable &table, ShareMode mode) | |
Copy constructor. | |
BinaryTable (const SectionPtrVector §ions, bool replace=true, bool grow=true) | |
Constructor from an array of sections. | |
template<class... Args> | |
bool | addNewSection (Args &&... args) |
Create a section and add it to a table. | |
bool | addSection (const SectionPtr §ion, bool replace=true, bool grow=true) |
Add a section to a table. | |
bool | addSections (const SectionPtrVector §ions, bool replace=true, bool grow=true) |
Add several sections to a table. | |
bool | addSections (SectionPtrVector::const_iterator first, SectionPtrVector::const_iterator last, bool replace=true, bool grow=true) |
Add several sections to a table. | |
UString | attribute () const |
Get the generic user-defined "attribute" string of the object. | |
void | clear () |
Clear the content of the table. | |
BinaryTable & | copy (const BinaryTable &table) |
Duplication. | |
virtual Standards | definingStandards () const override |
Get the list of standards which define this object. | |
PacketCounter | firstTSPacketIndex () const |
Index of first TS packet of the table in the demultiplexed stream. | |
bool | fromXML (DuckContext &duck, const xml::Element *node) |
This method converts an XML node as a binary table. | |
bool | isShortSection () const |
Check if this is a table with one short section. | |
bool | isValid () const |
Check if the table is valid. | |
PacketCounter | lastTSPacketIndex () const |
Index of last TS packet of the table in the demultiplexed stream. | |
BinaryTable & | operator= (BinaryTable &&table) noexcept |
Move assignment operator. | |
BinaryTable & | operator= (const BinaryTable &table) |
Assignment operator. | |
bool | operator== (const BinaryTable &table) const |
Equality operator. | |
PacketCounter | packetCount (bool pack=true) const |
Minimum number of TS packets required to transport the table. | |
bool | packSections () |
Pack all sections in a table, removing references to missing sections. | |
const SectionPtr | sectionAt (size_t index) const |
Get a pointer to a section. | |
size_t | sectionCount () const |
Number of sections in the table. | |
void | setAttribute (const UString &attr) |
Set a generic user-defined string as "attribute" of the object. | |
void | setSourcePID (PID pid) |
Set the source PID of all sections in the table. | |
void | setTableIdExtension (uint16_t tid, bool recompute_crc=true) |
Set the table id of all sections in the table. | |
void | setVersion (uint8_t version, bool recompute_crc=true) |
Set the table version number of all sections in the table. | |
PID | sourcePID () const |
Fast access to the source PID. | |
TID | tableId () const |
Fast access to the table id. | |
uint16_t | tableIdExtension () const |
Fast access to the table id extension. | |
size_t | totalSize () const |
Total size in bytes of all sections in the table. | |
xml::Element * | toXML (DuckContext &duck, xml::Element *parent, const XMLOptions &opt=XMLOptions()) const |
This method converts the table to XML. | |
uint8_t | version () const |
Fast access to the table version number. | |
Representation of MPEG PSI/SI tables in binary form (ie.
list of sections).
A table is built by adding sections using addSection(). When all sections are present, the table becomes valid.
Sections are added using SectionPtr safe pointers. Only the pointers are copied. The sections are shared.
The table_id, version and number of sections is determined when the first section is added. Subsequent sections must have the same properties.
ts::BinaryTable::BinaryTable | ( | const BinaryTable & | table, |
ShareMode | mode | ||
) |
Copy constructor.
[in] | table | Another instance to copy. |
[in] | mode | The sections are either shared (ShareMode::SHARE) between the two tables or duplicated (ShareMode::COPY). |
|
noexcept |
Move constructor.
[in,out] | table | Another instance to move. |
ts::BinaryTable::BinaryTable | ( | const SectionPtrVector & | sections, |
bool | replace = true , |
||
bool | grow = true |
||
) |
Constructor from an array of sections.
[in] | sections | An array of smart pointers to sections. |
[in] | replace | If true, duplicated sections may be replaced. Otherwise, sections which are already present (based on section number) are not replaced. |
[in] | grow | If true, the "last_section_number" of a section may be greater than the current "last_section_number" of the table. In this case, all sections which were previously added in the table are modified. |
BinaryTable & ts::BinaryTable::operator= | ( | const BinaryTable & | table | ) |
Assignment operator.
The sections are referenced, and thus shared between the two table objects.
[in] | table | Other table to assign to this object. |
|
noexcept |
Move assignment operator.
The sections are referenced, and thus shared between the two table objects.
[in,out] | table | Other table to move into this object. |
BinaryTable & ts::BinaryTable::copy | ( | const BinaryTable & | table | ) |
Duplication.
Similar to assignment but the sections are duplicated.
[in] | table | Other table to duplicate into this object. |
bool ts::BinaryTable::operator== | ( | const BinaryTable & | table | ) | const |
Equality operator.
The source PID's are ignored, only the table contents are compared. Invalid tables are never identical.
[in] | table | Other table to compare. |
bool ts::BinaryTable::addSection | ( | const SectionPtr & | section, |
bool | replace = true , |
||
bool | grow = true |
||
) |
Add a section to a table.
[in] | section | A smart pointers to section. |
[in] | replace | If true, duplicated sections may be replaced. Otherwise, sections which are already present (based on section number) are not replaced. |
[in] | grow | If true, the "last_section_number" of section may be greater than the current "last_section_number" of the table. In this case, all sections which were previously added in the table are modified. |
|
inline |
Create a section and add it to a table.
The section is replaced if it was already present and the table grows when necessary.
[in] | args | Arguments for the Section constructor. |
|
inline |
Add several sections to a table.
[in] | sections | An array of smart pointers to sections. |
[in] | replace | If true, duplicated sections may be replaced. Otherwise, sections which are already present (based on section number) are not replaced. |
[in] | grow | If true, the "last_section_number" of a section may be greater than the current "last_section_number" of the table. In this case, all sections which were previously added in the table are modified. |
bool ts::BinaryTable::addSections | ( | SectionPtrVector::const_iterator | first, |
SectionPtrVector::const_iterator | last, | ||
bool | replace = true , |
||
bool | grow = true |
||
) |
Add several sections to a table.
[in] | first | First iterator to an array of smart pointers to sections. |
[in] | last | Last iterator to an array of smart pointers to sections. |
[in] | replace | If true, duplicated sections may be replaced. Otherwise, sections which are already present (based on section number) are not replaced. |
[in] | grow | If true, the "last_section_number" of a section may be greater than the current "last_section_number" of the table. In this case, all sections which were previously added in the table are modified. |
bool ts::BinaryTable::packSections | ( | ) |
Pack all sections in a table, removing references to missing sections.
As an example, if a table expects 5 sections (numbered 0 to 4) but only sections numbered 1 and 3 are present, the table is packed with the two existing sections renumbered 0 and 1 and the last section number is set to 2 in the existing sections. The table becomes valid if at least one section was present.
|
inline |
Check if the table is valid.
void ts::BinaryTable::clear | ( | ) |
Clear the content of the table.
The table must be rebuilt using calls to addSection().
|
inline |
Fast access to the table id.
|
inline |
Fast access to the table id extension.
|
inline |
Fast access to the table version number.
|
inline |
Fast access to the source PID.
void ts::BinaryTable::setTableIdExtension | ( | uint16_t | tid, |
bool | recompute_crc = true |
||
) |
void ts::BinaryTable::setVersion | ( | uint8_t | version, |
bool | recompute_crc = true |
||
) |
void ts::BinaryTable::setSourcePID | ( | PID | pid | ) |
Set the source PID of all sections in the table.
[in] | pid | The new source PID. |
PacketCounter ts::BinaryTable::firstTSPacketIndex | ( | ) | const |
Index of first TS packet of the table in the demultiplexed stream.
Valid only if the table was extracted by a section demux.
PacketCounter ts::BinaryTable::lastTSPacketIndex | ( | ) | const |
Index of last TS packet of the table in the demultiplexed stream.
Valid only if the table was extracted by a section demux.
|
inline |
Number of sections in the table.
size_t ts::BinaryTable::totalSize | ( | ) | const |
Total size in bytes of all sections in the table.
PacketCounter ts::BinaryTable::packetCount | ( | bool | pack = true | ) | const |
Minimum number of TS packets required to transport the table.
[in] | pack | If true, assume that sections are packed in TS packets. When false, assume that each section starts at the beginning of a TS packet and stuffing in applied at the end of each section. |
const SectionPtr ts::BinaryTable::sectionAt | ( | size_t | index | ) | const |
Get a pointer to a section.
[in] | index | Index of the section to get. |
bool ts::BinaryTable::isShortSection | ( | ) | const |
Check if this is a table with one short section.
void ts::BinaryTable::setAttribute | ( | const UString & | attr | ) |
Set a generic user-defined string as "attribute" of the object.
The semantics of this attribute string is not defined. It is used by the application. The attribute string can be found in the <metadata>
structure of the XML representation of a table.
Here, the attribute is set on all sections in the table. If the table contains no section, the attibute is ignored. If additional sections are added later, their attribute will not be changed.
[in] | attr | Generic string to set as attribute. |
UString ts::BinaryTable::attribute | ( | ) | const |
Get the generic user-defined "attribute" string of the object.
This is the first non-empty attribute in the sections in the table.
xml::Element * ts::BinaryTable::toXML | ( | DuckContext & | duck, |
xml::Element * | parent, | ||
const XMLOptions & | opt = XMLOptions() |
||
) | const |
This method converts the table to XML.
If the table has a specialized implementation, generate a specialized XML structure. Otherwise, generate a <generic_short_table> or <generic_long_table> node.
[in,out] | duck | TSDuck execution environment. |
[in,out] | parent | The parent node for the XML representation. |
[in] | opt | Conversion options. |
bool ts::BinaryTable::fromXML | ( | DuckContext & | duck, |
const xml::Element * | node | ||
) |
This method converts an XML node as a binary table.
[in,out] | duck | TSDuck execution environment. |
[in] | node | The root of the XML descriptor. |
|
overridevirtual |
Get the list of standards which define this object.
Implements ts::AbstractDefinedByStandards.