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::StreamVolumeFormat;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::{boxed::Box as Box_, mem::transmute};
13
14glib::wrapper! {
15 #[doc(alias = "GstStreamVolume")]
16 pub struct StreamVolume(Interface<ffi::GstStreamVolume, ffi::GstStreamVolumeInterface>);
17
18 match fn {
19 type_ => || ffi::gst_stream_volume_get_type(),
20 }
21}
22
23impl StreamVolume {
24 pub const NONE: Option<&'static StreamVolume> = None;
25
26 #[doc(alias = "gst_stream_volume_convert_volume")]
27 pub fn convert_volume(from: StreamVolumeFormat, to: StreamVolumeFormat, val: f64) -> f64 {
28 assert_initialized_main_thread!();
29 unsafe { ffi::gst_stream_volume_convert_volume(from:from.into_glib(), to:to.into_glib(), val) }
30 }
31}
32
33unsafe impl Send for StreamVolume {}
34unsafe impl Sync for StreamVolume {}
35
36mod sealed {
37 pub trait Sealed {}
38 impl<T: super::IsA<super::StreamVolume>> Sealed for T {}
39}
40
41pub trait StreamVolumeExt: IsA<StreamVolume> + sealed::Sealed + 'static {
42 #[doc(alias = "gst_stream_volume_get_mute")]
43 #[doc(alias = "get_mute")]
44 fn is_muted(&self) -> bool {
45 unsafe {
46 from_glib(ffi::gst_stream_volume_get_mute(
47 self.as_ref().to_glib_none().0,
48 ))
49 }
50 }
51
52 #[doc(alias = "gst_stream_volume_get_volume")]
53 #[doc(alias = "get_volume")]
54 fn volume(&self, format: StreamVolumeFormat) -> f64 {
55 unsafe {
56 ffi::gst_stream_volume_get_volume(self.as_ref().to_glib_none().0, format.into_glib())
57 }
58 }
59
60 #[doc(alias = "gst_stream_volume_set_mute")]
61 fn set_mute(&self, mute: bool) {
62 unsafe {
63 ffi::gst_stream_volume_set_mute(self.as_ref().to_glib_none().0, mute.into_glib());
64 }
65 }
66
67 #[doc(alias = "gst_stream_volume_set_volume")]
68 fn set_volume(&self, format: StreamVolumeFormat, val: f64) {
69 unsafe {
70 ffi::gst_stream_volume_set_volume(
71 self.as_ref().to_glib_none().0,
72 format.into_glib(),
73 val,
74 );
75 }
76 }
77
78 #[doc(alias = "mute")]
79 fn connect_mute_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
80 unsafe extern "C" fn notify_mute_trampoline<
81 P: IsA<StreamVolume>,
82 F: Fn(&P) + Send + Sync + 'static,
83 >(
84 this: *mut ffi::GstStreamVolume,
85 _param_spec: glib::ffi::gpointer,
86 f: glib::ffi::gpointer,
87 ) {
88 let f: &F = &*(f as *const F);
89 f(StreamVolume::from_glib_borrow(this).unsafe_cast_ref())
90 }
91 unsafe {
92 let f: Box_<F> = Box_::new(f);
93 connect_raw(
94 self.as_ptr() as *mut _,
95 b"notify::mute\0".as_ptr() as *const _,
96 Some(transmute::<_, unsafe extern "C" fn()>(
97 notify_mute_trampoline::<Self, F> as *const (),
98 )),
99 Box_::into_raw(f),
100 )
101 }
102 }
103
104 #[doc(alias = "volume")]
105 fn connect_volume_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
106 unsafe extern "C" fn notify_volume_trampoline<
107 P: IsA<StreamVolume>,
108 F: Fn(&P) + Send + Sync + 'static,
109 >(
110 this: *mut ffi::GstStreamVolume,
111 _param_spec: glib::ffi::gpointer,
112 f: glib::ffi::gpointer,
113 ) {
114 let f: &F = &*(f as *const F);
115 f(StreamVolume::from_glib_borrow(this).unsafe_cast_ref())
116 }
117 unsafe {
118 let f: Box_<F> = Box_::new(f);
119 connect_raw(
120 self.as_ptr() as *mut _,
121 b"notify::volume\0".as_ptr() as *const _,
122 Some(transmute::<_, unsafe extern "C" fn()>(
123 notify_volume_trampoline::<Self, F> as *const (),
124 )),
125 Box_::into_raw(f),
126 )
127 }
128 }
129}
130
131impl<O: IsA<StreamVolume>> StreamVolumeExt for O {}
132