mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-22 03:21:00 +00:00
livekitwebrtcsrc: Add API for disabling/enabling a track
A disabled track is still negotiated but no data is sent for it temporarily until it is enabled again. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1794>
This commit is contained in:
parent
27dc76826e
commit
cd2b641321
3 changed files with 67 additions and 1 deletions
|
@ -11070,6 +11070,19 @@
|
|||
"type": "gchararray",
|
||||
"writable": false
|
||||
}
|
||||
},
|
||||
"signals": {
|
||||
"set-track-disabled": {
|
||||
"action": true,
|
||||
"args": [
|
||||
{
|
||||
"name": "arg0",
|
||||
"type": "gboolean"
|
||||
}
|
||||
],
|
||||
"return-type": "void",
|
||||
"when": "last"
|
||||
}
|
||||
}
|
||||
},
|
||||
"GstRSWebRTCSignallableIface": {
|
||||
|
|
|
@ -20,7 +20,7 @@ use tokio::task::JoinHandle;
|
|||
|
||||
use livekit_api::access_token::{AccessToken, VideoGrants};
|
||||
use livekit_api::signal_client;
|
||||
use livekit_protocol as proto;
|
||||
use livekit_protocol::{self as proto, UpdateTrackSettings};
|
||||
|
||||
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
||||
gst::DebugCategory::new(
|
||||
|
@ -558,6 +558,23 @@ impl Signaller {
|
|||
let participant = connection.participants.get(participant_sid)?;
|
||||
Some(participant.clone())
|
||||
}
|
||||
|
||||
pub(crate) fn set_track_disabled(&self, track_sid: &str, disabled: bool) {
|
||||
let update = proto::signal_request::Message::TrackSetting(UpdateTrackSettings {
|
||||
track_sids: vec![String::from(track_sid)],
|
||||
disabled,
|
||||
..Default::default()
|
||||
});
|
||||
let weak_imp = self.downgrade();
|
||||
RUNTIME.spawn(async move {
|
||||
let imp = match weak_imp.upgrade() {
|
||||
Some(imp) => imp,
|
||||
None => return,
|
||||
};
|
||||
let signal_client = imp.require_signal_client();
|
||||
signal_client.send(update).await;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl SignallableImpl for Signaller {
|
||||
|
|
|
@ -1996,6 +1996,21 @@ pub(super) mod livekit {
|
|||
self.participant_track_sid()
|
||||
.map(|(_participant_sid, track_sid)| track_sid)
|
||||
}
|
||||
|
||||
fn set_track_disabled(&self, disabled: bool) {
|
||||
let Some(track_sid) = self.track_sid() else {
|
||||
return;
|
||||
};
|
||||
let Some(webrtcbin) = self
|
||||
.obj()
|
||||
.parent()
|
||||
.and_downcast::<super::super::BaseWebRTCSrc>()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let signaller = webrtcbin.property::<LiveKitSignaller>("signaller");
|
||||
signaller.imp().set_track_disabled(&track_sid, disabled)
|
||||
}
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
@ -2006,6 +2021,27 @@ pub(super) mod livekit {
|
|||
}
|
||||
|
||||
impl ObjectImpl for LiveKitWebRTCSrcPad {
|
||||
fn signals() -> &'static [glib::subclass::Signal] {
|
||||
static SIGNALS: Lazy<Vec<glib::subclass::Signal>> = Lazy::new(|| {
|
||||
vec![glib::subclass::Signal::builder("set-track-disabled")
|
||||
.param_types([bool::static_type()])
|
||||
.action()
|
||||
.class_handler(|_token, values| {
|
||||
let pad = values[0]
|
||||
.get::<&super::super::LiveKitWebRTCSrcPad>()
|
||||
.unwrap();
|
||||
let disabled = values[1].get::<bool>().unwrap();
|
||||
|
||||
pad.imp().set_track_disabled(disabled);
|
||||
|
||||
None
|
||||
})
|
||||
.build()]
|
||||
});
|
||||
|
||||
SIGNALS.as_ref()
|
||||
}
|
||||
|
||||
fn properties() -> &'static [glib::ParamSpec] {
|
||||
static PROPS: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
|
||||
vec![
|
||||
|
|
Loading…
Reference in a new issue