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 | use crate::{ |
7 | Buffer, BufferList, Caps, Element, Event, FlowError, FlowSuccess, Object, PadDirection, |
8 | PadLinkCheck, PadLinkError, PadLinkSuccess, PadMode, PadTemplate, Stream, TaskState, |
9 | }; |
10 | use glib::{ |
11 | prelude::*, |
12 | signal::{connect_raw, SignalHandlerId}, |
13 | translate::*, |
14 | }; |
15 | use std::{boxed::Box as Box_, mem::transmute}; |
16 | |
17 | glib::wrapper! { |
18 | #[doc (alias = "GstPad" )] |
19 | pub struct Pad(Object<ffi::GstPad, ffi::GstPadClass>) @extends Object; |
20 | |
21 | match fn { |
22 | type_ => || ffi::gst_pad_get_type(), |
23 | } |
24 | } |
25 | |
26 | impl Pad { |
27 | pub const NONE: Option<&'static Pad> = None; |
28 | } |
29 | |
30 | unsafe impl Send for Pad {} |
31 | unsafe impl Sync for Pad {} |
32 | |
33 | mod sealed { |
34 | pub trait Sealed {} |
35 | impl<T: super::IsA<super::Pad>> Sealed for T {} |
36 | } |
37 | |
38 | pub trait PadExt: IsA<Pad> + sealed::Sealed + 'static { |
39 | #[doc (alias = "gst_pad_activate_mode" )] |
40 | fn activate_mode(&self, mode: PadMode, active: bool) -> Result<(), glib::error::BoolError> { |
41 | unsafe { |
42 | glib::result_from_gboolean!( |
43 | ffi::gst_pad_activate_mode( |
44 | self.as_ref().to_glib_none().0, |
45 | mode.into_glib(), |
46 | active.into_glib() |
47 | ), |
48 | "Failed to activate mode pad" |
49 | ) |
50 | } |
51 | } |
52 | |
53 | #[doc (alias = "gst_pad_can_link" )] |
54 | fn can_link(&self, sinkpad: &impl IsA<Pad>) -> bool { |
55 | unsafe { |
56 | from_glib(ffi::gst_pad_can_link( |
57 | self.as_ref().to_glib_none().0, |
58 | sinkpad.as_ref().to_glib_none().0, |
59 | )) |
60 | } |
61 | } |
62 | |
63 | #[doc (alias = "gst_pad_chain" )] |
64 | fn chain(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> { |
65 | unsafe { |
66 | try_from_glib(ffi::gst_pad_chain( |
67 | self.as_ref().to_glib_none().0, |
68 | buffer.into_glib_ptr(), |
69 | )) |
70 | } |
71 | } |
72 | |
73 | #[doc (alias = "gst_pad_chain_list" )] |
74 | fn chain_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> { |
75 | unsafe { |
76 | try_from_glib(ffi::gst_pad_chain_list( |
77 | self.as_ref().to_glib_none().0, |
78 | list.into_glib_ptr(), |
79 | )) |
80 | } |
81 | } |
82 | |
83 | #[doc (alias = "gst_pad_check_reconfigure" )] |
84 | fn check_reconfigure(&self) -> bool { |
85 | unsafe { |
86 | from_glib(ffi::gst_pad_check_reconfigure( |
87 | self.as_ref().to_glib_none().0, |
88 | )) |
89 | } |
90 | } |
91 | |
92 | #[doc (alias = "gst_pad_create_stream_id" )] |
93 | fn create_stream_id( |
94 | &self, |
95 | parent: &impl IsA<Element>, |
96 | stream_id: Option<&str>, |
97 | ) -> glib::GString { |
98 | unsafe { |
99 | from_glib_full(ffi::gst_pad_create_stream_id( |
100 | self.as_ref().to_glib_none().0, |
101 | parent.as_ref().to_glib_none().0, |
102 | stream_id.to_glib_none().0, |
103 | )) |
104 | } |
105 | } |
106 | |
107 | //#[doc(alias = "gst_pad_create_stream_id_printf")] |
108 | //fn create_stream_id_printf(&self, parent: &impl IsA<Element>, stream_id: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> glib::GString { |
109 | // unsafe { TODO: call ffi:gst_pad_create_stream_id_printf() } |
110 | //} |
111 | |
112 | //#[doc(alias = "gst_pad_create_stream_id_printf_valist")] |
113 | //fn create_stream_id_printf_valist(&self, parent: &impl IsA<Element>, stream_id: Option<&str>, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> glib::GString { |
114 | // unsafe { TODO: call ffi:gst_pad_create_stream_id_printf_valist() } |
115 | //} |
116 | |
117 | #[doc (alias = "gst_pad_forward" )] |
118 | fn forward<P: FnMut(&Pad) -> bool>(&self, forward: P) -> bool { |
119 | let forward_data: P = forward; |
120 | unsafe extern "C" fn forward_func<P: FnMut(&Pad) -> bool>( |
121 | pad: *mut ffi::GstPad, |
122 | user_data: glib::ffi::gpointer, |
123 | ) -> glib::ffi::gboolean { |
124 | let pad = from_glib_borrow(pad); |
125 | let callback: *mut P = user_data as *const _ as usize as *mut P; |
126 | (*callback)(&pad).into_glib() |
127 | } |
128 | let forward = Some(forward_func::<P> as _); |
129 | let super_callback0: &P = &forward_data; |
130 | unsafe { |
131 | from_glib(ffi::gst_pad_forward( |
132 | self.as_ref().to_glib_none().0, |
133 | forward, |
134 | super_callback0 as *const _ as usize as *mut _, |
135 | )) |
136 | } |
137 | } |
138 | |
139 | #[doc (alias = "gst_pad_get_allowed_caps" )] |
140 | #[doc (alias = "get_allowed_caps" )] |
141 | fn allowed_caps(&self) -> Option<Caps> { |
142 | unsafe { |
143 | from_glib_full(ffi::gst_pad_get_allowed_caps( |
144 | self.as_ref().to_glib_none().0, |
145 | )) |
146 | } |
147 | } |
148 | |
149 | #[doc (alias = "gst_pad_get_current_caps" )] |
150 | #[doc (alias = "get_current_caps" )] |
151 | fn current_caps(&self) -> Option<Caps> { |
152 | unsafe { |
153 | from_glib_full(ffi::gst_pad_get_current_caps( |
154 | self.as_ref().to_glib_none().0, |
155 | )) |
156 | } |
157 | } |
158 | |
159 | #[doc (alias = "gst_pad_get_direction" )] |
160 | #[doc (alias = "get_direction" )] |
161 | fn direction(&self) -> PadDirection { |
162 | unsafe { from_glib(ffi::gst_pad_get_direction(self.as_ref().to_glib_none().0)) } |
163 | } |
164 | |
165 | //#[doc(alias = "gst_pad_get_element_private")] |
166 | //#[doc(alias = "get_element_private")] |
167 | //fn element_private(&self) -> /*Unimplemented*/Option<Basic: Pointer> { |
168 | // unsafe { TODO: call ffi:gst_pad_get_element_private() } |
169 | //} |
170 | |
171 | #[doc (alias = "gst_pad_get_last_flow_return" )] |
172 | #[doc (alias = "get_last_flow_return" )] |
173 | fn last_flow_result(&self) -> Result<FlowSuccess, FlowError> { |
174 | unsafe { |
175 | try_from_glib(ffi::gst_pad_get_last_flow_return( |
176 | self.as_ref().to_glib_none().0, |
177 | )) |
178 | } |
179 | } |
180 | |
181 | #[doc (alias = "gst_pad_get_offset" )] |
182 | #[doc (alias = "get_offset" )] |
183 | fn offset(&self) -> i64 { |
184 | unsafe { ffi::gst_pad_get_offset(self.as_ref().to_glib_none().0) } |
185 | } |
186 | |
187 | #[doc (alias = "gst_pad_get_pad_template" )] |
188 | #[doc (alias = "get_pad_template" )] |
189 | fn pad_template(&self) -> Option<PadTemplate> { |
190 | unsafe { |
191 | from_glib_full(ffi::gst_pad_get_pad_template( |
192 | self.as_ref().to_glib_none().0, |
193 | )) |
194 | } |
195 | } |
196 | |
197 | #[doc (alias = "gst_pad_get_pad_template_caps" )] |
198 | #[doc (alias = "get_pad_template_caps" )] |
199 | fn pad_template_caps(&self) -> Caps { |
200 | unsafe { |
201 | from_glib_full(ffi::gst_pad_get_pad_template_caps( |
202 | self.as_ref().to_glib_none().0, |
203 | )) |
204 | } |
205 | } |
206 | |
207 | #[doc (alias = "gst_pad_get_parent_element" )] |
208 | #[doc (alias = "get_parent_element" )] |
209 | fn parent_element(&self) -> Option<Element> { |
210 | unsafe { |
211 | from_glib_full(ffi::gst_pad_get_parent_element( |
212 | self.as_ref().to_glib_none().0, |
213 | )) |
214 | } |
215 | } |
216 | |
217 | #[doc (alias = "gst_pad_get_peer" )] |
218 | #[doc (alias = "get_peer" )] |
219 | #[must_use ] |
220 | fn peer(&self) -> Option<Pad> { |
221 | unsafe { from_glib_full(ffi::gst_pad_get_peer(self.as_ref().to_glib_none().0)) } |
222 | } |
223 | |
224 | #[cfg (feature = "v1_18" )] |
225 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_18" )))] |
226 | #[doc (alias = "gst_pad_get_single_internal_link" )] |
227 | #[doc (alias = "get_single_internal_link" )] |
228 | #[must_use ] |
229 | fn single_internal_link(&self) -> Option<Pad> { |
230 | unsafe { |
231 | from_glib_full(ffi::gst_pad_get_single_internal_link( |
232 | self.as_ref().to_glib_none().0, |
233 | )) |
234 | } |
235 | } |
236 | |
237 | #[doc (alias = "gst_pad_get_stream" )] |
238 | #[doc (alias = "get_stream" )] |
239 | fn stream(&self) -> Option<Stream> { |
240 | unsafe { from_glib_full(ffi::gst_pad_get_stream(self.as_ref().to_glib_none().0)) } |
241 | } |
242 | |
243 | #[doc (alias = "gst_pad_get_stream_id" )] |
244 | #[doc (alias = "get_stream_id" )] |
245 | fn stream_id(&self) -> Option<glib::GString> { |
246 | unsafe { from_glib_full(ffi::gst_pad_get_stream_id(self.as_ref().to_glib_none().0)) } |
247 | } |
248 | |
249 | #[doc (alias = "gst_pad_get_task_state" )] |
250 | #[doc (alias = "get_task_state" )] |
251 | fn task_state(&self) -> TaskState { |
252 | unsafe { from_glib(ffi::gst_pad_get_task_state(self.as_ref().to_glib_none().0)) } |
253 | } |
254 | |
255 | #[doc (alias = "gst_pad_has_current_caps" )] |
256 | fn has_current_caps(&self) -> bool { |
257 | unsafe { |
258 | from_glib(ffi::gst_pad_has_current_caps( |
259 | self.as_ref().to_glib_none().0, |
260 | )) |
261 | } |
262 | } |
263 | |
264 | #[doc (alias = "gst_pad_is_active" )] |
265 | fn is_active(&self) -> bool { |
266 | unsafe { from_glib(ffi::gst_pad_is_active(self.as_ref().to_glib_none().0)) } |
267 | } |
268 | |
269 | #[doc (alias = "gst_pad_is_blocked" )] |
270 | fn is_blocked(&self) -> bool { |
271 | unsafe { from_glib(ffi::gst_pad_is_blocked(self.as_ref().to_glib_none().0)) } |
272 | } |
273 | |
274 | #[doc (alias = "gst_pad_is_blocking" )] |
275 | fn is_blocking(&self) -> bool { |
276 | unsafe { from_glib(ffi::gst_pad_is_blocking(self.as_ref().to_glib_none().0)) } |
277 | } |
278 | |
279 | #[doc (alias = "gst_pad_is_linked" )] |
280 | fn is_linked(&self) -> bool { |
281 | unsafe { from_glib(ffi::gst_pad_is_linked(self.as_ref().to_glib_none().0)) } |
282 | } |
283 | |
284 | //#[doc(alias = "gst_pad_iterate_internal_links")] |
285 | //fn iterate_internal_links(&self) -> /*Ignored*/Option<Iterator> { |
286 | // unsafe { TODO: call ffi:gst_pad_iterate_internal_links() } |
287 | //} |
288 | |
289 | //#[doc(alias = "gst_pad_iterate_internal_links_default")] |
290 | //fn iterate_internal_links_default(&self, parent: Option<&impl IsA<Object>>) -> /*Ignored*/Option<Iterator> { |
291 | // unsafe { TODO: call ffi:gst_pad_iterate_internal_links_default() } |
292 | //} |
293 | |
294 | #[doc (alias = "gst_pad_link" )] |
295 | fn link(&self, sinkpad: &impl IsA<Pad>) -> Result<PadLinkSuccess, PadLinkError> { |
296 | unsafe { |
297 | try_from_glib(ffi::gst_pad_link( |
298 | self.as_ref().to_glib_none().0, |
299 | sinkpad.as_ref().to_glib_none().0, |
300 | )) |
301 | } |
302 | } |
303 | |
304 | #[doc (alias = "gst_pad_link_full" )] |
305 | fn link_full( |
306 | &self, |
307 | sinkpad: &impl IsA<Pad>, |
308 | flags: PadLinkCheck, |
309 | ) -> Result<PadLinkSuccess, PadLinkError> { |
310 | unsafe { |
311 | try_from_glib(ffi::gst_pad_link_full( |
312 | self.as_ref().to_glib_none().0, |
313 | sinkpad.as_ref().to_glib_none().0, |
314 | flags.into_glib(), |
315 | )) |
316 | } |
317 | } |
318 | |
319 | #[doc (alias = "gst_pad_link_maybe_ghosting" )] |
320 | fn link_maybe_ghosting(&self, sink: &impl IsA<Pad>) -> Result<(), glib::error::BoolError> { |
321 | unsafe { |
322 | glib::result_from_gboolean!( |
323 | ffi::gst_pad_link_maybe_ghosting( |
324 | self.as_ref().to_glib_none().0, |
325 | sink.as_ref().to_glib_none().0 |
326 | ), |
327 | "Failed to link pads, possibly ghosting" |
328 | ) |
329 | } |
330 | } |
331 | |
332 | #[doc (alias = "gst_pad_link_maybe_ghosting_full" )] |
333 | fn link_maybe_ghosting_full( |
334 | &self, |
335 | sink: &impl IsA<Pad>, |
336 | flags: PadLinkCheck, |
337 | ) -> Result<(), glib::error::BoolError> { |
338 | unsafe { |
339 | glib::result_from_gboolean!( |
340 | ffi::gst_pad_link_maybe_ghosting_full( |
341 | self.as_ref().to_glib_none().0, |
342 | sink.as_ref().to_glib_none().0, |
343 | flags.into_glib() |
344 | ), |
345 | "Failed to link pads, possibly ghosting" |
346 | ) |
347 | } |
348 | } |
349 | |
350 | #[doc (alias = "gst_pad_mark_reconfigure" )] |
351 | fn mark_reconfigure(&self) { |
352 | unsafe { |
353 | ffi::gst_pad_mark_reconfigure(self.as_ref().to_glib_none().0); |
354 | } |
355 | } |
356 | |
357 | #[doc (alias = "gst_pad_needs_reconfigure" )] |
358 | fn needs_reconfigure(&self) -> bool { |
359 | unsafe { |
360 | from_glib(ffi::gst_pad_needs_reconfigure( |
361 | self.as_ref().to_glib_none().0, |
362 | )) |
363 | } |
364 | } |
365 | |
366 | #[doc (alias = "gst_pad_pause_task" )] |
367 | fn pause_task(&self) -> Result<(), glib::error::BoolError> { |
368 | unsafe { |
369 | glib::result_from_gboolean!( |
370 | ffi::gst_pad_pause_task(self.as_ref().to_glib_none().0), |
371 | "Failed to pause pad task" |
372 | ) |
373 | } |
374 | } |
375 | |
376 | #[doc (alias = "gst_pad_peer_query_accept_caps" )] |
377 | fn peer_query_accept_caps(&self, caps: &Caps) -> bool { |
378 | unsafe { |
379 | from_glib(ffi::gst_pad_peer_query_accept_caps( |
380 | self.as_ref().to_glib_none().0, |
381 | caps.to_glib_none().0, |
382 | )) |
383 | } |
384 | } |
385 | |
386 | #[doc (alias = "gst_pad_peer_query_caps" )] |
387 | fn peer_query_caps(&self, filter: Option<&Caps>) -> Caps { |
388 | unsafe { |
389 | from_glib_full(ffi::gst_pad_peer_query_caps( |
390 | self.as_ref().to_glib_none().0, |
391 | filter.to_glib_none().0, |
392 | )) |
393 | } |
394 | } |
395 | |
396 | #[doc (alias = "gst_pad_push" )] |
397 | fn push(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> { |
398 | unsafe { |
399 | try_from_glib(ffi::gst_pad_push( |
400 | self.as_ref().to_glib_none().0, |
401 | buffer.into_glib_ptr(), |
402 | )) |
403 | } |
404 | } |
405 | |
406 | #[doc (alias = "gst_pad_push_list" )] |
407 | fn push_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> { |
408 | unsafe { |
409 | try_from_glib(ffi::gst_pad_push_list( |
410 | self.as_ref().to_glib_none().0, |
411 | list.into_glib_ptr(), |
412 | )) |
413 | } |
414 | } |
415 | |
416 | #[doc (alias = "gst_pad_query_accept_caps" )] |
417 | fn query_accept_caps(&self, caps: &Caps) -> bool { |
418 | unsafe { |
419 | from_glib(ffi::gst_pad_query_accept_caps( |
420 | self.as_ref().to_glib_none().0, |
421 | caps.to_glib_none().0, |
422 | )) |
423 | } |
424 | } |
425 | |
426 | #[doc (alias = "gst_pad_query_caps" )] |
427 | fn query_caps(&self, filter: Option<&Caps>) -> Caps { |
428 | unsafe { |
429 | from_glib_full(ffi::gst_pad_query_caps( |
430 | self.as_ref().to_glib_none().0, |
431 | filter.to_glib_none().0, |
432 | )) |
433 | } |
434 | } |
435 | |
436 | #[doc (alias = "gst_pad_set_active" )] |
437 | fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError> { |
438 | unsafe { |
439 | glib::result_from_gboolean!( |
440 | ffi::gst_pad_set_active(self.as_ref().to_glib_none().0, active.into_glib()), |
441 | "Failed to activate pad" |
442 | ) |
443 | } |
444 | } |
445 | |
446 | //#[doc(alias = "gst_pad_set_element_private")] |
447 | //fn set_element_private(&self, priv_: /*Unimplemented*/Option<Basic: Pointer>) { |
448 | // unsafe { TODO: call ffi:gst_pad_set_element_private() } |
449 | //} |
450 | |
451 | #[doc (alias = "gst_pad_set_offset" )] |
452 | fn set_offset(&self, offset: i64) { |
453 | unsafe { |
454 | ffi::gst_pad_set_offset(self.as_ref().to_glib_none().0, offset); |
455 | } |
456 | } |
457 | |
458 | #[doc (alias = "gst_pad_stop_task" )] |
459 | fn stop_task(&self) -> Result<(), glib::error::BoolError> { |
460 | unsafe { |
461 | glib::result_from_gboolean!( |
462 | ffi::gst_pad_stop_task(self.as_ref().to_glib_none().0), |
463 | "Failed to stop pad task" |
464 | ) |
465 | } |
466 | } |
467 | |
468 | #[doc (alias = "gst_pad_store_sticky_event" )] |
469 | fn store_sticky_event(&self, event: &Event) -> Result<FlowSuccess, FlowError> { |
470 | unsafe { |
471 | try_from_glib(ffi::gst_pad_store_sticky_event( |
472 | self.as_ref().to_glib_none().0, |
473 | event.to_glib_none().0, |
474 | )) |
475 | } |
476 | } |
477 | |
478 | #[doc (alias = "gst_pad_unlink" )] |
479 | fn unlink(&self, sinkpad: &impl IsA<Pad>) -> Result<(), glib::error::BoolError> { |
480 | unsafe { |
481 | glib::result_from_gboolean!( |
482 | ffi::gst_pad_unlink( |
483 | self.as_ref().to_glib_none().0, |
484 | sinkpad.as_ref().to_glib_none().0 |
485 | ), |
486 | "Failed to unlink pad" |
487 | ) |
488 | } |
489 | } |
490 | |
491 | #[doc (alias = "gst_pad_use_fixed_caps" )] |
492 | fn use_fixed_caps(&self) { |
493 | unsafe { |
494 | ffi::gst_pad_use_fixed_caps(self.as_ref().to_glib_none().0); |
495 | } |
496 | } |
497 | |
498 | fn caps(&self) -> Option<Caps> { |
499 | ObjectExt::property(self.as_ref(), "caps" ) |
500 | } |
501 | |
502 | #[doc (alias = "linked" )] |
503 | fn connect_linked<F: Fn(&Self, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { |
504 | unsafe extern "C" fn linked_trampoline< |
505 | P: IsA<Pad>, |
506 | F: Fn(&P, &Pad) + Send + Sync + 'static, |
507 | >( |
508 | this: *mut ffi::GstPad, |
509 | peer: *mut ffi::GstPad, |
510 | f: glib::ffi::gpointer, |
511 | ) { |
512 | let f: &F = &*(f as *const F); |
513 | f( |
514 | Pad::from_glib_borrow(this).unsafe_cast_ref(), |
515 | &from_glib_borrow(peer), |
516 | ) |
517 | } |
518 | unsafe { |
519 | let f: Box_<F> = Box_::new(f); |
520 | connect_raw( |
521 | self.as_ptr() as *mut _, |
522 | b"linked \0" .as_ptr() as *const _, |
523 | Some(transmute::<_, unsafe extern "C" fn()>( |
524 | linked_trampoline::<Self, F> as *const (), |
525 | )), |
526 | Box_::into_raw(f), |
527 | ) |
528 | } |
529 | } |
530 | |
531 | #[doc (alias = "unlinked" )] |
532 | fn connect_unlinked<F: Fn(&Self, &Pad) + Send + Sync + 'static>( |
533 | &self, |
534 | f: F, |
535 | ) -> SignalHandlerId { |
536 | unsafe extern "C" fn unlinked_trampoline< |
537 | P: IsA<Pad>, |
538 | F: Fn(&P, &Pad) + Send + Sync + 'static, |
539 | >( |
540 | this: *mut ffi::GstPad, |
541 | peer: *mut ffi::GstPad, |
542 | f: glib::ffi::gpointer, |
543 | ) { |
544 | let f: &F = &*(f as *const F); |
545 | f( |
546 | Pad::from_glib_borrow(this).unsafe_cast_ref(), |
547 | &from_glib_borrow(peer), |
548 | ) |
549 | } |
550 | unsafe { |
551 | let f: Box_<F> = Box_::new(f); |
552 | connect_raw( |
553 | self.as_ptr() as *mut _, |
554 | b"unlinked \0" .as_ptr() as *const _, |
555 | Some(transmute::<_, unsafe extern "C" fn()>( |
556 | unlinked_trampoline::<Self, F> as *const (), |
557 | )), |
558 | Box_::into_raw(f), |
559 | ) |
560 | } |
561 | } |
562 | |
563 | #[doc (alias = "caps" )] |
564 | fn connect_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { |
565 | unsafe extern "C" fn notify_caps_trampoline< |
566 | P: IsA<Pad>, |
567 | F: Fn(&P) + Send + Sync + 'static, |
568 | >( |
569 | this: *mut ffi::GstPad, |
570 | _param_spec: glib::ffi::gpointer, |
571 | f: glib::ffi::gpointer, |
572 | ) { |
573 | let f: &F = &*(f as *const F); |
574 | f(Pad::from_glib_borrow(this).unsafe_cast_ref()) |
575 | } |
576 | unsafe { |
577 | let f: Box_<F> = Box_::new(f); |
578 | connect_raw( |
579 | self.as_ptr() as *mut _, |
580 | b"notify::caps \0" .as_ptr() as *const _, |
581 | Some(transmute::<_, unsafe extern "C" fn()>( |
582 | notify_caps_trampoline::<Self, F> as *const (), |
583 | )), |
584 | Box_::into_raw(f), |
585 | ) |
586 | } |
587 | } |
588 | |
589 | #[doc (alias = "offset" )] |
590 | fn connect_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { |
591 | unsafe extern "C" fn notify_offset_trampoline< |
592 | P: IsA<Pad>, |
593 | F: Fn(&P) + Send + Sync + 'static, |
594 | >( |
595 | this: *mut ffi::GstPad, |
596 | _param_spec: glib::ffi::gpointer, |
597 | f: glib::ffi::gpointer, |
598 | ) { |
599 | let f: &F = &*(f as *const F); |
600 | f(Pad::from_glib_borrow(this).unsafe_cast_ref()) |
601 | } |
602 | unsafe { |
603 | let f: Box_<F> = Box_::new(f); |
604 | connect_raw( |
605 | self.as_ptr() as *mut _, |
606 | b"notify::offset \0" .as_ptr() as *const _, |
607 | Some(transmute::<_, unsafe extern "C" fn()>( |
608 | notify_offset_trampoline::<Self, F> as *const (), |
609 | )), |
610 | Box_::into_raw(f), |
611 | ) |
612 | } |
613 | } |
614 | } |
615 | |
616 | impl<O: IsA<Pad>> PadExt for O {} |
617 | |