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

A class to display PSI/SI tables. More...

#include <tsTablesDisplay.h>

Public Member Functions

 TablesDisplay (DuckContext &duck)
 Constructor.
 
virtual ~TablesDisplay ()=default
 Virtual destructor.
 
void defineArgs (Args &args)
 Add command line option definitions in an Args.
 
virtual void displayATSCMultipleString (PSIBuffer &buf, size_t length_bytes=0, const UString &margin=UString(), const UString &title=UString())
 Display an ATSC multiple_string_structure() as defined in ATSC A/65 from a PSI buffer.
 
virtual void displayCRC32 (const Section &section, const UString &margin=UString())
 Display a CRC32 from a section.
 
virtual void displayCRC32 (const Section &section, PSIBuffer &buf, const UString &margin=UString())
 Display a CRC32 from a section.
 
virtual void displayDescriptor (const Descriptor &desc, const UString &margin=UString(), TID tid=TID_NULL, PDS pds=0, uint16_t cas=CASID_NULL)
 Display a descriptor on the output stream.
 
virtual void displayDescriptorData (DID did, const uint8_t *payload, size_t size, const UString &margin=UString(), TID tid=TID_NULL, PDS pds=0, uint16_t cas=CASID_NULL)
 Display the payload of a descriptor on the output stream.
 
virtual void displayDescriptorList (const DescriptorList &list, const UString &margin=UString(), uint16_t cas=CASID_NULL)
 Display a list of descriptors.
 
virtual void displayDescriptorList (const Section &section, const void *data, size_t size, const UString &margin=UString(), uint16_t cas=CASID_NULL)
 Display a list of descriptors from a memory area.
 
virtual void displayDescriptorList (const Section &section, PSIBuffer &buf, const UString &margin=UString(), const UString &title=UString(), const UString &empty_text=UString(), size_t length=NPOS, uint16_t cas=CASID_NULL)
 Display a list of descriptors from a PSI buffer.
 
virtual void displayDescriptorListWithLength (const Section &section, PSIBuffer &buf, const UString &margin=UString(), const UString &title=UString(), const UString &empty_text=UString(), size_t length_bits=12, uint16_t cas=CASID_NULL)
 Display a list of descriptors (with its preceding length) from a PSI buffer.
 
virtual void displayExtraData (const void *data, size_t size, const UString &margin=UString())
 A utility method to dump extraneous bytes after expected data.
 
virtual void displayExtraData (PSIBuffer &buf, const UString &margin=UString())
 A utility method to dump extraneous bytes after expected data in a PSI buffer.
 
void displayIntAndASCII (const UString &format, PSIBuffer &buf, size_t size, const UString &margin=UString())
 A utility method to display and integer and its optional ASCII interpretation.
 
virtual void displayInvalidSection (const DemuxedData &data, const UString &reason=UString(), const UString &margin=UString(), uint16_t cas=CASID_NULL, bool no_header=false)
 Display an invalid section on the output stream.
 
virtual void displayPrivateData (const UString &title, const void *data, size_t size, const UString &margin=UString(), size_t single_line_max=8)
 A utility method to dump private binary data in a descriptor or section.
 
virtual void displayPrivateData (const UString &title, PSIBuffer &buf, size_t size=NPOS, const UString &margin=UString(), size_t single_line_max=8)
 A utility method to dump private binary data in a descriptor or section.
 
virtual void displaySection (const Section &section, const UString &margin=UString(), uint16_t cas=CASID_NULL, bool no_header=false)
 Display a section on the output stream.
 
virtual void displaySectionData (const Section &section, const UString &margin=UString(), uint16_t cas=CASID_NULL)
 Display the payload of a section on the output stream.
 
virtual void displayTable (const BinaryTable &table, const UString &margin=UString(), uint16_t cas=CASID_NULL)
 Display a table on the output stream.
 
void displayTLV (const uint8_t *data, size_t tlvStart, size_t tlvSize, size_t dataOffset, size_t indent, size_t innerIndent, const TLVSyntax &tlv)
 Display a memory area containing a list of TLV records.
 
