QtlMovie 1.12 (A specialized FFmpeg front-end)
QtsPesPacket Class Reference

Basic definition of an MPEG-2 PES packet(Packetized Elementary Stream). More...

Public Member Functions

 QtsPesPacket ()
 Default constructor. More...
 
 QtsPesPacket (const void *addr, int size, QtsPid pid=QTS_PID_NULL)
 Constructor from full binary content. More...
 
 QtsPesPacket (const QtlByteBlock &content, QtsPid pid=QTS_PID_NULL)
 Constructor from full binary content. More...
 
void clear ()
 Clear packet content, becomes an invalid packet. More...
 
QtlByteBlock content () const
 Get a copy of the full binary content of the packet. More...
 
quint64 getDts () const
 Get the DTS (Decoding Time Stamp) - 33 bits. More...
 
QtsPacketCounter getFirstTsPacketIndex () const
 Get the index of first TS packet of the PES packet in the demultiplexed stream. More...
 
QtsPacketCounter getLastTsPacketIndex () const
 Get the index of last TS packet of the PES packet in the demultiplexed stream. More...
 
quint64 getPts () const
 Get the PTS (Presentation Time Stamp) - 33 bits. More...
 
QtsPid getSourcePid () const
 Get the PID from which the packet was collected (informational only). More...
 
QtsPesStreamId getStreamId () const
 Get the stream identifier of the PES packet. More...
 
bool hasDts () const
 Check if the PES packet contains a DTS (Decoding Time Stamp). More...
 
bool hasLongHeader () const
 Check if the packet has a long header. More...
 
bool hasPts () const
 Check if the PES packet contains a PTS (Presentation Time Stamp). More...
 
const quint8 * header () const
 Get the address of the PES header in the packet. More...
 
int headerSize () const
 Get the size of the PES header in 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. More...
 
bool isMpeg2Video () const
 Check if the PES packet contains MPEG-2 video (also applies to MPEG-1 video). More...
 
bool isValid () const
 Check if a packet has valid content. More...
 
bool operator!= (const QtsPesPacket &other) const
 Difference operator. More...
 
bool operator== (const QtsPesPacket &other) const
 Comparison operator. More...
 
const quint8 * payload () const
 Get the address of the PES payload in the packet. More...
 
int payloadSize () const
 Get the size of the PES payload in the packet. More...
 
void reload (const void *addr, int size, QtsPid pid=QTS_PID_NULL)
 Reload full binary content. More...
 
void reload (const QtlByteBlock &content, QtsPid pid=QTS_PID_NULL)
 Reload full binary content. More...
 
void setDts (const quint64 &dts)
 Replace the DTS (Decoding Time Stamp) value - 33 bits. More...
 
void setFirstTsPacketIndex (QtsPacketCounter i)
 Set the index of first TS packet of the PES packet in the demultiplexed stream. More...
 
void setLastTsPacketIndex (QtsPacketCounter i)
 Set the index of last TS packet of the PES packet in the demultiplexed stream. More...
 
void setPts (const quint64 &pts)
 Replace the PTS (Presentation Time Stamp) value - 33 bits. More...
 
void setSourcePid (QtsPid pid)
 Set the PID from which the packet was collected (informational only). More...
 
void setStreamId (QtsPesStreamId sid)
 Set the stream identifier of the PES packet. More...
 
int size () const
 Get the size in bytes of the packet. More...
 

Private Member Functions

void initialize (QtsPid pid)
 Helper for constructor. More...
 
void initialize (const QtlByteBlock &bb, QtsPid pid)
 Helper for constructor. More...
 

Private Attributes

QtlByteBlock _data
 Full binary content of the packet. More...
 
QtsPacketCounter _firstPkt
 Index of first packet in stream. More...
 
int _headerSize
 PES header size in bytes. More...
 
bool _isValid
 Content of _data is a valid packet. More...
 
QtsPacketCounter _lastPkt
 Index of last packet in stream. More...
 
