gstreamer_app/auto/app_src.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6#[cfg(feature = "v1_20")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
8use crate::AppLeakyType;
9use crate::{AppStreamType, ffi};
10use glib::{
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 /// The appsrc element can be used by applications to insert data into a
19 /// GStreamer pipeline. Unlike most GStreamer elements, appsrc provides
20 /// external API functions.
21 ///
22 /// appsrc can be used by linking with the libgstapp library to access the
23 /// methods directly or by using the appsrc action signals.
24 ///
25 /// Before operating appsrc, the caps property must be set to fixed caps
26 /// describing the format of the data that will be pushed with appsrc. An
27 /// exception to this is when pushing buffers with unknown caps, in which case no
28 /// caps should be set. This is typically true of file-like sources that push raw
29 /// byte buffers. If you don't want to explicitly set the caps, you can use
30 /// gst_app_src_push_sample. This method gets the caps associated with the
31 /// sample and sets them on the appsrc replacing any previously set caps (if
32 /// different from sample's caps).
33 ///
34 /// The main way of handing data to the appsrc element is by calling the
35 /// [`push_buffer()`][Self::push_buffer()] method or by emitting the push-buffer action signal.
36 /// This will put the buffer onto a queue from which appsrc will read from in its
37 /// streaming thread. It is important to note that data transport will not happen
38 /// from the thread that performed the push-buffer call.
39 ///
40 /// The "max-bytes", "max-buffers" and "max-time" properties control how much
41 /// data can be queued in appsrc before appsrc considers the queue full. A
42 /// filled internal queue will always signal the "enough-data" signal, which
43 /// signals the application that it should stop pushing data into appsrc. The
44 /// "block" property will cause appsrc to block the push-buffer method until
45 /// free data becomes available again.
46 ///
47 /// When the internal queue is running out of data, the "need-data" signal is
48 /// emitted, which signals the application that it should start pushing more data
49 /// into appsrc.
50 ///
51 /// In addition to the "need-data" and "enough-data" signals, appsrc can emit the
52 /// "seek-data" signal when the "stream-mode" property is set to "seekable" or
53 /// "random-access". The signal argument will contain the new desired position in
54 /// the stream expressed in the unit set with the "format" property. After
55 /// receiving the seek-data signal, the application should push-buffers from the
56 /// new position.
57 ///
58 /// These signals allow the application to operate the appsrc in two different
59 /// ways:
60 ///
61 /// The push mode, in which the application repeatedly calls the push-buffer/push-sample
62 /// method with a new buffer/sample. Optionally, the queue size in the appsrc
63 /// can be controlled with the enough-data and need-data signals by respectively
64 /// stopping/starting the push-buffer/push-sample calls. This is a typical
65 /// mode of operation for the stream-type "stream" and "seekable". Use this
66 /// mode when implementing various network protocols or hardware devices.
67 ///
68 /// The pull mode, in which the need-data signal triggers the next push-buffer call.
69 /// This mode is typically used in the "random-access" stream-type. Use this
70 /// mode for file access or other randomly accessible sources. In this mode, a
71 /// buffer of exactly the amount of bytes given by the need-data signal should be
72 /// pushed into appsrc.
73 ///
74 /// In all modes, the size property on appsrc should contain the total stream
75 /// size in bytes. Setting this property is mandatory in the random-access mode.
76 /// For the stream and seekable modes, setting this property is optional but
77 /// recommended.
78 ///
79 /// When the application has finished pushing data into appsrc, it should call
80 /// [`end_of_stream()`][Self::end_of_stream()] or emit the end-of-stream action signal. After
81 /// this call, no more buffers can be pushed into appsrc until a flushing seek
82 /// occurs or the state of the appsrc has gone through READY.
83 ///
84 /// ## Properties
85 ///
86 ///
87 /// #### `block`
88 /// When max-bytes are queued and after the enough-data signal has been emitted,
89 /// block any further push-buffer calls until the amount of queued bytes drops
90 /// below the max-bytes limit.
91 ///
92 /// Readable | Writeable
93 ///
94 ///
95 /// #### `caps`
96 /// The GstCaps that will negotiated downstream and will be put
97 /// on outgoing buffers.
98 ///
99 /// Readable | Writeable
100 ///
101 ///
102 /// #### `current-level-buffers`
103 /// The number of currently queued buffers inside appsrc.
104 ///
105 /// Readable
106 ///
107 ///
108 /// #### `current-level-bytes`
109 /// The number of currently queued bytes inside appsrc.
110 ///
111 /// Readable
112 ///
113 ///
114 /// #### `current-level-time`
115 /// The amount of currently queued time inside appsrc.
116 ///
117 /// Readable
118 ///
119 ///
120 /// #### `dropped`
121 /// Number of buffers that were dropped.
122 ///
123 /// Readable
124 ///
125 ///
126 /// #### `duration`
127 /// The total duration in nanoseconds of the data stream. If the total duration is known, it
128 /// is recommended to configure it with this property.
129 ///
130 /// Readable | Writeable
131 ///
132 ///
133 /// #### `emit-signals`
134 /// Make appsrc emit the "need-data", "enough-data" and "seek-data" signals.
135 /// This option is by default enabled for backwards compatibility reasons but
136 /// can disabled when needed because signal emission is expensive.
137 ///
138 /// Readable | Writeable
139 ///
140 ///
141 /// #### `format`
142 /// The format to use for segment events. When the source is producing
143 /// timestamped buffers this property should be set to GST_FORMAT_TIME.
144 ///
145 /// Readable | Writeable
146 ///
147 ///
148 /// #### `handle-segment-change`
149 /// When enabled, appsrc will check GstSegment in GstSample which was
150 /// pushed via [`AppSrc::push_sample()`][crate::AppSrc::push_sample()] or "push-sample" signal action.
151 /// If a GstSegment is changed, corresponding segment event will be followed
152 /// by next data flow.
153 ///
154 /// FIXME: currently only GST_FORMAT_TIME format is supported and therefore
155 /// GstAppSrc::format should be time. However, possibly [`AppSrc`][crate::AppSrc] can support
156 /// other formats.
157 ///
158 /// Readable | Writeable
159 ///
160 ///
161 /// #### `in`
162 /// Number of input buffers that were queued.
163 ///
164 /// Readable
165 ///
166 ///
167 /// #### `is-live`
168 /// Instruct the source to behave like a live source. This includes that it
169 /// will only push out buffers in the PLAYING state.
170 ///
171 /// Readable | Writeable
172 ///
173 ///
174 /// #### `leaky-type`
175 /// When set to any other value than GST_APP_LEAKY_TYPE_NONE then the appsrc
176 /// will drop any buffers that are pushed into it once its internal queue is
177 /// full. The selected type defines whether to drop the oldest or new
178 /// buffers.
179 ///
180 /// Readable | Writeable
181 ///
182 ///
183 /// #### `max-buffers`
184 /// The maximum amount of buffers that can be queued internally.
185 /// After the maximum amount of buffers are queued, appsrc will emit the
186 /// "enough-data" signal.
187 ///
188 /// Readable | Writeable
189 ///
190 ///
191 /// #### `max-bytes`
192 /// The maximum amount of bytes that can be queued internally.
193 /// After the maximum amount of bytes are queued, appsrc will emit the
194 /// "enough-data" signal.
195 ///
196 /// Readable | Writeable
197 ///
198 ///
199 /// #### `max-latency`
200 /// Readable | Writeable
201 ///
202 ///
203 /// #### `max-time`
204 /// The maximum amount of time that can be queued internally.
205 /// After the maximum amount of time are queued, appsrc will emit the
206 /// "enough-data" signal.
207 ///
208 /// Readable | Writeable
209 ///
210 ///
211 /// #### `min-latency`
212 /// The minimum latency of the source. A value of -1 will use the default
213 /// latency calculations of `GstBaseSrc`.
214 ///
215 /// Readable | Writeable
216 ///
217 ///
218 /// #### `min-percent`
219 /// Make appsrc emit the "need-data" signal when the amount of bytes in the
220 /// queue drops below this percentage of max-bytes.
221 ///
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `out`
226 /// Number of output buffers that were dequeued.
227 ///
228 /// Readable
229 ///
230 ///
231 /// #### `silent`
232 /// Don't emit notify for input, output and dropped buffers.
233 ///
234 /// Readable | Writeable
235 ///
236 ///
237 /// #### `size`
238 /// The total size in bytes of the data stream. If the total size is known, it
239 /// is recommended to configure it with this property.
240 ///
241 /// Readable | Writeable
242 ///
243 ///
244 /// #### `stream-type`
245 /// The type of stream that this source is producing. For seekable streams the
246 /// application should connect to the seek-data signal.
247 ///
248 /// Readable | Writeable
249 /// <details><summary><h4>BaseSrc</h4></summary>
250 ///
251 ///
252 /// #### `automatic-eos`
253 /// See `gst_base_src_set_automatic_eos()`
254 ///
255 /// Readable | Writeable
256 ///
257 ///
258 /// #### `blocksize`
259 /// Readable | Writeable
260 ///
261 ///
262 /// #### `do-timestamp`
263 /// Readable | Writeable
264 ///
265 ///
266 /// #### `num-buffers`
267 /// Readable | Writeable
268 ///
269 ///
270 /// #### `typefind`
271 /// Readable | Writeable
272 /// </details>
273 /// <details><summary><h4>Object</h4></summary>
274 ///
275 ///
276 /// #### `name`
277 /// Readable | Writeable | Construct
278 ///
279 ///
280 /// #### `parent`
281 /// The parent of the object. Please note, that when changing the 'parent'
282 /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
283 /// signals due to locking issues. In some cases one can use
284 /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
285 /// achieve a similar effect.
286 ///
287 /// Readable | Writeable
288 /// </details>
289 ///
290 /// ## Signals
291 ///
292 ///
293 /// #### `end-of-stream`
294 /// Notify `appsrc` that no more buffer are available.
295 ///
296 /// Action
297 ///
298 ///
299 /// #### `enough-data`
300 /// Signal that the source has enough data. It is recommended that the
301 /// application stops calling push-buffer until the need-data signal is
302 /// emitted again to avoid excessive buffer queueing.
303 ///
304 ///
305 ///
306 ///
307 /// #### `need-data`
308 /// Signal that the source needs more data. In the callback or from another
309 /// thread you should call push-buffer or end-of-stream.
310 ///
311 /// `length` is just a hint and when it is set to -1, any number of bytes can be
312 /// pushed into `appsrc`.
313 ///
314 /// You can call push-buffer multiple times until the enough-data signal is
315 /// fired.
316 ///
317 ///
318 ///
319 ///
320 /// #### `push-buffer`
321 /// Adds a buffer to the queue of buffers that the appsrc element will
322 /// push to its source pad.
323 ///
324 /// This function does not take ownership of the buffer, but it takes a
325 /// reference so the buffer can be unreffed at any time after calling this
326 /// function.
327 ///
328 /// When the block property is TRUE, this function can block until free space
329 /// becomes available in the queue.
330 ///
331 /// Action
332 ///
333 ///
334 /// #### `push-buffer-list`
335 /// Adds a buffer list to the queue of buffers and buffer lists that the
336 /// appsrc element will push to its source pad.
337 ///
338 /// This function does not take ownership of the buffer list, but it takes a
339 /// reference so the buffer list can be unreffed at any time after calling
340 /// this function.
341 ///
342 /// When the block property is TRUE, this function can block until free space
343 /// becomes available in the queue.
344 ///
345 /// Action
346 ///
347 ///
348 /// #### `push-sample`
349 /// Extract a buffer from the provided sample and adds the extracted buffer
350 /// to the queue of buffers that the appsrc element will
351 /// push to its source pad. This function set the appsrc caps based on the caps
352 /// in the sample and reset the caps if they change.
353 /// Only the caps and the buffer of the provided sample are used and not
354 /// for example the segment in the sample.
355 ///
356 /// This function does not take ownership of the sample, but it takes a
357 /// reference so the sample can be unreffed at any time after calling this
358 /// function.
359 ///
360 /// When the block property is TRUE, this function can block until free space
361 /// becomes available in the queue.
362 ///
363 /// Action
364 ///
365 ///
366 /// #### `seek-data`
367 /// Seek to the given offset. The next push-buffer should produce buffers from
368 /// the new `offset`.
369 /// This callback is only called for seekable stream types.
370 ///
371 ///
372 /// <details><summary><h4>Element</h4></summary>
373 ///
374 ///
375 /// #### `no-more-pads`
376 /// This signals that the element will not generate more dynamic pads.
377 /// Note that this signal will usually be emitted from the context of
378 /// the streaming thread.
379 ///
380 ///
381 ///
382 ///
383 /// #### `pad-added`
384 /// a new `GstPad` has been added to the element. Note that this signal will
385 /// usually be emitted from the context of the streaming thread. Also keep in
386 /// mind that if you add new elements to the pipeline in the signal handler
387 /// you will need to set them to the desired target state with
388 /// [`ElementExtManual::set_state()`][crate::gst::prelude::ElementExtManual::set_state()] or [`ElementExtManual::sync_state_with_parent()`][crate::gst::prelude::ElementExtManual::sync_state_with_parent()].
389 ///
390 ///
391 ///
392 ///
393 /// #### `pad-removed`
394 /// a `GstPad` has been removed from the element
395 ///
396 ///
397 /// </details>
398 /// <details><summary><h4>Object</h4></summary>
399 ///
400 ///
401 /// #### `deep-notify`
402 /// The deep notify signal is used to be notified of property changes. It is
403 /// typically attached to the toplevel bin to receive notifications from all
404 /// the elements contained in that bin.
405 ///
406 /// Detailed
407 /// </details>
408 ///
409 /// # Implements
410 ///
411 /// [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`trait@gst::prelude::URIHandlerExt`]
412 #[doc(alias = "GstAppSrc")]
413 pub struct AppSrc(Object<ffi::GstAppSrc, ffi::GstAppSrcClass>) @extends gst::Element, gst::Object, @implements gst::URIHandler;
414
415 match fn {
416 type_ => || ffi::gst_app_src_get_type(),
417 }
418}
419
420impl AppSrc {
421 /// Indicates to the appsrc element that the last buffer queued in the
422 /// element is the last buffer of the stream.
423 ///
424 /// # Returns
425 ///
426 /// [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok] when the EOS was successfully queued.
427 /// [`gst::FlowReturn::Flushing`][crate::gst::FlowReturn::Flushing] when `self` is not PAUSED or PLAYING.
428 #[doc(alias = "gst_app_src_end_of_stream")]
429 pub fn end_of_stream(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
430 unsafe { try_from_glib(ffi::gst_app_src_end_of_stream(self.to_glib_none().0)) }
431 }
432
433 /// Get the configured caps on `self`.
434 ///
435 /// # Returns
436 ///
437 /// the [`gst::Caps`][crate::gst::Caps] produced by the source. `gst_caps_unref()` after usage.
438 #[doc(alias = "gst_app_src_get_caps")]
439 #[doc(alias = "get_caps")]
440 pub fn caps(&self) -> Option<gst::Caps> {
441 unsafe { from_glib_full(ffi::gst_app_src_get_caps(self.to_glib_none().0)) }
442 }
443
444 /// Get the number of currently queued buffers inside `self`.
445 ///
446 /// # Returns
447 ///
448 /// The number of currently queued buffers.
449 #[cfg(feature = "v1_20")]
450 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
451 #[doc(alias = "gst_app_src_get_current_level_buffers")]
452 #[doc(alias = "get_current_level_buffers")]
453 #[doc(alias = "current-level-buffers")]
454 pub fn current_level_buffers(&self) -> u64 {
455 unsafe { ffi::gst_app_src_get_current_level_buffers(self.to_glib_none().0) }
456 }
457
458 /// Get the number of currently queued bytes inside `self`.
459 ///
460 /// # Returns
461 ///
462 /// The number of currently queued bytes.
463 #[doc(alias = "gst_app_src_get_current_level_bytes")]
464 #[doc(alias = "get_current_level_bytes")]
465 #[doc(alias = "current-level-bytes")]
466 pub fn current_level_bytes(&self) -> u64 {
467 unsafe { ffi::gst_app_src_get_current_level_bytes(self.to_glib_none().0) }
468 }
469
470 /// Get the amount of currently queued time inside `self`.
471 ///
472 /// # Returns
473 ///
474 /// The amount of currently queued time.
475 #[cfg(feature = "v1_20")]
476 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
477 #[doc(alias = "gst_app_src_get_current_level_time")]
478 #[doc(alias = "get_current_level_time")]
479 #[doc(alias = "current-level-time")]
480 pub fn current_level_time(&self) -> gst::ClockTime {
481 unsafe {
482 try_from_glib(ffi::gst_app_src_get_current_level_time(
483 self.to_glib_none().0,
484 ))
485 .expect("mandatory glib value is None")
486 }
487 }
488
489 /// Get the duration of the stream in nanoseconds. A value of GST_CLOCK_TIME_NONE means that the duration is
490 /// not known.
491 ///
492 /// # Returns
493 ///
494 /// the duration of the stream previously set with [`set_duration()`][Self::set_duration()];
495 #[doc(alias = "gst_app_src_get_duration")]
496 #[doc(alias = "get_duration")]
497 pub fn duration(&self) -> Option<gst::ClockTime> {
498 unsafe { from_glib(ffi::gst_app_src_get_duration(self.to_glib_none().0)) }
499 }
500
501 /// Returns the currently set [`AppLeakyType`][crate::AppLeakyType]. See [`set_leaky_type()`][Self::set_leaky_type()]
502 /// for more details.
503 ///
504 /// # Returns
505 ///
506 /// The currently set [`AppLeakyType`][crate::AppLeakyType].
507 #[cfg(feature = "v1_20")]
508 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
509 #[doc(alias = "gst_app_src_get_leaky_type")]
510 #[doc(alias = "get_leaky_type")]
511 #[doc(alias = "leaky-type")]
512 pub fn leaky_type(&self) -> AppLeakyType {
513 unsafe { from_glib(ffi::gst_app_src_get_leaky_type(self.to_glib_none().0)) }
514 }
515
516 /// Get the maximum amount of buffers that can be queued in `self`.
517 ///
518 /// # Returns
519 ///
520 /// The maximum amount of buffers that can be queued.
521 #[cfg(feature = "v1_20")]
522 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
523 #[doc(alias = "gst_app_src_get_max_buffers")]
524 #[doc(alias = "get_max_buffers")]
525 #[doc(alias = "max-buffers")]
526 pub fn max_buffers(&self) -> u64 {
527 unsafe { ffi::gst_app_src_get_max_buffers(self.to_glib_none().0) }
528 }
529
530 /// Get the maximum amount of bytes that can be queued in `self`.
531 ///
532 /// # Returns
533 ///
534 /// The maximum amount of bytes that can be queued.
535 #[doc(alias = "gst_app_src_get_max_bytes")]
536 #[doc(alias = "get_max_bytes")]
537 #[doc(alias = "max-bytes")]
538 pub fn max_bytes(&self) -> u64 {
539 unsafe { ffi::gst_app_src_get_max_bytes(self.to_glib_none().0) }
540 }
541
542 /// Get the maximum amount of time that can be queued in `self`.
543 ///
544 /// # Returns
545 ///
546 /// The maximum amount of time that can be queued.
547 #[cfg(feature = "v1_20")]
548 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
549 #[doc(alias = "gst_app_src_get_max_time")]
550 #[doc(alias = "get_max_time")]
551 #[doc(alias = "max-time")]
552 pub fn max_time(&self) -> gst::ClockTime {
553 unsafe {
554 try_from_glib(ffi::gst_app_src_get_max_time(self.to_glib_none().0))
555 .expect("mandatory glib value is None")
556 }
557 }
558
559 /// Get the size of the stream in bytes. A value of -1 means that the size is
560 /// not known.
561 ///
562 /// # Returns
563 ///
564 /// the size of the stream previously set with [`set_size()`][Self::set_size()];
565 #[doc(alias = "gst_app_src_get_size")]
566 #[doc(alias = "get_size")]
567 pub fn size(&self) -> i64 {
568 unsafe { ffi::gst_app_src_get_size(self.to_glib_none().0) }
569 }
570
571 /// Get the stream type. Control the stream type of `self`
572 /// with [`set_stream_type()`][Self::set_stream_type()].
573 ///
574 /// # Returns
575 ///
576 /// the stream type.
577 #[doc(alias = "gst_app_src_get_stream_type")]
578 #[doc(alias = "get_stream_type")]
579 #[doc(alias = "stream-type")]
580 pub fn stream_type(&self) -> AppStreamType {
581 unsafe { from_glib(ffi::gst_app_src_get_stream_type(self.to_glib_none().0)) }
582 }
583
584 /// Adds a buffer to the queue of buffers that the appsrc element will
585 /// push to its source pad. This function takes ownership of the buffer.
586 ///
587 /// When the block property is TRUE, this function can block until free
588 /// space becomes available in the queue.
589 /// ## `buffer`
590 /// a [`gst::Buffer`][crate::gst::Buffer] to push
591 ///
592 /// # Returns
593 ///
594 /// [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok] when the buffer was successfully queued.
595 /// [`gst::FlowReturn::Flushing`][crate::gst::FlowReturn::Flushing] when `self` is not PAUSED or PLAYING.
596 /// [`gst::FlowReturn::Eos`][crate::gst::FlowReturn::Eos] when EOS occurred.
597 #[doc(alias = "gst_app_src_push_buffer")]
598 pub fn push_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
599 unsafe {
600 try_from_glib(ffi::gst_app_src_push_buffer(
601 self.to_glib_none().0,
602 buffer.into_glib_ptr(),
603 ))
604 }
605 }
606
607 /// Adds a buffer list to the queue of buffers and buffer lists that the
608 /// appsrc element will push to its source pad. This function takes ownership
609 /// of `buffer_list`.
610 ///
611 /// When the block property is TRUE, this function can block until free
612 /// space becomes available in the queue.
613 /// ## `buffer_list`
614 /// a [`gst::BufferList`][crate::gst::BufferList] to push
615 ///
616 /// # Returns
617 ///
618 /// [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok] when the buffer list was successfully queued.
619 /// [`gst::FlowReturn::Flushing`][crate::gst::FlowReturn::Flushing] when `self` is not PAUSED or PLAYING.
620 /// [`gst::FlowReturn::Eos`][crate::gst::FlowReturn::Eos] when EOS occurred.
621 #[doc(alias = "gst_app_src_push_buffer_list")]
622 pub fn push_buffer_list(
623 &self,
624 buffer_list: gst::BufferList,
625 ) -> Result<gst::FlowSuccess, gst::FlowError> {
626 unsafe {
627 try_from_glib(ffi::gst_app_src_push_buffer_list(
628 self.to_glib_none().0,
629 buffer_list.into_glib_ptr(),
630 ))
631 }
632 }
633
634 /// Extract a buffer from the provided sample and adds it to the queue of
635 /// buffers that the appsrc element will push to its source pad. Any
636 /// previous caps that were set on appsrc will be replaced by the caps
637 /// associated with the sample if not equal.
638 ///
639 /// This function does not take ownership of the
640 /// sample so the sample needs to be unreffed after calling this function.
641 ///
642 /// When the block property is TRUE, this function can block until free
643 /// space becomes available in the queue.
644 /// ## `sample`
645 /// a [`gst::Sample`][crate::gst::Sample] from which buffer and caps may be
646 /// extracted
647 ///
648 /// # Returns
649 ///
650 /// [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok] when the buffer was successfully queued.
651 /// [`gst::FlowReturn::Flushing`][crate::gst::FlowReturn::Flushing] when `self` is not PAUSED or PLAYING.
652 /// [`gst::FlowReturn::Eos`][crate::gst::FlowReturn::Eos] when EOS occurred.
653 #[doc(alias = "gst_app_src_push_sample")]
654 pub fn push_sample(&self, sample: &gst::Sample) -> Result<gst::FlowSuccess, gst::FlowError> {
655 unsafe {
656 try_from_glib(ffi::gst_app_src_push_sample(
657 self.to_glib_none().0,
658 sample.to_glib_none().0,
659 ))
660 }
661 }
662
663 //#[doc(alias = "gst_app_src_set_callbacks")]
664 //pub fn set_callbacks(&self, callbacks: /*Ignored*/&mut AppSrcCallbacks, user_data: /*Unimplemented*/Option<Basic: Pointer>) {
665 // unsafe { TODO: call ffi:gst_app_src_set_callbacks() }
666 //}
667
668 /// Set the capabilities on the appsrc element. This function takes
669 /// a copy of the caps structure. After calling this method, the source will
670 /// only produce caps that match `caps`. `caps` must be fixed and the caps on the
671 /// buffers must match the caps or left NULL.
672 /// ## `caps`
673 /// caps to set
674 #[doc(alias = "gst_app_src_set_caps")]
675 #[doc(alias = "caps")]
676 pub fn set_caps(&self, caps: Option<&gst::Caps>) {
677 unsafe {
678 ffi::gst_app_src_set_caps(self.to_glib_none().0, caps.to_glib_none().0);
679 }
680 }
681
682 /// Set the duration of the stream in nanoseconds. A value of GST_CLOCK_TIME_NONE means that the duration is
683 /// not known.
684 /// ## `duration`
685 /// the duration to set
686 #[doc(alias = "gst_app_src_set_duration")]
687 #[doc(alias = "duration")]
688 pub fn set_duration(&self, duration: impl Into<Option<gst::ClockTime>>) {
689 unsafe {
690 ffi::gst_app_src_set_duration(self.to_glib_none().0, duration.into().into_glib());
691 }
692 }
693
694 /// When set to any other value than GST_APP_LEAKY_TYPE_NONE then the appsrc
695 /// will drop any buffers that are pushed into it once its internal queue is
696 /// full. The selected type defines whether to drop the oldest or new
697 /// buffers.
698 /// ## `leaky`
699 /// the [`AppLeakyType`][crate::AppLeakyType]
700 #[cfg(feature = "v1_20")]
701 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
702 #[doc(alias = "gst_app_src_set_leaky_type")]
703 #[doc(alias = "leaky-type")]
704 pub fn set_leaky_type(&self, leaky: AppLeakyType) {
705 unsafe {
706 ffi::gst_app_src_set_leaky_type(self.to_glib_none().0, leaky.into_glib());
707 }
708 }
709
710 /// Set the maximum amount of buffers that can be queued in `self`.
711 /// After the maximum amount of buffers are queued, `self` will emit the
712 /// "enough-data" signal.
713 /// ## `max`
714 /// the maximum number of buffers to queue
715 #[cfg(feature = "v1_20")]
716 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
717 #[doc(alias = "gst_app_src_set_max_buffers")]
718 #[doc(alias = "max-buffers")]
719 pub fn set_max_buffers(&self, max: u64) {
720 unsafe {
721 ffi::gst_app_src_set_max_buffers(self.to_glib_none().0, max);
722 }
723 }
724
725 /// Set the maximum amount of bytes that can be queued in `self`.
726 /// After the maximum amount of bytes are queued, `self` will emit the
727 /// "enough-data" signal.
728 /// ## `max`
729 /// the maximum number of bytes to queue
730 #[doc(alias = "gst_app_src_set_max_bytes")]
731 #[doc(alias = "max-bytes")]
732 pub fn set_max_bytes(&self, max: u64) {
733 unsafe {
734 ffi::gst_app_src_set_max_bytes(self.to_glib_none().0, max);
735 }
736 }
737
738 /// Set the maximum amount of time that can be queued in `self`.
739 /// After the maximum amount of time are queued, `self` will emit the
740 /// "enough-data" signal.
741 /// ## `max`
742 /// the maximum amonut of time to queue
743 #[cfg(feature = "v1_20")]
744 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
745 #[doc(alias = "gst_app_src_set_max_time")]
746 #[doc(alias = "max-time")]
747 pub fn set_max_time(&self, max: gst::ClockTime) {
748 unsafe {
749 ffi::gst_app_src_set_max_time(self.to_glib_none().0, max.into_glib());
750 }
751 }
752
753 //#[cfg(feature = "v1_28")]
754 //#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
755 //#[doc(alias = "gst_app_src_set_simple_callbacks")]
756 //pub fn set_simple_callbacks(&self, cb: /*Ignored*/Option<AppSrcSimpleCallbacks>) {
757 // unsafe { TODO: call ffi:gst_app_src_set_simple_callbacks() }
758 //}
759
760 /// Set the size of the stream in bytes. A value of -1 means that the size is
761 /// not known.
762 /// ## `size`
763 /// the size to set
764 #[doc(alias = "gst_app_src_set_size")]
765 #[doc(alias = "size")]
766 pub fn set_size(&self, size: i64) {
767 unsafe {
768 ffi::gst_app_src_set_size(self.to_glib_none().0, size);
769 }
770 }
771
772 /// Set the stream type on `self`. For seekable streams, the "seek" signal must
773 /// be connected to.
774 ///
775 /// A stream_type stream
776 /// ## `type_`
777 /// the new state
778 #[doc(alias = "gst_app_src_set_stream_type")]
779 #[doc(alias = "stream-type")]
780 pub fn set_stream_type(&self, type_: AppStreamType) {
781 unsafe {
782 ffi::gst_app_src_set_stream_type(self.to_glib_none().0, type_.into_glib());
783 }
784 }
785
786 /// When max-bytes are queued and after the enough-data signal has been emitted,
787 /// block any further push-buffer calls until the amount of queued bytes drops
788 /// below the max-bytes limit.
789 pub fn is_block(&self) -> bool {
790 ObjectExt::property(self, "block")
791 }
792
793 /// When max-bytes are queued and after the enough-data signal has been emitted,
794 /// block any further push-buffer calls until the amount of queued bytes drops
795 /// below the max-bytes limit.
796 pub fn set_block(&self, block: bool) {
797 ObjectExt::set_property(self, "block", block)
798 }
799
800 /// Number of buffers that were dropped.
801 #[cfg(feature = "v1_28")]
802 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
803 pub fn dropped(&self) -> u64 {
804 ObjectExt::property(self, "dropped")
805 }
806
807 /// The format to use for segment events. When the source is producing
808 /// timestamped buffers this property should be set to GST_FORMAT_TIME.
809 pub fn format(&self) -> gst::Format {
810 ObjectExt::property(self, "format")
811 }
812
813 /// The format to use for segment events. When the source is producing
814 /// timestamped buffers this property should be set to GST_FORMAT_TIME.
815 pub fn set_format(&self, format: gst::Format) {
816 ObjectExt::set_property(self, "format", format)
817 }
818
819 /// When enabled, appsrc will check GstSegment in GstSample which was
820 /// pushed via [`push_sample()`][Self::push_sample()] or "push-sample" signal action.
821 /// If a GstSegment is changed, corresponding segment event will be followed
822 /// by next data flow.
823 ///
824 /// FIXME: currently only GST_FORMAT_TIME format is supported and therefore
825 /// GstAppSrc::format should be time. However, possibly [`AppSrc`][crate::AppSrc] can support
826 /// other formats.
827 #[cfg(feature = "v1_18")]
828 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
829 #[doc(alias = "handle-segment-change")]
830 pub fn is_handle_segment_change(&self) -> bool {
831 ObjectExt::property(self, "handle-segment-change")
832 }
833
834 /// When enabled, appsrc will check GstSegment in GstSample which was
835 /// pushed via [`push_sample()`][Self::push_sample()] or "push-sample" signal action.
836 /// If a GstSegment is changed, corresponding segment event will be followed
837 /// by next data flow.
838 ///
839 /// FIXME: currently only GST_FORMAT_TIME format is supported and therefore
840 /// GstAppSrc::format should be time. However, possibly [`AppSrc`][crate::AppSrc] can support
841 /// other formats.
842 #[cfg(feature = "v1_18")]
843 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
844 #[doc(alias = "handle-segment-change")]
845 pub fn set_handle_segment_change(&self, handle_segment_change: bool) {
846 ObjectExt::set_property(self, "handle-segment-change", handle_segment_change)
847 }
848
849 /// Number of input buffers that were queued.
850 #[cfg(feature = "v1_28")]
851 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
852 #[doc(alias = "in")]
853 pub fn get_in(&self) -> u64 {
854 ObjectExt::property(self, "in")
855 }
856
857 /// Instruct the source to behave like a live source. This includes that it
858 /// will only push out buffers in the PLAYING state.
859 #[doc(alias = "is-live")]
860 pub fn is_live(&self) -> bool {
861 ObjectExt::property(self, "is-live")
862 }
863
864 /// Instruct the source to behave like a live source. This includes that it
865 /// will only push out buffers in the PLAYING state.
866 #[doc(alias = "is-live")]
867 pub fn set_is_live(&self, is_live: bool) {
868 ObjectExt::set_property(self, "is-live", is_live)
869 }
870
871 #[doc(alias = "max-latency")]
872 pub fn max_latency(&self) -> i64 {
873 ObjectExt::property(self, "max-latency")
874 }
875
876 #[doc(alias = "max-latency")]
877 pub fn set_max_latency(&self, max_latency: i64) {
878 ObjectExt::set_property(self, "max-latency", max_latency)
879 }
880
881 /// The minimum latency of the source. A value of -1 will use the default
882 /// latency calculations of `GstBaseSrc`.
883 #[doc(alias = "min-latency")]
884 pub fn min_latency(&self) -> i64 {
885 ObjectExt::property(self, "min-latency")
886 }
887
888 /// The minimum latency of the source. A value of -1 will use the default
889 /// latency calculations of `GstBaseSrc`.
890 #[doc(alias = "min-latency")]
891 pub fn set_min_latency(&self, min_latency: i64) {
892 ObjectExt::set_property(self, "min-latency", min_latency)
893 }
894
895 /// Make appsrc emit the "need-data" signal when the amount of bytes in the
896 /// queue drops below this percentage of max-bytes.
897 #[doc(alias = "min-percent")]
898 pub fn min_percent(&self) -> u32 {
899 ObjectExt::property(self, "min-percent")
900 }
901
902 /// Make appsrc emit the "need-data" signal when the amount of bytes in the
903 /// queue drops below this percentage of max-bytes.
904 #[doc(alias = "min-percent")]
905 pub fn set_min_percent(&self, min_percent: u32) {
906 ObjectExt::set_property(self, "min-percent", min_percent)
907 }
908
909 /// Number of output buffers that were dequeued.
910 #[cfg(feature = "v1_28")]
911 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
912 pub fn out(&self) -> u64 {
913 ObjectExt::property(self, "out")
914 }
915
916 /// Don't emit notify for input, output and dropped buffers.
917 #[cfg(feature = "v1_28")]
918 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
919 pub fn is_silent(&self) -> bool {
920 ObjectExt::property(self, "silent")
921 }
922
923 /// Don't emit notify for input, output and dropped buffers.
924 #[cfg(feature = "v1_28")]
925 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
926 pub fn set_silent(&self, silent: bool) {
927 ObjectExt::set_property(self, "silent", silent)
928 }
929
930 #[doc(alias = "block")]
931 pub fn connect_block_notify<F: Fn(&Self) + Send + Sync + 'static>(
932 &self,
933 f: F,
934 ) -> SignalHandlerId {
935 unsafe extern "C" fn notify_block_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
936 this: *mut ffi::GstAppSrc,
937 _param_spec: glib::ffi::gpointer,
938 f: glib::ffi::gpointer,
939 ) {
940 unsafe {
941 let f: &F = &*(f as *const F);
942 f(&from_glib_borrow(this))
943 }
944 }
945 unsafe {
946 let f: Box_<F> = Box_::new(f);
947 connect_raw(
948 self.as_ptr() as *mut _,
949 c"notify::block".as_ptr(),
950 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
951 notify_block_trampoline::<F> as *const (),
952 )),
953 Box_::into_raw(f),
954 )
955 }
956 }
957
958 #[doc(alias = "caps")]
959 pub fn connect_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(
960 &self,
961 f: F,
962 ) -> SignalHandlerId {
963 unsafe extern "C" fn notify_caps_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
964 this: *mut ffi::GstAppSrc,
965 _param_spec: glib::ffi::gpointer,
966 f: glib::ffi::gpointer,
967 ) {
968 unsafe {
969 let f: &F = &*(f as *const F);
970 f(&from_glib_borrow(this))
971 }
972 }
973 unsafe {
974 let f: Box_<F> = Box_::new(f);
975 connect_raw(
976 self.as_ptr() as *mut _,
977 c"notify::caps".as_ptr(),
978 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
979 notify_caps_trampoline::<F> as *const (),
980 )),
981 Box_::into_raw(f),
982 )
983 }
984 }
985
986 #[cfg(feature = "v1_20")]
987 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
988 #[doc(alias = "current-level-buffers")]
989 pub fn connect_current_level_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
990 &self,
991 f: F,
992 ) -> SignalHandlerId {
993 unsafe extern "C" fn notify_current_level_buffers_trampoline<
994 F: Fn(&AppSrc) + Send + Sync + 'static,
995 >(
996 this: *mut ffi::GstAppSrc,
997 _param_spec: glib::ffi::gpointer,
998 f: glib::ffi::gpointer,
999 ) {
1000 unsafe {
1001 let f: &F = &*(f as *const F);
1002 f(&from_glib_borrow(this))
1003 }
1004 }
1005 unsafe {
1006 let f: Box_<F> = Box_::new(f);
1007 connect_raw(
1008 self.as_ptr() as *mut _,
1009 c"notify::current-level-buffers".as_ptr(),
1010 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1011 notify_current_level_buffers_trampoline::<F> as *const (),
1012 )),
1013 Box_::into_raw(f),
1014 )
1015 }
1016 }
1017
1018 #[doc(alias = "current-level-bytes")]
1019 pub fn connect_current_level_bytes_notify<F: Fn(&Self) + Send + Sync + 'static>(
1020 &self,
1021 f: F,
1022 ) -> SignalHandlerId {
1023 unsafe extern "C" fn notify_current_level_bytes_trampoline<
1024 F: Fn(&AppSrc) + Send + Sync + 'static,
1025 >(
1026 this: *mut ffi::GstAppSrc,
1027 _param_spec: glib::ffi::gpointer,
1028 f: glib::ffi::gpointer,
1029 ) {
1030 unsafe {
1031 let f: &F = &*(f as *const F);
1032 f(&from_glib_borrow(this))
1033 }
1034 }
1035 unsafe {
1036 let f: Box_<F> = Box_::new(f);
1037 connect_raw(
1038 self.as_ptr() as *mut _,
1039 c"notify::current-level-bytes".as_ptr(),
1040 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1041 notify_current_level_bytes_trampoline::<F> as *const (),
1042 )),
1043 Box_::into_raw(f),
1044 )
1045 }
1046 }
1047
1048 #[cfg(feature = "v1_20")]
1049 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
1050 #[doc(alias = "current-level-time")]
1051 pub fn connect_current_level_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
1052 &self,
1053 f: F,
1054 ) -> SignalHandlerId {
1055 unsafe extern "C" fn notify_current_level_time_trampoline<
1056 F: Fn(&AppSrc) + Send + Sync + 'static,
1057 >(
1058 this: *mut ffi::GstAppSrc,
1059 _param_spec: glib::ffi::gpointer,
1060 f: glib::ffi::gpointer,
1061 ) {
1062 unsafe {
1063 let f: &F = &*(f as *const F);
1064 f(&from_glib_borrow(this))
1065 }
1066 }
1067 unsafe {
1068 let f: Box_<F> = Box_::new(f);
1069 connect_raw(
1070 self.as_ptr() as *mut _,
1071 c"notify::current-level-time".as_ptr(),
1072 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1073 notify_current_level_time_trampoline::<F> as *const (),
1074 )),
1075 Box_::into_raw(f),
1076 )
1077 }
1078 }
1079
1080 #[cfg(feature = "v1_28")]
1081 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
1082 #[doc(alias = "dropped")]
1083 pub fn connect_dropped_notify<F: Fn(&Self) + Send + Sync + 'static>(
1084 &self,
1085 f: F,
1086 ) -> SignalHandlerId {
1087 unsafe extern "C" fn notify_dropped_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1088 this: *mut ffi::GstAppSrc,
1089 _param_spec: glib::ffi::gpointer,
1090 f: glib::ffi::gpointer,
1091 ) {
1092 unsafe {
1093 let f: &F = &*(f as *const F);
1094 f(&from_glib_borrow(this))
1095 }
1096 }
1097 unsafe {
1098 let f: Box_<F> = Box_::new(f);
1099 connect_raw(
1100 self.as_ptr() as *mut _,
1101 c"notify::dropped".as_ptr(),
1102 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1103 notify_dropped_trampoline::<F> as *const (),
1104 )),
1105 Box_::into_raw(f),
1106 )
1107 }
1108 }
1109
1110 #[doc(alias = "duration")]
1111 pub fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
1112 &self,
1113 f: F,
1114 ) -> SignalHandlerId {
1115 unsafe extern "C" fn notify_duration_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1116 this: *mut ffi::GstAppSrc,
1117 _param_spec: glib::ffi::gpointer,
1118 f: glib::ffi::gpointer,
1119 ) {
1120 unsafe {
1121 let f: &F = &*(f as *const F);
1122 f(&from_glib_borrow(this))
1123 }
1124 }
1125 unsafe {
1126 let f: Box_<F> = Box_::new(f);
1127 connect_raw(
1128 self.as_ptr() as *mut _,
1129 c"notify::duration".as_ptr(),
1130 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1131 notify_duration_trampoline::<F> as *const (),
1132 )),
1133 Box_::into_raw(f),
1134 )
1135 }
1136 }
1137
1138 #[doc(alias = "format")]
1139 pub fn connect_format_notify<F: Fn(&Self) + Send + Sync + 'static>(
1140 &self,
1141 f: F,
1142 ) -> SignalHandlerId {
1143 unsafe extern "C" fn notify_format_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1144 this: *mut ffi::GstAppSrc,
1145 _param_spec: glib::ffi::gpointer,
1146 f: glib::ffi::gpointer,
1147 ) {
1148 unsafe {
1149 let f: &F = &*(f as *const F);
1150 f(&from_glib_borrow(this))
1151 }
1152 }
1153 unsafe {
1154 let f: Box_<F> = Box_::new(f);
1155 connect_raw(
1156 self.as_ptr() as *mut _,
1157 c"notify::format".as_ptr(),
1158 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1159 notify_format_trampoline::<F> as *const (),
1160 )),
1161 Box_::into_raw(f),
1162 )
1163 }
1164 }
1165
1166 #[cfg(feature = "v1_18")]
1167 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1168 #[doc(alias = "handle-segment-change")]
1169 pub fn connect_handle_segment_change_notify<F: Fn(&Self) + Send + Sync + 'static>(
1170 &self,
1171 f: F,
1172 ) -> SignalHandlerId {
1173 unsafe extern "C" fn notify_handle_segment_change_trampoline<
1174 F: Fn(&AppSrc) + Send + Sync + 'static,
1175 >(
1176 this: *mut ffi::GstAppSrc,
1177 _param_spec: glib::ffi::gpointer,
1178 f: glib::ffi::gpointer,
1179 ) {
1180 unsafe {
1181 let f: &F = &*(f as *const F);
1182 f(&from_glib_borrow(this))
1183 }
1184 }
1185 unsafe {
1186 let f: Box_<F> = Box_::new(f);
1187 connect_raw(
1188 self.as_ptr() as *mut _,
1189 c"notify::handle-segment-change".as_ptr(),
1190 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1191 notify_handle_segment_change_trampoline::<F> as *const (),
1192 )),
1193 Box_::into_raw(f),
1194 )
1195 }
1196 }
1197
1198 #[cfg(feature = "v1_28")]
1199 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
1200 #[doc(alias = "in")]
1201 pub fn connect_in_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1202 unsafe extern "C" fn notify_in_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1203 this: *mut ffi::GstAppSrc,
1204 _param_spec: glib::ffi::gpointer,
1205 f: glib::ffi::gpointer,
1206 ) {
1207 unsafe {
1208 let f: &F = &*(f as *const F);
1209 f(&from_glib_borrow(this))
1210 }
1211 }
1212 unsafe {
1213 let f: Box_<F> = Box_::new(f);
1214 connect_raw(
1215 self.as_ptr() as *mut _,
1216 c"notify::in".as_ptr(),
1217 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1218 notify_in_trampoline::<F> as *const (),
1219 )),
1220 Box_::into_raw(f),
1221 )
1222 }
1223 }
1224
1225 #[doc(alias = "is-live")]
1226 pub fn connect_is_live_notify<F: Fn(&Self) + Send + Sync + 'static>(
1227 &self,
1228 f: F,
1229 ) -> SignalHandlerId {
1230 unsafe extern "C" fn notify_is_live_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1231 this: *mut ffi::GstAppSrc,
1232 _param_spec: glib::ffi::gpointer,
1233 f: glib::ffi::gpointer,
1234 ) {
1235 unsafe {
1236 let f: &F = &*(f as *const F);
1237 f(&from_glib_borrow(this))
1238 }
1239 }
1240 unsafe {
1241 let f: Box_<F> = Box_::new(f);
1242 connect_raw(
1243 self.as_ptr() as *mut _,
1244 c"notify::is-live".as_ptr(),
1245 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1246 notify_is_live_trampoline::<F> as *const (),
1247 )),
1248 Box_::into_raw(f),
1249 )
1250 }
1251 }
1252
1253 #[cfg(feature = "v1_20")]
1254 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
1255 #[doc(alias = "leaky-type")]
1256 pub fn connect_leaky_type_notify<F: Fn(&Self) + Send + Sync + 'static>(
1257 &self,
1258 f: F,
1259 ) -> SignalHandlerId {
1260 unsafe extern "C" fn notify_leaky_type_trampoline<
1261 F: Fn(&AppSrc) + Send + Sync + 'static,
1262 >(
1263 this: *mut ffi::GstAppSrc,
1264 _param_spec: glib::ffi::gpointer,
1265 f: glib::ffi::gpointer,
1266 ) {
1267 unsafe {
1268 let f: &F = &*(f as *const F);
1269 f(&from_glib_borrow(this))
1270 }
1271 }
1272 unsafe {
1273 let f: Box_<F> = Box_::new(f);
1274 connect_raw(
1275 self.as_ptr() as *mut _,
1276 c"notify::leaky-type".as_ptr(),
1277 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1278 notify_leaky_type_trampoline::<F> as *const (),
1279 )),
1280 Box_::into_raw(f),
1281 )
1282 }
1283 }
1284
1285 #[cfg(feature = "v1_20")]
1286 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
1287 #[doc(alias = "max-buffers")]
1288 pub fn connect_max_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
1289 &self,
1290 f: F,
1291 ) -> SignalHandlerId {
1292 unsafe extern "C" fn notify_max_buffers_trampoline<
1293 F: Fn(&AppSrc) + Send + Sync + 'static,
1294 >(
1295 this: *mut ffi::GstAppSrc,
1296 _param_spec: glib::ffi::gpointer,
1297 f: glib::ffi::gpointer,
1298 ) {
1299 unsafe {
1300 let f: &F = &*(f as *const F);
1301 f(&from_glib_borrow(this))
1302 }
1303 }
1304 unsafe {
1305 let f: Box_<F> = Box_::new(f);
1306 connect_raw(
1307 self.as_ptr() as *mut _,
1308 c"notify::max-buffers".as_ptr(),
1309 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1310 notify_max_buffers_trampoline::<F> as *const (),
1311 )),
1312 Box_::into_raw(f),
1313 )
1314 }
1315 }
1316
1317 #[doc(alias = "max-bytes")]
1318 pub fn connect_max_bytes_notify<F: Fn(&Self) + Send + Sync + 'static>(
1319 &self,
1320 f: F,
1321 ) -> SignalHandlerId {
1322 unsafe extern "C" fn notify_max_bytes_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1323 this: *mut ffi::GstAppSrc,
1324 _param_spec: glib::ffi::gpointer,
1325 f: glib::ffi::gpointer,
1326 ) {
1327 unsafe {
1328 let f: &F = &*(f as *const F);
1329 f(&from_glib_borrow(this))
1330 }
1331 }
1332 unsafe {
1333 let f: Box_<F> = Box_::new(f);
1334 connect_raw(
1335 self.as_ptr() as *mut _,
1336 c"notify::max-bytes".as_ptr(),
1337 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1338 notify_max_bytes_trampoline::<F> as *const (),
1339 )),
1340 Box_::into_raw(f),
1341 )
1342 }
1343 }
1344
1345 #[doc(alias = "max-latency")]
1346 pub fn connect_max_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
1347 &self,
1348 f: F,
1349 ) -> SignalHandlerId {
1350 unsafe extern "C" fn notify_max_latency_trampoline<
1351 F: Fn(&AppSrc) + Send + Sync + 'static,
1352 >(
1353 this: *mut ffi::GstAppSrc,
1354 _param_spec: glib::ffi::gpointer,
1355 f: glib::ffi::gpointer,
1356 ) {
1357 unsafe {
1358 let f: &F = &*(f as *const F);
1359 f(&from_glib_borrow(this))
1360 }
1361 }
1362 unsafe {
1363 let f: Box_<F> = Box_::new(f);
1364 connect_raw(
1365 self.as_ptr() as *mut _,
1366 c"notify::max-latency".as_ptr(),
1367 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1368 notify_max_latency_trampoline::<F> as *const (),
1369 )),
1370 Box_::into_raw(f),
1371 )
1372 }
1373 }
1374
1375 #[cfg(feature = "v1_20")]
1376 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
1377 #[doc(alias = "max-time")]
1378 pub fn connect_max_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
1379 &self,
1380 f: F,
1381 ) -> SignalHandlerId {
1382 unsafe extern "C" fn notify_max_time_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1383 this: *mut ffi::GstAppSrc,
1384 _param_spec: glib::ffi::gpointer,
1385 f: glib::ffi::gpointer,
1386 ) {
1387 unsafe {
1388 let f: &F = &*(f as *const F);
1389 f(&from_glib_borrow(this))
1390 }
1391 }
1392 unsafe {
1393 let f: Box_<F> = Box_::new(f);
1394 connect_raw(
1395 self.as_ptr() as *mut _,
1396 c"notify::max-time".as_ptr(),
1397 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1398 notify_max_time_trampoline::<F> as *const (),
1399 )),
1400 Box_::into_raw(f),
1401 )
1402 }
1403 }
1404
1405 #[doc(alias = "min-latency")]
1406 pub fn connect_min_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
1407 &self,
1408 f: F,
1409 ) -> SignalHandlerId {
1410 unsafe extern "C" fn notify_min_latency_trampoline<
1411 F: Fn(&AppSrc) + Send + Sync + 'static,
1412 >(
1413 this: *mut ffi::GstAppSrc,
1414 _param_spec: glib::ffi::gpointer,
1415 f: glib::ffi::gpointer,
1416 ) {
1417 unsafe {
1418 let f: &F = &*(f as *const F);
1419 f(&from_glib_borrow(this))
1420 }
1421 }
1422 unsafe {
1423 let f: Box_<F> = Box_::new(f);
1424 connect_raw(
1425 self.as_ptr() as *mut _,
1426 c"notify::min-latency".as_ptr(),
1427 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1428 notify_min_latency_trampoline::<F> as *const (),
1429 )),
1430 Box_::into_raw(f),
1431 )
1432 }
1433 }
1434
1435 #[doc(alias = "min-percent")]
1436 pub fn connect_min_percent_notify<F: Fn(&Self) + Send + Sync + 'static>(
1437 &self,
1438 f: F,
1439 ) -> SignalHandlerId {
1440 unsafe extern "C" fn notify_min_percent_trampoline<
1441 F: Fn(&AppSrc) + Send + Sync + 'static,
1442 >(
1443 this: *mut ffi::GstAppSrc,
1444 _param_spec: glib::ffi::gpointer,
1445 f: glib::ffi::gpointer,
1446 ) {
1447 unsafe {
1448 let f: &F = &*(f as *const F);
1449 f(&from_glib_borrow(this))
1450 }
1451 }
1452 unsafe {
1453 let f: Box_<F> = Box_::new(f);
1454 connect_raw(
1455 self.as_ptr() as *mut _,
1456 c"notify::min-percent".as_ptr(),
1457 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1458 notify_min_percent_trampoline::<F> as *const (),
1459 )),
1460 Box_::into_raw(f),
1461 )
1462 }
1463 }
1464
1465 #[cfg(feature = "v1_28")]
1466 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
1467 #[doc(alias = "out")]
1468 pub fn connect_out_notify<F: Fn(&Self) + Send + Sync + 'static>(
1469 &self,
1470 f: F,
1471 ) -> SignalHandlerId {
1472 unsafe extern "C" fn notify_out_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1473 this: *mut ffi::GstAppSrc,
1474 _param_spec: glib::ffi::gpointer,
1475 f: glib::ffi::gpointer,
1476 ) {
1477 unsafe {
1478 let f: &F = &*(f as *const F);
1479 f(&from_glib_borrow(this))
1480 }
1481 }
1482 unsafe {
1483 let f: Box_<F> = Box_::new(f);
1484 connect_raw(
1485 self.as_ptr() as *mut _,
1486 c"notify::out".as_ptr(),
1487 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1488 notify_out_trampoline::<F> as *const (),
1489 )),
1490 Box_::into_raw(f),
1491 )
1492 }
1493 }
1494
1495 #[cfg(feature = "v1_28")]
1496 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
1497 #[doc(alias = "silent")]
1498 pub fn connect_silent_notify<F: Fn(&Self) + Send + Sync + 'static>(
1499 &self,
1500 f: F,
1501 ) -> SignalHandlerId {
1502 unsafe extern "C" fn notify_silent_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1503 this: *mut ffi::GstAppSrc,
1504 _param_spec: glib::ffi::gpointer,
1505 f: glib::ffi::gpointer,
1506 ) {
1507 unsafe {
1508 let f: &F = &*(f as *const F);
1509 f(&from_glib_borrow(this))
1510 }
1511 }
1512 unsafe {
1513 let f: Box_<F> = Box_::new(f);
1514 connect_raw(
1515 self.as_ptr() as *mut _,
1516 c"notify::silent".as_ptr(),
1517 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1518 notify_silent_trampoline::<F> as *const (),
1519 )),
1520 Box_::into_raw(f),
1521 )
1522 }
1523 }
1524
1525 #[doc(alias = "size")]
1526 pub fn connect_size_notify<F: Fn(&Self) + Send + Sync + 'static>(
1527 &self,
1528 f: F,
1529 ) -> SignalHandlerId {
1530 unsafe extern "C" fn notify_size_trampoline<F: Fn(&AppSrc) + Send + Sync + 'static>(
1531 this: *mut ffi::GstAppSrc,
1532 _param_spec: glib::ffi::gpointer,
1533 f: glib::ffi::gpointer,
1534 ) {
1535 unsafe {
1536 let f: &F = &*(f as *const F);
1537 f(&from_glib_borrow(this))
1538 }
1539 }
1540 unsafe {
1541 let f: Box_<F> = Box_::new(f);
1542 connect_raw(
1543 self.as_ptr() as *mut _,
1544 c"notify::size".as_ptr(),
1545 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1546 notify_size_trampoline::<F> as *const (),
1547 )),
1548 Box_::into_raw(f),
1549 )
1550 }
1551 }
1552
1553 #[doc(alias = "stream-type")]
1554 pub fn connect_stream_type_notify<F: Fn(&Self) + Send + Sync + 'static>(
1555 &self,
1556 f: F,
1557 ) -> SignalHandlerId {
1558 unsafe extern "C" fn notify_stream_type_trampoline<
1559 F: Fn(&AppSrc) + Send + Sync + 'static,
1560 >(
1561 this: *mut ffi::GstAppSrc,
1562 _param_spec: glib::ffi::gpointer,
1563 f: glib::ffi::gpointer,
1564 ) {
1565 unsafe {
1566 let f: &F = &*(f as *const F);
1567 f(&from_glib_borrow(this))
1568 }
1569 }
1570 unsafe {
1571 let f: Box_<F> = Box_::new(f);
1572 connect_raw(
1573 self.as_ptr() as *mut _,
1574 c"notify::stream-type".as_ptr(),
1575 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1576 notify_stream_type_trampoline::<F> as *const (),
1577 )),
1578 Box_::into_raw(f),
1579 )
1580 }
1581 }
1582}
1583
1584unsafe impl Send for AppSrc {}
1585unsafe impl Sync for AppSrc {}