TSDuck v3.46-4930
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::DescriptorList Class Reference

#include <tsDescriptorList.h>

Inheritance diagram for ts::DescriptorList:
Collaboration diagram for ts::DescriptorList:

Classes

class  const_iterator
class  iterator

Public Member Functions

 DescriptorList (const AbstractTable *table)
 DescriptorList (const AbstractTable *table, const DescriptorList &dl)
 DescriptorList (const AbstractTable *table, DescriptorList &&dl) noexcept
bool add (const Descriptor &desc)
void add (const DescriptorList &dl)
bool add (const DescriptorPtr &desc)
bool add (const void *addr)
bool add (const void *addr, size_t size)
bool add (DuckContext &duck, const AbstractDescriptor &desc)
void addPrivateDataSpecifier (PDS pds)
void addPrivateIdentifier (EDID edid)
void addRegistration (REGID regid)
iterator begin ()
const_iterator begin () const
size_t binarySize (size_t start=0, size_t count=NPOS) const
void clear ()
bool containsRegistration (REGID regid) const
size_t count () const
EDID edid (const DuckContext &duck, size_t index) const
bool empty () const
iterator end ()
const_iterator end () const
bool fromXML (DuckContext &duck, const xml::Element *parent)
bool fromXML (DuckContext &duck, const xml::Element *parent, const UString &allowed_others)
bool fromXML (DuckContext &duck, const xml::Element *parent, const UStringList &allowed_others)
void getAllLanguages (const DuckContext &duck, UStringVector &languages, size_t max_count=NPOS) const
void getAllRegistrations (const DuckContext &duck, REGIDVector &regids) const
bool hasTable () const
size_t lengthSerialize (uint8_t *&addr, size_t &size, size_t start=0, uint16_t reserved_bits=0x000F, size_t length_bits=12) const
bool merge (DuckContext &duck, const AbstractDescriptor &desc)
void merge (DuckContext &duck, const DescriptorList &other)
DescriptorList & operator= (const DescriptorList &dl)
DescriptorList & operator= (DescriptorList &&dl) noexcept
bool operator== (const DescriptorList &other) const
Descriptor & operator[] (size_t index)
const Descriptor & operator[] (size_t index) const
PDS privateDataSpecifier (size_t index) const
REGID registrationId (size_t index) const
bool removeByIndex (size_t index)
size_t removeByTag (DID tag, PDS pds=0)
size_t removeInvalidPrivateDescriptors ()
size_t search (const EDID &edid, size_t start_index=0) const
size_t search (DID tag, size_t start_index=0, PDS pds=0) const
template<class DESC>
requires std::derived_from<DESC, ts::AbstractDescriptor>
size_t search (DuckContext &duck, DID tag, DESC &desc, size_t start_index=0, PDS pds=0) const
size_t searchLanguage (const DuckContext &duck, const UString &language, size_t start_index=0) const
size_t searchSubtitle (const DuckContext &duck, const UString &language=UString(), size_t start_index=0) const
size_t serialize (ByteBlock &bb, size_t start=0) const
size_t serialize (uint8_t *&addr, size_t &size, size_t start=0) const
size_t size () const
const AbstractTable * table () const
TID tableId () const
Standards tableStandards () const
bool toXML (DuckContext &duck, xml::Element *parent) const

Detailed Description

List of MPEG PSI/SI descriptors.

Constructor & Destructor Documentation

◆ DescriptorList() [1/3]

ts::DescriptorList::DescriptorList ( const AbstractTable * table)
explicit

Basic constructor.

Parameters
[in]tableParent table. A descriptor list is always attached to a table it is part of. Use zero for a descriptor list object outside a table. There is no default value because zero is considered as an unusual use case and we want to avoid missing table pointer in constructors of the various tables.

◆ DescriptorList() [2/3]

ts::DescriptorList::DescriptorList ( const AbstractTable * table,
const DescriptorList & dl )

Basic copy-like constructor. We forbid a real copy constructor because we want to copy the descriptors only, while the parent table is usually different. The descriptors objects are shared between the two lists.

Parameters
[in]tableParent table. A descriptor list is always attached to a table it is part of. Use zero for a descriptor list object outside a table.
[in]dlAnother instance to copy.

◆ DescriptorList() [3/3]

ts::DescriptorList::DescriptorList ( const AbstractTable * table,
DescriptorList && dl )
noexcept

