Use IntoGlibPtr trait instead of implementing into_ptr

This commit is contained in:
Guillaume Gomez 2022-05-06 21:41:15 +02:00
parent cd49659fae
commit c1d3ed5eac
59 changed files with 252 additions and 194 deletions

View file

@ -210,7 +210,7 @@ impl AppSrc {
unsafe { unsafe {
try_from_glib(ffi::gst_app_src_push_buffer( try_from_glib(ffi::gst_app_src_push_buffer(
self.to_glib_none().0, self.to_glib_none().0,
buffer.into_ptr(), buffer.into_glib_ptr(),
)) ))
} }
} }
@ -223,7 +223,7 @@ impl AppSrc {
unsafe { unsafe {
try_from_glib(ffi::gst_app_src_push_buffer_list( try_from_glib(ffi::gst_app_src_push_buffer_list(
self.to_glib_none().0, self.to_glib_none().0,
list.into_ptr(), list.into_glib_ptr(),
)) ))
} }
} }

View file

@ -72,7 +72,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_audio_decoder_finish_frame( try_from_glib(ffi::gst_audio_decoder_finish_frame(
self.as_ref().to_glib_none().0, 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, frames,
)) ))
} }
@ -88,7 +88,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_audio_decoder_finish_subframe( try_from_glib(ffi::gst_audio_decoder_finish_subframe(
self.as_ref().to_glib_none().0, 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()),
)) ))
} }
} }

View file

@ -38,7 +38,7 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_audio_encoder_finish_frame( try_from_glib(ffi::gst_audio_encoder_finish_frame(
self.as_ref().to_glib_none().0, 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, frames,
)) ))
} }

View file

