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

Representation of MPEG PES packets. More...

Public Member Functions

 PESPacket (PID source_pid=PID_NULL)
 Default constructor. More...
 
 PESPacket (const PESPacket &other, CopyShare mode)
 Copy constructor. More...
 
 PESPacket (const void *content, size_t content_size, PID source_pid=PID_NULL)
 Constructor from full binary content. More...
 
 PESPacket (const ByteBlock &content, PID source_pid=PID_NULL)
 Constructor from full binary content. More...
 
 PESPacket (const ByteBlockPtr &content_ptr, PID source_pid=PID_NULL)
 Constructor from full binary content. More...
 
void clear ()
 Clear packet content. More...
 
const uint8_t * content () const
 Access to the full binary content of the packet. More...
 
PESPacketcopy (const PESPacket &other)
 Duplication. More...
 
PacketCounter getFirstTSPacketIndex () const
 Index of first TS packet of the PES packet in the demultiplexed stream. More...
 
PacketCounter getLastTSPacketIndex () const
 Index of last TS packet of the PES packet in the demultiplexed stream. More...
 
PID getSourcePID () const
 Get the source PID. More...
 
uint8_t getStreamId () const
 Stream id of the PES packet. More...
 
uint8_t getStreamType () const
 Get the stream type, as specified in the PMT (optional). More...
 
bool hasLongHeader () const
 Check if the packet has a long header. More...
 
const uint8_t * header () const
 Access to the PES header of the packet. More...
 
size_t headerSize () const
 Size of the PES header of the packet. More...
 
bool isAC3 () const
 Check if the PES packet contains AC-3 or Enhanced-AC-3 audio. More...
 
bool isAVC () const
 Check if the PES packet contains AVC / H.264 video. More...
 
bool isMPEG2Video () const
 Check if the PES packet contains MPEG-2 video. More...
 
bool isValid () const
 Check if the packet has valid content. More...
 
bool operator!= (const PESPacket &other) const
 Unequality operator. More...
 
PESPacketoperator= (const PESPacket &other)
 Assignment operator. More...
 
bool operator== (const PESPacket &other) const
 Equality operator. More...
 
const uint8_t * payload () const
 Access to the payload of the packet. More...
 
size_t payloadSize () const
 Size of the payload of the packet. More...
 
void reload (const void *content, size_t content_size, PID source_pid=PID_NULL)
 Reload from full binary content. More...
 
void reload (const ByteBlock &content, PID source_pid=PID_NULL)
 Reload from full binary content. More...
 
void reload (const ByteBlockPtr &content_ptr, PID source_pid=PID_NULL)
 Reload from full binary content. More...
 
void setFirstTSPacketIndex (PacketCounter i)
 Set the first TS packet of the PES packet in the demultiplexed stream. More...
 
void setLastTSPacketIndex (PacketCounter i)
 Set the last TS packet of the PES packet in the demultiplexed stream. More...
 
void setSourcePID (PID pid)
 Set the source PID. More...
 
void setStreamId (uint8_t sid)
 Set the stream id of the PES packet. More...
 
void setStreamType (uint8_t type)
 Set the stream type, as specified in the PMT. More...
 
size_t size () const
 Size of the binary content of the packet. More...
 

Detailed Description

Representation of MPEG PES packets.

Constructor & Destructor Documentation

◆ PESPacket() [1/5]

ts::PESPacket::PESPacket ( PID  source_pid = PID_NULL)

Default constructor.

The PESPacket is initially marked invalid.

Parameters
[in]source_pidPID from which the packet was read.

◆ PESPacket() [2/5]

ts::PESPacket::PESPacket ( const PESPacket other,
CopyShare  mode 
)

Copy constructor.

Parameters
[in]otherAnother instance to copy.
[in]modeThe packet's data are either shared (ts::SHARE) between the two instances or duplicated (ts::COPY).

◆ PESPacket() [3/5]

ts::PESPacket::PESPacket ( const void *  content,
size_t  content_size,
PID  source_pid = PID_NULL 
)

