mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 08:36:31 +00:00
gstreamer: Add bindings for querying allocation params
This can be used to query downstream for custom allocators.
This commit is contained in:
parent
8fb37c5134
commit
6d88e18772
2 changed files with 74 additions and 0 deletions
|
@ -69,3 +69,11 @@ impl<'a> ToGlibPtr<'a, *const ffi::GstAllocationParams> for AllocationParams {
|
||||||
Stash(&self.0, self)
|
Stash(&self.0, self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FromGlib<ffi::GstAllocationParams> for AllocationParams {
|
||||||
|
#[allow(unused_unsafe)]
|
||||||
|
unsafe fn from_glib(value: ffi::GstAllocationParams) -> Self {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
AllocationParams(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ use std::mem;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
use glib::object::IsA;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
mini_object_wrapper!(Query, QueryRef, ffi::GstQuery, || {
|
mini_object_wrapper!(Query, QueryRef, ffi::GstQuery, || {
|
||||||
|
@ -947,6 +948,28 @@ impl<T: AsPtr> Allocation<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_allocation_params")]
|
||||||
|
#[doc(alias = "gst_query_get_n_allocation_params")]
|
||||||
|
pub fn allocation_params(&self) -> Vec<(Option<crate::Allocator>, crate::AllocationParams)> {
|
||||||
|
unsafe {
|
||||||
|
let n = ffi::gst_query_get_n_allocation_params(self.0.as_ptr());
|
||||||
|
let mut params = Vec::with_capacity(n as usize);
|
||||||
|
for i in 0..n {
|
||||||
|
let mut allocator = ptr::null_mut();
|
||||||
|
let mut p = mem::MaybeUninit::uninit();
|
||||||
|
ffi::gst_query_parse_nth_allocation_param(
|
||||||
|
self.0.as_ptr(),
|
||||||
|
i,
|
||||||
|
&mut allocator,
|
||||||
|
p.as_mut_ptr(),
|
||||||
|
);
|
||||||
|
params.push((from_glib_full(allocator), from_glib(p.assume_init())));
|
||||||
|
}
|
||||||
|
|
||||||
|
params
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[doc(alias = "get_allocation_pools")]
|
#[doc(alias = "get_allocation_pools")]
|
||||||
#[doc(alias = "gst_query_get_n_allocation_pools")]
|
#[doc(alias = "gst_query_get_n_allocation_pools")]
|
||||||
pub fn allocation_pools(&self) -> Vec<(Option<crate::BufferPool>, u32, u32, u32)> {
|
pub fn allocation_pools(&self) -> Vec<(Option<crate::BufferPool>, u32, u32, u32)> {
|
||||||
|
@ -1070,6 +1093,49 @@ impl<T: AsMutPtr> Allocation<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_query_add_allocation_param")]
|
||||||
|
pub fn add_allocation_param(
|
||||||
|
&mut self,
|
||||||
|
allocator: Option<&impl IsA<crate::Allocator>>,
|
||||||
|
params: crate::AllocationParams,
|
||||||
|
) {
|
||||||
|
unsafe {
|
||||||
|
ffi::gst_query_add_allocation_param(
|
||||||
|
self.0.as_mut_ptr(),
|
||||||
|
allocator.to_glib_none().0 as *mut ffi::GstAllocator,
|
||||||
|
params.as_ptr(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_query_set_nth_allocation_param")]
|
||||||
|
pub fn set_nth_allocation_param(
|
||||||
|
&mut self,
|
||||||
|
idx: u32,
|
||||||
|
allocator: Option<&impl IsA<crate::Allocator>>,
|
||||||
|
params: crate::AllocationParams,
|
||||||
|
) {
|
||||||
|
unsafe {
|
||||||
|
let n = ffi::gst_query_get_n_allocation_params(self.0.as_ptr());
|
||||||
|
assert!(idx < n);
|
||||||
|
ffi::gst_query_set_nth_allocation_param(
|
||||||
|
self.0.as_mut_ptr(),
|
||||||
|
idx,
|
||||||
|
allocator.to_glib_none().0 as *mut ffi::GstAllocator,
|
||||||
|
params.as_ptr(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_query_remove_nth_allocation_param")]
|
||||||
|
pub fn remove_nth_allocation_param(&mut self, idx: u32) {
|
||||||
|
unsafe {
|
||||||
|
let n = ffi::gst_query_get_n_allocation_params(self.0.as_ptr());
|
||||||
|
assert!(idx < n);
|
||||||
|
ffi::gst_query_remove_nth_allocation_param(self.0.as_mut_ptr(), idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_query_add_allocation_meta")]
|
#[doc(alias = "gst_query_add_allocation_meta")]
|
||||||
pub fn add_allocation_meta<U: crate::MetaAPI>(
|
pub fn add_allocation_meta<U: crate::MetaAPI>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
Loading…
Reference in a new issue