void displayUnkownDescriptor (DID did, const uint8_t *payload, size_t size, const UString &margin, TID tid, PDS pds)
 Display the content of an unknown descriptor.
 
void displayUnkownSectionData (const ts::Section &section, const UString &margin=UString())
 Display the content of an unknown section.
 
void displayVector (const UString &title, const std::vector< bool > &values, const UString &margin=UString(), bool space_first=false, size_t num_per_line=40, char true_val='1', char false_val='0')
 Display boolean values in a structured manner using the characters specified and with the specified number of items on each line.
 
void displayVector (const UString &title, const std::vector< int8_t > &values, const UString &margin=UString(), bool space_first=true, size_t num_per_line=8)
 Display the signed 8-bit values in a structured manner with specified number of items on each line.
 
void displayVector (const UString &title, const std::vector< uint16_t > &values, const UString &margin=UString(), bool space_first=true, size_t num_per_line=6)
 Display the 16-bit values in a structured manner with specified number of items on each line.
 
void displayVector (const UString &title, const std::vector< uint32_t > &values, const UString &margin=UString(), bool space_first=true, size_t num_per_line=6)
 Display the 32-bit values in a structured manner with specified number of items on each line.
 
void displayVector (const UString &title, const std::vector< uint8_t > &values, const UString &margin=UString(), bool space_first=true, size_t num_per_line=8)
 Display the 8-bit values in a structured manner with specified number of items on each line.
 
void displayVector (const UString &title, const UStringVector &values, const UString &margin=UString(), bool space_first=true, size_t num_per_line=3)
 Display the string values in a tabular manner with specified number of items on each line.
 
DuckContextduck ()
 Get the TSDuck execution context.
 
bool loadArgs (DuckContext &duck, Args &args)
 Load arguments from command line.
 
virtual void logLine (const UString &line)
 Log a line, either on redirected output or on report if output was not redirected.
 
virtual void logSectionData (const Section &section, const UString &header=UString(), size_t max_bytes=0, uint16_t cas=CASID_NULL)
 Display the payload of a section on the output stream as a one-line "log" message.
 
template<typename T >
std::ostream & operator<< (const T &expression)
 Output stream operator to use a TablesDisplay instance directly as an output stream.
 
std::ostream & operator<< (std::ostream &(*manip)(std::ostream &))
 Output stream operator to use a TablesDisplay instance directly as an output stream.
 
std::ostream & out ()
 Get the output stream.
 

Static Public Member Functions

static UString LogUnknownSectionData (const Section &section, size_t max_bytes)
 Log the content of an unknown section.
 

Detailed Description

A class to display PSI/SI tables.

Constructor & Destructor Documentation

◆ TablesDisplay()

ts::TablesDisplay::TablesDisplay ( DuckContext duck)
inlineexplicit

Constructor.

By default, all displays are done on std::cout. Use redirect() to redirect the output to a file.

Parameters
[in,out]duckTSDuck context.

Member Function Documentation

◆ defineArgs()

void ts::TablesDisplay::defineArgs ( Args args)

Add command line option definitions in an Args.

Parameters
[in,out]argsCommand line arguments to update.

◆ loadArgs()

bool ts::TablesDisplay::loadArgs ( DuckContext duck,
Args args 
)

Load arguments from command line.

Args error indicator is set in case of incorrect arguments.

Parameters
[in,out]duckTSDuck execution context.
[in,out]argsCommand line arguments.
Returns
True on success, false on error in argument line.

◆ duck()

DuckContext & ts::TablesDisplay::duck ( )
inline

Get the TSDuck execution context.

Returns
A reference to the TSDuck execution context.

◆ out()

std::ostream & ts::TablesDisplay::out ( )
inline

Get the output stream.

Returns
A reference to the output stream.

◆ operator<<() [1/2]

template<typename T >
std::ostream & ts::TablesDisplay::operator<< ( const T &  expression)
inline

Output stream operator to use a TablesDisplay instance directly as an output stream.

Template Parameters
TAny type
Parameters
[in]expressionAny expression that can by output on streams.
Returns
A reference to the output stream.
See also
out()

