TSDuck Version 3.15-955 (TSDuck - The MPEG Transport Stream Toolkit)
ts::TSAnalyzer Class Reference

A class which analyzes a complete transport stream. More...

Inheritance diagram for ts::TSAnalyzer:
Collaboration diagram for ts::TSAnalyzer:

Classes

class  ETIDContext
 This protected inner class contains the analysis context for one TID/TIDext into one PID. More...
 
class  PIDContext
 This protected inner class contains the analysis context for one PID. More...
 
class  ServiceContext
 This protected inner class contains the analysis context for one service. More...
 

Public Member Functions

 TSAnalyzer (BitRate bitrate_hint=0)
 Default constructor. More...
 
 ~TSAnalyzer ()
 Destructor.
 
void feedPacket (const TSPacket &packet)
 The following method feeds the analyzer with a TS packet. More...
 
void getGlobalPIDs (std::vector< PID > &list)
 Get the list of global PID's. More...
 
void getPIDs (std::vector< PID > &list)
 Get the list of all PID's. More...
 
void getPIDsOfService (std::vector< PID > &list, uint16_t service_id)
 Get the list of PID's for one service id. More...
 
void getPIDsWithPES (std::vector< PID > &list)
 Get the list of PID's carrying PES packets. More...
 
void getServiceIds (std::vector< uint16_t > &list)
 Get the list of service ids. More...
 
void getUnreferencedPIDs (std::vector< PID > &list)
 Get the list of unreferenced PID's. More...
 
void reset ()
 Reset the analysis context.
 
void setBitrateHint (BitRate bitrate_hint=0)
 Specify a "bitrate hint" for the analysis. More...
 
void setDefaultCharacterSet (const DVBCharset *charset)
 Set the default DVB character set to use (for incorrect signalization only). More...
 
void setMaxConsecutiveSuspectCount (uint64_t count)
 Set the maximum number of consecutive suspect packets. More...
 
void setMinErrorCountBeforeSuspect (uint64_t count)
 Set the number of consecutive packet errors threshold. More...
 

Protected Types

typedef std::map< ETID, ETIDContextPtrETIDContextMap
 Map of ETIDContext, indexed by ETID.
 
typedef SafePtr< ETIDContext, NullMutexETIDContextPtr
 Safe pointer to an ETIDContext (not thread-safe).
 
typedef std::map< PID, PIDContextPtrPIDContextMap
 Map of PIDContext, indexed by PID.
 
typedef SafePtr< PIDContext, NullMutexPIDContextPtr
 Safe pointer to a PIDContext (not thread-safe).
 
typedef std::map< uint16_t, ServiceContextPtrServiceContextMap
 Map of ServiceContext, indexed by service id.
 
typedef SafePtr< ServiceContext, NullMutexServiceContextPtr
 Safe pointer to a ServiceContext (not thread-safe).
 
typedef std::set< uint16_t > ServiceIdSet
 Set of service ids.
 

Protected Member Functions

void recomputeStatistics ()
 Update the global statistics value if internal data were modified.
 

Protected Attributes

UString _country_code
 TOT country code.
 
MilliSecond _duration
 Total broadcast duration.
 
Time _first_local
 First system local time (first packet).
 
Time _first_tdt
 First TDT UTC time stamp.
 
Time _first_tot
 First TOT local time stamp.
 
Time _first_utc
 First system UTC time (first packet).
 
uint32_t _global_bitrate
 Bitrate for global PID's.
 
size_t _global_pid_cnt
 Number of global PID's (ref but no service).
 
uint64_t _global_pkt_cnt
 Number of packets in global PID's.
 
size_t _global_scr_pids
 Number of scrambled global PID's.
 
uint64_t _invalid_sync
 Number of packets with invalid sync byte (not 0x47).
 
Time _last_local
 Last system local time (recomputeStatistics).
 
Time _last_tdt
 Last TDT UTC time stamp.
 
Time _last_tot
 Last TOT local time stamp.
 
Time _last_utc
 Last system UTC time (recomputeStatistics).
 
size_t _pcr_pid_cnt
 Number of PID's with PCR's.
 
size_t _pid_cnt
 Number of PID's (with actual packets).
 
PIDContextMap _pids
 Description of PIDs.
 
size_t _scrambled_pid_cnt
 Number of scrambled PID's.
 
uint16_t _scrambled_services_cnt
 Number of scrambled services;.
 
ServiceContextMap _services
 Description of services, map key: service id..
 
uint64_t _suspect_ignored
 Number of suspect packets, ignored.
 
std::bitset< TID_MAX_tid_present
 Array of detected tables.
 
uint64_t _transport_errors
 Number of packets with transport error.
 
uint32_t _ts_bitrate
 TS bitrate (either from PCR or options).
 
uint16_t _ts_id
 Transport stream id.
 
bool _ts_id_valid
 Transport stream id is valid.
 
uint32_t _ts_pcr_bitrate_188
 Average TS bitrate in b/s (eval from PCR).
 
