1use 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 #[doc(alias = "GstPlaySignalAdapter")]
17 pub struct PlaySignalAdapter(Object<ffi::GstPlaySignalAdapter, ffi::GstPlaySignalAdapterClass>);
18
19 match fn {
20 type_ => || ffi::gst_play_signal_adapter_get_type(),
21 }
22}
23
24impl PlaySignalAdapter {
25 #[doc(alias = "gst_play_signal_adapter_new")]
26 pub fn new(play: &Play) -> PlaySignalAdapter {
27 skip_assert_initialized!();
28 unsafe { from_glib_full(ffi::gst_play_signal_adapter_new(play.to_glib_none().0)) }
29 }
30
31 #[doc(alias = "gst_play_signal_adapter_new_sync_emit")]
32 pub fn new_sync_emit(play: &Play) -> PlaySignalAdapter {
33 skip_assert_initialized!();
34 unsafe {
35 from_glib_full(ffi::gst_play_signal_adapter_new_sync_emit(
36 play.to_glib_none().0,
37 ))
38 }
39 }
40
41 #[doc(alias = "gst_play_signal_adapter_new_with_main_context")]
42 #[doc(alias = "new_with_main_context")]
43 pub fn with_main_context(play: &Play, context: &glib::MainContext) -> PlaySignalAdapter {
44 skip_assert_initialized!();
45 unsafe {
46 from_glib_full(ffi::gst_play_signal_adapter_new_with_main_context(
47 play.to_glib_none().0,
48 context.to_glib_none().0,
49 ))
50 }
51 }
52
53 #[doc(alias = "gst_play_signal_adapter_get_play")]
54 #[doc(alias = "get_play")]
55 pub fn play(&self) -> Play {
56 unsafe { from_glib_none(ffi::gst_play_signal_adapter_get_play(self.to_glib_none().0)) }
57 }
58
59 #[doc(alias = "buffering")]
60 pub fn connect_buffering<F: Fn(&Self, i32) + Send + 'static>(&self, f: F) -> SignalHandlerId {
61 unsafe extern "C" fn buffering_trampoline<
62 F: Fn(&PlaySignalAdapter, i32) + Send + 'static,
63 >(
64 this: *mut ffi::GstPlaySignalAdapter,
65 object: std::ffi::c_int,
66 f: glib::ffi::gpointer,
67 ) {
68 unsafe {
69 let f: &F = &*(f as *const F);
70 f(&from_glib_borrow(this), object)
71 }
72 }
73 unsafe {
74 let f: Box_<F> = Box_::new(f);
75 connect_raw(
76 self.as_ptr() as *mut _,
77 c"buffering".as_ptr(),
78 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
79 buffering_trampoline::<F> as *const (),
80 )),
81 Box_::into_raw(f),
82 )
83 }
84 }
85
86 #[doc(alias = "end-of-stream")]
87 pub fn connect_end_of_stream<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
88 unsafe extern "C" fn end_of_stream_trampoline<
89 F: Fn(&PlaySignalAdapter) + Send + 'static,
90 >(
91 this: *mut ffi::GstPlaySignalAdapter,
92 f: glib::ffi::gpointer,
93 ) {
94 unsafe {
95 let f: &F = &*(f as *const F);
96 f(&from_glib_borrow(this))
97 }
98 }
99 unsafe {
100 let f: Box_<F> = Box_::new(f);
101 connect_raw(
102 self.as_ptr() as *mut _,
103 c"end-of-stream".as_ptr(),
104 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
105 end_of_stream_trampoline::<F> as *const (),
106 )),
107 Box_::into_raw(f),
108 )
109 }
110 }
111
112 #[doc(alias = "error")]
113 pub fn connect_error<F: Fn(&Self, &glib::Error, Option<&gst::Structure>) + Send + 'static>(
114 &self,
115 f: F,
116 ) -> SignalHandlerId {
117 unsafe extern "C" fn error_trampoline<
118 F: Fn(&PlaySignalAdapter, &glib::Error, Option<&gst::Structure>) + Send + 'static,
119 >(
120 this: *mut ffi::GstPlaySignalAdapter,
121 error: *mut glib::ffi::GError,
122 details: *mut gst::ffi::GstStructure,
123 f: glib::ffi::gpointer,
124 ) {
125 unsafe {
126 let f: &F = &*(f as *const F);
127 f(
128 &from_glib_borrow(this),
129 &from_glib_borrow(error),
130 Option::<gst::Structure>::from_glib_borrow(details)
131 .as_ref()
132 .as_ref(),
133 )
134 }
135 }
136 unsafe {
137 let f: Box_<F> = Box_::new(f);
138 connect_raw(
139 self.as_ptr() as *mut _,
140 c"error".as_ptr(),
141 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
142 error_trampoline::<F> as *const (),
143 )),
144 Box_::into_raw(f),
145 )
146 }
147 }
148
149 #[doc(alias = "media-info-updated")]
150 pub fn connect_media_info_updated<F: Fn(&Self, &PlayMediaInfo) + Send + 'static>(
151 &self,
152 f: F,
153 ) -> SignalHandlerId {
154 unsafe extern "C" fn media_info_updated_trampoline<
155 F: Fn(&PlaySignalAdapter, &PlayMediaInfo) + Send + 'static,
156 >(
157 this: *mut ffi::GstPlaySignalAdapter,
158 object: *mut ffi::GstPlayMediaInfo,
159 f: glib::ffi::gpointer,
160 ) {
161 unsafe {
162 let f: &F = &*(f as *const F);
163 f(&from_glib_borrow(this), &from_glib_borrow(object))
164 }
165 }
166 unsafe {
167 let f: Box_<F> = Box_::new(f);
168 connect_raw(
169 self.as_ptr() as *mut _,
170 c"media-info-updated".as_ptr(),
171 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
172 media_info_updated_trampoline::<F> as *const (),
173 )),
174 Box_::into_raw(f),
175 )
176 }
177 }
178
179 #[doc(alias = "mute-changed")]
180 pub fn connect_mute_changed<F: Fn(&Self, bool) + Send + 'static>(
181 &self,
182 f: F,
183 ) -> SignalHandlerId {
184 unsafe extern "C" fn mute_changed_trampoline<
185 F: Fn(&PlaySignalAdapter, bool) + Send + 'static,
186 >(
187 this: *mut ffi::GstPlaySignalAdapter,
188 object: glib::ffi::gboolean,
189 f: glib::ffi::gpointer,
190 ) {
191 unsafe {
192 let f: &F = &*(f as *const F);
193 f(&from_glib_borrow(this), from_glib(object))
194 }
195 }
196 unsafe {
197 let f: Box_<F> = Box_::new(f);
198 connect_raw(
199 self.as_ptr() as *mut _,
200 c"mute-changed".as_ptr(),
201 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
202 mute_changed_trampoline::<F> as *const (),
203 )),
204 Box_::into_raw(f),
205 )
206 }
207 }
208
209 #[doc(alias = "state-changed")]
210 pub fn connect_state_changed<F: Fn(&Self, PlayState) + Send + 'static>(
211 &self,
212 f: F,
213 ) -> SignalHandlerId {
214 unsafe extern "C" fn state_changed_trampoline<
215 F: Fn(&PlaySignalAdapter, PlayState) + Send + 'static,
216 >(
217 this: *mut ffi::GstPlaySignalAdapter,
218 object: ffi::GstPlayState,
219 f: glib::ffi::gpointer,
220 ) {
221 unsafe {
222 let f: &F = &*(f as *const F);
223 f(&from_glib_borrow(this), from_glib(object))
224 }
225 }
226 unsafe {
227 let f: Box_<F> = Box_::new(f);
228 connect_raw(
229 self.as_ptr() as *mut _,
230 c"state-changed".as_ptr(),
231 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
232 state_changed_trampoline::<F> as *const (),
233 )),
234 Box_::into_raw(f),
235 )
236 }
237 }
238
239 #[cfg(feature = "v1_30")]
240 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
241 #[doc(alias = "tracks-selected")]
242 pub fn connect_tracks_selected<
243 F: Fn(&Self, Option<&str>, Option<&str>, Option<&str>) + Send + Sync + 'static,
244 >(
245 &self,
246 f: F,
247 ) -> SignalHandlerId {
248 unsafe extern "C" fn tracks_selected_trampoline<
249 F: Fn(&PlaySignalAdapter, Option<&str>, Option<&str>, Option<&str>)
250 + Send
251 + Sync
252 + 'static,
253 >(
254 this: *mut ffi::GstPlaySignalAdapter,
255 audio_track_id: *mut std::ffi::c_char,
256 video_track_id: *mut std::ffi::c_char,
257 subtitle_track_id: *mut std::ffi::c_char,
258 f: glib::ffi::gpointer,
259 ) {
260 unsafe {
261 let f: &F = &*(f as *const F);
262 f(
263 &from_glib_borrow(this),
264 Option::<glib::GString>::from_glib_borrow(audio_track_id)
265 .as_ref()
266 .as_ref()
267 .map(|s| s.as_str()),
268 Option::<glib::GString>::from_glib_borrow(video_track_id)
269 .as_ref()
270 .as_ref()
271 .map(|s| s.as_str()),
272 Option::<glib::GString>::from_glib_borrow(subtitle_track_id)
273 .as_ref()
274 .as_ref()
275 .map(|s| s.as_str()),
276 )
277 }
278 }
279 unsafe {
280 let f: Box_<F> = Box_::new(f);
281 connect_raw(
282 self.as_ptr() as *mut _,
283 c"tracks-selected".as_ptr(),
284 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
285 tracks_selected_trampoline::<F> as *const (),
286 )),
287 Box_::into_raw(f),
288 )
289 }
290 }
291
292 #[doc(alias = "uri-loaded")]
293 pub fn connect_uri_loaded<F: Fn(&Self, &str) + Send + 'static>(&self, f: F) -> SignalHandlerId {
294 unsafe extern "C" fn uri_loaded_trampoline<
295 F: Fn(&PlaySignalAdapter, &str) + Send + 'static,
296 >(
297 this: *mut ffi::GstPlaySignalAdapter,
298 object: *mut std::ffi::c_char,
299 f: glib::ffi::gpointer,
300 ) {
301 unsafe {
302 let f: &F = &*(f as *const F);
303 f(
304 &from_glib_borrow(this),
305 &glib::GString::from_glib_borrow(object),
306 )
307 }
308 }
309 unsafe {
310 let f: Box_<F> = Box_::new(f);
311 connect_raw(
312 self.as_ptr() as *mut _,
313 c"uri-loaded".as_ptr(),
314 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
315 uri_loaded_trampoline::<F> as *const (),
316 )),
317 Box_::into_raw(f),
318 )
319 }
320 }
321
322 #[doc(alias = "video-dimensions-changed")]
323 pub fn connect_video_dimensions_changed<F: Fn(&Self, u32, u32) + Send + 'static>(
324 &self,
325 f: F,
326 ) -> SignalHandlerId {
327 unsafe extern "C" fn video_dimensions_changed_trampoline<
328 F: Fn(&PlaySignalAdapter, u32, u32) + Send + 'static,
329 >(
330 this: *mut ffi::GstPlaySignalAdapter,
331 object: std::ffi::c_uint,
332 p0: std::ffi::c_uint,
333 f: glib::ffi::gpointer,
334 ) {
335 unsafe {
336 let f: &F = &*(f as *const F);
337 f(&from_glib_borrow(this), object, p0)
338 }
339 }
340 unsafe {
341 let f: Box_<F> = Box_::new(f);
342 connect_raw(
343 self.as_ptr() as *mut _,
344 c"video-dimensions-changed".as_ptr(),
345 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
346 video_dimensions_changed_trampoline::<F> as *const (),
347 )),
348 Box_::into_raw(f),
349 )
350 }
351 }
352
353 #[doc(alias = "volume-changed")]
354 pub fn connect_volume_changed<F: Fn(&Self, f64) + Send + 'static>(
355 &self,
356 f: F,
357 ) -> SignalHandlerId {
358 unsafe extern "C" fn volume_changed_trampoline<
359 F: Fn(&PlaySignalAdapter, f64) + Send + 'static,
360 >(
361 this: *mut ffi::GstPlaySignalAdapter,
362 object: std::ffi::c_double,
363 f: glib::ffi::gpointer,
364 ) {
365 unsafe {
366 let f: &F = &*(f as *const F);
367 f(&from_glib_borrow(this), object)
368 }
369 }
370 unsafe {
371 let f: Box_<F> = Box_::new(f);
372 connect_raw(
373 self.as_ptr() as *mut _,
374 c"volume-changed".as_ptr(),
375 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
376 volume_changed_trampoline::<F> as *const (),
377 )),
378 Box_::into_raw(f),
379 )
380 }
381 }
382
383 #[doc(alias = "warning")]
384 pub fn connect_warning<F: Fn(&Self, &glib::Error, Option<&gst::Structure>) + Send + 'static>(
385 &self,
386 f: F,
387 ) -> SignalHandlerId {
388 unsafe extern "C" fn warning_trampoline<
389 F: Fn(&PlaySignalAdapter, &glib::Error, Option<&gst::Structure>) + Send + 'static,
390 >(
391 this: *mut ffi::GstPlaySignalAdapter,
392 error: *mut glib::ffi::GError,
393 details: *mut gst::ffi::GstStructure,
394 f: glib::ffi::gpointer,
395 ) {
396 unsafe {
397 let f: &F = &*(f as *const F);
398 f(
399 &from_glib_borrow(this),
400 &from_glib_borrow(error),
401 Option::<gst::Structure>::from_glib_borrow(details)
402 .as_ref()
403 .as_ref(),
404 )
405 }
406 }
407 unsafe {
408 let f: Box_<F> = Box_::new(f);
409 connect_raw(
410 self.as_ptr() as *mut _,
411 c"warning".as_ptr(),
412 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
413 warning_trampoline::<F> as *const (),
414 )),
415 Box_::into_raw(f),
416 )
417 }
418 }
419
420 #[doc(alias = "play")]
421 pub fn connect_play_notify<F: Fn(&Self) + Send + Sync + 'static>(
422 &self,
423 f: F,
424 ) -> SignalHandlerId {
425 unsafe extern "C" fn notify_play_trampoline<
426 F: Fn(&PlaySignalAdapter) + Send + Sync + 'static,
427 >(
428 this: *mut ffi::GstPlaySignalAdapter,
429 _param_spec: glib::ffi::gpointer,
430 f: glib::ffi::gpointer,
431 ) {
432 unsafe {
433 let f: &F = &*(f as *const F);
434 f(&from_glib_borrow(this))
435 }
436 }
437 unsafe {
438 let f: Box_<F> = Box_::new(f);
439 connect_raw(
440 self.as_ptr() as *mut _,
441 c"notify::play".as_ptr(),
442 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
443 notify_play_trampoline::<F> as *const (),
444 )),
445 Box_::into_raw(f),
446 )
447 }
448 }
449}
450
451unsafe impl Send for PlaySignalAdapter {}
452unsafe impl Sync for PlaySignalAdapter {}