◆ operator<<() [2/2]

std::ostream & ts::TablesDisplay::operator<< ( std::ostream &(*)(std::ostream &)  manip)
inline

Output stream operator to use a TablesDisplay instance directly as an output stream.

Parameters
[in]manipAn I/O manipulator such as std::endl.
Returns
A reference to the output stream.
See also
out()

◆ logLine()

virtual void ts::TablesDisplay::logLine ( const UString line)
virtual

Log a line, either on redirected output or on report if output was not redirected.

Parameters
[in]lineThe line to log.

◆ displayTable()

virtual void ts::TablesDisplay::displayTable ( const BinaryTable table,
const UString margin = UString(),
uint16_t  cas = CASID_NULL 
)
virtual

Display a table on the output stream.

The content of the table is interpreted according to the table id.

Parameters
[in]tableThe table to display.
[in]marginLeft margin content.
[in]casCAS id of the table.

◆ displaySection()

virtual void ts::TablesDisplay::displaySection ( const Section section,
const UString margin = UString(),
uint16_t  cas = CASID_NULL,
bool  no_header = false 
)
virtual

Display a section on the output stream.

The content of the table is interpreted according to the table id.

Parameters
[in]sectionThe section to display.
[in]marginLeft margin content.
[in]casCAS id of the table.
[in]no_headerIf true, do not display the section header.

◆ displaySectionData()

virtual void ts::TablesDisplay::displaySectionData ( const Section section,
const UString margin = UString(),
uint16_t  cas = CASID_NULL 
)
virtual

Display the payload of a section on the output stream.

The content of the table is interpreted according to the table id.

Parameters
[in]sectionThe section to display.
[in]marginLeft margin content.
[in]casCAS id of the table.

◆ logSectionData()

virtual void ts::TablesDisplay::logSectionData ( const Section section,
const UString header = UString(),
size_t  max_bytes = 0,
uint16_t  cas = CASID_NULL 
)
virtual

Display the payload of a section on the output stream as a one-line "log" message.

Parameters
[in]sectionThe section to display.
[in]headerHeader string to display as prefix on the line.
[in]max_bytesMaximum number of bytes to log from the section. 0 means unlimited.
[in]casCAS id of the table.

◆ displayInvalidSection()

virtual void ts::TablesDisplay::displayInvalidSection ( const DemuxedData data,
const UString reason = UString(),
const UString margin = UString(),
uint16_t  cas = CASID_NULL,
bool  no_header = false 
)
virtual

Display an invalid section on the output stream.

Parameters
[in]dataThe invalid section.
[in]reasonReason for invalid section.
[in]marginLeft margin content.
[in]casCAS id of the table.
[in]no_headerIf true, do not display the section header.

◆ displayDescriptor()

virtual void ts::TablesDisplay::displayDescriptor ( const Descriptor desc,
const UString margin = UString(),
TID  tid = TID_NULL,
PDS  pds = 0,
uint16_t  cas = CASID_NULL 
)
virtual

Display a descriptor on the output stream.

Parameters
[in]descThe descriptor to display.
[in]marginLeft margin content.
[in]tidTable id of table containing the descriptors. This is optional. Used by some descriptors the interpretation of which may vary depending on the table that they are in.
[in]pdsPrivate Data Specifier. Used to interpret private descriptors.
[in]casCAS id of the table.

◆ displayDescriptorData()

virtual void ts::TablesDisplay::displayDescriptorData ( DID  did,
const uint8_t *  payload,
size_t  size,
const UString margin = UString(),
TID  tid = TID_NULL,
PDS  pds = 0,
uint16_t  cas = CASID_NULL 
)
virtual

Display the payload of a descriptor on the output stream.

Parameters
[in]didDescriptor id.
[in]payloadAddress of the descriptor payload.
[in]sizeSize in bytes of the descriptor payload.
[in]marginLeft margin content.
[in]tidTable id of table containing the descriptors. This is optional. Used by some descriptors the interpretation of which may vary depending on the table that they are in.
[in]pdsPrivate Data Specifier. Used to interpret private descriptors.
[in]casCAS id of the table.

