mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-27 20:40:31 +00:00
Add a consumer-removed
signal to notify the application
This commit is contained in:
parent
1983041770
commit
36eb00121c
1 changed files with 34 additions and 5 deletions
|
@ -856,7 +856,12 @@ impl CongestionController {
|
|||
}
|
||||
|
||||
impl State {
|
||||
fn finalize_consumer(&mut self, element: &super::WebRTCSink, consumer: Consumer, signal: bool) {
|
||||
fn finalize_consumer(
|
||||
&mut self,
|
||||
element: &super::WebRTCSink,
|
||||
consumer: &Consumer,
|
||||
signal: bool,
|
||||
) {
|
||||
consumer.pipeline.debug_to_dot_file_with_ts(
|
||||
gst::DebugGraphDetails::all(),
|
||||
format!("removing-peer-{}-", consumer.peer_id,),
|
||||
|
@ -881,9 +886,12 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
fn remove_consumer(&mut self, element: &super::WebRTCSink, peer_id: &str, signal: bool) {
|
||||
fn remove_consumer(&mut self, element: &super::WebRTCSink, peer_id: &str, signal: bool) -> Option<Consumer> {
|
||||
if let Some(consumer) = self.consumers.remove(peer_id) {
|
||||
self.finalize_consumer(element, consumer, signal);
|
||||
self.finalize_consumer(element, &consumer, signal);
|
||||
Some(consumer)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1748,7 +1756,10 @@ impl WebRTCSink {
|
|||
return Err(WebRTCSinkError::NoConsumerWithId(peer_id.to_string()));
|
||||
}
|
||||
|
||||
state.remove_consumer(element, peer_id, signal);
|
||||
if let Some(consumer) = state.remove_consumer(element, peer_id, signal) {
|
||||
drop(state);
|
||||
element.emit_by_name::<()>("consumer-removed", &[&peer_id, &consumer.webrtcbin]);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1841,7 +1852,7 @@ impl WebRTCSink {
|
|||
});
|
||||
|
||||
if remove {
|
||||
state.finalize_consumer(element, consumer, true);
|
||||
state.finalize_consumer(element, &consumer, true);
|
||||
} else {
|
||||
state.consumers.insert(consumer.peer_id.clone(), consumer);
|
||||
}
|
||||
|
@ -2473,6 +2484,24 @@ impl ObjectImpl for WebRTCSink {
|
|||
glib::types::Type::UNIT.into(),
|
||||
)
|
||||
.build(),
|
||||
|
||||
/*
|
||||
* RsWebRTCSink::consumer_removed:
|
||||
* @consumer_id: Identifier of the consumer that was removed
|
||||
* @webrtcbin: The webrtcbin connected to the newly removed consumer
|
||||
*
|
||||
* This signal is emitted right after the connection with a consumer
|
||||
* has been dropped.
|
||||
*/
|
||||
glib::subclass::Signal::builder(
|
||||
"consumer-removed",
|
||||
&[
|
||||
String::static_type().into(),
|
||||
gst::Element::static_type().into(),
|
||||
],
|
||||
glib::types::Type::UNIT.into(),
|
||||
)
|
||||
.build(),
|
||||
]
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue