diff --git a/lib-gst-meet-c/include/gstmeet.h b/lib-gst-meet-c/include/gstmeet.h index cc305f1..8a14473 100644 --- a/lib-gst-meet-c/include/gstmeet.h +++ b/lib-gst-meet-c/include/gstmeet.h @@ -72,4 +72,8 @@ void gstmeet_conference_on_participant(struct Context *context, GstBin *(*f)(struct Participant, void *), void *callback_context); +bool gstmeet_conference_set_pipeline_state(struct Context *context, + JitsiConference *conference, + GstState state); + #endif /* gstmeet_h */ diff --git a/lib-gst-meet-c/src/lib.rs b/lib-gst-meet-c/src/lib.rs index 571fc95..a6feb1b 100644 --- a/lib-gst-meet-c/src/lib.rs +++ b/lib-gst-meet-c/src/lib.rs @@ -6,7 +6,7 @@ use std::{ }; use anyhow::Result; -use glib::{ffi::GMainContext, translate::{from_glib_full, ToGlibPtr}}; +use glib::{ffi::GMainContext, translate::{from_glib, from_glib_full, ToGlibPtr}}; pub use lib_gst_meet::{init_tracing, JitsiConference, JitsiConnection, MediaType}; use lib_gst_meet::JitsiConferenceConfig; use tokio::runtime::Runtime; @@ -214,4 +214,17 @@ pub unsafe extern "C" fn gstmeet_conference_on_participant( } }) })); +} + +#[no_mangle] +pub unsafe extern "C" fn gstmeet_conference_set_pipeline_state( + context: *mut Context, + conference: *mut JitsiConference, + state: gstreamer::ffi::GstState, +) -> bool { + (*context) + .runtime + .block_on((*conference).set_pipeline_state(from_glib(state))) + .map_err(|e| eprintln!("lib-gst-meet: {:?}", e)) + .is_ok() } \ No newline at end of file diff --git a/lib-gst-meet/src/conference.rs b/lib-gst-meet/src/conference.rs index 7bf4419..7f6f5e0 100644 --- a/lib-gst-meet/src/conference.rs +++ b/lib-gst-meet/src/conference.rs @@ -533,7 +533,16 @@ impl StanzaFilter for JitsiConference { nick: item.nick, bin: None, }; - if locked_inner + if presence.type_ == presence::Type::Unavailable && locked_inner.participants.remove(&from.resource.clone()).is_some() { + debug!("participant left: {:?}", jid); + if let Some(f) = &locked_inner.on_participant_left { + debug!("calling on_participant_left with old participant"); + if let Err(e) = f(participant).await { + warn!("on_participant_left failed: {:?}", e); + } + } + } + else if locked_inner .participants .insert(from.resource.clone(), participant.clone()) .is_none() @@ -558,16 +567,6 @@ impl StanzaFilter for JitsiConference { } } } - else if presence.type_ == presence::Type::Unavailable { - locked_inner.participants.remove(&from.resource.clone()); - debug!("participant left: {:?}", jid); - if let Some(f) = &locked_inner.on_participant_left { - debug!("calling on_participant_left with old participant"); - if let Err(e) = f(participant).await { - warn!("on_participant_left failed: {:?}", e); - } - } - } } } } diff --git a/shell.nix b/shell.nix index d08a169..b6efbeb 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,9 @@ with import {}; +let + gst-plugins-base = gst_all_1.gst-plugins-base.override { + enableCocoa = stdenv.isDarwin; + }; +in mkShell { name = "gst-meet"; buildInputs = [ @@ -6,7 +11,7 @@ mkShell { glib glib-networking gst_all_1.gstreamer - gst_all_1.gst-plugins-base + gst-plugins-base gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad libnice