◆ displayDescriptorList() [1/3]

virtual void ts::TablesDisplay::displayDescriptorList ( const Section section,
const void *  data,
size_t  size,
const UString margin = UString(),
uint16_t  cas = CASID_NULL 
)
virtual

Display a list of descriptors from a memory area.

Parameters
[in]sectionSection containing the descriptor list.
[in]dataAddress of the descriptor list.
[in]sizeSize in bytes of the descriptor list.
[in]marginLeft margin content.
[in]casCAS id of the table.

◆ displayDescriptorList() [2/3]

virtual void ts::TablesDisplay::displayDescriptorList ( const DescriptorList list,
const UString margin = UString(),
uint16_t  cas = CASID_NULL 
)
virtual

Display a list of descriptors.

Parameters
[in]listDescriptor list.
[in]marginLeft margin content.
[in]casCAS id of the table.

◆ displayDescriptorList() [3/3]

virtual void ts::TablesDisplay::displayDescriptorList ( const Section section,
PSIBuffer buf,
const UString margin = UString(),
const UString title = UString(),
const UString empty_text = UString(),
size_t  length = NPOS,
uint16_t  cas = CASID_NULL 
)
virtual

Display a list of descriptors from a PSI buffer.

Parameters
[in]sectionSection containing the descriptor list.
[in,out]bufBuffer containing the descriptor list to read
[in]marginLeft margin content.
[in]titleOptional title to display as preceding line.
[in]empty_textOptional text to display when the descriptor list is empty.
[in]lengthNumber of bytes to read. If NPOS is specified (the default), read the rest of the buffer.
[in]casCAS id of the table.

◆ displayDescriptorListWithLength()

virtual void ts::TablesDisplay::displayDescriptorListWithLength ( const Section section,
PSIBuffer buf,
const UString margin = UString(),
const UString title = UString(),
const UString empty_text = UString(),
size_t  length_bits = 12,
uint16_t  cas = CASID_NULL 
)
virtual

Display a list of descriptors (with its preceding length) from a PSI buffer.

Parameters
[in]sectionSection containing the descriptor list.
[in,out]bufBuffer containing the descriptor list to read
[in]marginLeft margin content.
[in]titleOptional title to display as preceding line.
[in]empty_textOptional text to display when the descriptor list is empty.
[in]length_bitsNumber of meaningful bits in the length field.
[in]casCAS id of the table.

◆ displayATSCMultipleString()

virtual void ts::TablesDisplay::displayATSCMultipleString ( PSIBuffer buf,
size_t  length_bytes = 0,
const UString margin = UString(),
const UString title = UString() 
)
virtual

Display an ATSC multiple_string_structure() as defined in ATSC A/65 from a PSI buffer.

Parameters
[in,out]bufBuffer containing the structure to read
[in]length_bytesSize in bytes of the leading length field (0 if there is none).
[in]marginLeft margin content.
[in]titleOptional title to display.

◆ displayCRC32() [1/2]

virtual void ts::TablesDisplay::displayCRC32 ( const Section section,
const UString margin = UString() 
)
virtual

Display a CRC32 from a section.

Not required on section with long header since the CRC32 is validated when the section is read. Only useful on sections with short header and a CRC32 (TOT, splice_information_table).

Parameters
[in]sectionSection containing the CRC32.
[in]marginLeft margin content.

◆ displayCRC32() [2/2]

virtual void ts::TablesDisplay::displayCRC32 ( const Section section,
PSIBuffer buf,
const UString margin = UString() 
)
virtual

Display a CRC32 from a section.

Not required on section with long header since the CRC32 is validated when the section is read. Only useful on sections with short header and a CRC32 (TOT, splice_information_table).

Parameters
[in]sectionSection containing the CRC32.
[in,out]bufBuffer containing the section payload. If there are exactly 4 remaining bytes in buf, the CRC32 is displayed and the 4 bytes are skipped. Otherwise, nothing is displayed.
[in]marginLeft margin content.

◆ displayExtraData() [1/2]

