TSDuck Version 3.16-1064 (TSDuck - The MPEG Transport Stream Toolkit)
ts::TeletextDemux Class Reference

This class extracts Teletext subtitles from TS packets. More...

Inheritance diagram for ts::TeletextDemux:
Collaboration diagram for ts::TeletextDemux:

Public Types

typedef PESDemux SuperClass
 Explicit reference to superclass.
 

Public Member Functions

 TeletextDemux (TeletextHandlerInterface *handler=nullptr, const PIDSet &pids=NoPID)
 Constructor. More...
 
virtual ~TeletextDemux ()
 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...
 
bool allAC3 (PID) const
 Check if all PES packets on the specified PID contain AC-3 audio. More...
 
int demuxId () const
 Get the "demux id" value, as previously stored by the application. More...
 
virtual void feedPacket (const TSPacket &pkt) override
 The following method feeds the demux with a TS packet. More...
 
void flushTeletext ()
 Flush any pending Teletext message. More...
 
int frameCount (int page, PID pid=PID_NULL) const
 Get the number of Teletext frames found in a given page. More...
 
void getAC3Attributes (PID pid, AC3Attributes &attr) const
 Get the current AC-3 audio attributes on the specified PID. More...
 
bool getAddColors () const
 Check if font colors tags are inserted in the output text. More...
 
void getAudioAttributes (PID pid, AudioAttributes &attr) const
 Get the current audio attributes on the specified PID. More...
 
void getAVCAttributes (PID pid, AVCAttributes &attr) const
 Get the current AVC video attributes on the specified PID. More...
 
void getVideoAttributes (PID pid, VideoAttributes &attr) const
 Get the current MPEG-2 video attributes on the specified PID. 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...
 
MilliSecond pidDuration (PID pid) const
 Get the number of milliseconds measured on a PID. 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 setAddColors (bool addColors)
 Activate or deactivate the font color tags in the output text. More...
 
void setDemuxId (int id)
 Set some arbitrary "demux id" value. More...
 
void setPESHandler (PESHandlerInterface *h)
 Replace the PES packet handler. More...
 
virtual void setPIDFilter (const PIDSet &pid_filter)
 Replace the list of PID's to filter. More...
 
void setTeletextHandler (TeletextHandlerInterface *handler)
 Replace the Teletext handler. More...
 

Protected Member Functions

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 handlePESPacket (const PESPacket &packet) override
 This hook is invoked when a complete PES packet is available. More...
 
virtual void immediateReset () override
 Reset the demux immediately.
 
virtual void immediateResetPID (PID pid) override
 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

This class extracts Teletext subtitles from TS packets.

Constructor & Destructor Documentation

◆ TeletextDemux()

ts::TeletextDemux::TeletextDemux ( TeletextHandlerInterface handler = nullptr,
const PIDSet pids = NoPID 
)
explicit

Constructor.

Parameters
[in]handlerUser handler for Teletext notification.
[in]pidsThe set of PID's to demux.

Member Function Documentation

◆ setAddColors()

void ts::TeletextDemux::setAddColors ( bool  addColors)
inline

Activate or deactivate the font color tags in the output text.

Parameters
[in]addColorsIf true, font colors tags will be inserted in the output text.

◆ getAddColors()

bool ts::TeletextDemux::getAddColors ( ) const
inline

Check if font colors tags are inserted in the output text.

Returns
True when font colors tags are inserted in the output text.

◆ flushTeletext()

void ts::TeletextDemux::flushTeletext ( )

Flush any pending Teletext message.

Useful only after receiving the last packet in the stream. Implicitly called by destructor.

◆ setTeletextHandler()

void ts::TeletextDemux::setTeletextHandler ( TeletextHandlerInterface handler)
inline

Replace the Teletext handler.

Parameters
[in]handlerThe Teletext handler.

◆ frameCount()

int ts::TeletextDemux::frameCount ( int  page,
PID  pid = PID_NULL 
) const

Get the number of Teletext frames found in a given page.

Parameters
[in]pageTeletext page number.
[in]pidTeletext PID. If omitted, use the first PID containing frames from the specified page.
Returns
Number of Teletext frames found so far on page.

◆ immediateResetPID()

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

Reset the demuxing context for one single PID immediately.

Parameters
[in]pidThe PID to reset.

Reimplemented from ts::PESDemux.

◆ handlePESPacket()

virtual void ts::TeletextDemux::handlePESPacket ( const PESPacket packet)
overrideprotectedvirtual

This hook is invoked when a complete PES packet is available.

Can be overloaded by subclasses to add intermediate processing.

Parameters
[in]packetThe PES packet.

Reimplemented from ts::PESDemux.

◆ feedPacket()

virtual void ts::PESDemux::feedPacket ( const TSPacket pkt)
overridevirtualinherited

The following method feeds the demux with a TS packet.

Parameters
[in]pktA TS packet.

Reimplemented from ts::TimeTrackerDemux.

◆ setPESHandler()

void ts::PESDemux::setPESHandler ( PESHandlerInterface h)
inlineinherited

Replace the PES packet handler.

Parameters
[in]hThe object to invoke when PES packets are analyzed.

◆ getAudioAttributes()

void ts::PESDemux::getAudioAttributes ( PID  pid,
AudioAttributes attr 
) const
inherited

Get the current audio attributes on the specified PID.

Parameters
[in]pidThe PID to check.
[out]attrThe returned attributes. Invoke its isValid() method to verify its validity.

◆ getVideoAttributes()

void ts::PESDemux::getVideoAttributes ( PID  pid,
VideoAttributes attr 
) const
inherited

Get the current MPEG-2 video attributes on the specified PID.

Parameters
[in]pidThe PID to check.
[out]attrThe returned attributes. Invoke its isValid() method to verify its validity.

◆ getAVCAttributes()

void ts::PESDemux::getAVCAttributes ( PID  pid,
AVCAttributes attr 
) const
inherited

Get the current AVC video attributes on the specified PID.

Parameters
[in]pidThe PID to check.
[out]attrThe returned attributes. Invoke its isValid() method to verify its validity.

◆ getAC3Attributes()

void ts::PESDemux::getAC3Attributes ( PID  pid,
AC3Attributes attr 
) const
inherited

Get the current AC-3 audio attributes on the specified PID.

Parameters
[in]pidThe PID to check.
[out]attrThe returned attributes. Invoke its isValid() method to verify its validity.

◆ allAC3()

bool ts::PESDemux::allAC3 ( PID  ) const
inherited

Check if all PES packets on the specified PID contain AC-3 audio.

Returns
True if all PES packets on the specified PID contain AC-3 audio. Due to the way AC-3 is detected, it is possible that some PES packets are erroneously detected as AC-3. Thus, getAC3Attributes() returns a valid value since some AC-3 was detected. But, on homogeneous streams, it is safe to assume that the PID really contains AC-3 only if all PES packets contain AC-3.

◆ pidDuration()

MilliSecond ts::TimeTrackerDemux::pidDuration ( PID  pid) const
inherited

Get the number of milliseconds measured on a PID.

Parameters
[in]pidThe PID to check.
Returns
The number of milliseconds of the content of the specified pid, since the beginning of the stream, based on the PTS of this PID. If no PTS were found on this PID, use PCR's from another PID. Return zero is no timing information was found.

◆ 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)
virtualinherited

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

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.

◆ hasPID()

virtual bool ts::AbstractDemux::hasPID ( 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;
}
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)
protectedinherited

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

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