From fe038b7a14b663b66818cc103006d9d92324de2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 9 Mar 2023 18:22:25 +0200 Subject: [PATCH] rtsp-server: Work around `GstRTSPClientClass` ABI breakage in 1.18 Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/455 Part-of: --- .../src/subclass/rtsp_client.rs | 230 ++++++++++++++++++ 1 file changed, 230 insertions(+) diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs index 14ad322a4..8792e4024 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_client.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_client.rs @@ -736,6 +736,236 @@ unsafe impl IsSubclassable for RTSPClient { fn class_init(klass: &mut glib::Class) { Self::parent_class_init::(klass); let klass = klass.as_mut(); + + // There was unintentional ABI breakage in 1.18 so let's work around that + // for now by casting to the old struct layout. + #[cfg(not(feature = "v1_18"))] + { + if gst::version() < (1, 18, 0, 0) { + #[derive(Copy, Clone)] + #[repr(C)] + pub struct CompatClass { + pub parent_class: glib::gobject_ffi::GObjectClass, + pub create_sdp: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPMedia, + ) + -> *mut gst_sdp::ffi::GstSDPMessage, + >, + pub configure_client_media: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPMedia, + *mut ffi::GstRTSPStream, + *mut ffi::GstRTSPContext, + ) -> glib::ffi::gboolean, + >, + pub configure_client_transport: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + *mut gst_rtsp::ffi::GstRTSPTransport, + ) -> glib::ffi::gboolean, + >, + pub params_set: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPResult, + >, + pub params_get: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPResult, + >, + pub make_path_from_uri: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *const gst_rtsp::ffi::GstRTSPUrl, + ) -> *mut libc::c_char, + >, + pub closed: Option, + pub new_session: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPSession), + >, + pub options_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub describe_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub setup_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub play_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub pause_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub teardown_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub set_parameter_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub get_parameter_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub handle_response: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub tunnel_http_response: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut gst_rtsp::ffi::GstRTSPMessage, + *mut gst_rtsp::ffi::GstRTSPMessage, + ), + >, + pub send_message: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + *mut gst_rtsp::ffi::GstRTSPMessage, + ), + >, + pub handle_sdp: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + *mut ffi::GstRTSPMedia, + *mut gst_sdp::ffi::GstSDPMessage, + ) -> glib::ffi::gboolean, + >, + pub announce_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub record_request: Option< + unsafe extern "C" fn(*mut ffi::GstRTSPClient, *mut ffi::GstRTSPContext), + >, + pub check_requirements: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + *mut *mut libc::c_char, + ) -> *mut libc::c_char, + >, + pub pre_options_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub pre_describe_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub pre_setup_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub pre_play_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub pre_pause_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub pre_teardown_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub pre_set_parameter_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub pre_get_parameter_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub pre_announce_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub pre_record_request: Option< + unsafe extern "C" fn( + *mut ffi::GstRTSPClient, + *mut ffi::GstRTSPContext, + ) + -> gst_rtsp::ffi::GstRTSPStatusCode, + >, + pub _gst_reserved: [glib::ffi::gpointer; 4], + } + + let klass = unsafe { + std::mem::transmute::<&mut ffi::GstRTSPClientClass, &mut CompatClass>(klass) + }; + + klass.create_sdp = Some(client_create_sdp::); + klass.configure_client_media = Some(client_configure_client_media::); + klass.params_set = Some(client_params_set::); + klass.params_get = Some(client_params_get::); + klass.make_path_from_uri = Some(client_make_path_from_uri::); + klass.closed = Some(client_closed::); + klass.new_session = Some(client_new_session::); + klass.options_request = Some(client_options_request::); + klass.describe_request = Some(client_describe_request::); + klass.setup_request = Some(client_setup_request::); + klass.play_request = Some(client_play_request::); + klass.pause_request = Some(client_pause_request::); + klass.teardown_request = Some(client_teardown_request::); + klass.set_parameter_request = Some(client_set_parameter_request::); + klass.get_parameter_request = Some(client_get_parameter_request::); + klass.announce_request = Some(client_announce_request::); + klass.record_request = Some(client_record_request::); + klass.handle_response = Some(client_handle_response::); + klass.handle_sdp = Some(client_handle_sdp::); + klass.check_requirements = Some(client_check_requirements::); + klass.pre_options_request = Some(client_pre_options_request::); + klass.pre_describe_request = Some(client_pre_describe_request::); + klass.pre_setup_request = Some(client_pre_setup_request::); + klass.pre_play_request = Some(client_pre_play_request::); + klass.pre_pause_request = Some(client_pre_pause_request::); + klass.pre_teardown_request = Some(client_pre_teardown_request::); + klass.pre_set_parameter_request = Some(client_pre_set_parameter_request::); + 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::); + + return; + } + } + klass.create_sdp = Some(client_create_sdp::); klass.configure_client_media = Some(client_configure_client_media::); klass.params_set = Some(client_params_set::);