TSDuck v3.46-4964
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches

#include <tsSection.h>

Inheritance diagram for ts::Section:
Collaboration diagram for ts::Section:

Public Types

enum  Status {
  VALID ,
  UNDEFINED ,
  INV_DATA ,
  INV_HEADER ,
  INV_SIZE ,
  INV_SEC_NUM ,
  INV_CRC32 ,
  INV_REPEAT
}
using SuperClass = DemuxedData

Public Member Functions

 Section ()=default
 Section (const ByteBlock &content, PID source_pid=PID_NULL, CRC32::Validation crc_op=CRC32::Validation::IGNORE)
 Section (const ByteBlockPtr &content_ptr, PID source_pid=PID_NULL, CRC32::Validation crc_op=CRC32::Validation::IGNORE)
 Section (const Section &other, ShareMode mode)
 Section (const void *content, size_t content_size, PID source_pid=PID_NULL, CRC32::Validation crc_op=CRC32::Validation::IGNORE)
 Section (TID tid, bool is_private_section, const void *payload, size_t payload_size, PID source_pid=PID_NULL)
 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)
void appendPayload (const ByteBlock &data, bool recompute_crc=true)
void appendPayload (const void *data, size_t size, bool recompute_crc=true)
const UString & attribute () const
virtual void clear () override
virtual const uint8_t * content () const
DataBlock & copy (const DataBlock &other)
DemuxedData & copy (const DemuxedData &other)
Section & copy (const Section &other)
virtual Standards definingStandards (Standards current_standards=Standards::NONE) const override
std::ostream & dump (std::ostream &strm, int indent=0, CASID cas=CASID_NULL, bool no_header=false) const
PacketCounter firstTSPacketIndex () const
bool hasDiversifiedPayload () const
ByteBlock hash () const
size_t headerSize () const
bool isCurrent () const
bool isLongSection () const
bool isNext () const
bool isPrivateSection () const
bool isShortSection () const
virtual bool isValid () const override
uint8_t lastSectionNumber () const
PacketCounter lastTSPacketIndex () const
bool matchContent (const ByteBlock &pattern, const ByteBlock &mask=ByteBlock()) const
Section & operator= (const Section &&other) noexcept
Section & operator= (const Section &other)
bool operator== (const DataBlock &other) const
bool operator== (const DemuxedData &other) const
bool operator== (const Section &other) const
PacketCounter packetCount () const
const uint8_t * payload () const
size_t payloadSize () const
size_t rawDataSize () const
std::istream & read (std::istream &strm, CRC32::Validation crc_op=CRC32::Validation::IGNORE, Report &report=(ts::CerrReport::Instance()))
void recomputeCRC ()
void reload (const ByteBlock &content)
void reload (const ByteBlockPtr &content_ptr)
void reload (const void *content, size_t content_size)
void reload (const ByteBlock &content, PID source_pid, CRC32::Validation crc_op)
virtual void reload (const ByteBlock &content, PID source_pid=PID_NULL) override
void reload (const ByteBlockPtr &content_ptr, PID source_pid, CRC32::Validation crc_op)
virtual void reload (const ByteBlockPtr &content_ptr, PID source_pid=PID_NULL) override
void reload (const void *content, size_t content_size, PID source_pid, CRC32::Validation crc_op)
virtual void reload (const void *content, size_t content_size, PID source_pid=PID_NULL) override
void reload (TID tid, bool is_private_section, const void *payload, size_t payload_size, PID source_pid=PID_NULL)
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)
uint8_t sectionNumber () const
void setAttribute (const UString &attr)
void setFirstTSPacketIndex (PacketCounter i)
void setIsCurrent (bool is_current, bool recompute_crc=true)
void setLastSectionNumber (uint8_t num, bool recompute_crc=true)
void setLastTSPacketIndex (PacketCounter i)
void setSectionNumber (uint8_t num, bool recompute_crc=true)
void setSourcePID (PID pid)
void setTableId (uint8_t tid, bool recompute_crc=true)
void setTableIdExtension (uint16_t tid_ext, bool recompute_crc=true)
void setUInt16 (size_t offset, uint16_t value, bool recompute_crc=true)
void setUInt32 (size_t offset, uint32_t value, bool recompute_crc=true)
void setUInt8 (size_t offset, uint8_t value, bool recompute_crc=true)
void setVersion (uint8_t version, bool recompute_crc=true)
virtual size_t size () const
PID sourcePID () const
Status status () const
TID tableId () const
uint16_t tableIdExtension () const
void truncatePayload (size_t size, bool recompute_crc=true)
uint8_t version () const
std::ostream & write (std::ostream &strm, Report &report=(ts::CerrReport::Instance())) const
XTID xtid () const

Static Public Member Functions

static size_t GetLengthField (const void *content, size_t content_size)
template<class CONTAINER>
static PacketCounter PacketCount (const CONTAINER &container, bool pack=true)
static size_t SectionSize (const ByteBlock &content)
static size_t SectionSize (const void *content, size_t content_size)
static bool StartLongSection (const uint8_t *data, size_t size)
static bool StartShortSection (const uint8_t *data, size_t size)
static const Names & StatusEnum ()
static size_t UncheckedSectionSize (const void *content, size_t content_size)
static bool ValidateLengthField (const void *content, size_t content_size, bool allow_extra_data)

Static Public Attributes

static constexpr size_t AFTER_LEN_BYTE_OFFSET = LEN_SIZE == 0 ? 0 : (LEN_OFFSET + LEN_SIZE + 7) / 8
static constexpr size_t LEN_BIT_OFFSET = LEN_SIZE == 0 ? 0 : LEN_OFFSET
static constexpr size_t LEN_BIT_SIZE = LEN_SIZE
static constexpr bool UNBOUNDED_IS_ALLOWED = UNBOUNDED_ALLOWED

Protected Member Functions

void rwAppend (const void *data, size_t dsize)
uint8_t * rwContent ()
void rwResize (size_t s)

Detailed Description

Representation of MPEG PSI/SI sections.

What to do with the CRC32 when building a section depends on the parameter named crc_op:

  • IGNORE: Neither check nor compute.
  • CHECK: Validate the CRC from the section data. Mark the section as invalid if CRC is incorrect.
  • COMPUTE: Compute the CRC and store it in the section.

Typically, if the ByteBlock comes from the wire, use CHECK. If the ByteBlock is built by the application, use COMPUTE,

Member Typedef Documentation

◆ SuperClass

Explicit identification of super class.

Member Enumeration Documentation

◆ Status

Status of a section, including reasons for invalid sections.

Enumerator
VALID 

Section is valid.

UNDEFINED 

Section is invalid for some undefined reason.

INV_DATA 

Invalid memory data (e.g. null pointer, uninitialized object).

INV_HEADER 

Invalid section header (e.g. truncated, no complete header).

INV_SIZE 

Invalid section size in header, does not match the data size.

INV_SEC_NUM 

Invalid section number, greater than "last section number".

INV_CRC32 

Invalid CRC32, corrupted section.

INV_REPEAT 

Invalid repeated section: same version but different content.

Constructor & Destructor Documentation

◆ Section() [1/7]

ts::Section::Section ( )
default

Default constructor. Section is initially marked invalid.

◆ Section() [2/7]

ts::Section::Section ( const Section & other,
ShareMode mode )

Copy constructor.

Parameters
[in]otherAnother instance to copy.
[in]modeThe section's data are either shared (ShareMode::SHARE) between the two instances or duplicated (ShareMode::COPY).

◆ Section() [3/7]

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.

Parameters
[in]contentAddress of the binary section data.
[in]content_sizeSize in bytes of the section.
[in]source_pidPID from which the section was read.
[in]crc_opHow to process the CRC32.

◆ Section() [4/7]

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.

Parameters
[in]contentBinary section data.
[in]source_pidPID from which the section was read.
[in]crc_opHow to process the CRC32.

◆ Section() [5/7]

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.

Parameters
[in]content_ptrSafe pointer to the binary section data. The content is referenced, and thus shared. Do not modify the referenced ByteBlock from outside the Section.
[in]source_pidPID from which the section was read.
[in]crc_opHow to process the CRC32.

◆ Section() [6/7]

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.

