TSDuck v3.46-4930
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::ContinuityAnalyzer Class Reference

#include <tsContinuityAnalyzer.h>

Inheritance diagram for ts::ContinuityAnalyzer:
Collaboration diagram for ts::ContinuityAnalyzer:

Public Types

using SuperClass = AbstractDemux

Public Member Functions

 ContinuityAnalyzer (DuckContext &duck, const PIDSet &pid_filter=NoPID())
virtual void addPID (PID pid)
virtual void addPIDs (const PIDSet &pids)
int demuxId () const
DuckContext & duck ()
size_t dupCount (PID pid) const
PacketCounter errorCount () const
virtual void feedPacket (const TSPacket &pkt) override
uint8_t firstCC (PID pid) const
PacketCounter fixCount () const
void getLastPacket (PID pid, TSPacket &packet) const
virtual bool isFilteredPID (PID pid) const
uint8_t lastCC (PID pid) const
TSPacket lastPacket (PID pid) const
virtual size_t pidCount () const
PacketCounter processedPackets () const
bool processPacket (const TSPacket &pkt)
bool processPacket (TSPacket &pkt)
virtual void removePID (PID pid)
Report & report ()
virtual void reset ()
virtual void resetPID (PID pid)
void setDemuxId (int id)
void setDisplay (bool display)
void setFix (bool fix)
void setGenerator (bool gen)
void setJSON (bool on)
void setMessagePrefix (const UString &prefix)
void setMessageSeverity (int level)
virtual void setPIDFilter (const PIDSet &pid_filter)
void setReplicateDuplicated (bool on)
PacketCounter totalPackets () const

Static Public Member Functions

static size_t MissingPackets (int cc1, int cc2)

Protected Member Functions

bool afterCallingHandler (bool execute_delayed_operations=true)
void beforeCallingHandler (PID pid=PID_NULL)
virtual void immediateReset () override
virtual void immediateResetPID (PID pid) override

Detailed Description

Continuity counters analysis and repair.

Member Typedef Documentation

◆ SuperClass

Explicit reference to superclass.

Constructor & Destructor Documentation

◆ ContinuityAnalyzer()

ts::ContinuityAnalyzer::ContinuityAnalyzer ( DuckContext & duck,
const PIDSet & pid_filter = NoPID() )
explicit

Constructor.

Parameters
[in,out]duckTSDuck execution context. The reference is kept inside the demux.
[in]pid_filterThe set of PID's to analyze or fix.

Member Function Documentation

◆ processPacket() [1/2]

bool ts::ContinuityAnalyzer::processPacket ( const TSPacket & pkt)
inline

Process a constant TS packet. Can be used only to report discontinuity errors.

Parameters
[in]pktA transport stream packet.
Returns
True if the packet has no discontinuity error. False if it has an error.

◆ processPacket() [2/2]

bool ts::ContinuityAnalyzer::processPacket ( TSPacket & pkt)
inline

Process or modify a TS packet.

Parameters
[in,out]pktA transport stream packet. It can be modified only when error fixing or generator mode is activated.
Returns
True if the packet had no discontinuity error and is unmodified. False if the packet had an error or was modified.

◆ fixCount()

PacketCounter ts::ContinuityAnalyzer::fixCount ( ) const
inline

Get the number of fixed (modified) TS packets.

Returns
The number of fixed (modified) TS packets.

◆ errorCount()

PacketCounter ts::ContinuityAnalyzer::errorCount ( ) const
inline

Get the number of discontinuity errors.

Returns
The number of discontinuity errors.

◆ setDisplay()

void ts::ContinuityAnalyzer::setDisplay ( bool display)
inline

Change error reporting.

Parameters
[in]displayWhen true, display discontinuity errors.

◆ setFix()

void ts::ContinuityAnalyzer::setFix ( bool fix)
inline

Change error fixing.

Parameters
[in]fixWhen true, fix discontinuity errors.

◆ setReplicateDuplicated()

void ts::ContinuityAnalyzer::setReplicateDuplicated ( bool on)
inline

When fixing errors, specify how to handle duplicated packets. Two successive packets in the same PID are considered as duplicated if they have the same continuity counter and same content (except PCR, if any).

Parameters
[in]onWhen true (the default), duplicated input packets are replicated as duplicated on output (the corresponding output packets have the same continuity counters). When false, the input packets are not considered as duplicated and the output packets have incremented continuity counters.

