added set_pipeline_state to C API, improved participant-left handler

This commit is contained in:
Jasper Hugo 2021-08-18 07:56:01 +07:00
parent b593ca6697
commit e5d10c6da0
4 changed files with 34 additions and 13 deletions

View File

@ -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 */

View File

@ -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()
}

View File

@ -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);
}
}
}
}
}
}

View File

@ -1,4 +1,9 @@
with import <nixpkgs> {};
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