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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
// 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
#![allow(deprecated)]

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

glib::wrapper! {
    /// This is a generic base class for source elements. The following
    /// types of sources are supported:
    ///
    ///  * random access sources like files
    ///  * seekable sources
    ///  * live sources
    ///
    /// The source can be configured to operate in any [`gst::Format`][crate::gst::Format] with the
    /// [`BaseSrcExt::set_format()`][crate::prelude::BaseSrcExt::set_format()] method. The currently set format determines
    /// the format of the internal [`gst::Segment`][crate::gst::Segment] and any [`gst::EventType::Segment`][crate::gst::EventType::Segment]
    /// events. The default format for [`BaseSrc`][crate::BaseSrc] is [`gst::Format::Bytes`][crate::gst::Format::Bytes].
    ///
    /// [`BaseSrc`][crate::BaseSrc] always supports push mode scheduling. If the following
    /// conditions are met, it also supports pull mode scheduling:
    ///
    ///  * The format is set to [`gst::Format::Bytes`][crate::gst::Format::Bytes] (default).
    ///  * `GstBaseSrcClass::is_seekable` returns [`true`].
    ///
    /// If all the conditions are met for operating in pull mode, [`BaseSrc`][crate::BaseSrc] is
    /// automatically seekable in push mode as well. The following conditions must
    /// be met to make the element seekable in push mode when the format is not
    /// [`gst::Format::Bytes`][crate::gst::Format::Bytes]:
    ///
    /// * `GstBaseSrcClass::is_seekable` returns [`true`].
    /// * `GstBaseSrcClass::query` can convert all supported seek formats to the
    ///  internal format as set with [`BaseSrcExt::set_format()`][crate::prelude::BaseSrcExt::set_format()].
    /// * `GstBaseSrcClass::do_seek` is implemented, performs the seek and returns
    ///  [`true`].
    ///
    /// When the element does not meet the requirements to operate in pull mode, the
    /// offset and length in the `GstBaseSrcClass::create` method should be ignored.
    /// It is recommended to subclass [`PushSrc`][crate::PushSrc] instead, in this situation. If the
    /// element can operate in pull mode but only with specific offsets and
    /// lengths, it is allowed to generate an error when the wrong values are passed
    /// to the `GstBaseSrcClass::create` function.
    ///
    /// [`BaseSrc`][crate::BaseSrc] has support for live sources. Live sources are sources that when
    /// paused discard data, such as audio or video capture devices. A typical live
    /// source also produces data at a fixed rate and thus provides a clock to publish
    /// this rate.
    /// Use [`BaseSrcExt::set_live()`][crate::prelude::BaseSrcExt::set_live()] to activate the live source mode.
    ///
    /// A live source does not produce data in the PAUSED state. This means that the
    /// `GstBaseSrcClass::create` method will not be called in PAUSED but only in
    /// PLAYING. To signal the pipeline that the element will not produce data, the
    /// return value from the READY to PAUSED state will be
    /// [`gst::StateChangeReturn::NoPreroll`][crate::gst::StateChangeReturn::NoPreroll].
    ///
    /// A typical live source will timestamp the buffers it creates with the
    /// current running time of the pipeline. This is one reason why a live source
    /// can only produce data in the PLAYING state, when the clock is actually
    /// distributed and running.
    ///
    /// Live sources that synchronize and block on the clock (an audio source, for
    /// example) can use [`BaseSrcExt::wait_playing()`][crate::prelude::BaseSrcExt::wait_playing()] when the
    /// `GstBaseSrcClass::create` function was interrupted by a state change to
    /// PAUSED.
    ///
    /// The `GstBaseSrcClass::get_times` method can be used to implement pseudo-live
    /// sources. It only makes sense to implement the `GstBaseSrcClass::get_times`
    /// function if the source is a live source. The `GstBaseSrcClass::get_times`
    /// function should return timestamps starting from 0, as if it were a non-live
    /// source. The base class will make sure that the timestamps are transformed
    /// into the current running_time. The base source will then wait for the
    /// calculated running_time before pushing out the buffer.
    ///
    /// For live sources, the base class will by default report a latency of 0.
    /// For pseudo live sources, the base class will by default measure the difference
    /// between the first buffer timestamp and the start time of get_times and will
    /// report this value as the latency.
    /// Subclasses should override the query function when this behaviour is not
    /// acceptable.
    ///
    /// There is only support in [`BaseSrc`][crate::BaseSrc] for exactly one source pad, which
    /// should be named "src". A source implementation (subclass of [`BaseSrc`][crate::BaseSrc])
    /// should install a pad template in its class_init function, like so:
    ///
    ///
    /// **⚠️ The following code is in C ⚠️**
    ///
    /// ```C
    /// static void
    /// my_element_class_init (GstMyElementClass *klass)
    /// {
    ///   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
    ///   // srctemplate should be a #GstStaticPadTemplate with direction
    ///   // %GST_PAD_SRC and name "src"
    ///   gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
    ///
    ///   gst_element_class_set_static_metadata (gstelement_class,
    ///      "Source name",
    ///      "Source",
    ///      "My Source element",
    ///      "The author <my.sink@my.email>");
    /// }
    /// ```
    ///
    /// ## Controlled shutdown of live sources in applications
    ///
    /// Applications that record from a live source may want to stop recording
    /// in a controlled way, so that the recording is stopped, but the data
    /// already in the pipeline is processed to the end (remember that many live
    /// sources would go on recording forever otherwise). For that to happen the
    /// application needs to make the source stop recording and send an EOS
    /// event down the pipeline. The application would then wait for an
    /// EOS message posted on the pipeline's bus to know when all data has
    /// been processed and the pipeline can safely be stopped.
    ///
    /// An application may send an EOS event to a source element to make it
    /// perform the EOS logic (send EOS event downstream or post a
    /// `GST_MESSAGE_SEGMENT_DONE` on the bus). This can typically be done
    /// with the [`ElementExtManual::send_event()`][crate::gst::prelude::ElementExtManual::send_event()] function on the element or its parent bin.
    ///
    /// After the EOS has been sent to the element, the application should wait for
    /// an EOS message to be posted on the pipeline's bus. Once this EOS message is
    /// received, it may safely shut down the entire pipeline.
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// ## Properties
    ///
    ///
    /// #### `automatic-eos`
    ///  See [`BaseSrcExt::set_automatic_eos()`][crate::prelude::BaseSrcExt::set_automatic_eos()]
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `blocksize`
    ///  Readable | Writeable
    ///
    ///
    /// #### `do-timestamp`
    ///  Readable | Writeable
    ///
    ///
    /// #### `num-buffers`
    ///  Readable | Writeable
    ///
    ///
    /// #### `typefind`
    ///  Readable | Writeable
    /// <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
    ///
    /// [`BaseSrcExt`][trait@crate::prelude::BaseSrcExt], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`BaseSrcExtManual`][trait@crate::prelude::BaseSrcExtManual]
    #[doc(alias = "GstBaseSrc")]
    pub struct BaseSrc(Object<ffi::GstBaseSrc, ffi::GstBaseSrcClass>) @extends gst::Element, gst::Object;

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

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

unsafe impl Send for BaseSrc {}
unsafe impl Sync for BaseSrc {}

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

/// Trait containing all [`struct@BaseSrc`] methods.
///
/// # Implementors
///
/// [`BaseSrc`][struct@crate::BaseSrc], [`PushSrc`][struct@crate::PushSrc]
pub trait BaseSrcExt: IsA<BaseSrc> + sealed::Sealed + 'static {
    /// Get the number of bytes that `self` will push out with each buffer.
    ///
    /// # Returns
    ///
    /// the number of bytes pushed with each buffer.
    #[doc(alias = "gst_base_src_get_blocksize")]
    #[doc(alias = "get_blocksize")]
    fn blocksize(&self) -> u32 {
        unsafe { ffi::gst_base_src_get_blocksize(self.as_ref().to_glib_none().0) }
    }

    ///
    /// # Returns
    ///
    /// the instance of the [`gst::BufferPool`][crate::gst::BufferPool] used
    /// by the src; unref it after usage.
    #[doc(alias = "gst_base_src_get_buffer_pool")]
    #[doc(alias = "get_buffer_pool")]
    fn buffer_pool(&self) -> Option<gst::BufferPool> {
        unsafe {
            from_glib_full(ffi::gst_base_src_get_buffer_pool(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Query if `self` timestamps outgoing buffers based on the current running_time.
    ///
    /// # Returns
    ///
    /// [`true`] if the base class will automatically timestamp outgoing buffers.
    #[doc(alias = "gst_base_src_get_do_timestamp")]
    #[doc(alias = "get_do_timestamp")]
    #[doc(alias = "do-timestamp")]
    fn does_timestamp(&self) -> bool {
        unsafe {
            from_glib(ffi::gst_base_src_get_do_timestamp(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// Get the current async behaviour of `self`. See also [`set_async()`][Self::set_async()].
    ///
    /// # Returns
    ///
    /// [`true`] if `self` is operating in async mode.
    #[doc(alias = "gst_base_src_is_async")]
    fn is_async(&self) -> bool {
        unsafe { from_glib(ffi::gst_base_src_is_async(self.as_ref().to_glib_none().0)) }
    }

    /// Check if an element is in live mode.
    ///
    /// # Returns
    ///
    /// [`true`] if element is in live mode.
    #[doc(alias = "gst_base_src_is_live")]
    fn is_live(&self) -> bool {
        unsafe { from_glib(ffi::gst_base_src_is_live(self.as_ref().to_glib_none().0)) }
    }

    /// Negotiates src pad caps with downstream elements.
    /// Unmarks GST_PAD_FLAG_NEED_RECONFIGURE in any case. But marks it again
    /// if `GstBaseSrcClass::negotiate` fails.
    ///
    /// Do not call this in the `GstBaseSrcClass::fill` vmethod. Call this in
    /// `GstBaseSrcClass::create` or in `GstBaseSrcClass::alloc`, _before_ any
    /// buffer is allocated.
    ///
    /// # Returns
    ///
    /// [`true`] if the negotiation succeeded, else [`false`].
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "gst_base_src_negotiate")]
    fn negotiate(&self) -> bool {
        unsafe { from_glib(ffi::gst_base_src_negotiate(self.as_ref().to_glib_none().0)) }
    }

    /// Prepare a new seamless segment for emission downstream. This function must
    /// only be called by derived sub-classes, and only from the `GstBaseSrcClass::create` function,
    /// as the stream-lock needs to be held.
    ///
    /// The format for the new segment will be the current format of the source, as
    /// configured with [`set_format()`][Self::set_format()]
    ///
    /// # Deprecated since 1.18
    ///
    /// Use [`new_segment()`][Self::new_segment()]
    /// ## `start`
    /// The new start value for the segment
    /// ## `stop`
    /// Stop value for the new segment
    /// ## `time`
    /// The new time value for the start of the new segment
    ///
    /// # Returns
    ///
    /// [`true`] if preparation of the seamless segment succeeded.
    #[cfg_attr(feature = "v1_18", deprecated = "Since 1.18")]
    #[allow(deprecated)]
    #[doc(alias = "gst_base_src_new_seamless_segment")]
    fn new_seamless_segment(&self, start: i64, stop: i64, time: i64) -> bool {
        unsafe {
            from_glib(ffi::gst_base_src_new_seamless_segment(
                self.as_ref().to_glib_none().0,
                start,
                stop,
                time,
            ))
        }
    }

    /// Prepare a new segment for emission downstream. This function must
    /// only be called by derived sub-classes, and only from the `GstBaseSrcClass::create` function,
    /// as the stream-lock needs to be held.
    ///
    /// The format for the `segment` must be identical with the current format
    /// of the source, as configured with [`set_format()`][Self::set_format()].
    ///
    /// The format of `self` must not be [`gst::Format::Undefined`][crate::gst::Format::Undefined] and the format
    /// should be configured via [`set_format()`][Self::set_format()] before calling this method.
    /// ## `segment`
    /// a pointer to a [`gst::Segment`][crate::gst::Segment]
    ///
    /// # Returns
    ///
    /// [`true`] if preparation of new segment succeeded.
    #[cfg(feature = "v1_18")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
    #[doc(alias = "gst_base_src_new_segment")]
    fn new_segment(&self, segment: &gst::Segment) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_base_src_new_segment(
                    self.as_ref().to_glib_none().0,
                    segment.to_glib_none().0
                ),
                "Failed to update segment"
            )
        }
    }

    /// Send a new segment downstream. This function must
    /// only be called by derived sub-classes, and only from the `GstBaseSrcClass::create` function,
    /// as the stream-lock needs to be held.
    /// This method also requires that an out caps has been configured, so
    /// [`set_caps()`][Self::set_caps()] needs to have been called before.
    ///
    /// The format for the `segment` must be identical with the current format
    /// of the source, as configured with [`set_format()`][Self::set_format()].
    ///
    /// The format of `self` must not be [`gst::Format::Undefined`][crate::gst::Format::Undefined] and the format
    /// should be configured via [`set_format()`][Self::set_format()] before calling this method.
    ///
    /// This is a variant of [`new_segment()`][Self::new_segment()] sending the segment right away,
    /// which can be useful to ensure events ordering.
    /// ## `segment`
    /// a pointer to a [`gst::Segment`][crate::gst::Segment]
    ///
    /// # Returns
    ///
    /// [`true`] if sending of new segment succeeded.
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    #[doc(alias = "gst_base_src_push_segment")]
    fn push_segment(&self, segment: &gst::Segment) -> bool {
        unsafe {
            from_glib(ffi::gst_base_src_push_segment(
                self.as_ref().to_glib_none().0,
                segment.to_glib_none().0,
            ))
        }
    }

    /// Configure async behaviour in `self`, no state change will block. The open,
    /// close, start, stop, play and pause virtual methods will be executed in a
    /// different thread and are thus allowed to perform blocking operations. Any
    /// blocking operation should be unblocked with the unlock vmethod.
    /// ## `async_`
    /// new async mode
    #[doc(alias = "gst_base_src_set_async")]
    fn set_async(&self, async_: bool) {
        unsafe {
            ffi::gst_base_src_set_async(self.as_ref().to_glib_none().0, async_.into_glib());
        }
    }

    /// If `automatic_eos` is [`true`], `self` will automatically go EOS if a buffer
    /// after the total size is returned. By default this is [`true`] but sources
    /// that can't return an authoritative size and only know that they're EOS
    /// when trying to read more should set this to [`false`].
    ///
    /// When `self` operates in [`gst::Format::Time`][crate::gst::Format::Time], [`BaseSrc`][crate::BaseSrc] will send an EOS
    /// when a buffer outside of the currently configured segment is pushed if
    /// `automatic_eos` is [`true`]. Since 1.16, if `automatic_eos` is [`false`] an
    /// EOS will be pushed only when the `GstBaseSrcClass::create` implementation
    /// returns [`gst::FlowReturn::Eos`][crate::gst::FlowReturn::Eos].
    /// ## `automatic_eos`
    /// automatic eos
    #[doc(alias = "gst_base_src_set_automatic_eos")]
    #[doc(alias = "automatic-eos")]
    fn set_automatic_eos(&self, automatic_eos: bool) {
        unsafe {
            ffi::gst_base_src_set_automatic_eos(
                self.as_ref().to_glib_none().0,
                automatic_eos.into_glib(),
            );
        }
    }

    /// Set the number of bytes that `self` will push out with each buffer. When
    /// `blocksize` is set to -1, a default length will be used.
    /// ## `blocksize`
    /// the new blocksize in bytes
    #[doc(alias = "gst_base_src_set_blocksize")]
    #[doc(alias = "blocksize")]
    fn set_blocksize(&self, blocksize: u32) {
        unsafe {
            ffi::gst_base_src_set_blocksize(self.as_ref().to_glib_none().0, blocksize);
        }
    }

    /// Set new caps on the basesrc source pad.
    /// ## `caps`
    /// a [`gst::Caps`][crate::gst::Caps]
    ///
    /// # Returns
    ///
    /// [`true`] if the caps could be set
    #[doc(alias = "gst_base_src_set_caps")]
    fn set_caps(&self, caps: &gst::Caps) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_base_src_set_caps(self.as_ref().to_glib_none().0, caps.to_glib_none().0),
                "Failed to set caps"
            )
        }
    }

    /// Configure `self` to automatically timestamp outgoing buffers based on the
    /// current running_time of the pipeline. This property is mostly useful for live
    /// sources.
    /// ## `timestamp`
    /// enable or disable timestamping
    #[doc(alias = "gst_base_src_set_do_timestamp")]
    #[doc(alias = "do-timestamp")]
    fn set_do_timestamp(&self, timestamp: bool) {
        unsafe {
            ffi::gst_base_src_set_do_timestamp(
                self.as_ref().to_glib_none().0,
                timestamp.into_glib(),
            );
        }
    }

    /// If not `dynamic`, size is only updated when needed, such as when trying to
    /// read past current tracked size. Otherwise, size is checked for upon each
    /// read.
    /// ## `dynamic`
    /// new dynamic size mode
    #[doc(alias = "gst_base_src_set_dynamic_size")]
    fn set_dynamic_size(&self, dynamic: bool) {
        unsafe {
            ffi::gst_base_src_set_dynamic_size(self.as_ref().to_glib_none().0, dynamic.into_glib());
        }
    }

    /// Sets the default format of the source. This will be the format used
    /// for sending SEGMENT events and for performing seeks.
    ///
    /// If a format of GST_FORMAT_BYTES is set, the element will be able to
    /// operate in pull mode if the `GstBaseSrcClass::is_seekable` returns [`true`].
    ///
    /// This function must only be called in states < [`gst::State::Paused`][crate::gst::State::Paused].
    /// ## `format`
    /// the format to use
    #[doc(alias = "gst_base_src_set_format")]
    fn set_format(&self, format: gst::Format) {
        unsafe {
            ffi::gst_base_src_set_format(self.as_ref().to_glib_none().0, format.into_glib());
        }
    }

    /// If the element listens to a live source, `live` should
    /// be set to [`true`].
    ///
    /// A live source will not produce data in the PAUSED state and
    /// will therefore not be able to participate in the PREROLL phase
    /// of a pipeline. To signal this fact to the application and the
    /// pipeline, the state change return value of the live source will
    /// be GST_STATE_CHANGE_NO_PREROLL.
    /// ## `live`
    /// new live-mode
    #[doc(alias = "gst_base_src_set_live")]
    fn set_live(&self, live: bool) {
        unsafe {
            ffi::gst_base_src_set_live(self.as_ref().to_glib_none().0, live.into_glib());
        }
    }

    /// Complete an asynchronous start operation. When the subclass overrides the
    /// start method, it should call [`start_complete()`][Self::start_complete()] when the start
    /// operation completes either from the same thread or from an asynchronous
    /// helper thread.
    /// ## `ret`
    /// a [`gst::FlowReturn`][crate::gst::FlowReturn]
    #[doc(alias = "gst_base_src_start_complete")]
    fn start_complete(&self, ret: impl Into<gst::FlowReturn>) {
        unsafe {
            ffi::gst_base_src_start_complete(
                self.as_ref().to_glib_none().0,
                ret.into().into_glib(),
            );
        }
    }

    /// Wait until the start operation completes.
    ///
    /// # Returns
    ///
    /// a [`gst::FlowReturn`][crate::gst::FlowReturn].
    #[doc(alias = "gst_base_src_start_wait")]
    fn start_wait(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
        unsafe { try_from_glib(ffi::gst_base_src_start_wait(self.as_ref().to_glib_none().0)) }
    }

    /// If the `GstBaseSrcClass::create` method performs its own synchronisation
    /// against the clock it must unblock when going from PLAYING to the PAUSED state
    /// and call this method before continuing to produce the remaining data.
    ///
    /// This function will block until a state change to PLAYING happens (in which
    /// case this function returns [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok]) or the processing must be stopped due
    /// to a state change to READY or a FLUSH event (in which case this function
    /// returns [`gst::FlowReturn::Flushing`][crate::gst::FlowReturn::Flushing]).
    ///
    /// # Returns
    ///
    /// [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok] if `self` is PLAYING and processing can
    /// continue. Any other return value should be returned from the create vmethod.
    #[doc(alias = "gst_base_src_wait_playing")]
    fn wait_playing(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
        unsafe {
            try_from_glib(ffi::gst_base_src_wait_playing(
                self.as_ref().to_glib_none().0,
            ))
        }
    }

    /// See [`set_automatic_eos()`][Self::set_automatic_eos()]
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    #[doc(alias = "automatic-eos")]
    fn is_automatic_eos(&self) -> bool {
        ObjectExt::property(self.as_ref(), "automatic-eos")
    }

    #[doc(alias = "num-buffers")]
    fn num_buffers(&self) -> i32 {
        ObjectExt::property(self.as_ref(), "num-buffers")
    }

    #[doc(alias = "num-buffers")]
    fn set_num_buffers(&self, num_buffers: i32) {
        ObjectExt::set_property(self.as_ref(), "num-buffers", num_buffers)
    }

    fn is_typefind(&self) -> bool {
        ObjectExt::property(self.as_ref(), "typefind")
    }

    fn set_typefind(&self, typefind: bool) {
        ObjectExt::set_property(self.as_ref(), "typefind", typefind)
    }

    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    #[doc(alias = "automatic-eos")]
    fn connect_automatic_eos_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_automatic_eos_trampoline<
            P: IsA<BaseSrc>,
            F: Fn(&P) + Send + Sync + 'static,
        >(
            this: *mut ffi::GstBaseSrc,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(BaseSrc::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::automatic-eos\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_automatic_eos_trampoline::<Self, F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

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

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

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

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

impl<O: IsA<BaseSrc>> BaseSrcExt for O {}