video: Add VideoEncoder/VideoDecoder::get_allocator()

This commit is contained in:
Sebastian Dröge 2019-09-13 18:12:49 +03:00
parent 2a442f6ec1
commit 7dfe7c09bd
5 changed files with 42 additions and 12 deletions

View file

@ -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

View file

@ -26,8 +26,6 @@ pub trait VideoDecoderExt: 'static {
fn allocate_output_buffer(&self) -> Option<gst::Buffer>;
//fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams);
fn get_buffer_pool(&self) -> Option<gst::BufferPool>;
fn get_estimate_rate(&self) -> i32;
@ -78,10 +76,6 @@ impl<O: IsA<VideoDecoder>> 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<gst::BufferPool> {
unsafe {
from_glib_full(gst_video_sys::gst_video_decoder_get_buffer_pool(

View file

@ -34,8 +34,6 @@ pub const NONE_VIDEO_ENCODER: Option<&VideoEncoder> = None;
pub trait VideoEncoderExt: 'static {
fn allocate_output_buffer(&self, size: usize) -> Option<gst::Buffer>;
//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<O: IsA<VideoEncoder>> 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 {

View file

@ -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<VideoCodecFrame>;
fn get_oldest_frame(&self) -> Option<VideoCodecFrame>;
fn get_allocator(&self) -> (gst::Allocator, gst::AllocationParams);
fn have_frame(&self) -> Result<gst::FlowSuccess, gst::FlowError>;
fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError>;
fn release_frame(&self, frame: VideoCodecFrame);
@ -84,6 +87,19 @@ impl<O: IsA<VideoDecoder>> 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<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_video_sys::gst_video_decoder_have_frame(

View file

@ -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<VideoCodecFrame>;
fn get_oldest_frame(&self) -> Option<VideoCodecFrame>;
fn get_allocator(&self) -> (gst::Allocator, gst::AllocationParams);
fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError>;
fn get_latency(&self) -> (gst::ClockTime, gst::ClockTime);
@ -65,6 +68,19 @@ impl<O: IsA<VideoEncoder>> 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: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_video_sys::gst_video_encoder_finish_frame(