From 343b65975501fc296cd7effa291f8f2cee215ced Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Tue, 21 Mar 2023 16:09:44 +1100 Subject: [PATCH] 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: --- net/webrtc/src/signaller/iface.rs | 99 +++---------------------------- net/webrtc/src/signaller/mod.rs | 1 - 2 files changed, 8 insertions(+), 92 deletions(-) diff --git a/net/webrtc/src/signaller/iface.rs b/net/webrtc/src/signaller/iface.rs index d8a1d6bd..d5b73631 100644 --- a/net/webrtc/src/signaller/iface.rs +++ b/net/webrtc/src/signaller/iface.rs @@ -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, - sdp_mid: Option, + _session_id: &str, + _candidate: &str, + _sdp_m_line_index: Option, + _sdp_mid: Option, ) { - 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, - sdp_mid: Option, - ); - fn parent_end_session(&self, session_id: &str); -} - -type ClassType = *mut ::GlibClassType; -impl SignallableImplExt for Obj { - fn parent_vstart(&self) { - let obj = self.obj(); - let obj = unsafe { obj.unsafe_cast_ref::() }; - let vtable = unsafe { - &*(Self::type_data() - .as_ref() - .parent_interface::() as ClassType) - }; - (vtable.start)(obj) - } - fn parent_vstop(&self) { - let obj = self.obj(); - let obj = unsafe { obj.unsafe_cast_ref::() }; - let vtable = unsafe { - &*(Self::type_data() - .as_ref() - .parent_interface::() 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::() }; - let vtable = unsafe { - &*(Self::type_data() - .as_ref() - .parent_interface::() as ClassType) - }; - (vtable.send_sdp)(obj, session_id, sdp) - } - fn parent_add_ice( - &self, - session_id: &str, - candidate: &str, - sdp_m_line_index: Option, - sdp_mid: Option, - ) { - let obj = self.obj(); - let obj = unsafe { obj.unsafe_cast_ref::() }; - let vtable = unsafe { - &*(Self::type_data() - .as_ref() - .parent_interface::() 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::() }; - let vtable = unsafe { - &*(Self::type_data() - .as_ref() - .parent_interface::() as ClassType) - }; - (vtable.end_session)(obj, session_id) } + fn end_session(&self, _session_id: &str) {} } pub trait SignallableExt: 'static { diff --git a/net/webrtc/src/signaller/mod.rs b/net/webrtc/src/signaller/mod.rs index ef337be3..d487feee 100644 --- a/net/webrtc/src/signaller/mod.rs +++ b/net/webrtc/src/signaller/mod.rs @@ -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 {}