Commit 3b59cf7d authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

Add server-side latency configuration to the publisher

parent ea4e60f8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ pub enum PublisherMessage {
    CreateRoom {
        name: String,
        description: Option<String>,
        latency: Option<u32>,
    },
    Ice {
        candidate: String,
+4 −0
Original line number Diff line number Diff line
@@ -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,
}
+1 −0
Original line number Diff line number Diff line
@@ -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"),
        ))
+11 −3
Original line number Diff line number Diff line
@@ -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 {