xref: /xiu/protocol/rtmp/src/messages/define.rs (revision 85c0af6a)
1 use {crate::amf0::define::Amf0ValueType, bytes::BytesMut};
2 
3 #[allow(dead_code)]
4 pub struct SetPeerBandwidthProperties {
5     pub window_size: u32,
6     limit_type: u8,
7 }
8 
9 impl SetPeerBandwidthProperties {
new(window_size: u32, limit_type: u8) -> Self10     pub fn new(window_size: u32, limit_type: u8) -> Self {
11         Self {
12             window_size,
13             limit_type,
14         }
15     }
16 }
17 pub enum RtmpMessageData {
18     Amf0Command {
19         command_name: Amf0ValueType,
20         transaction_id: Amf0ValueType,
21         command_object: Amf0ValueType,
22         others: Vec<Amf0ValueType>,
23     },
24     AmfData {
25         raw_data: BytesMut,
26         // values: Vec<Amf0ValueType>,
27     },
28     SetChunkSize {
29         chunk_size: u32,
30     },
31     AbortMessage {
32         chunk_stream_id: u32,
33     },
34     Acknowledgement {
35         sequence_number: u32,
36     },
37     WindowAcknowledgementSize {
38         size: u32,
39     },
40     SetPeerBandwidth {
41         properties: SetPeerBandwidthProperties,
42     },
43     AudioData {
44         data: BytesMut,
45     },
46     VideoData {
47         data: BytesMut,
48     },
49     SetBufferLength {
50         stream_id: u32,
51         buffer_length: u32,
52     },
53     StreamBegin {
54         stream_id: u32,
55     },
56     StreamIsRecorded {
57         stream_id: u32,
58     },
59 
60     Unknow,
61 }
62 
63 pub mod msg_type_id {
64     pub const AUDIO: u8 = 8;
65     pub const VIDEO: u8 = 9;
66 
67     pub const SET_CHUNK_SIZE: u8 = 1;
68     pub const ABORT: u8 = 2;
69     pub const ACKNOWLEDGEMENT: u8 = 3;
70     pub const USER_CONTROL_EVENT: u8 = 4;
71     pub const WIN_ACKNOWLEDGEMENT_SIZE: u8 = 5;
72     pub const SET_PEER_BANDWIDTH: u8 = 6;
73 
74     pub const COMMAND_AMF3: u8 = 17;
75     pub const COMMAND_AMF0: u8 = 20;
76 
77     pub const DATA_AMF3: u8 = 15;
78     pub const DATA_AMF0: u8 = 18;
79 
80     pub const SHARED_OBJ_AMF3: u8 = 16;
81     pub const SHARED_OBJ_AMF0: u8 = 19;
82 
83     pub const AGGREGATE: u8 = 22;
84 }
85