Basic move-like constructor. We forbid a real move constructor because we want to copy the descriptors only, while the parent table is usually different.

Parameters
[in]tableParent table. A descriptor list is always attached to a table it is part of. Use zero for a descriptor list object outside a table.
[in,out]dlAnother instance to move.

Member Function Documentation

◆ operator=() [1/2]

DescriptorList & ts::DescriptorList::operator= ( const DescriptorList & dl)

Assignment operator. The descriptors objects are shared between the two lists. The parent table remains unchanged.

Parameters
[in]dlAnother instance to copy.
Returns
A reference to this object.

◆ operator=() [2/2]

DescriptorList & ts::DescriptorList::operator= ( DescriptorList && dl)
noexcept

Move assignment operator. The descriptors objects are moved. The parent table remains unchanged.

Parameters
[in,out]dlAnother instance to move.
Returns
A reference to this object.

◆ empty()

bool ts::DescriptorList::empty ( ) const
inline

Check if the descriptor list is empty.

Returns
True if the descriptor list is empty.

◆ size()

size_t ts::DescriptorList::size ( ) const
inline

Get the number of descriptors in the list (same as count()).

Returns
The number of descriptors in the list.

◆ count()

size_t ts::DescriptorList::count ( ) const
inline

Get the number of descriptors in the list (same as size()).

Returns
The number of descriptors in the list.

◆ operator==()

bool ts::DescriptorList::operator== ( const DescriptorList & other) const

Comparison operator.

Parameters
[in]otherAnother instance to compare.
Returns
True if the two descriptor lists are identical.

◆ operator[]() [1/2]

Descriptor & ts::DescriptorList::operator[] ( size_t index)

Get a reference to the descriptor at a specified index.

Parameters
[in]indexIndex in the list. Valid index are 0 to count()-1.
Returns
A reference to the descriptor at index.

◆ operator[]() [2/2]

const Descriptor & ts::DescriptorList::operator[] ( size_t index) const

Get a const reference to the descriptor at a specified index.

Parameters
[in]indexIndex in the list. Valid index are 0 to count()-1.
Returns
A const reference to the descriptor at index.

◆ begin() [1/2]

iterator ts::DescriptorList::begin ( )
inline

Get an iterator to the first descriptor in the list.

Returns
An iterator to the first descriptor in the list.

◆ end() [1/2]

iterator ts::DescriptorList::end ( )
inline

Get an iterator after the last descriptor in the list.

Returns
An iterator after the last descriptor in the list.

◆ begin() [2/2]

const_iterator ts::DescriptorList::begin ( ) const
inline

Get a constant iterator to the first descriptor in the list.

Returns
A constant iterator to the first descriptor in the list.

◆ end() [2/2]

const_iterator ts::DescriptorList::end ( ) const
inline

Get a constant iterator after the last descriptor in the list.

Returns
A constant iterator after the last descriptor in the list.

◆ edid()

EDID ts::DescriptorList::edid ( const DuckContext & duck,
size_t index ) const

Get the extended descriptor id of a descriptor in the list.

Parameters
[in]duckTSDuck execution context.
[in]indexIndex of a descriptor in the list. Valid index are 0 to count()-1.
Returns
The extended descriptor id at index.

◆ registrationId()

REGID ts::DescriptorList::registrationId ( size_t index) const

Return the MPEG "registration id" associated to a descriptor in the list.

Parameters
[in]indexIndex of a descriptor in the list. Valid index are 0 to count()-1.
Returns
The "registration id" associated to the descriptor at index or REGID_NULL.

◆ privateDataSpecifier()

PDS ts::DescriptorList::privateDataSpecifier ( size_t index) const

Return the "private data specifier" associated to a descriptor in the list.

Parameters
[in]indexIndex of a descriptor in the list. Valid index are 0 to count()-1.
Returns
The "private data specifier" associated to a descriptor at index or PDS_NULL.

◆ add() [1/6]

bool ts::DescriptorList::add ( const DescriptorPtr & desc)

Add one descriptor at end of list. The descriptor content is shared.

Parameters
[in]descThe binary descriptor to add.
Returns
True in case of success, false if the descriptor is invalid.

◆ add() [2/6]

bool ts::DescriptorList::add ( const Descriptor & desc)

