TSDuck Version 3.22-1913 (TSDuck - The MPEG Transport Stream Toolkit)
ts::DescriptorList Class Reference

List of MPEG PSI/SI descriptors. More...

Public Member Functions

 DescriptorList (const AbstractTable *table)
 Basic constructor. More...
 
 DescriptorList (const AbstractTable *table, const DescriptorList &dl)
 Basic copy-like constructor. More...
 
 DescriptorList (const AbstractTable *table, DescriptorList &&dl) noexcept
 Basic move-like constructor. More...
 
void add (const DescriptorPtr &desc)
 Add one descriptor at end of list. More...
 
void add (DuckContext &duck, const AbstractDescriptor &desc)
 Add one descriptor at end of list. More...
 
void add (const DescriptorList &dl)
 Add another list of descriptors at end of list. More...
 
void add (const void *addr, size_t size)
 Add descriptors from a memory area at end of list. More...
 
void add (const void *addr)
 Add one descriptor from a memory area at end of list. More...
 
void addPrivateDataSpecifier (PDS pds)
 Add a private_data_specifier descriptor if necessary at end of list. More...
 
size_t binarySize () const
 Total number of bytes that is required to serialize the list of descriptors. More...
 
void clear ()
 Clear the content of the descriptor list.
 
size_t count () const
 Get the number of descriptors in the list (same as size()). More...
 
bool empty () const
 Check if the descriptor list is empty. More...
 
bool fromXML (DuckContext &duck, xml::ElementVector &others, const xml::Element *parent, const UStringList &allowedOthers)
 This method decodes an XML list of descriptors. More...
 
bool fromXML (DuckContext &duck, xml::ElementVector &others, const xml::Element *parent, const UString &allowedOthers)
 This method decodes an XML list of descriptors. More...
 
bool fromXML (DuckContext &duck, const xml::Element *parent)
 This method decodes an XML list of descriptors. More...
 
size_t 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. More...
 
bool operator!= (const DescriptorList &other) const
 Comparison operator. More...
 
DescriptorListoperator= (const DescriptorList &dl)
 Assignment operator. More...
 
DescriptorListoperator= (DescriptorList &&dl) noexcept
 Move assignment operator. More...
 
bool operator== (const DescriptorList &other) const
 Comparison operator. More...
 
const DescriptorPtroperator[] (size_t index) const
 Get a reference to the descriptor at a specified index. More...
 
PDS privateDataSpecifier (size_t index) const
 Return the "private data specifier" associated to a descriptor in the list. More...
 
bool removeByIndex (size_t index)
 Remove the descriptor at the specified index in the list. More...
 
size_t removeByTag (DID tag, PDS pds=0)
 Remove all descriptors with the specified tag. More...
 
size_t removeInvalidPrivateDescriptors ()
 Remove all private descriptors without preceding private_data_specifier_descriptor. More...
 
size_t search (DID tag, size_t start_index=0, PDS pds=0) const
 Search a descriptor with the specified tag. More...
 
size_t search (const EDID &edid, size_t start_index=0) const
 Search a descriptor with the specified extended tag. More...
 
template<class DESC >
size_t search (DID tag, DESC &desc, size_t start_index=0, PDS pds=0) const
 Search a descriptor with the specified tag. More...
 
size_t searchLanguage (const UString &language, size_t start_index=0) const
 Search a language descriptor for the specified language. More...
 
size_t searchSubtitle (const UString &language=UString(), size_t start_index=0) const
 Search any kind of subtitle descriptor. More...
 
size_t serialize (uint8_t *&addr, size_t &size, size_t start=0) const
 Serialize the content of the descriptor list. More...
 
size_t serialize (ByteBlock &bb, size_t start=0) const
 Serialize the content of the descriptor list in a byte block. More...
 
size_t size () const
 Get the number of descriptors in the list (same as count()). More...
 
const AbstractTabletable () const
 Get the parent table. More...
 
TID tableId () const
 Get the table id of the parent table. More...
 
bool toXML (DuckContext &duck, xml::Element *parent) const
 This method converts a descriptor list to XML. More...
 

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.

◆ tableId()

TID ts::DescriptorList::tableId ( ) const

Get the table id of the parent table.

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

◆ table()

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

Get the parent table.

Returns
The parent table or zero if there is none.

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

bool ts::DescriptorList::operator!= ( const DescriptorList other) const
inline

Comparison operator.

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

◆ operator[]()

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

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.

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

◆ add() [1/5]

void ts::DescriptorList::add ( const DescriptorPtr desc)

Add one descriptor at end of list.

Parameters
[in]descThe binary descriptor to add.

◆ add() [2/5]

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

◆ add() [3/5]

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() [4/5]

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

◆ add() [5/5]

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

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.

◆ addPrivateDataSpecifier()

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

Add a 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.

◆ 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 private descriptors without preceding private_data_specifier_descriptor.

Returns
The number of removed descriptors.

◆ 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 UString language,
size_t  start_index = 0 
) const

Search a language descriptor for the specified language.

Parameters
[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 UString language = UString(),
size_t  start_index = 0 
) const

Search any kind of subtitle descriptor.

Parameters
[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 >
size_t ts::DescriptorList::search ( 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]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 ( ) const

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

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,
xml::ElementVector others,
const xml::Element parent,
const UStringList allowedOthers 
)

This method decodes an XML list of descriptors.

Parameters
[in,out]duckTSDuck execution context.
[out]othersReturned list of non-descriptor XML elements. All these elements are not null and their names are in allowedOthers.
[in]parentThe XML element containing all descriptors.
[in]allowedOthersA list of allowed element names inside parent which are not descriptors.
Returns
True on success, false on error.

◆ fromXML() [2/3]

bool ts::DescriptorList::fromXML ( DuckContext duck,
xml::ElementVector others,
const xml::Element parent,
const UString allowedOthers 
)

This method decodes an XML list of descriptors.

Parameters
[in,out]duckTSDuck execution context.
[out]othersReturned list of non-descriptor XML elements. All these elements are not null and their names are in allowedOthers.
[in]parentThe XML element containing all descriptors.
[in]allowedOthersA comma-separated 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 
)

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.

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