Skip to content

RtpH264

Source: RtpH264.h

Packetiser

class Packetiser
src/light/util/RtpH264.h:52

Packetises one access unit into caller-owned datagram buffers, reporting each as it is written.

Public Methods

inline Packetiser(uint32_t ssrc, uint16_t firstSeq) : ssrc identifies this stream for the session's life, and the sequence continues across frames.

inline size_t writeAccessUnit(const uint8_t * annexB, size_t len, uint32_t pts90, uint8_t * scratch, size_t scratchLen, Sink sink, void * ctx) : Packetise one access unit, whose NALs are Annex B framed. Returns the packets written, or 0 where the sink refused: a refused packet abandons the frame rather than sending it torn.

inline uint16_t nextSequence() const : The sequence number the next packet carries, which a session reports in its RTP-Info.

Public Types

using Sink = bool()(void ctx, const uint8_t *packet, size_t len) : Where each datagram is written: the callee sends it before the next call overwrites nothing, since the buffer is the caller's.

More info

One NAL is one packet while it fits

A NAL under the MTU rides alone, its own header byte becoming the packet's first payload byte. An oversized NAL splits into FU-A fragments carrying a two-byte indicator and header, the first setting S and the last E, every one repeating the original's type and reference bits. A decoder reassembles from those alone, so a lost fragment costs one frame rather than the stream.

The marker bit ends an access unit

Set on the last packet of a frame and clear on every other, so a decoder knows a frame is whole without waiting for the next timestamp to change. Every packet of one frame carries the SAME timestamp, a timestamp naming the moment a frame is displayed rather than sent.