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::{ffi, Play, PlayMediaInfo, PlayState};
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{connect_raw, SignalHandlerId},
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    /// #### `uri-loaded`
66    ///
67    ///
68    ///
69    /// #### `video-dimensions-changed`
70    ///
71    ///
72    ///
73    /// #### `volume-changed`
74    ///
75    ///
76    ///
77    /// #### `warning`
78    ///  Emitted on warnings.
79    ///
80    ///
81    ///
82    /// # Implements
83    ///
84    /// [`trait@glib::ObjectExt`]
85    #[doc(alias = "GstPlaySignalAdapter")]
86    pub struct PlaySignalAdapter(Object<ffi::GstPlaySignalAdapter, ffi::GstPlaySignalAdapterClass>);
87
88    match fn {
89        type_ => || ffi::gst_play_signal_adapter_get_type(),
90    }
91}
92
93impl PlaySignalAdapter {
94    /// A bus-watching `GSource` will be created and attached to the the
95    /// thread-default [`glib::MainContext`][crate::glib::MainContext]. The attached callback will emit the
96    /// corresponding signal for the message received. Matching signals for play
97    /// messages from the bus will be emitted by it on the created adapter object.
98    /// ## `play`
99    /// [`Play`][crate::Play] instance to emit signals for.
100    ///
101    /// # Returns
102    ///
103    /// A new [`PlaySignalAdapter`][crate::PlaySignalAdapter] to connect signal handlers to.
104    #[doc(alias = "gst_play_signal_adapter_new")]
105    pub fn new(play: &Play) -> PlaySignalAdapter {
106        skip_assert_initialized!();
107        unsafe { from_glib_full(ffi::gst_play_signal_adapter_new(play.to_glib_none().0)) }
108    }
109
110    /// Create an adapter that synchronously emits its signals, from the thread in
111    /// which the messages have been posted.
112    /// ## `play`
113    /// [`Play`][crate::Play] instance to emit signals for.
114    ///
115    /// # Returns
116    ///
117    /// A new [`PlaySignalAdapter`][crate::PlaySignalAdapter] to connect signal handlers to.
118    #[doc(alias = "gst_play_signal_adapter_new_sync_emit")]
119    pub fn new_sync_emit(play: &Play) -> PlaySignalAdapter {
120        skip_assert_initialized!();
121        unsafe {
122            from_glib_full(ffi::gst_play_signal_adapter_new_sync_emit(
123                play.to_glib_none().0,
124            ))
125        }
126    }
127
128    /// A bus-watching `GSource` will be created and attached to the `context`. The
129    /// attached callback will emit the corresponding signal for the message
130    /// received. Matching signals for play messages from the bus will be emitted by
131    /// it on the created adapter object.
132    /// ## `play`
133    /// [`Play`][crate::Play] instance to emit signals for.
134    /// ## `context`
135    /// A [`glib::MainContext`][crate::glib::MainContext] on which the main-loop will process play bus messages on.
136    ///
137    /// # Returns
138    ///
139    /// A new [`PlaySignalAdapter`][crate::PlaySignalAdapter] to connect signal handlers to.
140    #[doc(alias = "gst_play_signal_adapter_new_with_main_context")]
141    #[doc(alias = "new_with_main_context")]
142    pub fn with_main_context(play: &Play, context: &glib::MainContext) -> PlaySignalAdapter {
143        skip_assert_initialized!();
144        unsafe {
145            from_glib_full(ffi::gst_play_signal_adapter_new_with_main_context(
146                play.to_glib_none().0,
147                context.to_glib_none().0,
148            ))
149        }
150    }
151
152    ///
153    /// # Returns
154    ///
155    /// The [`Play`][crate::Play] owning this signal adapter.
156    #[doc(alias = "gst_play_signal_adapter_get_play")]
157    #[doc(alias = "get_play")]
158    pub fn play(&self) -> Play {
159        unsafe { from_glib_none(ffi::gst_play_signal_adapter_get_play(self.to_glib_none().0)) }
160    }
161
162    #[doc(alias = "buffering")]
163    pub fn connect_buffering<F: Fn(&Self, i32) + Send + 'static>(&self, f: F) -> SignalHandlerId {
164        unsafe extern "C" fn buffering_trampoline<
165            F: Fn(&PlaySignalAdapter, i32) + Send + 'static,
166        >(
167            this: *mut ffi::GstPlaySignalAdapter,
168            object: std::ffi::c_int,
169            f: glib::ffi::gpointer,
170        ) {
171            let f: &F = &*(f as *const F);
172            f(&from_glib_borrow(this), object)
173        }
174        unsafe {
175            let f: Box_<F> = Box_::new(f);
176            connect_raw(
177                self.as_ptr() as *mut _,
178                c"buffering".as_ptr() as *const _,
179                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
180                    buffering_trampoline::<F> as *const (),
181                )),
182                Box_::into_raw(f),
183            )
184        }
185    }
186
187    #[doc(alias = "end-of-stream")]
188    pub fn connect_end_of_stream<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
189        unsafe extern "C" fn end_of_stream_trampoline<
190            F: Fn(&PlaySignalAdapter) + Send + 'static,
191        >(
192            this: *mut ffi::GstPlaySignalAdapter,
193            f: glib::ffi::gpointer,
194        ) {
195            let f: &F = &*(f as *const F);
196            f(&from_glib_borrow(this))
197        }
198        unsafe {
199            let f: Box_<F> = Box_::new(f);
200            connect_raw(
201                self.as_ptr() as *mut _,
202                c"end-of-stream".as_ptr() as *const _,
203                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
204                    end_of_stream_trampoline::<F> as *const (),
205                )),
206                Box_::into_raw(f),
207            )
208        }
209    }
210
211    /// Emitted on errors.
212    /// ## `error`
213    /// The error
214    /// ## `details`
215    /// Additional error details
216    #[doc(alias = "error")]
217    pub fn connect_error<F: Fn(&Self, &glib::Error, Option<&gst::Structure>) + Send + 'static>(
218        &self,
219        f: F,
220    ) -> SignalHandlerId {
221        unsafe extern "C" fn error_trampoline<
222            F: Fn(&PlaySignalAdapter, &glib::Error, Option<&gst::Structure>) + Send + 'static,
223        >(
224            this: *mut ffi::GstPlaySignalAdapter,
225            error: *mut glib::ffi::GError,
226            details: *mut gst::ffi::GstStructure,
227            f: glib::ffi::gpointer,
228        ) {
229            let f: &F = &*(f as *const F);
230            f(
231                &from_glib_borrow(this),
232                &from_glib_borrow(error),
233                Option::<gst::Structure>::from_glib_borrow(details)
234                    .as_ref()
235                    .as_ref(),
236            )
237        }
238        unsafe {
239            let f: Box_<F> = Box_::new(f);
240            connect_raw(
241                self.as_ptr() as *mut _,
242                c"error".as_ptr() as *const _,
243                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
244                    error_trampoline::<F> as *const (),
245                )),
246                Box_::into_raw(f),
247            )
248        }
249    }
250
251    #[doc(alias = "media-info-updated")]
252    pub fn connect_media_info_updated<F: Fn(&Self, &PlayMediaInfo) + Send + 'static>(
253        &self,
254        f: F,
255    ) -> SignalHandlerId {
256        unsafe extern "C" fn media_info_updated_trampoline<
257            F: Fn(&PlaySignalAdapter, &PlayMediaInfo) + Send + 'static,
258        >(
259            this: *mut ffi::GstPlaySignalAdapter,
260            object: *mut ffi::GstPlayMediaInfo,
261            f: glib::ffi::gpointer,
262        ) {
263            let f: &F = &*(f as *const F);
264            f(&from_glib_borrow(this), &from_glib_borrow(object))
265        }
266        unsafe {
267            let f: Box_<F> = Box_::new(f);
268            connect_raw(
269                self.as_ptr() as *mut _,
270                c"media-info-updated".as_ptr() as *const _,
271                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
272                    media_info_updated_trampoline::<F> as *const (),
273                )),
274                Box_::into_raw(f),
275            )
276        }
277    }
278
279    #[doc(alias = "mute-changed")]
280    pub fn connect_mute_changed<F: Fn(&Self, bool) + Send + 'static>(
281        &self,
282        f: F,
283    ) -> SignalHandlerId {
284        unsafe extern "C" fn mute_changed_trampoline<
285            F: Fn(&PlaySignalAdapter, bool) + Send + 'static,
286        >(
287            this: *mut ffi::GstPlaySignalAdapter,
288            object: glib::ffi::gboolean,
289            f: glib::ffi::gpointer,
290        ) {
291            let f: &F = &*(f as *const F);
292            f(&from_glib_borrow(this), from_glib(object))
293        }
294        unsafe {
295            let f: Box_<F> = Box_::new(f);
296            connect_raw(
297                self.as_ptr() as *mut _,
298                c"mute-changed".as_ptr() as *const _,
299                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
300                    mute_changed_trampoline::<F> as *const (),
301                )),
302                Box_::into_raw(f),
303            )
304        }
305    }
306
307    #[doc(alias = "state-changed")]
308    pub fn connect_state_changed<F: Fn(&Self, PlayState) + Send + 'static>(
309        &self,
310        f: F,
311    ) -> SignalHandlerId {
312        unsafe extern "C" fn state_changed_trampoline<
313            F: Fn(&PlaySignalAdapter, PlayState) + Send + 'static,
314        >(
315            this: *mut ffi::GstPlaySignalAdapter,
316            object: ffi::GstPlayState,
317            f: glib::ffi::gpointer,
318        ) {
319            let f: &F = &*(f as *const F);
320            f(&from_glib_borrow(this), from_glib(object))
321        }
322        unsafe {
323            let f: Box_<F> = Box_::new(f);
324            connect_raw(
325                self.as_ptr() as *mut _,
326                c"state-changed".as_ptr() as *const _,
327                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
328                    state_changed_trampoline::<F> as *const (),
329                )),
330                Box_::into_raw(f),
331            )
332        }
333    }
334
335    #[doc(alias = "uri-loaded")]
336    pub fn connect_uri_loaded<F: Fn(&Self, &str) + Send + 'static>(&self, f: F) -> SignalHandlerId {
337        unsafe extern "C" fn uri_loaded_trampoline<
338            F: Fn(&PlaySignalAdapter, &str) + Send + 'static,
339        >(
340            this: *mut ffi::GstPlaySignalAdapter,
341            object: *mut std::ffi::c_char,
342            f: glib::ffi::gpointer,
343        ) {
344            let f: &F = &*(f as *const F);
345            f(
346                &from_glib_borrow(this),
347                &glib::GString::from_glib_borrow(object),
348            )
349        }
350        unsafe {
351            let f: Box_<F> = Box_::new(f);
352            connect_raw(
353                self.as_ptr() as *mut _,
354                c"uri-loaded".as_ptr() as *const _,
355                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
356                    uri_loaded_trampoline::<F> as *const (),
357                )),
358                Box_::into_raw(f),
359            )
360        }
361    }
362
363    #[doc(alias = "video-dimensions-changed")]
364    pub fn connect_video_dimensions_changed<F: Fn(&Self, u32, u32) + Send + 'static>(
365        &self,
366        f: F,
367    ) -> SignalHandlerId {
368        unsafe extern "C" fn video_dimensions_changed_trampoline<
369            F: Fn(&PlaySignalAdapter, u32, u32) + Send + 'static,
370        >(
371            this: *mut ffi::GstPlaySignalAdapter,
372            object: std::ffi::c_uint,
373            p0: std::ffi::c_uint,
374            f: glib::ffi::gpointer,
375        ) {
376            let f: &F = &*(f as *const F);
377            f(&from_glib_borrow(this), object, p0)
378        }
379        unsafe {
380            let f: Box_<F> = Box_::new(f);
381            connect_raw(
382                self.as_ptr() as *mut _,
383                c"video-dimensions-changed".as_ptr() as *const _,
384                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
385                    video_dimensions_changed_trampoline::<F> as *const (),
386                )),
387                Box_::into_raw(f),
388            )
389        }
390    }
391
392    #[doc(alias = "volume-changed")]
393    pub fn connect_volume_changed<F: Fn(&Self, f64) + Send + 'static>(
394        &self,
395        f: F,
396    ) -> SignalHandlerId {
397        unsafe extern "C" fn volume_changed_trampoline<
398            F: Fn(&PlaySignalAdapter, f64) + Send + 'static,
399        >(
400            this: *mut ffi::GstPlaySignalAdapter,
401            object: std::ffi::c_double,
402            f: glib::ffi::gpointer,
403        ) {
404            let f: &F = &*(f as *const F);
405            f(&from_glib_borrow(this), object)
406        }
407        unsafe {
408            let f: Box_<F> = Box_::new(f);
409            connect_raw(
410                self.as_ptr() as *mut _,
411                c"volume-changed".as_ptr() as *const _,
412                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
413                    volume_changed_trampoline::<F> as *const (),
414                )),
415                Box_::into_raw(f),
416            )
417        }
418    }
419
420    /// Emitted on warnings.
421    /// ## `error`
422    /// The warning
423    /// ## `details`
424    /// Additional warning details
425    #[doc(alias = "warning")]
426    pub fn connect_warning<F: Fn(&Self, &glib::Error, Option<&gst::Structure>) + Send + 'static>(
427        &self,
428        f: F,
429    ) -> SignalHandlerId {
430        unsafe extern "C" fn warning_trampoline<
431            F: Fn(&PlaySignalAdapter, &glib::Error, Option<&gst::Structure>) + Send + 'static,
432        >(
433            this: *mut ffi::GstPlaySignalAdapter,
434            error: *mut glib::ffi::GError,
435            details: *mut gst::ffi::GstStructure,
436            f: glib::ffi::gpointer,
437        ) {
438            let f: &F = &*(f as *const F);
439            f(
440                &from_glib_borrow(this),
441                &from_glib_borrow(error),
442                Option::<gst::Structure>::from_glib_borrow(details)
443                    .as_ref()
444                    .as_ref(),
445            )
446        }
447        unsafe {
448            let f: Box_<F> = Box_::new(f);
449            connect_raw(
450                self.as_ptr() as *mut _,
451                c"warning".as_ptr() as *const _,
452                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
453                    warning_trampoline::<F> as *const (),
454                )),
455                Box_::into_raw(f),
456            )
457        }
458    }
459
460    #[doc(alias = "play")]
461    pub fn connect_play_notify<F: Fn(&Self) + Send + Sync + 'static>(
462        &self,
463        f: F,
464    ) -> SignalHandlerId {
465        unsafe extern "C" fn notify_play_trampoline<
466            F: Fn(&PlaySignalAdapter) + Send + Sync + 'static,
467        >(
468            this: *mut ffi::GstPlaySignalAdapter,
469            _param_spec: glib::ffi::gpointer,
470            f: glib::ffi::gpointer,
471        ) {
472            let f: &F = &*(f as *const F);
473            f(&from_glib_borrow(this))
474        }
475        unsafe {
476            let f: Box_<F> = Box_::new(f);
477            connect_raw(
478                self.as_ptr() as *mut _,
479                c"notify::play".as_ptr() as *const _,
480                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
481                    notify_play_trampoline::<F> as *const (),
482                )),
483                Box_::into_raw(f),
484            )
485        }
486    }
487}
488
489unsafe impl Send for PlaySignalAdapter {}
490unsafe impl Sync for PlaySignalAdapter {}