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
// 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::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::Value;
use glib_sys;
use gobject_sys;
use gst;
use gst_base_sys;
use std::boxed::Box as Box_;
use std::mem::transmute;

glib_wrapper! {
    /// Manages a set of pads with the purpose of aggregating their buffers.
    /// Control is given to the subclass when all pads have data.
    ///
    ///  * Base class for mixers and muxers. Subclasses should at least implement
    ///  the `AggregatorClass.aggregate`() virtual method.
    ///
    ///  * Installs a `GstPadChainFunction`, a `GstPadEventFullFunction` and a
    ///  `GstPadQueryFunction` to queue all serialized data packets per sink pad.
    ///  Subclasses should not overwrite those, but instead implement
    ///  `AggregatorClass.sink_event`() and `AggregatorClass.sink_query`() as
    ///  needed.
    ///
    ///  * When data is queued on all pads, the aggregate vmethod is called.
    ///
    ///  * One can peek at the data on any given GstAggregatorPad with the
    ///  gst_aggregator_pad_peek_buffer () method, and remove it from the pad
    ///  with the gst_aggregator_pad_pop_buffer () method. When a buffer
    ///  has been taken with pop_buffer (), a new buffer can be queued
    ///  on that pad.
    ///
    ///  * If the subclass wishes to push a buffer downstream in its aggregate
    ///  implementation, it should do so through the
    ///  gst_aggregator_finish_buffer () method. This method will take care
    ///  of sending and ordering mandatory events such as stream start, caps
    ///  and segment.
    ///
    ///  * Same goes for EOS events, which should not be pushed directly by the
    ///  subclass, it should instead return GST_FLOW_EOS in its aggregate
    ///  implementation.
    ///
    ///  * Note that the aggregator logic regarding gap event handling is to turn
    ///  these into gap buffers with matching PTS and duration. It will also
    ///  flag these buffers with GST_BUFFER_FLAG_GAP and GST_BUFFER_FLAG_DROPPABLE
    ///  to ease their identification and subsequent processing.
    ///
    ///  * Subclasses must use (a subclass of) `AggregatorPad` for both their
    ///  sink and source pads.
    ///  See `gst::ElementClass::add_static_pad_template_with_gtype`.
    ///
    /// This class used to live in gst-plugins-bad and was moved to core.
    ///
    /// Feature: `v1_14`
    ///
    /// # Implements
    ///
    /// [`AggregatorExt`](trait.AggregatorExt.html), [`gst::ElementExt`](../gst/trait.ElementExt.html), [`gst::ObjectExt`](../gst/trait.ObjectExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html)
    pub struct Aggregator(Object<gst_base_sys::GstAggregator, gst_base_sys::GstAggregatorClass, AggregatorClass>) @extends gst::Element, gst::Object;

    match fn {
        get_type => || gst_base_sys::gst_aggregator_get_type(),
    }
}

unsafe impl Send for Aggregator {}
unsafe impl Sync for Aggregator {}

pub const NONE_AGGREGATOR: Option<&Aggregator> = None;

/// Trait containing all `Aggregator` methods.
///
/// Feature: `v1_14`
///
/// # Implementors
///
/// [`Aggregator`](struct.Aggregator.html)
pub trait AggregatorExt: 'static {
    //#[cfg(any(feature = "v1_14", feature = "dox"))]
    //fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams);

    ///
    /// Feature: `v1_14`
    ///
    ///
    /// # Returns
    ///
    /// the instance of the `gst::BufferPool` used
    /// by `trans`; free it after use it
    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn get_buffer_pool(&self) -> Option<gst::BufferPool>;

    /// Retrieves the latency values reported by `self` in response to the latency
    /// query, or `GST_CLOCK_TIME_NONE` if there is not live source connected and the element
    /// will not wait for the clock.
    ///
    /// Typically only called by subclasses.
    ///
    /// Feature: `v1_14`
    ///
    ///
    /// # Returns
    ///
    /// The latency or `GST_CLOCK_TIME_NONE` if the element does not sync
    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn get_latency(&self) -> gst::ClockTime;

    /// Lets `Aggregator` sub-classes tell the baseclass what their internal
    /// latency is. Will also post a LATENCY message on the bus so the pipeline
    /// can reconfigure its global latency.
    ///
    /// Feature: `v1_14`
    ///
    /// ## `min_latency`
    /// minimum latency
    /// ## `max_latency`
    /// maximum latency
    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn set_latency(&self, min_latency: gst::ClockTime, max_latency: gst::ClockTime);

    /// Sets the caps to be used on the src pad.
    ///
    /// Feature: `v1_14`
    ///
    /// ## `caps`
    /// The `gst::Caps` to set on the src pad.
    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn set_src_caps(&self, caps: &gst::Caps);

    /// This is a simple `Aggregator::get_next_time` implementation that
    /// just looks at the `gst::Segment` on the srcpad of the aggregator and bases
    /// the next time on the running time there.
    ///
    /// This is the desired behaviour in most cases where you have a live source
    /// and you have a dead line based aggregator subclass.
    ///
    /// Feature: `v1_16`
    ///
    ///
    /// # Returns
    ///
    /// The running time based on the position
    #[cfg(any(feature = "v1_16", feature = "dox"))]
    fn simple_get_next_time(&self) -> gst::ClockTime;

    fn get_property_start_time(&self) -> u64;

    fn set_property_start_time(&self, start_time: u64);

    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn connect_property_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;

    fn connect_property_start_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId;
}