Add one descriptor at end of list. The descriptor content is copied.

Parameters
[in]descThe binary descriptor to add.
Returns
True in case of success, false if the descriptor is invalid.

◆ add() [3/6]

bool ts::DescriptorList::add ( DuckContext & duck,
const AbstractDescriptor & desc )

Add one descriptor at end of list

Parameters
[in,out]duckTSDuck execution context.
[in]descThe descriptor to add.
Returns
True in case of success, false if the descriptor is invalid.

◆ add() [4/6]

void ts::DescriptorList::add ( const DescriptorList & dl)
inline

Add another list of descriptors at end of list. The descriptors objects are shared between the two lists.

Parameters
[in]dlThe descriptor list to add.

◆ add() [5/6]

bool ts::DescriptorList::add ( const void * addr,
size_t size )

Add descriptors from a memory area at end of list

Parameters
[in]addrAddress of descriptors in memory.
[in]sizeSize in bytes of descriptors in memory.
Returns
True in case of success, false in case of invalid or truncated descriptor.

◆ add() [6/6]

bool ts::DescriptorList::add ( const void * addr)

Add one descriptor from a memory area at end of list. The size is extracted from the descriptor header.

Parameters
[in]addrAddress of the descriptor in memory.
Returns
True in case of success, false if the descriptor is invalid.

◆ addRegistration()

void ts::DescriptorList::addRegistration ( REGID regid)

Add a MPEG registration_descriptor if necessary at end of list. If the current registration at end of list is not regid, a registration_descriptor is added. If regid is already the current registration id, the list is unchanged.

Parameters
[in]regidA registration id.

◆ addPrivateDataSpecifier()

void ts::DescriptorList::addPrivateDataSpecifier ( PDS pds)

Add a DVB private_data_specifier_descriptor if necessary at end of list. If the current private data specifier at end of list is not pds, a private_data_specifier descriptor is added. If pds is already the current private data specifier, the list is unchanged.

Parameters
[in]pdsA private data specifier.

◆ addPrivateIdentifier()

void ts::DescriptorList::addPrivateIdentifier ( EDID edid)

Add a MPEG registration_descriptor or a DVB private_data_specifier_descriptor if necessary at end of list.

Parameters
[in]edidExtended descriptor id of the descriptor to add and may need an preceding MPEG registration_descriptor or a DVB private_data_specifier_descriptor.

◆ containsRegistration()

bool ts::DescriptorList::containsRegistration ( REGID regid) const

Check if the descriptor list contains a MPEG registration descriptor with the specified id.

Parameters
[in]regidThe registration id to check.
Returns
True if regid is present in a registration descriptor.

◆ getAllRegistrations()

void ts::DescriptorList::getAllRegistrations ( const DuckContext & duck,
REGIDVector & regids ) const

Get a list of all registration ids, in all MPEG registration descriptors.

Parameters
[in]duckTSDuck execution context.
[out]regidsA list of all registration ids, in their order of appearance. The returned list can contain duplicates if the duplicates are present in the descriptor list.

◆ getAllLanguages()

void ts::DescriptorList::getAllLanguages ( const DuckContext & duck,
UStringVector & languages,
size_t max_count = NPOS ) const

Get a list of all language codes from all descriptors.

Parameters
[in]duckTSDuck execution context.
[out]languagesA list of all language codes, in their order of appearance. The returned list can contain duplicates if the duplicates are present in the descriptor list.
[in]max_countThe maximum number of languages to return. By default, return them all.

◆ merge() [1/2]

bool ts::DescriptorList::merge ( DuckContext & duck,
const AbstractDescriptor & desc )

Merge one descriptor in the list. If a descriptor of the same type is already present in the list, the DescriptorDuplication mode of the descriptor class is applied. If there is no descriptor of the same type, the descriptor is added at the end of the list.

Parameters
[in,out]duckTSDuck execution context.
[in]descThe descriptor to merge.
Returns
True in case of success, false if the descriptor is invalid.

◆ merge() [2/2]

void ts::DescriptorList::merge ( DuckContext & duck,
const DescriptorList & other )

Merge another descriptor list in this list. All descriptors are merged one by one.

Parameters
[in,out]duckTSDuck execution context.
[in]otherThe other descriptor list to merge.

◆ removeByIndex()

bool ts::DescriptorList::removeByIndex ( size_t index)

