From 0040d2015144469a1a7b7e930ad1f6b3635c1484 Mon Sep 17 00:00:00 2001 From: linkmauve Date: Mon, 11 Oct 2021 16:36:10 +0200 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20include=20region=20elements=20w?= =?UTF-8?q?hen=20empty=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In small deployments, for instance when there is only one server for all participants, the region doesn’t mean anything so we can remove the elements instead of sending an empty value. --- gst-meet/src/main.rs | 4 ++-- lib-gst-meet-c/src/lib.rs | 11 ++++++++--- lib-gst-meet/src/conference.rs | 18 +++++++++++------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/gst-meet/src/main.rs b/gst-meet/src/main.rs index 1bcc96e..832c379 100644 --- a/gst-meet/src/main.rs +++ b/gst-meet/src/main.rs @@ -36,8 +36,8 @@ struct Opt { video_codec: String, #[structopt(long, default_value = "gst-meet")] nick: String, - #[structopt(long, default_value)] - region: String, + #[structopt(long)] + region: Option, #[structopt(long)] send_pipeline: Option, #[structopt(long)] diff --git a/lib-gst-meet-c/src/lib.rs b/lib-gst-meet-c/src/lib.rs index f0ffd62..74e8620 100644 --- a/lib-gst-meet-c/src/lib.rs +++ b/lib-gst-meet-c/src/lib.rs @@ -135,13 +135,18 @@ pub unsafe extern "C" fn gstmeet_connection_join_conference( return ptr::null_mut(); }, }; + let region = if (*config).region.is_null() { + None + } else { + Some(CStr::from_ptr((*config).region) + .to_string_lossy() + .to_string()) + }; let config = JitsiConferenceConfig { muc, focus, nick: CStr::from_ptr((*config).nick).to_string_lossy().to_string(), - region: CStr::from_ptr((*config).region) - .to_string_lossy() - .to_string(), + region, video_codec: CStr::from_ptr((*config).video_codec) .to_string_lossy() .to_string(), diff --git a/lib-gst-meet/src/conference.rs b/lib-gst-meet/src/conference.rs index 42cc9b6..47ea0de 100644 --- a/lib-gst-meet/src/conference.rs +++ b/lib-gst-meet/src/conference.rs @@ -76,7 +76,7 @@ pub struct JitsiConferenceConfig { pub muc: BareJid, pub focus: Jid, pub nick: String, - pub region: String, + pub region: Option, pub video_codec: String, pub extra_muc_features: Vec, } @@ -453,18 +453,22 @@ impl StanzaFilter for JitsiConference { Element::builder("jitsi_participant_codecType", ns::DEFAULT_NS) .append(self.config.video_codec.as_str()) .build(), - Element::builder("jitsi_participant_region", ns::DEFAULT_NS) - .append(self.config.region.as_str()) - .build(), Element::builder("audiomuted", ns::DEFAULT_NS).append("false").build(), Element::builder("videomuted", ns::DEFAULT_NS).append("false").build(), Element::builder("nick", "http://jabber.org/protocol/nick") .append(self.config.nick.as_str()) .build(), - Element::builder("region", "http://jitsi.org/jitsi-meet") - .attr("id", &self.config.region) - .build(), ]; + if let Some(region) = &self.config.region { + presence.extend([ + Element::builder("jitsi_participant_region", ns::DEFAULT_NS) + .append(region.as_str()) + .build(), + Element::builder("region", "http://jitsi.org/jitsi-meet") + .attr("id", region) + .build(), + ]); + } presence.extend( self .config