Skip to main content

gstreamer_play/auto/
play_signal_adapter.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::{Play, PlayMediaInfo, PlayState, 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    ///
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `play`
22    ///  Readable
23    ///
24    /// ## Signals
25    ///
26    ///
27    /// #### `buffering`
28    ///
29    ///
30    ///
31    /// #### `duration-changed`
32    ///
33    ///
34    ///
35    /// #### `end-of-stream`
36    ///
37    ///
38    ///
39    /// #### `error`
40    ///  Emitted on errors.
41    ///
42    ///
43    ///
44    ///
45    /// #### `media-info-updated`
46    ///
47    ///
48    ///
49    /// #### `mute-changed`
50    ///
51    ///
52    ///
53    /// #### `position-updated`
54    ///
55    ///
56    ///
57    /// #### `seek-done`
58    ///
59    ///
60    ///
61    /// #### `state-changed`
62    ///
63    ///
64    ///
65    /// #### `tracks-selected`
66    ///  Emitted on warnings.
67    ///
68    ///
69    ///
70    ///
71    /// #### `uri-loaded`
72    ///
73    ///
74    ///
75    /// #### `video-dimensions-changed`
76    ///
77    ///
78    ///
79    /// #### `volume-changed`
80    ///
81    ///
82    ///
83    /// #### `warning`
84    ///  Emitted on warnings.
85    ///
86    ///
87    ///
88    /// # Implements
89    ///
90    /// [`trait@glib::ObjectExt`]
91    #[doc(alias = "GstPlaySignalAdapter")]
92    pub struct PlaySignalAdapter(Object<ffi::GstPlaySignalAdapter, ffi::GstPlaySignalAdapterClass>);
93
94    match fn {
95        type_ => || ffi::gst_play_signal_adapter_get_type(),
96    }
97}
98
99impl PlaySignalAdapter {
100    /// A bus-watching `GSource` will be created and attached to the the
101    /// thread-default [`glib::MainContext`][crate::glib::MainContext]. The attached callback will emit the
102    /// corresponding signal for the message received. Matching signals for play
103    /// messages from the bus will be emitted by it on the created adapter object.
104    /// ## `play`
105    /// [`Play`][crate::Play] instance to emit signals for.
106    ///
107    /// # Returns
108    ///
109    /// A new [`PlaySignalAdapter`][crate::PlaySignalAdapter] to connect signal handlers to.
110    #[doc(alias = "gst_play_signal_adapter_new")]
111    pub fn new(play: &Play) -> PlaySignalAdapter {
112        skip_assert_initialized!();
113        unsafe { from_glib_full(ffi::gst_play_signal_adapter_new(play.to_glib_none().0)) }
114    }
115
116    /// Create an adapter that synchronously emits its signals, from the thread in
117    /// which the messages have been posted.
118    /// ## `play`
119    /// [`Play`][crate::Play] instance to emit signals for.
120    ///
121    /// # Returns
122    ///
123    /// A new [`PlaySignalAdapter`][crate::PlaySignalAdapter] to connect signal handlers to.
124    #[doc(alias = "gst_play_signal_adapter_new_sync_emit")]
125    pub fn new_sync_emit(play: &Play) -> PlaySignalAdapter {
126        skip_assert_initialized!();
127        unsafe {
128            from_glib_full(ffi::gst_play_signal_adapter_new_sync_emit(
129                play.to_glib_none().0,
130            ))
131        }
132    }
133
134    /// A bus-watching `GSource` will be created and attached to the `context`. The
135    /// attached callback will emit the corresponding signal for the message
136    /// received. Matching signals for play messages from the bus will be emitted by
137    /// it on the created adapter object.
138    /// ## `play`
139    /// [`Play`][crate::Play] instance to emit signals for.
140    /// ## `context`
141    /// A [`glib::MainContext`][crate::glib::MainContext] on which the main-loop will process play bus messages on.
142    ///
143    /// # Returns
144    ///
145    /// A new [`PlaySignalAdapter`][crate::PlaySignalAdapter] to connect signal handlers to.
146    #[doc(alias = "gst_play_signal_adapter_new_with_main_context")]
147    #[doc(alias = "new_with_main_context")]
148    pub fn with_main_context(play: &Play, context: &glib::MainContext) -> PlaySignalAdapter {
149        skip_assert_initialized!();
150        unsafe {
151            from_glib_full(ffi::gst_play_signal_adapter_new_with_main_context(
152                play.to_glib_none().0,
153                context.to_glib_none().0,
154            ))
155        }
156    }
157
158    ///
159    /// # Returns
160    ///
161    /// The [`Play`][crate::Play] owning this signal adapter.
162    #[doc(alias = "gst_play_signal_adapter_get_play")]
163    #[doc(alias = "get_play")]
164    pub fn play(&self) -> Play {
165        unsafe { from_glib_none(ffi::gst_play_signal_adapter_get_play(self.to_glib_none().0)) }
166    }
167
168    #[doc(alias = "buffering")]
169    pub fn connect_buffering<F: Fn(&Self, i32) + Send + 'static>(&self, f: F) -> SignalHandlerId {
170        unsafe extern "C" fn buffering_trampoline<
171            F: Fn(&PlaySignalAdapter, i32) + Send + 'static,
172        >(
173            this: *mut ffi::GstPlaySignalAdapter,
174            object: std::ffi::c_int,
175            f: glib::ffi::gpointer,
176        ) {
177            unsafe {
178                let f: &F = &*(f as *const F);
179                f(&from_glib_borrow(this), object)
180            }
181        }
182        unsafe {
183            let f: Box_<F> = Box_::new(f);
184            connect_raw(
185                self.as_ptr() as *mut _,
186                c"buffering".as_ptr(),
187                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
188                    buffering_trampoline::<F> as *const (),
189                )),
190                Box_::into_raw(f),
191            )
192        }
193    }
194
195    #[doc(alias = "end-of-stream")]
196    pub fn connect_end_of_stream<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
197        unsafe extern "C" fn end_of_stream_trampoline<
198            F: Fn(&PlaySignalAdapter) + Send + 'static,
199        >(
200            this: *mut ffi::GstPlaySignalAdapter,
201            f: glib::ffi::gpointer,
202        ) {
203            unsafe {
204                let f: &F = &*(f as *const F);
205                f(&from_glib_borrow(this))
206            }
207        }
208        unsafe {
209            let f: Box_<F> = Box_::new(f);
210            connect_raw(
211                self.as_ptr() as *mut _,
212                c"end-of-stream".as_ptr(),
213                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
214                    end_of_stream_trampoline::<F> as *const (),
215                )),
216                Box_::into_raw(f),
217            )
218        }
219    }
220
221    /// Emitted on errors.
222    /// ## `error`
223    /// The error
224    /// ## `details`
225    /// Additional error details
226    #[doc(alias = "error")]
227    pub fn connect_error<F: Fn(&Self, &glib::Error, Option<&gst::Structure>) + Send + 'static>(
228        &self,
229        f: F,
230    ) -> SignalHandlerId {
231        unsafe extern "C" fn error_trampoline<
232            F: Fn(&PlaySignalAdapter, &glib::Error, Option<&gst::Structure>) + Send + 'static,
233        >(
234            this: *mut ffi::GstPlaySignalAdapter,
235            error: *mut glib::ffi::GError,
236            details: *mut gst::ffi::GstStructure,
237            f: glib::ffi::gpointer,
238        ) {
239            unsafe {
240                let f: &F = &*(f as *const F);
241                f(
242                    &from_glib_borrow(this),
243                    &from_glib_borrow(error),
244                    Option::<gst::Structure>::from_glib_borrow(details)
245                        .as_ref()
246                        .as_ref(),
247                )
248            }
249        }
250        unsafe {
251            let f: Box_<F> = Box_::new(f);
252            connect_raw(
253                self.as_ptr() as *mut _,
254                c"error".as_ptr(),
255                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
256                    error_trampoline::<F> as *const (),
257                )),
258                Box_::into_raw(f),
259            )
260        }
261    }
262
263    #[doc(alias = "media-info-updated")]
264    pub fn connect_media_info_updated<F: Fn(&Self, &PlayMediaInfo) + Send + 'static>(
265        &self,
266        f: F,
267    ) -> SignalHandlerId {
268        unsafe extern "C" fn media_info_updated_trampoline<
269            F: Fn(&PlaySignalAdapter, &PlayMediaInfo) + Send + 'static,
270        >(
271            this: *mut ffi::GstPlaySignalAdapter,
272            object: *mut ffi::GstPlayMediaInfo,
273            f: glib::ffi::gpointer,
274        ) {
275            unsafe {
276                let f: &F = &*(f as *const F);
277                f(&from_glib_borrow(this), &from_glib_borrow(object))
278            }
279        }
280        unsafe {
281            let f: Box_<F> = Box_::new(f);
282            connect_raw(
283                self.as_ptr() as *mut _,
284                c"media-info-updated".as_ptr(),
285                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
286                    media_info_updated_trampoline::<F> as *const (),
287                )),
288                Box_::into_raw(f),
289            )
290        }
291    }
292
293    #[doc(alias = "mute-changed")]
294    pub fn connect_mute_changed<F: Fn(&Self, bool) + Send + 'static>(
295        &self,
296        f: F,
297    ) -> SignalHandlerId {
298        unsafe extern "C" fn mute_changed_trampoline<
299            F: Fn(&PlaySignalAdapter, bool) + Send + 'static,
300        >(
301            this: *mut ffi::GstPlaySignalAdapter,
302            object: glib::ffi::gboolean,
303            f: glib::ffi::gpointer,
304        ) {
305            unsafe {
306                let f: &F = &*(f as *const F);
307                f(&from_glib_borrow(this), from_glib(object))
308            }
309        }
310        unsafe {
311            let f: Box_<F> = Box_::new(f);
312            connect_raw(
313                self.as_ptr() as *mut _,
314                c"mute-changed".as_ptr(),
315                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
316                    mute_changed_trampoline::<F> as *const (),
317                )),
318                Box_::into_raw(f),
319            )
320        }
321    }
322
323    #[doc(alias = "state-changed")]
324    pub fn connect_state_changed<F: Fn(&Self, PlayState) + Send + 'static>(
325        &self,
326        f: F,
327    ) -> SignalHandlerId {
328        unsafe extern "C" fn state_changed_trampoline<
329            F: Fn(&PlaySignalAdapter, PlayState) + Send + 'static,
330        >(
331            this: *mut ffi::GstPlaySignalAdapter,
332            object: ffi::GstPlayState,
333            f: glib::ffi::gpointer,
334        ) {
335            unsafe {
336                let f: &F = &*(f as *const F);
337                f(&from_glib_borrow(this), from_glib(object))
338            }
339        }
340        unsafe {
341            let f: Box_<F> = Box_::new(f);
342            connect_raw(
343                self.as_ptr() as *mut _,
344                c"state-changed".as_ptr(),
345                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
346                    state_changed_trampoline::<F> as *const (),
347                )),
348                Box_::into_raw(f),
349            )
350        }
351    }
352
353    /// Emitted on warnings.
354    /// ## `audio_track_id`
355    /// the selected audio track id
356    /// ## `video_track_id`
357    /// the selected video track id
358    /// ## `subtitle_track_id`
359    /// the selected subtitle track id
360    #[cfg(feature = "v1_30")]
361    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
362    #[doc(alias = "tracks-selected")]
363    pub fn connect_tracks_selected<
364        F: Fn(&Self, Option<&str>, Option<&str>, Option<&str>) + Send + Sync + 'static,
365    >(
366        &self,
367        f: F,
368    ) -> SignalHandlerId {
369        unsafe extern "C" fn tracks_selected_trampoline<
370            F: Fn(&PlaySignalAdapter, Option<&str>, Option<&str>, Option<&str>)
371                + Send
372                + Sync
373                + 'static,
374        >(
375            this: *mut ffi::GstPlaySignalAdapter,
376            audio_track_id: *mut std::ffi::c_char,
377            video_track_id: *mut std::ffi::c_char,
378            subtitle_track_id: *mut std::ffi::c_char,
379            f: glib::ffi::gpointer,
380        ) {
381            unsafe {
382                let f: &F = &*(f as *const F);
383                f(
384                    &from_glib_borrow(this),
385                    Option::<glib::GString>::from_glib_borrow(audio_track_id)
386                        .as_ref()
387                        .as_ref()
388                        .map(|s| s.as_str()),
389                    Option::<glib::GString>::from_glib_borrow(video_track_id)
390                        .as_ref()
391                        .as_ref()
392                        .map(|s| s.as_str()),
393                    Option::<glib::GString>::from_glib_borrow(subtitle_track_id)
394                        .as_ref()
395                        .as_ref()
396                        .map(|s| s.as_str()),
397                )
398            }
399        }
400        unsafe {
401            let f: Box_<F> = Box_::new(f);
402            connect_raw(
403                self.as_ptr() as *mut _,
404                c"tracks-selected".as_ptr(),
405                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
406                    tracks_selected_trampoline::<F> as *const (),
407                )),
408                Box_::into_raw(f),
409            )
410        }
411    }
412
413    #[doc(alias = "uri-loaded")]
414    pub fn connect_uri_loaded<F: Fn(&Self, &str) + Send + 'static>(&self, f: F) -> SignalHandlerId {
415        unsafe extern "C" fn uri_loaded_trampoline<
416            F: Fn(&PlaySignalAdapter, &str) + Send + 'static,
417        >(
418            this: *mut ffi::GstPlaySignalAdapter,
419            object: *mut std::ffi::c_char,
420            f: glib::ffi::gpointer,
421        ) {
422            unsafe {
423                let f: &F = &*(f as *const F);
424                f(
425                    &from_glib_borrow(this),
426                    &glib::GString::from_glib_borrow(object),
427                )
428            }
429        }
430        unsafe {
431            let f: Box_<F> = Box_::new(f);
432            connect_raw(
433                self.as_ptr() as *mut _,
434                c"uri-loaded".as_ptr(),
435                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
436                    uri_loaded_trampoline::<F> as *const (),
437                )),
438                Box_::into_raw(f),
439            )
440        }
441    }
442
443    #[doc(alias = "video-dimensions-changed")]
444    pub fn connect_video_dimensions_changed<F: Fn(&Self, u32, u32) + Send + 'static>(
445        &self,
446        f: F,
447    ) -> SignalHandlerId {
448        unsafe extern "C" fn video_dimensions_changed_trampoline<
449            F: Fn(&PlaySignalAdapter, u32, u32) + Send + 'static,
450        >(
451            this: *mut ffi::GstPlaySignalAdapter,
452            object: std::ffi::c_uint,
453            p0: std::ffi::c_uint,
454            f: glib::ffi::gpointer,
455        ) {
456            unsafe {
457                let f: &F = &*(f as *const F);
458                f(&from_glib_borrow(this), object, p0)
459            }
460        }
461        unsafe {
462            let f: Box_<F> = Box_::new(f);
463            connect_raw(
464                self.as_ptr() as *mut _,
465                c"video-dimensions-changed".as_ptr(),
466                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
467                    video_dimensions_changed_trampoline::<F> as *const (),
468                )),
469                Box_::into_raw(f),
470            )
471        }
472    }
473
474    #[doc(alias = "volume-changed")]
475    pub fn connect_volume_changed<F: Fn(&Self, f64) + Send + 'static>(
476        &self,
477        f: F,
478    ) -> SignalHandlerId {
479        unsafe extern "C" fn volume_changed_trampoline<
480            F: Fn(&PlaySignalAdapter, f64) + Send + 'static,
481        >(
482            this: *mut ffi::GstPlaySignalAdapter,
483            object: std::ffi::c_double,
484            f: glib::ffi::gpointer,
485        ) {
486            unsafe {
487                let f: &F = &*(f as *const F);
488                f(&from_glib_borrow(this), object)
489            }
490        }
491        unsafe {
492            let f: Box_<F> = Box_::new(f);
493            connect_raw(
494                self.as_ptr() as *mut _,
495                c"volume-changed".as_ptr(),
496                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
497                    volume_changed_trampoline::<F> as *const (),
498                )),
499                Box_::into_raw(f),
500            )
501        }
502    }
503
504    /// Emitted on warnings.
505    /// ## `error`
506    /// The warning
507    /// ## `details`
508    /// Additional warning details
509    #[doc(alias = "warning")]
510    pub fn connect_warning<F: Fn(&Self, &glib::Error, Option<&gst::Structure>) + Send + 'static>(
511        &self,
512        f: F,
513    ) -> SignalHandlerId {
514        unsafe extern "C" fn warning_trampoline<
515            F: Fn(&PlaySignalAdapter, &glib::Error, Option<&gst::Structure>) + Send + 'static,
516        >(
517            this: *mut ffi::GstPlaySignalAdapter,
518            error: *mut glib::ffi::GError,
519            details: *mut gst::ffi::GstStructure,
520            f: glib::ffi::gpointer,
521        ) {
522            unsafe {
523                let f: &F = &*(f as *const F);
524                f(
525                    &from_glib_borrow(this),
526                    &from_glib_borrow(error),
527                    Option::<gst::Structure>::from_glib_borrow(details)
528                        .as_ref()
529                        .as_ref(),
530                )
531            }
532        }
533        unsafe {
534            let f: Box_<F> = Box_::new(f);
535            connect_raw(
536                self.as_ptr() as *mut _,
537                c"warning".as_ptr(),
538                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
539                    warning_trampoline::<F> as *const (),
540                )),
541                Box_::into_raw(f),
542            )
543        }
544    }
545
546    #[doc(alias = "play")]
547    pub fn connect_play_notify<F: Fn(&Self) + Send + Sync + 'static>(
548        &self,
549        f: F,
550    ) -> SignalHandlerId {
551        unsafe extern "C" fn notify_play_trampoline<
552            F: Fn(&PlaySignalAdapter) + Send + Sync + 'static,
553        >(
554            this: *mut ffi::GstPlaySignalAdapter,
555            _param_spec: glib::ffi::gpointer,
556            f: glib::ffi::gpointer,
557        ) {
558            unsafe {
559                let f: &F = &*(f as *const F);
560                f(&from_glib_borrow(this))
561            }
562        }
563        unsafe {
564            let f: Box_<F> = Box_::new(f);
565            connect_raw(
566                self.as_ptr() as *mut _,
567                c"notify::play".as_ptr(),
568                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
569                    notify_play_trampoline::<F> as *const (),
570                )),
571                Box_::into_raw(f),
572            )
573        }
574    }
575}
576
577unsafe impl Send for PlaySignalAdapter {}
578unsafe impl Sync for PlaySignalAdapter {}