TSDuck v3.40-3963
MPEG Transport Stream Toolkit
|
Representation of a Tag, Length, Value (TVL) syntax. More...
#include <tsTLVSyntax.h>
Public Member Functions | |
TLVSyntax (int start=-1, int size=-1, size_t tagSize=1, size_t lengthSize=1, bool msb=true, Report &report=(ts::CerrReport::Instance())) | |
Default constructor. | |
bool | fromString (const UString &s, Report &report=(ts::CerrReport::Instance())) |
Set the values of a TLVSyntax object from a string representation. | |
size_t | getLengthSize () const |
Get the size in bytes of the Length field. | |
size_t | getTagAndLength (const uint8_t *data, size_t size, uint32_t &tag, size_t &length) const |
Extract a tag and length value from a data area. | |
size_t | getTagSize () const |
Get the size in bytes of the Tag field. | |
bool | locateTLV (const uint8_t *data, size_t dataSize, size_t &tlvStart, size_t &tlvSize) const |
Locate the "TLV area" inside a data area. | |
bool | operator< (const TLVSyntax &other) const |
Comparison operator, typically used to sort containers of TLVSyntax. | |
bool | set (int start=-1, int size=-1, size_t tagSize=1, size_t lengthSize=1, bool msb=true, Report &report=(ts::CerrReport::Instance())) |
Set the values of a TLVSyntax object. | |
void | setAutoLocation () |
Update the TLV syntax to automatically locate the TLV area. | |
Representation of a Tag, Length, Value (TVL) syntax.
An instance of this class describe how a part of a data area, typically in the payload of an MPEG section, is structured as a suite of TLV records. The complete suite of all contiguous TLV records is named the "TLV area" inside the larger data area.
A TLV area is described by the following values:
ts::TLVSyntax::TLVSyntax | ( | int | start = -1 , |
int | size = -1 , |
||
size_t | tagSize = 1 , |
||
size_t | lengthSize = 1 , |
||
bool | msb = true , |
||
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Default constructor.
[in] | start | Starting index of the "TLV area" in the "data area". A negative value means "auto". |
[in] | size | Size in bytes of the "TLV area". A negative value means "auto". |
[in] | tagSize | Size in bytes of the tag field. The valid sizes are 1 (default), 2 and 4. |
[in] | lengthSize | Size in bytes of the length field. The valid sizes are 1 (default), 2 and 4. |
[in] | msb | If true, the tag and length fields are represented in MSB-first. |
[in,out] | report | Where to report errors. |
bool ts::TLVSyntax::set | ( | int | start = -1 , |
int | size = -1 , |
||
size_t | tagSize = 1 , |
||
size_t | lengthSize = 1 , |
||
bool | msb = true , |
||
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Set the values of a TLVSyntax object.
[in] | start | Starting index of the "TLV area" in the "data area". A negative value means "auto". |
[in] | size | Size in bytes of the "TLV area". A negative value means "auto". |
[in] | tagSize | Size in bytes of the tag field. The valid sizes are 1 (default), 2 and 4. |
[in] | lengthSize | Size in bytes of the length field. The valid sizes are 1 (default), 2 and 4. |
[in] | msb | If true, the tag and length fields are represented in MSB-first. |
[in,out] | report | Where to report errors. |
|
inline |
Get the size in bytes of the Tag field.
|
inline |
Get the size in bytes of the Length field.
bool ts::TLVSyntax::fromString | ( | const UString & | s, |
Report & | report = (ts::CerrReport::Instance()) |
||
) |
Set the values of a TLVSyntax object from a string representation.
Typically used to ingest command line parameters.
[in] | s | The string representation in the form "start,size,tagSize,lengthSize,order". The start and size fields can be set to "auto". The order field shall be either "msb" or lsb". All fields are optional. Missing fields receive the default value as defined in the constructor. |
[in,out] | report | Where to report errors. |
size_t ts::TLVSyntax::getTagAndLength | ( | const uint8_t * | data, |
size_t | size, | ||
uint32_t & | tag, | ||
size_t & | length | ||
) | const |
Extract a tag and length value from a data area.
[in] | data | Address of the TLV record. |
[in] | size | Total size in bytes of the data area after data address. |
[out] | tag | Returned tag value. |
[out] | length | Returned length value. |
bool ts::TLVSyntax::locateTLV | ( | const uint8_t * | data, |
size_t | dataSize, | ||
size_t & | tlvStart, | ||
size_t & | tlvSize | ||
) | const |
Locate the "TLV area" inside a data area.
If the start or size are set to "auto", return the best match.
[in] | data | Address of the TLV data area. |
[in] | dataSize | Total size in bytes of the data area. |
[out] | tlvStart | Starting offset of the "TLV area" after data. |
[out] | tlvSize | Size in bytes of the "TLV area". Zero if no suitable TLV area was found. |
|
inline |
Comparison operator, typically used to sort containers of TLVSyntax.
[in] | other | Other instance to compare. |