1 use serde::Serialize; 2 use std::cmp::Eq; 3 use std::fmt; 4 5 pub const WINDOW_ACKNOWLEDGEMENT_SIZE: u32 = 4096; 6 pub const PEER_BANDWIDTH: u32 = 4096; 7 8 pub mod peer_bandwidth_limit_type { 9 pub const HARD: u8 = 0; 10 pub const SOFT: u8 = 1; 11 pub const DYNAMIC: u8 = 2; 12 } 13 14 pub const FMSVER: &str = "FMS/3,0,1,123"; 15 pub const CAPABILITIES: f64 = 31.0; 16 pub const LEVEL: &str = "status"; 17 18 pub const OBJENCODING_AMF0: f64 = 0.0; 19 pub const OBJENCODING_AMF3: f64 = 3.0; 20 21 pub const STREAM_ID: f64 = 1.0; 22 23 pub const TRANSACTION_ID_CONNECT: u8 = 1; 24 pub const TRANSACTION_ID_CREATE_STREAM: u8 = 2; 25 26 //pub mod 27 pub const RTMP_LEVEL_WARNING: &str = "warning"; 28 pub const RTMP_LEVEL_STATUS: &str = "status"; 29 pub const RTMP_LEVEL_ERROR: &str = "error\n"; 30 //session subscribe type 31 #[derive(Debug, Serialize, Clone, Eq, PartialEq)] 32 pub enum SubscribeType { 33 /* Remote client request playing rtmp stream.*/ 34 PlayerRtmp, 35 /* Remote client request playing http-flv stream.*/ 36 PlayerHttpFlv, 37 /* Remote client request playing hls stream.*/ 38 PlayerHls, 39 GenerateHls, 40 /* Local client *subscribe* from local rtmp session 41 and *publish* (relay push) the stream to remote server.*/ 42 PublisherRtmp, 43 } 44 45 //session publish type 46 #[derive(Debug, Serialize, Clone, Eq, PartialEq)] 47 pub enum PublishType { 48 /* Receive rtmp stream from remote push client */ 49 PushRtmp, 50 /* Local client *publish* the rtmp stream to local session, 51 the rtmp stream is *subscribed* (pull) from remote server.*/ 52 SubscriberRtmp, 53 } 54 55 pub enum SessionType { 56 Client, 57 Server, 58 } 59 60 impl fmt::Display for SessionType { 61 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 62 let client_type = match self { 63 SessionType::Client => String::from("client"), 64 SessionType::Server => String::from("server"), 65 }; 66 write!(f, "{client_type}") 67 } 68 } 69