xref: /xiu/protocol/rtmp/src/chunk/chunk.rs (revision 0ca99c20)
1 // use bytes::BytesMut;
2 
3 // //5.3.1.1
4 // #[derive(Eq, PartialEq, Debug, Clone)]
5 // pub struct ChunkBasicHeader {
6 //     pub format: u8,
7 //     pub chunk_stream_id: u32,
8 // }
9 
10 // impl ChunkBasicHeader {
11 //     pub fn new(fmt: u8, csid: u32) -> ChunkBasicHeader {
12 //         ChunkBasicHeader {
13 //             format: fmt,
14 //             chunk_stream_id: csid,
15 //         }
16 //     }
17 // }
18 
19 // //5.3.1.2
20 // #[derive(Eq, PartialEq, Debug, Clone)]
21 // pub struct ChunkMessageHeader {
22 //     pub timestamp: u32,
23 //     pub msg_length: u32,
24 //     pub msg_type_id: u8,
25 //     pub msg_streamd_id: u32,
26 //     pub timestamp_delta: u32,
27 //     pub is_extended_timestamp: bool,
28 // }
29 
30 // impl ChunkMessageHeader {
31 //     pub fn new(timestamp: u32, msg_length: u32, msg_type_id: u8, msg_stream_id: u32) -> Self {
32 //         Self {
33 //             timestamp,
34 //             msg_length,
35 //             msg_type_id,
36 //             msg_streamd_id: msg_stream_id,
37 //             timestamp_delta: 0,
38 //             is_extended_timestamp: false,
39 //         }
40 //     }
41 // }
42 
43 // pub struct ChunkHeader {
44 //     pub basic_header: ChunkBasicHeader,
45 //     pub message_header: ChunkMessageHeader,
46 // }
47 
48 // impl Default for ChunkHeader {
49 //     fn default() -> Self {
50 //         Self::new()
51 //     }
52 // }
53 
54 // impl ChunkHeader {
55 //     pub fn new() -> ChunkHeader {
56 //         ChunkHeader {
57 //             basic_header: ChunkBasicHeader::new(0, 0),
58 //             message_header: ChunkMessageHeader::new(0, 0, 0, 0),
59 //         }
60 //     }
61 // }
62 
63 // // pub struct Chunk {
64 // //     basic_header: ChunkBasicHeader,
65 // //     message_header: ChunkMessageHeader,
66 // //     raw_data: BytesMut,
67 // // }
68 
69 // #[derive(Eq, PartialEq, Debug, Clone)]
70 // pub struct ChunkInfo {
71 //     pub basic_header: ChunkBasicHeader,
72 //     pub message_header: ChunkMessageHeader,
73 //     pub payload: BytesMut,
74 // }
75 
76 // impl Default for ChunkInfo {
77 //     fn default() -> Self {
78 //         Self::new(0, 0, 0, 0, 0, 0, BytesMut::new())
79 //     }
80 // }
81 
82 // impl ChunkInfo {
83 //     pub fn new(
84 //         csid: u32,
85 //         format: u8,
86 //         timestamp: u32,
87 //         msg_length: u32,
88 //         msg_type_id: u8,
89 //         msg_stream_id: u32,
90 //         payload: BytesMut,
91 //     ) -> Self {
92 //         Self {
93 //             basic_header: ChunkBasicHeader::new(format, csid),
94 //             message_header: ChunkMessageHeader::new(
95 //                 timestamp,
96 //                 msg_length,
97 //                 msg_type_id,
98 //                 msg_stream_id,
99 //             ),
100 //             payload,
101 //         }
102 //     }
103 // }
104 
105 // // impl Chunk {
106 // //     pub fn chunk_read(&mut self, bytes: &[u8]) -> Result {
107 // //         self.buffer.extend_from_slice(bytes);
108 // //     }
109 
110 // //     pub fn read_basic_header(&mut self, bytes: &[u8]) -> Result<UnpackResult, ChunkUnpackError> {
111 // //         if self.buffer.len() < 1 {
112 // //             return Ok(UnpackResult::NotEnoughBytes);
113 // //         }
114 // //     }
115 // // }
116