TSDuck v3.38-3675
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::PESStreamPacketizer Class Reference

Packetization of PES data into Transport Stream packets in "push" mode. More...

#include <tsPESStreamPacketizer.h>

Inheritance diagram for ts::PESStreamPacketizer:
Collaboration diagram for ts::PESStreamPacketizer:

Public Member Functions

 PESStreamPacketizer (const DuckContext &duck, PID pid=PID_NULL)
 Constructor.
 
virtual ~PESStreamPacketizer () override
 Destructor.
 
bool addPES (const PESPacket &pes, ShareMode mode)
 Add a PES packet to packetize.
 
bool addPES (const PESPacketPtr &pes)
 Add a PES packet to packetize.
 
bool atPESBoundary () const
 Check if the TS packet stream is exactly at a PES packet boundary.
 
virtual std::ostream & display (std::ostream &strm) const override
 Display the internal state of the packetizer, mainly for debug.
 
const DuckContextduck () const
 Get a reference to the TSDuck execution context.
 
bool empty () const
 Check if the packetizer is empty (no more TS packet to produce).
 
virtual bool getNextPacket (TSPacket &packet) override
 Build the next MPEG packet for the list of items (sections or PES) to pacjetize.
 
PID getPID () const
 Get the default PID for subsequent MPEG packets.
 
uint8_t nextContinuityCounter () const
 Get the continuity counter value for next MPEG packet.
 
PacketCounter packetCount () const
 Get the number of generated TS packets so far.
 
PacketCounter pesCount () const
 Get the number of completely packetized PES packets so far.
 
PESProviderInterfacepesProvider () const
 Get the object which provides PES packets when the packetizer needs more data.
 
Reportreport () const
 Get a reference to the debugging report.
 
virtual void reset () override
 Reset the packetizer.
 
void setMaxQueuedPackets (size_t count)
 Set a limit to the number of internally queued PES packets.
 
void setNextContinuityCounter (uint8_t cc)
 Set the continuity counter value for next MPEG packet.
 
void setPID (PID pid)
 Set the default PID for subsequent MPEG packets.
 

Protected Member Functions

void configurePacket (TSPacket &pkt, bool nullify)
 Configure a TS packet with continuity and PID.
 

Detailed Description

Packetization of PES data into Transport Stream packets in "push" mode.

This class works in "push" mode; the application pushes new PES packets in the packetizer, asynchronously from the generation of the TS packets. If you need a PES packetizer working in "pull" mode, check class PESPacketizer.

Constructor & Destructor Documentation

◆ PESStreamPacketizer()

ts::PESStreamPacketizer::PESStreamPacketizer ( const DuckContext duck,
PID  pid = PID_NULL 
)

Constructor.

Parameters
[in]duckTSDuck execution context. The reference is kept inside the packetizer.
[in]pidPID for generated TS packets.

Member Function Documentation

◆ setMaxQueuedPackets()

void ts::PESStreamPacketizer::setMaxQueuedPackets ( size_t  count)
inline

Set a limit to the number of internally queued PES packets.

This is a way to limit the internal memory which is used by this instance.

Parameters
[in]countMaximum number of internally queued PES packets. If the number of already queued packets is already higher, none is dropped. If count is zero, there is no limit (this is the initial default).

◆ addPES() [1/2]

bool ts::PESStreamPacketizer::addPES ( const PESPacketPtr pes)

Add a PES packet to packetize.

Parameters
[in]pesA safe pointer to the PES packet.
Returns
True on success, false if the enqueue limit is reached.

◆ addPES() [2/2]

bool ts::PESStreamPacketizer::addPES ( const PESPacket pes,
ShareMode  mode 
)

Add a PES packet to packetize.

Parameters
[in]pesThe PES packet.
[in]modeThe enqueue PES packet's data are either shared (ShareMode::SHARE) between the provided pes or duplicated (ShareMode::COPY).
Returns
True on success, false if the enqueue limit is reached.

◆ empty()

bool ts::PESStreamPacketizer::empty ( ) const
inline

Check if the packetizer is empty (no more TS packet to produce).

Returns
True if the packetizer is empty, false otherwise.

◆ reset()

virtual void ts::PESStreamPacketizer::reset ( )
overridevirtual

Reset the packetizer.

All unfinished items (sections or PES packets) are dropped.

Reimplemented from ts::PESPacketizer.

◆ display()

virtual std::ostream & ts::PESStreamPacketizer::display ( std::ostream &  strm) const
overridevirtual

Display the internal state of the packetizer, mainly for debug.

Parameters
[in,out]strmOutput text stream.
Returns
A reference to strm.

Reimplemented from ts::PESPacketizer.

◆ pesProvider()

PESProviderInterface * ts::PESPacketizer::pesProvider ( ) const
inlineinherited

Get the object which provides PES packets when the packetizer needs more data.

Returns
The object which will be called each time a PES packet is required.

◆ atPESBoundary()

bool ts::PESPacketizer::atPESBoundary ( ) const
inlineinherited

Check if the TS packet stream is exactly at a PES packet boundary.

Returns
True if the last returned TS packet contained the end of a PES packet.

◆ pesCount()

PacketCounter ts::PESPacketizer::pesCount ( ) const
inlineinherited

Get the number of completely packetized PES packets so far.

Returns
The number of completely packetized PES packets so far.

◆ getNextPacket()

virtual bool ts::PESPacketizer::getNextPacket ( TSPacket packet)
overridevirtualinherited

Build the next MPEG packet for the list of items (sections or PES) to pacjetize.

If there is nothing to packetize, generate a null packet on PID_NULL.

Parameters
[out]packetThe next TS packet.
Returns
True if a real packet is returned, false if a null packet was returned.

Implements ts::AbstractPacketizer.

◆ setPID()

void ts::AbstractPacketizer::setPID ( PID  pid)
inlineinherited

Set the default PID for subsequent MPEG packets.

Parameters
[in]pidPID for generated TS packets.

◆ getPID()

PID ts::AbstractPacketizer::getPID ( ) const
inlineinherited

Get the default PID for subsequent MPEG packets.

Returns
PID for generated TS packets.

◆ setNextContinuityCounter()

void ts::AbstractPacketizer::setNextContinuityCounter ( uint8_t  cc)
inlineinherited

Set the continuity counter value for next MPEG packet.

This counter is automatically incremented at each packet. It is usually never a good idea to change this, except maybe before generating the first packet if the continuity must be preserved with the previous content of the PID.

Parameters
[in]ccNext continuity counter.

◆ nextContinuityCounter()

uint8_t ts::AbstractPacketizer::nextContinuityCounter ( ) const
inlineinherited

Get the continuity counter value for next MPEG packet.

Returns
Next continuity counter.

◆ packetCount()

PacketCounter ts::AbstractPacketizer::packetCount ( ) const
inlineinherited

Get the number of generated TS packets so far.

Returns
The number of generated TS packets so far.

◆ report()

Report & ts::AbstractPacketizer::report ( ) const
inlineinherited

Get a reference to the debugging report.

Returns
A reference to the debugging report.

◆ duck()

const DuckContext & ts::AbstractPacketizer::duck ( ) const
inlineinherited

Get a reference to the TSDuck execution context.

Returns
A reference to the TSDuck execution context.

◆ configurePacket()

void ts::AbstractPacketizer::configurePacket ( TSPacket pkt,
bool  nullify 
)
protectedinherited

Configure a TS packet with continuity and PID.

Also increment the number of generated packet. So this method must be called exactly once per packet.

Parameters
[in,out]pktTS packet to configure
[in]nullifyReturn a null packet instead (no data to return for now).

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