From 3b59cf7d8d2310cd8875cd1d47b686605c79237c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 25 Sep 2020 19:29:54 +0300 Subject: [PATCH] Add server-side latency configuration to the publisher --- common/src/publisher.rs | 1 + publisher/src/config.rs | 4 ++++ publisher/src/publisher.rs | 1 + server/src/publisher.rs | 14 +++++++++++--- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/common/src/publisher.rs b/common/src/publisher.rs index 66ed47f..8349049 100644 --- a/common/src/publisher.rs +++ b/common/src/publisher.rs @@ -11,6 +11,7 @@ pub enum PublisherMessage { CreateRoom { name: String, description: Option, + latency: Option, }, Ice { candidate: String, diff --git a/publisher/src/config.rs b/publisher/src/config.rs index 36b5649..2b8078b 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 34ab70c..5714c4d 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 05e75a1..447ee7c 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, text: &str) { match serde_json::from_str::(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 { -- GitLab