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 * GetPayload(void)
Get a pointer to the PES payload data.
const uint8_t * m_data
pointer to the raw PES packet data
uint8_t GetStreamId(void)
int GetPayloadSize(void)
Get the size of the PES payload.
bool HasPts(void)
Check if the PES packet contains a Presentation Time Stamp (PTS)
bool IsHeaderValid(void)
Check if the PES header is valid.
int GetPacketLength(void)
Get the total length of the PES packet.
static constexpr uint32_t PES_PACKET_START_CODE_PREFIX_LEN
bool IsValid(void)
Check if the PES packet is valid.
int64_t GetPts(void)
Get the Presentation Time Stamp (PTS) from the PES header.
void Init(void)
Initialize and validate the PES packet.
int64_t GetPts(void)
Get the PTS value for the current buffer position.
const char * GetIdentifier(void)
void Push(const uint8_t *, int, int64_t)
Push data into the PTS tracking buffer.
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)
void Erase(size_t)
Erase data from the beginning of the buffer.
const char * m_identifier
Audio Stream Reassembly Buffer.
AVCodecID TruncateBufferUntilFirstValidData(void)
Truncate buffer until the first valid audio frame.
static constexpr int MAX_HEADER_SIZE
AVCodecID DetectCodecFromSyncWord(const uint8_t *, int)
Detect audio codec from sync word pattern.
SyncWordInfo FindSyncWord(const uint8_t *, int)
Find the first audio sync word in data.
cReassemblyBufferAudio(void)
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 m_ptsInvalid
flag indicating if PTS is invalid for current buffer, because it was truncated
int GetFrameSizeForCodec(AVCodecID, const uint8_t *)
Get the frame size for a given codec and frame header.
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
bool HasLeadingZero(const uint8_t *, int)
Check if video data has a leading zero byte before the start code.
static constexpr uint8_t HEVC_STREAM_TYPE
cReassemblyBufferVideo(void)
bool ParseCodecHeader(const uint8_t *, int)
Parse video codec header to detect codec type.
Base Class for Stream Reassembly Buffers.
AVCodecID m_codec
detected codec ID
void Reset(void)
Reset the reassembly buffer.
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)
Information about a detected audio sync word.
AVCodecID codecId
Detected codec ID.
int pos
Position of sync word in buffer.