1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib;
use glib::object::IsA;
use glib::translate::*;
use gst_sys;
use Object;
use Pad;
use ProxyPad;

glib_wrapper! {
    pub struct GhostPad(Object<gst_sys::GstGhostPad, gst_sys::GstGhostPadClass, GhostPadClass>) @extends ProxyPad, Pad, Object;

    match fn {
        get_type => || gst_sys::gst_ghost_pad_get_type(),
    }
}

unsafe impl Send for GhostPad {}
unsafe impl Sync for GhostPad {}

pub const NONE_GHOST_PAD: Option<&GhostPad> = None;

pub trait GhostPadExt: 'static {
    fn get_target(&self) -> Option<Pad>;

    fn set_target<P: IsA<Pad>>(&self, newtarget: Option<&P>) -> Result<(), glib::error::BoolError>;
}

impl<O: IsA<GhostPad>> GhostPadExt for O {
    fn get_target(&self) -> Option<Pad> {
        unsafe {
            from_glib_full(gst_sys::gst_ghost_pad_get_target(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn set_target<P: IsA<Pad>>(&self, newtarget: Option<&P>) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib_result_from_gboolean!(
                gst_sys::gst_ghost_pad_set_target(
                    self.as_ref().to_glib_none().0,
                    newtarget.map(|p| p.as_ref()).to_glib_none().0
                ),
                "Failed to set target"
            )
        }
    }
}