18#ifndef __SOFTHDDEVICE_PES_H
19#define __SOFTHDDEVICE_PES_H
29#include <libavcodec/avcodec.h>
41 cPes(
const uint8_t *,
int);
102 void Push(
const uint8_t *,
int, int64_t);
123 virtual void Push(
const uint8_t *data,
int size, int64_t pts) {
m_buffer.
Push(data, size, pts); }
cPesAudio(const uint8_t *data, int size)
bool IsStreamIdValid() override
bool IsStreamIdValid() override
cPesVideo(const uint8_t *data, int size)
bool IsValid()
Check if the PES packet is valid.
static constexpr uint32_t PES_PACKET_START_CODE_PREFIX
bool m_valid
flag indicating if the PES packet is valid
int GetPayloadSize()
Get the size of the PES payload.
int m_size
size of the PES packet
cPes(const uint8_t *, int)
Construct a PES packet parser.
int GetPacketLength()
Get the total length of the PES packet.
const uint8_t * GetPayload()
Get a pointer to the PES payload data.
const uint8_t * m_data
pointer to the raw PES packet data
virtual bool IsStreamIdValid()=0
void Init()
Initialize and validate the PES packet.
bool IsHeaderValid()
Check if the PES header is valid.
bool HasPts()
Check if the PES packet contains a Presentation Time Stamp (PTS)
int64_t GetPts()
Get the Presentation Time Stamp (PTS) from the PES header.
static constexpr uint32_t PES_PACKET_START_CODE_PREFIX_LEN
Buffer that tracks PTS values at specific byte positions.
const char * GetIdentifier()
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.
void Erase(size_t)
Erase data from the beginning of the buffer.
const char * m_identifier
int64_t GetPts()
Get the PTS value for the current buffer position.
Audio stream reassembly buffer.
AVPacket * PopAvPacket() override
Pop an audio AVPacket from the reassembly buffer.
static constexpr int MAX_HEADER_SIZE
AVCodecID TruncateBufferUntilFirstValidData()
Truncate buffer until the first valid audio frame.
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.
SyncWordInfo FindTwoConsecutiveFramesWithSameSyncWord()
Find two consecutive audio frames with the same sync word.
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.
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
bool ParseCodecHeader(const uint8_t *, int)
Parse video codec header to detect codec type.
AVPacket * PopAvPacket() override
Base class for stream reassembly buffers.
AVCodecID m_codec
detected codec ID
virtual AVPacket * PopAvPacket()=0
int64_t m_lastPoppedPts
PTS of the last popped AVPacket.
virtual void Push(const uint8_t *data, int size, int64_t pts)
cPtsTrackingBuffer m_buffer
fragmentation buffer
cReassemblyBuffer(const char *identifier)
void Reset()
Reset the reassembly buffer.
Information about a detected audio sync word.
AVCodecID codecId
Detected codec ID.
int pos
Position of sync word in buffer.