virtual void ts::TablesDisplay::displayExtraData ( const void *  data,
size_t  size,
const UString margin = UString() 
)
virtual

A utility method to dump extraneous bytes after expected data.

Parameters
[in]dataAddress of extra data to dump.
[in]sizeSize of extra data to dump.
[in]marginLeft margin content.

◆ displayExtraData() [2/2]

virtual void ts::TablesDisplay::displayExtraData ( PSIBuffer buf,
const UString margin = UString() 
)
virtual

A utility method to dump extraneous bytes after expected data in a PSI buffer.

Parameters
[in,out]bufBuffer containing extra data to read.
[in]marginLeft margin content.

◆ displayPrivateData() [1/2]

virtual void ts::TablesDisplay::displayPrivateData ( const UString title,
const void *  data,
size_t  size,
const UString margin = UString(),
size_t  single_line_max = 8 
)
virtual

A utility method to dump private binary data in a descriptor or section.

Parameters
[in]titleName of the private data to display.
[in]dataAddress of data to dump.
[in]sizeSize of data to dump.
[in]marginLeft margin content.
[in]single_line_maxBelow that size, private data are displayed on one line after the title. Above that size, a multi-line hexa/ascii display is used.

◆ displayPrivateData() [2/2]

virtual void ts::TablesDisplay::displayPrivateData ( const UString title,
PSIBuffer buf,
size_t  size = NPOS,
const UString margin = UString(),
size_t  single_line_max = 8 
)
virtual

A utility method to dump private binary data in a descriptor or section.

Parameters
[in]titleName of the private data to display.
[in,out]bufBuffer containing extra data to read.
[in]sizeSize of data to dump. If larger than buffer size, display the rest of the buffer.
[in]marginLeft margin content.
[in]single_line_maxBelow that size, private data are displayed on one line after the title. Above that size, a multi-line hexa/ascii display is used.

◆ displayIntAndASCII()

void ts::TablesDisplay::displayIntAndASCII ( const UString format,
PSIBuffer buf,
size_t  size,
const UString margin = UString() 
)

A utility method to display and integer and its optional ASCII interpretation.

Parameters
[in]formatA format string for UString::Format(), including the '' sequence for the integer data. It the integer data can be interpreted as an ASCII string, the string is displayed after.
[in,out]bufBuffer containing the data to read.
[in]sizeSize of the integer data.
[in]marginLeft margin content.

◆ displayUnkownSectionData()

void ts::TablesDisplay::displayUnkownSectionData ( const ts::Section section,
const UString margin = UString() 
)

Display the content of an unknown section.

The command-line formatting options are used to analyze the content.

Parameters
[in]sectionThe section to display.
[in]marginLeft margin content.

◆ LogUnknownSectionData()

static UString ts::TablesDisplay::LogUnknownSectionData ( const Section section,
size_t  max_bytes 
)
static

Log the content of an unknown section.

Parameters
[in]sectionThe section to log.
[in]max_bytesMaximum number of bytes to log from the section. 0 means unlimited.
Returns
A one-line brief summary of the table.

◆ displayUnkownDescriptor()

void ts::TablesDisplay::displayUnkownDescriptor ( DID  did,
const uint8_t *  payload,
size_t  size,
const UString margin,
TID  tid,
PDS  pds 
)

Display the content of an unknown descriptor.

Parameters
[in]didDescriptor id.
[in]payloadAddress of the descriptor payload.
[in]sizeSize in bytes of the descriptor payload.
[in]marginLeft margin content.
[in]tidTable id of table containing the descriptors.
[in]pdsPrivate Data Specifier. Used to interpret private descriptors.

◆ displayTLV()

void ts::TablesDisplay::displayTLV ( const uint8_t *  data,
size_t  tlvStart,
size_t  tlvSize,
size_t  dataOffset,
size_t  indent,
size_t  innerIndent,
const TLVSyntax tlv 
)

Display a memory area containing a list of TLV records.

The displayed area extends from data to data + tlvStart + tlvSize.

  • From data to data + tlvStart : Raw data.
  • From data + tlvStart to data + tlvStart + tlvSize : TLV records.