Parameters
[in]tidTable id.
[in]is_private_sectionIf true, this is a private section (ie. not MPEG-defined).
[in]payloadAddress of the payload data.
[in]payload_sizeSize in bytes of the payload data.
[in]source_pidPID from which the section was read.

◆ Section() [7/7]

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.

Parameters
[in]tidTable id.
[in]is_private_sectionIf true, this is a private section (ie. not MPEG-defined).
[in]tid_extTable id extension.
[in]versionSection version number.
[in]is_currentIf true, this is a "current" section, not a "next" section.
[in]section_numberSection number.
[in]last_section_numberNumber of last section in the table.
[in]payloadAddress of the payload data.
[in]payload_sizeSize in bytes of the payload data.
[in]source_pidPID from which the section was read.

Member Function Documentation

◆ StatusEnum()

const Names & ts::Section::StatusEnum ( )
static

Enumeration description of ts::Section::Status.

Returns
A constant reference to the enumeration description.

◆ clear()

virtual void ts::Section::clear ( )
overridevirtual

Clear data content.

Reimplemented from ts::DemuxedData.

◆ reload() [1/11]

virtual void ts::Section::reload ( const void * content,
size_t content_size,
PID source_pid = PID_NULL )
overridevirtual

Reload from full binary content.

Parameters
[in]contentAddress of the binary packet data.
[in]content_sizeSize in bytes of the packet.
[in]source_pidPID from which the data were read.

Reimplemented from ts::DemuxedData.

◆ reload() [2/11]

virtual void ts::Section::reload ( const ByteBlock & content,
PID source_pid = PID_NULL )
overridevirtual

Reload from full binary content.

Parameters
[in]contentBinary packet data.
[in]source_pidPID from which the data were read.

Reimplemented from ts::DemuxedData.

◆ reload() [3/11]

virtual void ts::Section::reload ( const ByteBlockPtr & content_ptr,
PID source_pid = PID_NULL )
overridevirtual

Reload from full binary content.

Parameters
[in]content_ptrSafe 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_pidPID from which the data were read.

Reimplemented from ts::DemuxedData.

◆ definingStandards()

virtual Standards ts::Section::definingStandards ( Standards current_standards = Standards::NONE) const
overridevirtual

Get the list of standards which define this object.

Parameters
[in]current_standardsCurrent standards in the stream so far. This is a hint which may help the object to determine to which standard it belongs. This can be used by objects with slightly different semantics depending on the standard.
Returns
A bit mask of standards.

Implements ts::AbstractDefinedByStandards.

◆ reload() [4/11]

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.

Parameters
[in]contentAddress of the binary section data.
[in]content_sizeSize in bytes of the section.
[in]source_pidPID from which the section was read.
[in]crc_opHow to process the CRC32.

◆ reload() [5/11]

void ts::Section::reload ( const ByteBlock & content,
PID source_pid,
CRC32::Validation crc_op )

Reload from full binary content.

Parameters
[in]contentBinary section data.
[in]source_pidPID from which the section was read.
[in]crc_opHow to process the CRC32.

◆ reload() [6/11]

void ts::Section::reload ( const ByteBlockPtr & content_ptr,
PID source_pid,
CRC32::Validation crc_op )

Reload from full binary content.

Parameters
[in]content_ptrSafe pointer to the binary section data. The content is referenced, and thus shared. Do not modify the referenced ByteBlock from outside the Section.
[in]source_pidPID from which the section was read.
[in]crc_opHow to process the CRC32.

◆ reload() [7/11]

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.

Parameters
[in]tidTable id.
[in]is_private_sectionIf true, this is a private section (ie. not MPEG-defined).
[in]payloadAddress of the payload data.
[in]payload_sizeSize in bytes of the payload data.
[in]source_pidPID from which the section was read.

◆ reload() [8/11]

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.

Parameters
[in]tidTable id.
[in]is_private_sectionIf true, this is a private section (ie. not MPEG-defined).
[in]tid_extTable id extension.
[in]versionSection version number.
[in]is_currentIf true, this is a "current" section, not a "next" section.
[in]section_numberSection number.
[in]last_section_numberNumber of last section in the table.
[in]payloadAddress of the payload data.
[in]payload_sizeSize in bytes of the payload data.
[in]source_pidPID from which the section was read.

