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

Representation of MPEG PSI/SI tables in binary form (ie. More...

#include <tsBinaryTable.h>

Inheritance diagram for ts::BinaryTable:
Collaboration diagram for ts::BinaryTable:

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 &sections, 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 &section, bool replace=true, bool grow=true)
 Add a section to a table.
 
bool addSections (const SectionPtrVector &sections, 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.
 
BinaryTablecopy (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.
 
BinaryTableoperator= (BinaryTable &&table) noexcept
 Move assignment operator.
 
BinaryTableoperator= (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::ElementtoXML (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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BinaryTable() [1/3]

ts::BinaryTable::BinaryTable ( const BinaryTable table,
ShareMode  mode 
)

Copy constructor.

Parameters
[in]tableAnother instance to copy.
[in]modeThe sections are either shared (ShareMode::SHARE) between the two tables or duplicated (ShareMode::COPY).

◆ BinaryTable() [2/3]

ts::BinaryTable::BinaryTable ( BinaryTable &&  table)
noexcept

Move constructor.

Parameters
[in,out]tableAnother instance to move.

◆ BinaryTable() [3/3]

ts::BinaryTable::BinaryTable ( const SectionPtrVector sections,
bool  replace = true,
bool  grow = true 
)

Constructor from an array of sections.

Parameters
[in]sectionsAn array of smart pointers to sections.
[in]replaceIf true, duplicated sections may be replaced. Otherwise, sections which are already present (based on section number) are not replaced.
[in]growIf 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.

Member Function Documentation

◆ operator=() [1/2]

BinaryTable & ts::BinaryTable::operator= ( const BinaryTable table)

Assignment operator.

The sections are referenced, and thus shared between the two table objects.

Parameters
[in]tableOther table to assign to this object.
Returns
A reference to this object.

◆ operator=() [2/2]

BinaryTable & ts::BinaryTable::operator= ( BinaryTable &&  table)
noexcept

Move assignment operator.

The sections are referenced, and thus shared between the two table objects.

Parameters
[in,out]tableOther table to move into this object.
Returns
A reference to this object.

◆ copy()

BinaryTable & ts::BinaryTable::copy ( const BinaryTable table)

Duplication.

Similar to assignment but the sections are duplicated.

Parameters
[in]tableOther table to duplicate into this object.
Returns
A reference to this object.

◆ operator==()

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.

Parameters
[in]tableOther table to compare.
Returns
True if the two tables are identical. False otherwise.

◆ addSection()

bool ts::BinaryTable::addSection ( const SectionPtr section,
bool  replace = true,
bool  grow = true 
)

Add a section to a table.

Parameters
[in]sectionA smart pointers to section.
[in]replaceIf true, duplicated sections may be replaced. Otherwise, sections which are already present (based on section number) are not replaced.
[in]growIf 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.
Returns
True on succes, false if section could not be added (inconsistent property).

◆ addNewSection()

template<class... Args>
bool ts::BinaryTable::addNewSection ( Args &&...  args)
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.

Template Parameters
ArgsArguments types for the Section constructor.
Parameters
[in]argsArguments for the Section constructor.
Returns
True on succes, false if section could not be added (inconsistent property).

◆ addSections() [1/2]

bool ts::BinaryTable::addSections ( const SectionPtrVector sections,
bool  replace = true,
bool  grow = true 
)
inline

Add several sections to a table.

Parameters
[in]sectionsAn array of smart pointers to sections.
[in]replaceIf true, duplicated sections may be replaced. Otherwise, sections which are already present (based on section number) are not replaced.
[in]growIf 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.
Returns
True on succes, false if a section could not be added (inconsistent property).

◆ addSections() [2/2]

bool ts::BinaryTable::addSections ( SectionPtrVector::const_iterator  first,
SectionPtrVector::const_iterator  last,
bool  replace = true,
bool  grow = true 
)

Add several sections to a table.

Parameters
[in]firstFirst iterator to an array of smart pointers to sections.
[in]lastLast iterator to an array of smart pointers to sections.
[in]replaceIf true, duplicated sections may be replaced. Otherwise, sections which are already present (based on section number) are not replaced.
[in]growIf 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.
Returns
True on succes, false if a section could not be added (inconsistent property).

◆ packSections()

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.

Returns
True on succes, false if the table is empty.

◆ isValid()

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

Check if the table is valid.

Returns
True if the table is valid (all consistent sections are present with same table id, same version, same "last_section_number").

◆ clear()

void ts::BinaryTable::clear ( )

Clear the content of the table.

The table must be rebuilt using calls to addSection().

◆ tableId()

TID ts::BinaryTable::tableId ( ) const
inline

Fast access to the table id.

Returns
The table id.

◆ tableIdExtension()

uint16_t ts::BinaryTable::tableIdExtension ( ) const
inline

Fast access to the table id extension.

Returns
The table id extension.

◆ version()

uint8_t ts::BinaryTable::version ( ) const
inline

Fast access to the table version number.

Returns
The table version number.

◆ sourcePID()

PID ts::BinaryTable::sourcePID ( ) const
inline

Fast access to the source PID.

Returns
The source PID.

◆ setTableIdExtension()

void ts::BinaryTable::setTableIdExtension ( uint16_t  tid,
bool  recompute_crc = true 
)

Set the table id of all sections in the table.

Parameters
[in]tidThe new table id.
[in]recompute_crcIf true, immediately recompute the CRC32 of all sections. If false, the CRC32's become invalid and must be computed later.

◆ setVersion()

void ts::BinaryTable::setVersion ( uint8_t  version,
bool  recompute_crc = true 
)

Set the table version number of all sections in the table.

Parameters
[in]versionThe new table version number.
[in]recompute_crcIf true, immediately recompute the CRC32 of all sections. If false, the CRC32's become invalid and must be computed later.

◆ setSourcePID()

void ts::BinaryTable::setSourcePID ( PID  pid)

Set the source PID of all sections in the table.

Parameters
[in]pidThe new source PID.

◆ firstTSPacketIndex()

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.

Returns
The first TS packet of the table in the demultiplexed stream.

◆ lastTSPacketIndex()

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.

Returns
The last TS packet of the table in the demultiplexed stream.

◆ sectionCount()

size_t ts::BinaryTable::sectionCount ( ) const
inline

Number of sections in the table.

Returns
The number of sections in the table.

◆ totalSize()

size_t ts::BinaryTable::totalSize ( ) const

Total size in bytes of all sections in the table.

Returns
The total size in bytes of all sections in the table.

◆ packetCount()

PacketCounter ts::BinaryTable::packetCount ( bool  pack = true) const

Minimum number of TS packets required to transport the table.

Parameters
[in]packIf 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.
Returns
The minimum number of TS packets required to transport the table.

◆ sectionAt()

const SectionPtr ts::BinaryTable::sectionAt ( size_t  index) const

Get a pointer to a section.

Parameters
[in]indexIndex of the section to get.
Returns
A safe pointer to the section or a null pointer if the specified section is not present.

◆ isShortSection()

bool ts::BinaryTable::isShortSection ( ) const

Check if this is a table with one short section.

Returns
True if this is a table with one short section.

◆ setAttribute()

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.

Parameters
[in]attrGeneric string to set as attribute.

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

Returns
The attribute string in the object.
See also
setAttribute()

◆ toXML()

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.

Parameters
[in,out]duckTSDuck execution environment.
[in,out]parentThe parent node for the XML representation.
[in]optConversion options.
Returns
The new XML element or zero if the table is not valid.

◆ fromXML()

bool ts::BinaryTable::fromXML ( DuckContext duck,
const xml::Element node 
)

This method converts an XML node as a binary table.

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

◆ definingStandards()

virtual Standards ts::BinaryTable::definingStandards ( ) const
overridevirtual

Get the list of standards which define this object.

Returns
A bit mask of standards.

Implements ts::AbstractDefinedByStandards.


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