diff --git a/Gir_GstGL.toml b/Gir_GstGL.toml index f99325414..896f31b08 100644 --- a/Gir_GstGL.toml +++ b/Gir_GstGL.toml @@ -152,6 +152,10 @@ status = "generate" [object.function.return] nullable = false + [[object.function]] + name = "set_window" + [object.function.return] + bool_return_is_error = "Failed to set window" [[object]] name = "GstGL.GLDisplay" @@ -217,6 +221,11 @@ status = "generate" # callback ignore = true + [[object.function]] + name = "set_render_rectangle" + [object.function.return] + bool_return_is_error = "Failed to set the specified region" + [[object.function]] name = "set_resize_callback" # callback @@ -242,6 +251,11 @@ name = "GstGL.GLColorConvert" status = "generate" final_type = true + [[object.function]] + name = "set_caps" + [object.function.return] + bool_return_is_error = "Failed to set caps" + [[object.function]] name = "decide_allocation" # correct mutability @@ -272,11 +286,26 @@ name = "GstGL.GLSLStage" status = "generate" final_type = true + [[object.function]] + name = "set_strings" + [object.function.return] + bool_return_is_error = "Failed to attach stage to set strings" + [[object]] name = "GstGL.GLShader" status = "generate" final_type = true + [[object.function]] + name = "attach" + [object.function.return] + bool_return_is_error = "Failed to attach stage to shader" + + [[object.function]] + name = "attach_unlocked" + [object.function.return] + bool_return_is_error = "Failed to attach stage to shader" + [[object.function]] name = "set_uniform_matrix_2fv" # array with size @@ -327,6 +356,11 @@ name = "GstGL.GLUpload" status = "generate" final_type = true + [[object.function]] + name = "set_caps" + [object.function.return] + bool_return_is_error = "Failed to set caps" + [[object.function]] name = "perform_with_buffer" # Result @@ -347,6 +381,11 @@ name = "GstGL.GLViewConvert" status = "generate" final_type = true + [[object.function]] + name = "set_caps" + [object.function.return] + bool_return_is_error = "Failed to set caps" + [[object.function]] name = "fixate_caps" # correct reference ownership diff --git a/Gir_GstRtspServer.toml b/Gir_GstRtspServer.toml index 6a0717a4c..4e048ccdb 100644 --- a/Gir_GstRtspServer.toml +++ b/Gir_GstRtspServer.toml @@ -110,6 +110,16 @@ status = "generate" name = "attach" ignore = true + [[object.function]] + name = "io_func" + [object.function.return] + bool_return_is_error = "Failed to connect the source" + + [[object.function]] + name = "transfer_connection" + [object.function.return] + bool_return_is_error = "Failed to transfer to the connection" + [[object]] name = "GstRtspServer.RTSPClient" status = "generate" @@ -160,6 +170,21 @@ status = "generate" [object.function.return] bool_return_is_error = "Failed to leave bin" + [[object.function]] + name = "set_blocked" + [object.function.return] + bool_return_is_error = "Failed to block/unblock the dataflow" + + [[object.function]] + name = "unblock_linked" + [object.function.return] + bool_return_is_error = "Failed to unblock the dataflow" + + [[object.function]] + name = "update_crypto" + [object.function.return] + bool_return_is_error = "Failed to update crypto" + [[object]] name = "GstRtspServer.RTSPAddress" status = "generate" @@ -258,6 +283,16 @@ status = "generate" name="GstRtspServer.RTSPAuth" status="generate" + [[object.function]] + name = "check" + [object.function.return] + bool_return_is_error = "Check failed" + + [[object.function]] + name = "connect_accept_certificate" + # Use Result<(), LoggableError> + ignore = true + [[object.function]] name = "make_basic" [object.function.return] diff --git a/gstreamer-check/src/auto/test_clock.rs b/gstreamer-check/src/auto/test_clock.rs index a28edafc5..c69a90df9 100644 --- a/gstreamer-check/src/auto/test_clock.rs +++ b/gstreamer-check/src/auto/test_clock.rs @@ -45,9 +45,12 @@ impl TestClock { } } - pub fn crank(&self) -> bool { + pub fn crank(&self) -> Result<(), glib::BoolError> { unsafe { - from_glib(ffi::gst_test_clock_crank(self.to_glib_none().0)) + glib_result_from_gboolean!( + ffi::gst_test_clock_crank(self.to_glib_none().0), + "Failed to crank" + ) } } diff --git a/gstreamer-gl/src/auto/gl_color_convert.rs b/gstreamer-gl/src/auto/gl_color_convert.rs index 9a8f4875c..292aaccbd 100644 --- a/gstreamer-gl/src/auto/gl_color_convert.rs +++ b/gstreamer-gl/src/auto/gl_color_convert.rs @@ -4,6 +4,7 @@ use GLContext; use ffi; +use glib; use glib::object::IsA; use glib::translate::*; use gst; @@ -24,9 +25,9 @@ impl GLColorConvert { } } - pub fn set_caps(&self, in_caps: &gst::Caps, out_caps: &gst::Caps) -> bool { + pub fn set_caps(&self, in_caps: &gst::Caps, out_caps: &gst::Caps) -> Result<(), glib::error::BoolError> { unsafe { - from_glib(ffi::gst_gl_color_convert_set_caps(self.to_glib_none().0, in_caps.to_glib_none().0, out_caps.to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_gl_color_convert_set_caps(self.to_glib_none().0, in_caps.to_glib_none().0, out_caps.to_glib_none().0), "Failed to set caps") } } diff --git a/gstreamer-gl/src/auto/gl_context.rs b/gstreamer-gl/src/auto/gl_context.rs index 326e8226a..b65f66250 100644 --- a/gstreamer-gl/src/auto/gl_context.rs +++ b/gstreamer-gl/src/auto/gl_context.rs @@ -93,7 +93,7 @@ pub trait GLContextExt: 'static { fn set_shared_with>(&self, share: &P); - fn set_window>(&self, window: &P) -> bool; + fn set_window>(&self, window: &P) -> Result<(), glib::error::BoolError>; fn supports_glsl_profile_version(&self, version: GLSLVersion, profile: GLSLProfile) -> bool; @@ -220,9 +220,9 @@ impl> GLContextExt for O { } } - fn set_window>(&self, window: &P) -> bool { + fn set_window>(&self, window: &P) -> Result<(), glib::error::BoolError> { unsafe { - from_glib(ffi::gst_gl_context_set_window(self.as_ref().to_glib_none().0, window.as_ref().to_glib_full())) + glib_result_from_gboolean!(ffi::gst_gl_context_set_window(self.as_ref().to_glib_none().0, window.as_ref().to_glib_full()), "Failed to set window") } } diff --git a/gstreamer-gl/src/auto/gl_shader.rs b/gstreamer-gl/src/auto/gl_shader.rs index 4b8a5bd51..422ddf453 100644 --- a/gstreamer-gl/src/auto/gl_shader.rs +++ b/gstreamer-gl/src/auto/gl_shader.rs @@ -6,6 +6,7 @@ use Error; use GLContext; use GLSLStage; use ffi; +use glib; use glib::StaticType; use glib::Value; use glib::object::IsA; @@ -53,15 +54,15 @@ impl GLShader { // unsafe { TODO: call ffi::gst_gl_shader_new_with_stages() } //} - pub fn attach(&self, stage: &GLSLStage) -> bool { + pub fn attach(&self, stage: &GLSLStage) -> Result<(), glib::error::BoolError> { unsafe { - from_glib(ffi::gst_gl_shader_attach(self.to_glib_none().0, stage.to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_gl_shader_attach(self.to_glib_none().0, stage.to_glib_none().0), "Failed to attach stage to shader") } } - pub fn attach_unlocked(&self, stage: &GLSLStage) -> bool { + pub fn attach_unlocked(&self, stage: &GLSLStage) -> Result<(), glib::error::BoolError> { unsafe { - from_glib(ffi::gst_gl_shader_attach_unlocked(self.to_glib_none().0, stage.to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_gl_shader_attach_unlocked(self.to_glib_none().0, stage.to_glib_none().0), "Failed to attach stage to shader") } } diff --git a/gstreamer-gl/src/auto/gl_upload.rs b/gstreamer-gl/src/auto/gl_upload.rs index f1714d5f7..faa54a42c 100644 --- a/gstreamer-gl/src/auto/gl_upload.rs +++ b/gstreamer-gl/src/auto/gl_upload.rs @@ -4,6 +4,7 @@ use GLContext; use ffi; +use glib; use glib::object::IsA; use glib::translate::*; use gst; @@ -34,9 +35,9 @@ impl GLUpload { } } - pub fn set_caps(&self, in_caps: &gst::Caps, out_caps: &gst::Caps) -> bool { + pub fn set_caps(&self, in_caps: &gst::Caps, out_caps: &gst::Caps) -> Result<(), glib::error::BoolError> { unsafe { - from_glib(ffi::gst_gl_upload_set_caps(self.to_glib_none().0, in_caps.to_glib_none().0, out_caps.to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_gl_upload_set_caps(self.to_glib_none().0, in_caps.to_glib_none().0, out_caps.to_glib_none().0), "Failed to set caps") } } diff --git a/gstreamer-gl/src/auto/gl_view_convert.rs b/gstreamer-gl/src/auto/gl_view_convert.rs index c96124ba7..5532683f8 100644 --- a/gstreamer-gl/src/auto/gl_view_convert.rs +++ b/gstreamer-gl/src/auto/gl_view_convert.rs @@ -5,6 +5,7 @@ use GLContext; use GLStereoDownmix; use ffi; +use glib; use glib::StaticType; use glib::Value; use glib::object::IsA; @@ -47,9 +48,9 @@ impl GLViewConvert { } } - pub fn set_caps(&self, in_caps: &gst::Caps, out_caps: &gst::Caps) -> bool { + pub fn set_caps(&self, in_caps: &gst::Caps, out_caps: &gst::Caps) -> Result<(), glib::error::BoolError> { unsafe { - from_glib(ffi::gst_gl_view_convert_set_caps(self.to_glib_none().0, in_caps.to_glib_none().0, out_caps.to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_gl_view_convert_set_caps(self.to_glib_none().0, in_caps.to_glib_none().0, out_caps.to_glib_none().0), "Failed to set caps") } } diff --git a/gstreamer-gl/src/auto/gl_window.rs b/gstreamer-gl/src/auto/gl_window.rs index 182174e81..25ab4a1f9 100644 --- a/gstreamer-gl/src/auto/gl_window.rs +++ b/gstreamer-gl/src/auto/gl_window.rs @@ -5,6 +5,7 @@ use GLContext; use GLDisplay; use ffi; +use glib; use glib::GString; use glib::object::Cast; use glib::object::IsA; @@ -63,7 +64,7 @@ pub trait GLWindowExt: 'static { fn set_preferred_size(&self, width: i32, height: i32); - fn set_render_rectangle(&self, x: i32, y: i32, width: i32, height: i32) -> bool; + fn set_render_rectangle(&self, x: i32, y: i32, width: i32, height: i32) -> Result<(), glib::error::BoolError>; fn show(&self); @@ -142,9 +143,9 @@ impl> GLWindowExt for O { } } - fn set_render_rectangle(&self, x: i32, y: i32, width: i32, height: i32) -> bool { + fn set_render_rectangle(&self, x: i32, y: i32, width: i32, height: i32) -> Result<(), glib::error::BoolError> { unsafe { - from_glib(ffi::gst_gl_window_set_render_rectangle(self.as_ref().to_glib_none().0, x, y, width, height)) + glib_result_from_gboolean!(ffi::gst_gl_window_set_render_rectangle(self.as_ref().to_glib_none().0, x, y, width, height), "Failed to set the specified region") } } diff --git a/gstreamer-gl/src/auto/glsl_stage.rs b/gstreamer-gl/src/auto/glsl_stage.rs index 8cb41433b..e33589083 100644 --- a/gstreamer-gl/src/auto/glsl_stage.rs +++ b/gstreamer-gl/src/auto/glsl_stage.rs @@ -7,6 +7,7 @@ use GLContext; use GLSLProfile; use GLSLVersion; use ffi; +use glib; use glib::GString; use glib::object::IsA; use glib::translate::*; @@ -90,10 +91,10 @@ impl GLSLStage { } } - pub fn set_strings(&self, version: GLSLVersion, profile: GLSLProfile, str: &[&str]) -> bool { + pub fn set_strings(&self, version: GLSLVersion, profile: GLSLProfile, str: &[&str]) -> Result<(), glib::error::BoolError> { let n_strings = str.len() as i32; unsafe { - from_glib(ffi::gst_glsl_stage_set_strings(self.to_glib_none().0, version.to_glib(), profile.to_glib(), n_strings, str.to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_glsl_stage_set_strings(self.to_glib_none().0, version.to_glib(), profile.to_glib(), n_strings, str.to_glib_none().0), "Failed to attach stage to set strings") } } } diff --git a/gstreamer-rtsp-server/src/auto/rtsp_auth.rs b/gstreamer-rtsp-server/src/auto/rtsp_auth.rs index 39f3f328d..bc7aef5c9 100644 --- a/gstreamer-rtsp-server/src/auto/rtsp_auth.rs +++ b/gstreamer-rtsp-server/src/auto/rtsp_auth.rs @@ -6,6 +6,7 @@ use RTSPToken; use ffi; use gio; use gio_ffi; +use glib; use glib::GString; use glib::object::Cast; use glib::object::IsA; @@ -34,10 +35,10 @@ impl RTSPAuth { } } - pub fn check(check: &str) -> bool { + pub fn check(check: &str) -> Result<(), glib::error::BoolError> { assert_initialized_main_thread!(); unsafe { - from_glib(ffi::gst_rtsp_auth_check(check.to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_rtsp_auth_check(check.to_glib_none().0), "Check failed") } } diff --git a/gstreamer-rtsp-server/src/auto/rtsp_server.rs b/gstreamer-rtsp-server/src/auto/rtsp_server.rs index 03a491282..a0fed793b 100644 --- a/gstreamer-rtsp-server/src/auto/rtsp_server.rs +++ b/gstreamer-rtsp-server/src/auto/rtsp_server.rs @@ -38,10 +38,10 @@ impl RTSPServer { } } - pub fn io_func, Q: IsA>(socket: &P, condition: glib::IOCondition, server: &Q) -> bool { + pub fn io_func, Q: IsA>(socket: &P, condition: glib::IOCondition, server: &Q) -> Result<(), glib::error::BoolError> { skip_assert_initialized!(); unsafe { - from_glib(ffi::gst_rtsp_server_io_func(socket.as_ref().to_glib_none().0, condition.to_glib(), server.as_ref().to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_rtsp_server_io_func(socket.as_ref().to_glib_none().0, condition.to_glib(), server.as_ref().to_glib_none().0), "Failed to connect the source") } } } @@ -94,7 +94,7 @@ pub trait RTSPServerExt: 'static { fn set_thread_pool<'a, P: IsA + 'a, Q: Into>>(&self, pool: Q); - fn transfer_connection<'a, P: IsA, Q: Into>>(&self, socket: &P, ip: &str, port: i32, initial_buffer: Q) -> bool; + fn transfer_connection<'a, P: IsA, Q: Into>>(&self, socket: &P, ip: &str, port: i32, initial_buffer: Q) -> Result<(), glib::error::BoolError>; fn connect_client_connected(&self, f: F) -> SignalHandlerId; @@ -228,10 +228,10 @@ impl> RTSPServerExt for O { } } - fn transfer_connection<'a, P: IsA, Q: Into>>(&self, socket: &P, ip: &str, port: i32, initial_buffer: Q) -> bool { + fn transfer_connection<'a, P: IsA, Q: Into>>(&self, socket: &P, ip: &str, port: i32, initial_buffer: Q) -> Result<(), glib::error::BoolError> { let initial_buffer = initial_buffer.into(); unsafe { - from_glib(ffi::gst_rtsp_server_transfer_connection(self.as_ref().to_glib_none().0, socket.as_ref().to_glib_full(), ip.to_glib_none().0, port, initial_buffer.to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_rtsp_server_transfer_connection(self.as_ref().to_glib_none().0, socket.as_ref().to_glib_full(), ip.to_glib_none().0, port, initial_buffer.to_glib_none().0), "Failed to transfer to the connection") } } diff --git a/gstreamer-rtsp-server/src/auto/rtsp_stream.rs b/gstreamer-rtsp-server/src/auto/rtsp_stream.rs index 501569a14..0cf69bebe 100644 --- a/gstreamer-rtsp-server/src/auto/rtsp_stream.rs +++ b/gstreamer-rtsp-server/src/auto/rtsp_stream.rs @@ -136,7 +136,7 @@ pub trait RTSPStreamExt: 'static { fn set_address_pool<'a, P: IsA + 'a, Q: Into>>(&self, pool: Q); - fn set_blocked(&self, blocked: bool) -> bool; + fn set_blocked(&self, blocked: bool) -> Result<(), glib::error::BoolError>; fn set_buffer_size(&self, size: u32); @@ -166,9 +166,9 @@ pub trait RTSPStreamExt: 'static { //fn transport_filter(&self, func: /*Unimplemented*/Fn(&RTSPStream, &RTSPStreamTransport) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option) -> Vec; - fn unblock_linked(&self) -> bool; + fn unblock_linked(&self) -> Result<(), glib::error::BoolError>; - fn update_crypto<'a, P: Into>>(&self, ssrc: u32, crypto: P) -> bool; + fn update_crypto<'a, P: Into>>(&self, ssrc: u32, crypto: P) -> Result<(), glib::error::BoolError>; fn connect_new_rtcp_encoder(&self, f: F) -> SignalHandlerId; @@ -453,9 +453,9 @@ impl> RTSPStreamExt for O { } } - fn set_blocked(&self, blocked: bool) -> bool { + fn set_blocked(&self, blocked: bool) -> Result<(), glib::error::BoolError> { unsafe { - from_glib(ffi::gst_rtsp_stream_set_blocked(self.as_ref().to_glib_none().0, blocked.to_glib())) + glib_result_from_gboolean!(ffi::gst_rtsp_stream_set_blocked(self.as_ref().to_glib_none().0, blocked.to_glib()), "Failed to block/unblock the dataflow") } } @@ -543,16 +543,16 @@ impl> RTSPStreamExt for O { // unsafe { TODO: call ffi::gst_rtsp_stream_transport_filter() } //} - fn unblock_linked(&self) -> bool { + fn unblock_linked(&self) -> Result<(), glib::error::BoolError> { unsafe { - from_glib(ffi::gst_rtsp_stream_unblock_linked(self.as_ref().to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_rtsp_stream_unblock_linked(self.as_ref().to_glib_none().0), "Failed to unblock the dataflow") } } - fn update_crypto<'a, P: Into>>(&self, ssrc: u32, crypto: P) -> bool { + fn update_crypto<'a, P: Into>>(&self, ssrc: u32, crypto: P) -> Result<(), glib::error::BoolError> { let crypto = crypto.into(); unsafe { - from_glib(ffi::gst_rtsp_stream_update_crypto(self.as_ref().to_glib_none().0, ssrc, crypto.to_glib_none().0)) + glib_result_from_gboolean!(ffi::gst_rtsp_stream_update_crypto(self.as_ref().to_glib_none().0, ssrc, crypto.to_glib_none().0), "Failed to update crypto") } } diff --git a/gstreamer-rtsp-server/src/rtsp_auth.rs b/gstreamer-rtsp-server/src/rtsp_auth.rs index 214e1822e..4316427ee 100644 --- a/gstreamer-rtsp-server/src/rtsp_auth.rs +++ b/gstreamer-rtsp-server/src/rtsp_auth.rs @@ -1,11 +1,33 @@ use ffi; +use glib::object::Cast; use glib::object::IsA; +use glib::signal::connect_raw; +use glib::signal::SignalHandlerId; use glib::translate::*; + +use std::boxed::Box as Box_; +use std::mem::transmute; + use RTSPAuth; use RTSPToken; pub trait RTSPAuthExtManual: 'static { fn set_default_token<'a, P: Into>>(&self, token: P); + + fn connect_accept_certificate< + F: Fn( + &Self, + &gio::TlsConnection, + &gio::TlsCertificate, + gio::TlsCertificateFlags, + ) -> Result<(), gst::LoggableError> + + Send + + Sync + + 'static, + >( + &self, + f: F, + ) -> SignalHandlerId; } impl> RTSPAuthExtManual for O { @@ -18,4 +40,66 @@ impl> RTSPAuthExtManual for O { ); } } + + fn connect_accept_certificate< + F: Fn( + &Self, + &gio::TlsConnection, + &gio::TlsCertificate, + gio::TlsCertificateFlags, + ) -> Result<(), gst::LoggableError> + + Send + + Sync + + 'static, + >( + &self, + f: F, + ) -> SignalHandlerId { + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"accept-certificate\0".as_ptr() as *const _, + Some(transmute(accept_certificate_trampoline:: as usize)), + Box_::into_raw(f), + ) + } + } +} + +unsafe extern "C" fn accept_certificate_trampoline< + P, + F: Fn( + &P, + &gio::TlsConnection, + &gio::TlsCertificate, + gio::TlsCertificateFlags, + ) -> Result<(), gst::LoggableError> + + Send + + Sync + + 'static, +>( + this: *mut ffi::GstRTSPAuth, + connection: *mut gio_ffi::GTlsConnection, + peer_cert: *mut gio_ffi::GTlsCertificate, + errors: gio_ffi::GTlsCertificateFlags, + f: glib_ffi::gpointer, +) -> glib_ffi::gboolean +where + P: IsA, +{ + let f: &F = transmute(f); + match f( + &RTSPAuth::from_glib_borrow(this).unsafe_cast(), + &from_glib_borrow(connection), + &from_glib_borrow(peer_cert), + from_glib(errors), + ) { + Ok(()) => true, + Err(err) => { + err.log(); + false + } + } + .to_glib() }