1use crate::{
7 PlayerAudioInfo, PlayerColorBalanceType, PlayerMediaInfo, PlayerSignalDispatcher, PlayerState,
8 PlayerSubtitleInfo, PlayerVideoInfo, PlayerVideoRenderer, PlayerVisualization, ffi,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{SignalHandlerId, connect_raw},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 #[doc(alias = "GstPlayer")]
20 pub struct Player(Object<ffi::GstPlayer, ffi::GstPlayerClass>) @extends gst::Object;
21
22 match fn {
23 type_ => || ffi::gst_player_get_type(),
24 }
25}
26
27impl Player {
28 #[doc(alias = "gst_player_new")]
29 pub fn new(
30 video_renderer: Option<impl IsA<PlayerVideoRenderer>>,
31 signal_dispatcher: Option<impl IsA<PlayerSignalDispatcher>>,
32 ) -> Player {
33 assert_initialized_main_thread!();
34 unsafe {
35 from_glib_full(ffi::gst_player_new(
36 video_renderer.map(|p| p.upcast()).into_glib_ptr(),
37 signal_dispatcher.map(|p| p.upcast()).into_glib_ptr(),
38 ))
39 }
40 }
41
42 #[doc(alias = "gst_player_get_audio_video_offset")]
43 #[doc(alias = "get_audio_video_offset")]
44 #[doc(alias = "audio-video-offset")]
45 pub fn audio_video_offset(&self) -> i64 {
46 unsafe { ffi::gst_player_get_audio_video_offset(self.to_glib_none().0) }
47 }
48
49 #[doc(alias = "gst_player_get_color_balance")]
50 #[doc(alias = "get_color_balance")]
51 pub fn color_balance(&self, type_: PlayerColorBalanceType) -> f64 {
52 unsafe { ffi::gst_player_get_color_balance(self.to_glib_none().0, type_.into_glib()) }
53 }
54
55 #[doc(alias = "gst_player_get_current_audio_track")]
56 #[doc(alias = "get_current_audio_track")]
57 #[doc(alias = "current-audio-track")]
58 pub fn current_audio_track(&self) -> Option<PlayerAudioInfo> {
59 unsafe {
60 from_glib_full(ffi::gst_player_get_current_audio_track(
61 self.to_glib_none().0,
62 ))
63 }
64 }
65
66 #[doc(alias = "gst_player_get_current_subtitle_track")]
67 #[doc(alias = "get_current_subtitle_track")]
68 #[doc(alias = "current-subtitle-track")]
69 pub fn current_subtitle_track(&self) -> Option<PlayerSubtitleInfo> {
70 unsafe {
71 from_glib_full(ffi::gst_player_get_current_subtitle_track(
72 self.to_glib_none().0,
73 ))
74 }
75 }
76
77 #[doc(alias = "gst_player_get_current_video_track")]
78 #[doc(alias = "get_current_video_track")]
79 #[doc(alias = "current-video-track")]
80 pub fn current_video_track(&self) -> Option<PlayerVideoInfo> {
81 unsafe {
82 from_glib_full(ffi::gst_player_get_current_video_track(
83 self.to_glib_none().0,
84 ))
85 }
86 }
87
88 #[doc(alias = "gst_player_get_current_visualization")]
89 #[doc(alias = "get_current_visualization")]
90 pub fn current_visualization(&self) -> Option<glib::GString> {
91 unsafe {
92 from_glib_full(ffi::gst_player_get_current_visualization(
93 self.to_glib_none().0,
94 ))
95 }
96 }
97
98 #[doc(alias = "gst_player_get_duration")]
99 #[doc(alias = "get_duration")]
100 pub fn duration(&self) -> Option<gst::ClockTime> {
101 unsafe { from_glib(ffi::gst_player_get_duration(self.to_glib_none().0)) }
102 }
103
104 #[doc(alias = "gst_player_get_media_info")]
105 #[doc(alias = "get_media_info")]
106 #[doc(alias = "media-info")]
107 pub fn media_info(&self) -> Option<PlayerMediaInfo> {
108 unsafe { from_glib_full(ffi::gst_player_get_media_info(self.to_glib_none().0)) }
109 }
110
111 #[doc(alias = "gst_player_get_multiview_flags")]
112 #[doc(alias = "get_multiview_flags")]
113 pub fn multiview_flags(&self) -> gst_video::VideoMultiviewFlags {
114 unsafe { from_glib(ffi::gst_player_get_multiview_flags(self.to_glib_none().0)) }
115 }
116
117 #[doc(alias = "gst_player_get_multiview_mode")]
118 #[doc(alias = "get_multiview_mode")]
119 pub fn multiview_mode(&self) -> gst_video::VideoMultiviewFramePacking {
120 unsafe { from_glib(ffi::gst_player_get_multiview_mode(self.to_glib_none().0)) }
121 }
122
123 #[doc(alias = "gst_player_get_mute")]
124 #[doc(alias = "get_mute")]
125 #[doc(alias = "mute")]
126 pub fn is_muted(&self) -> bool {
127 unsafe { from_glib(ffi::gst_player_get_mute(self.to_glib_none().0)) }
128 }
129
130 #[doc(alias = "gst_player_get_pipeline")]
131 #[doc(alias = "get_pipeline")]
132 pub fn pipeline(&self) -> gst::Element {
133 unsafe { from_glib_full(ffi::gst_player_get_pipeline(self.to_glib_none().0)) }
134 }
135
136 #[doc(alias = "gst_player_get_position")]
137 #[doc(alias = "get_position")]
138 pub fn position(&self) -> Option<gst::ClockTime> {
139 unsafe { from_glib(ffi::gst_player_get_position(self.to_glib_none().0)) }
140 }
141
142 #[doc(alias = "gst_player_get_rate")]
143 #[doc(alias = "get_rate")]
144 pub fn rate(&self) -> f64 {
145 unsafe { ffi::gst_player_get_rate(self.to_glib_none().0) }
146 }
147
148 #[doc(alias = "gst_player_get_subtitle_uri")]
149 #[doc(alias = "get_subtitle_uri")]
150 pub fn subtitle_uri(&self) -> Option<glib::GString> {
151 unsafe { from_glib_full(ffi::gst_player_get_subtitle_uri(self.to_glib_none().0)) }
152 }
153
154 #[cfg(feature = "v1_16")]
155 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
156 #[doc(alias = "gst_player_get_subtitle_video_offset")]
157 #[doc(alias = "get_subtitle_video_offset")]
158 #[doc(alias = "subtitle-video-offset")]
159 pub fn subtitle_video_offset(&self) -> i64 {
160 unsafe { ffi::gst_player_get_subtitle_video_offset(self.to_glib_none().0) }
161 }
162
163 #[doc(alias = "gst_player_get_uri")]
164 #[doc(alias = "get_uri")]
165 pub fn uri(&self) -> Option<glib::GString> {
166 unsafe { from_glib_full(ffi::gst_player_get_uri(self.to_glib_none().0)) }
167 }
168
169 #[doc(alias = "gst_player_get_volume")]
170 #[doc(alias = "get_volume")]
171 pub fn volume(&self) -> f64 {
172 unsafe { ffi::gst_player_get_volume(self.to_glib_none().0) }
173 }
174
175 #[doc(alias = "gst_player_has_color_balance")]
176 pub fn has_color_balance(&self) -> bool {
177 unsafe { from_glib(ffi::gst_player_has_color_balance(self.to_glib_none().0)) }
178 }
179
180 #[doc(alias = "gst_player_pause")]
181 pub fn pause(&self) {
182 unsafe {
183 ffi::gst_player_pause(self.to_glib_none().0);
184 }
185 }
186
187 #[doc(alias = "gst_player_play")]
188 pub fn play(&self) {
189 unsafe {
190 ffi::gst_player_play(self.to_glib_none().0);
191 }
192 }
193
194 #[doc(alias = "gst_player_seek")]
195 pub fn seek(&self, position: gst::ClockTime) {
196 unsafe {
197 ffi::gst_player_seek(self.to_glib_none().0, position.into_glib());
198 }
199 }
200
201 #[doc(alias = "gst_player_set_audio_track")]
202 pub fn set_audio_track(&self, stream_index: i32) -> Result<(), glib::error::BoolError> {
203 unsafe {
204 glib::result_from_gboolean!(
205 ffi::gst_player_set_audio_track(self.to_glib_none().0, stream_index),
206 "Failed to set audio track"
207 )
208 }
209 }
210
211 #[doc(alias = "gst_player_set_audio_track_enabled")]
212 pub fn set_audio_track_enabled(&self, enabled: bool) {
213 unsafe {
214 ffi::gst_player_set_audio_track_enabled(self.to_glib_none().0, enabled.into_glib());
215 }
216 }
217
218 #[doc(alias = "gst_player_set_audio_video_offset")]
219 #[doc(alias = "audio-video-offset")]
220 pub fn set_audio_video_offset(&self, offset: i64) {
221 unsafe {
222 ffi::gst_player_set_audio_video_offset(self.to_glib_none().0, offset);
223 }
224 }
225
226 #[doc(alias = "gst_player_set_color_balance")]
227 pub fn set_color_balance(&self, type_: PlayerColorBalanceType, value: f64) {
228 unsafe {
229 ffi::gst_player_set_color_balance(self.to_glib_none().0, type_.into_glib(), value);
230 }
231 }
232
233 #[doc(alias = "gst_player_set_multiview_flags")]
234 pub fn set_multiview_flags(&self, flags: gst_video::VideoMultiviewFlags) {
235 unsafe {
236 ffi::gst_player_set_multiview_flags(self.to_glib_none().0, flags.into_glib());
237 }
238 }
239
240 #[doc(alias = "gst_player_set_multiview_mode")]
241 pub fn set_multiview_mode(&self, mode: gst_video::VideoMultiviewFramePacking) {
242 unsafe {
243 ffi::gst_player_set_multiview_mode(self.to_glib_none().0, mode.into_glib());
244 }
245 }
246
247 #[doc(alias = "gst_player_set_mute")]
248 #[doc(alias = "mute")]
249 pub fn set_mute(&self, val: bool) {
250 unsafe {
251 ffi::gst_player_set_mute(self.to_glib_none().0, val.into_glib());
252 }
253 }
254
255 #[doc(alias = "gst_player_set_rate")]
256 #[doc(alias = "rate")]
257 pub fn set_rate(&self, rate: f64) {
258 unsafe {
259 ffi::gst_player_set_rate(self.to_glib_none().0, rate);
260 }
261 }
262
263 #[doc(alias = "gst_player_set_subtitle_track")]
264 pub fn set_subtitle_track(&self, stream_index: i32) -> Result<(), glib::error::BoolError> {
265 unsafe {
266 glib::result_from_gboolean!(
267 ffi::gst_player_set_subtitle_track(self.to_glib_none().0, stream_index),
268 "Failed to set subtitle track"
269 )
270 }
271 }
272
273 #[doc(alias = "gst_player_set_subtitle_track_enabled")]
274 pub fn set_subtitle_track_enabled(&self, enabled: bool) {
275 unsafe {
276 ffi::gst_player_set_subtitle_track_enabled(self.to_glib_none().0, enabled.into_glib());
277 }
278 }
279
280 #[doc(alias = "gst_player_set_subtitle_uri")]
281 pub fn set_subtitle_uri(&self, uri: Option<&str>) {
282 unsafe {
283 ffi::gst_player_set_subtitle_uri(self.to_glib_none().0, uri.to_glib_none().0);
284 }
285 }
286
287 #[cfg(feature = "v1_16")]
288 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
289 #[doc(alias = "gst_player_set_subtitle_video_offset")]
290 #[doc(alias = "subtitle-video-offset")]
291 pub fn set_subtitle_video_offset(&self, offset: i64) {
292 unsafe {
293 ffi::gst_player_set_subtitle_video_offset(self.to_glib_none().0, offset);
294 }
295 }
296
297 #[doc(alias = "gst_player_set_uri")]
298 #[doc(alias = "uri")]
299 pub fn set_uri(&self, uri: Option<&str>) {
300 unsafe {
301 ffi::gst_player_set_uri(self.to_glib_none().0, uri.to_glib_none().0);
302 }
303 }
304
305 #[doc(alias = "gst_player_set_video_track")]
306 pub fn set_video_track(&self, stream_index: i32) -> Result<(), glib::error::BoolError> {
307 unsafe {
308 glib::result_from_gboolean!(
309 ffi::gst_player_set_video_track(self.to_glib_none().0, stream_index),
310 "Failed to set video track"
311 )
312 }
313 }
314
315 #[doc(alias = "gst_player_set_video_track_enabled")]
316 pub fn set_video_track_enabled(&self, enabled: bool) {
317 unsafe {
318 ffi::gst_player_set_video_track_enabled(self.to_glib_none().0, enabled.into_glib());
319 }
320 }
321
322 #[doc(alias = "gst_player_set_visualization")]
323 pub fn set_visualization(&self, name: Option<&str>) -> Result<(), glib::error::BoolError> {
324 unsafe {
325 glib::result_from_gboolean!(
326 ffi::gst_player_set_visualization(self.to_glib_none().0, name.to_glib_none().0),
327 "Failed to set visualization"
328 )
329 }
330 }
331
332 #[doc(alias = "gst_player_set_visualization_enabled")]
333 pub fn set_visualization_enabled(&self, enabled: bool) {
334 unsafe {
335 ffi::gst_player_set_visualization_enabled(self.to_glib_none().0, enabled.into_glib());
336 }
337 }
338
339 #[doc(alias = "gst_player_set_volume")]
340 #[doc(alias = "volume")]
341 pub fn set_volume(&self, val: f64) {
342 unsafe {
343 ffi::gst_player_set_volume(self.to_glib_none().0, val);
344 }
345 }
346
347 #[doc(alias = "gst_player_stop")]
348 pub fn stop(&self) {
349 unsafe {
350 ffi::gst_player_stop(self.to_glib_none().0);
351 }
352 }
353
354 pub fn suburi(&self) -> Option<glib::GString> {
355 ObjectExt::property(self, "suburi")
356 }
357
358 pub fn set_suburi(&self, suburi: Option<&str>) {
359 ObjectExt::set_property(self, "suburi", suburi)
360 }
361
362 #[doc(alias = "video-multiview-flags")]
363 pub fn video_multiview_flags(&self) -> gst_video::VideoMultiviewFlags {
364 ObjectExt::property(self, "video-multiview-flags")
365 }
366
367 #[doc(alias = "video-multiview-flags")]
368 pub fn set_video_multiview_flags(&self, video_multiview_flags: gst_video::VideoMultiviewFlags) {
369 ObjectExt::set_property(self, "video-multiview-flags", video_multiview_flags)
370 }
371
372 #[doc(alias = "video-multiview-mode")]
373 pub fn video_multiview_mode(&self) -> gst_video::VideoMultiviewFramePacking {
374 ObjectExt::property(self, "video-multiview-mode")
375 }
376
377 #[doc(alias = "video-multiview-mode")]
378 pub fn set_video_multiview_mode(
379 &self,
380 video_multiview_mode: gst_video::VideoMultiviewFramePacking,
381 ) {
382 ObjectExt::set_property(self, "video-multiview-mode", video_multiview_mode)
383 }
384
385 #[doc(alias = "video-renderer")]
386 pub fn video_renderer(&self) -> Option<PlayerVideoRenderer> {
387 ObjectExt::property(self, "video-renderer")
388 }
389
390 #[doc(alias = "gst_player_get_audio_streams")]
391 #[doc(alias = "get_audio_streams")]
392 pub fn audio_streams(info: &PlayerMediaInfo) -> Vec<PlayerAudioInfo> {
393 skip_assert_initialized!();
394 unsafe {
395 FromGlibPtrContainer::from_glib_none(ffi::gst_player_get_audio_streams(
396 info.to_glib_none().0,
397 ))
398 }
399 }
400
401 #[doc(alias = "gst_player_get_subtitle_streams")]
402 #[doc(alias = "get_subtitle_streams")]
403 pub fn subtitle_streams(info: &PlayerMediaInfo) -> Vec<PlayerSubtitleInfo> {
404 skip_assert_initialized!();
405 unsafe {
406 FromGlibPtrContainer::from_glib_none(ffi::gst_player_get_subtitle_streams(
407 info.to_glib_none().0,
408 ))
409 }
410 }
411
412 #[doc(alias = "gst_player_get_video_streams")]
413 #[doc(alias = "get_video_streams")]
414 pub fn video_streams(info: &PlayerMediaInfo) -> Vec<PlayerVideoInfo> {
415 skip_assert_initialized!();
416 unsafe {
417 FromGlibPtrContainer::from_glib_none(ffi::gst_player_get_video_streams(
418 info.to_glib_none().0,
419 ))
420 }
421 }
422
423 #[doc(alias = "gst_player_visualizations_get")]
424 pub fn visualizations_get() -> Vec<PlayerVisualization> {
425 assert_initialized_main_thread!();
426 unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_player_visualizations_get()) }
427 }
428
429 #[doc(alias = "buffering")]
430 pub fn connect_buffering<F: Fn(&Self, i32) + Send + 'static>(&self, f: F) -> SignalHandlerId {
431 unsafe extern "C" fn buffering_trampoline<F: Fn(&Player, i32) + Send + 'static>(
432 this: *mut ffi::GstPlayer,
433 object: std::ffi::c_int,
434 f: glib::ffi::gpointer,
435 ) {
436 unsafe {
437 let f: &F = &*(f as *const F);
438 f(&from_glib_borrow(this), object)
439 }
440 }
441 unsafe {
442 let f: Box_<F> = Box_::new(f);
443 connect_raw(
444 self.as_ptr() as *mut _,
445 c"buffering".as_ptr(),
446 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
447 buffering_trampoline::<F> as *const (),
448 )),
449 Box_::into_raw(f),
450 )
451 }
452 }
453
454 #[doc(alias = "end-of-stream")]
455 pub fn connect_end_of_stream<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
456 unsafe extern "C" fn end_of_stream_trampoline<F: Fn(&Player) + Send + 'static>(
457 this: *mut ffi::GstPlayer,
458 f: glib::ffi::gpointer,
459 ) {
460 unsafe {
461 let f: &F = &*(f as *const F);
462 f(&from_glib_borrow(this))
463 }
464 }
465 unsafe {
466 let f: Box_<F> = Box_::new(f);
467 connect_raw(
468 self.as_ptr() as *mut _,
469 c"end-of-stream".as_ptr(),
470 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
471 end_of_stream_trampoline::<F> as *const (),
472 )),
473 Box_::into_raw(f),
474 )
475 }
476 }
477
478 #[doc(alias = "error")]
479 pub fn connect_error<F: Fn(&Self, &glib::Error) + Send + 'static>(
480 &self,
481 f: F,
482 ) -> SignalHandlerId {
483 unsafe extern "C" fn error_trampoline<F: Fn(&Player, &glib::Error) + Send + 'static>(
484 this: *mut ffi::GstPlayer,
485 object: *mut glib::ffi::GError,
486 f: glib::ffi::gpointer,
487 ) {
488 unsafe {
489 let f: &F = &*(f as *const F);
490 f(&from_glib_borrow(this), &from_glib_borrow(object))
491 }
492 }
493 unsafe {
494 let f: Box_<F> = Box_::new(f);
495 connect_raw(
496 self.as_ptr() as *mut _,
497 c"error".as_ptr(),
498 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
499 error_trampoline::<F> as *const (),
500 )),
501 Box_::into_raw(f),
502 )
503 }
504 }
505
506 #[doc(alias = "media-info-updated")]
507 pub fn connect_media_info_updated<F: Fn(&Self, &PlayerMediaInfo) + Send + 'static>(
508 &self,
509 f: F,
510 ) -> SignalHandlerId {
511 unsafe extern "C" fn media_info_updated_trampoline<
512 F: Fn(&Player, &PlayerMediaInfo) + Send + 'static,
513 >(
514 this: *mut ffi::GstPlayer,
515 object: *mut ffi::GstPlayerMediaInfo,
516 f: glib::ffi::gpointer,
517 ) {
518 unsafe {
519 let f: &F = &*(f as *const F);
520 f(&from_glib_borrow(this), &from_glib_borrow(object))
521 }
522 }
523 unsafe {
524 let f: Box_<F> = Box_::new(f);
525 connect_raw(
526 self.as_ptr() as *mut _,
527 c"media-info-updated".as_ptr(),
528 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
529 media_info_updated_trampoline::<F> as *const (),
530 )),
531 Box_::into_raw(f),
532 )
533 }
534 }
535
536 #[doc(alias = "mute-changed")]
537 pub fn connect_mute_changed<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
538 unsafe extern "C" fn mute_changed_trampoline<F: Fn(&Player) + Send + 'static>(
539 this: *mut ffi::GstPlayer,
540 f: glib::ffi::gpointer,
541 ) {
542 unsafe {
543 let f: &F = &*(f as *const F);
544 f(&from_glib_borrow(this))
545 }
546 }
547 unsafe {
548 let f: Box_<F> = Box_::new(f);
549 connect_raw(
550 self.as_ptr() as *mut _,
551 c"mute-changed".as_ptr(),
552 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
553 mute_changed_trampoline::<F> as *const (),
554 )),
555 Box_::into_raw(f),
556 )
557 }
558 }
559
560 #[doc(alias = "state-changed")]
561 pub fn connect_state_changed<F: Fn(&Self, PlayerState) + Send + 'static>(
562 &self,
563 f: F,
564 ) -> SignalHandlerId {
565 unsafe extern "C" fn state_changed_trampoline<
566 F: Fn(&Player, PlayerState) + Send + 'static,
567 >(
568 this: *mut ffi::GstPlayer,
569 object: ffi::GstPlayerState,
570 f: glib::ffi::gpointer,
571 ) {
572 unsafe {
573 let f: &F = &*(f as *const F);
574 f(&from_glib_borrow(this), from_glib(object))
575 }
576 }
577 unsafe {
578 let f: Box_<F> = Box_::new(f);
579 connect_raw(
580 self.as_ptr() as *mut _,
581 c"state-changed".as_ptr(),
582 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
583 state_changed_trampoline::<F> as *const (),
584 )),
585 Box_::into_raw(f),
586 )
587 }
588 }
589
590 #[doc(alias = "uri-loaded")]
591 pub fn connect_uri_loaded<F: Fn(&Self, &str) + Send + 'static>(&self, f: F) -> SignalHandlerId {
592 unsafe extern "C" fn uri_loaded_trampoline<F: Fn(&Player, &str) + Send + 'static>(
593 this: *mut ffi::GstPlayer,
594 object: *mut std::ffi::c_char,
595 f: glib::ffi::gpointer,
596 ) {
597 unsafe {
598 let f: &F = &*(f as *const F);
599 f(
600 &from_glib_borrow(this),
601 &glib::GString::from_glib_borrow(object),
602 )
603 }
604 }
605 unsafe {
606 let f: Box_<F> = Box_::new(f);
607 connect_raw(
608 self.as_ptr() as *mut _,
609 c"uri-loaded".as_ptr(),
610 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
611 uri_loaded_trampoline::<F> as *const (),
612 )),
613 Box_::into_raw(f),
614 )
615 }
616 }
617
618 #[doc(alias = "video-dimensions-changed")]
619 pub fn connect_video_dimensions_changed<F: Fn(&Self, i32, i32) + Send + 'static>(
620 &self,
621 f: F,
622 ) -> SignalHandlerId {
623 unsafe extern "C" fn video_dimensions_changed_trampoline<
624 F: Fn(&Player, i32, i32) + Send + 'static,
625 >(
626 this: *mut ffi::GstPlayer,
627 object: std::ffi::c_int,
628 p0: std::ffi::c_int,
629 f: glib::ffi::gpointer,
630 ) {
631 unsafe {
632 let f: &F = &*(f as *const F);
633 f(&from_glib_borrow(this), object, p0)
634 }
635 }
636 unsafe {
637 let f: Box_<F> = Box_::new(f);
638 connect_raw(
639 self.as_ptr() as *mut _,
640 c"video-dimensions-changed".as_ptr(),
641 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
642 video_dimensions_changed_trampoline::<F> as *const (),
643 )),
644 Box_::into_raw(f),
645 )
646 }
647 }
648
649 #[doc(alias = "volume-changed")]
650 pub fn connect_volume_changed<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
651 unsafe extern "C" fn volume_changed_trampoline<F: Fn(&Player) + Send + 'static>(
652 this: *mut ffi::GstPlayer,
653 f: glib::ffi::gpointer,
654 ) {
655 unsafe {
656 let f: &F = &*(f as *const F);
657 f(&from_glib_borrow(this))
658 }
659 }
660 unsafe {
661 let f: Box_<F> = Box_::new(f);
662 connect_raw(
663 self.as_ptr() as *mut _,
664 c"volume-changed".as_ptr(),
665 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
666 volume_changed_trampoline::<F> as *const (),
667 )),
668 Box_::into_raw(f),
669 )
670 }
671 }
672
673 #[doc(alias = "warning")]
674 pub fn connect_warning<F: Fn(&Self, &glib::Error) + Send + 'static>(
675 &self,
676 f: F,
677 ) -> SignalHandlerId {
678 unsafe extern "C" fn warning_trampoline<F: Fn(&Player, &glib::Error) + Send + 'static>(
679 this: *mut ffi::GstPlayer,
680 object: *mut glib::ffi::GError,
681 f: glib::ffi::gpointer,
682 ) {
683 unsafe {
684 let f: &F = &*(f as *const F);
685 f(&from_glib_borrow(this), &from_glib_borrow(object))
686 }
687 }
688 unsafe {
689 let f: Box_<F> = Box_::new(f);
690 connect_raw(
691 self.as_ptr() as *mut _,
692 c"warning".as_ptr(),
693 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
694 warning_trampoline::<F> as *const (),
695 )),
696 Box_::into_raw(f),
697 )
698 }
699 }
700
701 #[doc(alias = "audio-video-offset")]
702 pub fn connect_audio_video_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
703 &self,
704 f: F,
705 ) -> SignalHandlerId {
706 unsafe extern "C" fn notify_audio_video_offset_trampoline<
707 F: Fn(&Player) + Send + Sync + 'static,
708 >(
709 this: *mut ffi::GstPlayer,
710 _param_spec: glib::ffi::gpointer,
711 f: glib::ffi::gpointer,
712 ) {
713 unsafe {
714 let f: &F = &*(f as *const F);
715 f(&from_glib_borrow(this))
716 }
717 }
718 unsafe {
719 let f: Box_<F> = Box_::new(f);
720 connect_raw(
721 self.as_ptr() as *mut _,
722 c"notify::audio-video-offset".as_ptr(),
723 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
724 notify_audio_video_offset_trampoline::<F> as *const (),
725 )),
726 Box_::into_raw(f),
727 )
728 }
729 }
730
731 #[doc(alias = "current-audio-track")]
732 pub fn connect_current_audio_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
733 &self,
734 f: F,
735 ) -> SignalHandlerId {
736 unsafe extern "C" fn notify_current_audio_track_trampoline<
737 F: Fn(&Player) + Send + Sync + 'static,
738 >(
739 this: *mut ffi::GstPlayer,
740 _param_spec: glib::ffi::gpointer,
741 f: glib::ffi::gpointer,
742 ) {
743 unsafe {
744 let f: &F = &*(f as *const F);
745 f(&from_glib_borrow(this))
746 }
747 }
748 unsafe {
749 let f: Box_<F> = Box_::new(f);
750 connect_raw(
751 self.as_ptr() as *mut _,
752 c"notify::current-audio-track".as_ptr(),
753 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
754 notify_current_audio_track_trampoline::<F> as *const (),
755 )),
756 Box_::into_raw(f),
757 )
758 }
759 }
760
761 #[doc(alias = "current-subtitle-track")]
762 pub fn connect_current_subtitle_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
763 &self,
764 f: F,
765 ) -> SignalHandlerId {
766 unsafe extern "C" fn notify_current_subtitle_track_trampoline<
767 F: Fn(&Player) + Send + Sync + 'static,
768 >(
769 this: *mut ffi::GstPlayer,
770 _param_spec: glib::ffi::gpointer,
771 f: glib::ffi::gpointer,
772 ) {
773 unsafe {
774 let f: &F = &*(f as *const F);
775 f(&from_glib_borrow(this))
776 }
777 }
778 unsafe {
779 let f: Box_<F> = Box_::new(f);
780 connect_raw(
781 self.as_ptr() as *mut _,
782 c"notify::current-subtitle-track".as_ptr(),
783 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
784 notify_current_subtitle_track_trampoline::<F> as *const (),
785 )),
786 Box_::into_raw(f),
787 )
788 }
789 }
790
791 #[doc(alias = "current-video-track")]
792 pub fn connect_current_video_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
793 &self,
794 f: F,
795 ) -> SignalHandlerId {
796 unsafe extern "C" fn notify_current_video_track_trampoline<
797 F: Fn(&Player) + Send + Sync + 'static,
798 >(
799 this: *mut ffi::GstPlayer,
800 _param_spec: glib::ffi::gpointer,
801 f: glib::ffi::gpointer,
802 ) {
803 unsafe {
804 let f: &F = &*(f as *const F);
805 f(&from_glib_borrow(this))
806 }
807 }
808 unsafe {
809 let f: Box_<F> = Box_::new(f);
810 connect_raw(
811 self.as_ptr() as *mut _,
812 c"notify::current-video-track".as_ptr(),
813 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
814 notify_current_video_track_trampoline::<F> as *const (),
815 )),
816 Box_::into_raw(f),
817 )
818 }
819 }
820
821 #[doc(alias = "duration")]
822 pub fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
823 &self,
824 f: F,
825 ) -> SignalHandlerId {
826 unsafe extern "C" fn notify_duration_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
827 this: *mut ffi::GstPlayer,
828 _param_spec: glib::ffi::gpointer,
829 f: glib::ffi::gpointer,
830 ) {
831 unsafe {
832 let f: &F = &*(f as *const F);
833 f(&from_glib_borrow(this))
834 }
835 }
836 unsafe {
837 let f: Box_<F> = Box_::new(f);
838 connect_raw(
839 self.as_ptr() as *mut _,
840 c"notify::duration".as_ptr(),
841 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
842 notify_duration_trampoline::<F> as *const (),
843 )),
844 Box_::into_raw(f),
845 )
846 }
847 }
848
849 #[doc(alias = "media-info")]
850 pub fn connect_media_info_notify<F: Fn(&Self) + Send + Sync + 'static>(
851 &self,
852 f: F,
853 ) -> SignalHandlerId {
854 unsafe extern "C" fn notify_media_info_trampoline<
855 F: Fn(&Player) + Send + Sync + 'static,
856 >(
857 this: *mut ffi::GstPlayer,
858 _param_spec: glib::ffi::gpointer,
859 f: glib::ffi::gpointer,
860 ) {
861 unsafe {
862 let f: &F = &*(f as *const F);
863 f(&from_glib_borrow(this))
864 }
865 }
866 unsafe {
867 let f: Box_<F> = Box_::new(f);
868 connect_raw(
869 self.as_ptr() as *mut _,
870 c"notify::media-info".as_ptr(),
871 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
872 notify_media_info_trampoline::<F> as *const (),
873 )),
874 Box_::into_raw(f),
875 )
876 }
877 }
878
879 #[doc(alias = "mute")]
880 pub fn connect_mute_notify<F: Fn(&Self) + Send + Sync + 'static>(
881 &self,
882 f: F,
883 ) -> SignalHandlerId {
884 unsafe extern "C" fn notify_mute_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
885 this: *mut ffi::GstPlayer,
886 _param_spec: glib::ffi::gpointer,
887 f: glib::ffi::gpointer,
888 ) {
889 unsafe {
890 let f: &F = &*(f as *const F);
891 f(&from_glib_borrow(this))
892 }
893 }
894 unsafe {
895 let f: Box_<F> = Box_::new(f);
896 connect_raw(
897 self.as_ptr() as *mut _,
898 c"notify::mute".as_ptr(),
899 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
900 notify_mute_trampoline::<F> as *const (),
901 )),
902 Box_::into_raw(f),
903 )
904 }
905 }
906
907 #[doc(alias = "pipeline")]
908 pub fn connect_pipeline_notify<F: Fn(&Self) + Send + Sync + 'static>(
909 &self,
910 f: F,
911 ) -> SignalHandlerId {
912 unsafe extern "C" fn notify_pipeline_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
913 this: *mut ffi::GstPlayer,
914 _param_spec: glib::ffi::gpointer,
915 f: glib::ffi::gpointer,
916 ) {
917 unsafe {
918 let f: &F = &*(f as *const F);
919 f(&from_glib_borrow(this))
920 }
921 }
922 unsafe {
923 let f: Box_<F> = Box_::new(f);
924 connect_raw(
925 self.as_ptr() as *mut _,
926 c"notify::pipeline".as_ptr(),
927 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
928 notify_pipeline_trampoline::<F> as *const (),
929 )),
930 Box_::into_raw(f),
931 )
932 }
933 }
934
935 #[doc(alias = "position")]
936 pub fn connect_position_notify<F: Fn(&Self) + Send + Sync + 'static>(
937 &self,
938 f: F,
939 ) -> SignalHandlerId {
940 unsafe extern "C" fn notify_position_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
941 this: *mut ffi::GstPlayer,
942 _param_spec: glib::ffi::gpointer,
943 f: glib::ffi::gpointer,
944 ) {
945 unsafe {
946 let f: &F = &*(f as *const F);
947 f(&from_glib_borrow(this))
948 }
949 }
950 unsafe {
951 let f: Box_<F> = Box_::new(f);
952 connect_raw(
953 self.as_ptr() as *mut _,
954 c"notify::position".as_ptr(),
955 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
956 notify_position_trampoline::<F> as *const (),
957 )),
958 Box_::into_raw(f),
959 )
960 }
961 }
962
963 #[doc(alias = "rate")]
964 pub fn connect_rate_notify<F: Fn(&Self) + Send + Sync + 'static>(
965 &self,
966 f: F,
967 ) -> SignalHandlerId {
968 unsafe extern "C" fn notify_rate_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
969 this: *mut ffi::GstPlayer,
970 _param_spec: glib::ffi::gpointer,
971 f: glib::ffi::gpointer,
972 ) {
973 unsafe {
974 let f: &F = &*(f as *const F);
975 f(&from_glib_borrow(this))
976 }
977 }
978 unsafe {
979 let f: Box_<F> = Box_::new(f);
980 connect_raw(
981 self.as_ptr() as *mut _,
982 c"notify::rate".as_ptr(),
983 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
984 notify_rate_trampoline::<F> as *const (),
985 )),
986 Box_::into_raw(f),
987 )
988 }
989 }
990
991 #[cfg(feature = "v1_16")]
992 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
993 #[doc(alias = "subtitle-video-offset")]
994 pub fn connect_subtitle_video_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
995 &self,
996 f: F,
997 ) -> SignalHandlerId {
998 unsafe extern "C" fn notify_subtitle_video_offset_trampoline<
999 F: Fn(&Player) + Send + Sync + 'static,
1000 >(
1001 this: *mut ffi::GstPlayer,
1002 _param_spec: glib::ffi::gpointer,
1003 f: glib::ffi::gpointer,
1004 ) {
1005 unsafe {
1006 let f: &F = &*(f as *const F);
1007 f(&from_glib_borrow(this))
1008 }
1009 }
1010 unsafe {
1011 let f: Box_<F> = Box_::new(f);
1012 connect_raw(
1013 self.as_ptr() as *mut _,
1014 c"notify::subtitle-video-offset".as_ptr(),
1015 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1016 notify_subtitle_video_offset_trampoline::<F> as *const (),
1017 )),
1018 Box_::into_raw(f),
1019 )
1020 }
1021 }
1022
1023 #[doc(alias = "suburi")]
1024 pub fn connect_suburi_notify<F: Fn(&Self) + Send + Sync + 'static>(
1025 &self,
1026 f: F,
1027 ) -> SignalHandlerId {
1028 unsafe extern "C" fn notify_suburi_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1029 this: *mut ffi::GstPlayer,
1030 _param_spec: glib::ffi::gpointer,
1031 f: glib::ffi::gpointer,
1032 ) {
1033 unsafe {
1034 let f: &F = &*(f as *const F);
1035 f(&from_glib_borrow(this))
1036 }
1037 }
1038 unsafe {
1039 let f: Box_<F> = Box_::new(f);
1040 connect_raw(
1041 self.as_ptr() as *mut _,
1042 c"notify::suburi".as_ptr(),
1043 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1044 notify_suburi_trampoline::<F> as *const (),
1045 )),
1046 Box_::into_raw(f),
1047 )
1048 }
1049 }
1050
1051 #[doc(alias = "uri")]
1052 pub fn connect_uri_notify<F: Fn(&Self) + Send + Sync + 'static>(
1053 &self,
1054 f: F,
1055 ) -> SignalHandlerId {
1056 unsafe extern "C" fn notify_uri_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1057 this: *mut ffi::GstPlayer,
1058 _param_spec: glib::ffi::gpointer,
1059 f: glib::ffi::gpointer,
1060 ) {
1061 unsafe {
1062 let f: &F = &*(f as *const F);
1063 f(&from_glib_borrow(this))
1064 }
1065 }
1066 unsafe {
1067 let f: Box_<F> = Box_::new(f);
1068 connect_raw(
1069 self.as_ptr() as *mut _,
1070 c"notify::uri".as_ptr(),
1071 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1072 notify_uri_trampoline::<F> as *const (),
1073 )),
1074 Box_::into_raw(f),
1075 )
1076 }
1077 }
1078
1079 #[doc(alias = "video-multiview-flags")]
1080 pub fn connect_video_multiview_flags_notify<F: Fn(&Self) + Send + Sync + 'static>(
1081 &self,
1082 f: F,
1083 ) -> SignalHandlerId {
1084 unsafe extern "C" fn notify_video_multiview_flags_trampoline<
1085 F: Fn(&Player) + Send + Sync + 'static,
1086 >(
1087 this: *mut ffi::GstPlayer,
1088 _param_spec: glib::ffi::gpointer,
1089 f: glib::ffi::gpointer,
1090 ) {
1091 unsafe {
1092 let f: &F = &*(f as *const F);
1093 f(&from_glib_borrow(this))
1094 }
1095 }
1096 unsafe {
1097 let f: Box_<F> = Box_::new(f);
1098 connect_raw(
1099 self.as_ptr() as *mut _,
1100 c"notify::video-multiview-flags".as_ptr(),
1101 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1102 notify_video_multiview_flags_trampoline::<F> as *const (),
1103 )),
1104 Box_::into_raw(f),
1105 )
1106 }
1107 }
1108
1109 #[doc(alias = "video-multiview-mode")]
1110 pub fn connect_video_multiview_mode_notify<F: Fn(&Self) + Send + Sync + 'static>(
1111 &self,
1112 f: F,
1113 ) -> SignalHandlerId {
1114 unsafe extern "C" fn notify_video_multiview_mode_trampoline<
1115 F: Fn(&Player) + Send + Sync + 'static,
1116 >(
1117 this: *mut ffi::GstPlayer,
1118 _param_spec: glib::ffi::gpointer,
1119 f: glib::ffi::gpointer,
1120 ) {
1121 unsafe {
1122 let f: &F = &*(f as *const F);
1123 f(&from_glib_borrow(this))
1124 }
1125 }
1126 unsafe {
1127 let f: Box_<F> = Box_::new(f);
1128 connect_raw(
1129 self.as_ptr() as *mut _,
1130 c"notify::video-multiview-mode".as_ptr(),
1131 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1132 notify_video_multiview_mode_trampoline::<F> as *const (),
1133 )),
1134 Box_::into_raw(f),
1135 )
1136 }
1137 }
1138
1139 #[doc(alias = "volume")]
1140 pub fn connect_volume_notify<F: Fn(&Self) + Send + Sync + 'static>(
1141 &self,
1142 f: F,
1143 ) -> SignalHandlerId {
1144 unsafe extern "C" fn notify_volume_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1145 this: *mut ffi::GstPlayer,
1146 _param_spec: glib::ffi::gpointer,
1147 f: glib::ffi::gpointer,
1148 ) {
1149 unsafe {
1150 let f: &F = &*(f as *const F);
1151 f(&from_glib_borrow(this))
1152 }
1153 }
1154 unsafe {
1155 let f: Box_<F> = Box_::new(f);
1156 connect_raw(
1157 self.as_ptr() as *mut _,
1158 c"notify::volume".as_ptr(),
1159 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1160 notify_volume_trampoline::<F> as *const (),
1161 )),
1162 Box_::into_raw(f),
1163 )
1164 }
1165 }
1166}
1167
1168unsafe impl Send for Player {}
1169unsafe impl Sync for Player {}