@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file. // 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 glib::ToSendValue;
use std::i32; use std::i32;
@ -16,7 +16,7 @@ pub fn audio_buffer_clip(
unsafe { unsafe {
from_glib_full(ffi::gst_audio_buffer_clip( from_glib_full(ffi::gst_audio_buffer_clip(
buffer.into_ptr(), buffer.into_glib_ptr(),
segment.to_glib_none().0, segment.to_glib_none().0,
rate as i32, rate as i32,
bpf as i32, bpf as i32,
@ -37,7 +37,7 @@ pub fn audio_buffer_truncate(
unsafe { unsafe {
from_glib_full(ffi::gst_audio_buffer_truncate( from_glib_full(ffi::gst_audio_buffer_truncate(
buffer.into_ptr(), buffer.into_glib_ptr(),
bpf as i32, bpf as i32,
trim, trim,
samples.unwrap_or(std::usize::MAX), samples.unwrap_or(std::usize::MAX),

View file

@ -129,7 +129,7 @@ unsafe extern "C" fn audio_aggregator_create_output_buffer<T: AudioAggregatorImp
gst::panic_to_error!(&wrap, imp.panicked(), None, { gst::panic_to_error!(&wrap, imp.panicked(), None, {
imp.create_output_buffer(wrap.unsafe_cast_ref(), num_frames) imp.create_output_buffer(wrap.unsafe_cast_ref(), num_frames)
}) })
.map(|buffer| buffer.into_ptr()) .map(|buffer| buffer.into_glib_ptr())
.unwrap_or(ptr::null_mut()) .unwrap_or(ptr::null_mut())
} }

View file

@ -111,6 +111,6 @@ unsafe extern "C" fn audio_aggregator_pad_convert_buffer<T: AudioAggregatorPadIm
&from_glib_none(out_info), &from_glib_none(out_info),
&from_glib_borrow(buffer), &from_glib_borrow(buffer),
) )
.map(|buffer| buffer.into_ptr()) .map(|buffer| buffer.into_glib_ptr())
.unwrap_or(ptr::null_mut()) .unwrap_or(ptr::null_mut())
} }

View file

@ -344,7 +344,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
let data = Self::type_data(); let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass; let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
if let Some(f) = (*parent_class).pre_push { 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( gst::FlowSuccess::try_from_glib(f(
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0, element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
&mut buffer, &mut buffer,
@ -418,7 +418,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
.expect("Missing parent function `sink_event`"); .expect("Missing parent function `sink_event`");
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0, element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -446,7 +446,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
.expect("Missing parent function `src_event`"); .expect("Missing parent function `src_event`");
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0, element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -691,7 +691,7 @@ unsafe extern "C" fn audio_decoder_pre_push<T: AudioDecoderImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) { match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) {
Ok(Some(new_buffer)) => { Ok(Some(new_buffer)) => {
*buffer = new_buffer.into_ptr(); *buffer = new_buffer.into_glib_ptr();
Ok(gst::FlowSuccess::Ok) Ok(gst::FlowSuccess::Ok)
} }
Ok(None) => { Ok(None) => {

View file

@ -299,7 +299,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
let data = Self::type_data(); let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass; let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
if let Some(f) = (*parent_class).pre_push { 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( gst::FlowSuccess::try_from_glib(f(
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0, element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
&mut buffer, &mut buffer,
@ -368,7 +368,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
.expect("Missing parent function `sink_event`"); .expect("Missing parent function `sink_event`");
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0, element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -396,7 +396,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
.expect("Missing parent function `src_event`"); .expect("Missing parent function `src_event`");
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0, element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -614,7 +614,7 @@ unsafe extern "C" fn audio_encoder_pre_push<T: AudioEncoderImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) { match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) {
Ok(Some(new_buffer)) => { Ok(Some(new_buffer)) => {
*buffer = new_buffer.into_ptr(); *buffer = new_buffer.into_glib_ptr();
Ok(gst::FlowSuccess::Ok) Ok(gst::FlowSuccess::Ok)
} }
Ok(None) => { Ok(None) => {

View file

@ -234,7 +234,7 @@ impl Adapter {
#[doc(alias = "gst_adapter_push")] #[doc(alias = "gst_adapter_push")]
pub fn push(&self, buf: gst::Buffer) { pub fn push(&self, buf: gst::Buffer) {
unsafe { 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());
} }
} }
} }

View file

@ -106,7 +106,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_aggregator_finish_buffer( try_from_glib(ffi::gst_aggregator_finish_buffer(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.into_ptr(), buffer.into_glib_ptr(),
)) ))
} }
} }
@ -120,7 +120,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_aggregator_finish_buffer_list( try_from_glib(ffi::gst_aggregator_finish_buffer_list(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
bufferlist.into_ptr(), bufferlist.into_glib_ptr(),
)) ))
} }
} }

View file

@ -149,7 +149,7 @@ impl<'a> BaseParseFrame<'a> {
gst::ffi::gst_mini_object_unref(prev as *mut gst::ffi::GstMiniObject); 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( let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable(
ptr as *const gst::ffi::GstMiniObject, ptr as *const gst::ffi::GstMiniObject,
)); ));

View file

@ -343,7 +343,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
Some(ref func) => from_glib_full(func( Some(ref func) => from_glib_full(func(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
aggregator_pad.to_glib_none().0, aggregator_pad.to_glib_none().0,
buffer.into_ptr(), buffer.into_glib_ptr(),
)), )),
} }
} }
@ -362,7 +362,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
.expect("Missing parent function `finish_buffer`"); .expect("Missing parent function `finish_buffer`");
try_from_glib(f( try_from_glib(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
buffer.into_ptr(), buffer.into_glib_ptr(),
)) ))
} }
} }
@ -382,7 +382,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
.expect("Missing parent function `finish_buffer_list`"); .expect("Missing parent function `finish_buffer_list`");
try_from_glib(f( try_from_glib(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
buffer_list.into_ptr(), buffer_list.into_glib_ptr(),
)) ))
} }
} }
@ -402,7 +402,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
from_glib(f( from_glib(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
aggregator_pad.to_glib_none().0, aggregator_pad.to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -424,7 +424,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
try_from_glib(f( try_from_glib(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
aggregator_pad.to_glib_none().0, aggregator_pad.to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -480,7 +480,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
.expect("Missing parent function `src_event`"); .expect("Missing parent function `src_event`");
from_glib(f( from_glib(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -659,7 +659,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
.expect("Missing parent function `fixate_src_caps`"); .expect("Missing parent function `fixate_src_caps`");
from_glib_full(f( from_glib_full(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
caps.into_ptr(), caps.into_glib_ptr(),
)) ))
} }
} }
@ -847,7 +847,7 @@ unsafe extern "C" fn aggregator_clip<T: AggregatorImpl>(
) )
}); });
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<T: AggregatorImpl>( unsafe extern "C" fn aggregator_finish_buffer<T: AggregatorImpl>(
@ -1117,7 +1117,7 @@ unsafe extern "C" fn aggregator_update_src_caps<T: AggregatorImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
match imp.update_src_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) { match imp.update_src_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
Ok(res_caps) => { Ok(res_caps) => {
*res = res_caps.into_ptr(); *res = res_caps.into_glib_ptr();
gst::FlowReturn::Ok gst::FlowReturn::Ok
} }
Err(err) => err.into(), Err(err) => err.into(),
@ -1137,7 +1137,7 @@ unsafe extern "C" fn aggregator_fixate_src_caps<T: AggregatorImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), { gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
imp.fixate_src_caps(wrap.unsafe_cast_ref(), from_glib_full(caps)) 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<T: AggregatorImpl>( unsafe extern "C" fn aggregator_negotiated_src_caps<T: AggregatorImpl>(

View file

@ -297,7 +297,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
.map(|f| { .map(|f| {
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0, element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
}) })
.unwrap_or(true) .unwrap_or(true)
@ -353,7 +353,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
match (*parent_class).fixate { match (*parent_class).fixate {
Some(fixate) => from_glib_full(fixate( Some(fixate) => from_glib_full(fixate(
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0, element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
caps.into_ptr(), caps.into_glib_ptr(),
)), )),
None => caps, None => caps,
} }
@ -585,7 +585,7 @@ unsafe extern "C" fn base_sink_get_caps<T: BaseSinkImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), None, { gst::panic_to_error!(&wrap, imp.panicked(), None, {
imp.caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref()) 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()) .unwrap_or(ptr::null_mut())
} }
@ -622,7 +622,7 @@ unsafe extern "C" fn base_sink_fixate<T: BaseSinkImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), { gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
imp.fixate(wrap.unsafe_cast_ref(), caps) imp.fixate(wrap.unsafe_cast_ref(), caps)
}) })
.into_ptr() .into_glib_ptr()
} }
unsafe extern "C" fn base_sink_unlock<T: BaseSinkImpl>( unsafe extern "C" fn base_sink_unlock<T: BaseSinkImpl>(

View file

@ -536,7 +536,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
match (*parent_class).fixate { match (*parent_class).fixate {
Some(fixate) => from_glib_full(fixate( Some(fixate) => from_glib_full(fixate(
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0, element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
caps.into_ptr(), caps.into_glib_ptr(),
)), )),
None => caps, None => caps,
} }
@ -759,7 +759,7 @@ unsafe extern "C" fn base_src_alloc<T: BaseSrcImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
match imp.alloc(wrap.unsafe_cast_ref(), offset, length) { match imp.alloc(wrap.unsafe_cast_ref(), offset, length) {
Ok(buffer) => { Ok(buffer) => {
*buffer_ptr = buffer.into_ptr(); *buffer_ptr = buffer.into_glib_ptr();
gst::FlowReturn::Ok gst::FlowReturn::Ok
} }
Err(err) => gst::FlowReturn::from(err), Err(err) => gst::FlowReturn::from(err),
@ -844,7 +844,7 @@ unsafe extern "C" fn base_src_create<T: BaseSrcImpl>(
gst::FlowReturn::Ok gst::FlowReturn::Ok
} }
} else { } else {
*buffer_ptr = new_buffer.into_ptr(); *buffer_ptr = new_buffer.into_glib_ptr();
gst::FlowReturn::Ok gst::FlowReturn::Ok
} }
} }
@ -914,7 +914,7 @@ unsafe extern "C" fn base_src_get_caps<T: BaseSrcImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), None, { gst::panic_to_error!(&wrap, imp.panicked(), None, {
imp.caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref()) 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()) .unwrap_or(ptr::null_mut())
} }
@ -970,7 +970,7 @@ unsafe extern "C" fn base_src_fixate<T: BaseSrcImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), { gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
imp.fixate(wrap.unsafe_cast_ref(), caps) imp.fixate(wrap.unsafe_cast_ref(), caps)
}) })
.into_ptr() .into_glib_ptr()
} }
unsafe extern "C" fn base_src_unlock<T: BaseSrcImpl>( unsafe extern "C" fn base_src_unlock<T: BaseSrcImpl>(

View file

@ -415,7 +415,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0, element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
direction.into_glib(), direction.into_glib(),
caps.to_glib_none().0, caps.to_glib_none().0,
othercaps.into_ptr(), othercaps.into_glib_ptr(),
)), )),
None => othercaps, None => othercaps,
} }
@ -565,7 +565,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
.map(|f| { .map(|f| {
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0, element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
}) })
.unwrap_or(true) .unwrap_or(true)
@ -581,7 +581,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
.map(|f| { .map(|f| {
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0, element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
}) })
.unwrap_or(true) .unwrap_or(true)
@ -844,7 +844,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0, element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
is_discont.into_glib(), is_discont.into_glib(),
inbuf.into_ptr(), inbuf.into_glib_ptr(),
)) ))
} }
} }
@ -1032,7 +1032,7 @@ unsafe extern "C" fn base_transform_transform_caps<T: BaseTransformImpl>(
filter.as_ref().as_ref(), filter.as_ref().as_ref(),
) )
}) })
.map(|caps| caps.into_ptr()) .map(|caps| caps.into_glib_ptr())
.unwrap_or(std::ptr::null_mut()) .unwrap_or(std::ptr::null_mut())
} }
@ -1054,7 +1054,7 @@ unsafe extern "C" fn base_transform_fixate_caps<T: BaseTransformImpl>(
from_glib_full(othercaps), from_glib_full(othercaps),
) )
}) })
.into_ptr() .into_glib_ptr()
} }
unsafe extern "C" fn base_transform_set_caps<T: BaseTransformImpl>( unsafe extern "C" fn base_transform_set_caps<T: BaseTransformImpl>(
@ -1208,7 +1208,7 @@ unsafe extern "C" fn base_transform_prepare_output_buffer<T: BaseTransformImpl>(
!is_passthrough, !is_passthrough,
"Returning Buffer not allowed for passthrough mode" "Returning Buffer not allowed for passthrough mode"
); );
*outbuf = buf.into_ptr(); *outbuf = buf.into_glib_ptr();
gst::FlowReturn::Ok gst::FlowReturn::Ok
} }
Err(err) => err.into(), Err(err) => err.into(),
@ -1451,7 +1451,7 @@ unsafe extern "C" fn base_transform_generate_output<T: BaseTransformImpl>(
Ok(GenerateOutputSuccess::Dropped) => crate::BASE_TRANSFORM_FLOW_DROPPED.into(), Ok(GenerateOutputSuccess::Dropped) => crate::BASE_TRANSFORM_FLOW_DROPPED.into(),
Ok(GenerateOutputSuccess::NoOutput) => gst::FlowReturn::Ok, Ok(GenerateOutputSuccess::NoOutput) => gst::FlowReturn::Ok,
Ok(GenerateOutputSuccess::Buffer(outbuf)) => { Ok(GenerateOutputSuccess::Buffer(outbuf)) => {
*buf = outbuf.into_ptr(); *buf = outbuf.into_glib_ptr();
gst::FlowReturn::Ok gst::FlowReturn::Ok
} }
Err(err) => err.into(), Err(err) => err.into(),

View file

@ -211,7 +211,7 @@ unsafe extern "C" fn push_src_alloc<T: PushSrcImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
match PushSrcImpl::alloc(imp, wrap.unsafe_cast_ref()) { match PushSrcImpl::alloc(imp, wrap.unsafe_cast_ref()) {
Ok(buffer) => { Ok(buffer) => {
*buffer_ptr = buffer.into_ptr(); *buffer_ptr = buffer.into_glib_ptr();
gst::FlowReturn::Ok gst::FlowReturn::Ok
} }
Err(err) => gst::FlowReturn::from(err), Err(err) => gst::FlowReturn::from(err),
@ -289,7 +289,7 @@ unsafe extern "C" fn push_src_create<T: PushSrcImpl>(
gst::FlowReturn::Ok gst::FlowReturn::Ok
} }
} else { } else {
*buffer_ptr = new_buffer.into_ptr(); *buffer_ptr = new_buffer.into_glib_ptr();
gst::FlowReturn::Ok gst::FlowReturn::Ok
} }
} }