uint32_t _ts_pcr_bitrate_204
 Average TS bitrate in b/s (eval from PCR).
 
uint64_t _ts_pkt_cnt
 Number of TS packets.
 
uint32_t _ts_user_bitrate
 User-specified TS bitrate (if any).
 
uint32_t _unref_bitrate
 Bitrate for unreferenced PID's.
 
size_t _unref_pid_cnt
 Number of unreferenced PID's.
 
uint64_t _unref_pkt_cnt
 Number of packets in unreferenced PID's.
 
size_t _unref_scr_pids
 Number of scrambled unreferenced PID's.
 

Private Member Functions

virtual void handleAVCAccessUnit (PESDemux &demux, const PESPacket &packet, uint8_t nal_unit_type, size_t offset, size_t size)
 This hook is invoked when an AVC (ISO 14496-10, ITU H.264) access unit (aka "NALunit") is found. More...
 
virtual void handlePESPacket (PESDemux &demux, const PESPacket &packet)
 This hook is invoked when a complete PES packet is available. More...
 
virtual void handleSEI (PESDemux &demux, const PESPacket &packet, uint32_t sei_type, size_t offset, size_t size)
 This hook is invoked when an AVC SEI (Supplemental Enhancement Information) is found. More...
 
virtual void handleVideoStartCode (PESDemux &demux, const PESPacket &packet, uint8_t start_code, size_t offset, size_t size)
 This hook is invoked when a video start code is encountered. More...
 

Detailed Description

A class which analyzes a complete transport stream.

Constructor & Destructor Documentation

◆ TSAnalyzer()

ts::TSAnalyzer::TSAnalyzer ( BitRate  bitrate_hint = 0)

Default constructor.

Parameters
[in]bitrate_hintOptional bitrate "hint" for the analysis. It is the user-specified bitrate in bits/seconds, based on 188-byte packets. The bitrate hint is optional: if specified as zero, the analysis is based on the PCR values.

Member Function Documentation

◆ feedPacket()

void ts::TSAnalyzer::feedPacket ( const TSPacket packet)

The following method feeds the analyzer with a TS packet.

The stream is analyzed by repeatedly calling feedPacket().

Parameters
[in]packetOne TS packet from the stream.

◆ setBitrateHint()

void ts::TSAnalyzer::setBitrateHint ( BitRate  bitrate_hint = 0)

Specify a "bitrate hint" for the analysis.

Parameters
[in]bitrate_hintOptional bitrate "hint" for the analysis. It is the user-specified bitrate in bits/seconds, based on 188-byte packets. The bitrate hint is optional: if specified as zero, the analysis is based on the PCR values.

◆ setMinErrorCountBeforeSuspect()

void ts::TSAnalyzer::setMinErrorCountBeforeSuspect ( uint64_t  count)
inline

Set the number of consecutive packet errors threshold.

Parameters
[in]countThe number of consecutive packet errors after which a packet is considered as suspect if it does not belong to a previously known PID. If set to zero, suspect packet detection is disabled. Initially set to the default value 1.

◆ setMaxConsecutiveSuspectCount()

void ts::TSAnalyzer::setMaxConsecutiveSuspectCount ( uint64_t  count)
inline

Set the maximum number of consecutive suspect packets.

Parameters
[in]countWhen that number of consecutive suspect packets is reached, the next packet will not be considered for suspect detection. Initially set to the default value 1.

◆ setDefaultCharacterSet()

void ts::TSAnalyzer::setDefaultCharacterSet ( const DVBCharset charset)
inline

Set the default DVB character set to use (for incorrect signalization only).

Parameters
[in]charsetThe DVB character set to use when no charset code is present and the signalisation is incorrect. Initially set to none.

◆ getServiceIds()

void ts::TSAnalyzer::getServiceIds ( std::vector< uint16_t > &  list)

Get the list of service ids.

Parameters
[out]listThe returned list of service ids.

◆ getPIDs()

void ts::TSAnalyzer::getPIDs ( std::vector< PID > &  list)

Get the list of all PID's.

Parameters
[out]listThe returned list of all PID's.

◆ getGlobalPIDs()

void ts::TSAnalyzer::getGlobalPIDs ( std::vector< PID > &  list)

Get the list of global PID's.

Global PID's are PID's which do not belong to a service.

Parameters
[out]listThe returned list of global PID's.

◆ getUnreferencedPIDs()

void ts::TSAnalyzer::getUnreferencedPIDs ( std::vector< PID > &  list)

Get the list of unreferenced PID's.

Parameters
[out]listThe returned list of unreferenced PID's.

◆ getPIDsOfService()

void ts::TSAnalyzer::getPIDsOfService ( std::vector< PID > &  list,
uint16_t  service_id 
)

Get the list of PID's for one service id.

Parameters
[out]listThe returned list of PID's.
[in]service_idThe service id.

◆ getPIDsWithPES()

void ts::TSAnalyzer::getPIDsWithPES ( std::vector< PID > &  list)

Get the list of PID's carrying PES packets.

Parameters
[out]listThe returned list of PID's carrying PES packets.

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