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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// This file was generated by gir (https://github.com/gtk-rs/gir)
// DO NOT EDIT

use crate::{Core,GlobalProxy,Iterator,NodeState,Object,ObjectInterest,PipewireObject,Port,Properties,Proxy};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    #[doc(alias = "WpNode")]
    pub struct Node(Object<ffi::WpNode, ffi::WpNodeClass>) @extends GlobalProxy, Proxy, Object, @implements PipewireObject;

    match fn {
        type_ => || ffi::wp_node_get_type(),
    }
}

impl Node {
    #[doc(alias = "wp_node_new_from_factory")]
    #[doc(alias = "new_from_factory")]
    pub fn from_factory(core: &Core, factory_name: &str, properties: Option<Properties>) -> Option<Node> {
        unsafe {
            from_glib_full(ffi::wp_node_new_from_factory(core.to_glib_none().0, factory_name.to_glib_none().0, properties.into_glib_ptr()))
        }
    }

    #[doc(alias = "wp_node_get_n_input_ports")]
    #[doc(alias = "get_n_input_ports")]
    pub fn n_input_ports(&self) -> (u32, u32) {
        unsafe {
            let mut max = std::mem::MaybeUninit::uninit();
            let ret = ffi::wp_node_get_n_input_ports(self.to_glib_none().0, max.as_mut_ptr());
            (ret, max.assume_init())
        }
    }

    #[doc(alias = "wp_node_get_n_output_ports")]
    #[doc(alias = "get_n_output_ports")]
    pub fn n_output_ports(&self) -> (u32, u32) {
        unsafe {
            let mut max = std::mem::MaybeUninit::uninit();
            let ret = ffi::wp_node_get_n_output_ports(self.to_glib_none().0, max.as_mut_ptr());
            (ret, max.assume_init())
        }
    }

    #[doc(alias = "wp_node_get_n_ports")]
    #[doc(alias = "get_n_ports")]
    pub fn n_ports(&self) -> u32 {
        unsafe {
            ffi::wp_node_get_n_ports(self.to_glib_none().0)
        }
    }

    #[doc(alias = "wp_node_lookup_port_full")]
    #[doc(alias = "lookup_port_full")]
    pub fn lookup_port(&self, interest: ObjectInterest) -> Option<Port> {
        unsafe {
            from_glib_full(ffi::wp_node_lookup_port_full(self.to_glib_none().0, interest.into_glib_ptr()))
        }
    }

    #[doc(alias = "wp_node_new_ports_filtered_iterator_full")]
    #[doc(alias = "new_ports_filtered_iterator_full")]
#[allow(dead_code)]    pub(crate) fn ports_filtered_iterator(&self, interest: ObjectInterest) -> Option<Iterator> {
        unsafe {
            from_glib_full(ffi::wp_node_new_ports_filtered_iterator_full(self.to_glib_none().0, interest.into_glib_ptr()))
        }
    }

    #[doc(alias = "wp_node_new_ports_iterator")]
    #[doc(alias = "new_ports_iterator")]
#[allow(dead_code)]    pub(crate) fn ports_iterator(&self) -> Option<Iterator> {
        unsafe {
            from_glib_full(ffi::wp_node_new_ports_iterator(self.to_glib_none().0))
        }
    }

    #[doc(alias = "wp_node_send_command")]
    pub fn send_command(&self, command: &str) {
        unsafe {
            ffi::wp_node_send_command(self.to_glib_none().0, command.to_glib_none().0);
        }
    }

    #[doc(alias = "max-input-ports")]
    pub fn max_input_ports(&self) -> u32 {
        ObjectExt::property(self, "max-input-ports")
    }

    #[doc(alias = "max-output-ports")]
    pub fn max_output_ports(&self) -> u32 {
        ObjectExt::property(self, "max-output-ports")
    }

    #[doc(alias = "ports-changed")]
    pub fn connect_ports_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn ports_changed_trampoline<F: Fn(&Node) + 'static>(this: *mut ffi::WpNode, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"ports-changed\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(ports_changed_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "state-changed")]
    pub fn connect_state_changed<F: Fn(&Self, NodeState, NodeState) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn state_changed_trampoline<F: Fn(&Node, NodeState, NodeState) + 'static>(this: *mut ffi::WpNode, object: ffi::WpNodeState, p0: ffi::WpNodeState, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this), from_glib(object), from_glib(p0))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"state-changed\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(state_changed_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "max-input-ports")]
    pub fn connect_max_input_ports_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_max_input_ports_trampoline<F: Fn(&Node) + 'static>(this: *mut ffi::WpNode, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::max-input-ports\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_max_input_ports_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "max-output-ports")]
    pub fn connect_max_output_ports_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_max_output_ports_trampoline<F: Fn(&Node) + 'static>(this: *mut ffi::WpNode, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::max-output-ports\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_max_output_ports_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "n-input-ports")]
    pub fn connect_n_input_ports_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_n_input_ports_trampoline<F: Fn(&Node) + 'static>(this: *mut ffi::WpNode, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::n-input-ports\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_n_input_ports_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "n-output-ports")]
    pub fn connect_n_output_ports_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_n_output_ports_trampoline<F: Fn(&Node) + 'static>(this: *mut ffi::WpNode, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::n-output-ports\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_n_output_ports_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[doc(alias = "state")]
    pub fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_state_trampoline<F: Fn(&Node) + 'static>(this: *mut ffi::WpNode, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, b"notify::state\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_state_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}