View file

@ -301,7 +301,12 @@ impl Harness {
#[doc(alias = "gst_harness_push")] #[doc(alias = "gst_harness_push")]
pub fn push(&mut self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> { pub fn push(&mut self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
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")] #[doc(alias = "gst_harness_push_and_pull")]
@ -309,7 +314,7 @@ impl Harness {
unsafe { unsafe {
Option::<_>::from_glib_full(ffi::gst_harness_push_and_pull( Option::<_>::from_glib_full(ffi::gst_harness_push_and_pull(
self.0.as_ptr(), self.0.as_ptr(),
buffer.into_ptr(), buffer.into_glib_ptr(),
)) ))
.ok_or_else(|| glib::bool_error!("Failed to push and pull buffer")) .ok_or_else(|| glib::bool_error!("Failed to push and pull buffer"))
} }
@ -320,7 +325,7 @@ impl Harness {
unsafe { unsafe {
from_glib(ffi::gst_harness_push_event( from_glib(ffi::gst_harness_push_event(
self.0.as_ptr(), self.0.as_ptr(),
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -340,7 +345,7 @@ impl Harness {
unsafe { unsafe {
from_glib(ffi::gst_harness_push_upstream_event( from_glib(ffi::gst_harness_push_upstream_event(
self.0.as_ptr(), self.0.as_ptr(),
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -364,7 +369,7 @@ impl Harness {
#[doc(alias = "gst_harness_set_caps")] #[doc(alias = "gst_harness_set_caps")]
pub fn set_caps(&mut self, in_: gst::Caps, out: gst::Caps) { pub fn set_caps(&mut self, in_: gst::Caps, out: gst::Caps) {
unsafe { 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")] #[doc(alias = "gst_harness_set_sink_caps")]
pub fn set_sink_caps(&mut self, caps: gst::Caps) { pub fn set_sink_caps(&mut self, caps: gst::Caps) {
unsafe { 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")] #[doc(alias = "gst_harness_set_src_caps")]
pub fn set_src_caps(&mut self, caps: gst::Caps) { pub fn set_src_caps(&mut self, caps: gst::Caps) {
unsafe { 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());
} }
} }

View file

@ -361,6 +361,6 @@ unsafe extern "C" fn transform_internal_caps<T: GLFilterImpl>(
filter_caps.as_ref().as_ref(), filter_caps.as_ref().as_ref(),
) )
}) })
.map(|caps| caps.into_ptr()) .map(|caps| caps.into_glib_ptr())
.unwrap_or(std::ptr::null_mut()) .unwrap_or(std::ptr::null_mut())
} }

View file

@ -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); let mut s = mem::ManuallyDrop::new(self);
s.0.to_glib_none_mut().0 s.0.to_glib_none_mut().0
} }

View file

@ -19,7 +19,7 @@ impl Player {
pub fn set_config(&self, config: crate::PlayerConfig) -> Result<(), glib::error::BoolError> { pub fn set_config(&self, config: crate::PlayerConfig) -> Result<(), glib::error::BoolError> {
unsafe { unsafe {
glib::result_from_gboolean!( 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", "Failed to set config",
) )
} }

View file

@ -19,7 +19,7 @@ impl<O: IsA<RTPBaseDepayload>> RTPBaseDepayloadExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_rtp_base_depayload_push( try_from_glib(ffi::gst_rtp_base_depayload_push(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
out_buf.into_ptr(), out_buf.into_glib_ptr(),
)) ))
} }
} }
@ -28,7 +28,7 @@ impl<O: IsA<RTPBaseDepayload>> RTPBaseDepayloadExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_rtp_base_depayload_push_list( try_from_glib(ffi::gst_rtp_base_depayload_push_list(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
out_list.into_ptr(), out_list.into_glib_ptr(),
)) ))
} }
} }

View file

@ -42,7 +42,7 @@ impl<O: IsA<RTPBasePayload>> RTPBasePayloadExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_rtp_base_payload_push( try_from_glib(ffi::gst_rtp_base_payload_push(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.into_ptr(), buffer.into_glib_ptr(),
)) ))
} }
} }
@ -51,7 +51,7 @@ impl<O: IsA<RTPBasePayload>> RTPBasePayloadExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_rtp_base_payload_push_list( try_from_glib(ffi::gst_rtp_base_payload_push_list(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
list.into_ptr(), list.into_glib_ptr(),
)) ))
} }
} }

View file

@ -88,7 +88,7 @@ impl<T: RTPBaseDepayloadImpl> RTPBaseDepayloadImplExt for T {
.unsafe_cast_ref::<RTPBaseDepayload>() .unsafe_cast_ref::<RTPBaseDepayload>()
.to_glib_none() .to_glib_none()
.0, .0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
}) })
.unwrap_or(false) .unwrap_or(false)
@ -212,7 +212,7 @@ unsafe extern "C" fn rtp_base_depayload_process_rtp_packet<T: RTPBaseDepayloadIm
let bufwrap = crate::RTPBuffer::<crate::rtp_buffer::Readable>::from_glib_borrow(rtp_packet); let bufwrap = crate::RTPBuffer::<crate::rtp_buffer::Readable>::from_glib_borrow(rtp_packet);
imp.process_rtp_packet(wrap.unsafe_cast_ref(), &bufwrap) 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()) .unwrap_or(ptr::null_mut())
}) })
} }

View file

@ -129,7 +129,7 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
.map(|f| { .map(|f| {
try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0, element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0,
buffer.into_ptr(), buffer.into_glib_ptr(),
)) ))
}) })
.unwrap_or(Err(gst::FlowError::Error)) .unwrap_or(Err(gst::FlowError::Error))
@ -167,7 +167,7 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
.map(|f| { .map(|f| {
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0, element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
}) })
.unwrap_or(false) .unwrap_or(false)
@ -183,7 +183,7 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
.map(|f| { .map(|f| {
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0, element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
}) })
.unwrap_or(false) .unwrap_or(false)

View file

@ -1,6 +1,6 @@
use crate::auto::Navigation; use crate::auto::Navigation;
use glib::object::IsA; use glib::object::IsA;
use glib::translate::ToGlibPtr; use glib::translate::{IntoGlibPtr, ToGlibPtr};
pub trait NavigationExtManual: 'static { pub trait NavigationExtManual: 'static {
#[doc(alias = "gst_navigation_send_event")] #[doc(alias = "gst_navigation_send_event")]
@ -15,7 +15,10 @@ pub trait NavigationExtManual: 'static {
impl<O: IsA<Navigation>> NavigationExtManual for O { impl<O: IsA<Navigation>> NavigationExtManual for O {
fn send_event(&self, structure: gst::Structure) { fn send_event(&self, structure: gst::Structure) {
unsafe { 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<O: IsA<Navigation>> NavigationExtManual for O {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
fn send_event_simple(&self, event: gst::Event) { fn send_event_simple(&self, event: gst::Event) {
unsafe { 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(),
);
} }
} }
} }

View file

@ -45,7 +45,7 @@ impl<T: NavigationImpl> NavigationImplExt for T {
func( func(
nav.unsafe_cast_ref::<Navigation>().to_glib_none().0, nav.unsafe_cast_ref::<Navigation>().to_glib_none().0,
structure.into_ptr(), structure.into_glib_ptr(),
); );
} }
} }
@ -65,7 +65,7 @@ impl<T: NavigationImpl> NavigationImplExt for T {
func( func(
nav.unsafe_cast_ref::<Navigation>().to_glib_none().0, nav.unsafe_cast_ref::<Navigation>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
); );
} }
} }

View file

@ -210,7 +210,7 @@ unsafe extern "C" fn video_aggregator_update_caps<T: VideoAggregatorImpl>(
gst::panic_to_error!(&wrap, imp.panicked(), ptr::null_mut(), { gst::panic_to_error!(&wrap, imp.panicked(), ptr::null_mut(), {
match imp.update_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) { 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(err) => {
err.log_with_object(&*wrap); err.log_with_object(&*wrap);
ptr::null_mut() ptr::null_mut()
@ -254,7 +254,7 @@ unsafe extern "C" fn video_aggregator_create_output_buffer<T: VideoAggregatorImp
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, { gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
match imp.create_output_buffer(wrap.unsafe_cast_ref()) { match imp.create_output_buffer(wrap.unsafe_cast_ref()) {
Ok(buffer) => { Ok(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) Ok(gst::FlowSuccess::Ok)
} }
Err(err) => { Err(err) => {

View file

@ -444,7 +444,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
.expect("Missing parent function `sink_event`"); .expect("Missing parent function `sink_event`");
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0, element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -472,7 +472,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
.expect("Missing parent function `src_event`"); .expect("Missing parent function `src_event`");
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0, element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }

View file

@ -360,7 +360,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
.expect("Missing parent function `sink_event`"); .expect("Missing parent function `sink_event`");
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0, element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }
@ -388,7 +388,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
.expect("Missing parent function `src_event`"); .expect("Missing parent function `src_event`");
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0, element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
} }
} }

View file

@ -189,7 +189,7 @@ impl<'a> VideoCodecFrame<'a> {
gst::ffi::gst_mini_object_unref(prev as *mut gst::ffi::GstMiniObject); 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( let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable(
ptr as *const gst::ffi::GstMiniObject, ptr as *const gst::ffi::GstMiniObject,
)); ));
@ -217,9 +217,10 @@ impl<'a> VideoCodecFrame<'a> {
pub fn num_subframes(&self) -> u32 { pub fn num_subframes(&self) -> u32 {
unsafe { (*self.to_glib_none().0).abidata.ABI.num_subframes } unsafe { (*self.to_glib_none().0).abidata.ABI.num_subframes }
} }
}
#[doc(hidden)] impl<'a> IntoGlibPtr<*mut ffi::GstVideoCodecFrame> for VideoCodecFrame<'a> {
pub unsafe fn into_ptr(self) -> *mut ffi::GstVideoCodecFrame { unsafe fn into_glib_ptr(self) -> *mut ffi::GstVideoCodecFrame {
let stream_lock = self.element.stream_lock(); let stream_lock = self.element.stream_lock();
glib::ffi::g_rec_mutex_unlock(stream_lock); glib::ffi::g_rec_mutex_unlock(stream_lock);

View file

@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file. // 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::ops;
use std::ptr; use std::ptr;
@ -40,7 +40,9 @@ impl VideoConverter {
let ptr = ffi::gst_video_converter_new( let ptr = ffi::gst_video_converter_new(
in_info.to_glib_none().0 as *mut _, in_info.to_glib_none().0 as *mut _,
out_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() { if ptr.is_null() {
Err(glib::bool_error!("Failed to create video converter")) Err(glib::bool_error!("Failed to create video converter"))
@ -66,7 +68,7 @@ impl VideoConverter {
#[doc(alias = "gst_video_converter_set_config")] #[doc(alias = "gst_video_converter_set_config")]
pub fn set_config(&mut self, config: VideoConverterConfig) { pub fn set_config(&mut self, config: VideoConverterConfig) {
unsafe { 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());
} }
} }

View file

@ -151,7 +151,7 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_video_decoder_finish_frame( try_from_glib(ffi::gst_video_decoder_finish_frame(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
frame.into_ptr(), frame.into_glib_ptr(),
)) ))
} }
} }
@ -159,7 +159,10 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
#[doc(alias = "gst_video_decoder_release_frame")] #[doc(alias = "gst_video_decoder_release_frame")]
fn release_frame(&self, frame: VideoCodecFrame) { fn release_frame(&self, frame: VideoCodecFrame) {
unsafe { 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<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_video_decoder_drop_frame( try_from_glib(ffi::gst_video_decoder_drop_frame(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
frame.into_ptr(), frame.into_glib_ptr(),
)) ))
} }
} }

View file

@ -108,7 +108,7 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_video_encoder_finish_frame( try_from_glib(ffi::gst_video_encoder_finish_frame(
self.as_ref().to_glib_none().0, 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<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
}; };
ffi::gst_video_encoder_set_output_state( ffi::gst_video_encoder_set_output_state(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
caps.into_ptr(), caps.into_glib_ptr(),
reference, reference,
) )
}; };

View file

@ -3,7 +3,7 @@
use std::fmt; use std::fmt;
use std::ptr; 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::*; use gst::prelude::*;
#[repr(transparent)] #[repr(transparent)]
@ -388,7 +388,7 @@ impl VideoRegionOfInterestMeta {
#[doc(alias = "gst_video_region_of_interest_meta_add_param")] #[doc(alias = "gst_video_region_of_interest_meta_add_param")]
pub fn add_param(&mut self, s: gst::Structure) { pub fn add_param(&mut self, s: gst::Structure) {
unsafe { 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());
} }
} }
} }

View file

@ -18,7 +18,9 @@ use crate::ClockTime;
use crate::Memory; use crate::Memory;
use crate::MemoryRef; 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 Readable {}
pub enum Writable {} pub enum Writable {}
@ -173,7 +175,7 @@ impl Buffer {
pub fn append(&mut self, other: Self) { pub fn append(&mut self, other: Self) {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { 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); self.replace_ptr(ptr);
} }
} }
@ -529,7 +531,7 @@ impl BufferRef {
#[doc(alias = "gst_buffer_append_memory")] #[doc(alias = "gst_buffer_append_memory")]
pub fn append_memory(&mut self, mem: 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")] #[doc(alias = "gst_buffer_find_memory")]
@ -622,7 +624,7 @@ impl BufferRef {
Some(val) => val as i32, Some(val) => val as i32,
None => -1, None => -1,
}, },
mem.into_ptr(), mem.into_glib_ptr(),
) )
} }
} }
@ -675,7 +677,7 @@ impl BufferRef {
#[doc(alias = "gst_buffer_prepend_memory")] #[doc(alias = "gst_buffer_prepend_memory")]
pub fn prepend_memory(&mut self, mem: 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")] #[doc(alias = "gst_buffer_remove_all_memory")]
@ -706,13 +708,13 @@ impl BufferRef {
#[doc(alias = "gst_buffer_replace_all_memory")] #[doc(alias = "gst_buffer_replace_all_memory")]
pub fn replace_all_memory(&mut self, mem: 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")] #[doc(alias = "gst_buffer_replace_memory")]
pub fn replace_memory(&mut self, idx: u32, mem: Memory) { pub fn replace_memory(&mut self, idx: u32, mem: Memory) {
assert!(idx < self.n_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")] #[doc(alias = "gst_buffer_replace_memory_range")]
@ -726,7 +728,7 @@ impl BufferRef {
Some(val) => val as i32, Some(val) => val as i32,
None => -1, None => -1,
}, },
mem.into_ptr(), mem.into_glib_ptr(),
) )
} }
} }

View file

@ -364,7 +364,7 @@ impl<O: IsA<BufferPool>> BufferPoolExtManual for O {
glib::result_from_gboolean!( glib::result_from_gboolean!(
ffi::gst_buffer_pool_set_config( ffi::gst_buffer_pool_set_config(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
config.0.into_ptr() config.0.into_glib_ptr()
), ),
"Failed to set config", "Failed to set config",
) )
@ -399,7 +399,10 @@ impl<O: IsA<BufferPool>> BufferPoolExtManual for O {
fn release_buffer(&self, buffer: crate::Buffer) { fn release_buffer(&self, buffer: crate::Buffer) {
unsafe { 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(),
);
} }
} }
} }

View file

@ -1,6 +1,6 @@
// Take a look at the license at the top of the repository in the LICENSE file. // 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::fmt;
use std::ops::ControlFlow; use std::ops::ControlFlow;
use std::ptr; use std::ptr;
@ -30,7 +30,7 @@ impl BufferListRef {
#[doc(alias = "gst_buffer_list_insert")] #[doc(alias = "gst_buffer_list_insert")]
pub fn insert(&mut self, idx: i32, buffer: Buffer) { pub fn insert(&mut self, idx: i32, buffer: Buffer) {
unsafe { 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(); *buffer = ptr::null_mut();
} }
Some(new_buffer) => { Some(new_buffer) => {
*buffer = new_buffer.into_ptr(); *buffer = new_buffer.into_glib_ptr();
} }
} }

View file

