Commit 21888daa authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Add GhostPad bindings

parent 52dbf03d
......@@ -366,6 +366,40 @@ status = "generate"
# Correct mutability
ignore = true
[[object]]
name = "Gst.GhostPad"
status = "generate"
[[object.function]]
name = "set_target"
[object.function.return]
bool_return_is_error = "Failed to set target"
[[object.function]]
name = "new"
ignore = true
[[object.function]]
name = "new_from_template"
ignore = true
[[object.function]]
name = "construct"
ignore = true
[[object]]
name = "Gst.ProxyPad"
status = "generate"
[[object.function]]
name = "chain_default"
# Buffer move
ignore = true
[[object.function]]
name = "getrange_default"
# Buffer move
ignore = true
[[object]]
name = "Gst.Stream"
status = "generate"
......
// This file was generated by gir (a01311c+) from gir-files (???)
// DO NOT EDIT
use Object;
use Pad;
use PadDirection;
use PadMode;
use PadTemplate;
use ProxyPad;
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct GhostPad(Object<ffi::GstGhostPad>): ProxyPad, Pad, Object;
match fn {
get_type => || ffi::gst_ghost_pad_get_type(),
}
}
impl GhostPad {
pub fn new_no_target<'a, P: Into<Option<&'a str>>>(name: P, dir: PadDirection) -> GhostPad {
assert_initialized_main_thread!();
let name = name.into();
let name = name.to_glib_none();
unsafe {
Pad::from_glib_none(ffi::gst_ghost_pad_new_no_target(name.0, dir.to_glib())).downcast_unchecked()
}
}
pub fn new_no_target_from_template<'a, P: Into<Option<&'a str>>>(name: P, templ: &PadTemplate) -> GhostPad {
skip_assert_initialized!();
let name = name.into();
let name = name.to_glib_none();
unsafe {
Pad::from_glib_none(ffi::gst_ghost_pad_new_no_target_from_template(name.0, templ.to_glib_none().0)).downcast_unchecked()
}
}
pub fn activate_mode_default<'a, P: IsA<Pad>, Q: IsA<Object> + 'a, R: Into<Option<&'a Q>>>(pad: &P, parent: R, mode: PadMode, active: bool) -> bool {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_ghost_pad_activate_mode_default(pad.to_glib_none().0, parent.0, mode.to_glib(), active.to_glib()))
}
}
pub fn internal_activate_mode_default<'a, P: IsA<Pad>, Q: IsA<Object> + 'a, R: Into<Option<&'a Q>>>(pad: &P, parent: R, mode: PadMode, active: bool) -> bool {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_ghost_pad_internal_activate_mode_default(pad.to_glib_none().0, parent.0, mode.to_glib(), active.to_glib()))
}
}
}
unsafe impl Send for GhostPad {}
unsafe impl Sync for GhostPad {}
pub trait GhostPadExt {
fn get_target(&self) -> Option<Pad>;
fn set_target<'a, P: IsA<Pad> + 'a, Q: Into<Option<&'a P>>>(&self, newtarget: Q) -> Result<(), glib::error::BoolError>;
}
impl<O: IsA<GhostPad>> GhostPadExt for O {
fn get_target(&self) -> Option<Pad> {
unsafe {
from_glib_full(ffi::gst_ghost_pad_get_target(self.to_glib_none().0))
}
}
fn set_target<'a, P: IsA<Pad> + 'a, Q: Into<Option<&'a P>>>(&self, newtarget: Q) -> Result<(), glib::error::BoolError> {
let newtarget = newtarget.into();
let newtarget = newtarget.to_glib_none();
unsafe {
glib::error::BoolError::from_glib(ffi::gst_ghost_pad_set_target(self.to_glib_none().0, newtarget.0), "Failed to set target")
}
}
}
......@@ -35,6 +35,10 @@ pub use self::element::ElementExt;
mod element_factory;
pub use self::element_factory::ElementFactory;
mod ghost_pad;
pub use self::ghost_pad::GhostPad;
pub use self::ghost_pad::GhostPadExt;
mod object;
pub use self::object::Object;
pub use self::object::ObjectExt;
......@@ -54,6 +58,10 @@ pub use self::pipeline::PipelineExt;
mod plugin;
pub use self::plugin::Plugin;
mod proxy_pad;
pub use self::proxy_pad::ProxyPad;
pub use self::proxy_pad::ProxyPadExt;
#[cfg(feature = "v1_10")]
mod stream;
#[cfg(feature = "v1_10")]
......@@ -193,10 +201,12 @@ pub mod traits {
pub use super::DeviceProviderExt;
pub use super::DeviceProviderFactoryExt;
pub use super::ElementExt;
pub use super::GhostPadExt;
pub use super::ObjectExt;
pub use super::PadExt;
pub use super::PadTemplateExt;
pub use super::PipelineExt;
pub use super::ProxyPadExt;
#[cfg(feature = "v1_10")]
pub use super::StreamExt;
#[cfg(feature = "v1_10")]
......
// This file was generated by gir (a01311c+) from gir-files (???)
// DO NOT EDIT
use Object;
use Pad;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct ProxyPad(Object<ffi::GstProxyPad>): Pad, Object;
match fn {
get_type => || ffi::gst_proxy_pad_get_type(),
}
}
impl ProxyPad {
//pub fn chain_list_default<'a, P: IsA<Pad>, Q: IsA<Object> + 'a, R: Into<Option<&'a Q>>>(pad: &P, parent: R, list: /*Ignored*/&mut BufferList) -> FlowReturn {
// 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> {
// unsafe { TODO: call ffi::gst_proxy_pad_iterate_internal_links_default() }
//}
}
unsafe impl Send for ProxyPad {}
unsafe impl Sync for ProxyPad {}
pub trait ProxyPadExt {
fn get_internal(&self) -> Option<ProxyPad>;
}
impl<O: IsA<ProxyPad>> ProxyPadExt for O {
fn get_internal(&self) -> Option<ProxyPad> {
unsafe {
from_glib_full(ffi::gst_proxy_pad_get_internal(self.to_glib_none().0))
}
}
}
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use Pad;
use PadTemplate;
use GhostPad;
use ffi;
use glib::object::Downcast;
use glib::object::IsA;
use glib::translate::*;
impl GhostPad {
pub fn new<'a, P: Into<Option<&'a str>>, Q: IsA<Pad>>(name: P, target: &Q) -> Option<GhostPad> {
skip_assert_initialized!();
let name = name.into();
let name = name.to_glib_none();
unsafe {
Option::<Pad>::from_glib_none(ffi::gst_ghost_pad_new(name.0, target.to_glib_none().0)).map(|o| Downcast::downcast_unchecked(o))
}
}
pub fn new_from_template<'a, P: Into<Option<&'a str>>, Q: IsA<Pad>>(name: P, target: &Q, templ: &PadTemplate) -> Option<GhostPad> {
skip_assert_initialized!();
let name = name.into();
let name = name.to_glib_none();
unsafe {
Option::<Pad>::from_glib_none(ffi::gst_ghost_pad_new_from_template(name.0, target.to_glib_none().0, templ.to_glib_none().0)).map(|o| Downcast::downcast_unchecked(o))
}
}
}
......@@ -71,6 +71,8 @@ mod bus;
mod pad;
mod gobject;
mod segment;
mod proxy_pad;
mod ghost_pad;
pub use element::ElementExtManual;
pub use bin::BinExtManual;
pub use pad::{PadExtManual, PadProbeId, PadProbeInfo, PadProbeData, PAD_PROBE_ID_INVALID};
......
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::ptr;
use Pad;
use ProxyPad;
use Object;
use FlowReturn;
use Buffer;
use glib::IsA;
use glib::translate::{ToGlibPtr, from_glib, from_glib_full};
use ffi;
impl ProxyPad {
pub fn chain_default<'a, P: IsA<Pad>, Q: IsA<Object> + 'a, R: Into<Option<&'a Q>>>(pad: &P, parent: R, buffer: Buffer) -> FlowReturn {
skip_assert_initialized!();
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_proxy_pad_chain_default(pad.to_glib_none().0, parent.0, buffer.into_ptr()))
}
}
pub fn getrange_default<P: IsA<Pad>, Q: IsA<Object>>(pad: &P, parent: &Q, offset: u64, size: u32) -> Result<Buffer, FlowReturn> {
skip_assert_initialized!();
unsafe {
let mut buffer = ptr::null_mut();
let ret = from_glib(ffi::gst_proxy_pad_getrange_default(pad.to_glib_none().0, parent.to_glib_none().0, offset, size, &mut buffer));
if ret == FlowReturn::Ok {
Ok(from_glib_full(buffer))
} else {
Err(ret)
}
}
}
}
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