gstreamer/auto/bin.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
6use crate::{ChildProxy, Element, ElementFlags, Object, Pad, PadDirection, ffi};
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{SignalHandlerId, connect_raw},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 /// [`Bin`][crate::Bin] is an element that can contain other [`Element`][crate::Element], allowing them to be
17 /// managed as a group.
18 /// Pads from the child elements can be ghosted to the bin, see [`GhostPad`][crate::GhostPad].
19 /// This makes the bin look like any other elements and enables creation of
20 /// higher-level abstraction elements.
21 ///
22 /// A new [`Bin`][crate::Bin] is created with [`new()`][Self::new()]. Use a [`Pipeline`][crate::Pipeline] instead if you
23 /// want to create a toplevel bin because a normal bin doesn't have a bus or
24 /// handle clock distribution of its own.
25 ///
26 /// After the bin has been created you will typically add elements to it with
27 /// [`GstBinExt::add()`][crate::prelude::GstBinExt::add()]. You can remove elements with [`GstBinExt::remove()`][crate::prelude::GstBinExt::remove()].
28 ///
29 /// An element can be retrieved from a bin with [`GstBinExt::by_name()`][crate::prelude::GstBinExt::by_name()], using the
30 /// elements name. [`GstBinExt::by_name_recurse_up()`][crate::prelude::GstBinExt::by_name_recurse_up()] is mainly used for internal
31 /// purposes and will query the parent bins when the element is not found in the
32 /// current bin.
33 ///
34 /// An iterator of elements in a bin can be retrieved with
35 /// [`GstBinExtManual::iterate_elements()`][crate::prelude::GstBinExtManual::iterate_elements()]. Various other iterators exist to retrieve the
36 /// elements in a bin.
37 ///
38 /// `gst_object_unref()` is used to drop your reference to the bin.
39 ///
40 /// The [`element-added`][struct@crate::Bin#element-added] signal is fired whenever a new element is added to
41 /// the bin. Likewise the [`element-removed`][struct@crate::Bin#element-removed] signal is fired whenever an
42 /// element is removed from the bin.
43 ///
44 /// A [`Bin`][crate::Bin] internally intercepts every [`Message`][crate::Message] posted by its children and
45 /// implements the following default behaviour for each of them:
46 ///
47 /// * `GST_MESSAGE_EOS`: This message is only posted by sinks in the PLAYING
48 /// state. If all sinks posted the EOS message, this bin will post and EOS
49 /// message upwards.
50 ///
51 /// * `GST_MESSAGE_SEGMENT_START`: Just collected and never forwarded upwards.
52 /// The messages are used to decide when all elements have completed playback
53 /// of their segment.
54 ///
55 /// * `GST_MESSAGE_SEGMENT_DONE`: Is posted by [`Bin`][crate::Bin] when all elements that posted
56 /// a SEGMENT_START have posted a SEGMENT_DONE.
57 ///
58 /// * `GST_MESSAGE_DURATION_CHANGED`: Is posted by an element that detected a change
59 /// in the stream duration. The duration change is posted to the
60 /// application so that it can refetch the new duration with a duration
61 /// query.
62 ///
63 /// Note that these messages can be posted before the bin is prerolled, in which
64 /// case the duration query might fail.
65 ///
66 /// Note also that there might be a discrepancy (due to internal buffering/queueing)
67 /// between the stream being currently displayed and the returned duration query.
68 ///
69 /// Applications might want to also query for duration (and changes) by
70 /// listening to the `GST_MESSAGE_STREAM_START` message, signaling the active start
71 /// of a (new) stream.
72 ///
73 /// * `GST_MESSAGE_CLOCK_LOST`: This message is posted by an element when it
74 /// can no longer provide a clock.
75 ///
76 /// The default bin behaviour is to check if the lost clock was the one provided
77 /// by the bin. If so and the bin is currently in the PLAYING state, the message
78 /// is forwarded to the bin parent.
79 ///
80 /// This message is also generated when a clock provider is removed from
81 /// the bin. If this message is received by the application, it should
82 /// PAUSE the pipeline and set it back to PLAYING to force a new clock
83 /// distribution.
84 ///
85 /// * `GST_MESSAGE_CLOCK_PROVIDE`: This message is generated when an element
86 /// can provide a clock. This mostly happens when a new clock
87 /// provider is added to the bin.
88 ///
89 /// The default behaviour of the bin is to mark the currently selected clock as
90 /// dirty, which will perform a clock recalculation the next time the bin is
91 /// asked to provide a clock.
92 ///
93 /// This message is never sent to the application but is forwarded to
94 /// the parent of the bin.
95 ///
96 /// * OTHERS: posted upwards.
97 ///
98 /// A [`Bin`][crate::Bin] implements the following default behaviour for answering to a
99 /// [`Query`][crate::Query]:
100 ///
101 /// * [`QueryType::Duration`][crate::QueryType::Duration]: The bin will forward the query to all sink
102 /// elements contained within and will return the maximum value.
103 /// If no sinks are available in the bin, the query fails.
104 ///
105 /// * [`QueryType::Position`][crate::QueryType::Position]: The query is sent to all sink elements in the bin and the
106 /// MAXIMUM of all values is returned. If no sinks are available in the bin,
107 /// the query fails.
108 ///
109 /// * OTHERS: the query is forwarded to all sink elements, the result
110 /// of the first sink that answers the query successfully is returned. If no
111 /// sink is in the bin, the query fails.
112 ///
113 /// A [`Bin`][crate::Bin] will by default forward any event sent to it to all sink
114 /// ( [`EventTypeFlags::UPSTREAM`][crate::EventTypeFlags::UPSTREAM] ) or source ( [`EventTypeFlags::DOWNSTREAM`][crate::EventTypeFlags::DOWNSTREAM] ) elements
115 /// depending on the event type.
116 ///
117 /// If all the elements return [`true`], the bin will also return [`true`], else [`false`]
118 /// is returned. If no elements of the required type are in the bin, the event
119 /// handler will return [`true`].
120 ///
121 /// ## Properties
122 ///
123 ///
124 /// #### `async-handling`
125 /// If set to [`true`], the bin will handle asynchronous state changes.
126 /// This should be used only if the bin subclass is modifying the state
127 /// of its children on its own.
128 ///
129 /// Readable | Writable
130 ///
131 ///
132 /// #### `message-forward`
133 /// Forward all children messages, even those that would normally be filtered by
134 /// the bin. This can be interesting when one wants to be notified of the EOS
135 /// state of individual elements, for example.
136 ///
137 /// The messages are converted to an ELEMENT message with the bin as the
138 /// source. The structure of the message is named `GstBinForwarded` and contains
139 /// a field named `message` that contains the original forwarded [`Message`][crate::Message].
140 ///
141 /// Readable | Writable
142 /// <details><summary><h4>Object</h4></summary>
143 ///
144 ///
145 /// #### `name`
146 /// Readable | Writable | Construct
147 ///
148 ///
149 /// #### `parent`
150 /// The parent of the object. Please note, that when changing the 'parent'
151 /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::Object#deep-notify]
152 /// signals due to locking issues. In some cases one can use
153 /// [`element-added`][struct@crate::Bin#element-added] or [`element-removed`][struct@crate::Bin#element-removed] signals on the parent to
154 /// achieve a similar effect.
155 ///
156 /// Readable | Writable
157 /// </details>
158 ///
159 /// ## Signals
160 ///
161 ///
162 /// #### `deep-element-added`
163 /// Will be emitted after the element was added to `sub_bin`.
164 ///
165 ///
166 ///
167 ///
168 /// #### `deep-element-removed`
169 /// Will be emitted after the element was removed from `sub_bin`.
170 ///
171 ///
172 ///
173 ///
174 /// #### `do-latency`
175 /// Will be emitted when the bin needs to perform latency calculations. This
176 /// signal is only emitted for toplevel bins or when [`async-handling`][struct@crate::Bin#async-handling] is
177 /// enabled.
178 ///
179 /// Only one signal handler is invoked. If no signals are connected, the
180 /// default handler is invoked, which will query and distribute the lowest
181 /// possible latency to all sinks.
182 ///
183 /// Connect to this signal if the default latency calculations are not
184 /// sufficient, like when you need different latencies for different sinks in
185 /// the same pipeline.
186 ///
187 ///
188 ///
189 ///
190 /// #### `element-added`
191 /// Will be emitted after the element was added to the bin.
192 ///
193 ///
194 ///
195 ///
196 /// #### `element-removed`
197 /// Will be emitted after the element was removed from the bin.
198 ///
199 ///
200 /// <details><summary><h4>Element</h4></summary>
201 ///
202 ///
203 /// #### `no-more-pads`
204 /// This signals that the element will not generate more dynamic pads.
205 /// Note that this signal will usually be emitted from the context of
206 /// the streaming thread.
207 ///
208 ///
209 ///
210 ///
211 /// #### `pad-added`
212 /// a new [`Pad`][crate::Pad] has been added to the element. Note that this signal will
213 /// usually be emitted from the context of the streaming thread. Also keep in
214 /// mind that if you add new elements to the pipeline in the signal handler
215 /// you will need to set them to the desired target state with
216 /// [`ElementExt::set_state()`][crate::prelude::ElementExt::set_state()] or [`ElementExt::sync_state_with_parent()`][crate::prelude::ElementExt::sync_state_with_parent()].
217 ///
218 ///
219 ///
220 ///
221 /// #### `pad-removed`
222 /// a [`Pad`][crate::Pad] has been removed from the element
223 ///
224 ///
225 /// </details>
226 /// <details><summary><h4>Object</h4></summary>
227 ///
228 ///
229 /// #### `deep-notify`
230 /// The deep notify signal is used to be notified of property changes. It is
231 /// typically attached to the toplevel bin to receive notifications from all
232 /// the elements contained in that bin.
233 ///
234 /// Detailed
235 /// </details>
236 /// <details><summary><h4>ChildProxy</h4></summary>
237 ///
238 ///
239 /// #### `child-added`
240 /// Will be emitted after the `object` was added to the `child_proxy`.
241 ///
242 ///
243 ///
244 ///
245 /// #### `child-removed`
246 /// Will be emitted after the `object` was removed from the `child_proxy`.
247 ///
248 ///
249 /// </details>
250 ///
251 /// # Implements
252 ///
253 /// [`GstBinExt`][trait@crate::prelude::GstBinExt], [`ElementExt`][trait@crate::prelude::ElementExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`ChildProxyExt`][trait@crate::prelude::ChildProxyExt], [`ElementExtManual`][trait@crate::prelude::ElementExtManual], [`GstObjectExtManual`][trait@crate::prelude::GstObjectExtManual], [`ChildProxyExtManual`][trait@crate::prelude::ChildProxyExtManual]
254 #[doc(alias = "GstBin")]
255 pub struct Bin(Object<ffi::GstBin, ffi::GstBinClass>) @extends Element, Object, @implements ChildProxy;
256
257 match fn {
258 type_ => || ffi::gst_bin_get_type(),
259 }
260}
261
262impl Bin {
263 pub const NONE: Option<&'static Bin> = None;
264}
265
266unsafe impl Send for Bin {}
267unsafe impl Sync for Bin {}
268
269/// Trait containing all [`struct@Bin`] methods.
270///
271/// # Implementors
272///
273/// [`Bin`][struct@crate::Bin], [`Pipeline`][struct@crate::Pipeline]
274pub trait GstBinExt: IsA<Bin> + 'static {
275 /// The bin or pipeline will not take care of this for you.
276 /// ## `element`
277 /// the [`Element`][crate::Element] to add
278 ///
279 /// # Returns
280 ///
281 /// [`true`] if the element could be added, [`false`] if
282 /// the bin does not want to accept the element.
283 #[doc(alias = "gst_bin_add")]
284 fn add(&self, element: &impl IsA<Element>) -> Result<(), glib::error::BoolError> {
285 unsafe {
286 glib::result_from_gboolean!(
287 ffi::gst_bin_add(
288 self.as_ref().to_glib_none().0,
289 element.as_ref().to_glib_none().0
290 ),
291 "Failed to add element"
292 )
293 }
294 }
295
296 /// Recursively looks for elements with an unlinked pad of the given
297 /// direction within the specified bin and returns an unlinked pad
298 /// if one is found, or [`None`] otherwise. If a pad is found, the caller
299 /// owns a reference to it and should use `gst_object_unref()` on the
300 /// pad when it is not needed any longer.
301 /// ## `direction`
302 /// whether to look for an unlinked source or sink pad
303 ///
304 /// # Returns
305 ///
306 /// unlinked pad of the given
307 /// direction.
308 #[doc(alias = "gst_bin_find_unlinked_pad")]
309 fn find_unlinked_pad(&self, direction: PadDirection) -> Option<Pad> {
310 unsafe {
311 from_glib_full(ffi::gst_bin_find_unlinked_pad(
312 self.as_ref().to_glib_none().0,
313 direction.into_glib(),
314 ))
315 }
316 }
317
318 /// Looks for an element inside the bin that implements the given
319 /// interface. If such an element is found, it returns the element.
320 /// You can cast this element to the given interface afterwards. If you want
321 /// all elements that implement the interface, use
322 /// [`GstBinExtManual::iterate_all_by_interface()`][crate::prelude::GstBinExtManual::iterate_all_by_interface()]. This function recurses into child bins.
323 /// ## `iface`
324 /// the `GType` of an interface
325 ///
326 /// # Returns
327 ///
328 /// A [`Element`][crate::Element] inside the bin
329 /// implementing the interface
330 #[doc(alias = "gst_bin_get_by_interface")]
331 #[doc(alias = "get_by_interface")]
332 fn by_interface(&self, iface: glib::types::Type) -> Option<Element> {
333 unsafe {
334 from_glib_full(ffi::gst_bin_get_by_interface(
335 self.as_ref().to_glib_none().0,
336 iface.into_glib(),
337 ))
338 }
339 }
340
341 /// Gets the element with the given name from a bin. This
342 /// function recurses into child bins.
343 /// ## `name`
344 /// the element name to search for
345 ///
346 /// # Returns
347 ///
348 /// the [`Element`][crate::Element] with the given
349 /// name
350 #[doc(alias = "gst_bin_get_by_name")]
351 #[doc(alias = "get_by_name")]
352 fn by_name(&self, name: &str) -> Option<Element> {
353 unsafe {
354 from_glib_full(ffi::gst_bin_get_by_name(
355 self.as_ref().to_glib_none().0,
356 name.to_glib_none().0,
357 ))
358 }
359 }
360
361 /// Gets the element with the given name from this bin. If the
362 /// element is not found, a recursion is performed on the parent bin.
363 /// ## `name`
364 /// the element name to search for
365 ///
366 /// # Returns
367 ///
368 /// the [`Element`][crate::Element] with the given
369 /// name
370 #[doc(alias = "gst_bin_get_by_name_recurse_up")]
371 #[doc(alias = "get_by_name_recurse_up")]
372 fn by_name_recurse_up(&self, name: &str) -> Option<Element> {
373 unsafe {
374 from_glib_full(ffi::gst_bin_get_by_name_recurse_up(
375 self.as_ref().to_glib_none().0,
376 name.to_glib_none().0,
377 ))
378 }
379 }
380
381 ///
382 /// # Returns
383 ///
384 /// the bin's suppressed [`ElementFlags`][crate::ElementFlags].
385 #[doc(alias = "gst_bin_get_suppressed_flags")]
386 #[doc(alias = "get_suppressed_flags")]
387 fn suppressed_flags(&self) -> ElementFlags {
388 unsafe {
389 from_glib(ffi::gst_bin_get_suppressed_flags(
390 self.as_ref().to_glib_none().0,
391 ))
392 }
393 }
394
395 /// Queries `self` for the current latency and reconfigures this latency on all the
396 /// elements using a LATENCY event.
397 ///
398 /// This method is typically called on the pipeline when a `GST_MESSAGE_LATENCY`
399 /// is posted on the bus.
400 ///
401 /// This function simply emits the [`do-latency`][struct@crate::Bin#do-latency] signal so any custom latency
402 /// calculations will be performed.
403 ///
404 /// # Returns
405 ///
406 /// [`true`] if the latency could be queried and reconfigured.
407 #[doc(alias = "gst_bin_recalculate_latency")]
408 fn recalculate_latency(&self) -> Result<(), glib::error::BoolError> {
409 unsafe {
410 glib::result_from_gboolean!(
411 ffi::gst_bin_recalculate_latency(self.as_ref().to_glib_none().0),
412 "Failed to recalculate latency"
413 )
414 }
415 }
416
417 /// Removes the element from the bin, unparenting it as well.
418 /// Unparenting the element means that the element will be dereferenced,
419 /// so if the bin holds the only reference to the element, the element
420 /// will be freed in the process of removing it from the bin. If you
421 /// want the element to still exist after removing, you need to call
422 /// `gst_object_ref()` before removing it from the bin.
423 ///
424 /// If the element's pads are linked to other pads, the pads will be unlinked
425 /// before the element is removed from the bin.
426 /// ## `element`
427 /// the [`Element`][crate::Element] to remove
428 ///
429 /// # Returns
430 ///
431 /// [`true`] if the element could be removed, [`false`] if
432 /// the bin does not want to remove the element.
433 #[doc(alias = "gst_bin_remove")]
434 fn remove(&self, element: &impl IsA<Element>) -> Result<(), glib::error::BoolError> {
435 unsafe {
436 glib::result_from_gboolean!(
437 ffi::gst_bin_remove(
438 self.as_ref().to_glib_none().0,
439 element.as_ref().to_glib_none().0
440 ),
441 "Failed to remove element"
442 )
443 }
444 }
445
446 /// Suppresses the given flags on the bin. [`ElementFlags`][crate::ElementFlags] of a
447 /// child element are propagated when it is added to the bin.
448 /// When suppressed flags are set, those specified flags will
449 /// not be propagated to the bin.
450 /// ## `flags`
451 /// the [`ElementFlags`][crate::ElementFlags] to suppress
452 #[doc(alias = "gst_bin_set_suppressed_flags")]
453 fn set_suppressed_flags(&self, flags: ElementFlags) {
454 unsafe {
455 ffi::gst_bin_set_suppressed_flags(self.as_ref().to_glib_none().0, flags.into_glib());
456 }
457 }
458
459 /// Synchronizes the state of every child of `self` with the state
460 /// of `self`. See also [`ElementExt::sync_state_with_parent()`][crate::prelude::ElementExt::sync_state_with_parent()].
461 ///
462 /// # Returns
463 ///
464 /// [`true`] if syncing the state was successful for all children,
465 /// otherwise [`false`].
466 #[doc(alias = "gst_bin_sync_children_states")]
467 fn sync_children_states(&self) -> Result<(), glib::error::BoolError> {
468 unsafe {
469 glib::result_from_gboolean!(
470 ffi::gst_bin_sync_children_states(self.as_ref().to_glib_none().0),
471 "Failed to sync children states"
472 )
473 }
474 }
475
476 /// If set to [`true`], the bin will handle asynchronous state changes.
477 /// This should be used only if the bin subclass is modifying the state
478 /// of its children on its own.
479 #[doc(alias = "async-handling")]
480 fn is_async_handling(&self) -> bool {
481 ObjectExt::property(self.as_ref(), "async-handling")
482 }
483
484 /// If set to [`true`], the bin will handle asynchronous state changes.
485 /// This should be used only if the bin subclass is modifying the state
486 /// of its children on its own.
487 #[doc(alias = "async-handling")]
488 fn set_async_handling(&self, async_handling: bool) {
489 ObjectExt::set_property(self.as_ref(), "async-handling", async_handling)
490 }
491
492 /// Forward all children messages, even those that would normally be filtered by
493 /// the bin. This can be interesting when one wants to be notified of the EOS
494 /// state of individual elements, for example.
495 ///
496 /// The messages are converted to an ELEMENT message with the bin as the
497 /// source. The structure of the message is named `GstBinForwarded` and contains
498 /// a field named `message` that contains the original forwarded [`Message`][crate::Message].
499 #[doc(alias = "message-forward")]
500 fn is_message_forward(&self) -> bool {
501 ObjectExt::property(self.as_ref(), "message-forward")
502 }
503
504 /// Forward all children messages, even those that would normally be filtered by
505 /// the bin. This can be interesting when one wants to be notified of the EOS
506 /// state of individual elements, for example.
507 ///
508 /// The messages are converted to an ELEMENT message with the bin as the
509 /// source. The structure of the message is named `GstBinForwarded` and contains
510 /// a field named `message` that contains the original forwarded [`Message`][crate::Message].
511 #[doc(alias = "message-forward")]
512 fn set_message_forward(&self, message_forward: bool) {
513 ObjectExt::set_property(self.as_ref(), "message-forward", message_forward)
514 }
515
516 /// Will be emitted after the element was added to `sub_bin`.
517 /// ## `sub_bin`
518 /// the [`Bin`][crate::Bin] the element was added to
519 /// ## `element`
520 /// the [`Element`][crate::Element] that was added to `sub_bin`
521 #[doc(alias = "deep-element-added")]
522 fn connect_deep_element_added<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(
523 &self,
524 f: F,
525 ) -> SignalHandlerId {
526 unsafe extern "C" fn deep_element_added_trampoline<
527 P: IsA<Bin>,
528 F: Fn(&P, &Bin, &Element) + Send + Sync + 'static,
529 >(
530 this: *mut ffi::GstBin,
531 sub_bin: *mut ffi::GstBin,
532 element: *mut ffi::GstElement,
533 f: glib::ffi::gpointer,
534 ) {
535 unsafe {
536 let f: &F = &*(f as *const F);
537 f(
538 Bin::from_glib_borrow(this).unsafe_cast_ref(),
539 &from_glib_borrow(sub_bin),
540 &from_glib_borrow(element),
541 )
542 }
543 }
544 unsafe {
545 let f: Box_<F> = Box_::new(f);
546 connect_raw(
547 self.as_ptr() as *mut _,
548 c"deep-element-added".as_ptr(),
549 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
550 deep_element_added_trampoline::<Self, F> as *const (),
551 )),
552 Box_::into_raw(f),
553 )
554 }
555 }
556
557 /// Will be emitted after the element was removed from `sub_bin`.
558 /// ## `sub_bin`
559 /// the [`Bin`][crate::Bin] the element was removed from
560 /// ## `element`
561 /// the [`Element`][crate::Element] that was removed from `sub_bin`
562 #[doc(alias = "deep-element-removed")]
563 fn connect_deep_element_removed<F: Fn(&Self, &Bin, &Element) + Send + Sync + 'static>(
564 &self,
565 f: F,
566 ) -> SignalHandlerId {
567 unsafe extern "C" fn deep_element_removed_trampoline<
568 P: IsA<Bin>,
569 F: Fn(&P, &Bin, &Element) + Send + Sync + 'static,
570 >(
571 this: *mut ffi::GstBin,
572 sub_bin: *mut ffi::GstBin,
573 element: *mut ffi::GstElement,
574 f: glib::ffi::gpointer,
575 ) {
576 unsafe {
577 let f: &F = &*(f as *const F);
578 f(
579 Bin::from_glib_borrow(this).unsafe_cast_ref(),
580 &from_glib_borrow(sub_bin),
581 &from_glib_borrow(element),
582 )
583 }
584 }
585 unsafe {
586 let f: Box_<F> = Box_::new(f);
587 connect_raw(
588 self.as_ptr() as *mut _,
589 c"deep-element-removed".as_ptr(),
590 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
591 deep_element_removed_trampoline::<Self, F> as *const (),
592 )),
593 Box_::into_raw(f),
594 )
595 }
596 }
597
598 /// Will be emitted after the element was added to the bin.
599 /// ## `element`
600 /// the [`Element`][crate::Element] that was added to the bin
601 #[doc(alias = "element-added")]
602 fn connect_element_added<F: Fn(&Self, &Element) + Send + Sync + 'static>(
603 &self,
604 f: F,
605 ) -> SignalHandlerId {
606 unsafe extern "C" fn element_added_trampoline<
607 P: IsA<Bin>,
608 F: Fn(&P, &Element) + Send + Sync + 'static,
609 >(
610 this: *mut ffi::GstBin,
611 element: *mut ffi::GstElement,
612 f: glib::ffi::gpointer,
613 ) {
614 unsafe {
615 let f: &F = &*(f as *const F);
616 f(
617 Bin::from_glib_borrow(this).unsafe_cast_ref(),
618 &from_glib_borrow(element),
619 )
620 }
621 }
622 unsafe {
623 let f: Box_<F> = Box_::new(f);
624 connect_raw(
625 self.as_ptr() as *mut _,
626 c"element-added".as_ptr(),
627 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
628 element_added_trampoline::<Self, F> as *const (),
629 )),
630 Box_::into_raw(f),
631 )
632 }
633 }
634
635 /// Will be emitted after the element was removed from the bin.
636 /// ## `element`
637 /// the [`Element`][crate::Element] that was removed from the bin
638 #[doc(alias = "element-removed")]
639 fn connect_element_removed<F: Fn(&Self, &Element) + Send + Sync + 'static>(
640 &self,
641 f: F,
642 ) -> SignalHandlerId {
643 unsafe extern "C" fn element_removed_trampoline<
644 P: IsA<Bin>,
645 F: Fn(&P, &Element) + Send + Sync + 'static,
646 >(
647 this: *mut ffi::GstBin,
648 element: *mut ffi::GstElement,
649 f: glib::ffi::gpointer,
650 ) {
651 unsafe {
652 let f: &F = &*(f as *const F);
653 f(
654 Bin::from_glib_borrow(this).unsafe_cast_ref(),
655 &from_glib_borrow(element),
656 )
657 }
658 }
659 unsafe {
660 let f: Box_<F> = Box_::new(f);
661 connect_raw(
662 self.as_ptr() as *mut _,
663 c"element-removed".as_ptr(),
664 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
665 element_removed_trampoline::<Self, F> as *const (),
666 )),
667 Box_::into_raw(f),
668 )
669 }
670 }
671
672 #[doc(alias = "async-handling")]
673 fn connect_async_handling_notify<F: Fn(&Self) + Send + Sync + 'static>(
674 &self,
675 f: F,
676 ) -> SignalHandlerId {
677 unsafe extern "C" fn notify_async_handling_trampoline<
678 P: IsA<Bin>,
679 F: Fn(&P) + Send + Sync + 'static,
680 >(
681 this: *mut ffi::GstBin,
682 _param_spec: glib::ffi::gpointer,
683 f: glib::ffi::gpointer,
684 ) {
685 unsafe {
686 let f: &F = &*(f as *const F);
687 f(Bin::from_glib_borrow(this).unsafe_cast_ref())
688 }
689 }
690 unsafe {
691 let f: Box_<F> = Box_::new(f);
692 connect_raw(
693 self.as_ptr() as *mut _,
694 c"notify::async-handling".as_ptr(),
695 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
696 notify_async_handling_trampoline::<Self, F> as *const (),
697 )),
698 Box_::into_raw(f),
699 )
700 }
701 }
702
703 #[doc(alias = "message-forward")]
704 fn connect_message_forward_notify<F: Fn(&Self) + Send + Sync + 'static>(
705 &self,
706 f: F,
707 ) -> SignalHandlerId {
708 unsafe extern "C" fn notify_message_forward_trampoline<
709 P: IsA<Bin>,
710 F: Fn(&P) + Send + Sync + 'static,
711 >(
712 this: *mut ffi::GstBin,
713 _param_spec: glib::ffi::gpointer,
714 f: glib::ffi::gpointer,
715 ) {
716 unsafe {
717 let f: &F = &*(f as *const F);
718 f(Bin::from_glib_borrow(this).unsafe_cast_ref())
719 }
720 }
721 unsafe {
722 let f: Box_<F> = Box_::new(f);
723 connect_raw(
724 self.as_ptr() as *mut _,
725 c"notify::message-forward".as_ptr(),
726 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
727 notify_message_forward_trampoline::<Self, F> as *const (),
728 )),
729 Box_::into_raw(f),
730 )
731 }
732 }
733}
734
735impl<O: IsA<Bin>> GstBinExt for O {}