Skip to main content

Module amf0

Module amf0 

Source
Expand description

AMF0 (Action Message Format 0) value encoding/decoding, used by RTMP command and data messages.

See docs/rtmp.md §8 (AMF0) for the full transcription of [AMF0] (the companion spec this doc cites): §8.1 for the type marker table, §8.2 for the wire encoding of each data type needed by RTMP command messages.

RTMP does not wrap command/data message bodies in AMF0’s own amf-packet framing — a message body is simply a sequence of AMF0 value-types (marker + body) concatenated one after another (§8.2). This module implements that sequence-of-values contract via Amf0Value (single value parse/serialize) and Command (the name + transaction_id + arguments sequence carried by Command Messages, §7.1.1).

§Scope

Implements the markers actually needed to decode/encode the ingest command set (connect/createStream/publish/_result/onStatus/…): Number, Boolean, String, Object, Null, Undefined, ECMA Array, Strict Array, plus Date and Long String (trivial once String/Number exist).

Out of scope, and rejected as RtmpError::Unsupported rather than panicking or silently misparsing: movieclip-marker (0x04, reserved), reference-marker (0x07), unsupported-marker (0x0D), recordset-marker (0x0E, reserved), xml-document-marker (0x0F), typed-object-marker (0x10), and avmplus-object-marker (0x11, the AMF3 switch — AMF3 itself, [AMF3], is a separate spec and explicitly out of scope for this ingest engine per docs/rtmp.md §8.3).

Amf0Value is a data-carrying ADT (like Fmt/MessageHeader’s payload variants), not a closed label enum, so it is a #204 label_coverage SKIP-list candidate rather than a name()/impl_spec_display! target (tracked for the crate’s Task 10 label-coverage pass).

Modules§

marker
AMF0 type markers ([AMF0] §2.1, docs/rtmp.md §8.1) — 1 byte.

Structs§

Command
An RTMP Command Message body (§7.1.1): name (AMF0 String) + AMF0 transaction_id (AMF0 Number) + zero or more argument values (typically a Command Object, then optional trailing arguments) — see docs/rtmp.md §8.2’s closing note and §6.1 (Command Message).

Enums§

Amf0Value
A single AMF0 value ([AMF0] §2, docs/rtmp.md §8.2).

Constants§

MAX_AMF0_DEPTH
Maximum AMF0 container nesting depth (Object/ECMA Array/Strict Array) Amf0Value::parse will descend into. Bounds recursion so a pathologically nested input returns RtmpError::Unsupported instead of overflowing the native call stack — the guard is checked on entering each nested container, so recursion never actually reaches an attacker-chosen depth, only this constant.