mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-22 16:16:37 +00:00
Add Iterator bindings
This commit is contained in:
parent
21888daab6
commit
4730500662
9 changed files with 191 additions and 47 deletions
|
@ -54,12 +54,14 @@ generate = [
|
||||||
"Gst.SegmentFlags",
|
"Gst.SegmentFlags",
|
||||||
"Gst.PadMode",
|
"Gst.PadMode",
|
||||||
"Gst.SchedulingFlags",
|
"Gst.SchedulingFlags",
|
||||||
|
"Gst.IteratorResult",
|
||||||
]
|
]
|
||||||
|
|
||||||
manual = [
|
manual = [
|
||||||
"GLib.Error",
|
"GLib.Error",
|
||||||
"GLib.Source",
|
"GLib.Source",
|
||||||
"Gst.Structure",
|
"Gst.Structure",
|
||||||
|
"Gst.Iterator",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[object]]
|
[[object]]
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// DO NOT EDIT
|
// DO NOT EDIT
|
||||||
|
|
||||||
use Element;
|
use Element;
|
||||||
|
use Iterator;
|
||||||
use Object;
|
use Object;
|
||||||
use Pad;
|
use Pad;
|
||||||
use PadDirection;
|
use PadDirection;
|
||||||
|
@ -57,17 +58,17 @@ pub trait BinExt {
|
||||||
//#[cfg(feature = "v1_10")]
|
//#[cfg(feature = "v1_10")]
|
||||||
//fn get_suppressed_flags(&self) -> /*Ignored*/ElementFlags;
|
//fn get_suppressed_flags(&self) -> /*Ignored*/ElementFlags;
|
||||||
|
|
||||||
//fn iterate_all_by_interface(&self, iface: glib::types::Type) -> /*Ignored*/Option<Iterator>;
|
fn iterate_all_by_interface(&self, iface: glib::types::Type) -> Option<Iterator>;
|
||||||
|
|
||||||
//fn iterate_elements(&self) -> /*Ignored*/Option<Iterator>;
|
fn iterate_elements(&self) -> Option<Iterator>;
|
||||||
|
|
||||||
//fn iterate_recurse(&self) -> /*Ignored*/Option<Iterator>;
|
fn iterate_recurse(&self) -> Option<Iterator>;
|
||||||
|
|
||||||
//fn iterate_sinks(&self) -> /*Ignored*/Option<Iterator>;
|
fn iterate_sinks(&self) -> Option<Iterator>;
|
||||||
|
|
||||||
//fn iterate_sorted(&self) -> /*Ignored*/Option<Iterator>;
|
fn iterate_sorted(&self) -> Option<Iterator>;
|
||||||
|
|
||||||
//fn iterate_sources(&self) -> /*Ignored*/Option<Iterator>;
|
fn iterate_sources(&self) -> Option<Iterator>;
|
||||||
|
|
||||||
fn recalculate_latency(&self) -> Result<(), glib::error::BoolError>;
|
fn recalculate_latency(&self) -> Result<(), glib::error::BoolError>;
|
||||||
|
|
||||||
|
@ -141,29 +142,41 @@ impl<O: IsA<Bin> + IsA<glib::object::Object>> BinExt for O {
|
||||||
// unsafe { TODO: call ffi::gst_bin_get_suppressed_flags() }
|
// unsafe { TODO: call ffi::gst_bin_get_suppressed_flags() }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//fn iterate_all_by_interface(&self, iface: glib::types::Type) -> /*Ignored*/Option<Iterator> {
|
fn iterate_all_by_interface(&self, iface: glib::types::Type) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_bin_iterate_all_by_interface() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_bin_iterate_all_by_interface(self.to_glib_none().0, iface.to_glib()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fn iterate_elements(&self) -> /*Ignored*/Option<Iterator> {
|
fn iterate_elements(&self) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_bin_iterate_elements() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_bin_iterate_elements(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fn iterate_recurse(&self) -> /*Ignored*/Option<Iterator> {
|
fn iterate_recurse(&self) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_bin_iterate_recurse() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_bin_iterate_recurse(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fn iterate_sinks(&self) -> /*Ignored*/Option<Iterator> {
|
fn iterate_sinks(&self) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_bin_iterate_sinks() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_bin_iterate_sinks(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fn iterate_sorted(&self) -> /*Ignored*/Option<Iterator> {
|
fn iterate_sorted(&self) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_bin_iterate_sorted() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_bin_iterate_sorted(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fn iterate_sources(&self) -> /*Ignored*/Option<Iterator> {
|
fn iterate_sources(&self) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_bin_iterate_sources() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_bin_iterate_sources(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn recalculate_latency(&self) -> Result<(), glib::error::BoolError> {
|
fn recalculate_latency(&self) -> Result<(), glib::error::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -8,6 +8,7 @@ use ClockTime;
|
||||||
use ElementFactory;
|
use ElementFactory;
|
||||||
use Error;
|
use Error;
|
||||||
use Format;
|
use Format;
|
||||||
|
use Iterator;
|
||||||
use Message;
|
use Message;
|
||||||
use Object;
|
use Object;
|
||||||
use Pad;
|
use Pad;
|
||||||
|
@ -129,11 +130,11 @@ pub trait ElementExt {
|
||||||
|
|
||||||
fn is_locked_state(&self) -> bool;
|
fn is_locked_state(&self) -> bool;
|
||||||
|
|
||||||
//fn iterate_pads(&self) -> /*Ignored*/Option<Iterator>;
|
fn iterate_pads(&self) -> Option<Iterator>;
|
||||||
|
|
||||||
//fn iterate_sink_pads(&self) -> /*Ignored*/Option<Iterator>;
|
fn iterate_sink_pads(&self) -> Option<Iterator>;
|
||||||
|
|
||||||
//fn iterate_src_pads(&self) -> /*Ignored*/Option<Iterator>;
|
fn iterate_src_pads(&self) -> Option<Iterator>;
|
||||||
|
|
||||||
fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError>;
|
fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError>;
|
||||||
|
|
||||||
|
@ -347,17 +348,23 @@ impl<O: IsA<Element> + IsA<glib::object::Object>> ElementExt for O {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fn iterate_pads(&self) -> /*Ignored*/Option<Iterator> {
|
fn iterate_pads(&self) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_element_iterate_pads() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_element_iterate_pads(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fn iterate_sink_pads(&self) -> /*Ignored*/Option<Iterator> {
|
fn iterate_sink_pads(&self) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_element_iterate_sink_pads() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_element_iterate_sink_pads(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fn iterate_src_pads(&self) -> /*Ignored*/Option<Iterator> {
|
fn iterate_src_pads(&self) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_element_iterate_src_pads() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_element_iterate_src_pads(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError> {
|
fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -479,6 +479,69 @@ impl SetValue for Format {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||||
|
pub enum IteratorResult {
|
||||||
|
Done,
|
||||||
|
Ok,
|
||||||
|
Resync,
|
||||||
|
Error,
|
||||||
|
#[doc(hidden)]
|
||||||
|
__Unknown(i32),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
impl ToGlib for IteratorResult {
|
||||||
|
type GlibType = ffi::GstIteratorResult;
|
||||||
|
|
||||||
|
fn to_glib(&self) -> ffi::GstIteratorResult {
|
||||||
|
match *self {
|
||||||
|
IteratorResult::Done => ffi::GST_ITERATOR_DONE,
|
||||||
|
IteratorResult::Ok => ffi::GST_ITERATOR_OK,
|
||||||
|
IteratorResult::Resync => ffi::GST_ITERATOR_RESYNC,
|
||||||
|
IteratorResult::Error => ffi::GST_ITERATOR_ERROR,
|
||||||
|
IteratorResult::__Unknown(value) => unsafe{std::mem::transmute(value)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
impl FromGlib<ffi::GstIteratorResult> for IteratorResult {
|
||||||
|
fn from_glib(value: ffi::GstIteratorResult) -> Self {
|
||||||
|
skip_assert_initialized!();
|
||||||
|
match value as i32 {
|
||||||
|
0 => IteratorResult::Done,
|
||||||
|
1 => IteratorResult::Ok,
|
||||||
|
2 => IteratorResult::Resync,
|
||||||
|
3 => IteratorResult::Error,
|
||||||
|
value => IteratorResult::__Unknown(value),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StaticType for IteratorResult {
|
||||||
|
fn static_type() -> Type {
|
||||||
|
unsafe { from_glib(ffi::gst_iterator_result_get_type()) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> FromValueOptional<'a> for IteratorResult {
|
||||||
|
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
|
||||||
|
Some(FromValue::from_value(value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> FromValue<'a> for IteratorResult {
|
||||||
|
unsafe fn from_value(value: &Value) -> Self {
|
||||||
|
from_glib(std::mem::transmute::<i32, ffi::GstIteratorResult>(gobject_ffi::g_value_get_enum(value.to_glib_none().0)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SetValue for IteratorResult {
|
||||||
|
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 LibraryError {
|
pub enum LibraryError {
|
||||||
Failed,
|
Failed,
|
||||||
|
|
|
@ -90,6 +90,7 @@ pub use self::enums::CapsIntersectMode;
|
||||||
pub use self::enums::CoreError;
|
pub use self::enums::CoreError;
|
||||||
pub use self::enums::FlowReturn;
|
pub use self::enums::FlowReturn;
|
||||||
pub use self::enums::Format;
|
pub use self::enums::Format;
|
||||||
|
pub use self::enums::IteratorResult;
|
||||||
pub use self::enums::LibraryError;
|
pub use self::enums::LibraryError;
|
||||||
pub use self::enums::PadDirection;
|
pub use self::enums::PadDirection;
|
||||||
pub use self::enums::PadLinkReturn;
|
pub use self::enums::PadLinkReturn;
|
||||||
|
|
|
@ -5,6 +5,7 @@ use Caps;
|
||||||
use Element;
|
use Element;
|
||||||
use FlowReturn;
|
use FlowReturn;
|
||||||
use Format;
|
use Format;
|
||||||
|
use Iterator;
|
||||||
use Object;
|
use Object;
|
||||||
use PadDirection;
|
use PadDirection;
|
||||||
use PadLinkReturn;
|
use PadLinkReturn;
|
||||||
|
@ -128,9 +129,9 @@ pub trait PadExt {
|
||||||
|
|
||||||
fn is_linked(&self) -> bool;
|
fn is_linked(&self) -> bool;
|
||||||
|
|
||||||
//fn iterate_internal_links(&self) -> /*Ignored*/Option<Iterator>;
|
fn iterate_internal_links(&self) -> Option<Iterator>;
|
||||||
|
|
||||||
//fn iterate_internal_links_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q) -> /*Ignored*/Option<Iterator>;
|
fn iterate_internal_links_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q) -> Option<Iterator>;
|
||||||
|
|
||||||
fn link<P: IsA<Pad>>(&self, sinkpad: &P) -> PadLinkReturn;
|
fn link<P: IsA<Pad>>(&self, sinkpad: &P) -> PadLinkReturn;
|
||||||
|
|
||||||
|
@ -380,13 +381,19 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fn iterate_internal_links(&self) -> /*Ignored*/Option<Iterator> {
|
fn iterate_internal_links(&self) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_pad_iterate_internal_links() }
|
unsafe {
|
||||||
//}
|
from_glib_full(ffi::gst_pad_iterate_internal_links(self.to_glib_none().0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//fn iterate_internal_links_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q) -> /*Ignored*/Option<Iterator> {
|
fn iterate_internal_links_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_pad_iterate_internal_links_default() }
|
let parent = parent.into();
|
||||||
//}
|
let parent = parent.to_glib_none();
|
||||||
|
unsafe {
|
||||||
|
from_glib_full(ffi::gst_pad_iterate_internal_links_default(self.to_glib_none().0, parent.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn link<P: IsA<Pad>>(&self, sinkpad: &P) -> PadLinkReturn {
|
fn link<P: IsA<Pad>>(&self, sinkpad: &P) -> PadLinkReturn {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// This file was generated by gir (a01311c+) from gir-files (???)
|
// This file was generated by gir (a01311c+) from gir-files (???)
|
||||||
// DO NOT EDIT
|
// DO NOT EDIT
|
||||||
|
|
||||||
|
use Iterator;
|
||||||
use Object;
|
use Object;
|
||||||
use Pad;
|
use Pad;
|
||||||
use ffi;
|
use ffi;
|
||||||
|
@ -24,9 +25,14 @@ impl ProxyPad {
|
||||||
// unsafe { TODO: call ffi::gst_proxy_pad_chain_list_default() }
|
// unsafe { TODO: call ffi::gst_proxy_pad_chain_list_default() }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//pub fn iterate_internal_links_default<'a, P: IsA<Pad>, Q: IsA<Object> + 'a, R: Into<Option<&'a Q>>>(pad: &P, parent: R) -> /*Ignored*/Option<Iterator> {
|
pub fn iterate_internal_links_default<'a, P: IsA<Pad>, Q: IsA<Object> + 'a, R: Into<Option<&'a Q>>>(pad: &P, parent: R) -> Option<Iterator> {
|
||||||
// unsafe { TODO: call ffi::gst_proxy_pad_iterate_internal_links_default() }
|
skip_assert_initialized!();
|
||||||
//}
|
let parent = parent.into();
|
||||||
|
let parent = parent.to_glib_none();
|
||||||
|
unsafe {
|
||||||
|
from_glib_full(ffi::gst_proxy_pad_iterate_internal_links_default(pad.to_glib_none().0, parent.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for ProxyPad {}
|
unsafe impl Send for ProxyPad {}
|
||||||
|
|
43
gstreamer/src/iterator.rs
Normal file
43
gstreamer/src/iterator.rs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
// This file was generated by gir (a01311c+) from gir-files (???)
|
||||||
|
// DO NOT EDIT
|
||||||
|
|
||||||
|
use ffi;
|
||||||
|
use glib::translate::*;
|
||||||
|
use glib_ffi;
|
||||||
|
use gobject_ffi;
|
||||||
|
use std::mem;
|
||||||
|
use std::ptr;
|
||||||
|
use glib::Value;
|
||||||
|
use IteratorResult;
|
||||||
|
|
||||||
|
glib_wrapper! {
|
||||||
|
pub struct Iterator(Boxed<ffi::GstIterator>);
|
||||||
|
|
||||||
|
match fn {
|
||||||
|
copy => |ptr| ffi::gst_iterator_copy(mut_override(ptr)),
|
||||||
|
free => |ptr| ffi::gst_iterator_free(ptr),
|
||||||
|
get_type => || ffi::gst_iterator_get_type(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Iterator {
|
||||||
|
pub fn next(&mut self) -> Result<Value, IteratorResult> {
|
||||||
|
unsafe {
|
||||||
|
let mut value = Value::uninitialized();
|
||||||
|
let res = from_glib(ffi::gst_iterator_next(self.to_glib_none_mut().0, value.to_glib_none_mut().0));
|
||||||
|
if res == IteratorResult::Ok {
|
||||||
|
Ok(value)
|
||||||
|
} else {
|
||||||
|
Err(res)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn resync(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
ffi::gst_iterator_resync(self.to_glib_none_mut().0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl Send for Iterator {}
|
|
@ -77,6 +77,8 @@ pub use element::ElementExtManual;
|
||||||
pub use bin::BinExtManual;
|
pub use bin::BinExtManual;
|
||||||
pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID};
|
pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID};
|
||||||
pub use gobject::GObjectExtManualGst;
|
pub use gobject::GObjectExtManualGst;
|
||||||
|
mod iterator;
|
||||||
|
pub use self::iterator::Iterator;
|
||||||
|
|
||||||
mod value;
|
mod value;
|
||||||
pub use value::*;
|
pub use value::*;
|
||||||
|
|
Loading…
Reference in a new issue