|
vdr-plugin-softhddevice-drm-gles 1.4.0
|
Audio stream reassembly buffer. More...
#include <pes.h>

Public Member Functions | |
| cReassemblyBufferAudio () | |
| AVPacket * | PopAvPacket () override |
| Pop an audio AVPacket from the reassembly buffer. More... | |
| AVCodecID | TruncateBufferUntilFirstValidData () |
| Truncate buffer until the first valid audio frame. More... | |
| SyncWordInfo | FindSyncWord (const uint8_t *, int) |
| Find the first audio sync word in data. More... | |
| AVCodecID | DetectCodecFromSyncWord (const uint8_t *, int) |
| Detect audio codec from sync word pattern. More... | |
| int | GetFrameSizeForCodec (AVCodecID, const uint8_t *) |
| Get the frame size for a given codec and frame header. More... | |
Public Member Functions inherited from cReassemblyBuffer | |
| virtual void | Push (const uint8_t *data, int size, int64_t pts) |
| virtual AVPacket * | PopAvPacket ()=0 |
| bool | IsEmpty () |
| size_t | GetSize () |
| void | Reset () |
| Reset the reassembly buffer. More... | |
| AVCodecID | GetCodec () |
Private Member Functions | |
| SyncWordInfo | FindTwoConsecutiveFramesWithSameSyncWord () |
| Find two consecutive audio frames with the same sync word. More... | |
Private Attributes | |
| bool | m_ptsInvalid = false |
| flag indicating if PTS is invalid for current buffer, because it was truncated More... | |
Static Private Attributes | |
| static constexpr int | MAX_HEADER_SIZE = 6 |
Additional Inherited Members | |
Protected Member Functions inherited from cReassemblyBuffer | |
| cReassemblyBuffer (const char *identifier) | |
| AVPacket * | PopAvPacket (int) |
| Pop an AVPacket from the reassembly buffer. More... | |
Protected Attributes inherited from cReassemblyBuffer | |
| AVCodecID | m_codec = AV_CODEC_ID_NONE |
| detected codec ID More... | |
| cPtsTrackingBuffer | m_buffer |
| fragmentation buffer More... | |
| int64_t | m_lastPoppedPts = AV_NOPTS_VALUE |
| PTS of the last popped AVPacket. More... | |
Audio stream reassembly buffer.
Reassembles audio elementary streams by detecting sync words and validating frame headers. Supports MP2, AAC (LATM/ADTS), AC3, and E-AC3 codecs.
| AVCodecID cReassemblyBufferAudio::DetectCodecFromSyncWord | ( | const uint8_t * | syncWord, |
| int | size | ||
| ) |
Detect audio codec from sync word pattern.
Checks if the data starts with a valid sync word for any supported audio codec. Uses the AudioCodecMap to test sync word patterns for MP2, AAC LATM, AAC ADTS, AC3, and E-AC3.
| syncWord | Pointer to potential sync word data |
| size | Size of available data |
Definition at line 595 of file pes.cpp.
References AudioCodecMap.
Referenced by FindSyncWord(), FindTwoConsecutiveFramesWithSameSyncWord(), and TEST_CASE().
| SyncWordInfo cReassemblyBufferAudio::FindSyncWord | ( | const uint8_t * | data, |
| int | size | ||
| ) |
Find the first audio sync word in data.
Scans the data byte-by-byte looking for any recognized audio sync word pattern. Checks all supported audio codecs (MP2, AAC LATM, AAC ADTS, AC3, E-AC3).
| data | Pointer to audio data |
| size | Size of the data in bytes |
Definition at line 573 of file pes.cpp.
References DetectCodecFromSyncWord().
Referenced by FindTwoConsecutiveFramesWithSameSyncWord(), and TEST_CASE().
|
private |
Find two consecutive audio frames with the same sync word.
Searches the buffer for a valid audio frame followed immediately by another frame of the same codec. This validates that the sync word and frame header are genuine and not false positives in random data.
The function modifies the buffer internally by erasing false positives as it searches. When no sync word is found, it keeps the last MAX_HEADER_SIZE bytes.
Definition at line 526 of file pes.cpp.
References AudioCodecMap, SyncWordInfo::codecId, DetectCodecFromSyncWord(), cPtsTrackingBuffer::Erase(), FindSyncWord(), cPtsTrackingBuffer::GetSize(), cReassemblyBuffer::m_buffer, MAX_HEADER_SIZE, cPtsTrackingBuffer::Peek(), and SyncWordInfo::pos.
Referenced by TruncateBufferUntilFirstValidData().
| int cReassemblyBufferAudio::GetFrameSizeForCodec | ( | AVCodecID | codec, |
| const uint8_t * | data | ||
| ) |
Get the frame size for a given codec and frame header.
Calculates the frame size by parsing the codec-specific frame header. Only used for testing purposes to expose the AudioCodecMap frame size calculation.
| codec | The audio codec ID |
| data | Pointer to the frame header data |
| std::out_of_range | if codec is not in AudioCodecMap |
| std::invalid_argument | if frame header is invalid |
Definition at line 619 of file pes.cpp.
References AudioCodecMap.
Referenced by TEST_CASE().
|
overridevirtual |
Pop an audio AVPacket from the reassembly buffer.
Truncates the buffer to the first valid audio frame, detects the codec, and pops a complete audio frame as an AVPacket.
Implements cReassemblyBuffer.
Definition at line 461 of file pes.cpp.
References AudioCodecMap, AV_NOPTS_VALUE, LOGERROR, LOGWARNING, cReassemblyBuffer::m_buffer, cReassemblyBuffer::m_codec, m_ptsInvalid, cPtsTrackingBuffer::Peek(), cReassemblyBuffer::PopAvPacket(), and TruncateBufferUntilFirstValidData().
Referenced by cSoftHdDevice::PlayAudio().
| AVCodecID cReassemblyBufferAudio::TruncateBufferUntilFirstValidData | ( | ) |
Truncate buffer until the first valid audio frame.
Searches for two consecutive audio frames with the same sync word to validate the frame header, then erases all data before the first valid frame. This removes garbage data and synchronizes to the audio stream.
Definition at line 499 of file pes.cpp.
References SyncWordInfo::codecId, cPtsTrackingBuffer::Erase(), FindTwoConsecutiveFramesWithSameSyncWord(), cPtsTrackingBuffer::GetSize(), LOGDEBUG, cReassemblyBuffer::m_buffer, m_ptsInvalid, and SyncWordInfo::pos.
Referenced by PopAvPacket(), and TEST_CASE().
|
private |
flag indicating if PTS is invalid for current buffer, because it was truncated
Definition at line 183 of file pes.h.
Referenced by PopAvPacket(), and TruncateBufferUntilFirstValidData().
|
staticconstexprprivate |
Definition at line 182 of file pes.h.
Referenced by FindTwoConsecutiveFramesWithSameSyncWord().