Constructor from full binary content.

The content is copied into the packet if valid.

Parameters
[in]contentAddress of the binary packet data.
[in]content_sizeSize in bytes of the packet.
[in]source_pidPID from which the packet was read.

◆ PESPacket() [4/5]

ts::PESPacket::PESPacket ( const ByteBlock content,
PID  source_pid = PID_NULL 
)

Constructor from full binary content.

The content is copied into the packet if valid.

Parameters
[in]contentBinary packet data.
[in]source_pidPID from which the packet was read.

◆ PESPacket() [5/5]

ts::PESPacket::PESPacket ( const ByteBlockPtr content_ptr,
PID  source_pid = PID_NULL 
)

Constructor from full binary content.

The content is copied into the packet if valid.

Parameters
[in]content_ptrSafe pointer to the binary packet data. The content is referenced, and thus shared. Do not modify the referenced ByteBlock from outside the PESPacket.
[in]source_pidPID from which the packet was read.

Member Function Documentation

◆ reload() [1/3]

void ts::PESPacket::reload ( const void *  content,
size_t  content_size,
PID  source_pid = PID_NULL 
)
inline

Reload from full binary content.

The content is copied into the packet if valid.

Parameters
[in]contentAddress of the binary packet data.
[in]content_sizeSize in bytes of the packet.
[in]source_pidPID from which the packet was read.

◆ reload() [2/3]

void ts::PESPacket::reload ( const ByteBlock content,
PID  source_pid = PID_NULL 
)
inline

Reload from full binary content.

The content is copied into the packet if valid.

Parameters
[in]contentBinary packet data.
[in]source_pidPID from which the packet was read.

◆ reload() [3/3]

void ts::PESPacket::reload ( const ByteBlockPtr content_ptr,
PID  source_pid = PID_NULL 
)
inline

Reload from full binary content.

The content is copied into the packet if valid.

Parameters
[in]content_ptrSafe pointer to the binary packet data. The content is referenced, and thus shared. Do not modify the referenced ByteBlock from outside the PESPacket.
[in]source_pidPID from which the packet was read.

◆ clear()

void ts::PESPacket::clear ( )

Clear packet content.

Becomes an invalid packet.

◆ operator=()

PESPacket& ts::PESPacket::operator= ( const PESPacket other)

Assignment operator.

The packets are referenced, and thus shared between the two packet objects.

Parameters
[in]otherOther packet to assign to this object.
Returns
A reference to this object.

◆ copy()

PESPacket& ts::PESPacket::copy ( const PESPacket other)

Duplication.

Similar to assignment but the packets are duplicated.

Parameters
[in]otherOther packet to duplicate into this object.
Returns
A reference to this object.

◆ isValid()

bool ts::PESPacket::isValid ( ) const
inline

Check if the packet has valid content.

Returns
True if the packet has valid content.

◆ operator==()

bool ts::PESPacket::operator== ( const PESPacket other) const

Equality operator.

The source PID's are ignored, only the packet contents are compared. Invalid packets are never identical.

Parameters
[in]otherOther packet to compare.
Returns
True if the two packets are identical. False otherwise.

◆ operator!=()

bool ts::PESPacket::operator!= ( const PESPacket other) const
inline

Unequality operator.

The source PID's are ignored, only the packet contents are compared. Invalid packets are never identical.

Parameters
[in]otherOther packet to compare.
Returns
True if the two packets are different. False otherwise.

◆ getSourcePID()

PID ts::PESPacket::getSourcePID ( ) const
inline

Get the source PID.

Returns
The source PID.

◆ setSourcePID()

void ts::PESPacket::setSourcePID ( PID  pid)
inline

Set the source PID.

Parameters
[in]pidThe source PID.

◆ getStreamType()

uint8_t ts::PESPacket::getStreamType ( ) const
inline

Get the stream type, as specified in the PMT (optional).

Returns
The stream type.

◆ setStreamType()