◆ setGenerator()

void ts::ContinuityAnalyzer::setGenerator ( bool gen)
inline

Set generator mode. When the generator mode is on, the input continuity counters are always ignored. The output continuity counters are updated to create a continuous stream. No error is reported.

Parameters
[in]genWhen true, activate generator mode.

◆ setMessageSeverity()

void ts::ContinuityAnalyzer::setMessageSeverity ( int level)
inline

Define the severity of messages. The default severity is Severity::Info.

Parameters
[in]levelThe severity of each message.

◆ setMessagePrefix()

void ts::ContinuityAnalyzer::setMessagePrefix ( const UString & prefix)
inline

Define a prefix string to be displayed with each message.

Parameters
[in]prefixThe prefix string to be displayed with each message.

◆ setJSON()

void ts::ContinuityAnalyzer::setJSON ( bool on)
inline

Specify to log messages in JSON format. If a message prefix is set, it is logged just before the JSON structure and can be used to locate the appropriate JSON messages in a flow of logs.

Parameters
[in]onSet the JSON mode on or off.

◆ firstCC()

uint8_t ts::ContinuityAnalyzer::firstCC ( PID pid) const

Get the first CC in a PID.

Parameters
[in]pidThe PID to check.
Returns
The first CC value in the PID or ts::INVALID_CC when the PID is not filtered. The first CC in a PID is never modified.

◆ lastCC()

uint8_t ts::ContinuityAnalyzer::lastCC ( PID pid) const

Get the last CC in a PID.

Parameters
[in]pidThe PID to check.
Returns
The last CC value in the PID or ts::INVALID_CC when the PID is not filtered. This is the output CC value, possibly modified.

◆ dupCount()

size_t ts::ContinuityAnalyzer::dupCount ( PID pid) const

Get the last duplicate packet count for a PID.

Parameters
[in]pidThe PID to check.
Returns
The last duplicate packet count for the PID or ts::NPOS when the PID is not filtered.

◆ lastPacket()

TSPacket ts::ContinuityAnalyzer::lastPacket ( PID pid) const

Get the last transport stream packet that was passed to feedPacket() for a PID.

Parameters
[in]pidThe PID to check.
Returns
The last packet for the PID or ts::NullPacket when the PID is not filtered.

◆ getLastPacket()

void ts::ContinuityAnalyzer::getLastPacket ( PID pid,
TSPacket & packet ) const

Get the last transport stream packet that was passed to feedPacket() for a PID.

Parameters
[in]pidThe PID to check.
[out]packetThe last packet for the PID or ts::NullPacket when the PID is not filtered.

◆ MissingPackets()

size_t ts::ContinuityAnalyzer::MissingPackets ( int cc1,
int cc2 )
static

Compute the number of missing packets between two continuity counters.

Parameters
[in]cc1First continuity counter.
[in]cc2Second continuity counter.
Returns
Number of missing packets between cc1 and cc2.

◆ feedPacket()

virtual void ts::ContinuityAnalyzer::feedPacket ( const TSPacket & pkt)
overridevirtual

The following method feeds the demux with a TS packet.

Parameters
[in]pktA TS packet.

Reimplemented from ts::AbstractDemux.

◆ immediateReset()

virtual void ts::ContinuityAnalyzer::immediateReset ( )
overrideprotectedvirtual

Reset the demux immediately.

Reimplemented from ts::AbstractDemux.

◆ immediateResetPID()

virtual void ts::ContinuityAnalyzer::immediateResetPID ( PID pid)
overrideprotectedvirtual

Reset the demuxing context for one single PID immediately.

Parameters
[in]pidThe PID to reset.

Reimplemented from ts::AbstractDemux.

◆ report()

Report & ts::AbstractDemux::report ( )
inlineinherited

Get the associated Report.

Returns
A reference to the associated Report.

◆ duck()

DuckContext & ts::AbstractDemux::duck ( )
inlineinherited

Get the associated TSDuck execution context.

Returns
A reference to the associated DuckContext.

◆ setPIDFilter()

virtual void ts::AbstractDemux::setPIDFilter ( const PIDSet & pid_filter)
virtualinherited

Replace the list of PID's to filter. The method resetPID() is invoked on each removed PID.

Parameters
[in]pid_filterThe list of PID's to filter.

◆ addPID()

virtual void ts::AbstractDemux::addPID ( PID pid)
inlinevirtualinherited

Add one PID to filter.

Parameters
[in]pidThe new PID to filter.

Reimplemented in ts::MPEDemux.

◆ addPIDs()

virtual void ts::AbstractDemux::addPIDs ( const PIDSet & pids)
inlinevirtualinherited

Add several PID's to filter.

Parameters
[in]pidsThe list of new PID's to filter.

Reimplemented in ts::MPEDemux.

◆ removePID()

virtual void ts::AbstractDemux::removePID ( PID pid)
virtualinherited

Remove one PID to filter. The method resetPID() is invoked on pid.

Parameters
[in]pidThe PID to no longer filter.

Reimplemented in ts::MPEDemux.

◆ pidCount()

virtual size_t ts::AbstractDemux::pidCount ( ) const
inlinevirtualinherited

Get the current number of PID's being filtered.

Returns
The current number of PID's being filtered.

◆ totalPackets()

PacketCounter ts::AbstractDemux::totalPackets ( ) const
inlineinherited

Get the current total number of TS packets which were processed by the demux.

Returns
The current number of TS packets which were processed by the demux.

◆ processedPackets()

PacketCounter ts::AbstractDemux::processedPackets ( ) const
inlineinherited

Get the number of processed TS packets in filtered PIDs.

Returns
The number of processed TS packets.

◆ isFilteredPID()

virtual bool ts::AbstractDemux::isFilteredPID ( PID pid) const
inlinevirtualinherited

Check if a PID is filtered.

Parameters
[in]pidThe PID to test.
Returns
Tue if pid is filtered.

◆ reset()

virtual void ts::AbstractDemux::reset ( )
virtualinherited

Reset the demux.

Useful when the transport stream changes. The PID filter and the handlers are not modified.

If invoked in an application-handler, the operation is delayed until the handler terminates. For subclass implementers, see beforeCallingHandler() and override immediateReset() instead of reset().

Reimplemented in ts::StandaloneTableDemux.

◆ resetPID()

virtual void ts::AbstractDemux::resetPID ( PID pid)
virtualinherited

Reset the demuxing context for one single PID. Forget all previous partially demuxed data on this PID.

If invoked in an application-handler, the operation is delayed until the handler terminates. For subclass implementers, see beforeCallingHandler() and override immediateResetPID() instead of resetPID().

Parameters
[in]pidThe PID to reset.

Reimplemented in ts::StandaloneTableDemux.

◆ setDemuxId()

void ts::AbstractDemux::setDemuxId ( int id)
inlineinherited

Set some arbitrary "demux id" value. This value is chosen and set by the application. It can be retrieved later if a table or section handler is used by several demux. The demux id is not interpreted by the demux, it is only stored for the application. The initial value of a demux id is zero.

Parameters
[in]idApplication-defined demux id to assign.

◆ demuxId()

int ts::AbstractDemux::demuxId ( ) const
inlineinherited

Get the "demux id" value, as previously stored by the application.

Returns
The application-defined demux id.

◆ beforeCallingHandler()

void ts::AbstractDemux::beforeCallingHandler ( PID pid = PID_NULL)
protectedinherited

Helper for subclass, before invoking an application-defined handler.

The idea is to protect the integrity of the demux during the execution of an application-defined handler. The handler is invoked in the middle of an operation but the handler may call reset() or resetPID(). Executing the reset in the middle of an operation may be problematic. By using beforeCallingHandler() and afterCallingHandler(), all reset operations in between are delayed after the execution of the handler.

Example:

try {
_handler->handleEvent(*this, pid, ...);
}
catch (...) {
throw;
}
bool afterCallingHandler(bool execute_delayed_operations=true)
void beforeCallingHandler(PID pid=PID_NULL)
Parameters
[in]pidThe PID for which the handler will be called. All reset operations on this PID will be delayed until afterCallingHandler().

◆ afterCallingHandler()

bool ts::AbstractDemux::afterCallingHandler ( bool execute_delayed_operations = true)
protectedinherited

Helper for subclass, after invoking an application-defined handler.

Parameters
[in]execute_delayed_operationsWhen true (the default), execute all pending reset operations.
Returns
True if a delayed reset was executed.
See also
beforeCallingHandler()

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