webrtc/signaller: remove SignallableImplExt

This pattern is used for subclassing and calling parent class/interface functions.
However that is not useful for the signaller object.
1. The signals are the API contract and should instead be used by
   webrtcsrc/sink to ask or provide outside for/with information.
2. The default case (no signal attached)is instead handled by default class
   handlers that call directly using the relevant rust trait.  No parent
   (GObject) vfuncs necessary.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1141>
This commit is contained in:
Matthew Waters 2023-03-21 16:09:44 +11:00
parent b6e78b5f04
commit 343b659755
2 changed files with 8 additions and 92 deletions

View file

@ -303,101 +303,18 @@ where
}
pub trait SignallableImpl: object::ObjectImpl + 'static {
fn start(&self) {
SignallableImplExt::parent_vstart(self)
}
fn stop(&self) {
SignallableImplExt::parent_vstop(self)
}
fn send_sdp(&self, session_id: &str, sdp: &gst_webrtc::WebRTCSessionDescription) {
SignallableImplExt::parent_send_sdp(self, session_id, sdp)
}
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,
sdp_m_line_index: Option<u32>,
sdp_mid: Option<String>,
_session_id: &str,
_candidate: &str,
_sdp_m_line_index: Option<u32>,
_sdp_mid: Option<String>,
) {
SignallableImplExt::parent_add_ice(self, session_id, candidate, sdp_m_line_index, sdp_mid)
}
fn end_session(&self, session_id: &str) {
SignallableImplExt::parent_end_session(self, session_id)
}
}
pub trait SignallableImplExt: types::ObjectSubclass {
fn parent_vstart(&self);
fn parent_vstop(&self);
fn parent_send_sdp(&self, session_id: &str, sdp: &gst_webrtc::WebRTCSessionDescription);
fn parent_add_ice(
&self,
session_id: &str,
candidate: &str,
sdp_m_line_index: Option<u32>,
sdp_mid: Option<String>,
);
fn parent_end_session(&self, session_id: &str);
}
type ClassType = *mut <super::Signallable as glib::object::ObjectType>::GlibClassType;
impl<Obj: SignallableImpl> SignallableImplExt for Obj {
fn parent_vstart(&self) {
let obj = self.obj();
let obj = unsafe { obj.unsafe_cast_ref::<super::Signallable>() };
let vtable = unsafe {
&*(Self::type_data()
.as_ref()
.parent_interface::<super::Signallable>() as ClassType)
};
(vtable.start)(obj)
}
fn parent_vstop(&self) {
let obj = self.obj();
let obj = unsafe { obj.unsafe_cast_ref::<super::Signallable>() };
let vtable = unsafe {
&*(Self::type_data()
.as_ref()
.parent_interface::<super::Signallable>() as ClassType)
};
(vtable.stop)(obj)
}
fn parent_send_sdp(&self, session_id: &str, sdp: &gst_webrtc::WebRTCSessionDescription) {
let obj = self.obj();
let obj = unsafe { obj.unsafe_cast_ref::<super::Signallable>() };
let vtable = unsafe {
&*(Self::type_data()
.as_ref()
.parent_interface::<super::Signallable>() as ClassType)
};
(vtable.send_sdp)(obj, session_id, sdp)
}
fn parent_add_ice(
&self,
session_id: &str,
candidate: &str,
sdp_m_line_index: Option<u32>,
sdp_mid: Option<String>,
) {
let obj = self.obj();
let obj = unsafe { obj.unsafe_cast_ref::<super::Signallable>() };
let vtable = unsafe {
&*(Self::type_data()
.as_ref()
.parent_interface::<super::Signallable>() as ClassType)
};
(vtable.add_ice)(obj, session_id, candidate, sdp_m_line_index, sdp_mid)
}
fn parent_end_session(&self, session_id: &str) {
let obj = self.obj();
let obj = unsafe { obj.unsafe_cast_ref::<super::Signallable>() };
let vtable = unsafe {
&*(Self::type_data()
.as_ref()
.parent_interface::<super::Signallable>() as ClassType)
};
(vtable.end_session)(obj, session_id)
}
fn end_session(&self, _session_id: &str) {}
}
pub trait SignallableExt: 'static {

View file

@ -40,7 +40,6 @@ impl Signaller {
pub use iface::SignallableExt;
pub use iface::SignallableImpl;
pub use iface::SignallableImplExt;
unsafe impl Send for Signallable {}
unsafe impl Sync for Signallable {}