Remove the descriptor at the specified index in the list. A private_data_specifier descriptor can be removed only if it is not necessary (no private descriptor ahead).

Parameters
[in]indexIndex of the descriptor to remove.
Returns
True on success, false on error (index out of range or required private_data_specifier descriptor).

◆ removeByTag()

size_t ts::DescriptorList::removeByTag ( DID tag,
PDS pds = 0 )

Remove all descriptors with the specified tag. A private_data_specifier descriptor can be removed only if it is not necessary (no private descriptor ahead).

Parameters
[in]tagTag of descriptors to remove.
[in]pdsPrivate data specifier. If pds is non-zero and tag is >= 0x80, remove only descriptors with the corresponding private data specifier.
Returns
The number of removed descriptors.

◆ removeInvalidPrivateDescriptors()

size_t ts::DescriptorList::removeInvalidPrivateDescriptors ( )

Remove all DVB private descriptors without preceding private_data_specifier_descriptor.

Returns
The number of removed descriptors.

◆ clear()

void ts::DescriptorList::clear ( )
inline

Clear the content of the descriptor list.

◆ search() [1/3]

size_t ts::DescriptorList::search ( DID tag,
size_t start_index = 0,
PDS pds = 0 ) const

Search a descriptor with the specified tag.

Parameters
[in]tagTag of descriptor to search.
[in]start_indexStart searching at this index.
[in]pdsPrivate data specifier. If pds is non-zero and tag is >= 0x80, return only a descriptor with the corresponding private data specifier.
Returns
The index of the descriptor in the list or count() if no such descriptor is found.

◆ search() [2/3]

size_t ts::DescriptorList::search ( const EDID & edid,
size_t start_index = 0 ) const

Search a descriptor with the specified extended tag.

Parameters
[in]edidExtended tag of descriptor to search.
[in]start_indexStart searching at this index.
Returns
The index of the descriptor in the list or count() if no such descriptor is found.

◆ searchLanguage()

size_t ts::DescriptorList::searchLanguage ( const DuckContext & duck,
const UString & language,
size_t start_index = 0 ) const

Search a descriptor for the specified language. This can be an audio, subtitles or other component descriptor.

Parameters
[in]duckTSDuck execution context.
[in]languageThe 3-character language name to search.
[in]start_indexStart searching at this index.
Returns
The index of the descriptor in the list or count() if no such descriptor is found.

◆ searchSubtitle()

size_t ts::DescriptorList::searchSubtitle ( const DuckContext & duck,
const UString & language = UString(),
size_t start_index = 0 ) const

Search any kind of subtitle descriptor.

Parameters
[in]duckTSDuck execution context.
[in]languageThe language name to search. If language is non-empty, look only for a subtitle descriptor matching the specified language. In this case, if some kind of subtitle descriptor exists in the list but none matches the language, return count()+1.
[in]start_indexStart searching at this index.
Returns
The index of the descriptor in the list or count() if no such descriptor is found.

◆ search() [3/3]

template<class DESC>
requires std::derived_from<DESC, ts::AbstractDescriptor>
size_t ts::DescriptorList::search ( DuckContext & duck,
DID tag,
DESC & desc,
size_t start_index = 0,
PDS pds = 0 ) const

Search a descriptor with the specified tag.

Template Parameters
DESCA subclass of AbstractDescriptor.
Parameters
[in,out]duckTSDuck execution context.
[in]tagTag of descriptor to search.
[out]descWhen a descriptor with the specified tag is found, it is deserialized into desc. Always check desc.isValid() on return to check if the deserialization was successful.
[in]start_indexStart searching at this index.
[in]pdsPrivate data specifier. If pds is non-zero and tag is >= 0x80, return only a descriptor with the corresponding private data specifier.
Returns
The index of the descriptor in the list or count() if no such descriptor is found.

◆ binarySize()

size_t ts::DescriptorList::binarySize ( size_t start = 0,
size_t count = NPOS ) const

Total number of bytes that is required to serialize the list of descriptors.

Parameters
[in]startStarting index in the descriptor list.
[in]countMaximum number of descriptors to include in the size.
Returns
The total number of bytes that is required to serialize the list of descriptors.

◆ serialize() [1/2]

size_t ts::DescriptorList::serialize ( uint8_t *& addr,
size_t & size,
size_t start = 0 ) const