Parameters
[in]dataStarting address of memory area.
[in]tlvStartStarting index of TLV records after data.
[in]tlvSizeSize in bytes of the TLV area.
[in]dataOffsetDisplay offset of data.
[in]indentLeft margin size.
[in]innerIndentInner margin size.
[in]tlvTLV syntax.

◆ displayVector() [1/6]

void ts::TablesDisplay::displayVector ( const UString title,
const std::vector< uint32_t > &  values,
const UString margin = UString(),
bool  space_first = true,
size_t  num_per_line = 6 
)

Display the 32-bit values in a structured manner with specified number of items on each line.

Parameters
[in]titleLabel that identifies the values
[in]valuesList of values to be output in hexadecimal form
[in]marginLeft margin content (default: "").
[in]space_firstWhen set, inserts a space character before the hexadecimal value (default: true)
[in]num_per_lineNumber of values to be output on a single line (default: 6)

◆ displayVector() [2/6]

void ts::TablesDisplay::displayVector ( const UString title,
const std::vector< uint16_t > &  values,
const UString margin = UString(),
bool  space_first = true,
size_t  num_per_line = 6 
)

Display the 16-bit values in a structured manner with specified number of items on each line.

Parameters
[in]titleLabel that identifies the values
[in]valuesList of values to be output in hexadecimal form
[in]marginLeft margin content (default: "").
[in]space_firstWhen set, inserts a space character before the hexadecimal value (default: true)
[in]num_per_lineNumber of values to be output on a single line (default: 6)

◆ displayVector() [3/6]

void ts::TablesDisplay::displayVector ( const UString title,
const std::vector< uint8_t > &  values,
const UString margin = UString(),
bool  space_first = true,
size_t  num_per_line = 8 
)

Display the 8-bit values in a structured manner with specified number of items on each line.

Parameters
[in]titleLabel that identifies the values
[in]valuesList of values to be output in hexadecimal form
[in]marginLeft margin content (default: "").
[in]space_firstWhen set, inserts a space character before the hexadecimal value (default: true)
[in]num_per_lineNumber of values to be output on a single line (default: 8)

◆ displayVector() [4/6]

void ts::TablesDisplay::displayVector ( const UString title,
const std::vector< int8_t > &  values,
const UString margin = UString(),
bool  space_first = true,
size_t  num_per_line = 8 
)

Display the signed 8-bit values in a structured manner with specified number of items on each line.

Parameters
[in]titleLabel that identifies the values
[in]valuesList of values to be output in hexadecimal form
[in]marginLeft margin content (default: "").
[in]space_firstWhen set, inserts a space character before the hexadecimal value (default: true)
[in]num_per_lineNumber of values to be output on a single line (default: 8)

◆ displayVector() [5/6]

void ts::TablesDisplay::displayVector ( const UString title,
const std::vector< bool > &  values,
const UString margin = UString(),
bool  space_first = false,
size_t  num_per_line = 40,
char  true_val = '1',
char  false_val = '0' 
)

Display boolean values in a structured manner using the characters specified and with the specified number of items on each line.

Parameters
[in]titleLabel that identifies the values
[in]valuesList of values to be output in hexadecimal form
[in]marginLeft margin content (default: "").
[in]space_firstWhen set, inserts a space character before the hexadecimal value (default: true)
[in]num_per_lineNumber of values to be output on a single line (default: 6)
[in]true_valCharacter to display when the value is true (default: '1')
[in]false_valCharacter to display when the value is false (default: '0')

◆ displayVector() [6/6]

void ts::TablesDisplay::displayVector ( const UString title,
const UStringVector values,
const UString margin = UString(),
bool  space_first = true,
size_t  num_per_line = 3 
)

Display the string values in a tabular manner with specified number of items on each line.

Parameters
[in]titleLabel that identifies the values
[in]valuesList of values to be output in hexadecimal form
[in]marginLeft margin content (default: "").
[in]space_firstWhen set, inserts a space character before the value (default: true)
[in]num_per_lineNumber of values to be output on a single line (default: 3)

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