#[non_exhaustive]pub enum MessageHeader {
Type0 {
timestamp: u32,
message_length: u32,
message_type_id: u8,
message_stream_id: u32,
},
Type1 {
timestamp_delta: u32,
message_length: u32,
message_type_id: u8,
},
Type2 {
timestamp_delta: u32,
},
Type3,
}Expand description
Chunk Message Header: one of 4 formats selected by Fmt (§5.3.1.2),
carrying decreasing field sets — each format after Type 0 inherits the
fields it omits from the preceding chunk on the same chunk stream.
Reassembling that “preceding chunk” state (so Type 1/2/3 headers can be
resolved to absolute values) is a stateful job for the chunk-stream
reassembler (#738 Task 4), not this header type. In particular, a Type 3
header carrying zero bytes here does not by itself tell you whether an
Extended Timestamp follows it on the wire: per §5.3.1.3, a Type 3 chunk
carries the 4-byte Extended Timestamp when — and only when — the most
recent Type 0/1/2 chunk on the same csid itself used one. Deciding that
requires exactly that per-csid state, so MessageHeader::parse never
consumes an Extended Timestamp for Fmt::Type3; the reassembler must
apply this rule itself once it is tracking that state.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Type0
Type 0 (§5.3.1.2.1, 11 bytes on the wire before any Extended Timestamp). MUST be used at the start of a chunk stream and whenever the stream timestamp goes backward.
Fields
Type1
Type 1 (§5.3.1.2.2, 7 bytes before any Extended Timestamp). No message stream id — inherits the preceding chunk’s.
Fields
Type2
Type 2 (§5.3.1.2.3, 3 bytes before any Extended Timestamp). Neither stream id nor message length included — both inherited.
Fields
Type3
Type 3 (§5.3.1.2.4, 0 bytes). Stream id, message length, message type id, and timestamp delta are all inherited from the preceding chunk on the same csid.
Implementations§
Source§impl MessageHeader
impl MessageHeader
Sourcepub fn parse(fmt: Fmt, bytes: &[u8]) -> Result<(Self, usize), RtmpError>
pub fn parse(fmt: Fmt, bytes: &[u8]) -> Result<(Self, usize), RtmpError>
Parse the message header that follows a BasicHeader carrying
fmt. Returns the parsed variant and the number of bytes consumed
from bytes — the fixed per-fmt header length, plus 4 more if a
Type 0/1/2 field’s 24-bit value read exactly EXTENDED_TIMESTAMP_MARKER
(in which case the real, unresolved value is read from the following
4-byte big-endian Extended Timestamp — see §5.3.1.3).
§Errors
RtmpError::BufferTooShort if bytes does not hold the full fixed
header (and, when signalled, the Extended Timestamp).
Trait Implementations§
Source§impl Clone for MessageHeader
impl Clone for MessageHeader
Source§fn clone(&self) -> MessageHeader
fn clone(&self) -> MessageHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MessageHeader
Source§impl Debug for MessageHeader
impl Debug for MessageHeader
impl Eq for MessageHeader
Source§impl PartialEq for MessageHeader
impl PartialEq for MessageHeader
Source§impl Serialize for MessageHeader
impl Serialize for MessageHeader
Source§type Error = RtmpError
type Error = RtmpError
Parse impl, but need not be).Source§fn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
serialize_into will write.