From c1d3ed5eac20b148aa446b11420ce35b34d24837 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 6 May 2022 21:41:15 +0200 Subject: [PATCH] Use IntoGlibPtr trait instead of implementing `into_ptr` --- gstreamer-app/src/app_src.rs | 4 +-- gstreamer-audio/src/audio_decoder.rs | 4 +-- gstreamer-audio/src/audio_encoder.rs | 2 +- gstreamer-audio/src/functions.rs | 6 ++-- .../src/subclass/audio_aggregator.rs | 2 +- .../src/subclass/audio_aggregator_pad.rs | 2 +- gstreamer-audio/src/subclass/audio_decoder.rs | 8 ++--- gstreamer-audio/src/subclass/audio_encoder.rs | 8 ++--- gstreamer-base/src/adapter.rs | 2 +- gstreamer-base/src/aggregator.rs | 4 +-- gstreamer-base/src/base_parse_frame.rs | 2 +- gstreamer-base/src/subclass/aggregator.rs | 20 ++++++------ gstreamer-base/src/subclass/base_sink.rs | 8 ++--- gstreamer-base/src/subclass/base_src.rs | 10 +++--- gstreamer-base/src/subclass/base_transform.rs | 16 +++++----- gstreamer-base/src/subclass/push_src.rs | 4 +-- gstreamer-check/src/harness.rs | 19 +++++++---- gstreamer-gl/src/subclass/gl_filter.rs | 2 +- gstreamer-player/src/config.rs | 4 ++- gstreamer-player/src/player.rs | 2 +- gstreamer-rtp/src/rtp_base_depayload.rs | 4 +-- gstreamer-rtp/src/rtp_base_payload.rs | 4 +-- .../src/subclass/rtp_base_depayload.rs | 4 +-- .../src/subclass/rtp_base_payload.rs | 6 ++-- gstreamer-video/src/navigation.rs | 12 +++++-- gstreamer-video/src/subclass/navigation.rs | 4 +-- .../src/subclass/video_aggregator.rs | 4 +-- gstreamer-video/src/subclass/video_decoder.rs | 4 +-- gstreamer-video/src/subclass/video_encoder.rs | 4 +-- gstreamer-video/src/video_codec_frame.rs | 7 ++-- gstreamer-video/src/video_converter.rs | 8 +++-- gstreamer-video/src/video_decoder.rs | 9 ++++-- gstreamer-video/src/video_encoder.rs | 4 +-- gstreamer-video/src/video_meta.rs | 4 +-- gstreamer/src/buffer.rs | 18 ++++++----- gstreamer/src/buffer_pool.rs | 7 ++-- gstreamer/src/bufferlist.rs | 6 ++-- gstreamer/src/caps.rs | 32 ++++++++++++------- gstreamer/src/caps_features.rs | 4 ++- gstreamer/src/element.rs | 9 ++++-- gstreamer/src/event.rs | 19 ++++++----- gstreamer/src/iterator.rs | 19 +++++++---- gstreamer/src/memory.rs | 8 ++--- gstreamer/src/message.rs | 16 +++++----- gstreamer/src/meta.rs | 3 +- gstreamer/src/miniobject.rs | 10 ++++-- gstreamer/src/pad.rs | 26 +++++++-------- gstreamer/src/plugin.rs | 2 +- gstreamer/src/promise.rs | 2 +- gstreamer/src/proxy_pad.rs | 4 +-- gstreamer/src/query.rs | 2 +- gstreamer/src/sample.rs | 9 ++++-- gstreamer/src/structure.rs | 12 ++++--- gstreamer/src/subclass/bin.rs | 2 +- gstreamer/src/subclass/buffer_pool.rs | 8 ++--- gstreamer/src/subclass/element.rs | 4 +-- gstreamer/src/subclass/task_pool.rs | 4 +-- gstreamer/src/subclass/uri_handler.rs | 2 +- gstreamer/src/toc.rs | 11 ++++--- 59 files changed, 252 insertions(+), 194 deletions(-) diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index b487aa760..d71618691 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -210,7 +210,7 @@ impl AppSrc { unsafe { try_from_glib(ffi::gst_app_src_push_buffer( self.to_glib_none().0, - buffer.into_ptr(), + buffer.into_glib_ptr(), )) } } @@ -223,7 +223,7 @@ impl AppSrc { unsafe { try_from_glib(ffi::gst_app_src_push_buffer_list( self.to_glib_none().0, - list.into_ptr(), + list.into_glib_ptr(), )) } } diff --git a/gstreamer-audio/src/audio_decoder.rs b/gstreamer-audio/src/audio_decoder.rs index ae95c3dd3..8d8bb4381 100644 --- a/gstreamer-audio/src/audio_decoder.rs +++ b/gstreamer-audio/src/audio_decoder.rs @@ -72,7 +72,7 @@ impl> AudioDecoderExtManual for O { unsafe { try_from_glib(ffi::gst_audio_decoder_finish_frame( self.as_ref().to_glib_none().0, - buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()), + buffer.map(|b| b.into_glib_ptr()).unwrap_or(ptr::null_mut()), frames, )) } @@ -88,7 +88,7 @@ impl> AudioDecoderExtManual for O { unsafe { try_from_glib(ffi::gst_audio_decoder_finish_subframe( self.as_ref().to_glib_none().0, - buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()), + buffer.map(|b| b.into_glib_ptr()).unwrap_or(ptr::null_mut()), )) } } diff --git a/gstreamer-audio/src/audio_encoder.rs b/gstreamer-audio/src/audio_encoder.rs index 8ea3814ca..f9bb5c8fd 100644 --- a/gstreamer-audio/src/audio_encoder.rs +++ b/gstreamer-audio/src/audio_encoder.rs @@ -38,7 +38,7 @@ impl> AudioEncoderExtManual for O { unsafe { try_from_glib(ffi::gst_audio_encoder_finish_frame( self.as_ref().to_glib_none().0, - buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()), + buffer.map(|b| b.into_glib_ptr()).unwrap_or(ptr::null_mut()), frames, )) } diff --git a/gstreamer-audio/src/functions.rs b/gstreamer-audio/src/functions.rs index 4912f6599..284d59b42 100644 --- a/gstreamer-audio/src/functions.rs +++ b/gstreamer-audio/src/functions.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::translate::{from_glib_full, ToGlibPtr}; +use glib::translate::{from_glib_full, IntoGlibPtr, ToGlibPtr}; use glib::ToSendValue; use std::i32; @@ -16,7 +16,7 @@ pub fn audio_buffer_clip( unsafe { from_glib_full(ffi::gst_audio_buffer_clip( - buffer.into_ptr(), + buffer.into_glib_ptr(), segment.to_glib_none().0, rate as i32, bpf as i32, @@ -37,7 +37,7 @@ pub fn audio_buffer_truncate( unsafe { from_glib_full(ffi::gst_audio_buffer_truncate( - buffer.into_ptr(), + buffer.into_glib_ptr(), bpf as i32, trim, samples.unwrap_or(std::usize::MAX), diff --git a/gstreamer-audio/src/subclass/audio_aggregator.rs b/gstreamer-audio/src/subclass/audio_aggregator.rs index 4ce58c9a1..ff17821ff 100644 --- a/gstreamer-audio/src/subclass/audio_aggregator.rs +++ b/gstreamer-audio/src/subclass/audio_aggregator.rs @@ -129,7 +129,7 @@ unsafe extern "C" fn audio_aggregator_create_output_buffer AudioDecoderImplExt for T { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass; if let Some(f) = (*parent_class).pre_push { - let mut buffer = buffer.into_ptr(); + let mut buffer = buffer.into_glib_ptr(); gst::FlowSuccess::try_from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, &mut buffer, @@ -418,7 +418,7 @@ impl AudioDecoderImplExt for T { .expect("Missing parent function `sink_event`"); from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -446,7 +446,7 @@ impl AudioDecoderImplExt for T { .expect("Missing parent function `src_event`"); from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -691,7 +691,7 @@ unsafe extern "C" fn audio_decoder_pre_push( gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) { Ok(Some(new_buffer)) => { - *buffer = new_buffer.into_ptr(); + *buffer = new_buffer.into_glib_ptr(); Ok(gst::FlowSuccess::Ok) } Ok(None) => { diff --git a/gstreamer-audio/src/subclass/audio_encoder.rs b/gstreamer-audio/src/subclass/audio_encoder.rs index 810fa6679..2193f3d49 100644 --- a/gstreamer-audio/src/subclass/audio_encoder.rs +++ b/gstreamer-audio/src/subclass/audio_encoder.rs @@ -299,7 +299,7 @@ impl AudioEncoderImplExt for T { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass; if let Some(f) = (*parent_class).pre_push { - let mut buffer = buffer.into_ptr(); + let mut buffer = buffer.into_glib_ptr(); gst::FlowSuccess::try_from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, &mut buffer, @@ -368,7 +368,7 @@ impl AudioEncoderImplExt for T { .expect("Missing parent function `sink_event`"); from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -396,7 +396,7 @@ impl AudioEncoderImplExt for T { .expect("Missing parent function `src_event`"); from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -614,7 +614,7 @@ unsafe extern "C" fn audio_encoder_pre_push( gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) { Ok(Some(new_buffer)) => { - *buffer = new_buffer.into_ptr(); + *buffer = new_buffer.into_glib_ptr(); Ok(gst::FlowSuccess::Ok) } Ok(None) => { diff --git a/gstreamer-base/src/adapter.rs b/gstreamer-base/src/adapter.rs index da0eb50f7..06bab7f19 100644 --- a/gstreamer-base/src/adapter.rs +++ b/gstreamer-base/src/adapter.rs @@ -234,7 +234,7 @@ impl Adapter { #[doc(alias = "gst_adapter_push")] pub fn push(&self, buf: gst::Buffer) { unsafe { - ffi::gst_adapter_push(self.to_glib_none().0, buf.into_ptr()); + ffi::gst_adapter_push(self.to_glib_none().0, buf.into_glib_ptr()); } } } diff --git a/gstreamer-base/src/aggregator.rs b/gstreamer-base/src/aggregator.rs index cff94729e..eee4d91c3 100644 --- a/gstreamer-base/src/aggregator.rs +++ b/gstreamer-base/src/aggregator.rs @@ -106,7 +106,7 @@ impl> AggregatorExtManual for O { unsafe { try_from_glib(ffi::gst_aggregator_finish_buffer( self.as_ref().to_glib_none().0, - buffer.into_ptr(), + buffer.into_glib_ptr(), )) } } @@ -120,7 +120,7 @@ impl> AggregatorExtManual for O { unsafe { try_from_glib(ffi::gst_aggregator_finish_buffer_list( self.as_ref().to_glib_none().0, - bufferlist.into_ptr(), + bufferlist.into_glib_ptr(), )) } } diff --git a/gstreamer-base/src/base_parse_frame.rs b/gstreamer-base/src/base_parse_frame.rs index 3849eb766..9b3f9b022 100644 --- a/gstreamer-base/src/base_parse_frame.rs +++ b/gstreamer-base/src/base_parse_frame.rs @@ -149,7 +149,7 @@ impl<'a> BaseParseFrame<'a> { gst::ffi::gst_mini_object_unref(prev as *mut gst::ffi::GstMiniObject); } - let ptr = output_buffer.into_ptr(); + let ptr = output_buffer.into_glib_ptr(); let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable( ptr as *const gst::ffi::GstMiniObject, )); diff --git a/gstreamer-base/src/subclass/aggregator.rs b/gstreamer-base/src/subclass/aggregator.rs index d92e3a703..945638237 100644 --- a/gstreamer-base/src/subclass/aggregator.rs +++ b/gstreamer-base/src/subclass/aggregator.rs @@ -343,7 +343,7 @@ impl AggregatorImplExt for T { Some(ref func) => from_glib_full(func( aggregator.unsafe_cast_ref::().to_glib_none().0, aggregator_pad.to_glib_none().0, - buffer.into_ptr(), + buffer.into_glib_ptr(), )), } } @@ -362,7 +362,7 @@ impl AggregatorImplExt for T { .expect("Missing parent function `finish_buffer`"); try_from_glib(f( aggregator.unsafe_cast_ref::().to_glib_none().0, - buffer.into_ptr(), + buffer.into_glib_ptr(), )) } } @@ -382,7 +382,7 @@ impl AggregatorImplExt for T { .expect("Missing parent function `finish_buffer_list`"); try_from_glib(f( aggregator.unsafe_cast_ref::().to_glib_none().0, - buffer_list.into_ptr(), + buffer_list.into_glib_ptr(), )) } } @@ -402,7 +402,7 @@ impl AggregatorImplExt for T { from_glib(f( aggregator.unsafe_cast_ref::().to_glib_none().0, aggregator_pad.to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -424,7 +424,7 @@ impl AggregatorImplExt for T { try_from_glib(f( aggregator.unsafe_cast_ref::().to_glib_none().0, aggregator_pad.to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -480,7 +480,7 @@ impl AggregatorImplExt for T { .expect("Missing parent function `src_event`"); from_glib(f( aggregator.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -659,7 +659,7 @@ impl AggregatorImplExt for T { .expect("Missing parent function `fixate_src_caps`"); from_glib_full(f( aggregator.unsafe_cast_ref::().to_glib_none().0, - caps.into_ptr(), + caps.into_glib_ptr(), )) } } @@ -847,7 +847,7 @@ unsafe extern "C" fn aggregator_clip( ) }); - ret.map(|r| r.into_ptr()).unwrap_or(ptr::null_mut()) + ret.map(|r| r.into_glib_ptr()).unwrap_or(ptr::null_mut()) } unsafe extern "C" fn aggregator_finish_buffer( @@ -1117,7 +1117,7 @@ unsafe extern "C" fn aggregator_update_src_caps( gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { match imp.update_src_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) { Ok(res_caps) => { - *res = res_caps.into_ptr(); + *res = res_caps.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => err.into(), @@ -1137,7 +1137,7 @@ unsafe extern "C" fn aggregator_fixate_src_caps( gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), { imp.fixate_src_caps(wrap.unsafe_cast_ref(), from_glib_full(caps)) }) - .into_ptr() + .into_glib_ptr() } unsafe extern "C" fn aggregator_negotiated_src_caps( diff --git a/gstreamer-base/src/subclass/base_sink.rs b/gstreamer-base/src/subclass/base_sink.rs index d96a5ec62..9926b49b0 100644 --- a/gstreamer-base/src/subclass/base_sink.rs +++ b/gstreamer-base/src/subclass/base_sink.rs @@ -297,7 +297,7 @@ impl BaseSinkImplExt for T { .map(|f| { from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) }) .unwrap_or(true) @@ -353,7 +353,7 @@ impl BaseSinkImplExt for T { match (*parent_class).fixate { Some(fixate) => from_glib_full(fixate( element.unsafe_cast_ref::().to_glib_none().0, - caps.into_ptr(), + caps.into_glib_ptr(), )), None => caps, } @@ -585,7 +585,7 @@ unsafe extern "C" fn base_sink_get_caps( gst::panic_to_error!(&wrap, imp.panicked(), None, { imp.caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref()) }) - .map(|caps| caps.into_ptr()) + .map(|caps| caps.into_glib_ptr()) .unwrap_or(ptr::null_mut()) } @@ -622,7 +622,7 @@ unsafe extern "C" fn base_sink_fixate( gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), { imp.fixate(wrap.unsafe_cast_ref(), caps) }) - .into_ptr() + .into_glib_ptr() } unsafe extern "C" fn base_sink_unlock( diff --git a/gstreamer-base/src/subclass/base_src.rs b/gstreamer-base/src/subclass/base_src.rs index cdc5d2a05..ed90d80d9 100644 --- a/gstreamer-base/src/subclass/base_src.rs +++ b/gstreamer-base/src/subclass/base_src.rs @@ -536,7 +536,7 @@ impl BaseSrcImplExt for T { match (*parent_class).fixate { Some(fixate) => from_glib_full(fixate( element.unsafe_cast_ref::().to_glib_none().0, - caps.into_ptr(), + caps.into_glib_ptr(), )), None => caps, } @@ -759,7 +759,7 @@ unsafe extern "C" fn base_src_alloc( gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { match imp.alloc(wrap.unsafe_cast_ref(), offset, length) { Ok(buffer) => { - *buffer_ptr = buffer.into_ptr(); + *buffer_ptr = buffer.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => gst::FlowReturn::from(err), @@ -844,7 +844,7 @@ unsafe extern "C" fn base_src_create( gst::FlowReturn::Ok } } else { - *buffer_ptr = new_buffer.into_ptr(); + *buffer_ptr = new_buffer.into_glib_ptr(); gst::FlowReturn::Ok } } @@ -914,7 +914,7 @@ unsafe extern "C" fn base_src_get_caps( gst::panic_to_error!(&wrap, imp.panicked(), None, { imp.caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref()) }) - .map(|caps| caps.into_ptr()) + .map(|caps| caps.into_glib_ptr()) .unwrap_or(ptr::null_mut()) } @@ -970,7 +970,7 @@ unsafe extern "C" fn base_src_fixate( gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), { imp.fixate(wrap.unsafe_cast_ref(), caps) }) - .into_ptr() + .into_glib_ptr() } unsafe extern "C" fn base_src_unlock( diff --git a/gstreamer-base/src/subclass/base_transform.rs b/gstreamer-base/src/subclass/base_transform.rs index 95b6b2a8d..bcbf9631b 100644 --- a/gstreamer-base/src/subclass/base_transform.rs +++ b/gstreamer-base/src/subclass/base_transform.rs @@ -415,7 +415,7 @@ impl BaseTransformImplExt for T { element.unsafe_cast_ref::().to_glib_none().0, direction.into_glib(), caps.to_glib_none().0, - othercaps.into_ptr(), + othercaps.into_glib_ptr(), )), None => othercaps, } @@ -565,7 +565,7 @@ impl BaseTransformImplExt for T { .map(|f| { from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) }) .unwrap_or(true) @@ -581,7 +581,7 @@ impl BaseTransformImplExt for T { .map(|f| { from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) }) .unwrap_or(true) @@ -844,7 +844,7 @@ impl BaseTransformImplExt for T { try_from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, is_discont.into_glib(), - inbuf.into_ptr(), + inbuf.into_glib_ptr(), )) } } @@ -1032,7 +1032,7 @@ unsafe extern "C" fn base_transform_transform_caps( filter.as_ref().as_ref(), ) }) - .map(|caps| caps.into_ptr()) + .map(|caps| caps.into_glib_ptr()) .unwrap_or(std::ptr::null_mut()) } @@ -1054,7 +1054,7 @@ unsafe extern "C" fn base_transform_fixate_caps( from_glib_full(othercaps), ) }) - .into_ptr() + .into_glib_ptr() } unsafe extern "C" fn base_transform_set_caps( @@ -1208,7 +1208,7 @@ unsafe extern "C" fn base_transform_prepare_output_buffer( !is_passthrough, "Returning Buffer not allowed for passthrough mode" ); - *outbuf = buf.into_ptr(); + *outbuf = buf.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => err.into(), @@ -1451,7 +1451,7 @@ unsafe extern "C" fn base_transform_generate_output( Ok(GenerateOutputSuccess::Dropped) => crate::BASE_TRANSFORM_FLOW_DROPPED.into(), Ok(GenerateOutputSuccess::NoOutput) => gst::FlowReturn::Ok, Ok(GenerateOutputSuccess::Buffer(outbuf)) => { - *buf = outbuf.into_ptr(); + *buf = outbuf.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => err.into(), diff --git a/gstreamer-base/src/subclass/push_src.rs b/gstreamer-base/src/subclass/push_src.rs index 2f26d7729..9bd54c029 100644 --- a/gstreamer-base/src/subclass/push_src.rs +++ b/gstreamer-base/src/subclass/push_src.rs @@ -211,7 +211,7 @@ unsafe extern "C" fn push_src_alloc( gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { match PushSrcImpl::alloc(imp, wrap.unsafe_cast_ref()) { Ok(buffer) => { - *buffer_ptr = buffer.into_ptr(); + *buffer_ptr = buffer.into_glib_ptr(); gst::FlowReturn::Ok } Err(err) => gst::FlowReturn::from(err), @@ -289,7 +289,7 @@ unsafe extern "C" fn push_src_create( gst::FlowReturn::Ok } } else { - *buffer_ptr = new_buffer.into_ptr(); + *buffer_ptr = new_buffer.into_glib_ptr(); gst::FlowReturn::Ok } } diff --git a/gstreamer-check/src/harness.rs b/gstreamer-check/src/harness.rs index 9bc4f9e30..07ad61c7b 100644 --- a/gstreamer-check/src/harness.rs +++ b/gstreamer-check/src/harness.rs @@ -301,7 +301,12 @@ impl Harness { #[doc(alias = "gst_harness_push")] pub fn push(&mut self, buffer: gst::Buffer) -> Result { - unsafe { try_from_glib(ffi::gst_harness_push(self.0.as_ptr(), buffer.into_ptr())) } + unsafe { + try_from_glib(ffi::gst_harness_push( + self.0.as_ptr(), + buffer.into_glib_ptr(), + )) + } } #[doc(alias = "gst_harness_push_and_pull")] @@ -309,7 +314,7 @@ impl Harness { unsafe { Option::<_>::from_glib_full(ffi::gst_harness_push_and_pull( self.0.as_ptr(), - buffer.into_ptr(), + buffer.into_glib_ptr(), )) .ok_or_else(|| glib::bool_error!("Failed to push and pull buffer")) } @@ -320,7 +325,7 @@ impl Harness { unsafe { from_glib(ffi::gst_harness_push_event( self.0.as_ptr(), - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -340,7 +345,7 @@ impl Harness { unsafe { from_glib(ffi::gst_harness_push_upstream_event( self.0.as_ptr(), - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -364,7 +369,7 @@ impl Harness { #[doc(alias = "gst_harness_set_caps")] pub fn set_caps(&mut self, in_: gst::Caps, out: gst::Caps) { unsafe { - ffi::gst_harness_set_caps(self.0.as_ptr(), in_.into_ptr(), out.into_ptr()); + ffi::gst_harness_set_caps(self.0.as_ptr(), in_.into_glib_ptr(), out.into_glib_ptr()); } } @@ -407,7 +412,7 @@ impl Harness { #[doc(alias = "gst_harness_set_sink_caps")] pub fn set_sink_caps(&mut self, caps: gst::Caps) { unsafe { - ffi::gst_harness_set_sink_caps(self.0.as_ptr(), caps.into_ptr()); + ffi::gst_harness_set_sink_caps(self.0.as_ptr(), caps.into_glib_ptr()); } } @@ -421,7 +426,7 @@ impl Harness { #[doc(alias = "gst_harness_set_src_caps")] pub fn set_src_caps(&mut self, caps: gst::Caps) { unsafe { - ffi::gst_harness_set_src_caps(self.0.as_ptr(), caps.into_ptr()); + ffi::gst_harness_set_src_caps(self.0.as_ptr(), caps.into_glib_ptr()); } } diff --git a/gstreamer-gl/src/subclass/gl_filter.rs b/gstreamer-gl/src/subclass/gl_filter.rs index 59e943aa3..3ec6ee1b9 100644 --- a/gstreamer-gl/src/subclass/gl_filter.rs +++ b/gstreamer-gl/src/subclass/gl_filter.rs @@ -361,6 +361,6 @@ unsafe extern "C" fn transform_internal_caps( filter_caps.as_ref().as_ref(), ) }) - .map(|caps| caps.into_ptr()) + .map(|caps| caps.into_glib_ptr()) .unwrap_or(std::ptr::null_mut()) } diff --git a/gstreamer-player/src/config.rs b/gstreamer-player/src/config.rs index 22fea7544..6271de23c 100644 --- a/gstreamer-player/src/config.rs +++ b/gstreamer-player/src/config.rs @@ -91,8 +91,10 @@ impl PlayerConfig { ); } } +} - pub unsafe fn into_ptr(self) -> *mut gst::ffi::GstStructure { +impl IntoGlibPtr<*mut gst::ffi::GstStructure> for PlayerConfig { + unsafe fn into_glib_ptr(self) -> *mut gst::ffi::GstStructure { let mut s = mem::ManuallyDrop::new(self); s.0.to_glib_none_mut().0 } diff --git a/gstreamer-player/src/player.rs b/gstreamer-player/src/player.rs index 623224855..1fdba1094 100644 --- a/gstreamer-player/src/player.rs +++ b/gstreamer-player/src/player.rs @@ -19,7 +19,7 @@ impl Player { pub fn set_config(&self, config: crate::PlayerConfig) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( - ffi::gst_player_set_config(self.to_glib_none().0, config.into_ptr()), + ffi::gst_player_set_config(self.to_glib_none().0, config.into_glib_ptr()), "Failed to set config", ) } diff --git a/gstreamer-rtp/src/rtp_base_depayload.rs b/gstreamer-rtp/src/rtp_base_depayload.rs index b8d7c69b8..2fd468d68 100644 --- a/gstreamer-rtp/src/rtp_base_depayload.rs +++ b/gstreamer-rtp/src/rtp_base_depayload.rs @@ -19,7 +19,7 @@ impl> RTPBaseDepayloadExtManual for O { unsafe { try_from_glib(ffi::gst_rtp_base_depayload_push( self.as_ref().to_glib_none().0, - out_buf.into_ptr(), + out_buf.into_glib_ptr(), )) } } @@ -28,7 +28,7 @@ impl> RTPBaseDepayloadExtManual for O { unsafe { try_from_glib(ffi::gst_rtp_base_depayload_push_list( self.as_ref().to_glib_none().0, - out_list.into_ptr(), + out_list.into_glib_ptr(), )) } } diff --git a/gstreamer-rtp/src/rtp_base_payload.rs b/gstreamer-rtp/src/rtp_base_payload.rs index a833b2cf0..d231e6f8f 100644 --- a/gstreamer-rtp/src/rtp_base_payload.rs +++ b/gstreamer-rtp/src/rtp_base_payload.rs @@ -42,7 +42,7 @@ impl> RTPBasePayloadExtManual for O { unsafe { try_from_glib(ffi::gst_rtp_base_payload_push( self.as_ref().to_glib_none().0, - buffer.into_ptr(), + buffer.into_glib_ptr(), )) } } @@ -51,7 +51,7 @@ impl> RTPBasePayloadExtManual for O { unsafe { try_from_glib(ffi::gst_rtp_base_payload_push_list( self.as_ref().to_glib_none().0, - list.into_ptr(), + list.into_glib_ptr(), )) } } diff --git a/gstreamer-rtp/src/subclass/rtp_base_depayload.rs b/gstreamer-rtp/src/subclass/rtp_base_depayload.rs index 792703937..32d0b3e94 100644 --- a/gstreamer-rtp/src/subclass/rtp_base_depayload.rs +++ b/gstreamer-rtp/src/subclass/rtp_base_depayload.rs @@ -88,7 +88,7 @@ impl RTPBaseDepayloadImplExt for T { .unsafe_cast_ref::() .to_glib_none() .0, - event.into_ptr(), + event.into_glib_ptr(), )) }) .unwrap_or(false) @@ -212,7 +212,7 @@ unsafe extern "C" fn rtp_base_depayload_process_rtp_packet::from_glib_borrow(rtp_packet); imp.process_rtp_packet(wrap.unsafe_cast_ref(), &bufwrap) - .map(|buffer| buffer.into_ptr()) + .map(|buffer| buffer.into_glib_ptr()) .unwrap_or(ptr::null_mut()) }) } diff --git a/gstreamer-rtp/src/subclass/rtp_base_payload.rs b/gstreamer-rtp/src/subclass/rtp_base_payload.rs index bf07ecf89..33d8bda5d 100644 --- a/gstreamer-rtp/src/subclass/rtp_base_payload.rs +++ b/gstreamer-rtp/src/subclass/rtp_base_payload.rs @@ -129,7 +129,7 @@ impl RTPBasePayloadImplExt for T { .map(|f| { try_from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - buffer.into_ptr(), + buffer.into_glib_ptr(), )) }) .unwrap_or(Err(gst::FlowError::Error)) @@ -167,7 +167,7 @@ impl RTPBasePayloadImplExt for T { .map(|f| { from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) }) .unwrap_or(false) @@ -183,7 +183,7 @@ impl RTPBasePayloadImplExt for T { .map(|f| { from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) }) .unwrap_or(false) diff --git a/gstreamer-video/src/navigation.rs b/gstreamer-video/src/navigation.rs index 97e223988..4a8d76e9d 100644 --- a/gstreamer-video/src/navigation.rs +++ b/gstreamer-video/src/navigation.rs @@ -1,6 +1,6 @@ use crate::auto::Navigation; use glib::object::IsA; -use glib::translate::ToGlibPtr; +use glib::translate::{IntoGlibPtr, ToGlibPtr}; pub trait NavigationExtManual: 'static { #[doc(alias = "gst_navigation_send_event")] @@ -15,7 +15,10 @@ pub trait NavigationExtManual: 'static { impl> NavigationExtManual for O { fn send_event(&self, structure: gst::Structure) { unsafe { - ffi::gst_navigation_send_event(self.as_ref().to_glib_none().0, structure.into_ptr()); + ffi::gst_navigation_send_event( + self.as_ref().to_glib_none().0, + structure.into_glib_ptr(), + ); } } @@ -23,7 +26,10 @@ impl> NavigationExtManual for O { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] fn send_event_simple(&self, event: gst::Event) { unsafe { - ffi::gst_navigation_send_event_simple(self.as_ref().to_glib_none().0, event.into_ptr()); + ffi::gst_navigation_send_event_simple( + self.as_ref().to_glib_none().0, + event.into_glib_ptr(), + ); } } } diff --git a/gstreamer-video/src/subclass/navigation.rs b/gstreamer-video/src/subclass/navigation.rs index 58fb56bb9..987ae0458 100644 --- a/gstreamer-video/src/subclass/navigation.rs +++ b/gstreamer-video/src/subclass/navigation.rs @@ -45,7 +45,7 @@ impl NavigationImplExt for T { func( nav.unsafe_cast_ref::().to_glib_none().0, - structure.into_ptr(), + structure.into_glib_ptr(), ); } } @@ -65,7 +65,7 @@ impl NavigationImplExt for T { func( nav.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), ); } } diff --git a/gstreamer-video/src/subclass/video_aggregator.rs b/gstreamer-video/src/subclass/video_aggregator.rs index 2e09871a7..b26f96617 100644 --- a/gstreamer-video/src/subclass/video_aggregator.rs +++ b/gstreamer-video/src/subclass/video_aggregator.rs @@ -210,7 +210,7 @@ unsafe extern "C" fn video_aggregator_update_caps( gst::panic_to_error!(&wrap, imp.panicked(), ptr::null_mut(), { match imp.update_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) { - Ok(caps) => caps.into_ptr(), + Ok(caps) => caps.into_glib_ptr(), Err(err) => { err.log_with_object(&*wrap); ptr::null_mut() @@ -254,7 +254,7 @@ unsafe extern "C" fn video_aggregator_create_output_buffer { - *outbuf = buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()); + *outbuf = buffer.map(|b| b.into_glib_ptr()).unwrap_or(ptr::null_mut()); Ok(gst::FlowSuccess::Ok) } Err(err) => { diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index 58053bbf0..1cee636f3 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -444,7 +444,7 @@ impl VideoDecoderImplExt for T { .expect("Missing parent function `sink_event`"); from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -472,7 +472,7 @@ impl VideoDecoderImplExt for T { .expect("Missing parent function `src_event`"); from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } diff --git a/gstreamer-video/src/subclass/video_encoder.rs b/gstreamer-video/src/subclass/video_encoder.rs index bedce3a81..255870321 100644 --- a/gstreamer-video/src/subclass/video_encoder.rs +++ b/gstreamer-video/src/subclass/video_encoder.rs @@ -360,7 +360,7 @@ impl VideoEncoderImplExt for T { .expect("Missing parent function `sink_event`"); from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } @@ -388,7 +388,7 @@ impl VideoEncoderImplExt for T { .expect("Missing parent function `src_event`"); from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) } } diff --git a/gstreamer-video/src/video_codec_frame.rs b/gstreamer-video/src/video_codec_frame.rs index 69cc9d32c..0851d02d6 100644 --- a/gstreamer-video/src/video_codec_frame.rs +++ b/gstreamer-video/src/video_codec_frame.rs @@ -189,7 +189,7 @@ impl<'a> VideoCodecFrame<'a> { gst::ffi::gst_mini_object_unref(prev as *mut gst::ffi::GstMiniObject); } - let ptr = output_buffer.into_ptr(); + let ptr = output_buffer.into_glib_ptr(); let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable( ptr as *const gst::ffi::GstMiniObject, )); @@ -217,9 +217,10 @@ impl<'a> VideoCodecFrame<'a> { pub fn num_subframes(&self) -> u32 { unsafe { (*self.to_glib_none().0).abidata.ABI.num_subframes } } +} - #[doc(hidden)] - pub unsafe fn into_ptr(self) -> *mut ffi::GstVideoCodecFrame { +impl<'a> IntoGlibPtr<*mut ffi::GstVideoCodecFrame> for VideoCodecFrame<'a> { + unsafe fn into_glib_ptr(self) -> *mut ffi::GstVideoCodecFrame { let stream_lock = self.element.stream_lock(); glib::ffi::g_rec_mutex_unlock(stream_lock); diff --git a/gstreamer-video/src/video_converter.rs b/gstreamer-video/src/video_converter.rs index a88d5546d..f85e74cb9 100644 --- a/gstreamer-video/src/video_converter.rs +++ b/gstreamer-video/src/video_converter.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::translate::ToGlibPtr; +use glib::translate::{IntoGlibPtr, ToGlibPtr}; use std::ops; use std::ptr; @@ -40,7 +40,9 @@ impl VideoConverter { let ptr = ffi::gst_video_converter_new( in_info.to_glib_none().0 as *mut _, out_info.to_glib_none().0 as *mut _, - config.map(|s| s.0.into_ptr()).unwrap_or(ptr::null_mut()), + config + .map(|s| s.0.into_glib_ptr()) + .unwrap_or(ptr::null_mut()), ); if ptr.is_null() { Err(glib::bool_error!("Failed to create video converter")) @@ -66,7 +68,7 @@ impl VideoConverter { #[doc(alias = "gst_video_converter_set_config")] pub fn set_config(&mut self, config: VideoConverterConfig) { unsafe { - ffi::gst_video_converter_set_config(self.0.as_ptr(), config.0.into_ptr()); + ffi::gst_video_converter_set_config(self.0.as_ptr(), config.0.into_glib_ptr()); } } diff --git a/gstreamer-video/src/video_decoder.rs b/gstreamer-video/src/video_decoder.rs index 9afd9283b..461153b76 100644 --- a/gstreamer-video/src/video_decoder.rs +++ b/gstreamer-video/src/video_decoder.rs @@ -151,7 +151,7 @@ impl> VideoDecoderExtManual for O { unsafe { try_from_glib(ffi::gst_video_decoder_finish_frame( self.as_ref().to_glib_none().0, - frame.into_ptr(), + frame.into_glib_ptr(), )) } } @@ -159,7 +159,10 @@ impl> VideoDecoderExtManual for O { #[doc(alias = "gst_video_decoder_release_frame")] fn release_frame(&self, frame: VideoCodecFrame) { unsafe { - ffi::gst_video_decoder_release_frame(self.as_ref().to_glib_none().0, frame.into_ptr()) + ffi::gst_video_decoder_release_frame( + self.as_ref().to_glib_none().0, + frame.into_glib_ptr(), + ) } } @@ -168,7 +171,7 @@ impl> VideoDecoderExtManual for O { unsafe { try_from_glib(ffi::gst_video_decoder_drop_frame( self.as_ref().to_glib_none().0, - frame.into_ptr(), + frame.into_glib_ptr(), )) } } diff --git a/gstreamer-video/src/video_encoder.rs b/gstreamer-video/src/video_encoder.rs index cea854ee9..95b8a9e29 100644 --- a/gstreamer-video/src/video_encoder.rs +++ b/gstreamer-video/src/video_encoder.rs @@ -108,7 +108,7 @@ impl> VideoEncoderExtManual for O { unsafe { try_from_glib(ffi::gst_video_encoder_finish_frame( self.as_ref().to_glib_none().0, - frame.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), + frame.map(|f| f.into_glib_ptr()).unwrap_or(ptr::null_mut()), )) } } @@ -221,7 +221,7 @@ impl> VideoEncoderExtManual for O { }; ffi::gst_video_encoder_set_output_state( self.as_ref().to_glib_none().0, - caps.into_ptr(), + caps.into_glib_ptr(), reference, ) }; diff --git a/gstreamer-video/src/video_meta.rs b/gstreamer-video/src/video_meta.rs index b9414239a..1e11a6bcf 100644 --- a/gstreamer-video/src/video_meta.rs +++ b/gstreamer-video/src/video_meta.rs @@ -3,7 +3,7 @@ use std::fmt; use std::ptr; -use glib::translate::{from_glib, from_glib_none, FromGlib, IntoGlib, ToGlibPtr}; +use glib::translate::{from_glib, from_glib_none, FromGlib, IntoGlib, IntoGlibPtr, ToGlibPtr}; use gst::prelude::*; #[repr(transparent)] @@ -388,7 +388,7 @@ impl VideoRegionOfInterestMeta { #[doc(alias = "gst_video_region_of_interest_meta_add_param")] pub fn add_param(&mut self, s: gst::Structure) { unsafe { - ffi::gst_video_region_of_interest_meta_add_param(&mut self.0, s.into_ptr()); + ffi::gst_video_region_of_interest_meta_add_param(&mut self.0, s.into_glib_ptr()); } } } diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index d99b38b7a..96de2daa0 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -18,7 +18,9 @@ use crate::ClockTime; use crate::Memory; use crate::MemoryRef; -use glib::translate::{from_glib, from_glib_full, FromGlib, FromGlibPtrFull, IntoGlib}; +use glib::translate::{ + from_glib, from_glib_full, FromGlib, FromGlibPtrFull, IntoGlib, IntoGlibPtr, +}; pub enum Readable {} pub enum Writable {} @@ -173,7 +175,7 @@ impl Buffer { pub fn append(&mut self, other: Self) { skip_assert_initialized!(); unsafe { - let ptr = ffi::gst_buffer_append(self.as_mut_ptr(), other.into_ptr()); + let ptr = ffi::gst_buffer_append(self.as_mut_ptr(), other.into_glib_ptr()); self.replace_ptr(ptr); } } @@ -529,7 +531,7 @@ impl BufferRef { #[doc(alias = "gst_buffer_append_memory")] pub fn append_memory(&mut self, mem: Memory) { - unsafe { ffi::gst_buffer_append_memory(self.as_mut_ptr(), mem.into_ptr()) } + unsafe { ffi::gst_buffer_append_memory(self.as_mut_ptr(), mem.into_glib_ptr()) } } #[doc(alias = "gst_buffer_find_memory")] @@ -622,7 +624,7 @@ impl BufferRef { Some(val) => val as i32, None => -1, }, - mem.into_ptr(), + mem.into_glib_ptr(), ) } } @@ -675,7 +677,7 @@ impl BufferRef { #[doc(alias = "gst_buffer_prepend_memory")] pub fn prepend_memory(&mut self, mem: Memory) { - unsafe { ffi::gst_buffer_prepend_memory(self.as_mut_ptr(), mem.into_ptr()) } + unsafe { ffi::gst_buffer_prepend_memory(self.as_mut_ptr(), mem.into_glib_ptr()) } } #[doc(alias = "gst_buffer_remove_all_memory")] @@ -706,13 +708,13 @@ impl BufferRef { #[doc(alias = "gst_buffer_replace_all_memory")] pub fn replace_all_memory(&mut self, mem: Memory) { - unsafe { ffi::gst_buffer_replace_all_memory(self.as_mut_ptr(), mem.into_ptr()) } + unsafe { ffi::gst_buffer_replace_all_memory(self.as_mut_ptr(), mem.into_glib_ptr()) } } #[doc(alias = "gst_buffer_replace_memory")] pub fn replace_memory(&mut self, idx: u32, mem: Memory) { assert!(idx < self.n_memory()); - unsafe { ffi::gst_buffer_replace_memory(self.as_mut_ptr(), idx, mem.into_ptr()) } + unsafe { ffi::gst_buffer_replace_memory(self.as_mut_ptr(), idx, mem.into_glib_ptr()) } } #[doc(alias = "gst_buffer_replace_memory_range")] @@ -726,7 +728,7 @@ impl BufferRef { Some(val) => val as i32, None => -1, }, - mem.into_ptr(), + mem.into_glib_ptr(), ) } } diff --git a/gstreamer/src/buffer_pool.rs b/gstreamer/src/buffer_pool.rs index 2b6048a9a..febf0cb69 100644 --- a/gstreamer/src/buffer_pool.rs +++ b/gstreamer/src/buffer_pool.rs @@ -364,7 +364,7 @@ impl> BufferPoolExtManual for O { glib::result_from_gboolean!( ffi::gst_buffer_pool_set_config( self.as_ref().to_glib_none().0, - config.0.into_ptr() + config.0.into_glib_ptr() ), "Failed to set config", ) @@ -399,7 +399,10 @@ impl> BufferPoolExtManual for O { fn release_buffer(&self, buffer: crate::Buffer) { unsafe { - ffi::gst_buffer_pool_release_buffer(self.as_ref().to_glib_none().0, buffer.into_ptr()); + ffi::gst_buffer_pool_release_buffer( + self.as_ref().to_glib_none().0, + buffer.into_glib_ptr(), + ); } } } diff --git a/gstreamer/src/bufferlist.rs b/gstreamer/src/bufferlist.rs index d0df8c0f9..d3fe8f041 100644 --- a/gstreamer/src/bufferlist.rs +++ b/gstreamer/src/bufferlist.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::translate::{from_glib, from_glib_full, from_glib_none, IntoGlib}; +use glib::translate::{from_glib, from_glib_full, from_glib_none, IntoGlib, IntoGlibPtr}; use std::fmt; use std::ops::ControlFlow; use std::ptr; @@ -30,7 +30,7 @@ impl BufferListRef { #[doc(alias = "gst_buffer_list_insert")] pub fn insert(&mut self, idx: i32, buffer: Buffer) { unsafe { - ffi::gst_buffer_list_insert(self.as_mut_ptr(), idx, buffer.into_ptr()); + ffi::gst_buffer_list_insert(self.as_mut_ptr(), idx, buffer.into_glib_ptr()); } } @@ -158,7 +158,7 @@ impl BufferListRef { *buffer = ptr::null_mut(); } Some(new_buffer) => { - *buffer = new_buffer.into_ptr(); + *buffer = new_buffer.into_glib_ptr(); } } diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index 4dd9c9e83..79f9f6e7d 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -9,7 +9,9 @@ use std::str; use crate::CapsIntersectMode; -use glib::translate::{from_glib, from_glib_full, FromGlibPtrFull, IntoGlib, ToGlibPtr}; +use glib::translate::{ + from_glib, from_glib_full, FromGlibPtrFull, IntoGlib, IntoGlibPtr, ToGlibPtr, +}; use glib::value::ToSendValue; mini_object_wrapper!(Caps, CapsRef, ffi::GstCaps, || { ffi::gst_caps_get_type() }); @@ -81,7 +83,7 @@ impl Caps { pub fn merge(&mut self, other: Self) { skip_assert_initialized!(); unsafe { - let ptr = ffi::gst_caps_merge(self.as_mut_ptr(), other.into_ptr()); + let ptr = ffi::gst_caps_merge(self.as_mut_ptr(), other.into_glib_ptr()); self.replace_ptr(ptr); } } @@ -90,7 +92,7 @@ impl Caps { pub fn merge_structure(&mut self, structure: Structure) { skip_assert_initialized!(); unsafe { - let ptr = ffi::gst_caps_merge_structure(self.as_mut_ptr(), structure.into_ptr()); + let ptr = ffi::gst_caps_merge_structure(self.as_mut_ptr(), structure.into_glib_ptr()); self.replace_ptr(ptr); } } @@ -101,8 +103,10 @@ impl Caps { unsafe { let ptr = ffi::gst_caps_merge_structure_full( self.as_mut_ptr(), - structure.into_ptr(), - features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), + structure.into_glib_ptr(), + features + .map(|f| f.into_glib_ptr()) + .unwrap_or(ptr::null_mut()), ); self.replace_ptr(ptr); } @@ -297,7 +301,9 @@ impl CapsRef { ffi::gst_caps_set_features( self.as_mut_ptr(), idx, - features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), + features + .map(|f| f.into_glib_ptr()) + .unwrap_or(ptr::null_mut()), ) } } @@ -309,7 +315,9 @@ impl CapsRef { unsafe { ffi::gst_caps_set_features_simple( self.as_mut_ptr(), - features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), + features + .map(|f| f.into_glib_ptr()) + .unwrap_or(ptr::null_mut()), ) } } @@ -338,7 +346,7 @@ impl CapsRef { #[doc(alias = "gst_caps_append_structure")] pub fn append_structure(&mut self, structure: Structure) { - unsafe { ffi::gst_caps_append_structure(self.as_mut_ptr(), structure.into_ptr()) } + unsafe { ffi::gst_caps_append_structure(self.as_mut_ptr(), structure.into_glib_ptr()) } } #[doc(alias = "gst_caps_append_structure_full")] @@ -346,8 +354,10 @@ impl CapsRef { unsafe { ffi::gst_caps_append_structure_full( self.as_mut_ptr(), - structure.into_ptr(), - features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), + structure.into_glib_ptr(), + features + .map(|f| f.into_glib_ptr()) + .unwrap_or(ptr::null_mut()), ) } } @@ -359,7 +369,7 @@ impl CapsRef { #[doc(alias = "gst_caps_append")] pub fn append(&mut self, other: Caps) { - unsafe { ffi::gst_caps_append(self.as_mut_ptr(), other.into_ptr()) } + unsafe { ffi::gst_caps_append(self.as_mut_ptr(), other.into_glib_ptr()) } } #[doc(alias = "gst_caps_can_intersect")] diff --git a/gstreamer/src/caps_features.rs b/gstreamer/src/caps_features.rs index 996123880..af651a682 100644 --- a/gstreamer/src/caps_features.rs +++ b/gstreamer/src/caps_features.rs @@ -59,8 +59,10 @@ impl CapsFeatures { assert_initialized_main_thread!(); unsafe { CapsFeatures(ptr::NonNull::new_unchecked(ffi::gst_caps_features_new_any())) } } +} - pub unsafe fn into_ptr(self) -> *mut ffi::GstCapsFeatures { +impl IntoGlibPtr<*mut ffi::GstCapsFeatures> for CapsFeatures { + unsafe fn into_glib_ptr(self) -> *mut ffi::GstCapsFeatures { let s = mem::ManuallyDrop::new(self); s.0.as_ptr() } diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index 17127b4e0..eb52d22f5 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -299,7 +299,7 @@ impl> ElementExtManual for O { unsafe { from_glib(ffi::gst_element_send_event( self.as_ref().to_glib_none().0, - event.into().into_ptr(), + event.into().into_glib_ptr(), )) } } @@ -399,7 +399,7 @@ impl> ElementExtManual for O { file.to_glib_none().0, function.to_glib_none().0, line as i32, - structure.into_ptr(), + structure.into_glib_ptr(), ); } } @@ -407,7 +407,10 @@ impl> ElementExtManual for O { fn post_message(&self, message: crate::Message) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( - ffi::gst_element_post_message(self.as_ref().to_glib_none().0, message.into_ptr()), + ffi::gst_element_post_message( + self.as_ref().to_glib_none().0, + message.into_glib_ptr() + ), "Failed to post message" ) } diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 2bbcced32..ecfead2ce 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -1746,7 +1746,7 @@ impl<'a> TagBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let tags = s.tags.take().unwrap(); - ffi::gst_event_new_tag(tags.into_ptr()) + ffi::gst_event_new_tag(tags.into_glib_ptr()) }); } @@ -2102,7 +2102,7 @@ impl<'a> NavigationBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - ffi::gst_event_new_navigation(structure.into_ptr()) + ffi::gst_event_new_navigation(structure.into_glib_ptr()) }); } @@ -2229,7 +2229,7 @@ impl<'a> CustomUpstreamBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_UPSTREAM, structure.into_ptr()) + ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_UPSTREAM, structure.into_glib_ptr()) }); } @@ -2250,7 +2250,7 @@ impl<'a> CustomDownstreamBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM, structure.into_ptr()) + ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM, structure.into_glib_ptr()) }); } @@ -2271,7 +2271,10 @@ impl<'a> CustomDownstreamOobBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB, structure.into_ptr()) + ffi::gst_event_new_custom( + ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB, + structure.into_glib_ptr(), + ) }); } @@ -2294,7 +2297,7 @@ impl<'a> CustomDownstreamStickyBuilder<'a> { let structure = s.structure.take().unwrap(); ffi::gst_event_new_custom( ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, - structure.into_ptr(), + structure.into_glib_ptr(), ) }); } @@ -2316,7 +2319,7 @@ impl<'a> CustomBothBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH, structure.into_ptr()) + ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH, structure.into_glib_ptr()) }); } @@ -2337,7 +2340,7 @@ impl<'a> CustomBothOobBuilder<'a> { event_builder_generic_impl!(|s: &mut Self| { let structure = s.structure.take().unwrap(); - ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH_OOB, structure.into_ptr()) + ffi::gst_event_new_custom(ffi::GST_EVENT_CUSTOM_BOTH_OOB, structure.into_glib_ptr()) }); } diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index fe71b6fdd..f20977072 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -32,12 +32,6 @@ impl Iterator where for<'a> T: FromValue<'a> + 'static, { - pub unsafe fn into_ptr(self) -> *mut ffi::GstIterator { - let s = mem::ManuallyDrop::new(self); - let it = s.to_glib_none().0; - it as *mut _ - } - #[allow(clippy::should_implement_trait)] #[doc(alias = "gst_iterator_next")] pub fn next(&mut self) -> Result, IteratorError> { @@ -81,7 +75,7 @@ where ); from_glib_full(ffi::gst_iterator_filter( - self.into_ptr(), + self.into_glib_ptr(), Some(filter_trampoline::), closure_value.to_glib_none().0, )) @@ -212,6 +206,17 @@ where } } +impl IntoGlibPtr<*mut ffi::GstIterator> for Iterator +where + for<'a> T: FromValue<'a> + 'static, +{ + unsafe fn into_glib_ptr(self) -> *mut ffi::GstIterator { + let s = mem::ManuallyDrop::new(self); + let it = s.to_glib_none().0; + it as *mut _ + } +} + #[repr(C)] struct RsIterator> where diff --git a/gstreamer/src/memory.rs b/gstreamer/src/memory.rs index 25fd9d1b1..127e655bc 100644 --- a/gstreamer/src/memory.rs +++ b/gstreamer/src/memory.rs @@ -7,7 +7,7 @@ use std::ops::{Deref, DerefMut}; use std::ptr; use std::slice; -use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlibPtr}; +use glib::translate::{from_glib, from_glib_full, from_glib_none, IntoGlibPtr, ToGlibPtr}; use crate::AllocationParams; use crate::Allocator; @@ -602,7 +602,7 @@ impl Memory { ::RefType: AsRef + AsMut, { if M::check_memory_type(&self) { - unsafe { Ok(from_glib_full(self.into_ptr() as *mut M::FfiType)) } + unsafe { Ok(from_glib_full(self.into_glib_ptr() as *mut M::FfiType)) } } else { Err(self) } @@ -663,7 +663,7 @@ macro_rules! memory_object_wrapper { if M::check_memory_type(&self) { unsafe { Ok($crate::glib::translate::from_glib_full( - self.into_ptr() as *mut M::FfiType + self.into_glib_ptr() as *mut M::FfiType )) } } else { @@ -683,7 +683,7 @@ macro_rules! memory_object_wrapper { { unsafe { $crate::glib::translate::from_glib_full( - self.into_ptr() as *const ::FfiType + self.into_glib_ptr() as *const ::FfiType ) } } diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index c2d82a301..fe6496f6f 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -1939,7 +1939,7 @@ impl<'a> ErrorBuilder<'a> { message_builder_generic_impl!(|s: &mut Self, src| { let details = match s.details.take() { None => ptr::null_mut(), - Some(details) => details.into_ptr(), + Some(details) => details.into_glib_ptr(), }; ffi::gst_message_new_error_with_details( @@ -1988,7 +1988,7 @@ impl<'a> WarningBuilder<'a> { message_builder_generic_impl!(|s: &mut Self, src| { let details = match s.details.take() { None => ptr::null_mut(), - Some(details) => details.into_ptr(), + Some(details) => details.into_glib_ptr(), }; ffi::gst_message_new_warning_with_details( @@ -2037,7 +2037,7 @@ impl<'a> InfoBuilder<'a> { message_builder_generic_impl!(|s: &mut Self, src| { let details = match s.details.take() { None => ptr::null_mut(), - Some(details) => details.into_ptr(), + Some(details) => details.into_glib_ptr(), }; ffi::gst_message_new_info_with_details( @@ -2355,7 +2355,7 @@ impl<'a> ApplicationBuilder<'a> { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_application( src, - s.structure.take().unwrap().into_ptr() + s.structure.take().unwrap().into_glib_ptr() )); } @@ -2376,7 +2376,7 @@ impl<'a> ElementBuilder<'a> { message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_element( src, - s.structure.take().unwrap().into_ptr() + s.structure.take().unwrap().into_glib_ptr() )); } @@ -2788,7 +2788,7 @@ impl<'a> HaveContextBuilder<'a> { message_builder_generic_impl!(|s: &mut Self, src| { let context = s.context.take().unwrap(); - ffi::gst_message_new_have_context(src, context.into_ptr()) + ffi::gst_message_new_have_context(src, context.into_glib_ptr()) }); } @@ -2985,7 +2985,7 @@ impl<'a> RedirectBuilder<'a> { message_builder_generic_impl!(|s: &mut Self, src| { let entry_struct = s.entry_struct.take(); let entry_struct_ptr = if let Some(entry_struct) = entry_struct { - entry_struct.into_ptr() + entry_struct.into_glib_ptr() } else { ptr::null_mut() }; @@ -3000,7 +3000,7 @@ impl<'a> RedirectBuilder<'a> { for &(location, tag_list, entry_struct) in entries { let entry_struct = entry_struct.cloned(); let entry_struct_ptr = if let Some(entry_struct) = entry_struct { - entry_struct.into_ptr() + entry_struct.into_glib_ptr() } else { ptr::null_mut() }; diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index 52231427e..c4be2261e 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -411,7 +411,8 @@ impl ProtectionMeta { pub fn add(buffer: &mut BufferRef, info: crate::Structure) -> MetaRefMut { skip_assert_initialized!(); unsafe { - let meta = ffi::gst_buffer_add_protection_meta(buffer.as_mut_ptr(), info.into_ptr()); + let meta = + ffi::gst_buffer_add_protection_meta(buffer.as_mut_ptr(), info.into_glib_ptr()); Self::from_mut_ptr(buffer, meta) } diff --git a/gstreamer/src/miniobject.rs b/gstreamer/src/miniobject.rs index cbdc6c10e..5cf5dd1a7 100644 --- a/gstreamer/src/miniobject.rs +++ b/gstreamer/src/miniobject.rs @@ -96,12 +96,16 @@ macro_rules! mini_object_wrapper ( #[must_use] pub fn upcast(self) -> $crate::miniobject::MiniObject { + use $crate::glib::translate::IntoGlibPtr; + unsafe { - from_glib_full(self.into_ptr() as *mut $crate::ffi::GstMiniObject) + from_glib_full(self.into_glib_ptr() as *mut $crate::ffi::GstMiniObject) } } + } - pub unsafe fn into_ptr(self) -> *mut $ffi_name { + impl $crate::glib::translate::IntoGlibPtr<*mut $ffi_name> for $name { + unsafe fn into_glib_ptr(self) -> *mut $ffi_name { let s = std::mem::ManuallyDrop::new(self); s.as_mut_ptr() } @@ -547,7 +551,7 @@ mini_object_wrapper!(MiniObject, MiniObjectRef, ffi::GstMiniObject, || { impl MiniObject { pub fn downcast(self) -> Result { if self.type_().is_a(T::static_type()) { - unsafe { Ok(from_glib_full(self.into_ptr() as *mut T::FfiType)) } + unsafe { Ok(from_glib_full(self.into_glib_ptr() as *mut T::FfiType)) } } else { Err(self) } diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 2e1685035..c230adefb 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -366,7 +366,7 @@ impl> PadExtManual for O { unsafe { try_from_glib(ffi::gst_pad_chain( self.as_ref().to_glib_none().0, - buffer.into_ptr(), + buffer.into_glib_ptr(), )) } } @@ -375,7 +375,7 @@ impl> PadExtManual for O { unsafe { try_from_glib(ffi::gst_pad_push( self.as_ref().to_glib_none().0, - buffer.into_ptr(), + buffer.into_glib_ptr(), )) } } @@ -384,7 +384,7 @@ impl> PadExtManual for O { unsafe { try_from_glib(ffi::gst_pad_chain_list( self.as_ref().to_glib_none().0, - list.into_ptr(), + list.into_glib_ptr(), )) } } @@ -393,7 +393,7 @@ impl> PadExtManual for O { unsafe { try_from_glib(ffi::gst_pad_push_list( self.as_ref().to_glib_none().0, - list.into_ptr(), + list.into_glib_ptr(), )) } } @@ -539,7 +539,7 @@ impl> PadExtManual for O { from_glib(ffi::gst_pad_event_default( self.as_ref().to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0, - event.into().into_ptr(), + event.into().into_glib_ptr(), )) } } @@ -548,7 +548,7 @@ impl> PadExtManual for O { unsafe { from_glib(ffi::gst_pad_push_event( self.as_ref().to_glib_none().0, - event.into().into_ptr(), + event.into().into_glib_ptr(), )) } } @@ -557,7 +557,7 @@ impl> PadExtManual for O { unsafe { from_glib(ffi::gst_pad_send_event( self.as_ref().to_glib_none().0, - event.into().into_ptr(), + event.into().into_glib_ptr(), )) } } @@ -1039,7 +1039,7 @@ impl> PadExtManual for O { } Replace(ev) => { ffi::gst_mini_object_unref(*event as *mut _); - *event = ev.into_ptr(); + *event = ev.into_glib_ptr(); } } @@ -1181,15 +1181,15 @@ unsafe fn update_probe_info( match probe_info.data { Some(PadProbeData::Buffer(buffer)) => { assert_eq!(data_type, Some(Buffer::static_type())); - (*info).data = buffer.into_ptr() as *mut libc::c_void; + (*info).data = buffer.into_glib_ptr() as *mut libc::c_void; } Some(PadProbeData::BufferList(bufferlist)) => { assert_eq!(data_type, Some(BufferList::static_type())); - (*info).data = bufferlist.into_ptr() as *mut libc::c_void; + (*info).data = bufferlist.into_glib_ptr() as *mut libc::c_void; } Some(PadProbeData::Event(event)) => { assert_eq!(data_type, Some(Event::static_type())); - (*info).data = event.into_ptr() as *mut libc::c_void; + (*info).data = event.into_glib_ptr() as *mut libc::c_void; } Some(PadProbeData::Query(query)) => { assert_eq!(data_type, Some(Query::static_type())); @@ -1483,7 +1483,7 @@ where } } } else { - *buffer = new_buffer.into_ptr(); + *buffer = new_buffer.into_glib_ptr(); FlowReturn::Ok.into_glib() } } @@ -1515,7 +1515,7 @@ where .as_ref(), ); - ret.into_ptr() + ret.into_glib_ptr() } unsafe extern "C" fn trampoline_link_function< diff --git a/gstreamer/src/plugin.rs b/gstreamer/src/plugin.rs index 1364c6f5d..a0678fedb 100644 --- a/gstreamer/src/plugin.rs +++ b/gstreamer/src/plugin.rs @@ -25,7 +25,7 @@ impl Plugin { #[doc(alias = "gst_plugin_set_cache_data")] pub fn set_cache_data(&self, cache_data: Structure) { unsafe { - ffi::gst_plugin_set_cache_data(self.to_glib_none().0, cache_data.into_ptr()); + ffi::gst_plugin_set_cache_data(self.to_glib_none().0, cache_data.into_glib_ptr()); } } } diff --git a/gstreamer/src/promise.rs b/gstreamer/src/promise.rs index b05fe3bf5..16de5fb3d 100644 --- a/gstreamer/src/promise.rs +++ b/gstreamer/src/promise.rs @@ -127,7 +127,7 @@ impl Promise { unsafe { ffi::gst_promise_reply( self.to_glib_none().0, - s.map(|s| s.into_ptr()).unwrap_or(ptr::null_mut()), + s.map(|s| s.into_glib_ptr()).unwrap_or(ptr::null_mut()), ); } } diff --git a/gstreamer/src/proxy_pad.rs b/gstreamer/src/proxy_pad.rs index 0966c77d8..21b3a1c13 100644 --- a/gstreamer/src/proxy_pad.rs +++ b/gstreamer/src/proxy_pad.rs @@ -53,7 +53,7 @@ impl> ProxyPadExtManual for O { try_from_glib(ffi::gst_proxy_pad_chain_default( self.as_ptr() as *mut ffi::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, - buffer.into_ptr(), + buffer.into_glib_ptr(), )) } } @@ -68,7 +68,7 @@ impl> ProxyPadExtManual for O { try_from_glib(ffi::gst_proxy_pad_chain_list_default( self.as_ptr() as *mut ffi::GstPad, parent.map(|p| p.as_ref()).to_glib_none().0, - list.into_ptr(), + list.into_glib_ptr(), )) } } diff --git a/gstreamer/src/query.rs b/gstreamer/src/query.rs index 6ad150949..80ea0a38c 100644 --- a/gstreamer/src/query.rs +++ b/gstreamer/src/query.rs @@ -910,7 +910,7 @@ impl Custom { unsafe { Self(from_glib_full(ffi::gst_query_new_custom( ffi::GST_QUERY_CUSTOM, - structure.into_ptr(), + structure.into_glib_ptr(), ))) } } diff --git a/gstreamer/src/sample.rs b/gstreamer/src/sample.rs index 3a74fe3e7..2208867cf 100644 --- a/gstreamer/src/sample.rs +++ b/gstreamer/src/sample.rs @@ -3,7 +3,7 @@ use std::fmt; use std::ptr; -use glib::translate::{from_glib_full, from_glib_none, mut_override, ToGlibPtr}; +use glib::translate::{from_glib_full, from_glib_none, mut_override, IntoGlibPtr, ToGlibPtr}; use crate::Buffer; use crate::BufferList; @@ -74,7 +74,10 @@ impl<'a> SampleBuilder<'a> { assert_initialized_main_thread!(); unsafe { - let info = self.info.map(|i| i.into_ptr()).unwrap_or(ptr::null_mut()); + let info = self + .info + .map(|i| i.into_glib_ptr()) + .unwrap_or(ptr::null_mut()); let sample: Sample = from_glib_full(ffi::gst_sample_new( self.buffer.to_glib_none().0, @@ -223,7 +226,7 @@ impl SampleRef { unsafe { ffi::gst_sample_set_info( self.as_mut_ptr(), - info.map(|i| i.into_ptr()).unwrap_or(ptr::null_mut()), + info.map(|i| i.into_glib_ptr()).unwrap_or(ptr::null_mut()), ); } } diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 55d3b1ca0..e2063cee5 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -73,11 +73,6 @@ impl Structure { structure } - pub unsafe fn into_ptr(self) -> *mut ffi::GstStructure { - let s = mem::ManuallyDrop::new(self); - s.0.as_ptr() - } - #[allow(clippy::should_implement_trait)] pub fn from_iter<'a>( name: &str, @@ -93,6 +88,13 @@ impl Structure { } } +impl IntoGlibPtr<*mut ffi::GstStructure> for Structure { + unsafe fn into_glib_ptr(self) -> *mut ffi::GstStructure { + let s = mem::ManuallyDrop::new(self); + s.0.as_ptr() + } +} + impl Deref for Structure { type Target = StructureRef; diff --git a/gstreamer/src/subclass/bin.rs b/gstreamer/src/subclass/bin.rs index 294d365bf..e539c3f33 100644 --- a/gstreamer/src/subclass/bin.rs +++ b/gstreamer/src/subclass/bin.rs @@ -91,7 +91,7 @@ impl BinImplExt for T { if let Some(ref f) = (*parent_class).handle_message { f( bin.unsafe_cast_ref::().to_glib_none().0, - message.into_ptr(), + message.into_glib_ptr(), ); } } diff --git a/gstreamer/src/subclass/buffer_pool.rs b/gstreamer/src/subclass/buffer_pool.rs index 67497bb5e..e90740901 100644 --- a/gstreamer/src/subclass/buffer_pool.rs +++ b/gstreamer/src/subclass/buffer_pool.rs @@ -162,7 +162,7 @@ impl BufferPoolImplExt for T { .unsafe_cast_ref::() .to_glib_none() .0, - buffer.into_ptr(), + buffer.into_glib_ptr(), ) } } @@ -178,7 +178,7 @@ impl BufferPoolImplExt for T { .unsafe_cast_ref::() .to_glib_none() .0, - buffer.into_ptr(), + buffer.into_glib_ptr(), ) } } @@ -336,7 +336,7 @@ unsafe extern "C" fn buffer_pool_acquire_buffer( match imp.acquire_buffer(wrap.unsafe_cast_ref(), params.as_ref()) { Ok(b) => { - *buffer = b.into_ptr(); + *buffer = b.into_glib_ptr(); ffi::GST_FLOW_OK } Err(err) => err.into_glib(), @@ -355,7 +355,7 @@ unsafe extern "C" fn buffer_pool_alloc_buffer( match imp.alloc_buffer(wrap.unsafe_cast_ref(), params.as_ref()) { Ok(b) => { - *buffer = b.into_ptr(); + *buffer = b.into_glib_ptr(); ffi::GST_FLOW_OK } Err(err) => err.into_glib(), diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index 94bd127bc..54a67ece1 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -247,7 +247,7 @@ impl ElementImplExt for T { .map(|f| { from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - event.into_ptr(), + event.into_glib_ptr(), )) }) .unwrap_or(false) @@ -325,7 +325,7 @@ impl ElementImplExt for T { if let Some(f) = (*parent_class).post_message { from_glib(f( element.unsafe_cast_ref::().to_glib_none().0, - msg.into_ptr(), + msg.into_glib_ptr(), )) } else { false diff --git a/gstreamer/src/subclass/task_pool.rs b/gstreamer/src/subclass/task_pool.rs index 9e3f402c7..f6e556559 100644 --- a/gstreamer/src/subclass/task_pool.rs +++ b/gstreamer/src/subclass/task_pool.rs @@ -77,7 +77,7 @@ unsafe extern "C" fn task_pool_prepare( Ok(()) => {} Err(err) => { if !error.is_null() { - *error = err.into_raw(); + *error = err.into_glib_ptr(); } } } @@ -109,7 +109,7 @@ unsafe extern "C" fn task_pool_push( Err(err) => { func.prevent_call(); if !error.is_null() { - *error = err.into_raw(); + *error = err.into_glib_ptr(); } ptr::null_mut() } diff --git a/gstreamer/src/subclass/uri_handler.rs b/gstreamer/src/subclass/uri_handler.rs index 56ac0d3f1..e650d59d6 100644 --- a/gstreamer/src/subclass/uri_handler.rs +++ b/gstreamer/src/subclass/uri_handler.rs @@ -145,7 +145,7 @@ unsafe extern "C" fn uri_handler_set_uri( Ok(()) => true.into_glib(), Err(error) => { if !err.is_null() { - *err = error.into_raw(); + *err = error.into_glib_ptr(); } false.into_glib() } diff --git a/gstreamer/src/toc.rs b/gstreamer/src/toc.rs index c8901036a..7ab5bf885 100644 --- a/gstreamer/src/toc.rs +++ b/gstreamer/src/toc.rs @@ -5,7 +5,8 @@ use std::fmt; use std::mem; use glib::translate::{ - from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, IntoGlib, ToGlibPtr, + from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, IntoGlib, IntoGlibPtr, + ToGlibPtr, }; use crate::TagList; @@ -45,7 +46,7 @@ impl TocRef { #[doc(alias = "gst_toc_append_entry")] pub fn append_entry(&mut self, entry: TocEntry) { unsafe { - ffi::gst_toc_append_entry(self.as_mut_ptr(), entry.into_ptr()); + ffi::gst_toc_append_entry(self.as_mut_ptr(), entry.into_glib_ptr()); } } @@ -58,7 +59,7 @@ impl TocRef { #[doc(alias = "gst_toc_set_tags")] pub fn set_tags(&mut self, tag_list: TagList) { unsafe { - ffi::gst_toc_set_tags(self.as_mut_ptr(), tag_list.into_ptr()); + ffi::gst_toc_set_tags(self.as_mut_ptr(), tag_list.into_glib_ptr()); } } @@ -130,7 +131,7 @@ impl TocEntryRef { #[doc(alias = "gst_toc_entry_append_sub_entry")] pub fn append_sub_entry(&mut self, subentry: TocEntry) { unsafe { - ffi::gst_toc_entry_append_sub_entry(self.as_mut_ptr(), subentry.into_ptr()); + ffi::gst_toc_entry_append_sub_entry(self.as_mut_ptr(), subentry.into_glib_ptr()); } } @@ -183,7 +184,7 @@ impl TocEntryRef { #[doc(alias = "gst_toc_entry_set_tags")] pub fn set_tags(&mut self, tag_list: TagList) { unsafe { - ffi::gst_toc_entry_set_tags(self.as_mut_ptr(), tag_list.into_ptr()); + ffi::gst_toc_entry_set_tags(self.as_mut_ptr(), tag_list.into_glib_ptr()); } }