Expand description
RTMP chunk stream codec
RTMP messages are split into chunks for multiplexing. Each chunk has a header that identifies the chunk stream and message being sent.
Chunk Format:
+-------------+----------------+-------------------+
| Basic Header| Message Header | Chunk Data |
| (1-3 bytes) | (0,3,7,11 bytes)| (variable) |
+-------------+----------------+-------------------+
Basic Header formats:
- 1 byte: fmt(2) + csid(6) for csid 2-63
- 2 bytes: fmt(2) + 0 + csid(8) for csid 64-319
- 3 bytes: fmt(2) + 1 + csid(16) for csid 64-65599
Message Header formats (based on fmt):
- Type 0 (11 bytes): timestamp(3) + length(3) + type(1) + stream_id(4)
- Type 1 (7 bytes): timestamp_delta(3) + length(3) + type(1)
- Type 2 (3 bytes): timestamp_delta(3)
- Type 3 (0 bytes): (use previous chunk's values)
Extended timestamp (4 bytes) is appended when timestamp >= 0xFFFFFFReference: RTMP Specification Section 5.3
Structsยง
- Chunk
Decoder - Chunk stream decoder
- Chunk
Encoder - Chunk stream encoder
- Rtmp
Chunk - A complete RTMP message (reassembled from chunks)