2022-10-18 18:16:49 +00:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2021-10-05 21:28:05 +00:00
|
|
|
use crate::webrtcsink::{Signallable, WebRTCSink};
|
|
|
|
use gst::glib;
|
|
|
|
use gst::subclass::prelude::ObjectSubclassExt;
|
2021-12-21 22:37:29 +00:00
|
|
|
use std::error::Error;
|
2021-10-05 21:28:05 +00:00
|
|
|
|
|
|
|
mod imp;
|
|
|
|
|
|
|
|
glib::wrapper! {
|
|
|
|
pub struct Signaller(ObjectSubclass<imp::Signaller>);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl Send for Signaller {}
|
|
|
|
unsafe impl Sync for Signaller {}
|
|
|
|
|
|
|
|
impl Signallable for Signaller {
|
2021-12-21 22:37:29 +00:00
|
|
|
fn start(&mut self, element: &WebRTCSink) -> Result<(), Box<dyn Error>> {
|
2021-10-05 21:28:05 +00:00
|
|
|
let signaller = imp::Signaller::from_instance(self);
|
|
|
|
signaller.start(element);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn handle_sdp(
|
|
|
|
&mut self,
|
|
|
|
element: &WebRTCSink,
|
|
|
|
peer_id: &str,
|
|
|
|
sdp: &gst_webrtc::WebRTCSessionDescription,
|
2021-12-21 22:37:29 +00:00
|
|
|
) -> Result<(), Box<dyn Error>> {
|
2021-10-05 21:28:05 +00:00
|
|
|
let signaller = imp::Signaller::from_instance(self);
|
|
|
|
signaller.handle_sdp(element, peer_id, sdp);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn handle_ice(
|
|
|
|
&mut self,
|
|
|
|
element: &WebRTCSink,
|
2022-07-14 18:25:12 +00:00
|
|
|
session_id: &str,
|
2021-10-05 21:28:05 +00:00
|
|
|
candidate: &str,
|
|
|
|
sdp_mline_index: Option<u32>,
|
|
|
|
sdp_mid: Option<String>,
|
2021-12-21 22:37:29 +00:00
|
|
|
) -> Result<(), Box<dyn Error>> {
|
2021-10-05 21:28:05 +00:00
|
|
|
let signaller = imp::Signaller::from_instance(self);
|
2022-07-14 18:25:12 +00:00
|
|
|
signaller.handle_ice(element, session_id, candidate, sdp_mline_index, sdp_mid);
|
2021-10-05 21:28:05 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn stop(&mut self, element: &WebRTCSink) {
|
|
|
|
let signaller = imp::Signaller::from_instance(self);
|
|
|
|
signaller.stop(element);
|
|
|
|
}
|
|
|
|
|
2022-07-14 18:25:12 +00:00
|
|
|
fn session_ended(&mut self, element: &WebRTCSink, session_id: &str) {
|
2021-10-05 21:28:05 +00:00
|
|
|
let signaller = imp::Signaller::from_instance(self);
|
2022-07-14 18:25:12 +00:00
|
|
|
signaller.end_session(element, session_id);
|
2021-10-05 21:28:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-26 10:02:09 +00:00
|
|
|
impl Default for Signaller {
|
|
|
|
fn default() -> Self {
|
2022-10-17 17:29:35 +00:00
|
|
|
glib::Object::new::<Self>(&[])
|
2021-10-05 21:28:05 +00:00
|
|
|
}
|
|
|
|
}
|