mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-09 16:55:27 +00:00
Add bindings for remaining pad task functions
Especially Pad::start_task()
This commit is contained in:
parent
88f37b799c
commit
dc6c7500df
5 changed files with 104 additions and 6 deletions
|
@ -74,6 +74,7 @@ generate = [
|
||||||
"Gst.StackTraceFlags",
|
"Gst.StackTraceFlags",
|
||||||
"Gst.DebugGraphDetails",
|
"Gst.DebugGraphDetails",
|
||||||
"Gst.ParseFlags",
|
"Gst.ParseFlags",
|
||||||
|
"Gst.TaskState",
|
||||||
]
|
]
|
||||||
|
|
||||||
manual = [
|
manual = [
|
||||||
|
|
|
@ -2342,6 +2342,66 @@ impl SetValue for TagMergeMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||||
|
pub enum TaskState {
|
||||||
|
Started,
|
||||||
|
Stopped,
|
||||||
|
Paused,
|
||||||
|
#[doc(hidden)]
|
||||||
|
__Unknown(i32),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
impl ToGlib for TaskState {
|
||||||
|
type GlibType = ffi::GstTaskState;
|
||||||
|
|
||||||
|
fn to_glib(&self) -> ffi::GstTaskState {
|
||||||
|
match *self {
|
||||||
|
TaskState::Started => ffi::GST_TASK_STARTED,
|
||||||
|
TaskState::Stopped => ffi::GST_TASK_STOPPED,
|
||||||
|
TaskState::Paused => ffi::GST_TASK_PAUSED,
|
||||||
|
TaskState::__Unknown(value) => unsafe{std::mem::transmute(value)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
impl FromGlib<ffi::GstTaskState> for TaskState {
|
||||||
|
fn from_glib(value: ffi::GstTaskState) -> Self {
|
||||||
|
skip_assert_initialized!();
|
||||||
|
match value as i32 {
|
||||||
|
0 => TaskState::Started,
|
||||||
|
1 => TaskState::Stopped,
|
||||||
|
2 => TaskState::Paused,
|
||||||
|
value => TaskState::__Unknown(value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StaticType for TaskState {
|
||||||
|
fn static_type() -> Type {
|
||||||
|
unsafe { from_glib(ffi::gst_task_state_get_type()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> FromValueOptional<'a> for TaskState {
|
||||||
|
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
|
||||||
|
Some(FromValue::from_value(value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> FromValue<'a> for TaskState {
|
||||||
|
unsafe fn from_value(value: &Value) -> Self {
|
||||||
|
from_glib(std::mem::transmute::<i32, ffi::GstTaskState>(gobject_ffi::g_value_get_enum(value.to_glib_none().0)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SetValue for TaskState {
|
||||||
|
unsafe fn set_value(value: &mut Value, this: &Self) {
|
||||||
|
gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib() as i32)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||||
pub enum TocEntryType {
|
pub enum TocEntryType {
|
||||||
Angle,
|
Angle,
|
||||||
|
|
|
@ -128,6 +128,7 @@ pub use self::enums::StreamError;
|
||||||
pub use self::enums::StreamStatusType;
|
pub use self::enums::StreamStatusType;
|
||||||
pub use self::enums::StructureChangeType;
|
pub use self::enums::StructureChangeType;
|
||||||
pub use self::enums::TagMergeMode;
|
pub use self::enums::TagMergeMode;
|
||||||
|
pub use self::enums::TaskState;
|
||||||
pub use self::enums::TocEntryType;
|
pub use self::enums::TocEntryType;
|
||||||
pub use self::enums::TocLoopType;
|
pub use self::enums::TocLoopType;
|
||||||
pub use self::enums::TocScope;
|
pub use self::enums::TocScope;
|
||||||
|
|
|
@ -15,6 +15,8 @@ use PadMode;
|
||||||
use PadTemplate;
|
use PadTemplate;
|
||||||
#[cfg(feature = "v1_10")]
|
#[cfg(feature = "v1_10")]
|
||||||
use Stream;
|
use Stream;
|
||||||
|
#[cfg(feature = "v1_12")]
|
||||||
|
use TaskState;
|
||||||
use ffi;
|
use ffi;
|
||||||
use glib;
|
use glib;
|
||||||
use glib::Value;
|
use glib::Value;
|
||||||
|
@ -116,8 +118,8 @@ pub trait PadExt {
|
||||||
|
|
||||||
fn get_stream_id(&self) -> Option<String>;
|
fn get_stream_id(&self) -> Option<String>;
|
||||||
|
|
||||||
//#[cfg(feature = "v1_12")]
|
#[cfg(feature = "v1_12")]
|
||||||
//fn get_task_state(&self) -> /*Ignored*/TaskState;
|
fn get_task_state(&self) -> TaskState;
|
||||||
|
|
||||||
fn has_current_caps(&self) -> bool;
|
fn has_current_caps(&self) -> bool;
|
||||||
|
|
||||||
|
@ -348,10 +350,12 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#[cfg(feature = "v1_12")]
|
#[cfg(feature = "v1_12")]
|
||||||
//fn get_task_state(&self) -> /*Ignored*/TaskState {
|
fn get_task_state(&self) -> TaskState {
|
||||||
// unsafe { TODO: call ffi::gst_pad_get_task_state() }
|
unsafe {
|
||||||
//}
|
from_glib(ffi::gst_pad_get_task_state(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn has_current_caps(&self) -> bool {
|
fn has_current_caps(&self) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -20,6 +20,7 @@ use miniobject::MiniObject;
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
use glib::{IsA, StaticType};
|
use glib::{IsA, StaticType};
|
||||||
use glib::translate::{from_glib, from_glib_borrow, from_glib_full, from_glib_none, FromGlib,
|
use glib::translate::{from_glib, from_glib_borrow, from_glib_full, from_glib_none, FromGlib,
|
||||||
|
@ -166,6 +167,8 @@ pub trait PadExtManual {
|
||||||
fn set_unlink_function<F>(&self, func: F)
|
fn set_unlink_function<F>(&self, func: F)
|
||||||
where
|
where
|
||||||
F: Fn(&Pad, &::Object) + Send + Sync + 'static;
|
F: Fn(&Pad, &::Object) + Send + Sync + 'static;
|
||||||
|
|
||||||
|
fn start_task<F: FnMut() + Send + 'static>(&self, func: F) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<O: IsA<Pad>> PadExtManual for O {
|
impl<O: IsA<Pad>> PadExtManual for O {
|
||||||
|
@ -560,6 +563,17 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn start_task<F: FnMut() + Send + 'static>(&self, func: F) -> bool {
|
||||||
|
unsafe {
|
||||||
|
from_glib(ffi::gst_pad_start_task(
|
||||||
|
self.to_glib_none().0,
|
||||||
|
Some(trampoline_pad_task),
|
||||||
|
into_raw_pad_task(func),
|
||||||
|
Some(destroy_closure_pad_task),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_pad_probe(
|
unsafe extern "C" fn trampoline_pad_probe(
|
||||||
|
@ -839,3 +853,21 @@ unsafe extern "C" fn destroy_closure(ptr: gpointer) {
|
||||||
let _guard = CallbackGuard::new();
|
let _guard = CallbackGuard::new();
|
||||||
Box::<Box<Fn()>>::from_raw(ptr as *mut _);
|
Box::<Box<Fn()>>::from_raw(ptr as *mut _);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn trampoline_pad_task(func: gpointer) {
|
||||||
|
let _guard = CallbackGuard::new();
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||||
|
let func: &RefCell<Box<FnMut() + Send + 'static>> = transmute(func);
|
||||||
|
(&mut *func.borrow_mut())()
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe extern "C" fn destroy_closure_pad_task(ptr: gpointer) {
|
||||||
|
let _guard = CallbackGuard::new();
|
||||||
|
Box::<RefCell<Box<FnMut() + Send + 'static>>>::from_raw(ptr as *mut _);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn into_raw_pad_task<F: FnMut() + Send + 'static>(func: F) -> gpointer {
|
||||||
|
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
|
||||||
|
let func: Box<RefCell<Box<FnMut() + Send + 'static>>> = Box::new(RefCell::new(Box::new(func)));
|
||||||
|
Box::into_raw(func) as gpointer
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue