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

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

#include <tsDescriptorList.h>

Public Member Functions

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

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

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.

◆ edid()

EDID ts::DescriptorList::edid ( size_t  index) const

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

Parameters
[in]indexIndex of a descriptor in the list. Valid index are 0 to count()-1.
Returns
The extended descriptor id 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]

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

Add one descriptor at end of list.

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

◆ add() [2/5]

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

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

bool 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.
Returns
True in case of success, false if the descriptor is invalid.

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

◆ merge() [1/2]

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

◆ 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 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 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 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 , typename std::enable_if< std::is_base_of< ts::AbstractDescriptor, DESC >::value >::type * >
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,
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: