TSDuck Version 3.15-964 (TSDuck - The MPEG Transport Stream Toolkit)
ts::AbstractDemux Class Reference

Abstract base class for all sorts of demux from TS packets. More...

Inheritance diagram for ts::AbstractDemux:

Public Member Functions

virtual ~AbstractDemux ()
 Destructor.
 
virtual void addPID (PID pid)
 Add one PID to filter. More...
 
virtual void addPIDs (const PIDSet &pids)
 Add several PID's to filter. More...
 
int demuxId () const
 Get the "demux id" value, as previously stored by the application. More...
 
virtual void feedPacket (const TSPacket &pkt)
 The following method feeds the demux with a TS packet. More...
 
virtual bool hasPID (PID pid) const
 Check if a PID is filtered. More...
 
virtual size_t pidCount () const
 Get the current number of PID's being filtered. More...
 
virtual void removePID (PID pid)
 Remove one PID to filter. More...
 
virtual void reset ()
 Reset the demux. More...
 
virtual void resetPID (PID pid)
 Reset the demuxing context for one single PID. More...
 
void setDemuxId (int id)
 Set some arbitrary "demux id" value. More...
 
virtual void setPIDFilter (const PIDSet &pid_filter)
 Replace the list of PID's to filter. More...
 

Protected Member Functions

 AbstractDemux (const PIDSet &pid_filter=NoPID)
 Constructor. More...
 
bool afterCallingHandler (bool executeDelayedOperations=true)
 Helper for subclass, after invoking an application-defined handler. More...
 
void beforeCallingHandler (PID pid=PID_NULL)
 Helper for subclass, before invoking an application-defined handler. More...
 
virtual void immediateReset ()
 Reset the demux immediately.
 
virtual void immediateResetPID (PID pid)
 Reset the demuxing context for one single PID immediately. More...
 

Protected Attributes

PacketCounter _packet_count
 Number of TS packets in the demultiplexed stream.
 
PIDSet _pid_filter
 Current set of filtered PID's.
 

Detailed Description

Abstract base class for all sorts of demux from TS packets.

The application sets a number of PID's to filter. What is extracted from those PID's and how they are reported to the application depend on the concrete demux class.

Constructor & Destructor Documentation

◆ AbstractDemux()

ts::AbstractDemux::AbstractDemux ( const PIDSet pid_filter = NoPID)
protected

Constructor.

Parameters
[in]pid_filterThe initial set of PID's to demux.

Member Function Documentation

◆ feedPacket()

virtual void ts::AbstractDemux::feedPacket ( const TSPacket pkt)
virtual

The following method feeds the demux with a TS packet.

Parameters
[in]pktA TS packet.

Reimplemented in ts::T2MIDemux, ts::MPEDemux, ts::SectionDemux, ts::PESDemux, and ts::TimeTrackerDemux.

◆ setPIDFilter()

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

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)
virtual

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)
virtual

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)
virtual

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
inlinevirtual

Get the current number of PID's being filtered.

Returns
The current number of PID's being filtered.

◆ hasPID()

virtual bool ts::AbstractDemux::hasPID ( PID  pid) const
inlinevirtual

Check if a PID is filtered.

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

◆ reset()

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

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)
virtual

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)
inline

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
inline

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)
protected

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;
}
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  executeDelayedOperations = true)
protected

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

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

◆ immediateResetPID()

virtual void ts::AbstractDemux::immediateResetPID ( PID  pid)
protectedvirtual

Reset the demuxing context for one single PID immediately.

Parameters
[in]pidThe PID to reset.

Reimplemented in ts::SectionDemux, ts::PESDemux, ts::TeletextDemux, ts::T2MIDemux, and ts::TimeTrackerDemux.


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