workspace reshape
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#[derive(Default, Debug)]
|
||||
pub struct RtmpSession {
|
||||
client: RtmpClient,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct RtmpClient {
|
||||
version: u8,
|
||||
timestamp: u32,
|
||||
magic_bytes: [u8; 1536],
|
||||
}
|
||||
|
||||
impl Default for RtmpClient {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
magic_bytes: [0; 1536],
|
||||
version: 0,
|
||||
timestamp: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RtmpSession {
|
||||
pub fn consume_handshake(&mut self, bytes: &[u8]) -> Result<(), ()> {
|
||||
let version = bytes[0];
|
||||
let timestamp = u32::from_be_bytes(bytes[1..5].try_into().unwrap());
|
||||
let mut random: [u8; 1536] = [0; 1536];
|
||||
random.copy_from_slice(&bytes[1..1537]);
|
||||
|
||||
println!("size of rand: {}", random.len());
|
||||
|
||||
let client = RtmpClient {
|
||||
version,
|
||||
timestamp,
|
||||
magic_bytes: random,
|
||||
};
|
||||
|
||||
self.client = client;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
pub fn response(&self) -> [u8; 1537] {
|
||||
let mut reply: [u8; 1537] = [0; 1537];
|
||||
reply[0] = 3;
|
||||
// reply[1..1537].copy_from_slice(&self.client.magic_bytes);
|
||||
let mut rand: [u8; 1536] = [0; 1536];
|
||||
rand.fill(1);
|
||||
reply[1..1537].copy_from_slice(&rand);
|
||||
|
||||
reply
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user