Add a new 'get-consumers' action signal

So user can get the list of currently avalaible consumers (by ID).
This commit is contained in:
Thibault Saunier 2022-02-07 17:33:22 +00:00 committed by Mathieu Duponchelle
parent 4e0e8d1cc3
commit 794df19122

View file

@ -2502,6 +2502,35 @@ impl ObjectImpl for WebRTCSink {
glib::types::Type::UNIT.into(),
)
.build(),
/*
* RsWebRTCSink::get_consumers:
*
* List all consumers (by ID).
*/
glib::subclass::Signal::builder(
"get-consumers",
&[],
<Vec<String>>::static_type().into(),
)
.action()
.class_handler(|_, args| {
let element = args[0].get::<super::WebRTCSink>().expect("signal arg");
let this = element.imp();
let res = Some(
this.state
.lock()
.unwrap()
.consumers
.keys()
.cloned()
.collect::<Vec<String>>()
.to_value(),
);
res
})
.build(),
]
});