From b9e4b91a3dca94c7007372621981feede62ff1a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 12 Oct 2022 15:09:47 +0300 Subject: [PATCH] rtsp-server: Add bindings for new `RTSPClientImpl::adjust_error_code()` --- .../src/subclass/rtsp_client.rs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs index 1bba5c39e..8f66dfa0e 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs @@ -147,6 +147,16 @@ pub trait RTSPClientImpl: RTSPClientImplExt + ObjectImpl + Send + Sync { fn pre_record_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode { self.parent_pre_record_request(ctx) } + + #[cfg(any(feature = "v1_22", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] + fn adjust_error_code( + &self, + ctx: &crate::RTSPContext, + status_code: gst_rtsp::RTSPStatusCode, + ) -> gst_rtsp::RTSPStatusCode { + self.parent_adjust_error_code(ctx, status_code) + } } pub trait RTSPClientImplExt: ObjectSubclass { @@ -234,6 +244,14 @@ pub trait RTSPClientImplExt: ObjectSubclass { fn parent_pre_announce_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; fn parent_pre_record_request(&self, ctx: &crate::RTSPContext) -> gst_rtsp::RTSPStatusCode; + + #[cfg(any(feature = "v1_22", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] + fn parent_adjust_error_code( + &self, + ctx: &crate::RTSPContext, + status_code: gst_rtsp::RTSPStatusCode, + ) -> gst_rtsp::RTSPStatusCode; } impl RTSPClientImplExt for T { @@ -786,6 +804,31 @@ impl RTSPClientImplExt for T { } } } + + #[cfg(any(feature = "v1_22", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] + fn parent_adjust_error_code( + &self, + ctx: &crate::RTSPContext, + status_code: gst_rtsp::RTSPStatusCode, + ) -> gst_rtsp::RTSPStatusCode { + unsafe { + let data = Self::type_data(); + let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPClientClass; + if let Some(f) = (*parent_class).adjust_error_code { + from_glib(f( + self.instance() + .unsafe_cast_ref::() + .to_glib_none() + .0, + ctx.to_glib_none().0, + status_code.into_glib(), + )) + } else { + gst_rtsp::RTSPStatusCode::Ok + } + } + } } unsafe impl IsSubclassable for RTSPClient { fn class_init(klass: &mut glib::Class) { @@ -821,6 +864,11 @@ unsafe impl IsSubclassable for RTSPClient { klass.pre_get_parameter_request = Some(client_pre_get_parameter_request::); klass.pre_announce_request = Some(client_pre_announce_request::); klass.pre_record_request = Some(client_pre_record_request::); + #[cfg(any(feature = "v1_22", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] + { + klass.adjust_error_code = Some(client_adjust_error_code::); + } } } @@ -1152,3 +1200,17 @@ unsafe extern "C" fn client_pre_record_request( imp.pre_record_request(&from_glib_borrow(ctx)).into_glib() } + +#[cfg(any(feature = "v1_22", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] +unsafe extern "C" fn client_adjust_error_code( + ptr: *mut ffi::GstRTSPClient, + ctx: *mut ffi::GstRTSPContext, + status_code: gst_rtsp::ffi::GstRTSPStatusCode, +) -> gst_rtsp::ffi::GstRTSPStatusCode { + let instance = &*(ptr as *mut T::Instance); + let imp = instance.imp(); + + imp.adjust_error_code(&from_glib_borrow(ctx), from_glib(status_code)) + .into_glib() +}