forked from mirrors/gstreamer-rs
gstreamer/pad: Add get_range_fill() and pull_range_fill() functions
These allow providing an already allocated, writable buffer. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/242
This commit is contained in:
parent
0ca6be25c5
commit
7c2f3bafa0
1 changed files with 72 additions and 0 deletions
|
@ -128,7 +128,19 @@ pub trait PadExtManual: 'static {
|
|||
fn push_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError>;
|
||||
|
||||
fn pull_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowError>;
|
||||
fn pull_range_fill(
|
||||
&self,
|
||||
offset: u64,
|
||||
buffer: &mut ::BufferRef,
|
||||
size: u32,
|
||||
) -> Result<(), FlowError>;
|
||||
fn get_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowError>;
|
||||
fn get_range_fill(
|
||||
&self,
|
||||
offset: u64,
|
||||
buffer: &mut ::BufferRef,
|
||||
size: u32,
|
||||
) -> Result<(), FlowError>;
|
||||
|
||||
fn peer_query(&self, query: &mut QueryRef) -> bool;
|
||||
fn query(&self, query: &mut QueryRef) -> bool;
|
||||
|
@ -351,6 +363,36 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_range_fill(
|
||||
&self,
|
||||
offset: u64,
|
||||
buffer: &mut ::BufferRef,
|
||||
size: u32,
|
||||
) -> Result<(), FlowError> {
|
||||
assert!(buffer.get_size() >= size as usize);
|
||||
|
||||
unsafe {
|
||||
let mut buffer_ref = buffer.as_mut_ptr();
|
||||
let ret: FlowReturn = from_glib(gst_sys::gst_pad_get_range(
|
||||
self.as_ref().to_glib_none().0,
|
||||
offset,
|
||||
size,
|
||||
&mut buffer_ref,
|
||||
));
|
||||
match ret.into_result_value(|| ()) {
|
||||
Ok(_) => {
|
||||
if buffer.as_mut_ptr() != buffer_ref {
|
||||
gst_sys::gst_mini_object_unref(buffer_ref as *mut _);
|
||||
Err(::FlowError::Error)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pull_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowError> {
|
||||
unsafe {
|
||||
let mut buffer = ptr::null_mut();
|
||||
|
@ -364,6 +406,36 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn pull_range_fill(
|
||||
&self,
|
||||
offset: u64,
|
||||
buffer: &mut ::BufferRef,
|
||||
size: u32,
|
||||
) -> Result<(), FlowError> {
|
||||
assert!(buffer.get_size() >= size as usize);
|
||||
|
||||
unsafe {
|
||||
let mut buffer_ref = buffer.as_mut_ptr();
|
||||
let ret: FlowReturn = from_glib(gst_sys::gst_pad_pull_range(
|
||||
self.as_ref().to_glib_none().0,
|
||||
offset,
|
||||
size,
|
||||
&mut buffer_ref,
|
||||
));
|
||||
match ret.into_result_value(|| ()) {
|
||||
Ok(_) => {
|
||||
if buffer.as_mut_ptr() != buffer_ref {
|
||||
gst_sys::gst_mini_object_unref(buffer_ref as *mut _);
|
||||
Err(::FlowError::Error)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn query(&self, query: &mut QueryRef) -> bool {
|
||||
unsafe {
|
||||
from_glib(gst_sys::gst_pad_query(
|
||||
|
|
Loading…
Reference in a new issue