scuffle_rtmp/protocol_control_messages/
mod.rs

1//! Protocol control messages as defined in 5.4.
2
3pub mod reader;
4pub mod writer;
5
6/// Used to notify the peer of a new maximum chunk size.
7///
8/// Defined by:
9/// - Legacy RTMP spec, 5.4.1. Set Chunk Size (1)
10#[derive(Debug)]
11pub struct ProtocolControlMessageSetChunkSize {
12    /// > This field holds the new maximum chunk size,
13    /// > in bytes, which will be used for all of the sender's subsequent
14    /// > chunks until further notice. Valid sizes are `1` to `2147483647`
15    /// > (`0x7FFFFFFF`) inclusive; however, all sizes greater than `16777215`
16    /// > (`0xFFFFFF`) are equivalent since no chunk is larger than one
17    /// > message, and no message is larger than `16777215` bytes.
18    pub chunk_size: u32,
19}
20
21// Not implemented: 5.4.2. Abort Message (2)
22
23/// Acknowledges the receipt of data.
24///
25/// Defined by:
26/// - Legacy RTMP spec, 5.4.3. Acknowledgement (3)
27#[derive(Debug)]
28pub struct ProtocolControlMessageAcknowledgement {
29    /// This field holds the number of bytes received so far.
30    pub sequence_number: u32,
31}
32
33/// The client or the server sends this message to inform the peer of the
34/// window size to use between sending acknowledgments.
35///
36/// Defined by:
37/// - Legacy RTMP spec, 5.4.4. Window Acknowledgement Size (5)
38#[derive(Debug)]
39pub struct ProtocolControlMessageWindowAcknowledgementSize {
40    /// The new window size to use.
41    pub acknowledgement_window_size: u32,
42}
43
44/// > The client or the server sends this message to limit the output bandwidth of its peer.
45/// > The peer receiving this message limits its
46/// > output bandwidth by limiting the amount of sent but unacknowledged
47/// > data to the window size indicated in this message.
48///
49/// Defined by:
50/// - Legacy RTMP spec, 5.4.5. Set Peer Bandwidth (6)
51#[derive(Debug)]
52pub struct ProtocolControlMessageSetPeerBandwidth {
53    /// The window size to limit the output bandwidth to.
54    pub acknowledgement_window_size: u32,
55    /// The limit type.
56    pub limit_type: ProtocolControlMessageSetPeerBandwidthLimitType,
57}
58
59/// The limit type for [`ProtocolControlMessageSetPeerBandwidth`].
60///
61/// Defined by:
62/// - Legacy RTMP spec, 5.4.5. Set Peer Bandwidth (6) Limit Type
63#[derive(Debug, PartialEq, Eq, Clone, Copy, num_derive::FromPrimitive)]
64#[repr(u8)]
65pub enum ProtocolControlMessageSetPeerBandwidthLimitType {
66    /// > The peer SHOULD limit its output bandwidth to the indicated window size.
67    Hard = 0,
68    /// > The peer SHOULD limit its output bandwidth to the the
69    /// > window indicated in this message or the limit already in effect,
70    /// > whichever is smaller.
71    Soft = 1,
72    /// > If the previous Limit Type was Hard, treat this message
73    /// > as though it was marked Hard, otherwise ignore this message.
74    Dynamic = 2,
75}