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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// 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 Object;
use Pad;
use PadDirection;
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, ffi::GstGhostPadClass>): 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()
        }
    }
}

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")
        }
    }
}