@ -9,7 +9,9 @@ use std::str;
use crate::CapsIntersectMode; 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; use glib::value::ToSendValue;
mini_object_wrapper!(Caps, CapsRef, ffi::GstCaps, || { ffi::gst_caps_get_type() }); 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) { pub fn merge(&mut self, other: Self) {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { 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); self.replace_ptr(ptr);
} }
} }
@ -90,7 +92,7 @@ impl Caps {
pub fn merge_structure(&mut self, structure: Structure) { pub fn merge_structure(&mut self, structure: Structure) {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { 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); self.replace_ptr(ptr);
} }
} }
@ -101,8 +103,10 @@ impl Caps {
unsafe { unsafe {
let ptr = ffi::gst_caps_merge_structure_full( let ptr = ffi::gst_caps_merge_structure_full(
self.as_mut_ptr(), self.as_mut_ptr(),
structure.into_ptr(), structure.into_glib_ptr(),
features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), features
.map(|f| f.into_glib_ptr())
.unwrap_or(ptr::null_mut()),
); );
self.replace_ptr(ptr); self.replace_ptr(ptr);
} }
@ -297,7 +301,9 @@ impl CapsRef {
ffi::gst_caps_set_features( ffi::gst_caps_set_features(
self.as_mut_ptr(), self.as_mut_ptr(),
idx, 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 { unsafe {
ffi::gst_caps_set_features_simple( ffi::gst_caps_set_features_simple(
self.as_mut_ptr(), 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")] #[doc(alias = "gst_caps_append_structure")]
pub fn append_structure(&mut self, structure: 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")] #[doc(alias = "gst_caps_append_structure_full")]
@ -346,8 +354,10 @@ impl CapsRef {
unsafe { unsafe {
ffi::gst_caps_append_structure_full( ffi::gst_caps_append_structure_full(
self.as_mut_ptr(), self.as_mut_ptr(),
structure.into_ptr(), structure.into_glib_ptr(),
features.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), features
.map(|f| f.into_glib_ptr())
.unwrap_or(ptr::null_mut()),
) )
} }
} }
@ -359,7 +369,7 @@ impl CapsRef {
#[doc(alias = "gst_caps_append")] #[doc(alias = "gst_caps_append")]
pub fn append(&mut self, other: Caps) { 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")] #[doc(alias = "gst_caps_can_intersect")]

View file

@ -59,8 +59,10 @@ impl CapsFeatures {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { CapsFeatures(ptr::NonNull::new_unchecked(ffi::gst_caps_features_new_any())) } 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); let s = mem::ManuallyDrop::new(self);
s.0.as_ptr() s.0.as_ptr()
} }

View file

@ -299,7 +299,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
unsafe { unsafe {
from_glib(ffi::gst_element_send_event( from_glib(ffi::gst_element_send_event(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
event.into().into_ptr(), event.into().into_glib_ptr(),
)) ))
} }
} }
@ -399,7 +399,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
file.to_glib_none().0, file.to_glib_none().0,
function.to_glib_none().0, function.to_glib_none().0,
line as i32, line as i32,
structure.into_ptr(), structure.into_glib_ptr(),
); );
} }
} }
@ -407,7 +407,10 @@ impl<O: IsA<Element>> ElementExtManual for O {
fn post_message(&self, message: crate::Message) -> Result<(), glib::error::BoolError> { fn post_message(&self, message: crate::Message) -> Result<(), glib::error::BoolError> {
unsafe { unsafe {
glib::result_from_gboolean!( 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" "Failed to post message"
) )
} }

View file

@ -1746,7 +1746,7 @@ impl<'a> TagBuilder<'a> {
event_builder_generic_impl!(|s: &mut Self| { event_builder_generic_impl!(|s: &mut Self| {
let tags = s.tags.take().unwrap(); 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| { event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take().unwrap(); 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| { event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take().unwrap(); 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| { event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take().unwrap(); 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| { event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take().unwrap(); 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(); let structure = s.structure.take().unwrap();
ffi::gst_event_new_custom( ffi::gst_event_new_custom(
ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, 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| { event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take().unwrap(); 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| { event_builder_generic_impl!(|s: &mut Self| {
let structure = s.structure.take().unwrap(); 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())
}); });
} }

View file

@ -32,12 +32,6 @@ impl<T> Iterator<T>
where where
for<'a> T: FromValue<'a> + 'static, 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)] #[allow(clippy::should_implement_trait)]
#[doc(alias = "gst_iterator_next")] #[doc(alias = "gst_iterator_next")]
pub fn next(&mut self) -> Result<Option<T>, IteratorError> { pub fn next(&mut self) -> Result<Option<T>, IteratorError> {
@ -81,7 +75,7 @@ where
); );
from_glib_full(ffi::gst_iterator_filter( from_glib_full(ffi::gst_iterator_filter(
self.into_ptr(), self.into_glib_ptr(),
Some(filter_trampoline::<T>), Some(filter_trampoline::<T>),
closure_value.to_glib_none().0, closure_value.to_glib_none().0,
)) ))
@ -212,6 +206,17 @@ where
} }
} }
impl<T> IntoGlibPtr<*mut ffi::GstIterator> for Iterator<T>
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)] #[repr(C)]
struct RsIterator<T, I: IteratorImpl<T>> struct RsIterator<T, I: IteratorImpl<T>>
where where

View file

@ -7,7 +7,7 @@ use std::ops::{Deref, DerefMut};
use std::ptr; use std::ptr;
use std::slice; 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::AllocationParams;
use crate::Allocator; use crate::Allocator;
@ -602,7 +602,7 @@ impl Memory {
<M as crate::prelude::IsMiniObject>::RefType: AsRef<MemoryRef> + AsMut<MemoryRef>, <M as crate::prelude::IsMiniObject>::RefType: AsRef<MemoryRef> + AsMut<MemoryRef>,
{ {
if M::check_memory_type(&self) { 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 { } else {
Err(self) Err(self)
} }
@ -663,7 +663,7 @@ macro_rules! memory_object_wrapper {
if M::check_memory_type(&self) { if M::check_memory_type(&self) {
unsafe { unsafe {
Ok($crate::glib::translate::from_glib_full( Ok($crate::glib::translate::from_glib_full(
self.into_ptr() as *mut M::FfiType self.into_glib_ptr() as *mut M::FfiType
)) ))
} }
} else { } else {
@ -683,7 +683,7 @@ macro_rules! memory_object_wrapper {
{ {
unsafe { unsafe {
$crate::glib::translate::from_glib_full( $crate::glib::translate::from_glib_full(
self.into_ptr() as *const <M as $crate::miniobject::IsMiniObject>::FfiType self.into_glib_ptr() as *const <M as $crate::miniobject::IsMiniObject>::FfiType
) )
} }
} }

View file

@ -1939,7 +1939,7 @@ impl<'a> ErrorBuilder<'a> {
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| {
let details = match s.details.take() { let details = match s.details.take() {
None => ptr::null_mut(), None => ptr::null_mut(),
Some(details) => details.into_ptr(), Some(details) => details.into_glib_ptr(),
}; };
ffi::gst_message_new_error_with_details( ffi::gst_message_new_error_with_details(
@ -1988,7 +1988,7 @@ impl<'a> WarningBuilder<'a> {
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| {
let details = match s.details.take() { let details = match s.details.take() {
None => ptr::null_mut(), None => ptr::null_mut(),
Some(details) => details.into_ptr(), Some(details) => details.into_glib_ptr(),
}; };
ffi::gst_message_new_warning_with_details( ffi::gst_message_new_warning_with_details(
@ -2037,7 +2037,7 @@ impl<'a> InfoBuilder<'a> {
message_builder_generic_impl!(|s: &mut Self, src| { message_builder_generic_impl!(|s: &mut Self, src| {
let details = match s.details.take() { let details = match s.details.take() {
None => ptr::null_mut(), None => ptr::null_mut(),
Some(details) => details.into_ptr(), Some(details) => details.into_glib_ptr(),
}; };
ffi::gst_message_new_info_with_details( 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( message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_application(
src, 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( message_builder_generic_impl!(|s: &mut Self, src| ffi::gst_message_new_element(
src, 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| { message_builder_generic_impl!(|s: &mut Self, src| {
let context = s.context.take().unwrap(); 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| { message_builder_generic_impl!(|s: &mut Self, src| {
let entry_struct = s.entry_struct.take(); let entry_struct = s.entry_struct.take();
let entry_struct_ptr = if let Some(entry_struct) = entry_struct { let entry_struct_ptr = if let Some(entry_struct) = entry_struct {
entry_struct.into_ptr() entry_struct.into_glib_ptr()
} else { } else {
ptr::null_mut() ptr::null_mut()
}; };
@ -3000,7 +3000,7 @@ impl<'a> RedirectBuilder<'a> {
for &(location, tag_list, entry_struct) in entries { for &(location, tag_list, entry_struct) in entries {
let entry_struct = entry_struct.cloned(); let entry_struct = entry_struct.cloned();
let entry_struct_ptr = if let Some(entry_struct) = entry_struct { let entry_struct_ptr = if let Some(entry_struct) = entry_struct {
entry_struct.into_ptr() entry_struct.into_glib_ptr()
} else { } else {
ptr::null_mut() ptr::null_mut()
}; };

View file

@ -411,7 +411,8 @@ impl ProtectionMeta {
pub fn add(buffer: &mut BufferRef, info: crate::Structure) -> MetaRefMut<Self, Standalone> { pub fn add(buffer: &mut BufferRef, info: crate::Structure) -> MetaRefMut<Self, Standalone> {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { 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) Self::from_mut_ptr(buffer, meta)
} }

View file

@ -96,12 +96,16 @@ macro_rules! mini_object_wrapper (
#[must_use] #[must_use]
pub fn upcast(self) -> $crate::miniobject::MiniObject { pub fn upcast(self) -> $crate::miniobject::MiniObject {
use $crate::glib::translate::IntoGlibPtr;
unsafe { 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); let s = std::mem::ManuallyDrop::new(self);
s.as_mut_ptr() s.as_mut_ptr()
} }
@ -547,7 +551,7 @@ mini_object_wrapper!(MiniObject, MiniObjectRef, ffi::GstMiniObject, || {
impl MiniObject { impl MiniObject {
pub fn downcast<T: IsMiniObject + glib::StaticType>(self) -> Result<T, Self> { pub fn downcast<T: IsMiniObject + glib::StaticType>(self) -> Result<T, Self> {
if self.type_().is_a(T::static_type()) { 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 { } else {
Err(self) Err(self)
} }

View file

@ -366,7 +366,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_pad_chain( try_from_glib(ffi::gst_pad_chain(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.into_ptr(), buffer.into_glib_ptr(),
)) ))
} }
} }
@ -375,7 +375,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_pad_push( try_from_glib(ffi::gst_pad_push(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.into_ptr(), buffer.into_glib_ptr(),
)) ))
} }
} }
@ -384,7 +384,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_pad_chain_list( try_from_glib(ffi::gst_pad_chain_list(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
list.into_ptr(), list.into_glib_ptr(),
)) ))
} }
} }
@ -393,7 +393,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe { unsafe {
try_from_glib(ffi::gst_pad_push_list( try_from_glib(ffi::gst_pad_push_list(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
list.into_ptr(), list.into_glib_ptr(),
)) ))
} }
} }
@ -539,7 +539,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
from_glib(ffi::gst_pad_event_default( from_glib(ffi::gst_pad_event_default(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
parent.map(|p| p.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<O: IsA<Pad>> PadExtManual for O {
unsafe { unsafe {
from_glib(ffi::gst_pad_push_event( from_glib(ffi::gst_pad_push_event(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
event.into().into_ptr(), event.into().into_glib_ptr(),
)) ))
} }
} }
@ -557,7 +557,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
unsafe { unsafe {
from_glib(ffi::gst_pad_send_event( from_glib(ffi::gst_pad_send_event(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
event.into().into_ptr(), event.into().into_glib_ptr(),
)) ))
} }
} }
@ -1039,7 +1039,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
} }
Replace(ev) => { Replace(ev) => {
ffi::gst_mini_object_unref(*event as *mut _); 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 { match probe_info.data {
Some(PadProbeData::Buffer(buffer)) => { Some(PadProbeData::Buffer(buffer)) => {
assert_eq!(data_type, Some(Buffer::static_type())); 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)) => { Some(PadProbeData::BufferList(bufferlist)) => {
assert_eq!(data_type, Some(BufferList::static_type())); 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)) => { Some(PadProbeData::Event(event)) => {
assert_eq!(data_type, Some(Event::static_type())); 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)) => { Some(PadProbeData::Query(query)) => {
assert_eq!(data_type, Some(Query::static_type())); assert_eq!(data_type, Some(Query::static_type()));
@ -1483,7 +1483,7 @@ where
} }
} }
} else { } else {
*buffer = new_buffer.into_ptr(); *buffer = new_buffer.into_glib_ptr();
FlowReturn::Ok.into_glib() FlowReturn::Ok.into_glib()
} }
} }
@ -1515,7 +1515,7 @@ where
.as_ref(), .as_ref(),
); );
ret.into_ptr() ret.into_glib_ptr()
} }
unsafe extern "C" fn trampoline_link_function< unsafe extern "C" fn trampoline_link_function<

View file

@ -25,7 +25,7 @@ impl Plugin {
#[doc(alias = "gst_plugin_set_cache_data")] #[doc(alias = "gst_plugin_set_cache_data")]
pub fn set_cache_data(&self, cache_data: Structure) { pub fn set_cache_data(&self, cache_data: Structure) {
unsafe { 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());
} }
} }
} }

View file

@ -127,7 +127,7 @@ impl Promise {
unsafe { unsafe {
ffi::gst_promise_reply( ffi::gst_promise_reply(
self.to_glib_none().0, 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()),
); );
} }
} }

View file

@ -53,7 +53,7 @@ impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
try_from_glib(ffi::gst_proxy_pad_chain_default( try_from_glib(ffi::gst_proxy_pad_chain_default(
self.as_ptr() as *mut ffi::GstPad, self.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0,
buffer.into_ptr(), buffer.into_glib_ptr(),
)) ))
} }
} }
@ -68,7 +68,7 @@ impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
try_from_glib(ffi::gst_proxy_pad_chain_list_default( try_from_glib(ffi::gst_proxy_pad_chain_list_default(
self.as_ptr() as *mut ffi::GstPad, self.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0,
list.into_ptr(), list.into_glib_ptr(),
)) ))
} }
} }

View file

@ -910,7 +910,7 @@ impl Custom<Query> {
unsafe { unsafe {
Self(from_glib_full(ffi::gst_query_new_custom( Self(from_glib_full(ffi::gst_query_new_custom(
ffi::GST_QUERY_CUSTOM, ffi::GST_QUERY_CUSTOM,
structure.into_ptr(), structure.into_glib_ptr(),
))) )))
} }
} }

View file

@ -3,7 +3,7 @@
use std::fmt; use std::fmt;
use std::ptr; 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::Buffer;
use crate::BufferList; use crate::BufferList;
@ -74,7 +74,10 @@ impl<'a> SampleBuilder<'a> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();
unsafe { 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( let sample: Sample = from_glib_full(ffi::gst_sample_new(
self.buffer.to_glib_none().0, self.buffer.to_glib_none().0,
@ -223,7 +226,7 @@ impl SampleRef {
unsafe { unsafe {
ffi::gst_sample_set_info( ffi::gst_sample_set_info(
self.as_mut_ptr(), 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()),
); );
} }
} }

View file

@ -73,11 +73,6 @@ impl Structure {
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)] #[allow(clippy::should_implement_trait)]
pub fn from_iter<'a>( pub fn from_iter<'a>(
name: &str, 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 { impl Deref for Structure {
type Target = StructureRef; type Target = StructureRef;

View file

@ -91,7 +91,7 @@ impl<T: BinImpl> BinImplExt for T {
if let Some(ref f) = (*parent_class).handle_message { if let Some(ref f) = (*parent_class).handle_message {
f( f(
bin.unsafe_cast_ref::<crate::Bin>().to_glib_none().0, bin.unsafe_cast_ref::<crate::Bin>().to_glib_none().0,
message.into_ptr(), message.into_glib_ptr(),
); );
} }
} }

View file

@ -162,7 +162,7 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
.unsafe_cast_ref::<crate::BufferPool>() .unsafe_cast_ref::<crate::BufferPool>()
.to_glib_none() .to_glib_none()
.0, .0,
buffer.into_ptr(), buffer.into_glib_ptr(),
) )
} }
} }
@ -178,7 +178,7 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
.unsafe_cast_ref::<crate::BufferPool>() .unsafe_cast_ref::<crate::BufferPool>()
.to_glib_none() .to_glib_none()
.0, .0,
buffer.into_ptr(), buffer.into_glib_ptr(),
) )
} }
} }
@ -336,7 +336,7 @@ unsafe extern "C" fn buffer_pool_acquire_buffer<T: BufferPoolImpl>(
match imp.acquire_buffer(wrap.unsafe_cast_ref(), params.as_ref()) { match imp.acquire_buffer(wrap.unsafe_cast_ref(), params.as_ref()) {
Ok(b) => { Ok(b) => {
*buffer = b.into_ptr(); *buffer = b.into_glib_ptr();
ffi::GST_FLOW_OK ffi::GST_FLOW_OK
} }
Err(err) => err.into_glib(), Err(err) => err.into_glib(),
@ -355,7 +355,7 @@ unsafe extern "C" fn buffer_pool_alloc_buffer<T: BufferPoolImpl>(
match imp.alloc_buffer(wrap.unsafe_cast_ref(), params.as_ref()) { match imp.alloc_buffer(wrap.unsafe_cast_ref(), params.as_ref()) {
Ok(b) => { Ok(b) => {
*buffer = b.into_ptr(); *buffer = b.into_glib_ptr();
ffi::GST_FLOW_OK ffi::GST_FLOW_OK
} }
Err(err) => err.into_glib(), Err(err) => err.into_glib(),

View file

@ -247,7 +247,7 @@ impl<T: ElementImpl> ElementImplExt for T {
.map(|f| { .map(|f| {
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<Element>().to_glib_none().0, element.unsafe_cast_ref::<Element>().to_glib_none().0,
event.into_ptr(), event.into_glib_ptr(),
)) ))
}) })
.unwrap_or(false) .unwrap_or(false)
@ -325,7 +325,7 @@ impl<T: ElementImpl> ElementImplExt for T {
if let Some(f) = (*parent_class).post_message { if let Some(f) = (*parent_class).post_message {
from_glib(f( from_glib(f(
element.unsafe_cast_ref::<Element>().to_glib_none().0, element.unsafe_cast_ref::<Element>().to_glib_none().0,
msg.into_ptr(), msg.into_glib_ptr(),
)) ))
} else { } else {
false false

View file

@ -77,7 +77,7 @@ unsafe extern "C" fn task_pool_prepare<T: TaskPoolImpl>(
Ok(()) => {} Ok(()) => {}
Err(err) => { Err(err) => {
if !error.is_null() { if !error.is_null() {
*error = err.into_raw(); *error = err.into_glib_ptr();
} }
} }
} }
@ -109,7 +109,7 @@ unsafe extern "C" fn task_pool_push<T: TaskPoolImpl>(
Err(err) => { Err(err) => {
func.prevent_call(); func.prevent_call();
if !error.is_null() { if !error.is_null() {
*error = err.into_raw(); *error = err.into_glib_ptr();
} }
ptr::null_mut() ptr::null_mut()
} }

View file

@ -145,7 +145,7 @@ unsafe extern "C" fn uri_handler_set_uri<T: URIHandlerImpl>(
Ok(()) => true.into_glib(), Ok(()) => true.into_glib(),
Err(error) => { Err(error) => {
if !err.is_null() { if !err.is_null() {
*err = error.into_raw(); *err = error.into_glib_ptr();
} }
false.into_glib() false.into_glib()
} }

View file

@ -5,7 +5,8 @@ use std::fmt;
use std::mem; use std::mem;
use glib::translate::{ 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; use crate::TagList;
@ -45,7 +46,7 @@ impl TocRef {
#[doc(alias = "gst_toc_append_entry")] #[doc(alias = "gst_toc_append_entry")]
pub fn append_entry(&mut self, entry: TocEntry) { pub fn append_entry(&mut self, entry: TocEntry) {
unsafe { 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")] #[doc(alias = "gst_toc_set_tags")]
pub fn set_tags(&mut self, tag_list: TagList) { pub fn set_tags(&mut self, tag_list: TagList) {
unsafe { 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")] #[doc(alias = "gst_toc_entry_append_sub_entry")]
pub fn append_sub_entry(&mut self, subentry: TocEntry) { pub fn append_sub_entry(&mut self, subentry: TocEntry) {
unsafe { 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")] #[doc(alias = "gst_toc_entry_set_tags")]
pub fn set_tags(&mut self, tag_list: TagList) { pub fn set_tags(&mut self, tag_list: TagList) {
unsafe { 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());
} }
} }