TSDuck v3.40-4033
MPEG Transport Stream Toolkit
|
This class extracts PES packets from TS packets. More...
#include <tsPESDemux.h>
Public Types | |
using | SuperClass = TimeTrackerDemux |
Explicit reference to superclass. | |
Public Member Functions | |
PESDemux (DuckContext &duck, PESHandlerInterface *handler=nullptr, const PIDSet &pids=AllPIDs) | |
Constructor. | |
virtual | ~PESDemux () override |
Destructor. | |
virtual void | addPID (PID pid) |
Add one PID to filter. | |
virtual void | addPIDs (const PIDSet &pids) |
Add several PID's to filter. | |
bool | allAC3 (PID pid) const |
Check if all PES packets on the specified PID contain AC-3 audio. | |
int | demuxId () const |
Get the "demux id" value, as previously stored by the application. | |
virtual void | feedPacket (const TSPacket &pkt) override |
The following method feeds the demux with a TS packet. | |
void | flushUnboundedPES () |
Flush any unterminated unbounded PES packet on all PID's. | |
void | flushUnboundedPES (PID pid) |
Flush any unterminated unbounded PES packet on the specified PID. | |
void | getAC3Attributes (PID pid, AC3Attributes &attr) const |
Get the current AC-3 audio attributes on the specified PID. | |
void | getAudioAttributes (PID pid, MPEG2AudioAttributes &attr) const |
Get the current audio attributes on the specified PID. | |
void | getAVCAttributes (PID pid, AVCAttributes &attr) const |
Get the current AVC video attributes on the specified PID. | |
CodecType | getDefaultCodec (PID pid) const |
Get the default codec type on a given PID. | |
void | getHEVCAttributes (PID pid, HEVCAttributes &attr) const |
Get the current HEVC video attributes on the specified PID. | |
void | getVideoAttributes (PID pid, MPEG2VideoAttributes &attr) const |
Get the current MPEG-2 video attributes on the specified PID. | |
virtual bool | hasPID (PID pid) const |
Check if a PID is filtered. | |
virtual size_t | pidCount () const |
Get the current number of PID's being filtered. | |
cn::milliseconds | pidDuration (PID pid) const |
Get the number of milliseconds measured on a PID. | |
virtual void | removePID (PID pid) |
Remove one PID to filter. | |
virtual void | reset () |
Reset the demux. | |
virtual void | resetPID (PID pid) |
Reset the demuxing context for one single PID. | |
void | setDefaultCodec (CodecType codec) |
Set the default audio or video codec for all analyzed PES PID's. | |
void | setDefaultCodec (PID pid, CodecType codec) |
Set the default audio or video codec for one specific PES PID's. | |
void | setDemuxId (int id) |
Set some arbitrary "demux id" value. | |
void | setPESHandler (PESHandlerInterface *h) |
Replace the PES packet handler. | |
virtual void | setPIDFilter (const PIDSet &pid_filter) |
Replace the list of PID's to filter. | |
Protected Member Functions | |
bool | afterCallingHandler (bool executeDelayedOperations=true) |
Helper for subclass, after invoking an application-defined handler. | |
void | beforeCallingHandler (PID pid=PID_NULL) |
Helper for subclass, before invoking an application-defined handler. | |
virtual void | handlePESPacket (const PESPacket &packet) |
This hook is invoked when a complete PES packet is available. | |
virtual void | immediateReset () override |
Reset the demux immediately. | |
virtual void | immediateResetPID (PID pid) override |
Reset the demuxing context for one single PID immediately. | |
Protected Attributes | |
DuckContext & | _duck |
The TSDuck execution context is accessible to all subclasses. | |
PacketCounter | _packet_count = 0 |
Number of TS packets in the demultiplexed stream. | |
PIDSet | _pid_filter {} |
Current set of filtered PID's. | |
This class extracts PES packets from TS packets.
|
explicit |
Constructor.
[in,out] | duck | TSDuck execution context. The reference is kept inside the demux. |
[in] | handler | The object to invoke when PES packets are analyzed. |
[in] | pids | The set of PID's to demux. |
|
overridevirtual |
The following method feeds the demux with a TS packet.
[in] | pkt | A TS packet. |
Reimplemented from ts::TimeTrackerDemux.
void ts::PESDemux::flushUnboundedPES | ( | PID | pid | ) |
Flush any unterminated unbounded PES packet on the specified PID.
Unbounded PES packets have no predetermined size. They implicitely end when the next PES packet starts on the same PID. However, at end of stream, there is no next PES packet and the previous buffered data are not considered as a full unbounded packet. These data are lost. This method shall be called at end of stream when the caller is certain that the buffered data from the PID form a complete PES packet. This PES packet is then processed.
[in] | pid | PID containing an unbounded PES packet to complete. |
void ts::PESDemux::flushUnboundedPES | ( | ) |
Flush any unterminated unbounded PES packet on all PID's.
|
inline |
Replace the PES packet handler.
[in] | h | The object to invoke when PES packets are analyzed. |
|
inline |
Set the default audio or video codec for all analyzed PES PID's.
The analysis of the content of a PES packet sometimes depends on the PES data format. The PES demux uses several ways to determine the data format inside a PES packet. First, when the packet is identified in a PMT, the stream type may uniquely identify the format. Second, the content itself can be identified as a specific format. Finally, in the absence of other indications, the specified codec is used.
[in] | codec | The default codec to use. |
Set the default audio or video codec for one specific PES PID's.
This is the same as setDefaultCodec(CodecType) for one specific PID. The codec of a PID is automatically determined from the characteristics of this PID in the PMT, if the PMT packets are passed to this demux.
[in] | pid | The PID to identify. |
[in] | codec | The default codec to use. |
Get the default codec type on a given PID.
[in] | pid | The PID to check. |
void ts::PESDemux::getAudioAttributes | ( | PID | pid, |
MPEG2AudioAttributes & | attr | ||
) | const |
Get the current audio attributes on the specified PID.
[in] | pid | The PID to check. |
[out] | attr | The returned attributes. Invoke its isValid() method to verify its validity. |
void ts::PESDemux::getVideoAttributes | ( | PID | pid, |
MPEG2VideoAttributes & | attr | ||
) | const |
Get the current MPEG-2 video attributes on the specified PID.
[in] | pid | The PID to check. |
[out] | attr | The returned attributes. Invoke its isValid() method to verify its validity. |
void ts::PESDemux::getAVCAttributes | ( | PID | pid, |
AVCAttributes & | attr | ||
) | const |
Get the current AVC video attributes on the specified PID.
[in] | pid | The PID to check. |
[out] | attr | The returned attributes. Invoke its isValid() method to verify its validity. |
void ts::PESDemux::getHEVCAttributes | ( | PID | pid, |
HEVCAttributes & | attr | ||
) | const |
Get the current HEVC video attributes on the specified PID.
[in] | pid | The PID to check. |
[out] | attr | The returned attributes. Invoke its isValid() method to verify its validity. |
void ts::PESDemux::getAC3Attributes | ( | PID | pid, |
AC3Attributes & | attr | ||
) | const |
Get the current AC-3 audio attributes on the specified PID.
[in] | pid | The PID to check. |
[out] | attr | The returned attributes. Invoke its isValid() method to verify its validity. |
bool ts::PESDemux::allAC3 | ( | PID | pid | ) | const |
Check if all PES packets on the specified PID contain AC-3 audio.
[in] | pid | The PID to check. |
|
protectedvirtual |
This hook is invoked when a complete PES packet is available.
Can be overloaded by subclasses to add intermediate processing.
[in] | packet | The PES packet. |
Reimplemented in ts::TeletextDemux.
|
overrideprotectedvirtual |
Reset the demux immediately.
Reimplemented from ts::TimeTrackerDemux.
Reimplemented in ts::TeletextDemux.
|
overrideprotectedvirtual |
Reset the demuxing context for one single PID immediately.
[in] | pid | The PID to reset. |
Reimplemented from ts::TimeTrackerDemux.
Reimplemented in ts::TeletextDemux.
|
inherited |
Get the number of milliseconds measured on a PID.
[in] | pid | The PID to check. |
|
virtualinherited |
Replace the list of PID's to filter.
The method resetPID() is invoked on each removed PID.
[in] | pid_filter | The list of PID's to filter. |
|
virtualinherited |
|
virtualinherited |
Add several PID's to filter.
[in] | pids | The list of new PID's to filter. |
Reimplemented in ts::MPEDemux.
|
virtualinherited |
Remove one PID to filter.
The method resetPID() is invoked on pid.
[in] | pid | The PID to no longer filter. |
Reimplemented in ts::MPEDemux.
|
virtualinherited |
Get the current number of PID's being filtered.
|
virtualinherited |
Check if a PID is filtered.
[in] | pid | The PID to test. |
|
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.
|
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().
[in] | pid | The PID to reset. |
Reimplemented in ts::StandaloneTableDemux.
|
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.
[in] | id | Application-defined demux id to assign. |
|
inlineinherited |
Get the "demux id" value, as previously stored by the application.
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:
[in] | pid | The PID for which the handler will be called. All reset operations on this PID will be delayed until afterCallingHandler(). |
|
protectedinherited |
Helper for subclass, after invoking an application-defined handler.
[in] | executeDelayedOperations | When true (the default), execute all pending reset operations. |