TSDuck Version 3.16-1064 (TSDuck - The MPEG Transport Stream Toolkit)
ts::BinaryTable Class Reference

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

Public Member Functions

 BinaryTable ()
 Default constructor.
 
 BinaryTable (const BinaryTable &table, CopyShare mode)
 Copy constructor. More...
 
 BinaryTable (const SectionPtrVector &sections, bool replace=true, bool grow=true)
 Constructor from an array of sections. More...
 
bool addSection (const SectionPtr &section, bool replace=true, bool grow=true)
 Add a section to a table. More...
 
bool addSections (const SectionPtrVector &sections, bool replace=true, bool grow=true)
 Add several sections to a table. More...
 
bool addSections (SectionPtrVector::const_iterator first, SectionPtrVector::const_iterator last, bool replace=true, bool grow=true)
 Add several sections to a table. More...
 
void clear ()
 Clear the content of the table. More...
 
BinaryTablecopy (const BinaryTable &table)
 Duplication. More...
 
bool fromXML (const xml::Element *node, const DVBCharset *charset=nullptr)
 This method converts an XML node as a binary table. More...
 
PacketCounter getFirstTSPacketIndex () const
 Index of first TS packet of the table in the demultiplexed stream. More...
 
PacketCounter getLastTSPacketIndex () const
 Index of last TS packet of the table in the demultiplexed stream. More...
 
bool isShortSection () const
 Check if this is a table with one short section. More...
 
bool isValid () const
 Check if the table is valid. More...
 
bool operator!= (const BinaryTable &table) const
 Unequality operator. More...
 
BinaryTableoperator= (const BinaryTable &table)
 Assignment operator. More...
 
bool operator== (const BinaryTable &table) const
 Equality operator. More...
 
PacketCounter packetCount (bool pack=true) const
 Minimum number of TS packets required to transport the table. More...
 
bool packSections ()
 Pack all sections in a table, removing references to missing sections. More...
 
const SectionPtrsectionAt (size_t index) const
 Get a pointer to a section. More...
 
size_t sectionCount () const
 Number of sections in the table. More...
 
void setSourcePID (PID pid)
 Set the source PID of all sections in the table. More...
 
void setTableIdExtension (uint16_t tid, bool recompute_crc=true)
 Set the table id of all sections in the table. More...
 
void setVersion (uint8_t version, bool recompute_crc=true)
 Set the table version number of all sections in the table. More...
 
PID sourcePID () const
 Fast access to the source PID. More...
 
TID tableId () const
 Fast access to the table id. More...
 
uint16_t tableIdExtension () const
 Fast access to the table id extension. More...
 
size_t totalSize () const
 Total size in bytes of all sections in the table. More...
 
xml::ElementtoXML (xml::Element *parent, bool forceGeneric=false, const DVBCharset *charset=nullptr) const
 This method converts the table to XML. More...
 
uint8_t version () const
 Fast access to the table version number. More...
 

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/2]

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

Copy constructor.

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

◆ BinaryTable() [2/2]

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=()

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.

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

◆ operator!=()

bool ts::BinaryTable::operator!= ( const BinaryTable table) const
inline

Unequality 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 different. 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).

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

◆ getFirstTSPacketIndex()

PacketCounter ts::BinaryTable::getFirstTSPacketIndex ( ) 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.

◆ getLastTSPacketIndex()

PacketCounter ts::BinaryTable::getLastTSPacketIndex ( ) 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
inline

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.

◆ toXML()

xml::Element* ts::BinaryTable::toXML ( xml::Element parent,
bool  forceGeneric = false,
const DVBCharset charset = nullptr 
) 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]parentThe parent node for the XML representation.
[in]forceGenericForce a generic table node even if the table can be specialized.
[in]charsetIf not zero, default character set to use.
Returns
The new XML element or zero if the table is not valid.

◆ fromXML()

bool ts::BinaryTable::fromXML ( const xml::Element node,
const DVBCharset charset = nullptr 
)

This method converts an XML node as a binary table.

Parameters
[in]nodeThe root of the XML descriptor.
[in]charsetIf not zero, default character set to use.
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.

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