gst-plugins-rs/net/webrtc/src/signaller/mod.rs

65 lines
1.7 KiB
Rust
Raw Normal View History

// 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;
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 {
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,
) -> 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,
session_id: &str,
2021-10-05 21:28:05 +00:00
candidate: &str,
sdp_mline_index: Option<u32>,
sdp_mid: Option<String>,
) -> Result<(), Box<dyn Error>> {
2021-10-05 21:28:05 +00:00
let signaller = imp::Signaller::from_instance(self);
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);
}
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);
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
}
}