diff --git a/common/src/publisher.rs b/common/src/publisher.rs index 66ed47f1c6eba215662f41ef183df99a412a3040..8349049e81adbd111c9538d6f1f936a7ccf96497 100644 --- a/common/src/publisher.rs +++ b/common/src/publisher.rs @@ -11,6 +11,7 @@ pub enum PublisherMessage { CreateRoom { name: String, description: Option<String>, + latency: Option<u32>, }, Ice { candidate: String, diff --git a/publisher/src/config.rs b/publisher/src/config.rs index 36b564938cb73e0b773a388e7ab34ea6d18447be..2b8078b9a1b57983b31ddac65d602063b573aa32 100644 --- a/publisher/src/config.rs +++ b/publisher/src/config.rs @@ -72,4 +72,8 @@ pub struct Config { /// Channel configuration to use, can be mono or stereo. #[structopt(long, default_value = "mono")] pub channel_configuration: ChannelConfiguration, + + /// Server-side latency. + #[structopt(long, default_value = "200")] + pub server_latency: u32, } diff --git a/publisher/src/publisher.rs b/publisher/src/publisher.rs index 34ab70c4d2457b463d797e5c4781c973b128b704..5714c4dd524d7594ae1890a8fc692dec8820022c 100644 --- a/publisher/src/publisher.rs +++ b/publisher/src/publisher.rs @@ -341,6 +341,7 @@ impl Publisher { serde_json::to_string(&PublisherMessage::CreateRoom { name: cfg.server_room.clone(), description: cfg.server_room_description.clone(), + latency: Some(cfg.server_latency), }) .expect("Failed to serialize create room message"), )) diff --git a/server/src/publisher.rs b/server/src/publisher.rs index 05e75a1329011934b71b9934cf98639dd6eae4a3..447ee7c883a33823a8fa768e97fd63eb221458c1 100644 --- a/server/src/publisher.rs +++ b/server/src/publisher.rs @@ -275,12 +275,20 @@ impl Publisher { /// Handle JSON messages from the publisher. fn handle_message(&mut self, ctx: &mut ws::WebsocketContext<Self>, text: &str) { match serde_json::from_str::<PublisherMessage>(text) { - Ok(PublisherMessage::CreateRoom { name, description }) => { + Ok(PublisherMessage::CreateRoom { + name, + description, + latency, + }) => { debug!( - "Publisher {} asked to create new room {} with description {:?}", - self.remote_addr, name, description + "Publisher {} asked to create new room {} with description {:?} and latency {:?}", + self.remote_addr, name, description, latency, ); + self.webrtcbin + .set_property("latency", &latency.unwrap_or(200)) + .expect("Failed to set latency property"); + // Check if we can join a room currently. { match &self.room_state {