impl<O: IsA<Aggregator>> AggregatorExt for O {
    //#[cfg(any(feature = "v1_14", feature = "dox"))]
    //fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams) {
    //    unsafe { TODO: call gst_base_sys:gst_aggregator_get_allocator() }
    //}

    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn get_buffer_pool(&self) -> Option<gst::BufferPool> {
        unsafe {
            from_glib_full(gst_base_sys::gst_aggregator_get_buffer_pool(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn get_latency(&self) -> gst::ClockTime {
        unsafe {
            from_glib(gst_base_sys::gst_aggregator_get_latency(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn set_latency(&self, min_latency: gst::ClockTime, max_latency: gst::ClockTime) {
        unsafe {
            gst_base_sys::gst_aggregator_set_latency(
                self.as_ref().to_glib_none().0,
                min_latency.to_glib(),
                max_latency.to_glib(),
            );
        }
    }

    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn set_src_caps(&self, caps: &gst::Caps) {
        unsafe {
            gst_base_sys::gst_aggregator_set_src_caps(
                self.as_ref().to_glib_none().0,
                caps.to_glib_none().0,
            );
        }
    }

    #[cfg(any(feature = "v1_16", feature = "dox"))]
    fn simple_get_next_time(&self) -> gst::ClockTime {
        unsafe {
            from_glib(gst_base_sys::gst_aggregator_simple_get_next_time(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    fn get_property_start_time(&self) -> u64 {
        unsafe {
            let mut value = Value::from_type(<u64 as StaticType>::static_type());
            gobject_sys::g_object_get_property(
                self.to_glib_none().0 as *mut gobject_sys::GObject,
                b"start-time\0".as_ptr() as *const _,
                value.to_glib_none_mut().0,
            );
            value
                .get()
                .expect("Return Value for property `start-time` getter")
                .unwrap()
        }
    }

    fn set_property_start_time(&self, start_time: u64) {
        unsafe {
            gobject_sys::g_object_set_property(
                self.to_glib_none().0 as *mut gobject_sys::GObject,
                b"start-time\0".as_ptr() as *const _,
                Value::from(&start_time).to_glib_none().0,
            );
        }
    }

    #[cfg(any(feature = "v1_14", feature = "dox"))]
    fn connect_property_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_latency_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
            this: *mut gst_base_sys::GstAggregator,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<Aggregator>,
        {
            let f: &F = &*(f as *const F);
            f(&Aggregator::from_glib_borrow(this).unsafe_cast())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::latency\0".as_ptr() as *const _,
                Some(transmute(notify_latency_trampoline::<Self, F> as usize)),
                Box_::into_raw(f),
            )
        }
    }

    fn connect_property_start_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_start_time_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
            this: *mut gst_base_sys::GstAggregator,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::gpointer,
        ) where
            P: IsA<Aggregator>,
        {
            let f: &F = &*(f as *const F);
            f(&Aggregator::from_glib_borrow(this).unsafe_cast())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::start-time\0".as_ptr() as *const _,
                Some(transmute(notify_start_time_trampoline::<Self, F> as usize)),
                Box_::into_raw(f),
            )
        }
    }
}