Skip to content

MpegTs

Source: MpegTs.h

Continuity

struct Continuity
src/light/util/MpegTs.h:23

The continuity counters, which belong to the STREAM rather than to any one write.

MPEG-TS requires each PID's counter to advance by one per packet without interruption, across frames and across segment boundaries alike. A player treats any gap as lost packets. The caller keeps one of these for the whole stream and hands it to every Writer.

Public Attributes

uint8_t pat = 0

uint8_t pmt = 0

uint8_t video = 0 : the continuity counter each stream carries

Writer

class Writer
src/light/util/MpegTs.h:29

Writes packets into a caller-owned buffer, reporting overflow rather than growing.

A segment buffer is a fixed PSRAM slot on the P4, and a muxer that allocates would be the one thing in the hot path doing so.

Public Methods

inline Writer(uint8_t * dst, size_t cap, Continuity & cc) : cc must outlive the Writer and be the SAME object for every write in a stream.

inline size_t size() const : Bytes written so far.

inline bool overflowed() const : Did any write not fit? Once true the output is incomplete and must be discarded.

inline void writeTables() : Start a segment.

inline void writeAccessUnit(const uint8_t * au, size_t len, uint32_t pts90, bool keyframe) : Write one access unit (the NALs of a single frame, Annex-B start codes included) as a PES packet split across as many TS packets as it needs.