|
vdr-plugin-softhddevice-drm-gles 1.4.0
|
PES packet parser class. More...
#include <pes.h>
Public Member Functions | |
| cPes (const uint8_t *, int) | |
| Construct a PES packet parser. More... | |
| bool | IsValid () |
| Check if the PES packet is valid. More... | |
| bool | HasPts () |
| Check if the PES packet contains a Presentation Time Stamp (PTS) More... | |
| int64_t | GetPts () |
| Get the Presentation Time Stamp (PTS) from the PES header. More... | |
| const uint8_t * | GetPayload () |
| Get a pointer to the PES payload data. More... | |
| int | GetPayloadSize () |
| Get the size of the PES payload. More... | |
| int | GetPacketLength () |
| Get the total length of the PES packet. More... | |
| uint8_t | GetStreamId () |
Protected Member Functions | |
| virtual bool | IsStreamIdValid ()=0 |
| void | Init () |
| Initialize and validate the PES packet. More... | |
| bool | IsHeaderValid () |
| Check if the PES header is valid. More... | |
Protected Attributes | |
| bool | m_valid = false |
| flag indicating if the PES packet is valid More... | |
| const uint8_t * | m_data |
| pointer to the raw PES packet data More... | |
| int | m_size |
| size of the PES packet More... | |
Static Protected Attributes | |
| static constexpr uint32_t | PES_PACKET_START_CODE_PREFIX = 0x00'0001 |
| static constexpr uint32_t | PES_PACKET_START_CODE_PREFIX_LEN = 3 |
PES packet parser class.
This class parses PES (Packetized Elementary Stream) packets to extract header information, PTS, and payload data.
| cPes::cPes | ( | const uint8_t * | data, |
| int | size | ||
| ) |
Construct a PES packet parser.
Initializes the parser with a pointer to PES packet data and its size. The actual validation is performed by calling Init() in derived classes.
| data | Pointer to the raw PES packet data |
| size | Size of the PES packet in bytes |
| int cPes::GetPacketLength | ( | ) |
Get the total length of the PES packet.
Returns the complete size of the PES packet including both header and payload. The length is read from the PES packet header (bytes 4-5).
For packets with a specified length field (common for audio):
For unbounded packets (length field = 0, common for video streams):
Definition at line 346 of file pes.cpp.
References m_data, and m_size.
Referenced by cSoftHdDevice::HandleStillPicture(), and TEST_CASE().
| const uint8_t * cPes::GetPayload | ( | ) |
Get a pointer to the PES payload data.
Returns a pointer to the start of the payload data, skipping the PES header. For H.264/HEVC streams with a leading zero byte, the leading zero is also skipped.
Definition at line 311 of file pes.cpp.
References m_data.
Referenced by cSoftHdDevice::PlayAudio(), cSoftHdDevice::PlayVideoInternal(), and TEST_CASE().
| int cPes::GetPayloadSize | ( | ) |
Get the size of the PES payload.
Calculates the size of the payload by subtracting the header size (and optional leading zero for H.264/HEVC) from the total packet size.
Definition at line 324 of file pes.cpp.
References m_data, and m_size.
Referenced by cSoftHdDevice::PlayAudio(), cSoftHdDevice::PlayVideoInternal(), and TEST_CASE().
| int64_t cPes::GetPts | ( | ) |
Get the Presentation Time Stamp (PTS) from the PES header.
Extracts the PTS value from the PES packet header if present. The PTS indicates when the decoded content should be presented.
Definition at line 295 of file pes.cpp.
References AV_NOPTS_VALUE, HasPts(), and m_data.
Referenced by cSoftHdDevice::PlayAudio(), cSoftHdDevice::PlayVideoInternal(), and TEST_CASE().
|
inline |
Definition at line 48 of file pes.h.
References m_data.
Referenced by Init(), cPesAudio::IsAudioStreamId(), cPesAudio::IsPrivateStreamId(), and cPesVideo::IsStreamIdValid().
| bool cPes::HasPts | ( | void | ) |
Check if the PES packet contains a Presentation Time Stamp (PTS)
Examines the PES header flags to determine if a PTS is present in the packet. The PTS presence is indicated by specific bits in the PES header flags field.
Definition at line 282 of file pes.cpp.
References m_data.
Referenced by GetPts(), and cSoftHdDevice::PlayVideoInternal().
|
protected |
Initialize and validate the PES packet.
Performs validation checks on the PES packet structure:
Sets m_valid to true if all checks pass. Called by derived class constructors.
Definition at line 231 of file pes.cpp.
References GetStreamId(), IsHeaderValid(), IsStreamIdValid(), LOGDEBUG, LOGWARNING, m_data, m_size, and m_valid.
Referenced by cPesAudio::cPesAudio(), and cPesVideo::cPesVideo().
|
protected |
Check if the PES header is valid.
Validates that the PES packet has a valid header by checking:
Definition at line 269 of file pes.cpp.
References m_data, m_size, PES_PACKET_START_CODE_PREFIX, and ReadBytes().
Referenced by Init().
|
protectedpure virtual |
| bool cPes::IsValid | ( | ) |
Check if the PES packet is valid.
Validates that the PES packet is well-formed and matches the expected stream type by checking:
The stream ID is masked with 0xF0 to check the stream type category (e.g., 0xE0 for video, 0xC0 for audio) while ignoring the low nibble which indicates the specific stream number.
Video streams have stream IDs in the range 0xE0-0xEF according to H.222.0 03/2017 Table 2-22, audio streams have IDs in the range 0xC0-0xCF.
Definition at line 256 of file pes.cpp.
References m_valid.
Referenced by cSoftHdDevice::HandleStillPicture(), cSoftHdDevice::PlayAudio(), cSoftHdDevice::PlayVideoInternal(), and TEST_CASE().
|
protected |
pointer to the raw PES packet data
Definition at line 56 of file pes.h.
Referenced by GetPacketLength(), GetPayload(), GetPayloadSize(), GetPts(), GetStreamId(), HasPts(), Init(), and IsHeaderValid().
|
protected |
size of the PES packet
Definition at line 57 of file pes.h.
Referenced by GetPacketLength(), GetPayloadSize(), Init(), and IsHeaderValid().
|
protected |
|
staticconstexprprotected |
Definition at line 61 of file pes.h.
Referenced by IsHeaderValid().
|
staticconstexprprotected |