Commit 69e1fdd5 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Add Query bindings

parent 29d4e3a5
......@@ -52,6 +52,8 @@ generate = [
"Gst.CapsIntersectMode",
"Gst.BufferFlags",
"Gst.SegmentFlags",
"Gst.PadMode",
"Gst.SchedulingFlags",
]
manual = [
......@@ -289,6 +291,11 @@ status = "generate"
[object.function.return]
bool_return_is_error = "Failed to activate pad"
[[object.function]]
name = "activate_mode"
[object.function.return]
bool_return_is_error = "Failed to activate mode pad"
[[object.property]]
name = "caps"
# Caps is not a GObject
......
......@@ -708,6 +708,66 @@ impl SetValue for PadLinkReturn {
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum PadMode {
None,
Push,
Pull,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for PadMode {
type GlibType = ffi::GstPadMode;
fn to_glib(&self) -> ffi::GstPadMode {
match *self {
PadMode::None => ffi::GST_PAD_MODE_NONE,
PadMode::Push => ffi::GST_PAD_MODE_PUSH,
PadMode::Pull => ffi::GST_PAD_MODE_PULL,
PadMode::__Unknown(value) => unsafe{std::mem::transmute(value)}
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstPadMode> for PadMode {
fn from_glib(value: ffi::GstPadMode) -> Self {
skip_assert_initialized!();
match value as i32 {
0 => PadMode::None,
1 => PadMode::Push,
2 => PadMode::Pull,
value => PadMode::__Unknown(value),
}
}
}
impl StaticType for PadMode {
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_pad_mode_get_type()) }
}
}
impl<'a> FromValueOptional<'a> for PadMode {
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
Some(FromValue::from_value(value))
}
}
impl<'a> FromValue<'a> for PadMode {
unsafe fn from_value(value: &Value) -> Self {
from_glib(std::mem::transmute::<i32, ffi::GstPadMode>(gobject_ffi::g_value_get_enum(value.to_glib_none().0)))
}
}
impl SetValue for PadMode {
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)]
pub enum PadPresence {
Always,
......
......@@ -135,6 +135,55 @@ impl SetValue for PadProbeType {
}
}
bitflags! {
pub struct SchedulingFlags: u32 {
const SCHEDULING_FLAG_SEEKABLE = 1;
const SCHEDULING_FLAG_SEQUENTIAL = 2;
const SCHEDULING_FLAG_BANDWIDTH_LIMITED = 4;
}
}
#[doc(hidden)]
impl ToGlib for SchedulingFlags {
type GlibType = ffi::GstSchedulingFlags;
fn to_glib(&self) -> ffi::GstSchedulingFlags {
ffi::GstSchedulingFlags::from_bits_truncate(self.bits())
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstSchedulingFlags> for SchedulingFlags {
fn from_glib(value: ffi::GstSchedulingFlags) -> SchedulingFlags {
skip_assert_initialized!();
SchedulingFlags::from_bits_truncate(value.bits())
}
}
impl StaticType for SchedulingFlags {
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_scheduling_flags_get_type()) }
}
}
impl<'a> FromValueOptional<'a> for SchedulingFlags {
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
Some(FromValue::from_value(value))
}
}
impl<'a> FromValue<'a> for SchedulingFlags {
unsafe fn from_value(value: &Value) -> Self {
from_glib(ffi::GstSchedulingFlags::from_bits_truncate(gobject_ffi::g_value_get_flags(value.to_glib_none().0)))
}
}
impl SetValue for SchedulingFlags {
unsafe fn set_value(value: &mut Value, this: &Self) {
gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib().bits())
}
}
bitflags! {
pub struct SeekFlags: u32 {
const SEEK_FLAG_NONE = 0;
......
......@@ -85,6 +85,7 @@ pub use self::enums::Format;
pub use self::enums::LibraryError;
pub use self::enums::PadDirection;
pub use self::enums::PadLinkReturn;
pub use self::enums::PadMode;
pub use self::enums::PadPresence;
pub use self::enums::PadProbeReturn;
pub use self::enums::ParseError;
......@@ -140,6 +141,10 @@ pub use self::flags::PAD_PROBE_TYPE_EVENT_BOTH;
pub use self::flags::PAD_PROBE_TYPE_QUERY_BOTH;
pub use self::flags::PAD_PROBE_TYPE_ALL_BOTH;
pub use self::flags::PAD_PROBE_TYPE_SCHEDULING;
pub use self::flags::SchedulingFlags;
pub use self::flags::SCHEDULING_FLAG_SEEKABLE;
pub use self::flags::SCHEDULING_FLAG_SEQUENTIAL;
pub use self::flags::SCHEDULING_FLAG_BANDWIDTH_LIMITED;
pub use self::flags::SeekFlags;
pub use self::flags::SEEK_FLAG_NONE;
pub use self::flags::SEEK_FLAG_FLUSH;
......
......@@ -8,6 +8,7 @@ use Format;
use Object;
use PadDirection;
use PadLinkReturn;
use PadMode;
use PadTemplate;
#[cfg(feature = "v1_10")]
use Stream;
......@@ -67,7 +68,7 @@ unsafe impl Send for Pad {}
unsafe impl Sync for Pad {}
pub trait PadExt {
//fn activate_mode(&self, mode: /*Ignored*/PadMode, active: bool) -> bool;
fn activate_mode(&self, mode: PadMode, active: bool) -> Result<(), glib::error::BoolError>;
//fn add_probe<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, mask: PadProbeType, callback: /*Unknown conversion*//*Unimplemented*/PadProbeCallback, user_data: P, destroy_data: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> libc::c_ulong;
......@@ -229,9 +230,11 @@ pub trait PadExt {
}
impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
//fn activate_mode(&self, mode: /*Ignored*/PadMode, active: bool) -> bool {
// unsafe { TODO: call ffi::gst_pad_activate_mode() }
//}
fn activate_mode(&self, mode: PadMode, active: bool) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_pad_activate_mode(self.to_glib_none().0, mode.to_glib(), active.to_glib()), "Failed to activate mode pad")
}
}
//fn add_probe<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, mask: PadProbeType, callback: /*Unknown conversion*//*Unimplemented*/PadProbeCallback, user_data: P, destroy_data: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> libc::c_ulong {
// unsafe { TODO: call ffi::gst_pad_add_probe() }
......
......@@ -62,6 +62,8 @@ pub mod sample;
pub use sample::{Sample, SampleRef};
pub mod bufferlist;
pub use bufferlist::{BufferList, BufferListRef};
pub mod query;
pub use query::{Query, QueryRef, QueryView};
mod element;
mod bin;
......
......@@ -124,6 +124,10 @@ impl MessageRef {
MessageView::Other
}
}
pub fn new_eos<'a>() -> EosBuilder<'a> {
EosBuilder::new()
}
}
impl glib::types::StaticType for GstRc<MessageRef> {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment