diff --git a/Gir_GstVideo.toml b/Gir_GstVideo.toml index 395c87c91..9c6b3724d 100644 --- a/Gir_GstVideo.toml +++ b/Gir_GstVideo.toml @@ -50,6 +50,8 @@ manual = [ "Gst.Buffer", "Gst.BufferPool", "Gst.BufferPoolAcquireParams", + "Gst.Allocator", + "Gst.AllocationParams", "Gst.ClockTimeDiff", "Gst.FlowReturn", "Gst.TagList", @@ -149,6 +151,10 @@ status = "generate" name = "negotiate" ignore = true + [[object.function]] + name = "get_allocator" + ignore = true + [[object]] name = "GstVideo.VideoEncoder" status = "generate" @@ -196,3 +202,7 @@ status = "generate" [[object.function]] name = "negotiate" ignore = true + + [[object.function]] + name = "get_allocator" + ignore = true diff --git a/gstreamer-video/src/auto/video_decoder.rs b/gstreamer-video/src/auto/video_decoder.rs index e5e1bdd64..d36cc4429 100644 --- a/gstreamer-video/src/auto/video_decoder.rs +++ b/gstreamer-video/src/auto/video_decoder.rs @@ -26,8 +26,6 @@ pub trait VideoDecoderExt: 'static { fn allocate_output_buffer(&self) -> Option; - //fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams); - fn get_buffer_pool(&self) -> Option; fn get_estimate_rate(&self) -> i32; @@ -78,10 +76,6 @@ impl> VideoDecoderExt for O { } } - //fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams) { - // unsafe { TODO: call gst_video_sys:gst_video_decoder_get_allocator() } - //} - fn get_buffer_pool(&self) -> Option { unsafe { from_glib_full(gst_video_sys::gst_video_decoder_get_buffer_pool( diff --git a/gstreamer-video/src/auto/video_encoder.rs b/gstreamer-video/src/auto/video_encoder.rs index 83fbfcd79..99f1e7fb8 100644 --- a/gstreamer-video/src/auto/video_encoder.rs +++ b/gstreamer-video/src/auto/video_encoder.rs @@ -34,8 +34,6 @@ pub const NONE_VIDEO_ENCODER: Option<&VideoEncoder> = None; pub trait VideoEncoderExt: 'static { fn allocate_output_buffer(&self, size: usize) -> Option; - //fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams); - #[cfg(any(feature = "v1_14", feature = "dox"))] fn get_max_encode_time(&self, frame: &VideoCodecFrame) -> gst::ClockTimeDiff; @@ -77,10 +75,6 @@ impl> VideoEncoderExt for O { } } - //fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams) { - // unsafe { TODO: call gst_video_sys:gst_video_encoder_get_allocator() } - //} - #[cfg(any(feature = "v1_14", feature = "dox"))] fn get_max_encode_time(&self, frame: &VideoCodecFrame) -> gst::ClockTimeDiff { unsafe { diff --git a/gstreamer-video/src/video_decoder.rs b/gstreamer-video/src/video_decoder.rs index fb134ba9d..08b04ab9d 100644 --- a/gstreamer-video/src/video_decoder.rs +++ b/gstreamer-video/src/video_decoder.rs @@ -11,6 +11,7 @@ use glib::object::IsA; use glib::translate::*; use gst; use gst_video_sys; +use std::mem; use std::ptr; use utils::HasStreamLock; use video_codec_state::{InNegotiation, Readable, VideoCodecState, VideoCodecStateContext}; @@ -32,6 +33,8 @@ pub trait VideoDecoderExtManual: 'static { fn get_frames(&self) -> Vec; fn get_oldest_frame(&self) -> Option; + fn get_allocator(&self) -> (gst::Allocator, gst::AllocationParams); + fn have_frame(&self) -> Result; fn finish_frame(&self, frame: VideoCodecFrame) -> Result; fn release_frame(&self, frame: VideoCodecFrame); @@ -84,6 +87,19 @@ impl> VideoDecoderExtManual for O { ret.into_result() } + fn get_allocator(&self) -> (gst::Allocator, gst::AllocationParams) { + unsafe { + let mut allocator = ptr::null_mut(); + let mut params = mem::zeroed(); + gst_video_sys::gst_video_decoder_get_allocator( + self.as_ref().to_glib_none().0, + &mut allocator, + &mut params, + ); + (from_glib_full(allocator), params.into()) + } + } + fn have_frame(&self) -> Result { let ret: gst::FlowReturn = unsafe { from_glib(gst_video_sys::gst_video_decoder_have_frame( diff --git a/gstreamer-video/src/video_encoder.rs b/gstreamer-video/src/video_encoder.rs index 298030d83..e7fdab633 100644 --- a/gstreamer-video/src/video_encoder.rs +++ b/gstreamer-video/src/video_encoder.rs @@ -12,6 +12,7 @@ use glib::object::IsA; use glib::translate::*; use gst; use gst_video_sys; +use std::mem; use std::ptr; use utils::HasStreamLock; use video_codec_state::{InNegotiation, Readable, VideoCodecState, VideoCodecStateContext}; @@ -30,6 +31,8 @@ pub trait VideoEncoderExtManual: 'static { fn get_frames(&self) -> Vec; fn get_oldest_frame(&self) -> Option; + fn get_allocator(&self) -> (gst::Allocator, gst::AllocationParams); + fn finish_frame( &self, frame: Option, @@ -68,6 +71,19 @@ impl> VideoEncoderExtManual for O { ret.into_result() } + fn get_allocator(&self) -> (gst::Allocator, gst::AllocationParams) { + unsafe { + let mut allocator = ptr::null_mut(); + let mut params = mem::zeroed(); + gst_video_sys::gst_video_encoder_get_allocator( + self.as_ref().to_glib_none().0, + &mut allocator, + &mut params, + ); + (from_glib_full(allocator), params.into()) + } + } + fn finish_frame( &self, frame: Option,