◆ operator=() [1/2]

Section & ts::Section::operator= ( const Section & other)

Assignment operator. The sections contents are referenced, and thus shared between the two section objects.

Parameters
[in]otherOther section to assign to this object.
Returns
A reference to this object.

◆ operator=() [2/2]

Section & ts::Section::operator= ( const Section && other)
noexcept

Move assignment operator.

Parameters
[in,out]otherOther section to move into this object.
Returns
A reference to this object.

◆ copy() [1/3]

Section & ts::Section::copy ( const Section & other)

Duplication. Similar to assignment but the sections are duplicated.

Parameters
[in]otherOther section to duplicate into this object.
Returns
A reference to this object.

◆ isValid()

virtual bool ts::Section::isValid ( ) const
overridevirtual

Check if the section has valid content.

Returns
True if the section has valid content.

Reimplemented from ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >.

◆ status()

Status ts::Section::status ( ) const
inline

Get the section status.

Returns
The section status. If not VALID, this value indicates why the section is invalid.

◆ operator==() [1/3]

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.

Parameters
[in]otherOther section to compare.
Returns
True if the two sections are identical. False otherwise.

◆ tableId()

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

Get the table id.

Returns
The table id or TID_NULL if the table is invalid.

◆ StartLongSection()

bool ts::Section::StartLongSection ( const uint8_t * data,
size_t size )
static

This static method checks if a data area of at least 3 bytes can be the start of a long section.

Parameters
[in]dataAddress of the data area.
[in]sizeSize in bytes of the data area.
Returns
True if the section is a long one.

◆ StartShortSection()

bool ts::Section::StartShortSection ( const uint8_t * data,
size_t size )
static

This static method checks if a data area of at least 3 bytes can be the start of a short section.

Parameters
[in]dataAddress of the data area.
[in]sizeSize in bytes of the data area.
Returns
True if the section is a short one.

◆ isLongSection()

bool ts::Section::isLongSection ( ) const

Check if the section is a long one.

Returns
True if the section is a long one.

◆ isShortSection()

bool ts::Section::isShortSection ( ) const

Check if the section is a short one.

Returns
True if the section is a short one.

◆ isPrivateSection()

bool ts::Section::isPrivateSection ( ) const
inline

Check if the section is a private one (ie. not MPEG-defined).

Returns
True if the section is a private one (ie. not MPEG-defined).

◆ tableIdExtension()

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

Get the table id extension (long section only).

Returns
The table id extension.

◆ version()

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

Get the section version number (long section only).

Returns
The section version number.

◆ isCurrent()

bool ts::Section::isCurrent ( ) const
inline

Check if the section is "current", not "next" (long section only).

Returns
True if the section is "current", false if it is "next".

◆ isNext()

bool ts::Section::isNext ( ) const
inline

Check if the section is "next", not "current" (long section only).

Returns
True if the section is "next", false if it is "current".

◆ sectionNumber()

uint8_t ts::Section::sectionNumber ( ) const
inline

Get the section number in the table (long section only).

Returns
The section number in the table.

◆ lastSectionNumber()

uint8_t ts::Section::lastSectionNumber ( ) const
inline

Get the number of the last section in the table (long section only).

Returns
The number of the last section in the table.

◆ xtid()

XTID ts::Section::xtid ( ) const
inline

Get the table id and id extension (long section only).

Returns
The table id and id extension as an XTID.

◆ headerSize()

size_t ts::Section::headerSize ( ) const
inline

Size of the section header.

Returns
Size of the section header.

◆ payload()

const uint8_t * ts::Section::payload ( ) const
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.

Returns
Address of the payload of the section.

◆ payloadSize()

size_t ts::Section::payloadSize ( ) const
inline

Get the size of the payload of the section. For long sections, the payload ends before the CRC32 field.

Returns
Size in bytes of the payload of the section.

◆ hash()

ByteBlock ts::Section::hash ( ) const

Get a hash of the section content.

Returns
SHA-1 value of the section content.

◆ packetCount()

PacketCounter ts::Section::packetCount ( ) const
inline

