2022-07-12 21:13:38 +00:00
|
|
|
use gst::glib;
|
|
|
|
use gst::glib::subclass::*;
|
|
|
|
use gst::prelude::*;
|
|
|
|
use gst::subclass::prelude::*;
|
|
|
|
use once_cell::sync::Lazy;
|
|
|
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
pub struct Signallable {
|
|
|
|
_parent: glib::gobject_ffi::GTypeInterface,
|
|
|
|
pub start: fn(&super::Signallable),
|
|
|
|
pub stop: fn(&super::Signallable),
|
|
|
|
pub send_sdp: fn(&super::Signallable, &str, &gst_webrtc::WebRTCSessionDescription),
|
2023-03-21 05:16:16 +00:00
|
|
|
pub add_ice: fn(&super::Signallable, &str, &str, u32, Option<String>),
|
2022-07-12 21:13:38 +00:00
|
|
|
pub end_session: fn(&super::Signallable, &str),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Signallable {
|
|
|
|
fn request_meta(_iface: &super::Signallable) -> Option<gst::Structure> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
fn start(_iface: &super::Signallable) {}
|
|
|
|
fn stop(_iface: &super::Signallable) {}
|
|
|
|
fn send_sdp(
|
|
|
|
_iface: &super::Signallable,
|
|
|
|
_session_id: &str,
|
|
|
|
_sdp: &gst_webrtc::WebRTCSessionDescription,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
fn add_ice(
|
|
|
|
_iface: &super::Signallable,
|
|
|
|
_session_id: &str,
|
|
|
|
_candidate: &str,
|
2023-03-21 05:16:16 +00:00
|
|
|
_sdp_m_line_index: u32,
|
2022-07-12 21:13:38 +00:00
|
|
|
_sdp_mid: Option<String>,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
fn end_session(_iface: &super::Signallable, _session_id: &str) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[glib::object_interface]
|
|
|
|
unsafe impl prelude::ObjectInterface for Signallable {
|
|
|
|
const NAME: &'static ::std::primitive::str = "GstRSWebRTCSignallableIface";
|
|
|
|
type Prerequisites = (glib::Object,);
|
|
|
|
|
|
|
|
fn interface_init(&mut self) {
|
|
|
|
self.start = Signallable::start;
|
|
|
|
self.stop = Signallable::stop;
|
|
|
|
self.send_sdp = Signallable::send_sdp;
|
|
|
|
self.add_ice = Signallable::add_ice;
|
|
|
|
self.end_session = Signallable::end_session;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn signals() -> &'static [Signal] {
|
|
|
|
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| {
|
|
|
|
vec![
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::session-ended:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @session-id: The ID of the session that ended
|
|
|
|
*
|
2023-03-21 05:16:16 +00:00
|
|
|
* Notify the underlying webrtc object that a session has ended.
|
2022-07-12 21:13:38 +00:00
|
|
|
*/
|
|
|
|
Signal::builder("session-ended")
|
|
|
|
.param_types([str::static_type()])
|
2023-03-21 05:16:16 +00:00
|
|
|
.return_type::<bool>()
|
2022-07-12 21:13:38 +00:00
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::producer-added:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @producer_id: The ID of the producer that was added
|
|
|
|
* @meta: The metadata structure of the producer
|
|
|
|
*
|
|
|
|
* Some new producing peer is ready to produce a WebRTC stream.
|
|
|
|
*/
|
|
|
|
Signal::builder("producer-added")
|
|
|
|
.param_types([str::static_type(), <Option<gst::Structure>>::static_type()])
|
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::producer-removed:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @producer_id: The ID of the producer that was added
|
|
|
|
* @meta: The metadata structure of the producer
|
|
|
|
*
|
|
|
|
* Some new producing peer is stopped producing streams.
|
|
|
|
*/
|
|
|
|
Signal::builder("producer-removed")
|
|
|
|
.param_types([str::static_type(), <Option<gst::Structure>>::static_type()])
|
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::session-started:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
*
|
2023-03-21 05:16:16 +00:00
|
|
|
* Notify the underlying webrtc object that a session has started.
|
2022-07-12 21:13:38 +00:00
|
|
|
*/
|
|
|
|
Signal::builder("session-started")
|
|
|
|
.param_types([str::static_type(), str::static_type()])
|
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::session-requested:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @session_id: The ID of the producer that was added
|
|
|
|
* @peer_id: The ID of the consumer peer who wants to initiate a
|
|
|
|
* session
|
2023-03-21 05:16:16 +00:00
|
|
|
*
|
|
|
|
* Notify the underlying webrtc object that a session has been requested from the
|
|
|
|
* peer.
|
2022-07-12 21:13:38 +00:00
|
|
|
*/
|
|
|
|
Signal::builder("session-requested")
|
2022-11-19 00:43:03 +00:00
|
|
|
.param_types([
|
|
|
|
str::static_type(),
|
|
|
|
str::static_type(),
|
|
|
|
gst_webrtc::WebRTCSessionDescription::static_type(),
|
|
|
|
])
|
2022-07-12 21:13:38 +00:00
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::error:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @error: The error message as a string
|
|
|
|
*/
|
|
|
|
Signal::builder("error")
|
|
|
|
.param_types([str::static_type()])
|
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::request-meta:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
*
|
|
|
|
* The signaller requests a meta about the peer using it
|
|
|
|
*
|
|
|
|
* Return: The metadata about the peer represented by the signaller
|
|
|
|
*/
|
|
|
|
Signal::builder("request-meta")
|
|
|
|
.return_type::<Option<gst::Structure>>()
|
|
|
|
.class_handler(|_token, args| {
|
2023-04-04 01:47:15 +00:00
|
|
|
let this = args[0usize]
|
2022-07-12 21:13:38 +00:00
|
|
|
.get::<&super::Signallable>()
|
|
|
|
.unwrap_or_else(|e| {
|
|
|
|
panic!("Wrong type for argument {}: {:?}", 0usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
Some(Signallable::request_meta(this).to_value())
|
2022-07-12 21:13:38 +00:00
|
|
|
})
|
2023-03-21 05:16:16 +00:00
|
|
|
.accumulator(move |_hint, output, input| {
|
|
|
|
*output = input.clone();
|
|
|
|
false
|
|
|
|
})
|
2022-07-12 21:13:38 +00:00
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::handle-ice:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @session_id: Id of the session the ice information is about
|
|
|
|
* @sdp_m_line_index: The mlineindex of the ice candidate
|
|
|
|
* @sdp_mid: Media ID of the ice candidate
|
|
|
|
* @candiate: Information about the candidate
|
2023-03-21 05:16:16 +00:00
|
|
|
*
|
|
|
|
* Notify the underlying webrtc object of an ICE candidate.
|
2022-07-12 21:13:38 +00:00
|
|
|
*/
|
|
|
|
Signal::builder("handle-ice")
|
2023-03-21 05:16:16 +00:00
|
|
|
.flags(glib::SignalFlags::ACTION)
|
2022-07-12 21:13:38 +00:00
|
|
|
.param_types([
|
|
|
|
str::static_type(),
|
|
|
|
u32::static_type(),
|
|
|
|
<Option<String>>::static_type(),
|
|
|
|
str::static_type(),
|
|
|
|
])
|
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::session-description:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @session_id: Id of the session being described
|
|
|
|
* @description: The WebRTC session description
|
2023-03-21 05:16:16 +00:00
|
|
|
*
|
|
|
|
* Notify the underlying webrtc object of a received session description
|
2022-07-12 21:13:38 +00:00
|
|
|
*/
|
|
|
|
Signal::builder("session-description")
|
2023-03-21 05:16:16 +00:00
|
|
|
.flags(glib::SignalFlags::ACTION)
|
2022-07-12 21:13:38 +00:00
|
|
|
.param_types([
|
|
|
|
str::static_type(),
|
|
|
|
gst_webrtc::WebRTCSessionDescription::static_type(),
|
|
|
|
])
|
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::start:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
*
|
|
|
|
* Starts the signaller, connecting it to the signalling server.
|
|
|
|
*/
|
|
|
|
Signal::builder("start")
|
2023-03-21 05:16:16 +00:00
|
|
|
.run_last()
|
|
|
|
.return_type::<bool>()
|
2022-07-12 21:13:38 +00:00
|
|
|
.class_handler(|_token, args| {
|
2023-04-04 01:47:15 +00:00
|
|
|
let this = args[0usize]
|
2022-07-12 21:13:38 +00:00
|
|
|
.get::<&super::Signallable>()
|
|
|
|
.unwrap_or_else(|e| {
|
|
|
|
panic!("Wrong type for argument {}: {:?}", 0usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let vtable = this.interface::<super::Signallable>().unwrap();
|
2023-03-21 05:16:16 +00:00
|
|
|
let vtable = vtable.as_ref();
|
2023-04-04 01:47:15 +00:00
|
|
|
(vtable.start)(this);
|
2022-07-12 21:13:38 +00:00
|
|
|
|
2023-03-21 05:16:16 +00:00
|
|
|
Some(false.into())
|
|
|
|
})
|
|
|
|
.accumulator(move |_hint, output, input| {
|
|
|
|
*output = input.clone();
|
|
|
|
false
|
2022-07-12 21:13:38 +00:00
|
|
|
})
|
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::stop:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
*
|
|
|
|
* Stops the signaller, disconnecting it to the signalling server.
|
|
|
|
*/
|
|
|
|
Signal::builder("stop")
|
2023-03-21 05:16:16 +00:00
|
|
|
.run_last()
|
|
|
|
.return_type::<bool>()
|
2022-07-12 21:13:38 +00:00
|
|
|
.class_handler(|_tokens, args| {
|
2023-04-04 01:47:15 +00:00
|
|
|
let this = args[0usize]
|
2022-07-12 21:13:38 +00:00
|
|
|
.get::<&super::Signallable>()
|
|
|
|
.unwrap_or_else(|e| {
|
|
|
|
panic!("Wrong type for argument {}: {:?}", 0usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let vtable = this.interface::<super::Signallable>().unwrap();
|
2023-03-21 05:16:16 +00:00
|
|
|
let vtable = vtable.as_ref();
|
2023-04-04 01:47:15 +00:00
|
|
|
(vtable.stop)(this);
|
2022-07-12 21:13:38 +00:00
|
|
|
|
2023-03-21 05:16:16 +00:00
|
|
|
Some(false.into())
|
|
|
|
})
|
|
|
|
.accumulator(move |_hint, output, input| {
|
|
|
|
*output = input.clone();
|
|
|
|
false
|
2022-07-12 21:13:38 +00:00
|
|
|
})
|
|
|
|
.build(),
|
2022-11-19 00:43:03 +00:00
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::shutdown:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
*/
|
2023-03-21 05:16:16 +00:00
|
|
|
Signal::builder("shutdown")
|
|
|
|
.flags(glib::SignalFlags::ACTION)
|
|
|
|
.build(),
|
2023-04-07 23:28:31 +00:00
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::end-session:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @session-id: The ID of the session that should be ended
|
|
|
|
*
|
|
|
|
* Notify the signaller that a session should be ended.
|
|
|
|
*/
|
|
|
|
Signal::builder("end-session")
|
|
|
|
.run_last()
|
|
|
|
.param_types([str::static_type()])
|
|
|
|
.return_type::<bool>()
|
|
|
|
.class_handler(|_tokens, args| {
|
|
|
|
let this = args[0usize]
|
|
|
|
.get::<&super::Signallable>()
|
|
|
|
.unwrap_or_else(|e| {
|
|
|
|
panic!("Wrong type for argument {}: {:?}", 0usize, e)
|
|
|
|
});
|
|
|
|
let session_id = args[1usize].get::<&str>().unwrap_or_else(|e| {
|
|
|
|
panic!("Wrong type for argument {}: {:?}", 1usize, e)
|
|
|
|
});
|
|
|
|
let vtable = this.interface::<super::Signallable>().unwrap();
|
|
|
|
let vtable = vtable.as_ref();
|
|
|
|
(vtable.end_session)(this, session_id);
|
|
|
|
|
|
|
|
Some(false.into())
|
|
|
|
})
|
|
|
|
.accumulator(move |_hint, output, input| {
|
|
|
|
*output = input.clone();
|
|
|
|
false
|
|
|
|
})
|
|
|
|
.build(),
|
2022-11-19 00:43:03 +00:00
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::consumer-added:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @peer_id: Id of the consumer
|
|
|
|
* @webrtcbin: The internal WebRTCBin element
|
|
|
|
*
|
|
|
|
* This signal can be used to tweak @webrtcbin, creating a data
|
|
|
|
* channel for example.
|
|
|
|
*/
|
|
|
|
Signal::builder("consumer-added")
|
|
|
|
.param_types([String::static_type(), gst::Element::static_type()])
|
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::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.
|
|
|
|
*/
|
2023-03-21 05:16:16 +00:00
|
|
|
Signal::builder("consumer-removed")
|
2022-11-19 00:43:03 +00:00
|
|
|
.param_types([String::static_type(), gst::Element::static_type()])
|
|
|
|
.build(),
|
2023-03-21 05:16:16 +00:00
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::send-session-description:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @session_id: Id of the session being described
|
|
|
|
* @description: The WebRTC session description to send to the peer
|
|
|
|
*
|
|
|
|
* Send @description to the peer.
|
|
|
|
*/
|
|
|
|
Signal::builder("send-session-description")
|
|
|
|
.run_last()
|
|
|
|
.param_types([
|
|
|
|
str::static_type(),
|
|
|
|
gst_webrtc::WebRTCSessionDescription::static_type(),
|
|
|
|
])
|
|
|
|
.return_type::<bool>()
|
|
|
|
.class_handler(|_tokens, args| {
|
2023-04-04 01:47:15 +00:00
|
|
|
let this = args[0usize]
|
2023-03-21 05:16:16 +00:00
|
|
|
.get::<&super::Signallable>()
|
|
|
|
.unwrap_or_else(|e| {
|
|
|
|
panic!("Wrong type for argument {}: {:?}", 0usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let session_id = args[1usize].get::<&str>().unwrap_or_else(|e| {
|
2023-03-21 05:16:16 +00:00
|
|
|
panic!("Wrong type for argument {}: {:?}", 1usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let desc = args[2usize]
|
2023-03-21 05:16:16 +00:00
|
|
|
.get::<&gst_webrtc::WebRTCSessionDescription>()
|
|
|
|
.unwrap_or_else(|e| {
|
|
|
|
panic!("Wrong type for argument {}: {:?}", 2usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let vtable = this.interface::<super::Signallable>().unwrap();
|
2023-03-21 05:16:16 +00:00
|
|
|
let vtable = vtable.as_ref();
|
2023-04-04 01:47:15 +00:00
|
|
|
(vtable.send_sdp)(this, session_id, desc);
|
2023-03-21 05:16:16 +00:00
|
|
|
|
|
|
|
Some(false.into())
|
|
|
|
})
|
|
|
|
.accumulator(move |_hint, output, input| {
|
|
|
|
*output = input.clone();
|
|
|
|
false
|
|
|
|
})
|
|
|
|
.build(),
|
|
|
|
/**
|
|
|
|
* GstRSWebRTCSignallableIface::send-ice:
|
|
|
|
* @self: The object implementing #GstRSWebRTCSignallableIface
|
|
|
|
* @session_id: Id of the session being described
|
|
|
|
* @candidate: The ICE candidate description to send to the peer
|
|
|
|
* @sdp_m_line_index: The M-line of the session description this candidate applies to
|
|
|
|
* @sdp_mid: The MID this candidate applies to
|
|
|
|
*
|
|
|
|
* Send @candidate to the peer.
|
|
|
|
*/
|
|
|
|
Signal::builder("send-ice")
|
|
|
|
.param_types([
|
|
|
|
str::static_type(),
|
|
|
|
str::static_type(),
|
|
|
|
u32::static_type(),
|
|
|
|
String::static_type(),
|
|
|
|
])
|
|
|
|
.return_type::<bool>()
|
|
|
|
.class_handler(|_tokens, args| {
|
2023-04-04 01:47:15 +00:00
|
|
|
let this = args[0usize]
|
2023-03-21 05:16:16 +00:00
|
|
|
.get::<&super::Signallable>()
|
|
|
|
.unwrap_or_else(|e| {
|
|
|
|
panic!("Wrong type for argument {}: {:?}", 0usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let session_id = args[1usize].get::<&str>().unwrap_or_else(|e| {
|
2023-03-21 05:16:16 +00:00
|
|
|
panic!("Wrong type for argument {}: {:?}", 1usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let candidate = args[2usize].get::<&str>().unwrap_or_else(|e| {
|
2023-03-21 05:16:16 +00:00
|
|
|
panic!("Wrong type for argument {}: {:?}", 2usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let sdp_m_line_index = args[3usize].get::<u32>().unwrap_or_else(|e| {
|
2023-03-21 05:16:16 +00:00
|
|
|
panic!("Wrong type for argument {}: {:?}", 2usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let sdp_mid = args[4usize].get::<Option<String>>().unwrap_or_else(|e| {
|
2023-03-21 05:16:16 +00:00
|
|
|
panic!("Wrong type for argument {}: {:?}", 2usize, e)
|
|
|
|
});
|
2023-04-04 01:47:15 +00:00
|
|
|
let vtable = this.interface::<super::Signallable>().unwrap();
|
2023-03-21 05:16:16 +00:00
|
|
|
let vtable = vtable.as_ref();
|
2023-04-04 01:47:15 +00:00
|
|
|
(vtable.add_ice)(this, session_id, candidate, sdp_m_line_index, sdp_mid);
|
2023-03-21 05:16:16 +00:00
|
|
|
|
|
|
|
Some(false.into())
|
|
|
|
})
|
|
|
|
.accumulator(move |_hint, output, input| {
|
|
|
|
*output = input.clone();
|
|
|
|
false
|
|
|
|
})
|
|
|
|
.build(),
|
2022-07-12 21:13:38 +00:00
|
|
|
]
|
|
|
|
});
|
|
|
|
SIGNALS.as_ref()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl<Obj: SignallableImpl> types::IsImplementable<Obj> for super::Signallable
|
|
|
|
where
|
|
|
|
<Obj as types::ObjectSubclass>::Type: glib::IsA<glib::Object>,
|
|
|
|
{
|
|
|
|
fn interface_init(iface: &mut glib::Interface<Self>) {
|
|
|
|
let iface = ::std::convert::AsMut::as_mut(iface);
|
|
|
|
|
|
|
|
fn vstart_trampoline<Obj: types::ObjectSubclass + SignallableImpl>(
|
|
|
|
obj: &super::Signallable,
|
|
|
|
) {
|
|
|
|
let this = obj
|
|
|
|
.dynamic_cast_ref::<<Obj as types::ObjectSubclass>::Type>()
|
|
|
|
.unwrap()
|
|
|
|
.imp();
|
|
|
|
SignallableImpl::start(this)
|
|
|
|
}
|
|
|
|
iface.start = vstart_trampoline::<Obj>;
|
|
|
|
|
|
|
|
fn vstop_trampoline<Obj: types::ObjectSubclass + SignallableImpl>(
|
|
|
|
this: &super::Signallable,
|
|
|
|
) {
|
|
|
|
let this = this
|
|
|
|
.dynamic_cast_ref::<<Obj as types::ObjectSubclass>::Type>()
|
|
|
|
.unwrap();
|
|
|
|
SignallableImpl::stop(this.imp())
|
|
|
|
}
|
|
|
|
iface.stop = vstop_trampoline::<Obj>;
|
|
|
|
|
|
|
|
fn send_sdp_trampoline<Obj: types::ObjectSubclass + SignallableImpl>(
|
|
|
|
this: &super::Signallable,
|
|
|
|
session_id: &str,
|
|
|
|
sdp: &gst_webrtc::WebRTCSessionDescription,
|
|
|
|
) {
|
|
|
|
let this = this
|
|
|
|
.dynamic_cast_ref::<<Obj as types::ObjectSubclass>::Type>()
|
|
|
|
.unwrap();
|
|
|
|
SignallableImpl::send_sdp(this.imp(), session_id, sdp)
|
|
|
|
}
|
|
|
|
iface.send_sdp = send_sdp_trampoline::<Obj>;
|
|
|
|
|
|
|
|
fn add_ice_trampoline<Obj: types::ObjectSubclass + SignallableImpl>(
|
|
|
|
this: &super::Signallable,
|
|
|
|
session_id: &str,
|
|
|
|
candidate: &str,
|
2023-03-21 05:16:16 +00:00
|
|
|
sdp_m_line_index: u32,
|
2022-07-12 21:13:38 +00:00
|
|
|
sdp_mid: Option<String>,
|
|
|
|
) {
|
|
|
|
let this = this
|
|
|
|
.dynamic_cast_ref::<<Obj as types::ObjectSubclass>::Type>()
|
|
|
|
.unwrap();
|
|
|
|
SignallableImpl::add_ice(this.imp(), session_id, candidate, sdp_m_line_index, sdp_mid)
|
|
|
|
}
|
|
|
|
iface.add_ice = add_ice_trampoline::<Obj>;
|
|
|
|
|
|
|
|
fn end_session_trampoline<Obj: types::ObjectSubclass + SignallableImpl>(
|
|
|
|
this: &super::Signallable,
|
|
|
|
session_id: &str,
|
|
|
|
) {
|
|
|
|
let this = this
|
|
|
|
.dynamic_cast_ref::<<Obj as types::ObjectSubclass>::Type>()
|
|
|
|
.unwrap();
|
|
|
|
SignallableImpl::end_session(this.imp(), session_id)
|
|
|
|
}
|
|
|
|
iface.end_session = end_session_trampoline::<Obj>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait SignallableImpl: object::ObjectImpl + 'static {
|
2023-03-21 05:09:44 +00:00
|
|
|
fn start(&self) {}
|
|
|
|
fn stop(&self) {}
|
|
|
|
fn send_sdp(&self, _session_id: &str, _sdp: &gst_webrtc::WebRTCSessionDescription) {}
|
2022-07-12 21:13:38 +00:00
|
|
|
fn add_ice(
|
|
|
|
&self,
|
2023-03-21 05:09:44 +00:00
|
|
|
_session_id: &str,
|
|
|
|
_candidate: &str,
|
2023-03-21 05:16:16 +00:00
|
|
|
_sdp_m_line_index: u32,
|
2023-03-21 05:09:44 +00:00
|
|
|
_sdp_mid: Option<String>,
|
2022-07-12 21:13:38 +00:00
|
|
|
) {
|
|
|
|
}
|
2023-03-21 05:09:44 +00:00
|
|
|
fn end_session(&self, _session_id: &str) {}
|
2022-07-12 21:13:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait SignallableExt: 'static {
|
|
|
|
fn start(&self);
|
|
|
|
fn stop(&self);
|
|
|
|
fn send_sdp(&self, session_id: &str, sdp: &gst_webrtc::WebRTCSessionDescription);
|
|
|
|
fn add_ice(
|
|
|
|
&self,
|
|
|
|
session_id: &str,
|
|
|
|
candidate: &str,
|
2023-03-21 05:16:16 +00:00
|
|
|
sdp_m_line_index: u32,
|
2022-07-12 21:13:38 +00:00
|
|
|
sdp_mid: Option<String>,
|
|
|
|
);
|
|
|
|
fn end_session(&self, session_id: &str);
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<Obj: glib::IsA<super::Signallable>> SignallableExt for Obj {
|
|
|
|
fn start(&self) {
|
2023-03-21 05:16:16 +00:00
|
|
|
self.emit_by_name::<bool>("start", &[]);
|
2022-07-12 21:13:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn stop(&self) {
|
2023-03-21 05:16:16 +00:00
|
|
|
self.emit_by_name::<bool>("stop", &[]);
|
2022-07-12 21:13:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn send_sdp(&self, session_id: &str, sdp: &gst_webrtc::WebRTCSessionDescription) {
|
2023-03-21 05:16:16 +00:00
|
|
|
self.emit_by_name::<bool>("send-session-description", &[&session_id, sdp]);
|
2022-07-12 21:13:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn add_ice(
|
|
|
|
&self,
|
|
|
|
session_id: &str,
|
|
|
|
candidate: &str,
|
2023-03-21 05:16:16 +00:00
|
|
|
sdp_m_line_index: u32,
|
2022-07-12 21:13:38 +00:00
|
|
|
sdp_mid: Option<String>,
|
|
|
|
) {
|
2023-03-21 05:16:16 +00:00
|
|
|
self.emit_by_name::<bool>(
|
|
|
|
"send-ice",
|
|
|
|
&[&session_id, &candidate, &sdp_m_line_index, &sdp_mid],
|
|
|
|
);
|
2022-07-12 21:13:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn end_session(&self, session_id: &str) {
|
2023-04-07 23:28:31 +00:00
|
|
|
self.emit_by_name::<bool>("end-session", &[&session_id]);
|
2022-07-12 21:13:38 +00:00
|
|
|
}
|
|
|
|
}
|