QtsPid _sourcePid
 Source PID (informational). More...
 

Detailed Description

Basic definition of an MPEG-2 PES packet(Packetized Elementary Stream).

Constructor & Destructor Documentation

◆ QtsPesPacket() [1/3]

QtsPesPacket::QtsPesPacket ( )
inline

Default constructor.

The PES packet is initially marked invalid.

◆ QtsPesPacket() [2/3]

QtsPesPacket::QtsPesPacket ( const void *  addr,
int  size,
QtsPid  pid = QTS_PID_NULL 
)
inline

Constructor from full binary content.

The content is copied into the packet only if valid.

Parameters
[in]addrAddress of binary content.
[in]sizeSize of binary content.
[in]pidPID from which the PES packet was extracted (informational only).

◆ QtsPesPacket() [3/3]

QtsPesPacket::QtsPesPacket ( const QtlByteBlock content,
QtsPid  pid = QTS_PID_NULL 
)
inline

Constructor from full binary content.

The content is copied into the packet only if valid.

Parameters
[in]contentBinary content.
[in]pidPID from which the PES packet was extracted (informational only).

Member Function Documentation

◆ reload() [1/2]

void QtsPesPacket::reload ( const void *  addr,
int  size,
QtsPid  pid = QTS_PID_NULL 
)
inline

Reload full binary content.

The content is copied into the packet only if valid.

Parameters
[in]addrAddress of binary content.
[in]sizeSize of binary content.
[in]pidPID from which the PES packet was extracted (informational only).

◆ reload() [2/2]

void QtsPesPacket::reload ( const QtlByteBlock content,
QtsPid  pid = QTS_PID_NULL 
)
inline

Reload full binary content.

The content is copied into the packet only if valid.

Parameters
[in]contentBinary content.
[in]pidPID from which the PES packet was extracted (informational only).

◆ clear()

void QtsPesPacket::clear ( )

Clear packet content, becomes an invalid packet.

◆ isValid()

bool QtsPesPacket::isValid ( ) const
inline

Check if a packet has valid content.

Returns
True if the packet content is valid, false otherwise.

◆ operator==()

bool QtsPesPacket::operator== ( const QtsPesPacket other) const

Comparison operator.

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

Parameters
[in]otherOther instance to compare.
Returns
True if packets are identical, false otherwise.

◆ operator!=()

bool QtsPesPacket::operator!= ( const QtsPesPacket other) const
inline

Difference operator.

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

Parameters
[in]otherOther instance to compare.
Returns
True if packets are identical, false otherwise.

◆ getSourcePid()

QtsPid QtsPesPacket::getSourcePid ( ) const
inline

Get the PID from which the packet was collected (informational only).

Returns
The PID from which the packet was collected.

◆ setSourcePid()

void QtsPesPacket::setSourcePid ( QtsPid  pid)
inline

Set the PID from which the packet was collected (informational only).

Parameters
[in]pidThe PID from which the packet was collected.

◆ getFirstTsPacketIndex()

QtsPacketCounter QtsPesPacket::getFirstTsPacketIndex ( ) const
inline

Get the index of first TS packet of the PES packet in the demultiplexed stream.

Returns
The index of first TS packet of the PES packet.

◆ getLastTsPacketIndex()

QtsPacketCounter QtsPesPacket::getLastTsPacketIndex ( ) const
inline

Get the index of last TS packet of the PES packet in the demultiplexed stream.

Returns
The index of last TS packet of the PES packet.

◆ setFirstTsPacketIndex()

void QtsPesPacket::setFirstTsPacketIndex ( QtsPacketCounter  i)
inline

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

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

◆ setLastTsPacketIndex()

void QtsPesPacket::setLastTsPacketIndex ( QtsPacketCounter  i)
inline

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

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

◆ getStreamId()

QtsPesStreamId QtsPesPacket::getStreamId ( ) const
inline

Get the stream identifier of the PES packet.

Returns
The stream identifier of the PES packet.

◆ setStreamId()