Serialize the content of the descriptor list.

Parameters
[in,out]addrAddress of the memory area where the descriptors are serialized. Upon return, addr is updated to contain the next address in memory, after the last serialized byte.
[in,out]sizeSize in bytes of the memory area where the descriptors are serialized. Upon return, size is updated to the remaining size of the buffer. Descriptors are written one by one until either the end of the list or until one descriptor does not fit.
[in]startStart searializing at this index.
Returns
The index of the first descriptor that could not be serialized (or count() if all descriptors were serialized). In the first case, the returned index can be used as start parameter to serialized the rest of the list (in another section for instance).

◆ serialize() [2/2]

size_t ts::DescriptorList::serialize ( ByteBlock & bb,
size_t start = 0 ) const

Serialize the content of the descriptor list in a byte block.

Parameters
[in,out]bbA byte block into which the descriptor list is appended.
[in]startStart searializing at this index.
Returns
The size in bytes of the serialized data.

◆ lengthSerialize()

size_t ts::DescriptorList::lengthSerialize ( uint8_t *& addr,
size_t & size,
size_t start = 0,
uint16_t reserved_bits = 0x000F,
size_t length_bits = 12 ) const

Same as serialize(), but prepend a 2-byte length field before the descriptor list. The 2-byte length field has 4 reserved bits and 12 bits for the length of the descriptor list. In fact, the number of bits in the length can be set in length_bits.

Parameters
[in,out]addrAddress of the memory area where the descriptors are serialized. Upon return, addr is updated to contain the next address in memory, after the last serialized byte.
[in,out]sizeSize in bytes of the memory area where the descriptors are serialized. Upon return, size is updated to the remaining size of the buffer. Descriptors are written one by one until either the end of the list or until one descriptor does not fit.
[in]startStart serializing at this index in the descriptor list.
[in]reserved_bitsValue of the upper bits of the length field.
[in]length_bitsNumber of meaningful bits in the length field.
Returns
The index of the first descriptor that could not be serialized (or count() if all descriptors were serialized). In the first case, the returned index can be used as start parameter to serialized the rest of the list (in another section for instance).

◆ toXML()

bool ts::DescriptorList::toXML ( DuckContext & duck,
xml::Element * parent ) const

This method converts a descriptor list to XML.

Parameters
[in,out]duckTSDuck execution context.
[in,out]parentThe parent node for the XML descriptors.
Returns
True on success, false on error.

◆ fromXML() [1/3]

bool ts::DescriptorList::fromXML ( DuckContext & duck,
const xml::Element * parent )

This method decodes an XML list of descriptors.

Parameters
[in,out]duckTSDuck execution context.
[in]parentThe XML element containing all descriptors. All children must be valid descriptors.
Returns
True on success, false on error.

◆ fromXML() [2/3]

bool ts::DescriptorList::fromXML ( DuckContext & duck,
const xml::Element * parent,
const UStringList & allowed_others )

This method decodes an XML list of descriptors.

Parameters
[in,out]duckTSDuck execution context.
[in]parentThe XML element containing all descriptors.
[in]allowed_othersA list of allowed element names inside parent which are not descriptors.
Returns
True on success, false on error.

◆ fromXML() [3/3]

bool ts::DescriptorList::fromXML ( DuckContext & duck,
const xml::Element * parent,
const UString & allowed_others )

This method decodes an XML list of descriptors.

Parameters
[in,out]duckTSDuck execution context.
[in]parentThe XML element containing all descriptors.
[in]allowed_othersA comma-separated list of allowed element names inside parent which are not descriptors.
Returns
True on success, false on error.

◆ tableId()

TID ts::AbstractTableAttachment::tableId ( ) const
inherited

Get the table id of the parent table.

Returns
The table id of the parent table or TID_NULL if there is none.

◆ tableStandards()

Standards ts::AbstractTableAttachment::tableStandards ( ) const
inherited

Get the standards of the parent table.

Returns
The standards of the parent table or NONE if there is none.

◆ table()

const AbstractTable * ts::AbstractTableAttachment::table ( ) const
inlineinherited

Get the parent table.

Returns
The parent table or zero if there is none.

◆ hasTable()

bool ts::AbstractTableAttachment::hasTable ( ) const
inlineinherited

Check if this instance has a parent table.

Returns
True if there is one parent table.

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