Merge branch 'audio-video-info-reference-return' into 'main'

Return AudioInfo/VideoInfo references in more places instead of copies

See merge request gstreamer/gstreamer-rs!1698
This commit is contained in:
Sebastian Dröge 2025-04-04 06:23:39 +00:00
commit be68722857
3 changed files with 13 additions and 12 deletions

View file

@ -8,10 +8,7 @@ use std::ptr;
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
use std::slice;
use glib::translate::{from_glib, IntoGlib};
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
use glib::translate::{from_glib_none, ToGlibPtr};
use glib::translate::*;
use gst::prelude::*;
use crate::ffi;
@ -181,8 +178,8 @@ impl AudioMeta {
#[doc(alias = "get_info")]
#[inline]
pub fn info(&self) -> crate::AudioInfo {
unsafe { from_glib_none(&self.0.info as *const _) }
pub fn info(&self) -> &crate::AudioInfo {
unsafe { &*(&self.0.info as *const ffi::GstAudioInfo as *const crate::AudioInfo) }
}
#[doc(alias = "get_samples")]

View file

@ -95,9 +95,9 @@ impl<'a> VideoCodecState<'a, InNegotiation<'a>> {
impl<'a, T: VideoCodecStateContext<'a>> VideoCodecState<'a, T> {
#[doc(alias = "get_info")]
#[inline]
pub fn info(&self) -> VideoInfo {
pub fn info(&self) -> &VideoInfo {
unsafe {
VideoInfo::from_glib_none(&((*self.as_mut_ptr()).info) as *const ffi::GstVideoInfo)
&*(&(*self.as_mut_ptr()).info as *const ffi::GstVideoInfo as *const crate::VideoInfo)
}
}

View file

@ -77,16 +77,20 @@ impl VideoConverter {
#[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
#[doc(alias = "get_in_info")]
#[doc(alias = "gst_video_converter_get_in_info")]
pub fn in_info(&self) -> crate::VideoInfo {
unsafe { from_glib_none(ffi::gst_video_converter_get_in_info(self.0.as_ptr())) }
pub fn in_info(&self) -> &crate::VideoInfo {
unsafe {
&*(ffi::gst_video_converter_get_in_info(self.0.as_ptr()) as *const crate::VideoInfo)
}
}
#[cfg(feature = "v1_22")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
#[doc(alias = "get_out_info")]
#[doc(alias = "gst_video_converter_get_out_info")]
pub fn out_info(&self) -> crate::VideoInfo {
unsafe { from_glib_none(ffi::gst_video_converter_get_out_info(self.0.as_ptr())) }
pub fn out_info(&self) -> &crate::VideoInfo {
unsafe {
&*(ffi::gst_video_converter_get_out_info(self.0.as_ptr()) as *const crate::VideoInfo)
}
}
#[doc(alias = "gst_video_converter_frame")]