webrtc_rtp_av1 (webrtc v0.1.0)

View Source

AV1 RTP payload format (AOMedia "RTP Payload Format for AV1" v1.0.0 §4.4 to §4.5): aggregation header, key frame detection, depacketization, packetization and the frame size of a sequence header.

The aggregation header is Z Y W(2) N followed by three reserved bits. N = 1 marks the first packet of a coded video sequence, which starts with a key frame and a sequence header; it is the signal used here for key frame detection.

depacketize/1 joins the OBU elements of a temporal unit's payloads, fragments included, into the low overhead bitstream format (AV1 §5.2): a temporal delimiter, then every OBU with its size field. packetize/3 does the reverse, dropping temporal delimiters and tile lists as §5 asks.

Summary

Functions

Parse the aggregation header. continuation (Z): the first OBU element continues one from the previous packet; continues (Y): the last OBU element continues in the next packet; obu_count (W): the number of OBU elements, 0 when each element carries a length field.

The temporal unit carried by the payloads of one frame, in order. An element that continues a missing one, or a last element left unfinished, fails the frame.

Maximum frame width and height from the sequence header of a temporal unit (AV1 §5.5): the frame size when frames do not override it.

The OBUs of a low overhead bitstream, as {Type, Payload}.

Split a temporal unit in the low overhead bitstream format into payloads of at most Mtu bytes. Every OBU element has a length field (W = 0) and no size field of its own; elements longer than a packet continue in the next one (Y, then Z). new_sequence: the unit starts a coded video sequence (N = 1 on the first payload). The caller sets the RTP marker bit on the last payload.

The frame size of a sequence header among the whole OBU elements of one payload.

Types

aggregation_header/0

-type aggregation_header() ::
          #{continuation := boolean(),
            continues := boolean(),
            obu_count := 0..3,
            new_sequence := boolean()}.

Functions

aggregation_header(_)

-spec aggregation_header(binary()) -> {ok, aggregation_header()} | {error, truncated}.

Parse the aggregation header. continuation (Z): the first OBU element continues one from the previous packet; continues (Y): the last OBU element continues in the next packet; obu_count (W): the number of OBU elements, 0 when each element carries a length field.

depacketize(Payloads)

-spec depacketize([binary()]) -> {ok, binary()} | {error, term()}.

The temporal unit carried by the payloads of one frame, in order. An element that continues a missing one, or a last element left unfinished, fails the frame.

frame_size(Tu)

-spec frame_size(binary()) -> {ok, {pos_integer(), pos_integer()}} | error.

Maximum frame width and height from the sequence header of a temporal unit (AV1 §5.5): the frame size when frames do not override it.

is_keyframe(Payload)

-spec is_keyframe(binary()) -> boolean().

obus(Bin)

-spec obus(binary()) -> {ok, [{0..15, binary()}]} | {error, term()}.

The OBUs of a low overhead bitstream, as {Type, Payload}.

packetize(Tu, Mtu, Opts)

-spec packetize(binary(), pos_integer(), #{new_sequence => boolean()}) -> [binary()].

Split a temporal unit in the low overhead bitstream format into payloads of at most Mtu bytes. Every OBU element has a length field (W = 0) and no size field of its own; elements longer than a packet continue in the next one (Y, then Z). new_sequence: the unit starts a coded video sequence (N = 1 on the first payload). The caller sets the RTP marker bit on the last payload.

payload_size(_)

-spec payload_size(binary()) -> {ok, {pos_integer(), pos_integer()}} | error.

The frame size of a sequence header among the whole OBU elements of one payload.