Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade jid to 0.10 and xmpp-parsers to 0.20 #91

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gst-meet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ async fn main_inner() -> Result<()> {
participant
.jid
.as_ref()
.and_then(|jid| jid.node.as_deref())
.and_then(|jid| jid.node_str())
.unwrap_or_default(),
)
.replace("{participant_id}", &participant.muc_jid.resource)
.replace("{participant_id}", &participant.muc_jid.resource_str())
.replace("{nick}", &participant.nick.unwrap_or_default());

let bin = gstreamer::parse_bin_from_description(&pipeline_description, false)
Expand All @@ -463,7 +463,7 @@ async fn main_inner() -> Result<()> {

bin.set_property(
"name",
format!("participant_{}", participant.muc_jid.resource),
format!("participant_{}", participant.muc_jid.resource_str()),
);
conference.add_bin(&bin).await?;
}
Expand Down
4 changes: 2 additions & 2 deletions jitsi-xmpp-parsers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ documentation = "https://docs.rs/jitsi-xmpp-parsers/"
authors = ["Jasper Hugo <[email protected]>"]

[dependencies]
jid = { version = "0.9", default-features = false, features = ["minidom"] }
jid = { version = "0.10", default-features = false, features = ["minidom"] }
minidom = { version = "0.15", default-features = false }
xmpp-parsers = { version = "0.19", default-features = false, features = ["disable-validation"] }
xmpp-parsers = { version = "0.20", default-features = false, features = ["disable-validation"] }

[package.metadata.docs.rs]
rustdoc-args = [ "--sort-modules-by-appearance", "-Zunstable-options" ]
3 changes: 2 additions & 1 deletion lib-gst-meet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gstreamer = { version = "0.20", default-features = false, features = ["v1_20"] }
gstreamer-rtp = { version = "0.20", default-features = false, features = ["v1_20"] }
hex = { version = "0.4", default-features = false, features = ["std"] }
itertools = { version = "0.10", default-features = false, features = ["use_std"] }
jid = { version = "0.10", default-features = false }
jitsi-xmpp-parsers = { version = "0.2", path = "../jitsi-xmpp-parsers", default-features = false }
libc = { version = "0.2", default-features = false }
maplit = { version = "1", default-features = false }
Expand Down Expand Up @@ -51,7 +52,7 @@ tracing-subscriber = { version = "0.3", optional = true, default-features = fals
] }
uuid = { version = "1", default-features = false, features = ["v4"] }
webpki-roots = { version = "0.23", default-features = false, optional = true }
xmpp-parsers = { version = "0.19", default-features = false, features = ["disable-validation"] }
xmpp-parsers = { version = "0.20", default-features = false, features = ["disable-validation"] }

