don’t include region elements when empty (#4)

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.
This commit is contained in:
linkmauve 2021-10-11 16:36:10 +02:00 committed by GitHub
parent 9d2dcfb21c
commit 0040d20151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 12 deletions

View File

@ -36,8 +36,8 @@ struct Opt {
video_codec: String, video_codec: String,
#[structopt(long, default_value = "gst-meet")] #[structopt(long, default_value = "gst-meet")]
nick: String, nick: String,
#[structopt(long, default_value)] #[structopt(long)]
region: String, region: Option<String>,
#[structopt(long)] #[structopt(long)]
send_pipeline: Option<String>, send_pipeline: Option<String>,
#[structopt(long)] #[structopt(long)]

View File

@ -135,13 +135,18 @@ pub unsafe extern "C" fn gstmeet_connection_join_conference(
return ptr::null_mut(); 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 { let config = JitsiConferenceConfig {
muc, muc,
focus, focus,
nick: CStr::from_ptr((*config).nick).to_string_lossy().to_string(), nick: CStr::from_ptr((*config).nick).to_string_lossy().to_string(),
region: CStr::from_ptr((*config).region) region,
.to_string_lossy()
.to_string(),
video_codec: CStr::from_ptr((*config).video_codec) video_codec: CStr::from_ptr((*config).video_codec)
.to_string_lossy() .to_string_lossy()
.to_string(), .to_string(),

View File

@ -76,7 +76,7 @@ pub struct JitsiConferenceConfig {
pub muc: BareJid, pub muc: BareJid,
pub focus: Jid, pub focus: Jid,
pub nick: String, pub nick: String,
pub region: String, pub region: Option<String>,
pub video_codec: String, pub video_codec: String,
pub extra_muc_features: Vec<String>, pub extra_muc_features: Vec<String>,
} }
@ -453,18 +453,22 @@ impl StanzaFilter for JitsiConference {
Element::builder("jitsi_participant_codecType", ns::DEFAULT_NS) Element::builder("jitsi_participant_codecType", ns::DEFAULT_NS)
.append(self.config.video_codec.as_str()) .append(self.config.video_codec.as_str())
.build(), .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("audiomuted", ns::DEFAULT_NS).append("false").build(),
Element::builder("videomuted", ns::DEFAULT_NS).append("false").build(), Element::builder("videomuted", ns::DEFAULT_NS).append("false").build(),
Element::builder("nick", "http://jabber.org/protocol/nick") Element::builder("nick", "http://jabber.org/protocol/nick")
.append(self.config.nick.as_str()) .append(self.config.nick.as_str())
.build(), .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( presence.extend(
self self
.config .config