void ts::PESPacket::setStreamType ( uint8_t  type)
inline

Set the stream type, as specified in the PMT.

Parameters
[in]typeThe stream type.

◆ getFirstTSPacketIndex()

PacketCounter ts::PESPacket::getFirstTSPacketIndex ( ) const
inline

Index of first TS packet of the PES packet in the demultiplexed stream.

Usually valid only if the PES packet was extracted by a PES demux.

Returns
The first TS packet of the PES packet in the demultiplexed stream.

◆ getLastTSPacketIndex()

PacketCounter ts::PESPacket::getLastTSPacketIndex ( ) const
inline

Index of last TS packet of the PES packet in the demultiplexed stream.

Usually valid only if the PES packet was extracted by a PES demux.

Returns
The last TS packet of the PES packet in the demultiplexed stream.

◆ setFirstTSPacketIndex()

void ts::PESPacket::setFirstTSPacketIndex ( PacketCounter  i)
inline

Set the first TS packet of the PES packet in the demultiplexed stream.

Parameters
[in]iThe first TS packet of the PES packet in the demultiplexed stream.

◆ setLastTSPacketIndex()

void ts::PESPacket::setLastTSPacketIndex ( PacketCounter  i)
inline

Set the last TS packet of the PES packet in the demultiplexed stream.

Parameters
[in]iThe last TS packet of the PES packet in the demultiplexed stream.

◆ getStreamId()

uint8_t ts::PESPacket::getStreamId ( ) const
inline

Stream id of the PES packet.

Returns
The stream id of the PES packet.

◆ setStreamId()

void ts::PESPacket::setStreamId ( uint8_t  sid)
inline

Set the stream id of the PES packet.

Parameters
[in]sidThe stream id of the PES packet.

◆ hasLongHeader()

bool ts::PESPacket::hasLongHeader ( ) const
inline

Check if the packet has a long header.

Returns
True if the packet has a long header.

◆ content()

const uint8_t* ts::PESPacket::content ( ) const
inline

Access to the full binary content of the packet.

Do not modify content.

Returns
Address of the full binary content of the packet. May be invalidated after modification in packet.

◆ size()

size_t ts::PESPacket::size ( ) const
inline

Size of the binary content of the packet.

Returns
Size of the binary content of the packet.

◆ header()

const uint8_t* ts::PESPacket::header ( ) const
inline

Access to the PES header of the packet.

Returns
Address of the PES header of the packet.

◆ headerSize()

size_t ts::PESPacket::headerSize ( ) const
inline

Size of the PES header of the packet.

Returns
Size of the PES header of the packet.

◆ payload()

const uint8_t* ts::PESPacket::payload ( ) const
inline

Access to the payload of the packet.

Returns
Address of the payload of the packet.

◆ payloadSize()

size_t ts::PESPacket::payloadSize ( ) const
inline

Size of the payload of the packet.

Returns
Size of the payload of the packet.

◆ isMPEG2Video()

bool ts::PESPacket::isMPEG2Video ( ) const

Check if the PES packet contains MPEG-2 video.

Also applies to MPEG-1 video.

Returns
True if the PES packet contains MPEG-2 video.

◆ isAVC()

bool ts::PESPacket::isAVC ( ) const

Check if the PES packet contains AVC / H.264 video.

Returns
True if the PES packet contains AVC / H.264 video.

◆ isAC3()

bool ts::PESPacket::isAC3 ( ) const

Check if the PES packet contains AC-3 or Enhanced-AC-3 audio.

Warning: As specified in ETSI TS 102 366, an AC-3 audio frame always starts with 0x0B77. This is what we check here. However, it is still possible that other encodings may start from time to time with 0x0B77. Thus, it is safe to say that a PID in which all PES packets start with 0x0B77 (ie isAC3() returns true) contains AC-3. However, if only a few PES packets start with 0x0B77, it is safe to say that it should be something else.

Returns
True if the PES packet contains AC-3 or Enhanced-AC-3 audio.

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