[features]
# Ideally we would enable rustls/dangerous_configuration only when tls-insecure is enabled, but until weak-dep-features is stabilised, that
Expand Down
36 changes: 18 additions & 18 deletions lib-gst-meet/src/conference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use colibri::{ColibriMessage, JsonMessage};
use futures::stream::StreamExt;
use glib::ObjectExt;
use gstreamer::prelude::{ElementExt, ElementExtManual, GstBinExt};
use jid::ResourcePart;
use jitsi_xmpp_parsers::jingle::{Action, Jingle};
use maplit::hashmap;
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -130,7 +131,7 @@ pub struct Participant {
type BoxedResultFuture = Pin<Box<dyn Future<Output = Result<()>> + Send>>;

pub(crate) struct JitsiConferenceInner {
participants: HashMap<String, Participant>,
participants: HashMap<ResourcePart, Participant>,
audio_sink: Option<gstreamer::Element>,
video_sink: Option<gstreamer::Element>,
on_participant:
Expand Down Expand Up @@ -271,20 +272,19 @@ impl JitsiConference {
fn endpoint_id(&self) -> Result<&str> {
self
.jid
.node
.as_ref()
.node_str()
.ok_or_else(|| anyhow!("invalid jid"))?
.split('-')
.next()
.ok_or_else(|| anyhow!("invalid jid"))
}

fn jid_in_muc(&self) -> Result<FullJid> {
Ok(self.config.muc.clone().with_resource(self.endpoint_id()?))
Ok(self.config.muc.with_resource_str(self.endpoint_id()?)?)
}

pub(crate) fn focus_jid_in_muc(&self) -> Result<FullJid> {
Ok(self.config.muc.clone().with_resource("focus"))
Ok(self.config.muc.with_resource_str("focus")?)
}

#[tracing::instrument(level = "debug", err)]
Expand Down Expand Up @@ -423,19 +423,19 @@ impl JitsiConference {
Ok(())
}

pub(crate) async fn ensure_participant(&self, id: &str) -> Result<()> {
if !self.inner.lock().await.participants.contains_key(id) {
pub(crate) async fn ensure_participant(&self, id: ResourcePart) -> Result<()> {
if !self.inner.lock().await.participants.contains_key(&id) {
let participant = Participant {
jid: None,
muc_jid: self.config.muc.clone().with_resource(id),
muc_jid: self.config.muc.with_resource(&id),
nick: None,
};
self
.inner
.lock()
.await
.participants
.insert(id.to_owned(), participant.clone());
.insert(id, participant.clone());
if let Some(f) = self.inner.lock().await.on_participant.as_ref().cloned() {
if let Err(e) = f(self.clone(), participant.clone()).await {
warn!("on_participant failed: {:?}", e);
Expand All @@ -444,7 +444,7 @@ impl JitsiConference {
gstreamer::debug_bin_to_dot_file(
&pipeline,
gstreamer::DebugGraphDetails::ALL,
&format!("participant-added-{}", participant.muc_jid.resource),
&format!("participant-added-{}", participant.muc_jid.resource_str()),
);
}
}
Expand Down Expand Up @@ -476,7 +476,7 @@ impl JitsiConference {
gstreamer::debug_bin_to_dot_file(
&pipeline,
gstreamer::DebugGraphDetails::ALL,
&format!("participant-added-{}", participant.muc_jid.resource),
&format!("participant-added-{}", participant.muc_jid.resource_str()),
);
}
}
Expand Down Expand Up @@ -600,7 +600,7 @@ impl StanzaFilter for JitsiConference {
Ok(jingle) => {
if let Some(Jid::Full(from_jid)) = iq.from {
if jingle.action == Action::SessionInitiate {
if from_jid.resource == "focus" {
if from_jid.resource_str() == "focus" {
// Acknowledge the IQ
let result_iq = Iq::empty_result(Jid::Full(from_jid.clone()), iq.id.clone())
.with_from(Jid::Full(self.jid.clone()));
Expand Down Expand Up @@ -914,9 +914,9 @@ impl StanzaFilter for JitsiConference {
.context("missing from in presence")?
.clone()
{
let bare_from: BareJid = from.clone().into();
if bare_from == self.config.muc && from.resource != "focus" {
trace!("received MUC presence from {}", from.resource);
let bare_from = from.to_bare();
if bare_from == self.config.muc && from.resource_str() != "focus" {
trace!("received MUC presence from {}", from.resource_str());
let nick_payload = presence
.payloads
.iter()
Expand Down Expand Up @@ -953,7 +953,7 @@ impl StanzaFilter for JitsiConference {
.lock()
.await
.participants
.remove(&from.resource.clone())
.remove(&from.resource())
.is_some()
{
debug!("participant left: {:?}", jid);
Expand All @@ -976,7 +976,7 @@ impl StanzaFilter for JitsiConference {
.lock()
.await
.participants
.insert(from.resource.clone(), participant.clone())
.insert(from.resource(), participant.clone())
.is_none()
{
debug!("new participant: {:?}", jid);
Expand All @@ -991,7 +991,7 @@ impl StanzaFilter for JitsiConference {
gstreamer::debug_bin_to_dot_file(
&jingle_session.pipeline(),
gstreamer::DebugGraphDetails::ALL,
&format!("participant-added-{}", participant.muc_jid.resource),
&format!("participant-added-{}", participant.muc_jid.resource_str()),
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib-gst-meet/src/jingle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use gstreamer::{
use gstreamer_rtp::RTPBuffer;
use gstreamer_rtp::{prelude::RTPHeaderExtensionExt, RTPHeaderExtension};
use itertools::Itertools;
use jid::ResourcePart;
use jitsi_xmpp_parsers::{
jingle::{Action, Content, Description, Jingle, Transport},
jingle_dtls_srtp::Fingerprint,
Expand Down Expand Up @@ -962,7 +963,8 @@ impl JingleSession {
};

if let Some(participant_id) = source.participant_id {
handle.block_on(conference.ensure_participant(&participant_id))?;
handle
.block_on(conference.ensure_participant(ResourcePart::new(&participant_id)?))?;
let maybe_sink_element = match source.media_type {
MediaType::Audio => {
handle.block_on(conference.remote_participant_audio_sink_element())
Expand Down