TSDuck Version 3.32-2780 (TSDuck - The MPEG Transport Stream Toolkit)
ts::Packetizer Class Reference

Packetization of MPEG sections into Transport Stream packets. More...

Inheritance diagram for ts::Packetizer:
Collaboration diagram for ts::Packetizer:

Public Member Functions

 Packetizer (const DuckContext &duck, PID pid=PID_NULL, SectionProviderInterface *provider=nullptr)
 Constructor. More...
 
virtual ~Packetizer () override
 Destructor.
 
void allowHeaderSplit (bool allow)
 Allow or disallow splitting section headers across TS packets. More...
 
bool atSectionBoundary () const
 Check if the packet stream is exactly at a section boundary. More...
 
virtual std::ostream & display (std::ostream &strm) const override
 Display the internal state of the packetizer, mainly for debug. More...
 
const DuckContextduck () const
 Get a reference to the TSDuck execution context. More...
 
virtual bool getNextPacket (TSPacket &packet) override
 Build the next MPEG packet for the list of items (sections or PES) to pacjetize. More...
 
PID getPID () const
 Get the default PID for subsequent MPEG packets. More...
 
bool headerSplitAllowed () const
 Check if splitting section headers across TS packets is allowed. More...
 
uint8_t nextContinuityCounter () const
 Get the continuity counter value for next MPEG packet. More...
 
PacketCounter packetCount () const
 Get the number of generated TS packets so far. More...
 
Reportreport () const
 Get a reference to the debugging report. More...
 
virtual void reset () override
 Reset the packetizer. More...
 
SectionCounter sectionCount () const
 Get the number of completely packetized sections so far. More...
 
SectionProviderInterfacesectionProvider () const
 Get the object which provides MPEG sections when the packetizer needs a new section. More...
 
void setNextContinuityCounter (uint8_t cc)
 Set the continuity counter value for next MPEG packet. More...
 
void setPID (PID pid)
 Set the default PID for subsequent MPEG packets. More...
 
void setSectionProvider (SectionProviderInterface *provider)
 Set the object which provides MPEG sections when the packetizer needs a new section. More...
 

Protected Member Functions

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

Detailed Description

Packetization of MPEG sections into Transport Stream packets.

Sections are provided by an object implementing SectionProviderInterface.

Constructor & Destructor Documentation

◆ Packetizer()

ts::Packetizer::Packetizer ( const DuckContext duck,
PID  pid = PID_NULL,
SectionProviderInterface provider = nullptr 
)

Constructor.

Parameters
[in]duckTSDuck execution context. The reference is kept inside the packetizer.
[in]pidPID for generated TS packets.
[in]providerAn object which will be called each time a section is required.

Member Function Documentation

◆ setSectionProvider()

void ts::Packetizer::setSectionProvider ( SectionProviderInterface provider)
inline

Set the object which provides MPEG sections when the packetizer needs a new section.

Parameters
[in]providerAn object which will be called each time a section is required.

◆ sectionProvider()

SectionProviderInterface* ts::Packetizer::sectionProvider ( ) const
inline

Get the object which provides MPEG sections when the packetizer needs a new section.

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

◆ atSectionBoundary()

bool ts::Packetizer::atSectionBoundary ( ) const
inline

Check if the packet stream is exactly at a section boundary.

Returns
True if the last returned packet contained the end of a section and no unfinished section.

◆ sectionCount()

SectionCounter ts::Packetizer::sectionCount ( ) const
inline

Get the number of completely packetized sections so far.

Returns
The number of completely packetized sections so far.

◆ allowHeaderSplit()

void ts::Packetizer::allowHeaderSplit ( bool  allow)
inline

Allow or disallow splitting section headers across TS packets.

By default, a Packetizer never splits a section header between two TS packets. This is not required by the MPEG standard but some STB are known to have problems with that.

Parameters
[in]allowIf true, splitting section headers across TS packets is allowed.

◆ headerSplitAllowed()

bool ts::Packetizer::headerSplitAllowed ( ) const
inline

Check if splitting section headers across TS packets is allowed.

Returns
True if splitting section headers across TS packets is allowed.

◆ reset()

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

Reset the packetizer.

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

Reimplemented from ts::AbstractPacketizer.

Reimplemented in ts::CyclingPacketizer.

◆ getNextPacket()

virtual bool ts::Packetizer::getNextPacket ( TSPacket packet)
overridevirtual

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.

◆ display()

virtual std::ostream& ts::Packetizer::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::AbstractPacketizer.

Reimplemented in ts::CyclingPacketizer.

◆ 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: