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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    /// Subclasses must use (a subclass of) [`AudioAggregatorPad`][crate::AudioAggregatorPad] for both
    /// their source and sink pads,
    /// `gst_element_class_add_static_pad_template_with_gtype()` is a convenient
    /// helper.
    ///
    /// [`AudioAggregator`][crate::AudioAggregator] can perform conversion on the data arriving
    /// on its sink pads, based on the format expected downstream: in order
    /// to enable that behaviour, the GType of the sink pads must either be
    /// a (subclass of) [`AudioAggregatorConvertPad`][crate::AudioAggregatorConvertPad] to use the default
    /// `GstAudioConverter` implementation, or a subclass of [`AudioAggregatorPad`][crate::AudioAggregatorPad]
    /// implementing `GstAudioAggregatorPadClass.convert_buffer`.
    ///
    /// To allow for the output caps to change, the mechanism is the same as
    /// above, with the GType of the source pad.
    ///
    /// See `GstAudioMixer` for an example.
    ///
    /// When conversion is enabled, [`AudioAggregator`][crate::AudioAggregator] will accept
    /// any type of raw audio caps and perform conversion
    /// on the data arriving on its sink pads, with whatever downstream
    /// expects as the target format.
    ///
    /// In case downstream caps are not fully fixated, it will use
    /// the first configured sink pad to finish fixating its source pad
    /// caps.
    ///
    /// A notable exception for now is the sample rate, sink pads must
    /// have the same sample rate as either the downstream requirement,
    /// or the first configured pad, or a combination of both (when
    /// downstream specifies a range or a set of acceptable rates).
    ///
    /// The [`samples-selected`][struct@crate::gst_base::Aggregator#samples-selected] signal is provided with some
    /// additional information about the output buffer:
    /// - "offset" G_TYPE_UINT64 Offset in samples since segment start
    ///  for the position that is next to be filled in the output buffer.
    /// - "frames" G_TYPE_UINT Number of frames per output buffer.
    ///
    /// In addition the [`AggregatorExtManual::peek_next_sample()`][crate::gst_base::prelude::AggregatorExtManual::peek_next_sample()] function returns
    /// additional information in the info `GstStructure` of the returned sample:
    /// - "output-offset" G_TYPE_UINT64 Sample offset in output segment relative to
    ///  the output segment's start where the current position of this input
    ///  buffer would be placed
    /// - "position" G_TYPE_UINT current position in the input buffer in samples
    /// - "size" G_TYPE_UINT size of the input buffer in samples
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// ## Properties
    ///
    ///
    /// #### `alignment-threshold`
    ///  Readable | Writeable
    ///
    ///
    /// #### `discont-wait`
    ///  Readable | Writeable
    ///
    ///
    /// #### `force-live`
    ///  Causes the element to aggregate on a timeout even when no live source is
    /// connected to its sinks. See [`min-upstream-latency`][struct@crate::gst_base::Aggregator#min-upstream-latency] for a
    /// companion property: in the vast majority of cases where you plan to plug in
    /// live sources with a non-zero latency, you should set it to a non-zero value.
    ///
    /// Readable | Writeable | Construct Only
    ///
    ///
    /// #### `ignore-inactive-pads`
    ///  Don't wait for inactive pads when live. An inactive pad
    /// is a pad that hasn't yet received a buffer, but that has
    /// been waited on at least once.
    ///
    /// The purpose of this property is to avoid aggregating on
    /// timeout when new pads are requested in advance of receiving
    /// data flow, for example the user may decide to connect it later,
    /// but wants to configure it already.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `output-buffer-duration`
    ///  Readable | Writeable
    ///
    ///
    /// #### `output-buffer-duration-fraction`
    ///  Output block size in nanoseconds, expressed as a fraction.
    ///
    /// Readable | Writeable
    /// <details><summary><h4>Aggregator</h4></summary>
    ///
    ///
    /// #### `emit-signals`
    ///  Enables the emission of signals such as [`samples-selected`][struct@crate::gst_base::Aggregator#samples-selected]
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `latency`
    ///  Readable | Writeable
    ///
    ///
    /// #### `min-upstream-latency`
    ///  Force minimum upstream latency (in nanoseconds). When sources with a
    /// higher latency are expected to be plugged in dynamically after the
    /// aggregator has started playing, this allows overriding the minimum
    /// latency reported by the initial source(s). This is only taken into
    /// account when larger than the actually reported minimum latency.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `start-time`
    ///  Readable | Writeable
    ///
    ///
    /// #### `start-time-selection`
    ///  Readable | Writeable
    /// </details>
    /// <details><summary><h4>Object</h4></summary>
    ///
    ///
    /// #### `name`
    ///  Readable | Writeable | Construct
    ///
    ///
    /// #### `parent`
    ///  The parent of the object. Please note, that when changing the 'parent'
    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
    /// signals due to locking issues. In some cases one can use
    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
    /// achieve a similar effect.
    ///
    /// Readable | Writeable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`AudioAggregatorExt`][trait@crate::prelude::AudioAggregatorExt], [`trait@gst_base::prelude::AggregatorExt`], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::GstObjectExt`], [`trait@glib::ObjectExt`]
    #[doc(alias = "GstAudioAggregator")]
    pub struct AudioAggregator(Object<ffi::GstAudioAggregator, ffi::GstAudioAggregatorClass>) @extends gst_base::Aggregator, gst::Element, gst::Object;

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

impl AudioAggregator {
    pub const NONE: Option<&'static AudioAggregator> = None;
}

unsafe impl Send for AudioAggregator {}
unsafe impl Sync for AudioAggregator {}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::AudioAggregator>> Sealed for T {}
}

/// Trait containing all [`struct@AudioAggregator`] methods.
///
/// # Implementors
///
/// [`AudioAggregator`][struct@crate::AudioAggregator]
pub trait AudioAggregatorExt: IsA<AudioAggregator> + sealed::Sealed + 'static {
    #[doc(alias = "alignment-threshold")]
    fn alignment_threshold(&self) -> u64 {
        ObjectExt::property(self.as_ref(), "alignment-threshold")
    }

    #[doc(alias = "alignment-threshold")]
    fn set_alignment_threshold(&self, alignment_threshold: u64) {
        ObjectExt::set_property(self.as_ref(), "alignment-threshold", alignment_threshold)
    }

    #[doc(alias = "discont-wait")]
    fn discont_wait(&self) -> u64 {
        ObjectExt::property(self.as_ref(), "discont-wait")
    }

    #[doc(alias = "discont-wait")]
    fn set_discont_wait(&self, discont_wait: u64) {
        ObjectExt::set_property(self.as_ref(), "discont-wait", discont_wait)
    }

    #[doc(alias = "output-buffer-duration")]
    fn output_buffer_duration(&self) -> u64 {
        ObjectExt::property(self.as_ref(), "output-buffer-duration")
    }

    #[doc(alias = "output-buffer-duration")]
    fn set_output_buffer_duration(&self, output_buffer_duration: u64) {
        ObjectExt::set_property(
            self.as_ref(),
            "output-buffer-duration",
            output_buffer_duration,
        )
    }

    #[doc(alias = "alignment-threshold")]
    fn connect_alignment_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_alignment_threshold_trampoline<
            P: IsA<AudioAggregator>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstAudioAggregator,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AudioAggregator::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::alignment-threshold\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_alignment_threshold_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "discont-wait")]
    fn connect_discont_wait_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_discont_wait_trampoline<
            P: IsA<AudioAggregator>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstAudioAggregator,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AudioAggregator::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::discont-wait\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_discont_wait_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "output-buffer-duration")]
    fn connect_output_buffer_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_output_buffer_duration_trampoline<
            P: IsA<AudioAggregator>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstAudioAggregator,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(AudioAggregator::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::output-buffer-duration\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_output_buffer_duration_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

impl<O: IsA<AudioAggregator>> AudioAggregatorExt for O {}