gstreamer/auto/pad.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::{
7 Buffer, BufferList, Caps, Element, Event, FlowError, FlowSuccess, Object, PadDirection,
8 PadLinkCheck, PadLinkError, PadLinkSuccess, PadMode, PadTemplate, Stream, TaskState, ffi,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{SignalHandlerId, connect_raw},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 /// A [`Element`][crate::Element] is linked to other elements via "pads", which are extremely
20 /// light-weight generic link points.
21 ///
22 /// Pads have a [`PadDirection`][crate::PadDirection], source pads produce data, sink pads consume
23 /// data.
24 ///
25 /// Pads are typically created from a [`PadTemplate`][crate::PadTemplate] with
26 /// [`from_template()`][Self::from_template()] and are then added to a [`Element`][crate::Element]. This usually
27 /// happens when the element is created but it can also happen dynamically based
28 /// on the data that the element is processing or based on the pads that the
29 /// application requests.
30 ///
31 /// Pads without pad templates can be created with [`new()`][Self::new()],
32 /// which takes a direction and a name as an argument. If the name is [`None`],
33 /// then a guaranteed unique name will be assigned to it.
34 ///
35 /// A [`Element`][crate::Element] creating a pad will typically use the various
36 /// gst_pad_set_*_function\() calls to register callbacks for events, queries or
37 /// dataflow on the pads.
38 ///
39 /// `gst_pad_get_parent()` will retrieve the [`Element`][crate::Element] that owns the pad.
40 ///
41 /// After two pads are retrieved from an element by [`ElementExt::static_pad()`][crate::prelude::ElementExt::static_pad()],
42 /// the pads can be linked with [`PadExt::link()`][crate::prelude::PadExt::link()]. (For quick links,
43 /// you can also use [`ElementExtManual::link()`][crate::prelude::ElementExtManual::link()], which will make the obvious
44 /// link for you if it's straightforward.). Pads can be unlinked again with
45 /// [`PadExt::unlink()`][crate::prelude::PadExt::unlink()]. [`PadExt::peer()`][crate::prelude::PadExt::peer()] can be used to check what the pad is
46 /// linked to.
47 ///
48 /// Before dataflow is possible on the pads, they need to be activated with
49 /// [`PadExt::set_active()`][crate::prelude::PadExt::set_active()].
50 ///
51 /// [`PadExtManual::query()`][crate::prelude::PadExtManual::query()] and [`PadExtManual::peer_query()`][crate::prelude::PadExtManual::peer_query()] can be used to query various
52 /// properties of the pad and the stream.
53 ///
54 /// To send a [`Event`][crate::Event] on a pad, use [`PadExtManual::send_event()`][crate::prelude::PadExtManual::send_event()] and
55 /// [`PadExtManual::push_event()`][crate::prelude::PadExtManual::push_event()]. Some events will be sticky on the pad, meaning that
56 /// after they pass on the pad they can be queried later with
57 /// [`PadExtManual::sticky_event()`][crate::prelude::PadExtManual::sticky_event()] and [`PadExtManual::sticky_events_foreach()`][crate::prelude::PadExtManual::sticky_events_foreach()].
58 /// [`PadExt::current_caps()`][crate::prelude::PadExt::current_caps()] and [`PadExt::has_current_caps()`][crate::prelude::PadExt::has_current_caps()] are convenience
59 /// functions to query the current sticky CAPS event on a pad.
60 ///
61 /// GstElements will use [`PadExt::push()`][crate::prelude::PadExt::push()] and [`PadExtManual::pull_range()`][crate::prelude::PadExtManual::pull_range()] to push out
62 /// or pull in a buffer.
63 ///
64 /// The dataflow, events and queries that happen on a pad can be monitored with
65 /// probes that can be installed with [`PadExtManual::add_probe()`][crate::prelude::PadExtManual::add_probe()]. [`PadExt::is_blocked()`][crate::prelude::PadExt::is_blocked()]
66 /// can be used to check if a block probe is installed on the pad.
67 /// [`PadExt::is_blocking()`][crate::prelude::PadExt::is_blocking()] checks if the blocking probe is currently blocking the
68 /// pad. [`PadExtManual::remove_probe()`][crate::prelude::PadExtManual::remove_probe()] is used to remove a previously installed probe
69 /// and unblock blocking probes if any.
70 ///
71 /// Pad have an offset that can be retrieved with [`PadExt::offset()`][crate::prelude::PadExt::offset()]. This
72 /// offset will be applied to the running_time of all data passing over the pad.
73 /// [`PadExt::set_offset()`][crate::prelude::PadExt::set_offset()] can be used to change the offset.
74 ///
75 /// Convenience functions exist to start, pause and stop the task on a pad with
76 /// [`PadExtManual::start_task()`][crate::prelude::PadExtManual::start_task()], [`PadExt::pause_task()`][crate::prelude::PadExt::pause_task()] and [`PadExt::stop_task()`][crate::prelude::PadExt::stop_task()]
77 /// respectively.
78 ///
79 /// ## Properties
80 ///
81 ///
82 /// #### `caps`
83 /// Readable
84 ///
85 ///
86 /// #### `direction`
87 /// Readable | Writeable | Construct Only
88 ///
89 ///
90 /// #### `offset`
91 /// The offset that will be applied to the running time of the pad.
92 ///
93 /// Readable | Writeable
94 ///
95 ///
96 /// #### `template`
97 /// Readable | Writeable
98 /// <details><summary><h4>Object</h4></summary>
99 ///
100 ///
101 /// #### `name`
102 /// Readable | Writeable | Construct
103 ///
104 ///
105 /// #### `parent`
106 /// The parent of the object. Please note, that when changing the 'parent'
107 /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::Object#deep-notify]
108 /// signals due to locking issues. In some cases one can use
109 /// [`element-added`][struct@crate::Bin#element-added] or [`element-removed`][struct@crate::Bin#element-removed] signals on the parent to
110 /// achieve a similar effect.
111 ///
112 /// Readable | Writeable
113 /// </details>
114 ///
115 /// ## Signals
116 ///
117 ///
118 /// #### `linked`
119 /// Signals that a pad has been linked to the peer pad.
120 ///
121 ///
122 ///
123 ///
124 /// #### `unlinked`
125 /// Signals that a pad has been unlinked from the peer pad.
126 ///
127 ///
128 /// <details><summary><h4>Object</h4></summary>
129 ///
130 ///
131 /// #### `deep-notify`
132 /// The deep notify signal is used to be notified of property changes. It is
133 /// typically attached to the toplevel bin to receive notifications from all
134 /// the elements contained in that bin.
135 ///
136 /// Detailed
137 /// </details>
138 ///
139 /// # Implements
140 ///
141 /// [`PadExt`][trait@crate::prelude::PadExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`PadExtManual`][trait@crate::prelude::PadExtManual]
142 #[doc(alias = "GstPad")]
143 pub struct Pad(Object<ffi::GstPad, ffi::GstPadClass>) @extends Object;
144
145 match fn {
146 type_ => || ffi::gst_pad_get_type(),
147 }
148}
149
150impl Pad {
151 pub const NONE: Option<&'static Pad> = None;
152}
153
154unsafe impl Send for Pad {}
155unsafe impl Sync for Pad {}
156
157/// Trait containing all [`struct@Pad`] methods.
158///
159/// # Implementors
160///
161/// [`Pad`][struct@crate::Pad], [`ProxyPad`][struct@crate::ProxyPad]
162pub trait PadExt: IsA<Pad> + 'static {
163 /// Activates or deactivates the given pad in `mode` via dispatching to the
164 /// pad's activatemodefunc. For use from within pad activation functions only.
165 ///
166 /// If you don't know what this is, you probably don't want to call it.
167 /// ## `mode`
168 /// the requested activation mode
169 /// ## `active`
170 /// whether or not the pad should be active.
171 ///
172 /// # Returns
173 ///
174 /// [`true`] if the operation was successful.
175 ///
176 /// MT safe.
177 #[doc(alias = "gst_pad_activate_mode")]
178 fn activate_mode(&self, mode: PadMode, active: bool) -> Result<(), glib::error::BoolError> {
179 unsafe {
180 glib::result_from_gboolean!(
181 ffi::gst_pad_activate_mode(
182 self.as_ref().to_glib_none().0,
183 mode.into_glib(),
184 active.into_glib()
185 ),
186 "Failed to activate mode pad"
187 )
188 }
189 }
190
191 /// Checks if the source pad and the sink pad are compatible so they can be
192 /// linked.
193 /// ## `sinkpad`
194 /// the sink [`Pad`][crate::Pad].
195 ///
196 /// # Returns
197 ///
198 /// [`true`] if the pads can be linked.
199 #[doc(alias = "gst_pad_can_link")]
200 fn can_link(&self, sinkpad: &impl IsA<Pad>) -> bool {
201 unsafe {
202 from_glib(ffi::gst_pad_can_link(
203 self.as_ref().to_glib_none().0,
204 sinkpad.as_ref().to_glib_none().0,
205 ))
206 }
207 }
208
209 /// Chain a buffer to `self`.
210 ///
211 /// The function returns [`FlowReturn::Flushing`][crate::FlowReturn::Flushing] if the pad was flushing.
212 ///
213 /// If the buffer type is not acceptable for `self` (as negotiated with a
214 /// preceding GST_EVENT_CAPS event), this function returns
215 /// [`FlowReturn::NotNegotiated`][crate::FlowReturn::NotNegotiated].
216 ///
217 /// The function proceeds calling the chain function installed on `self` (see
218 /// `gst_pad_set_chain_function()`) and the return value of that function is
219 /// returned to the caller. [`FlowReturn::NotSupported`][crate::FlowReturn::NotSupported] is returned if `self` has no
220 /// chain function.
221 ///
222 /// In all cases, success or failure, the caller loses its reference to `buffer`
223 /// after calling this function.
224 /// ## `buffer`
225 /// the [`Buffer`][crate::Buffer] to send, return GST_FLOW_ERROR
226 /// if not.
227 ///
228 /// # Returns
229 ///
230 /// a [`FlowReturn`][crate::FlowReturn] from the pad.
231 ///
232 /// MT safe.
233 #[doc(alias = "gst_pad_chain")]
234 fn chain(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> {
235 unsafe {
236 try_from_glib(ffi::gst_pad_chain(
237 self.as_ref().to_glib_none().0,
238 buffer.into_glib_ptr(),
239 ))
240 }
241 }
242
243 /// Chain a bufferlist to `self`.
244 ///
245 /// The function returns [`FlowReturn::Flushing`][crate::FlowReturn::Flushing] if the pad was flushing.
246 ///
247 /// If `self` was not negotiated properly with a CAPS event, this function
248 /// returns [`FlowReturn::NotNegotiated`][crate::FlowReturn::NotNegotiated].
249 ///
250 /// The function proceeds calling the chainlist function installed on `self` (see
251 /// `gst_pad_set_chain_list_function()`) and the return value of that function is
252 /// returned to the caller. [`FlowReturn::NotSupported`][crate::FlowReturn::NotSupported] is returned if `self` has no
253 /// chainlist function.
254 ///
255 /// In all cases, success or failure, the caller loses its reference to `list`
256 /// after calling this function.
257 ///
258 /// MT safe.
259 /// ## `list`
260 /// the [`BufferList`][crate::BufferList] to send, return GST_FLOW_ERROR
261 /// if not.
262 ///
263 /// # Returns
264 ///
265 /// a [`FlowReturn`][crate::FlowReturn] from the pad.
266 #[doc(alias = "gst_pad_chain_list")]
267 fn chain_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> {
268 unsafe {
269 try_from_glib(ffi::gst_pad_chain_list(
270 self.as_ref().to_glib_none().0,
271 list.into_glib_ptr(),
272 ))
273 }
274 }
275
276 /// Check and clear the [`PadFlags::NEED_RECONFIGURE`][crate::PadFlags::NEED_RECONFIGURE] flag on `self` and return [`true`]
277 /// if the flag was set.
278 ///
279 /// # Returns
280 ///
281 /// [`true`] is the GST_PAD_FLAG_NEED_RECONFIGURE flag was set on `self`.
282 #[doc(alias = "gst_pad_check_reconfigure")]
283 fn check_reconfigure(&self) -> bool {
284 unsafe {
285 from_glib(ffi::gst_pad_check_reconfigure(
286 self.as_ref().to_glib_none().0,
287 ))
288 }
289 }
290
291 /// Creates a stream-id for the source [`Pad`][crate::Pad] `self` by combining the
292 /// upstream information with the optional `stream_id` of the stream
293 /// of `self`. `self` must have a parent [`Element`][crate::Element] and which must have zero
294 /// or one sinkpad. `stream_id` can only be [`None`] if the parent element
295 /// of `self` has only a single source pad.
296 ///
297 /// This function generates an unique stream-id by getting the upstream
298 /// stream-start event stream ID and appending `stream_id` to it. If the
299 /// element has no sinkpad it will generate an upstream stream-id by
300 /// doing an URI query on the element and in the worst case just uses
301 /// a random number. Source elements that don't implement the URI
302 /// handler interface should ideally generate a unique, deterministic
303 /// stream-id manually instead.
304 ///
305 /// Since stream IDs are sorted alphabetically, any numbers in the
306 /// stream ID should be printed with a fixed number of characters,
307 /// preceded by 0's, such as by using the format \`03u` instead of \`u`.
308 /// ## `parent`
309 /// Parent [`Element`][crate::Element] of `self`
310 /// ## `stream_id`
311 /// The stream-id
312 ///
313 /// # Returns
314 ///
315 /// A stream-id for `self`. `g_free()` after usage.
316 #[doc(alias = "gst_pad_create_stream_id")]
317 fn create_stream_id(
318 &self,
319 parent: &impl IsA<Element>,
320 stream_id: Option<&str>,
321 ) -> glib::GString {
322 unsafe {
323 from_glib_full(ffi::gst_pad_create_stream_id(
324 self.as_ref().to_glib_none().0,
325 parent.as_ref().to_glib_none().0,
326 stream_id.to_glib_none().0,
327 ))
328 }
329 }
330
331 //#[doc(alias = "gst_pad_create_stream_id_printf")]
332 //fn create_stream_id_printf(&self, parent: &impl IsA<Element>, stream_id: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> glib::GString {
333 // unsafe { TODO: call ffi:gst_pad_create_stream_id_printf() }
334 //}
335
336 //#[doc(alias = "gst_pad_create_stream_id_printf_valist")]
337 //fn create_stream_id_printf_valist(&self, parent: &impl IsA<Element>, stream_id: Option<&str>, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> glib::GString {
338 // unsafe { TODO: call ffi:gst_pad_create_stream_id_printf_valist() }
339 //}
340
341 /// Calls `forward` for all internally linked pads of `self`. This function deals with
342 /// dynamically changing internal pads and will make sure that the `forward`
343 /// function is only called once for each pad.
344 ///
345 /// When `forward` returns [`true`], no further pads will be processed.
346 /// ## `forward`
347 /// a `GstPadForwardFunction`
348 ///
349 /// # Returns
350 ///
351 /// [`true`] if one of the dispatcher functions returned [`true`].
352 #[doc(alias = "gst_pad_forward")]
353 fn forward<P: FnMut(&Pad) -> bool>(&self, forward: P) -> bool {
354 let mut forward_data: P = forward;
355 unsafe extern "C" fn forward_func<P: FnMut(&Pad) -> bool>(
356 pad: *mut ffi::GstPad,
357 user_data: glib::ffi::gpointer,
358 ) -> glib::ffi::gboolean {
359 unsafe {
360 let pad = from_glib_borrow(pad);
361 let callback = user_data as *mut P;
362 (*callback)(&pad).into_glib()
363 }
364 }
365 let forward = Some(forward_func::<P> as _);
366 let super_callback0: &mut P = &mut forward_data;
367 unsafe {
368 from_glib(ffi::gst_pad_forward(
369 self.as_ref().to_glib_none().0,
370 forward,
371 super_callback0 as *mut _ as *mut _,
372 ))
373 }
374 }
375
376 /// Gets the capabilities of the allowed media types that can flow through
377 /// `self` and its peer.
378 ///
379 /// The allowed capabilities is calculated as the intersection of the results of
380 /// calling [`query_caps()`][Self::query_caps()] on `self` and its peer. The caller owns a reference
381 /// on the resulting caps.
382 ///
383 /// # Returns
384 ///
385 /// the allowed [`Caps`][crate::Caps] of the
386 /// pad link. Unref the caps when you no longer need it. This
387 /// function returns [`None`] when `self` has no peer.
388 ///
389 /// MT safe.
390 #[doc(alias = "gst_pad_get_allowed_caps")]
391 #[doc(alias = "get_allowed_caps")]
392 fn allowed_caps(&self) -> Option<Caps> {
393 unsafe {
394 from_glib_full(ffi::gst_pad_get_allowed_caps(
395 self.as_ref().to_glib_none().0,
396 ))
397 }
398 }
399
400 /// Gets the capabilities currently configured on `self` with the last
401 /// [`EventType::Caps`][crate::EventType::Caps] event.
402 ///
403 /// # Returns
404 ///
405 /// the current caps of the pad with
406 /// incremented ref-count or [`None`] when pad has no caps. Unref after usage.
407 #[doc(alias = "gst_pad_get_current_caps")]
408 #[doc(alias = "get_current_caps")]
409 fn current_caps(&self) -> Option<Caps> {
410 unsafe {
411 from_glib_full(ffi::gst_pad_get_current_caps(
412 self.as_ref().to_glib_none().0,
413 ))
414 }
415 }
416
417 /// Gets the direction of the pad. The direction of the pad is
418 /// decided at construction time so this function does not take
419 /// the LOCK.
420 ///
421 /// # Returns
422 ///
423 /// the [`PadDirection`][crate::PadDirection] of the pad.
424 ///
425 /// MT safe.
426 #[doc(alias = "gst_pad_get_direction")]
427 #[doc(alias = "get_direction")]
428 fn direction(&self) -> PadDirection {
429 unsafe { from_glib(ffi::gst_pad_get_direction(self.as_ref().to_glib_none().0)) }
430 }
431
432 //#[doc(alias = "gst_pad_get_element_private")]
433 //#[doc(alias = "get_element_private")]
434 //fn element_private(&self) -> /*Unimplemented*/Option<Basic: Pointer> {
435 // unsafe { TODO: call ffi:gst_pad_get_element_private() }
436 //}
437
438 /// Gets the [`FlowReturn`][crate::FlowReturn] return from the last data passed by this pad.
439 #[doc(alias = "gst_pad_get_last_flow_return")]
440 #[doc(alias = "get_last_flow_return")]
441 fn last_flow_result(&self) -> Result<FlowSuccess, FlowError> {
442 unsafe {
443 try_from_glib(ffi::gst_pad_get_last_flow_return(
444 self.as_ref().to_glib_none().0,
445 ))
446 }
447 }
448
449 /// Get the offset applied to the running time of `self`. `self` has to be a source
450 /// pad.
451 ///
452 /// # Returns
453 ///
454 /// the offset.
455 #[doc(alias = "gst_pad_get_offset")]
456 #[doc(alias = "get_offset")]
457 fn offset(&self) -> i64 {
458 unsafe { ffi::gst_pad_get_offset(self.as_ref().to_glib_none().0) }
459 }
460
461 /// Gets the template for `self`.
462 ///
463 /// # Returns
464 ///
465 /// the [`PadTemplate`][crate::PadTemplate] from which
466 /// this pad was instantiated, or [`None`] if this pad has no
467 /// template. Unref after usage.
468 #[doc(alias = "gst_pad_get_pad_template")]
469 #[doc(alias = "get_pad_template")]
470 fn pad_template(&self) -> Option<PadTemplate> {
471 unsafe {
472 from_glib_full(ffi::gst_pad_get_pad_template(
473 self.as_ref().to_glib_none().0,
474 ))
475 }
476 }
477
478 /// Gets the capabilities for `self`'s template.
479 ///
480 /// # Returns
481 ///
482 /// the [`Caps`][crate::Caps] of this pad template.
483 /// Unref after usage.
484 #[doc(alias = "gst_pad_get_pad_template_caps")]
485 #[doc(alias = "get_pad_template_caps")]
486 fn pad_template_caps(&self) -> Caps {
487 unsafe {
488 from_glib_full(ffi::gst_pad_get_pad_template_caps(
489 self.as_ref().to_glib_none().0,
490 ))
491 }
492 }
493
494 /// Gets the parent of `self`, cast to a [`Element`][crate::Element]. If a `self` has no parent or
495 /// its parent is not an element, return [`None`].
496 ///
497 /// # Returns
498 ///
499 /// the parent of the pad. The
500 /// caller has a reference on the parent, so unref when you're finished
501 /// with it.
502 ///
503 /// MT safe.
504 #[doc(alias = "gst_pad_get_parent_element")]
505 #[doc(alias = "get_parent_element")]
506 fn parent_element(&self) -> Option<Element> {
507 unsafe {
508 from_glib_full(ffi::gst_pad_get_parent_element(
509 self.as_ref().to_glib_none().0,
510 ))
511 }
512 }
513
514 /// Gets the peer of `self`. This function refs the peer pad so
515 /// you need to unref it after use.
516 ///
517 /// # Returns
518 ///
519 /// the peer [`Pad`][crate::Pad]. Unref after usage.
520 ///
521 /// MT safe.
522 #[doc(alias = "gst_pad_get_peer")]
523 #[doc(alias = "get_peer")]
524 #[must_use]
525 fn peer(&self) -> Option<Pad> {
526 unsafe { from_glib_full(ffi::gst_pad_get_peer(self.as_ref().to_glib_none().0)) }
527 }
528
529 /// If there is a single internal link of the given pad, this function will
530 /// return it. Otherwise, it will return NULL.
531 ///
532 /// # Returns
533 ///
534 /// a [`Pad`][crate::Pad], or [`None`] if `self` has none
535 /// or more than one internal links. Unref returned pad with
536 /// `gst_object_unref()`.
537 #[cfg(feature = "v1_18")]
538 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
539 #[doc(alias = "gst_pad_get_single_internal_link")]
540 #[doc(alias = "get_single_internal_link")]
541 #[must_use]
542 fn single_internal_link(&self) -> Option<Pad> {
543 unsafe {
544 from_glib_full(ffi::gst_pad_get_single_internal_link(
545 self.as_ref().to_glib_none().0,
546 ))
547 }
548 }
549
550 /// Returns the current [`Stream`][crate::Stream] for the `self`, or [`None`] if none has been
551 /// set yet, i.e. the pad has not received a stream-start event yet.
552 ///
553 /// This is a convenience wrapper around [`PadExtManual::sticky_event()`][crate::prelude::PadExtManual::sticky_event()] and
554 /// `gst_event_parse_stream()`.
555 ///
556 /// # Returns
557 ///
558 /// the current [`Stream`][crate::Stream] for `self`, or [`None`].
559 /// unref the returned stream when no longer needed.
560 #[doc(alias = "gst_pad_get_stream")]
561 #[doc(alias = "get_stream")]
562 fn stream(&self) -> Option<Stream> {
563 unsafe { from_glib_full(ffi::gst_pad_get_stream(self.as_ref().to_glib_none().0)) }
564 }
565
566 /// Returns the current stream-id for the `self`, or [`None`] if none has been
567 /// set yet, i.e. the pad has not received a stream-start event yet.
568 ///
569 /// This is a convenience wrapper around [`PadExtManual::sticky_event()`][crate::prelude::PadExtManual::sticky_event()] and
570 /// `gst_event_parse_stream_start()`.
571 ///
572 /// The returned stream-id string should be treated as an opaque string, its
573 /// contents should not be interpreted.
574 ///
575 /// # Returns
576 ///
577 /// a newly-allocated copy of the stream-id for
578 /// `self`, or [`None`]. `g_free()` the returned string when no longer
579 /// needed.
580 #[doc(alias = "gst_pad_get_stream_id")]
581 #[doc(alias = "get_stream_id")]
582 fn stream_id(&self) -> Option<glib::GString> {
583 unsafe { from_glib_full(ffi::gst_pad_get_stream_id(self.as_ref().to_glib_none().0)) }
584 }
585
586 /// Get `self` task state. If no task is currently
587 /// set, [`TaskState::Stopped`][crate::TaskState::Stopped] is returned.
588 ///
589 /// # Returns
590 ///
591 /// The current state of `self`'s task.
592 #[doc(alias = "gst_pad_get_task_state")]
593 #[doc(alias = "get_task_state")]
594 fn task_state(&self) -> TaskState {
595 unsafe { from_glib(ffi::gst_pad_get_task_state(self.as_ref().to_glib_none().0)) }
596 }
597
598 /// Check if `self` has caps set on it with a [`EventType::Caps`][crate::EventType::Caps] event.
599 ///
600 /// # Returns
601 ///
602 /// [`true`] when `self` has caps associated with it.
603 #[doc(alias = "gst_pad_has_current_caps")]
604 fn has_current_caps(&self) -> bool {
605 unsafe {
606 from_glib(ffi::gst_pad_has_current_caps(
607 self.as_ref().to_glib_none().0,
608 ))
609 }
610 }
611
612 /// Query if a pad is active
613 ///
614 /// # Returns
615 ///
616 /// [`true`] if the pad is active.
617 ///
618 /// MT safe.
619 #[doc(alias = "gst_pad_is_active")]
620 fn is_active(&self) -> bool {
621 unsafe { from_glib(ffi::gst_pad_is_active(self.as_ref().to_glib_none().0)) }
622 }
623
624 /// Checks if the pad is blocked or not. This function returns the
625 /// last requested state of the pad. It is not certain that the pad
626 /// is actually blocking at this point (see [`is_blocking()`][Self::is_blocking()]).
627 ///
628 /// # Returns
629 ///
630 /// [`true`] if the pad is blocked.
631 ///
632 /// MT safe.
633 #[doc(alias = "gst_pad_is_blocked")]
634 fn is_blocked(&self) -> bool {
635 unsafe { from_glib(ffi::gst_pad_is_blocked(self.as_ref().to_glib_none().0)) }
636 }
637
638 /// Checks if the pad is blocking or not. This is a guaranteed state
639 /// of whether the pad is actually blocking on a [`Buffer`][crate::Buffer] or a [`Event`][crate::Event].
640 ///
641 /// # Returns
642 ///
643 /// [`true`] if the pad is blocking.
644 ///
645 /// MT safe.
646 #[doc(alias = "gst_pad_is_blocking")]
647 fn is_blocking(&self) -> bool {
648 unsafe { from_glib(ffi::gst_pad_is_blocking(self.as_ref().to_glib_none().0)) }
649 }
650
651 /// Checks if a `self` is linked to another pad or not.
652 ///
653 /// # Returns
654 ///
655 /// [`true`] if the pad is linked, [`false`] otherwise.
656 ///
657 /// MT safe.
658 #[doc(alias = "gst_pad_is_linked")]
659 fn is_linked(&self) -> bool {
660 unsafe { from_glib(ffi::gst_pad_is_linked(self.as_ref().to_glib_none().0)) }
661 }
662
663 //#[doc(alias = "gst_pad_iterate_internal_links")]
664 //fn iterate_internal_links(&self) -> /*Ignored*/Option<Iterator> {
665 // unsafe { TODO: call ffi:gst_pad_iterate_internal_links() }
666 //}
667
668 //#[doc(alias = "gst_pad_iterate_internal_links_default")]
669 //fn iterate_internal_links_default(&self, parent: Option<&impl IsA<Object>>) -> /*Ignored*/Option<Iterator> {
670 // unsafe { TODO: call ffi:gst_pad_iterate_internal_links_default() }
671 //}
672
673 /// Links the source pad and the sink pad.
674 /// ## `sinkpad`
675 /// the sink [`Pad`][crate::Pad] to link.
676 ///
677 /// # Returns
678 ///
679 /// A result code indicating if the connection worked or
680 /// what went wrong.
681 ///
682 /// MT Safe.
683 #[doc(alias = "gst_pad_link")]
684 fn link(&self, sinkpad: &impl IsA<Pad>) -> Result<PadLinkSuccess, PadLinkError> {
685 unsafe {
686 try_from_glib(ffi::gst_pad_link(
687 self.as_ref().to_glib_none().0,
688 sinkpad.as_ref().to_glib_none().0,
689 ))
690 }
691 }
692
693 /// Links the source pad and the sink pad.
694 ///
695 /// This variant of `gst_pad_link` provides a more granular control on the
696 /// checks being done when linking. While providing some considerable speedups
697 /// the caller of this method must be aware that wrong usage of those flags
698 /// can cause severe issues. Refer to the documentation of [`PadLinkCheck`][crate::PadLinkCheck]
699 /// for more information.
700 ///
701 /// MT Safe.
702 /// ## `sinkpad`
703 /// the sink [`Pad`][crate::Pad] to link.
704 /// ## `flags`
705 /// the checks to validate when linking
706 ///
707 /// # Returns
708 ///
709 /// A result code indicating if the connection worked or
710 /// what went wrong.
711 #[doc(alias = "gst_pad_link_full")]
712 fn link_full(
713 &self,
714 sinkpad: &impl IsA<Pad>,
715 flags: PadLinkCheck,
716 ) -> Result<PadLinkSuccess, PadLinkError> {
717 unsafe {
718 try_from_glib(ffi::gst_pad_link_full(
719 self.as_ref().to_glib_none().0,
720 sinkpad.as_ref().to_glib_none().0,
721 flags.into_glib(),
722 ))
723 }
724 }
725
726 /// Links `self` to `sink`, creating any [`GhostPad`][crate::GhostPad]'s in between as necessary.
727 ///
728 /// This is a convenience function to save having to create and add intermediate
729 /// [`GhostPad`][crate::GhostPad]'s as required for linking across [`Bin`][crate::Bin] boundaries.
730 ///
731 /// If `self` or `sink` pads don't have parent elements or do not share a common
732 /// ancestor, the link will fail.
733 /// ## `sink`
734 /// a [`Pad`][crate::Pad]
735 ///
736 /// # Returns
737 ///
738 /// whether the link succeeded.
739 #[doc(alias = "gst_pad_link_maybe_ghosting")]
740 fn link_maybe_ghosting(&self, sink: &impl IsA<Pad>) -> Result<(), glib::error::BoolError> {
741 unsafe {
742 glib::result_from_gboolean!(
743 ffi::gst_pad_link_maybe_ghosting(
744 self.as_ref().to_glib_none().0,
745 sink.as_ref().to_glib_none().0
746 ),
747 "Failed to link pads, possibly ghosting"
748 )
749 }
750 }
751
752 /// Links `self` to `sink`, creating any [`GhostPad`][crate::GhostPad]'s in between as necessary.
753 ///
754 /// This is a convenience function to save having to create and add intermediate
755 /// [`GhostPad`][crate::GhostPad]'s as required for linking across [`Bin`][crate::Bin] boundaries.
756 ///
757 /// If `self` or `sink` pads don't have parent elements or do not share a common
758 /// ancestor, the link will fail.
759 ///
760 /// Calling [`link_maybe_ghosting_full()`][Self::link_maybe_ghosting_full()] with
761 /// `flags` == [`PadLinkCheck::DEFAULT`][crate::PadLinkCheck::DEFAULT] is the recommended way of linking
762 /// pads with safety checks applied.
763 /// ## `sink`
764 /// a [`Pad`][crate::Pad]
765 /// ## `flags`
766 /// some [`PadLinkCheck`][crate::PadLinkCheck] flags
767 ///
768 /// # Returns
769 ///
770 /// whether the link succeeded.
771 #[doc(alias = "gst_pad_link_maybe_ghosting_full")]
772 fn link_maybe_ghosting_full(
773 &self,
774 sink: &impl IsA<Pad>,
775 flags: PadLinkCheck,
776 ) -> Result<(), glib::error::BoolError> {
777 unsafe {
778 glib::result_from_gboolean!(
779 ffi::gst_pad_link_maybe_ghosting_full(
780 self.as_ref().to_glib_none().0,
781 sink.as_ref().to_glib_none().0,
782 flags.into_glib()
783 ),
784 "Failed to link pads, possibly ghosting"
785 )
786 }
787 }
788
789 /// Mark a pad for needing reconfiguration. The next call to
790 /// [`check_reconfigure()`][Self::check_reconfigure()] will return [`true`] after this call.
791 #[doc(alias = "gst_pad_mark_reconfigure")]
792 fn mark_reconfigure(&self) {
793 unsafe {
794 ffi::gst_pad_mark_reconfigure(self.as_ref().to_glib_none().0);
795 }
796 }
797
798 /// Check the [`PadFlags::NEED_RECONFIGURE`][crate::PadFlags::NEED_RECONFIGURE] flag on `self` and return [`true`]
799 /// if the flag was set.
800 ///
801 /// # Returns
802 ///
803 /// [`true`] is the GST_PAD_FLAG_NEED_RECONFIGURE flag is set on `self`.
804 #[doc(alias = "gst_pad_needs_reconfigure")]
805 fn needs_reconfigure(&self) -> bool {
806 unsafe {
807 from_glib(ffi::gst_pad_needs_reconfigure(
808 self.as_ref().to_glib_none().0,
809 ))
810 }
811 }
812
813 /// Pause the task of `self`. This function will also wait until the
814 /// function executed by the task is finished if this function is not
815 /// called from the task function.
816 ///
817 /// # Returns
818 ///
819 /// a [`true`] if the task could be paused or [`false`] when the pad
820 /// has no task.
821 #[doc(alias = "gst_pad_pause_task")]
822 fn pause_task(&self) -> Result<(), glib::error::BoolError> {
823 unsafe {
824 glib::result_from_gboolean!(
825 ffi::gst_pad_pause_task(self.as_ref().to_glib_none().0),
826 "Failed to pause pad task"
827 )
828 }
829 }
830
831 /// Check if the peer of `self` accepts `caps`. If `self` has no peer, this function
832 /// returns [`true`].
833 /// ## `caps`
834 /// a [`Caps`][crate::Caps] to check on the pad
835 ///
836 /// # Returns
837 ///
838 /// [`true`] if the peer of `self` can accept the caps or `self` has no peer.
839 #[doc(alias = "gst_pad_peer_query_accept_caps")]
840 fn peer_query_accept_caps(&self, caps: &Caps) -> bool {
841 unsafe {
842 from_glib(ffi::gst_pad_peer_query_accept_caps(
843 self.as_ref().to_glib_none().0,
844 caps.to_glib_none().0,
845 ))
846 }
847 }
848
849 /// Gets the capabilities of the peer connected to this pad. Similar to
850 /// [`query_caps()`][Self::query_caps()].
851 ///
852 /// When called on srcpads `filter` contains the caps that
853 /// upstream could produce in the order preferred by upstream. When
854 /// called on sinkpads `filter` contains the caps accepted by
855 /// downstream in the preferred order. `filter` might be [`None`] but
856 /// if it is not [`None`] the returned caps will be a subset of `filter`.
857 /// ## `filter`
858 /// a [`Caps`][crate::Caps] filter, or [`None`].
859 ///
860 /// # Returns
861 ///
862 /// the caps of the peer pad with incremented
863 /// ref-count. When there is no peer pad, this function returns `filter` or,
864 /// when `filter` is [`None`], ANY caps.
865 #[doc(alias = "gst_pad_peer_query_caps")]
866 fn peer_query_caps(&self, filter: Option<&Caps>) -> Caps {
867 unsafe {
868 from_glib_full(ffi::gst_pad_peer_query_caps(
869 self.as_ref().to_glib_none().0,
870 filter.to_glib_none().0,
871 ))
872 }
873 }
874
875 /// Pushes a buffer to the peer of `self`.
876 ///
877 /// This function will call installed block probes before triggering any
878 /// installed data probes.
879 ///
880 /// The function proceeds calling [`chain()`][Self::chain()] on the peer pad and returns
881 /// the value from that function. If `self` has no peer, [`FlowReturn::NotLinked`][crate::FlowReturn::NotLinked] will
882 /// be returned.
883 ///
884 /// In all cases, success or failure, the caller loses its reference to `buffer`
885 /// after calling this function.
886 /// ## `buffer`
887 /// the [`Buffer`][crate::Buffer] to push returns GST_FLOW_ERROR
888 /// if not.
889 ///
890 /// # Returns
891 ///
892 /// a [`FlowReturn`][crate::FlowReturn] from the peer pad.
893 ///
894 /// MT safe.
895 #[doc(alias = "gst_pad_push")]
896 fn push(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> {
897 unsafe {
898 try_from_glib(ffi::gst_pad_push(
899 self.as_ref().to_glib_none().0,
900 buffer.into_glib_ptr(),
901 ))
902 }
903 }
904
905 /// Pushes a buffer list to the peer of `self`.
906 ///
907 /// This function will call installed block probes before triggering any
908 /// installed data probes.
909 ///
910 /// The function proceeds calling the chain function on the peer pad and returns
911 /// the value from that function. If `self` has no peer, [`FlowReturn::NotLinked`][crate::FlowReturn::NotLinked] will
912 /// be returned. If the peer pad does not have any installed chainlist function
913 /// every group buffer of the list will be merged into a normal [`Buffer`][crate::Buffer] and
914 /// chained via [`chain()`][Self::chain()].
915 ///
916 /// In all cases, success or failure, the caller loses its reference to `list`
917 /// after calling this function.
918 /// ## `list`
919 /// the [`BufferList`][crate::BufferList] to push returns GST_FLOW_ERROR
920 /// if not.
921 ///
922 /// # Returns
923 ///
924 /// a [`FlowReturn`][crate::FlowReturn] from the peer pad.
925 ///
926 /// MT safe.
927 #[doc(alias = "gst_pad_push_list")]
928 fn push_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> {
929 unsafe {
930 try_from_glib(ffi::gst_pad_push_list(
931 self.as_ref().to_glib_none().0,
932 list.into_glib_ptr(),
933 ))
934 }
935 }
936
937 /// Check if the given pad accepts the caps.
938 /// ## `caps`
939 /// a [`Caps`][crate::Caps] to check on the pad
940 ///
941 /// # Returns
942 ///
943 /// [`true`] if the pad can accept the caps.
944 #[doc(alias = "gst_pad_query_accept_caps")]
945 fn query_accept_caps(&self, caps: &Caps) -> bool {
946 unsafe {
947 from_glib(ffi::gst_pad_query_accept_caps(
948 self.as_ref().to_glib_none().0,
949 caps.to_glib_none().0,
950 ))
951 }
952 }
953
954 /// Gets the capabilities this pad can produce or consume.
955 /// Note that this method doesn't necessarily return the caps set by sending a
956 /// `gst_event_new_caps()` - use [`current_caps()`][Self::current_caps()] for that instead.
957 /// gst_pad_query_caps returns all possible caps a pad can operate with, using
958 /// the pad's CAPS query function, If the query fails, this function will return
959 /// `filter`, if not [`None`], otherwise ANY.
960 ///
961 /// When called on sinkpads `filter` contains the caps that
962 /// upstream could produce in the order preferred by upstream. When
963 /// called on srcpads `filter` contains the caps accepted by
964 /// downstream in the preferred order. `filter` might be [`None`] but
965 /// if it is not [`None`] the returned caps will be a subset of `filter`.
966 ///
967 /// Note that this function does not return writable [`Caps`][crate::Caps], use
968 /// [`Caps::make_writable()`][crate::Caps::make_writable()] before modifying the caps.
969 /// ## `filter`
970 /// suggested [`Caps`][crate::Caps], or [`None`]
971 ///
972 /// # Returns
973 ///
974 /// the caps of the pad with incremented ref-count.
975 #[doc(alias = "gst_pad_query_caps")]
976 fn query_caps(&self, filter: Option<&Caps>) -> Caps {
977 unsafe {
978 from_glib_full(ffi::gst_pad_query_caps(
979 self.as_ref().to_glib_none().0,
980 filter.to_glib_none().0,
981 ))
982 }
983 }
984
985 /// Activates or deactivates the given pad.
986 /// Normally called from within core state change functions.
987 ///
988 /// If `active`, makes sure the pad is active. If it is already active, either in
989 /// push or pull mode, just return. Otherwise dispatches to the pad's activate
990 /// function to perform the actual activation.
991 ///
992 /// If not `active`, calls [`activate_mode()`][Self::activate_mode()] with the pad's current mode
993 /// and a [`false`] argument.
994 /// ## `active`
995 /// whether or not the pad should be active.
996 ///
997 /// # Returns
998 ///
999 /// [`true`] if the operation was successful.
1000 ///
1001 /// MT safe.
1002 #[doc(alias = "gst_pad_set_active")]
1003 fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError> {
1004 unsafe {
1005 glib::result_from_gboolean!(
1006 ffi::gst_pad_set_active(self.as_ref().to_glib_none().0, active.into_glib()),
1007 "Failed to activate pad"
1008 )
1009 }
1010 }
1011
1012 //#[doc(alias = "gst_pad_set_element_private")]
1013 //fn set_element_private(&self, priv_: /*Unimplemented*/Option<Basic: Pointer>) {
1014 // unsafe { TODO: call ffi:gst_pad_set_element_private() }
1015 //}
1016
1017 /// Set the offset that will be applied to the running time of `self`. Upon next
1018 /// buffer, every sticky events (notably segment) will be pushed again with
1019 /// their running time adjusted. For that reason this is only reliable on
1020 /// source pads.
1021 /// ## `offset`
1022 /// the offset
1023 #[doc(alias = "gst_pad_set_offset")]
1024 #[doc(alias = "offset")]
1025 fn set_offset(&self, offset: i64) {
1026 unsafe {
1027 ffi::gst_pad_set_offset(self.as_ref().to_glib_none().0, offset);
1028 }
1029 }
1030
1031 /// Stop the task of `self`. This function will also make sure that the
1032 /// function executed by the task will effectively stop if not called
1033 /// from the GstTaskFunction.
1034 ///
1035 /// This function will deadlock if called from the GstTaskFunction of
1036 /// the task. Use [`TaskExt::pause()`][crate::prelude::TaskExt::pause()] instead.
1037 ///
1038 /// Regardless of whether the pad has a task, the stream lock is acquired and
1039 /// released so as to ensure that streaming through this pad has finished.
1040 ///
1041 /// # Returns
1042 ///
1043 /// a [`true`] if the task could be stopped or [`false`] on error.
1044 #[doc(alias = "gst_pad_stop_task")]
1045 fn stop_task(&self) -> Result<(), glib::error::BoolError> {
1046 unsafe {
1047 glib::result_from_gboolean!(
1048 ffi::gst_pad_stop_task(self.as_ref().to_glib_none().0),
1049 "Failed to stop pad task"
1050 )
1051 }
1052 }
1053
1054 /// Store the sticky `event` on `self`
1055 /// ## `event`
1056 /// a [`Event`][crate::Event]
1057 ///
1058 /// # Returns
1059 ///
1060 /// [`FlowReturn::Ok`][crate::FlowReturn::Ok] on success, [`FlowReturn::Flushing`][crate::FlowReturn::Flushing] when the pad
1061 /// was flushing or [`FlowReturn::Eos`][crate::FlowReturn::Eos] when the pad was EOS.
1062 #[doc(alias = "gst_pad_store_sticky_event")]
1063 fn store_sticky_event(&self, event: &Event) -> Result<FlowSuccess, FlowError> {
1064 unsafe {
1065 try_from_glib(ffi::gst_pad_store_sticky_event(
1066 self.as_ref().to_glib_none().0,
1067 event.to_glib_none().0,
1068 ))
1069 }
1070 }
1071
1072 /// Unlinks the source pad from the sink pad. Will emit the [`unlinked`][struct@crate::Pad#unlinked]
1073 /// signal on both pads.
1074 /// ## `sinkpad`
1075 /// the sink [`Pad`][crate::Pad] to unlink.
1076 ///
1077 /// # Returns
1078 ///
1079 /// [`true`] if the pads were unlinked. This function returns [`false`] if
1080 /// the pads were not linked together.
1081 ///
1082 /// MT safe.
1083 #[doc(alias = "gst_pad_unlink")]
1084 fn unlink(&self, sinkpad: &impl IsA<Pad>) -> Result<(), glib::error::BoolError> {
1085 unsafe {
1086 glib::result_from_gboolean!(
1087 ffi::gst_pad_unlink(
1088 self.as_ref().to_glib_none().0,
1089 sinkpad.as_ref().to_glib_none().0
1090 ),
1091 "Failed to unlink pad"
1092 )
1093 }
1094 }
1095
1096 /// A helper function you can use that sets the FIXED_CAPS flag
1097 /// This way the default CAPS query will always return the negotiated caps
1098 /// or in case the pad is not negotiated, the padtemplate caps.
1099 ///
1100 /// The negotiated caps are the caps of the last CAPS event that passed on the
1101 /// pad. Use this function on a pad that, once it negotiated to a CAPS, cannot
1102 /// be renegotiated to something else.
1103 #[doc(alias = "gst_pad_use_fixed_caps")]
1104 fn use_fixed_caps(&self) {
1105 unsafe {
1106 ffi::gst_pad_use_fixed_caps(self.as_ref().to_glib_none().0);
1107 }
1108 }
1109
1110 /// Signals that a pad has been linked to the peer pad.
1111 /// ## `peer`
1112 /// the peer pad that has been connected
1113 #[doc(alias = "linked")]
1114 fn connect_linked<F: Fn(&Self, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1115 unsafe extern "C" fn linked_trampoline<
1116 P: IsA<Pad>,
1117 F: Fn(&P, &Pad) + Send + Sync + 'static,
1118 >(
1119 this: *mut ffi::GstPad,
1120 peer: *mut ffi::GstPad,
1121 f: glib::ffi::gpointer,
1122 ) {
1123 unsafe {
1124 let f: &F = &*(f as *const F);
1125 f(
1126 Pad::from_glib_borrow(this).unsafe_cast_ref(),
1127 &from_glib_borrow(peer),
1128 )
1129 }
1130 }
1131 unsafe {
1132 let f: Box_<F> = Box_::new(f);
1133 connect_raw(
1134 self.as_ptr() as *mut _,
1135 c"linked".as_ptr(),
1136 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1137 linked_trampoline::<Self, F> as *const (),
1138 )),
1139 Box_::into_raw(f),
1140 )
1141 }
1142 }
1143
1144 /// Signals that a pad has been unlinked from the peer pad.
1145 /// ## `peer`
1146 /// the peer pad that has been disconnected
1147 #[doc(alias = "unlinked")]
1148 fn connect_unlinked<F: Fn(&Self, &Pad) + Send + Sync + 'static>(
1149 &self,
1150 f: F,
1151 ) -> SignalHandlerId {
1152 unsafe extern "C" fn unlinked_trampoline<
1153 P: IsA<Pad>,
1154 F: Fn(&P, &Pad) + Send + Sync + 'static,
1155 >(
1156 this: *mut ffi::GstPad,
1157 peer: *mut ffi::GstPad,
1158 f: glib::ffi::gpointer,
1159 ) {
1160 unsafe {
1161 let f: &F = &*(f as *const F);
1162 f(
1163 Pad::from_glib_borrow(this).unsafe_cast_ref(),
1164 &from_glib_borrow(peer),
1165 )
1166 }
1167 }
1168 unsafe {
1169 let f: Box_<F> = Box_::new(f);
1170 connect_raw(
1171 self.as_ptr() as *mut _,
1172 c"unlinked".as_ptr(),
1173 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1174 unlinked_trampoline::<Self, F> as *const (),
1175 )),
1176 Box_::into_raw(f),
1177 )
1178 }
1179 }
1180
1181 #[doc(alias = "caps")]
1182 fn connect_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1183 unsafe extern "C" fn notify_caps_trampoline<
1184 P: IsA<Pad>,
1185 F: Fn(&P) + Send + Sync + 'static,
1186 >(
1187 this: *mut ffi::GstPad,
1188 _param_spec: glib::ffi::gpointer,
1189 f: glib::ffi::gpointer,
1190 ) {
1191 unsafe {
1192 let f: &F = &*(f as *const F);
1193 f(Pad::from_glib_borrow(this).unsafe_cast_ref())
1194 }
1195 }
1196 unsafe {
1197 let f: Box_<F> = Box_::new(f);
1198 connect_raw(
1199 self.as_ptr() as *mut _,
1200 c"notify::caps".as_ptr(),
1201 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1202 notify_caps_trampoline::<Self, F> as *const (),
1203 )),
1204 Box_::into_raw(f),
1205 )
1206 }
1207 }
1208
1209 #[doc(alias = "offset")]
1210 fn connect_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1211 unsafe extern "C" fn notify_offset_trampoline<
1212 P: IsA<Pad>,
1213 F: Fn(&P) + Send + Sync + 'static,
1214 >(
1215 this: *mut ffi::GstPad,
1216 _param_spec: glib::ffi::gpointer,
1217 f: glib::ffi::gpointer,
1218 ) {
1219 unsafe {
1220 let f: &F = &*(f as *const F);
1221 f(Pad::from_glib_borrow(this).unsafe_cast_ref())
1222 }
1223 }
1224 unsafe {
1225 let f: Box_<F> = Box_::new(f);
1226 connect_raw(
1227 self.as_ptr() as *mut _,
1228 c"notify::offset".as_ptr(),
1229 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1230 notify_offset_trampoline::<Self, F> as *const (),
1231 )),
1232 Box_::into_raw(f),
1233 )
1234 }
1235 }
1236}
1237
1238impl<O: IsA<Pad>> PadExt for O {}