TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
Representation of MPEG PSI/SI sections. More...
#include <tsSection.h>
Public Types | |
using | SuperClass = DemuxedData |
Explicit identification of super class. | |
Public Member Functions | |
Section ()=default | |
Default constructor. | |
Section (const ByteBlock &content, PID source_pid=PID_NULL, CRC32::Validation crc_op=CRC32::Validation::IGNORE) | |
Constructor from full binary content. | |
Section (const ByteBlockPtr &content_ptr, PID source_pid=PID_NULL, CRC32::Validation crc_op=CRC32::Validation::IGNORE) | |
Constructor from full binary content. | |
Section (const Section &other, ShareMode mode) | |
Copy constructor. | |
Section (const void *content, size_t content_size, PID source_pid=PID_NULL, CRC32::Validation crc_op=CRC32::Validation::IGNORE) | |
Constructor from full binary content. | |
Section (TID tid, bool is_private_section, const void *payload, size_t payload_size, PID source_pid=PID_NULL) | |
Constructor from a short section payload. | |
Section (TID tid, bool is_private_section, uint16_t tid_ext, uint8_t version, bool is_current, uint8_t section_number, uint8_t last_section_number, const void *payload, size_t payload_size, PID source_pid=PID_NULL) | |
Constructor from a long section payload. | |
void | appendPayload (const ByteBlock &data, bool recompute_crc=true) |
Append binary data to the payload of the section. | |
void | appendPayload (const void *data, size_t size, bool recompute_crc=true) |
Append binary data to the payload of the section. | |
const UString & | attribute () const |
Get the generic user-defined "attribute" string of the object. | |
virtual void | clear () override |
Clear data content. | |
virtual const uint8_t * | content () const |
Access to the full binary content of the data. | |
DemuxedData & | copy (const DemuxedData &other) |
Duplication. | |
Section & | copy (const Section &other) |
Duplication. | |
virtual Standards | definingStandards () const override |
Get the list of standards which define this object. | |
std::ostream & | dump (std::ostream &strm, int indent=0, uint16_t cas=CASID_NULL, bool no_header=false) const |
Hexa dump the section on an output stream without interpretation of the payload. | |
ETID | etid () const |
Get the table id and id extension (long section only). | |
PacketCounter | firstTSPacketIndex () const |
Index of first TS packet of the data in the demultiplexed stream. | |
bool | hasDiversifiedPayload () const |
Check if the section has a "diversified" payload. | |
ByteBlock | hash () const |
Get a hash of the section content. | |
size_t | headerSize () const |
Size of the section header. | |
bool | isCurrent () const |
Check if the section is "current", not "next" (long section only). | |
bool | isLongSection () const |
Check if the section is a long one. | |
bool | isNext () const |
Check if the section is "next", not "current" (long section only). | |
bool | isPrivateSection () const |
Check if the section is a private one (ie. | |
bool | isShortSection () const |
Check if the section is a short one. | |
bool | isValid () const |
Check if the section has valid content. | |
uint8_t | lastSectionNumber () const |
Get the number of the last section in the table (long section only). | |
PacketCounter | lastTSPacketIndex () const |
Index of last TS packet of the data in the demultiplexed stream. | |
bool | matchContent (const ByteBlock &pattern, const ByteBlock &mask=ByteBlock()) const |
Check if the start of the data matches a given pattern. | |
Section & | operator= (const Section &&other) noexcept |
Move assignment operator. | |
Section & | operator= (const Section &other) |
Assignment operator. | |
bool | operator== (const DemuxedData &other) const |
Equality operator. | |
bool | operator== (const Section &other) const |
Equality operator. | |
PacketCounter | packetCount () const |
Minimum number of TS packets required to transport the section. | |
const uint8_t * | payload () const |
Access to the payload of the section. | |
size_t | payloadSize () const |
Get the size of the payload of the section. | |
size_t | rawDataSize () const |
Size of the complete binary raw data containing the logical structure. | |
std::istream & | read (std::istream &strm, CRC32::Validation crc_op=CRC32::Validation::IGNORE, Report &report=(ts::CerrReport::Instance())) |
Read a section from standard streams (binary mode). | |
void | recomputeCRC () |
This method recomputes and replaces the CRC32 of the section. | |
void | reload (const ByteBlock &content, PID source_pid, CRC32::Validation crc_op) |
Reload from full binary content. | |
virtual void | reload (const ByteBlock &content, PID source_pid=PID_NULL) override |
Reload from full binary content. | |
void | reload (const ByteBlockPtr &content_ptr, PID source_pid, CRC32::Validation crc_op) |
Reload from full binary content. | |
virtual void | reload (const ByteBlockPtr &content_ptr, PID source_pid=PID_NULL) override |
Reload from full binary content. | |
void | reload (const void *content, size_t content_size, PID source_pid, CRC32::Validation crc_op) |
Reload from full binary content. | |
virtual void | reload (const void *content, size_t content_size, PID source_pid=PID_NULL) override |
Reload from full binary content. | |
void | reload (TID tid, bool is_private_section, const void *payload, size_t payload_size, PID source_pid=PID_NULL) |
Reload from a short section payload. | |
void | reload (TID tid, bool is_private_section, uint16_t tid_ext, uint8_t version, bool is_current, uint8_t section_number, uint8_t last_section_number, const void *payload, size_t payload_size, PID source_pid=PID_NULL) |
Reload from a long section payload. | |
uint8_t | sectionNumber () const |
Get the section number in the table (long section only). | |
void | setAttribute (const UString &attr) |
Set a generic user-defined string as "attribute" of the object. | |
void | setFirstTSPacketIndex (PacketCounter i) |
Set the first TS packet of the data in the demultiplexed stream. | |
void | setIsCurrent (bool is_current, bool recompute_crc=true) |
Set the section current/next flag (long section only). | |
void | setLastSectionNumber (uint8_t num, bool recompute_crc=true) |
Set the number of the last section in the table (long section only). | |
void | setLastTSPacketIndex (PacketCounter i) |
Set the last TS packet of the data in the demultiplexed stream. | |
void | setSectionNumber (uint8_t num, bool recompute_crc=true) |
Set the section number (long section only). | |
void | setSourcePID (PID pid) |
Set the source PID. | |
void | setTableId (uint8_t tid, bool recompute_crc=true) |
Set the table id. | |
void | setTableIdExtension (uint16_t tid_ext, bool recompute_crc=true) |
Set the table id extension (long section only). | |
void | setUInt16 (size_t offset, uint16_t value, bool recompute_crc=true) |
Set a 16-bit integer in the payload of the section. | |
void | setUInt32 (size_t offset, uint32_t value, bool recompute_crc=true) |
Set a 32-bit integer in the payload of the section. | |
void | setUInt8 (size_t offset, uint8_t value, bool recompute_crc=true) |
Set one byte in the payload of the section. | |
void | setVersion (uint8_t version, bool recompute_crc=true) |
Set the section version number (long section only). | |
virtual size_t | size () const |
Size of the logical binary content of the data. | |
PID | sourcePID () const |
Get the source PID. | |
TID | tableId () const |
Get the table id. | |
uint16_t | tableIdExtension () const |
Get the table id extension (long section only). | |
void | truncatePayload (size_t size, bool recompute_crc=true) |
Truncate the payload of the section. | |
uint8_t | version () const |
Get the section version number (long section only). | |
std::ostream & | write (std::ostream &strm, Report &report=(ts::CerrReport::Instance())) const |
Write a section to standard streams (binary mode). | |
Static Public Member Functions | |
template<class CONTAINER > | |
static PacketCounter | PacketCount (const CONTAINER &container, bool pack=true) |
Static method to compute the minimum number of TS packets required to transport a set of sections. | |
static size_t | SectionSize (const ByteBlock &content) |
Static method to compute a section size. | |
static size_t | SectionSize (const void *content, size_t content_size) |
Static method to compute a section size. | |
static bool | StartLongSection (const uint8_t *data, size_t size) |
This static method checks if a data area of at least 3 bytes can be the start of a long section. | |
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 MPEG PSI/SI sections.
What to do with the CRC32 when building a section depends on the parameter named crc_op:
Typically, if the ByteBlock comes from the wire, use CHECK. If the ByteBlock is built by the application, use COMPUTE,
|
default |
Default constructor.
Section is initially marked invalid.
Copy constructor.
[in] | other | Another instance to copy. |
[in] | mode | The section's data are either shared (ShareMode::SHARE) between the two instances or duplicated (ShareMode::COPY). |
ts::Section::Section | ( | const void * | content, |
size_t | content_size, | ||
PID | source_pid = PID_NULL , |
||
CRC32::Validation | crc_op = CRC32::Validation::IGNORE |
||
) |
Constructor from full binary content.
The content is copied into the section if valid.
[in] | content | Address of the binary section data. |
[in] | content_size | Size in bytes of the section. |
[in] | source_pid | PID from which the section was read. |
[in] | crc_op | How to process the CRC32. |
ts::Section::Section | ( | const ByteBlock & | content, |
PID | source_pid = PID_NULL , |
||
CRC32::Validation | crc_op = CRC32::Validation::IGNORE |
||
) |
Constructor from full binary content.
The content is copied into the section if valid.
[in] | content | Binary section data. |
[in] | source_pid | PID from which the section was read. |
[in] | crc_op | How to process the CRC32. |
ts::Section::Section | ( | const ByteBlockPtr & | content_ptr, |
PID | source_pid = PID_NULL , |
||
CRC32::Validation | crc_op = CRC32::Validation::IGNORE |
||
) |
Constructor from full binary content.
The content is copied into the section if valid.
ts::Section::Section | ( | TID | tid, |
bool | is_private_section, | ||
const void * | payload, | ||
size_t | payload_size, | ||
PID | source_pid = PID_NULL |
||
) |
Constructor from a short section payload.
[in] | tid | Table id. |
[in] | is_private_section | If true, this is a private section (ie. not MPEG-defined). |
[in] | payload | Address of the payload data. |
[in] | payload_size | Size in bytes of the payload data. |
[in] | source_pid | PID from which the section was read. |
ts::Section::Section | ( | TID | tid, |
bool | is_private_section, | ||
uint16_t | tid_ext, | ||
uint8_t | version, | ||
bool | is_current, | ||
uint8_t | section_number, | ||
uint8_t | last_section_number, | ||
const void * | payload, | ||
size_t | payload_size, | ||
PID | source_pid = PID_NULL |
||
) |
Constructor from a long section payload.
The provided payload does not contain the CRC32. The CRC32 is automatically computed.
[in] | tid | Table id. |
[in] | is_private_section | If true, this is a private section (ie. not MPEG-defined). |
[in] | tid_ext | Table id extension. |
[in] | version | Section version number. |
[in] | is_current | If true, this is a "current" section, not a "next" section. |
[in] | section_number | Section number. |
[in] | last_section_number | Number of last section in the table. |
[in] | payload | Address of the payload data. |
[in] | payload_size | Size in bytes of the payload data. |
[in] | source_pid | PID from which the section was read. |
|
overridevirtual |
Clear data content.
Reimplemented from ts::DemuxedData.
|
overridevirtual |
Reload from full binary content.
[in] | content | Address of the binary packet data. |
[in] | content_size | Size in bytes of the packet. |
[in] | source_pid | PID from which the data were read. |
Reimplemented from ts::DemuxedData.
|
overridevirtual |
Reload from full binary content.
[in] | content | Binary packet data. |
[in] | source_pid | PID from which the data were read. |
Reimplemented from ts::DemuxedData.
|
overridevirtual |
Reload from full binary content.
[in] | content_ptr | Safe pointer to the binary packet data. The content is referenced, and thus shared. Do not modify the referenced ByteBlock from outside the DemuxedData. |
[in] | source_pid | PID from which the data were read. |
Reimplemented from ts::DemuxedData.
|
overridevirtual |
Get the list of standards which define this object.
Implements ts::AbstractDefinedByStandards.
void ts::Section::reload | ( | const void * | content, |
size_t | content_size, | ||
PID | source_pid, | ||
CRC32::Validation | crc_op | ||
) |
Reload from full binary content.
The content is copied into the section if valid.
[in] | content | Address of the binary section data. |
[in] | content_size | Size in bytes of the section. |
[in] | source_pid | PID from which the section was read. |
[in] | crc_op | How to process the CRC32. |
void ts::Section::reload | ( | const ByteBlock & | content, |
PID | source_pid, | ||
CRC32::Validation | crc_op | ||
) |
Reload from full binary content.
[in] | content | Binary section data. |
[in] | source_pid | PID from which the section was read. |
[in] | crc_op | How to process the CRC32. |
void ts::Section::reload | ( | const ByteBlockPtr & | content_ptr, |
PID | source_pid, | ||
CRC32::Validation | crc_op | ||
) |
void ts::Section::reload | ( | TID | tid, |
bool | is_private_section, | ||
const void * | payload, | ||
size_t | payload_size, | ||
PID | source_pid = PID_NULL |
||
) |
Reload from a short section payload.
[in] | tid | Table id. |
[in] | is_private_section | If true, this is a private section (ie. not MPEG-defined). |
[in] | payload | Address of the payload data. |
[in] | payload_size | Size in bytes of the payload data. |
[in] | source_pid | PID from which the section was read. |
void ts::Section::reload | ( | TID | tid, |
bool | is_private_section, | ||
uint16_t | tid_ext, | ||
uint8_t | version, | ||
bool | is_current, | ||
uint8_t | section_number, | ||
uint8_t | last_section_number, | ||
const void * | payload, | ||
size_t | payload_size, | ||
PID | source_pid = PID_NULL |
||
) |
Reload from a long section payload.
The provided payload does not contain the CRC32. The CRC32 is automatically computed.
[in] | tid | Table id. |
[in] | is_private_section | If true, this is a private section (ie. not MPEG-defined). |
[in] | tid_ext | Table id extension. |
[in] | version | Section version number. |
[in] | is_current | If true, this is a "current" section, not a "next" section. |
[in] | section_number | Section number. |
[in] | last_section_number | Number of last section in the table. |
[in] | payload | Address of the payload data. |
[in] | payload_size | Size in bytes of the payload data. |
[in] | source_pid | PID from which the section was read. |
Assignment operator.
The sections contents are referenced, and thus shared between the two section objects.
[in] | other | Other section to assign to this object. |
Move assignment operator.
[in,out] | other | Other section to move into this object. |
Duplication.
Similar to assignment but the sections are duplicated.
[in] | other | Other section to duplicate into this object. |
|
inline |
Check if the section has valid content.
bool ts::Section::operator== | ( | const Section & | other | ) | const |
Equality operator.
The source PID's are ignored, only the section contents are compared. Invalid sections are never identical.
[in] | other | Other section to compare. |
|
inline |
Get the table id.
|
static |
This static method checks if a data area of at least 3 bytes can be the start of a long section.
[in] | data | Address of the data area. |
[in] | size | Size in bytes of the data area. |
|
inline |
Check if the section is a long one.
|
inline |
Check if the section is a short one.
|
inline |
Check if the section is a private one (ie.
not MPEG-defined).
|
inline |
Get the table id extension (long section only).
|
inline |
Get the section version number (long section only).
|
inline |
Check if the section is "current", not "next" (long section only).
|
inline |
Check if the section is "next", not "current" (long section only).
|
inline |
Get the section number in the table (long section only).
|
inline |
Get the number of the last section in the table (long section only).
|
inline |
Get the table id and id extension (long section only).
|
inline |
Size of the section header.
|
inline |
Access to the payload of the section.
For short sections, the payload starts after the private_section_length field. For long sections, the payload starts after the last_section_number field and ends before the CRC32 field. Do not modify payload content. May be invalidated after modification in section.
|
inline |
Get the size of the payload of the section.
For long sections, the payload ends before the CRC32 field.
ByteBlock ts::Section::hash | ( | ) | const |
Get a hash of the section content.
|
inline |
Minimum number of TS packets required to transport the section.
void ts::Section::setTableId | ( | uint8_t | tid, |
bool | recompute_crc = true |
||
) |
Set the table id.
[in] | tid | The table id. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::setTableIdExtension | ( | uint16_t | tid_ext, |
bool | recompute_crc = true |
||
) |
Set the table id extension (long section only).
[in] | tid_ext | The table id extension. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::setVersion | ( | uint8_t | version, |
bool | recompute_crc = true |
||
) |
Set the section version number (long section only).
[in] | version | The section version number. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::setIsCurrent | ( | bool | is_current, |
bool | recompute_crc = true |
||
) |
Set the section current/next flag (long section only).
[in] | is_current | True if the table is "current", false if it is "next". |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::setSectionNumber | ( | uint8_t | num, |
bool | recompute_crc = true |
||
) |
Set the section number (long section only).
[in] | num | The section number. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::setLastSectionNumber | ( | uint8_t | num, |
bool | recompute_crc = true |
||
) |
Set the number of the last section in the table (long section only).
[in] | num | The number of the last section in the table. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::setUInt8 | ( | size_t | offset, |
uint8_t | value, | ||
bool | recompute_crc = true |
||
) |
Set one byte in the payload of the section.
[in] | offset | Byte offset in the payload. |
[in] | value | The value to set in the payload. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::setUInt16 | ( | size_t | offset, |
uint16_t | value, | ||
bool | recompute_crc = true |
||
) |
Set a 16-bit integer in the payload of the section.
[in] | offset | Byte offset in the payload. |
[in] | value | The value to set in the payload. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::setUInt32 | ( | size_t | offset, |
uint32_t | value, | ||
bool | recompute_crc = true |
||
) |
Set a 32-bit integer in the payload of the section.
[in] | offset | Byte offset in the payload. |
[in] | value | The value to set in the payload. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::appendPayload | ( | const void * | data, |
size_t | size, | ||
bool | recompute_crc = true |
||
) |
Append binary data to the payload of the section.
[in] | data | Address of data to add to the payload. |
[in] | size | Size in bytes of data to add to the payload. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
|
inline |
Append binary data to the payload of the section.
[in] | data | Byte block to add to the payload. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
void ts::Section::truncatePayload | ( | size_t | size, |
bool | recompute_crc = true |
||
) |
Truncate the payload of the section.
[in] | size | New size in bytes of the payload. If larger than the current payload size, does nothing. |
[in] | recompute_crc | If true, immediately recompute the CRC32 of the section. |
bool ts::Section::hasDiversifiedPayload | ( | ) | const |
Check if the section has a "diversified" payload.
A payload is "diversified" if its size is 2 bytes or more and if it contains at least 2 different byte values (not all 0x00 or not all 0xFF for instance).
std::istream & ts::Section::read | ( | std::istream & | strm, |
CRC32::Validation | crc_op = CRC32::Validation::IGNORE , |
||
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Read a section from standard streams (binary mode).
[in,out] | strm | A standard stream in input mode. If a section is invalid (eof before end of section, wrong crc), the failbit of the stream is set. |
[in] | crc_op | How to process the CRC32 of the input packet. |
[in,out] | report | Where to report errors. |
std::ostream & ts::Section::write | ( | std::ostream & | strm, |
Report & | report = (ts::CerrReport::Instance()) |
||
) | const |
Write a section to standard streams (binary mode).
[in,out] | strm | A standard stream in output mode. |
[in,out] | report | Where to report errors. |
std::ostream & ts::Section::dump | ( | std::ostream & | strm, |
int | indent = 0 , |
||
uint16_t | cas = CASID_NULL , |
||
bool | no_header = false |
||
) | const |
Hexa dump the section on an output stream without interpretation of the payload.
[in,out] | strm | A standard stream in output mode (text mode). |
[in] | indent | Indicates the base indentation of lines. |
[in] | cas | CAS id, for CAS-specific information. |
[in] | no_header | If true, do not display the section header. |
|
static |
Static method to compute a section size.
[in] | content | Address of the binary section data. |
[in] | content_size | Size in bytes of the buffer containing the section and possibly trailing additional data. |
|
inlinestatic |
Static method to compute a section size.
[in] | content | Buffer containing the section and possibly trailing additional data. |
|
static |
Static method to compute the minimum number of TS packets required to transport a set of sections.
CONTAINER | A container class of SectionPtr as defined by the C++ Standard Template Library (STL). |
[in] | container | A container class of SectionPtr. |
[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. |
|
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. |
|
inlineinherited |
Get the source PID.
|
inlineinherited |
Set the source PID.
[in] | pid | The source PID. |
|
inlineinherited |
Index of first TS packet of the data in the demultiplexed stream.
Usually valid only if the data were extracted by a demux.
|
inlineinherited |
Index of last TS packet of the data in the demultiplexed stream.
Usually valid only if the data were extracted by a demux.
|
inlineinherited |
Set the first TS packet of the data in the demultiplexed stream.
[in] | i | The first TS packet of the data in the demultiplexed stream. |
|
inlineinherited |
Set the last TS packet of the data in the demultiplexed stream.
[in] | i | The last TS packet of the data in the demultiplexed stream. |
|
inlineinherited |
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.
[in] | attr | Generic string to set as attribute. |
|
inlineinherited |
Get the generic user-defined "attribute" string of the object.
|
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 DemuxedData, this is the logical size of the data structure inside the DemuxedData blob.
Reimplemented in ts::PESPacket.
|
inherited |
Size of the complete binary raw data containing the logical structure.
|
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. |
|
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. |