void QtsPesPacket::setStreamId ( QtsPesStreamId  sid)
inline

Set the stream identifier of the PES packet.

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

◆ hasLongHeader()

bool QtsPesPacket::hasLongHeader ( ) const
inline

Check if the packet has a long header.

Returns
True if the packet has a long header.

◆ content()

QtlByteBlock QtsPesPacket::content ( ) const
inline

Get a copy of the full binary content of the packet.

Returns
The full binary content of the packet.

◆ size()

int QtsPesPacket::size ( ) const
inline

Get the size in bytes of the packet.

Returns
The size in bytes of the packet.

◆ header()

const quint8* QtsPesPacket::header ( ) const
inline

Get the address of the PES header in the packet.

Do not modify the content.

Returns
Address of the PES header in the packet. May be invalidated when the packet is reloaded. Zero if the packet is invalid.

◆ headerSize()

int QtsPesPacket::headerSize ( ) const
inline

Get the size of the PES header in the packet.

Returns
Size of the PES header in the packet.

◆ payload()

const quint8* QtsPesPacket::payload ( ) const
inline

Get the address of the PES payload in the packet.

Do not modify the content.

Returns
Address of the PES payload in the packet. May be invalidated when the packet is reloaded. Zero if the packet is invalid.

◆ payloadSize()

int QtsPesPacket::payloadSize ( ) const
inline

Get the size of the PES payload in the packet.

Returns
Size of the PES payload in the packet.

◆ isMpeg2Video()

bool QtsPesPacket::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 QtsPesPacket::isAvc ( ) const

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

Returns
True if the PES packet contains AVC video.

◆ isAc3()

bool QtsPesPacket::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.

◆ hasPts()

bool QtsPesPacket::hasPts ( ) const

Check if the PES packet contains a PTS (Presentation Time Stamp).

Returns
True if the PES packet contains a PTS.

◆ getPts()

quint64 QtsPesPacket::getPts ( ) const

Get the PTS (Presentation Time Stamp) - 33 bits.

Returns
PTS value or zero if not found.

◆ setPts()

void QtsPesPacket::setPts ( const quint64 &  pts)

Replace the PTS (Presentation Time Stamp) value - 33 bits.

Do nothing if the packet has not PTS.

Parameters
ptsPTS value to replace.

◆ hasDts()

bool QtsPesPacket::hasDts ( ) const

Check if the PES packet contains a DTS (Decoding Time Stamp).

Returns
True if the PES packet contains a DTS.

◆ getDts()

quint64 QtsPesPacket::getDts ( ) const

Get the DTS (Decoding Time Stamp) - 33 bits.

Returns
DTS value or zero if not found.

◆ setDts()

void QtsPesPacket::setDts ( const quint64 &  dts)

Replace the DTS (Decoding Time Stamp) value - 33 bits.

Do nothing if the packet has not DTS.

Parameters
dtsDTS value to replace.

◆ initialize() [1/2]

void QtsPesPacket::initialize ( QtsPid  pid)
private

Helper for constructor.

Parameters
[in]pidSource PID.

◆ initialize() [2/2]

void QtsPesPacket::initialize ( const QtlByteBlock bb,
QtsPid  pid 
)
private

Helper for constructor.

Parameters
[in]bbPES packet binary content.
[in]pidSource PID.

Member Data Documentation

◆ _isValid

bool QtsPesPacket::_isValid
private

Content of _data is a valid packet.

◆ _headerSize

int QtsPesPacket::_headerSize
private

PES header size in bytes.

◆ _sourcePid

QtsPid QtsPesPacket::_sourcePid
private

Source PID (informational).

◆ _firstPkt

QtsPacketCounter QtsPesPacket::_firstPkt
private

Index of first packet in stream.

◆ _lastPkt

QtsPacketCounter QtsPesPacket::_lastPkt
private

Index of last packet in stream.

◆ _data

QtlByteBlock QtsPesPacket::_data
private

Full binary content of the packet.


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