mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
Use IntoGlibPtr
trait instead of to_glib_full()
where appropriate to reduce unnecessary refcounting/copying
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1183>
This commit is contained in:
parent
5e852fa0ff
commit
8d30bcbf4b
26 changed files with 73 additions and 70 deletions
|
@ -61,8 +61,8 @@ fn configure_encodebin(encodebin: &gst::Element) {
|
||||||
&gst::Caps::builder("video/x-matroska").build(),
|
&gst::Caps::builder("video/x-matroska").build(),
|
||||||
)
|
)
|
||||||
.name("container")
|
.name("container")
|
||||||
.add_profile(&(video_profile))
|
.add_profile(video_profile)
|
||||||
.add_profile(&(audio_profile))
|
.add_profile(audio_profile)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Finally, apply the EncodingProfile onto our encodebin element.
|
// Finally, apply the EncodingProfile onto our encodebin element.
|
||||||
|
|
|
@ -58,8 +58,8 @@ fn configure_pipeline(pipeline: &ges::Pipeline, output_name: &str) {
|
||||||
let container_profile =
|
let container_profile =
|
||||||
gst_pbutils::EncodingContainerProfile::builder(&gst::Caps::builder("video/webm").build())
|
gst_pbutils::EncodingContainerProfile::builder(&gst::Caps::builder("video/webm").build())
|
||||||
.name("container")
|
.name("container")
|
||||||
.add_profile(&video_profile)
|
.add_profile(video_profile)
|
||||||
.add_profile(&audio_profile)
|
.add_profile(audio_profile)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Apply the EncodingProfile to the pipeline, and set it to render mode
|
// Apply the EncodingProfile to the pipeline, and set it to render mode
|
||||||
|
|
|
@ -736,7 +736,7 @@ unsafe extern "C" fn audio_decoder_getcaps<T: AudioDecoderImpl>(
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.to_glib_full()
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn audio_decoder_sink_event<T: AudioDecoderImpl>(
|
unsafe extern "C" fn audio_decoder_sink_event<T: AudioDecoderImpl>(
|
||||||
|
|
|
@ -669,7 +669,7 @@ unsafe extern "C" fn audio_encoder_getcaps<T: AudioEncoderImpl>(
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.to_glib_full()
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn audio_encoder_sink_event<T: AudioEncoderImpl>(
|
unsafe extern "C" fn audio_encoder_sink_event<T: AudioEncoderImpl>(
|
||||||
|
|
|
@ -941,7 +941,7 @@ unsafe extern "C" fn aggregator_create_new_pad<T: AggregatorImpl>(
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.to_glib_full()
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn aggregator_update_src_caps<T: AggregatorImpl>(
|
unsafe extern "C" fn aggregator_update_src_caps<T: AggregatorImpl>(
|
||||||
|
@ -1074,5 +1074,6 @@ unsafe extern "C" fn aggregator_peek_next_sample<T: AggregatorImpl>(
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
gst::panic_to_error!(imp, None, { imp.peek_next_sample(&from_glib_borrow(pad)) }).to_glib_full()
|
gst::panic_to_error!(imp, None, { imp.peek_next_sample(&from_glib_borrow(pad)) })
|
||||||
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,11 @@ impl NetAddressMeta {
|
||||||
unsafe { from_glib_none(self.0.addr) }
|
unsafe { from_glib_none(self.0.addr) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_addr<T: IsA<gio::SocketAddress>>(&mut self, addr: &T) {
|
pub fn set_addr(&mut self, addr: impl IsA<gio::SocketAddress>) {
|
||||||
#![allow(clippy::cast_ptr_alignment)]
|
#![allow(clippy::cast_ptr_alignment)]
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::gobject_ffi::g_object_unref(self.0.addr as *mut _);
|
glib::gobject_ffi::g_object_unref(self.0.addr as *mut _);
|
||||||
self.0.addr = addr.as_ref().to_glib_full();
|
self.0.addr = addr.upcast().into_glib_ptr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O {
|
||||||
|
|
||||||
// Split the trait as only the getter is public
|
// Split the trait as only the getter is public
|
||||||
trait EncodingProfileHasRestrictionSetter {
|
trait EncodingProfileHasRestrictionSetter {
|
||||||
fn set_restriction(&self, restriction: Option<&gst::Caps>);
|
fn set_restriction(&self, restriction: Option<gst::Caps>);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait EncodingProfileHasRestrictionGetter {
|
pub trait EncodingProfileHasRestrictionGetter {
|
||||||
|
@ -167,12 +167,12 @@ macro_rules! declare_encoding_profile_has_restriction(
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
impl EncodingProfileHasRestrictionSetter for $name {
|
impl EncodingProfileHasRestrictionSetter for $name {
|
||||||
// checker-ignore-item
|
// checker-ignore-item
|
||||||
fn set_restriction(&self, restriction: Option<&gst::Caps>) {
|
fn set_restriction(&self, restriction: Option<gst::Caps>) {
|
||||||
let profile: &EncodingProfile = glib::object::Cast::upcast_ref(self);
|
let profile: &EncodingProfile = glib::object::Cast::upcast_ref(self);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let restriction = match restriction {
|
let restriction = match restriction {
|
||||||
Some(restriction) => restriction.to_glib_full(),
|
Some(restriction) => restriction.into_glib_ptr(),
|
||||||
None => gst::ffi::gst_caps_new_any(),
|
None => gst::ffi::gst_caps_new_any(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -305,11 +305,11 @@ impl EncodingContainerProfile {
|
||||||
}
|
}
|
||||||
|
|
||||||
// checker-ignore-item
|
// checker-ignore-item
|
||||||
fn add_profile<P: IsA<EncodingProfile>>(&self, profile: &P) {
|
fn add_profile(&self, profile: impl IsA<EncodingProfile>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let res = ffi::gst_encoding_container_profile_add_profile(
|
let res = ffi::gst_encoding_container_profile_add_profile(
|
||||||
self.to_glib_none().0,
|
self.to_glib_none().0,
|
||||||
profile.as_ref().to_glib_full(),
|
profile.upcast().into_glib_ptr(),
|
||||||
);
|
);
|
||||||
// Can't possibly fail unless we pass random pointers
|
// Can't possibly fail unless we pass random pointers
|
||||||
assert_ne!(res, glib::ffi::GFALSE);
|
assert_ne!(res, glib::ffi::GFALSE);
|
||||||
|
@ -588,7 +588,7 @@ impl<'a> EncodingContainerProfileBuilder<'a> {
|
||||||
);
|
);
|
||||||
|
|
||||||
for profile in self.profiles {
|
for profile in self.profiles {
|
||||||
container_profile.add_profile(&profile);
|
container_profile.add_profile(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_common_fields(&container_profile, self.base);
|
set_common_fields(&container_profile, self.base);
|
||||||
|
@ -597,8 +597,8 @@ impl<'a> EncodingContainerProfileBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_encoding_container_profile_add_profile")]
|
#[doc(alias = "gst_encoding_container_profile_add_profile")]
|
||||||
pub fn add_profile<P: IsA<EncodingProfile>>(mut self, profile: &P) -> Self {
|
pub fn add_profile(mut self, profile: impl IsA<EncodingProfile>) -> Self {
|
||||||
self.profiles.push(profile.as_ref().clone());
|
self.profiles.push(profile.upcast());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,7 +666,7 @@ mod tests {
|
||||||
let restriction = gst_audio::AudioCapsBuilder::new()
|
let restriction = gst_audio::AudioCapsBuilder::new()
|
||||||
.format(gst_audio::AudioFormat::S32be)
|
.format(gst_audio::AudioFormat::S32be)
|
||||||
.build();
|
.build();
|
||||||
audio_profile.set_restriction(Some(&restriction));
|
audio_profile.set_restriction(Some(restriction.clone()));
|
||||||
assert_eq!(audio_profile.restriction().unwrap(), restriction);
|
assert_eq!(audio_profile.restriction().unwrap(), restriction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,7 +714,7 @@ mod tests {
|
||||||
let restriction = gst_video::VideoCapsBuilder::new()
|
let restriction = gst_video::VideoCapsBuilder::new()
|
||||||
.format(gst_video::VideoFormat::Nv12)
|
.format(gst_video::VideoFormat::Nv12)
|
||||||
.build();
|
.build();
|
||||||
video_profile.set_restriction(Some(&restriction));
|
video_profile.set_restriction(Some(restriction.clone()));
|
||||||
assert_eq!(video_profile.restriction().unwrap(), restriction);
|
assert_eq!(video_profile.restriction().unwrap(), restriction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,8 +743,8 @@ mod tests {
|
||||||
.presence(PRESENCE)
|
.presence(PRESENCE)
|
||||||
.allow_dynamic_output(ALLOW_DYNAMIC_OUTPUT)
|
.allow_dynamic_output(ALLOW_DYNAMIC_OUTPUT)
|
||||||
.enabled(ENABLED)
|
.enabled(ENABLED)
|
||||||
.add_profile(&audio_profile)
|
.add_profile(audio_profile.clone())
|
||||||
.add_profile(&video_profile)
|
.add_profile(video_profile.clone())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assert_eq!(profile.name().unwrap(), CONTAINER_PROFILE_NAME);
|
assert_eq!(profile.name().unwrap(), CONTAINER_PROFILE_NAME);
|
||||||
|
|
|
@ -205,7 +205,7 @@ unsafe extern "C" fn rtp_base_payload_get_caps<T: RTPBasePayloadImpl>(
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.to_glib_full()
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn rtp_base_payload_set_caps<T: RTPBasePayloadImpl>(
|
unsafe extern "C" fn rtp_base_payload_set_caps<T: RTPBasePayloadImpl>(
|
||||||
|
|
|
@ -6,13 +6,13 @@ use crate::RTSPMedia;
|
||||||
|
|
||||||
pub trait RTSPMediaExtManual: 'static {
|
pub trait RTSPMediaExtManual: 'static {
|
||||||
#[doc(alias = "gst_rtsp_media_take_pipeline")]
|
#[doc(alias = "gst_rtsp_media_take_pipeline")]
|
||||||
fn take_pipeline<P: IsA<gst::Pipeline>>(&self, pipeline: &P);
|
fn take_pipeline(&self, pipeline: impl IsA<gst::Pipeline>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<O: IsA<RTSPMedia>> RTSPMediaExtManual for O {
|
impl<O: IsA<RTSPMedia>> RTSPMediaExtManual for O {
|
||||||
fn take_pipeline<P: IsA<gst::Pipeline>>(&self, pipeline: &P) {
|
fn take_pipeline(&self, pipeline: impl IsA<gst::Pipeline>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let pipeline = pipeline.as_ref().to_glib_full();
|
let pipeline = pipeline.upcast().into_glib_ptr();
|
||||||
// See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109
|
// See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109
|
||||||
glib::gobject_ffi::g_object_force_floating(pipeline as *mut _);
|
glib::gobject_ffi::g_object_force_floating(pipeline as *mut _);
|
||||||
ffi::gst_rtsp_media_take_pipeline(self.as_ref().to_glib_none().0, pipeline);
|
ffi::gst_rtsp_media_take_pipeline(self.as_ref().to_glib_none().0, pipeline);
|
||||||
|
|
|
@ -839,7 +839,7 @@ unsafe extern "C" fn client_make_path_from_uri<T: RTSPClientImpl>(
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
imp.make_path_from_uri(&from_glib_borrow(url))
|
imp.make_path_from_uri(&from_glib_borrow(url))
|
||||||
.to_glib_full()
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn client_closed<T: RTSPClientImpl>(ptr: *mut ffi::GstRTSPClient) {
|
unsafe extern "C" fn client_closed<T: RTSPClientImpl>(ptr: *mut ffi::GstRTSPClient) {
|
||||||
|
@ -1000,7 +1000,7 @@ unsafe extern "C" fn client_check_requirements<T: RTSPClientImpl>(
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
imp.check_requirements(&from_glib_borrow(ctx), Vec::from_glib_none(arr).as_slice())
|
imp.check_requirements(&from_glib_borrow(ctx), Vec::from_glib_none(arr).as_slice())
|
||||||
.to_glib_full()
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn client_pre_options_request<T: RTSPClientImpl>(
|
unsafe extern "C" fn client_pre_options_request<T: RTSPClientImpl>(
|
||||||
|
|
|
@ -553,7 +553,7 @@ unsafe extern "C" fn media_create_rtpbin<T: RTSPMediaImpl>(
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
let res: *mut gst::ffi::GstElement = imp.create_rtpbin().to_glib_full();
|
let res: *mut gst::ffi::GstElement = imp.create_rtpbin().into_glib_ptr();
|
||||||
|
|
||||||
if !res.is_null() {
|
if !res.is_null() {
|
||||||
glib::gobject_ffi::g_object_force_floating(res as *mut _);
|
glib::gobject_ffi::g_object_force_floating(res as *mut _);
|
||||||
|
|
|
@ -203,7 +203,7 @@ unsafe extern "C" fn factory_gen_key<T: RTSPMediaFactoryImpl>(
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
imp.gen_key(&from_glib_borrow(url)).to_glib_full()
|
imp.gen_key(&from_glib_borrow(url)).into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn factory_create_element<T: RTSPMediaFactoryImpl>(
|
unsafe extern "C" fn factory_create_element<T: RTSPMediaFactoryImpl>(
|
||||||
|
@ -213,7 +213,7 @@ unsafe extern "C" fn factory_create_element<T: RTSPMediaFactoryImpl>(
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
let element = imp.create_element(&from_glib_borrow(url)).to_glib_full();
|
let element = imp.create_element(&from_glib_borrow(url)).into_glib_ptr();
|
||||||
glib::gobject_ffi::g_object_force_floating(element as *mut _);
|
glib::gobject_ffi::g_object_force_floating(element as *mut _);
|
||||||
element
|
element
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ unsafe extern "C" fn factory_construct<T: RTSPMediaFactoryImpl>(
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
imp.construct(&from_glib_borrow(url)).to_glib_full()
|
imp.construct(&from_glib_borrow(url)).into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn factory_create_pipeline<T: RTSPMediaFactoryImpl>(
|
unsafe extern "C" fn factory_create_pipeline<T: RTSPMediaFactoryImpl>(
|
||||||
|
@ -240,8 +240,9 @@ unsafe extern "C" fn factory_create_pipeline<T: RTSPMediaFactoryImpl>(
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
let pipeline: *mut gst::ffi::GstPipeline =
|
let pipeline: *mut gst::ffi::GstPipeline = imp
|
||||||
imp.create_pipeline(&from_glib_borrow(media)).to_glib_full();
|
.create_pipeline(&from_glib_borrow(media))
|
||||||
|
.into_glib_ptr();
|
||||||
|
|
||||||
// FIXME We somehow need to ensure the pipeline actually stays alive...
|
// FIXME We somehow need to ensure the pipeline actually stays alive...
|
||||||
glib::gobject_ffi::g_object_set_qdata_full(
|
glib::gobject_ffi::g_object_set_qdata_full(
|
||||||
|
|
|
@ -49,5 +49,5 @@ unsafe extern "C" fn mount_points_make_path<T: RTSPMountPointsImpl>(
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
imp.make_path(&from_glib_borrow(url)).to_glib_full()
|
imp.make_path(&from_glib_borrow(url)).into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ unsafe extern "C" fn server_create_client<T: RTSPServerImpl>(
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
imp.create_client().to_glib_full()
|
imp.create_client().into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn server_client_connected<T: RTSPServerImpl>(
|
unsafe extern "C" fn server_client_connected<T: RTSPServerImpl>(
|
||||||
|
|
|
@ -806,7 +806,7 @@ unsafe extern "C" fn video_decoder_getcaps<T: VideoDecoderImpl>(
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.to_glib_full()
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn video_decoder_sink_event<T: VideoDecoderImpl>(
|
unsafe extern "C" fn video_decoder_sink_event<T: VideoDecoderImpl>(
|
||||||
|
|
|
@ -661,7 +661,7 @@ unsafe extern "C" fn video_encoder_getcaps<T: VideoEncoderImpl>(
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.to_glib_full()
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn video_encoder_sink_event<T: VideoEncoderImpl>(
|
unsafe extern "C" fn video_encoder_sink_event<T: VideoEncoderImpl>(
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
// 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 std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use glib::{
|
use glib::{translate::*, ToSendValue};
|
||||||
translate::{from_glib, from_glib_full, IntoGlib, ToGlibPtr},
|
|
||||||
ToSendValue,
|
|
||||||
};
|
|
||||||
use gst::EventType;
|
use gst::EventType;
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||||
|
@ -426,7 +423,7 @@ nav_event_builder!(
|
||||||
modifier_state: s.modifier_state,
|
modifier_state: s.modifier_state,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
gst::ffi::gst_event_new_navigation(event.structure().to_glib_full())
|
gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr())
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -487,7 +484,7 @@ nav_event_builder!(
|
||||||
modifier_state: s.modifier_state,
|
modifier_state: s.modifier_state,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
gst::ffi::gst_event_new_navigation(event.structure().to_glib_full())
|
gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr())
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -532,7 +529,7 @@ impl<'a> CommandEventBuilder<'a> {
|
||||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||||
modifier_state: s.modifier_state,
|
modifier_state: s.modifier_state,
|
||||||
};
|
};
|
||||||
gst::ffi::gst_event_new_navigation(event.structure().to_glib_full())
|
gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -573,7 +570,7 @@ nav_event_builder!(
|
||||||
modifier_state: s.modifier_state,
|
modifier_state: s.modifier_state,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
gst::ffi::gst_event_new_navigation(event.structure().to_glib_full())
|
gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr())
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -599,7 +596,7 @@ nav_event_builder!(
|
||||||
modifier_state: s.modifier_state,
|
modifier_state: s.modifier_state,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
gst::ffi::gst_event_new_navigation(event.structure().to_glib_full())
|
gst::ffi::gst_event_new_navigation(event.structure().into_glib_ptr())
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -325,13 +325,13 @@ macro_rules! generic_impl {
|
||||||
unsafe { from_glib_none(self.inner.config.latest_daily_jam) }
|
unsafe { from_glib_none(self.inner.config.latest_daily_jam) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_latest_daily_jam(&mut self, latest_daily_jam: Option<&glib::DateTime>) {
|
pub fn set_latest_daily_jam(&mut self, latest_daily_jam: Option<glib::DateTime>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if !self.inner.config.latest_daily_jam.is_null() {
|
if !self.inner.config.latest_daily_jam.is_null() {
|
||||||
glib::ffi::g_date_time_unref(self.inner.config.latest_daily_jam);
|
glib::ffi::g_date_time_unref(self.inner.config.latest_daily_jam);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.inner.config.latest_daily_jam = latest_daily_jam.to_glib_full()
|
self.inner.config.latest_daily_jam = latest_daily_jam.into_glib_ptr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
// 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::*, IsA};
|
use glib::{translate::*, Cast, IsA};
|
||||||
|
|
||||||
use crate::Allocator;
|
use crate::Allocator;
|
||||||
|
|
||||||
impl Allocator {
|
impl Allocator {
|
||||||
#[doc(alias = "gst_allocator_register")]
|
#[doc(alias = "gst_allocator_register")]
|
||||||
pub fn register(name: &str, allocator: &impl IsA<Allocator>) {
|
pub fn register(name: &str, allocator: impl IsA<Allocator>) {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
// See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3364
|
// See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3364
|
||||||
if crate::version() < (1, 20, 5, 0) {
|
if crate::version() < (1, 20, 5, 0) {
|
||||||
ffi::gst_allocator_register(name.to_glib_full(), allocator.as_ref().to_glib_full());
|
ffi::gst_allocator_register(
|
||||||
|
name.to_glib_full(),
|
||||||
|
allocator.upcast().into_glib_ptr(),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
ffi::gst_allocator_register(
|
ffi::gst_allocator_register(
|
||||||
name.to_glib_none().0,
|
name.to_glib_none().0,
|
||||||
allocator.as_ref().to_glib_full(),
|
allocator.upcast().into_glib_ptr(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
// Re-exported for the subclass gst_plugin_define! macro
|
// Re-exported for the subclass gst_plugin_define! macro
|
||||||
pub use ffi;
|
pub use ffi;
|
||||||
pub use glib;
|
pub use glib;
|
||||||
use glib::translate::{from_glib, from_glib_full};
|
|
||||||
pub use paste;
|
pub use paste;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
@ -256,6 +255,8 @@ use std::ptr;
|
||||||
#[doc(alias = "gst_init_check")]
|
#[doc(alias = "gst_init_check")]
|
||||||
pub fn init() -> Result<(), glib::Error> {
|
pub fn init() -> Result<(), glib::Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
use glib::translate::*;
|
||||||
|
|
||||||
let mut error = ptr::null_mut();
|
let mut error = ptr::null_mut();
|
||||||
if from_glib(ffi::gst_init_check(
|
if from_glib(ffi::gst_init_check(
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
||||||
ptr, slice,
|
ptr, slice,
|
||||||
};
|
};
|
||||||
|
|
||||||
use glib::translate::{from_glib, from_glib_full, from_glib_none, IntoGlibPtr, ToGlibPtr};
|
use glib::translate::*;
|
||||||
|
|
||||||
use crate::{AllocationParams, Allocator, MemoryFlags};
|
use crate::{AllocationParams, Allocator, MemoryFlags};
|
||||||
|
|
||||||
|
|
|
@ -104,20 +104,23 @@ pub struct StreamCollectionBuilder(StreamCollection);
|
||||||
|
|
||||||
impl StreamCollectionBuilder {
|
impl StreamCollectionBuilder {
|
||||||
#[doc(alias = "gst_stream_collection_add_stream")]
|
#[doc(alias = "gst_stream_collection_add_stream")]
|
||||||
pub fn stream(self, stream: &Stream) -> Self {
|
pub fn stream(self, stream: Stream) -> Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_stream_collection_add_stream((self.0).to_glib_none().0, stream.to_glib_full());
|
ffi::gst_stream_collection_add_stream(
|
||||||
|
(self.0).to_glib_none().0,
|
||||||
|
stream.into_glib_ptr(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn streams(self, streams: &[impl AsRef<Stream>]) -> Self {
|
pub fn streams(self, streams: impl IntoIterator<Item = Stream>) -> Self {
|
||||||
for stream in streams {
|
for stream in streams.into_iter() {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_stream_collection_add_stream(
|
ffi::gst_stream_collection_add_stream(
|
||||||
(self.0).to_glib_none().0,
|
(self.0).to_glib_none().0,
|
||||||
stream.as_ref().to_glib_full(),
|
stream.into_glib_ptr(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ mod tests {
|
||||||
const TEST_ALLOCATOR_NAME: &str = "TestAllocator";
|
const TEST_ALLOCATOR_NAME: &str = "TestAllocator";
|
||||||
|
|
||||||
let allocator = TestAllocator::default();
|
let allocator = TestAllocator::default();
|
||||||
Allocator::register(TEST_ALLOCATOR_NAME, &allocator);
|
Allocator::register(TEST_ALLOCATOR_NAME, allocator);
|
||||||
|
|
||||||
let allocator = Allocator::find(Some(TEST_ALLOCATOR_NAME));
|
let allocator = Allocator::find(Some(TEST_ALLOCATOR_NAME));
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ unsafe extern "C" fn child_proxy_get_child_by_name<T: ChildProxyImpl>(
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
imp.child_by_name(&glib::GString::from_glib_borrow(name))
|
imp.child_by_name(&glib::GString::from_glib_borrow(name))
|
||||||
.to_glib_full()
|
.into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn child_proxy_get_child_by_index<T: ChildProxyImpl>(
|
unsafe extern "C" fn child_proxy_get_child_by_index<T: ChildProxyImpl>(
|
||||||
|
@ -142,7 +142,7 @@ unsafe extern "C" fn child_proxy_get_child_by_index<T: ChildProxyImpl>(
|
||||||
let instance = &*(child_proxy as *mut T::Instance);
|
let instance = &*(child_proxy as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
imp.child_by_index(index).to_glib_full()
|
imp.child_by_index(index).into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn child_proxy_get_children_count<T: ChildProxyImpl>(
|
unsafe extern "C" fn child_proxy_get_children_count<T: ChildProxyImpl>(
|
||||||
|
|
|
@ -97,13 +97,10 @@ unsafe extern "C" fn device_create_element<T: DeviceImpl>(
|
||||||
Ok(element) => {
|
Ok(element) => {
|
||||||
// The reference we're going to return, the initial reference is going to
|
// The reference we're going to return, the initial reference is going to
|
||||||
// be dropped here now
|
// be dropped here now
|
||||||
let element_ptr = element.to_glib_full();
|
let element = element.into_glib_ptr();
|
||||||
drop(element);
|
|
||||||
// See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444
|
// See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444
|
||||||
glib::gobject_ffi::g_object_force_floating(
|
glib::gobject_ffi::g_object_force_floating(element as *mut glib::gobject_ffi::GObject);
|
||||||
element_ptr as *mut glib::gobject_ffi::GObject,
|
element
|
||||||
);
|
|
||||||
element_ptr
|
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_imp(imp);
|
err.log_with_imp(imp);
|
||||||
|
|
|
@ -538,7 +538,7 @@ unsafe extern "C" fn element_provide_clock<T: ElementImpl>(
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.imp();
|
let imp = instance.imp();
|
||||||
|
|
||||||
panic_to_error!(imp, None, { imp.provide_clock() }).to_glib_full()
|
panic_to_error!(imp, None, { imp.provide_clock() }).into_glib_ptr()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn element_post_message<T: ElementImpl>(
|
unsafe extern "C" fn element_post_message<T: ElementImpl>(
|
||||||
|
|
Loading…
Reference in a new issue