Minimum number of TS packets required to transport the section.

Returns
The minimum number of TS packets required to transport the section.

◆ setTableId()

void ts::Section::setTableId ( uint8_t tid,
bool recompute_crc = true )

Set the table id.

Parameters
[in]tidThe table id.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ setTableIdExtension()

void ts::Section::setTableIdExtension ( uint16_t tid_ext,
bool recompute_crc = true )

Set the table id extension (long section only).

Parameters
[in]tid_extThe table id extension.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ setVersion()

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

Set the section version number (long section only).

Parameters
[in]versionThe section version number.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ setIsCurrent()

void ts::Section::setIsCurrent ( bool is_current,
bool recompute_crc = true )

Set the section current/next flag (long section only).

Parameters
[in]is_currentTrue if the table is "current", false if it is "next".
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ setSectionNumber()

void ts::Section::setSectionNumber ( uint8_t num,
bool recompute_crc = true )

Set the section number (long section only).

Parameters
[in]numThe section number.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ setLastSectionNumber()

void ts::Section::setLastSectionNumber ( uint8_t num,
bool recompute_crc = true )

Set the number of the last section in the table (long section only).

Parameters
[in]numThe number of the last section in the table.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ setUInt8()

void ts::Section::setUInt8 ( size_t offset,
uint8_t value,
bool recompute_crc = true )

Set one byte in the payload of the section.

Parameters
[in]offsetByte offset in the payload.
[in]valueThe value to set in the payload.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ setUInt16()

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.

Parameters
[in]offsetByte offset in the payload.
[in]valueThe value to set in the payload.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ setUInt32()

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.

Parameters
[in]offsetByte offset in the payload.
[in]valueThe value to set in the payload.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ appendPayload() [1/2]

void ts::Section::appendPayload ( const void * data,
size_t size,
bool recompute_crc = true )

Append binary data to the payload of the section.

Parameters
[in]dataAddress of data to add to the payload.
[in]sizeSize in bytes of data to add to the payload.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ appendPayload() [2/2]

void ts::Section::appendPayload ( const ByteBlock & data,
bool recompute_crc = true )
inline

Append binary data to the payload of the section.

Parameters
[in]dataByte block to add to the payload.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ truncatePayload()

void ts::Section::truncatePayload ( size_t size,
bool recompute_crc = true )

Truncate the payload of the section.

Parameters
[in]sizeNew size in bytes of the payload. If larger than the current payload size, does nothing.
[in]recompute_crcIf true, immediately recompute the CRC32 of the section.

◆ recomputeCRC()

void ts::Section::recomputeCRC ( )

This method recomputes and replaces the CRC32 of the section.

◆ hasDiversifiedPayload()

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

Returns
True if the payload is diversified.

◆ read()

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

Parameters
[in,out]strmA 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_opHow to process the CRC32 of the input packet.
[in,out]reportWhere to report errors.
Returns
A reference to the strm object.

◆ write()

std::ostream & ts::Section::write ( std::ostream & strm,
Report & report = (ts::CerrReport::Instance()) ) const

Write a section to standard streams (binary mode).

Parameters
[in,out]strmA standard stream in output mode.
[in,out]reportWhere to report errors.
Returns
A reference to the strm object.

◆ dump()

std::ostream & ts::Section::dump ( std::ostream & strm,
int indent = 0,
CASID cas = CASID_NULL,
bool no_header = false ) const

Hexa dump the section on an output stream without interpretation of the payload.

Parameters
[in,out]strmA standard stream in output mode (text mode).
[in]indentIndicates the base indentation of lines.
[in]casCAS id, for CAS-specific information.
[in]no_headerIf true, do not display the section header.
Returns
A reference to the strm object.

◆ SectionSize() [1/2]

size_t ts::Section::SectionSize ( const void * content,
size_t content_size )
static

Static method to compute and validate a section size.

Parameters
[in]contentAddress of the binary section data.
[in]content_sizeSize in bytes of the buffer containing the section and possibly trailing additional data.
Returns
The total size in bytes of the section starting at content or zero on error.

◆ UncheckedSectionSize()

