10#ifndef __SOFTHDDEVICE_PES_H
11#define __SOFTHDDEVICE_PES_H
19#include <libavcodec/avcodec.h>
cPesAudio(const uint8_t *data, int size)
bool IsPrivateStreamId(void)
bool IsAudioStreamId(void)
bool IsStreamIdValid(void) override
bool IsStreamIdValid(void) override
cPesVideo(const uint8_t *data, int size)
static constexpr uint32_t PES_PACKET_START_CODE_PREFIX
bool m_valid
flag indicating if the PES packet is valid
virtual bool IsStreamIdValid(void)=0
int m_size
size of the PES packet
const uint8_t * m_data
pointer to the raw PES packet data
uint8_t GetStreamId(void)
static constexpr uint32_t PES_PACKET_START_CODE_PREFIX_LEN
const char * GetIdentifier(void)
std::vector< uint8_t > m_data
Byte buffer.
cPtsTrackingBuffer(const char *identifier)
std::map< size_t, int64_t > m_pts
Map of buffer positions to PTS values.
const uint8_t * Peek(void)
const char * m_identifier
Audio Stream Reassembly Buffer.
static constexpr int MAX_HEADER_SIZE
cReassemblyBufferAudio(void)
bool m_ptsInvalid
flag indicating if PTS is invalid for current buffer, because it was truncated
Video Stream Reassembly Buffer.
AVPacket * PopAvPacket(void) override
static constexpr uint32_t VIDEO_FRAME_START_CODE
static constexpr int VIDEO_FRAME_START_CODE_LEN
static constexpr uint8_t H264_STREAM_TYPE
static constexpr uint8_t MPEG2_STREAM_TYPE
static constexpr uint8_t HEVC_STREAM_TYPE
cReassemblyBufferVideo(void)
Base Class for Stream Reassembly Buffers.
AVCodecID m_codec
detected codec ID
int64_t m_lastPoppedPts
PTS of the last popped AVPacket.
virtual void Push(const uint8_t *data, int size, int64_t pts)
virtual AVPacket * PopAvPacket(void)=0
cPtsTrackingBuffer m_buffer
fragmentation buffer
cReassemblyBuffer(const char *identifier)
int64_t GetPts(void)
Get the PTS value for the current buffer position.
AVCodecID TruncateBufferUntilFirstValidData(void)
Truncate buffer until the first valid audio frame.
void Push(const uint8_t *, int, int64_t)
Push data into the PTS tracking buffer.
void Reset(void)
Reset the reassembly buffer.
const uint8_t * GetPayload(void)
Get a pointer to the PES payload data.
AVCodecID DetectCodecFromSyncWord(const uint8_t *, int)
Detect audio codec from sync word pattern.
int GetPayloadSize(void)
Get the size of the PES payload.
bool HasLeadingZero(const uint8_t *, int)
Check if video data has a leading zero byte before the start code.
SyncWordInfo FindSyncWord(const uint8_t *, int)
Find the first audio sync word in data.
bool HasPts(void)
Check if the PES packet contains a Presentation Time Stamp (PTS)
bool IsHeaderValid(void)
Check if the PES header is valid.
void Erase(size_t)
Erase data from the beginning of the buffer.
int GetPacketLength(void)
Get the total length of the PES packet.
bool IsValid(void)
Check if the PES packet is valid.
SyncWordInfo FindTwoConsecutiveFramesWithSameSyncWord()
Find two consecutive audio frames with the same sync word.
AVPacket * PopAvPacket(void) override
Pop an audio AVPacket from the reassembly buffer.
bool ParseCodecHeader(const uint8_t *, int)
Parse video codec header to detect codec type.
int64_t GetPts(void)
Get the Presentation Time Stamp (PTS) from the PES header.
int GetFrameSizeForCodec(AVCodecID, const uint8_t *)
Get the frame size for a given codec and frame header.
void Init(void)
Initialize and validate the PES packet.
Information about a detected audio sync word.
AVCodecID codecId
Detected codec ID.
int pos
Position of sync word in buffer.