size_t ts::Section::UncheckedSectionSize ( const void * content,
size_t content_size )
static

Static method to compute a section size, without validation.

Parameters
[in]contentAddress of the binary section data.
[in]content_sizeSize in bytes of the buffer containing at least the beginning of a section.
Returns
The total size in bytes of the section starting at content or zero when the size cannot be evaluated (null pointer or not enough data to find a length).

◆ SectionSize() [2/2]

size_t ts::Section::SectionSize ( const ByteBlock & content)
inlinestatic

Static method to compute a section size.

Parameters
[in]contentBuffer containing the section and possibly trailing additional data.
Returns
The total size in bytes of the section starting in content or zero on error.

◆ PacketCount()

template<class CONTAINER>
PacketCounter ts::Section::PacketCount ( const CONTAINER & container,
bool pack = true )
static

Static method to compute the minimum number of TS packets required to transport a set of sections.

Template Parameters
CONTAINERA container class of SectionPtr as defined by the C++ Standard Template Library (STL).
Parameters
[in]containerA container class of SectionPtr.
[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 sections in container.

◆ reload() [9/11]

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
void ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::reload ( const void * content,
size_t content_size )
inherited

Reload from full binary content.

Parameters
[in]contentAddress of the binary packet data.
[in]content_sizeSize in bytes of the packet.

◆ reload() [10/11]

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
void ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::reload ( const ByteBlock & content)
inherited

Reload from full binary content.

Parameters
[in]contentBinary packet data. The content is copied into a new byte block.

◆ reload() [11/11]

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
void ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::reload ( const ByteBlockPtr & content_ptr)
inherited

Reload from full binary content.

Parameters
[in]content_ptrSafe pointer to the binary packet data. The content is referenced, and thus shared. Do not modify the referenced ByteBlock from outside the DataBlock.

◆ copy() [2/3]

DemuxedData & ts::DemuxedData::copy ( const DemuxedData & other)
inherited

Duplication. Similar to assignment but the data are duplicated.

Parameters
[in]otherOther data to duplicate into this object.
Returns
A reference to this object.

◆ copy() [3/3]

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
DataBlock & ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::copy ( const DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED > & other)
inherited

Duplication. Similar to assignment but the data are duplicated.

Parameters
[in]otherOther data to duplicate into this object.
Returns
A reference to this object.

◆ operator==() [2/3]

bool ts::DemuxedData::operator== ( const DemuxedData & other) const
inherited

Equality operator. The source PID's are ignored, only the data contents are compared.

Parameters
[in]otherOther packet to compare.
Returns
True if the two packets are identical. False otherwise.

◆ operator==() [3/3]

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
bool ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::operator== ( const DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED > & other) const
inherited

Equality operator. The source PID's are ignored, only the data contents are compared.

Parameters
[in]otherOther packet to compare.
Returns
True if the two packets are identical. False otherwise.

◆ sourcePID()

PID ts::DemuxedData::sourcePID ( ) const
inlineinherited

Get the source PID.

Returns
The source PID.

◆ setSourcePID()

void ts::DemuxedData::setSourcePID ( PID pid)
inlineinherited

Set the source PID.

Parameters
[in]pidThe source PID.

◆ firstTSPacketIndex()

PacketCounter ts::DemuxedData::firstTSPacketIndex ( ) const
inlineinherited

Index of first TS packet of the data in the demultiplexed stream. Usually valid only if the data were extracted by a demux.

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

◆ lastTSPacketIndex()

PacketCounter ts::DemuxedData::lastTSPacketIndex ( ) const
inlineinherited

Index of last TS packet of the data in the demultiplexed stream. Usually valid only if the data were extracted by a demux.

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

◆ setFirstTSPacketIndex()

void ts::DemuxedData::setFirstTSPacketIndex ( PacketCounter i)
inlineinherited

Set the first TS packet of the data in the demultiplexed stream.

Parameters
[in]iThe first TS packet of the data in the demultiplexed stream.

◆ setLastTSPacketIndex()

void ts::DemuxedData::setLastTSPacketIndex ( PacketCounter i)
inlineinherited

Set the last TS packet of the data in the demultiplexed stream.

Parameters
[in]iThe last TS packet of the data in the demultiplexed stream.

◆ setAttribute()

void ts::DemuxedData::setAttribute ( const UString & attr)
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.

Parameters
[in]attrGeneric string to set as attribute.

◆ attribute()

const UString & ts::DemuxedData::attribute ( ) const
inlineinherited

Get the generic user-defined "attribute" string of the object.

Returns
A constant reference to the attribute string in the object.
See also
setAttribute()

◆ content()

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
virtual const uint8_t * ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::content ( ) const
virtualinherited

Access to the full binary content of the data. Do not modify content.

Returns
Address of the full binary content of the data. May be invalidated after modification.

◆ size()

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
virtual size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::size ( ) const
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.

Returns
Size of the logical binary content of the data.
See also
rawDataSize()

Reimplemented in ts::PESPacket.

◆ rawDataSize()

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::rawDataSize ( ) const
inlineinherited

Size of the complete binary raw data containing the logical structure. Non-virtual method, always return the same result.

Returns
Size of the complete binary raw data.
See also
size()

◆ matchContent()

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
bool ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::matchContent ( const ByteBlock & pattern,
const ByteBlock & mask = ByteBlock() ) const
inherited

Check if the start of the data matches a given pattern.

Parameters
[in]patternA byte block to compare with the start of the data.
[in]maskOptional mask to select meaningful bits in pattern.
Returns
Size of the binary content of the data.

◆ GetLengthField()

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::GetLengthField ( const void * content,
size_t content_size )
staticinherited

Static method to extract the content of the length field.

Parameters
[in]contentAddress of the binary data. Can be the null pointer.
[in]content_sizeSize in bytes of the data.
Returns
The extracted length field or NPOS if the data structure does not contain a length field or if the length is "unbounded" (when allowed).

◆ ValidateLengthField()

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
bool ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::ValidateLengthField ( const void * content,
size_t content_size,
bool allow_extra_data )
staticinherited

Static method to validate the content of the length field.

Parameters
[in]contentAddress of the binary data. Can be the null pointer.
[in]content_sizeSize in bytes of the data.
[in]allow_extra_dataIf true, additional data are allowed after the declared length.
Returns
True if the length field is valid, or the length field does not exist, or the length field is "unbounded" (when allowed).

◆ rwContent()

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
uint8_t * ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::rwContent ( )
inlineprotectedinherited

Read/write access to the full binary content of the data for subclasses.

Returns
Address of the full binary content of the data.

◆ rwResize()

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
void ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::rwResize ( size_t s)
protectedinherited

Resize the full binary content of the data for subclasses.

Parameters
[in]sNew size in bytes of the full binary content of the data.

◆ rwAppend()

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
void ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::rwAppend ( const void * data,
size_t dsize )
protectedinherited

Append raw data to the full binary content of the data for subclasses.

Parameters
[in]dataAddress of the new area to append.
[in]dsizeSize of the area to append.

Member Data Documentation

◆ LEN_BIT_OFFSET

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::LEN_BIT_OFFSET = LEN_SIZE == 0 ? 0 : LEN_OFFSET
staticconstexprinherited

Offset in bits of the length field from the beginning of the structure.

◆ LEN_BIT_SIZE

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::LEN_BIT_SIZE = LEN_SIZE
staticconstexprinherited

Size in bits of the length field. If zero, there is no length field.

◆ AFTER_LEN_BYTE_OFFSET

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
size_t ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::AFTER_LEN_BYTE_OFFSET = LEN_SIZE == 0 ? 0 : (LEN_OFFSET + LEN_SIZE + 7) / 8
staticconstexprinherited

Offset in bytes of the next byte after the length field. Zero if there is no length field.

◆ UNBOUNDED_IS_ALLOWED

template<const size_t LEN_OFFSET = 0, const size_t LEN_SIZE = 0, const bool UNBOUNDED_ALLOWED = false>
bool ts::DataBlock< LEN_OFFSET, LEN_SIZE, UNBOUNDED_ALLOWED >::UNBOUNDED_IS_ALLOWED = UNBOUNDED_ALLOWED
staticconstexprinherited

If true, the length field allows zero as an "unbounded" value.


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