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")]
180 pub struct Player(Object<ffi::GstPlayer, ffi::GstPlayerClass>) @extends gst::Object;
181
182 match fn {
183 type_ => || ffi::gst_player_get_type(),
184 }
185}
186
187impl Player {
188 #[doc(alias = "gst_player_new")]
207 pub fn new(
208 video_renderer: Option<impl IsA<PlayerVideoRenderer>>,
209 signal_dispatcher: Option<impl IsA<PlayerSignalDispatcher>>,
210 ) -> Player {
211 assert_initialized_main_thread!();
212 unsafe {
213 from_glib_full(ffi::gst_player_new(
214 video_renderer.map(|p| p.upcast()).into_glib_ptr(),
215 signal_dispatcher.map(|p| p.upcast()).into_glib_ptr(),
216 ))
217 }
218 }
219
220 #[doc(alias = "gst_player_get_audio_video_offset")]
226 #[doc(alias = "get_audio_video_offset")]
227 #[doc(alias = "audio-video-offset")]
228 pub fn audio_video_offset(&self) -> i64 {
229 unsafe { ffi::gst_player_get_audio_video_offset(self.to_glib_none().0) }
230 }
231
232 #[doc(alias = "gst_player_get_color_balance")]
241 #[doc(alias = "get_color_balance")]
242 pub fn color_balance(&self, type_: PlayerColorBalanceType) -> f64 {
243 unsafe { ffi::gst_player_get_color_balance(self.to_glib_none().0, type_.into_glib()) }
244 }
245
246 #[doc(alias = "gst_player_get_current_audio_track")]
254 #[doc(alias = "get_current_audio_track")]
255 #[doc(alias = "current-audio-track")]
256 pub fn current_audio_track(&self) -> Option<PlayerAudioInfo> {
257 unsafe {
258 from_glib_full(ffi::gst_player_get_current_audio_track(
259 self.to_glib_none().0,
260 ))
261 }
262 }
263
264 #[doc(alias = "gst_player_get_current_subtitle_track")]
272 #[doc(alias = "get_current_subtitle_track")]
273 #[doc(alias = "current-subtitle-track")]
274 pub fn current_subtitle_track(&self) -> Option<PlayerSubtitleInfo> {
275 unsafe {
276 from_glib_full(ffi::gst_player_get_current_subtitle_track(
277 self.to_glib_none().0,
278 ))
279 }
280 }
281
282 #[doc(alias = "gst_player_get_current_video_track")]
290 #[doc(alias = "get_current_video_track")]
291 #[doc(alias = "current-video-track")]
292 pub fn current_video_track(&self) -> Option<PlayerVideoInfo> {
293 unsafe {
294 from_glib_full(ffi::gst_player_get_current_video_track(
295 self.to_glib_none().0,
296 ))
297 }
298 }
299
300 #[doc(alias = "gst_player_get_current_visualization")]
307 #[doc(alias = "get_current_visualization")]
308 pub fn current_visualization(&self) -> Option<glib::GString> {
309 unsafe {
310 from_glib_full(ffi::gst_player_get_current_visualization(
311 self.to_glib_none().0,
312 ))
313 }
314 }
315
316 #[doc(alias = "gst_player_get_duration")]
323 #[doc(alias = "get_duration")]
324 pub fn duration(&self) -> Option<gst::ClockTime> {
325 unsafe { from_glib(ffi::gst_player_get_duration(self.to_glib_none().0)) }
326 }
327
328 #[doc(alias = "gst_player_get_media_info")]
336 #[doc(alias = "get_media_info")]
337 #[doc(alias = "media-info")]
338 pub fn media_info(&self) -> Option<PlayerMediaInfo> {
339 unsafe { from_glib_full(ffi::gst_player_get_media_info(self.to_glib_none().0)) }
340 }
341
342 #[doc(alias = "gst_player_get_multiview_flags")]
348 #[doc(alias = "get_multiview_flags")]
349 pub fn multiview_flags(&self) -> gst_video::VideoMultiviewFlags {
350 unsafe { from_glib(ffi::gst_player_get_multiview_flags(self.to_glib_none().0)) }
351 }
352
353 #[doc(alias = "gst_player_get_multiview_mode")]
359 #[doc(alias = "get_multiview_mode")]
360 pub fn multiview_mode(&self) -> gst_video::VideoMultiviewFramePacking {
361 unsafe { from_glib(ffi::gst_player_get_multiview_mode(self.to_glib_none().0)) }
362 }
363
364 #[doc(alias = "gst_player_get_mute")]
369 #[doc(alias = "get_mute")]
370 #[doc(alias = "mute")]
371 pub fn is_muted(&self) -> bool {
372 unsafe { from_glib(ffi::gst_player_get_mute(self.to_glib_none().0)) }
373 }
374
375 #[doc(alias = "gst_player_get_pipeline")]
382 #[doc(alias = "get_pipeline")]
383 pub fn pipeline(&self) -> gst::Element {
384 unsafe { from_glib_full(ffi::gst_player_get_pipeline(self.to_glib_none().0)) }
385 }
386
387 #[doc(alias = "gst_player_get_position")]
393 #[doc(alias = "get_position")]
394 pub fn position(&self) -> Option<gst::ClockTime> {
395 unsafe { from_glib(ffi::gst_player_get_position(self.to_glib_none().0)) }
396 }
397
398 #[doc(alias = "gst_player_get_rate")]
403 #[doc(alias = "get_rate")]
404 pub fn rate(&self) -> f64 {
405 unsafe { ffi::gst_player_get_rate(self.to_glib_none().0) }
406 }
407
408 #[doc(alias = "gst_player_get_subtitle_uri")]
415 #[doc(alias = "get_subtitle_uri")]
416 pub fn subtitle_uri(&self) -> Option<glib::GString> {
417 unsafe { from_glib_full(ffi::gst_player_get_subtitle_uri(self.to_glib_none().0)) }
418 }
419
420 #[cfg(feature = "v1_16")]
426 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
427 #[doc(alias = "gst_player_get_subtitle_video_offset")]
428 #[doc(alias = "get_subtitle_video_offset")]
429 #[doc(alias = "subtitle-video-offset")]
430 pub fn subtitle_video_offset(&self) -> i64 {
431 unsafe { ffi::gst_player_get_subtitle_video_offset(self.to_glib_none().0) }
432 }
433
434 #[doc(alias = "gst_player_get_uri")]
441 #[doc(alias = "get_uri")]
442 pub fn uri(&self) -> Option<glib::GString> {
443 unsafe { from_glib_full(ffi::gst_player_get_uri(self.to_glib_none().0)) }
444 }
445
446 #[doc(alias = "gst_player_get_volume")]
452 #[doc(alias = "get_volume")]
453 pub fn volume(&self) -> f64 {
454 unsafe { ffi::gst_player_get_volume(self.to_glib_none().0) }
455 }
456
457 #[doc(alias = "gst_player_has_color_balance")]
464 pub fn has_color_balance(&self) -> bool {
465 unsafe { from_glib(ffi::gst_player_has_color_balance(self.to_glib_none().0)) }
466 }
467
468 #[doc(alias = "gst_player_pause")]
470 pub fn pause(&self) {
471 unsafe {
472 ffi::gst_player_pause(self.to_glib_none().0);
473 }
474 }
475
476 #[doc(alias = "gst_player_play")]
478 pub fn play(&self) {
479 unsafe {
480 ffi::gst_player_play(self.to_glib_none().0);
481 }
482 }
483
484 #[doc(alias = "gst_player_seek")]
489 pub fn seek(&self, position: gst::ClockTime) {
490 unsafe {
491 ffi::gst_player_seek(self.to_glib_none().0, position.into_glib());
492 }
493 }
494
495 #[doc(alias = "gst_player_set_audio_track")]
504 pub fn set_audio_track(&self, stream_index: i32) -> Result<(), glib::error::BoolError> {
505 unsafe {
506 glib::result_from_gboolean!(
507 ffi::gst_player_set_audio_track(self.to_glib_none().0, stream_index),
508 "Failed to set audio track"
509 )
510 }
511 }
512
513 #[doc(alias = "gst_player_set_audio_track_enabled")]
517 pub fn set_audio_track_enabled(&self, enabled: bool) {
518 unsafe {
519 ffi::gst_player_set_audio_track_enabled(self.to_glib_none().0, enabled.into_glib());
520 }
521 }
522
523 #[doc(alias = "gst_player_set_audio_video_offset")]
527 #[doc(alias = "audio-video-offset")]
528 pub fn set_audio_video_offset(&self, offset: i64) {
529 unsafe {
530 ffi::gst_player_set_audio_video_offset(self.to_glib_none().0, offset);
531 }
532 }
533
534 #[doc(alias = "gst_player_set_color_balance")]
541 pub fn set_color_balance(&self, type_: PlayerColorBalanceType, value: f64) {
542 unsafe {
543 ffi::gst_player_set_color_balance(self.to_glib_none().0, type_.into_glib(), value);
544 }
545 }
546
547 #[doc(alias = "gst_player_set_multiview_flags")]
552 pub fn set_multiview_flags(&self, flags: gst_video::VideoMultiviewFlags) {
553 unsafe {
554 ffi::gst_player_set_multiview_flags(self.to_glib_none().0, flags.into_glib());
555 }
556 }
557
558 #[doc(alias = "gst_player_set_multiview_mode")]
563 pub fn set_multiview_mode(&self, mode: gst_video::VideoMultiviewFramePacking) {
564 unsafe {
565 ffi::gst_player_set_multiview_mode(self.to_glib_none().0, mode.into_glib());
566 }
567 }
568
569 #[doc(alias = "gst_player_set_mute")]
573 #[doc(alias = "mute")]
574 pub fn set_mute(&self, val: bool) {
575 unsafe {
576 ffi::gst_player_set_mute(self.to_glib_none().0, val.into_glib());
577 }
578 }
579
580 #[doc(alias = "gst_player_set_rate")]
584 #[doc(alias = "rate")]
585 pub fn set_rate(&self, rate: f64) {
586 unsafe {
587 ffi::gst_player_set_rate(self.to_glib_none().0, rate);
588 }
589 }
590
591 #[doc(alias = "gst_player_set_subtitle_track")]
600 pub fn set_subtitle_track(&self, stream_index: i32) -> Result<(), glib::error::BoolError> {
601 unsafe {
602 glib::result_from_gboolean!(
603 ffi::gst_player_set_subtitle_track(self.to_glib_none().0, stream_index),
604 "Failed to set subtitle track"
605 )
606 }
607 }
608
609 #[doc(alias = "gst_player_set_subtitle_track_enabled")]
613 pub fn set_subtitle_track_enabled(&self, enabled: bool) {
614 unsafe {
615 ffi::gst_player_set_subtitle_track_enabled(self.to_glib_none().0, enabled.into_glib());
616 }
617 }
618
619 #[doc(alias = "gst_player_set_subtitle_uri")]
625 pub fn set_subtitle_uri(&self, uri: Option<&str>) {
626 unsafe {
627 ffi::gst_player_set_subtitle_uri(self.to_glib_none().0, uri.to_glib_none().0);
628 }
629 }
630
631 #[cfg(feature = "v1_16")]
635 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
636 #[doc(alias = "gst_player_set_subtitle_video_offset")]
637 #[doc(alias = "subtitle-video-offset")]
638 pub fn set_subtitle_video_offset(&self, offset: i64) {
639 unsafe {
640 ffi::gst_player_set_subtitle_video_offset(self.to_glib_none().0, offset);
641 }
642 }
643
644 #[doc(alias = "gst_player_set_uri")]
648 #[doc(alias = "uri")]
649 pub fn set_uri(&self, uri: Option<&str>) {
650 unsafe {
651 ffi::gst_player_set_uri(self.to_glib_none().0, uri.to_glib_none().0);
652 }
653 }
654
655 #[doc(alias = "gst_player_set_video_track")]
664 pub fn set_video_track(&self, stream_index: i32) -> Result<(), glib::error::BoolError> {
665 unsafe {
666 glib::result_from_gboolean!(
667 ffi::gst_player_set_video_track(self.to_glib_none().0, stream_index),
668 "Failed to set video track"
669 )
670 }
671 }
672
673 #[doc(alias = "gst_player_set_video_track_enabled")]
677 pub fn set_video_track_enabled(&self, enabled: bool) {
678 unsafe {
679 ffi::gst_player_set_video_track_enabled(self.to_glib_none().0, enabled.into_glib());
680 }
681 }
682
683 #[doc(alias = "gst_player_set_visualization")]
692 pub fn set_visualization(&self, name: Option<&str>) -> Result<(), glib::error::BoolError> {
693 unsafe {
694 glib::result_from_gboolean!(
695 ffi::gst_player_set_visualization(self.to_glib_none().0, name.to_glib_none().0),
696 "Failed to set visualization"
697 )
698 }
699 }
700
701 #[doc(alias = "gst_player_set_visualization_enabled")]
705 pub fn set_visualization_enabled(&self, enabled: bool) {
706 unsafe {
707 ffi::gst_player_set_visualization_enabled(self.to_glib_none().0, enabled.into_glib());
708 }
709 }
710
711 #[doc(alias = "gst_player_set_volume")]
719 #[doc(alias = "volume")]
720 pub fn set_volume(&self, val: f64) {
721 unsafe {
722 ffi::gst_player_set_volume(self.to_glib_none().0, val);
723 }
724 }
725
726 #[doc(alias = "gst_player_stop")]
729 pub fn stop(&self) {
730 unsafe {
731 ffi::gst_player_stop(self.to_glib_none().0);
732 }
733 }
734
735 pub fn suburi(&self) -> Option<glib::GString> {
736 ObjectExt::property(self, "suburi")
737 }
738
739 pub fn set_suburi(&self, suburi: Option<&str>) {
740 ObjectExt::set_property(self, "suburi", suburi)
741 }
742
743 #[doc(alias = "video-multiview-flags")]
744 pub fn video_multiview_flags(&self) -> gst_video::VideoMultiviewFlags {
745 ObjectExt::property(self, "video-multiview-flags")
746 }
747
748 #[doc(alias = "video-multiview-flags")]
749 pub fn set_video_multiview_flags(&self, video_multiview_flags: gst_video::VideoMultiviewFlags) {
750 ObjectExt::set_property(self, "video-multiview-flags", video_multiview_flags)
751 }
752
753 #[doc(alias = "video-multiview-mode")]
754 pub fn video_multiview_mode(&self) -> gst_video::VideoMultiviewFramePacking {
755 ObjectExt::property(self, "video-multiview-mode")
756 }
757
758 #[doc(alias = "video-multiview-mode")]
759 pub fn set_video_multiview_mode(
760 &self,
761 video_multiview_mode: gst_video::VideoMultiviewFramePacking,
762 ) {
763 ObjectExt::set_property(self, "video-multiview-mode", video_multiview_mode)
764 }
765
766 #[doc(alias = "video-renderer")]
767 pub fn video_renderer(&self) -> Option<PlayerVideoRenderer> {
768 ObjectExt::property(self, "video-renderer")
769 }
770
771 #[doc(alias = "gst_player_get_audio_streams")]
779 #[doc(alias = "get_audio_streams")]
780 pub fn audio_streams(info: &PlayerMediaInfo) -> Vec<PlayerAudioInfo> {
781 skip_assert_initialized!();
782 unsafe {
783 FromGlibPtrContainer::from_glib_none(ffi::gst_player_get_audio_streams(
784 info.to_glib_none().0,
785 ))
786 }
787 }
788
789 #[doc(alias = "gst_player_get_subtitle_streams")]
797 #[doc(alias = "get_subtitle_streams")]
798 pub fn subtitle_streams(info: &PlayerMediaInfo) -> Vec<PlayerSubtitleInfo> {
799 skip_assert_initialized!();
800 unsafe {
801 FromGlibPtrContainer::from_glib_none(ffi::gst_player_get_subtitle_streams(
802 info.to_glib_none().0,
803 ))
804 }
805 }
806
807 #[doc(alias = "gst_player_get_video_streams")]
815 #[doc(alias = "get_video_streams")]
816 pub fn video_streams(info: &PlayerMediaInfo) -> Vec<PlayerVideoInfo> {
817 skip_assert_initialized!();
818 unsafe {
819 FromGlibPtrContainer::from_glib_none(ffi::gst_player_get_video_streams(
820 info.to_glib_none().0,
821 ))
822 }
823 }
824
825 #[doc(alias = "gst_player_visualizations_get")]
833 pub fn visualizations_get() -> Vec<PlayerVisualization> {
834 assert_initialized_main_thread!();
835 unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_player_visualizations_get()) }
836 }
837
838 #[doc(alias = "buffering")]
839 pub fn connect_buffering<F: Fn(&Self, i32) + Send + 'static>(&self, f: F) -> SignalHandlerId {
840 unsafe extern "C" fn buffering_trampoline<F: Fn(&Player, i32) + Send + 'static>(
841 this: *mut ffi::GstPlayer,
842 object: std::ffi::c_int,
843 f: glib::ffi::gpointer,
844 ) {
845 unsafe {
846 let f: &F = &*(f as *const F);
847 f(&from_glib_borrow(this), object)
848 }
849 }
850 unsafe {
851 let f: Box_<F> = Box_::new(f);
852 connect_raw(
853 self.as_ptr() as *mut _,
854 c"buffering".as_ptr(),
855 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
856 buffering_trampoline::<F> as *const (),
857 )),
858 Box_::into_raw(f),
859 )
860 }
861 }
862
863 #[doc(alias = "end-of-stream")]
864 pub fn connect_end_of_stream<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
865 unsafe extern "C" fn end_of_stream_trampoline<F: Fn(&Player) + Send + 'static>(
866 this: *mut ffi::GstPlayer,
867 f: glib::ffi::gpointer,
868 ) {
869 unsafe {
870 let f: &F = &*(f as *const F);
871 f(&from_glib_borrow(this))
872 }
873 }
874 unsafe {
875 let f: Box_<F> = Box_::new(f);
876 connect_raw(
877 self.as_ptr() as *mut _,
878 c"end-of-stream".as_ptr(),
879 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
880 end_of_stream_trampoline::<F> as *const (),
881 )),
882 Box_::into_raw(f),
883 )
884 }
885 }
886
887 #[doc(alias = "error")]
888 pub fn connect_error<F: Fn(&Self, &glib::Error) + Send + 'static>(
889 &self,
890 f: F,
891 ) -> SignalHandlerId {
892 unsafe extern "C" fn error_trampoline<F: Fn(&Player, &glib::Error) + Send + 'static>(
893 this: *mut ffi::GstPlayer,
894 object: *mut glib::ffi::GError,
895 f: glib::ffi::gpointer,
896 ) {
897 unsafe {
898 let f: &F = &*(f as *const F);
899 f(&from_glib_borrow(this), &from_glib_borrow(object))
900 }
901 }
902 unsafe {
903 let f: Box_<F> = Box_::new(f);
904 connect_raw(
905 self.as_ptr() as *mut _,
906 c"error".as_ptr(),
907 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
908 error_trampoline::<F> as *const (),
909 )),
910 Box_::into_raw(f),
911 )
912 }
913 }
914
915 #[doc(alias = "media-info-updated")]
916 pub fn connect_media_info_updated<F: Fn(&Self, &PlayerMediaInfo) + Send + 'static>(
917 &self,
918 f: F,
919 ) -> SignalHandlerId {
920 unsafe extern "C" fn media_info_updated_trampoline<
921 F: Fn(&Player, &PlayerMediaInfo) + Send + 'static,
922 >(
923 this: *mut ffi::GstPlayer,
924 object: *mut ffi::GstPlayerMediaInfo,
925 f: glib::ffi::gpointer,
926 ) {
927 unsafe {
928 let f: &F = &*(f as *const F);
929 f(&from_glib_borrow(this), &from_glib_borrow(object))
930 }
931 }
932 unsafe {
933 let f: Box_<F> = Box_::new(f);
934 connect_raw(
935 self.as_ptr() as *mut _,
936 c"media-info-updated".as_ptr(),
937 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
938 media_info_updated_trampoline::<F> as *const (),
939 )),
940 Box_::into_raw(f),
941 )
942 }
943 }
944
945 #[doc(alias = "mute-changed")]
946 pub fn connect_mute_changed<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
947 unsafe extern "C" fn mute_changed_trampoline<F: Fn(&Player) + Send + 'static>(
948 this: *mut ffi::GstPlayer,
949 f: glib::ffi::gpointer,
950 ) {
951 unsafe {
952 let f: &F = &*(f as *const F);
953 f(&from_glib_borrow(this))
954 }
955 }
956 unsafe {
957 let f: Box_<F> = Box_::new(f);
958 connect_raw(
959 self.as_ptr() as *mut _,
960 c"mute-changed".as_ptr(),
961 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
962 mute_changed_trampoline::<F> as *const (),
963 )),
964 Box_::into_raw(f),
965 )
966 }
967 }
968
969 #[doc(alias = "state-changed")]
970 pub fn connect_state_changed<F: Fn(&Self, PlayerState) + Send + 'static>(
971 &self,
972 f: F,
973 ) -> SignalHandlerId {
974 unsafe extern "C" fn state_changed_trampoline<
975 F: Fn(&Player, PlayerState) + Send + 'static,
976 >(
977 this: *mut ffi::GstPlayer,
978 object: ffi::GstPlayerState,
979 f: glib::ffi::gpointer,
980 ) {
981 unsafe {
982 let f: &F = &*(f as *const F);
983 f(&from_glib_borrow(this), from_glib(object))
984 }
985 }
986 unsafe {
987 let f: Box_<F> = Box_::new(f);
988 connect_raw(
989 self.as_ptr() as *mut _,
990 c"state-changed".as_ptr(),
991 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
992 state_changed_trampoline::<F> as *const (),
993 )),
994 Box_::into_raw(f),
995 )
996 }
997 }
998
999 #[doc(alias = "uri-loaded")]
1000 pub fn connect_uri_loaded<F: Fn(&Self, &str) + Send + 'static>(&self, f: F) -> SignalHandlerId {
1001 unsafe extern "C" fn uri_loaded_trampoline<F: Fn(&Player, &str) + Send + 'static>(
1002 this: *mut ffi::GstPlayer,
1003 object: *mut std::ffi::c_char,
1004 f: glib::ffi::gpointer,
1005 ) {
1006 unsafe {
1007 let f: &F = &*(f as *const F);
1008 f(
1009 &from_glib_borrow(this),
1010 &glib::GString::from_glib_borrow(object),
1011 )
1012 }
1013 }
1014 unsafe {
1015 let f: Box_<F> = Box_::new(f);
1016 connect_raw(
1017 self.as_ptr() as *mut _,
1018 c"uri-loaded".as_ptr(),
1019 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1020 uri_loaded_trampoline::<F> as *const (),
1021 )),
1022 Box_::into_raw(f),
1023 )
1024 }
1025 }
1026
1027 #[doc(alias = "video-dimensions-changed")]
1028 pub fn connect_video_dimensions_changed<F: Fn(&Self, i32, i32) + Send + 'static>(
1029 &self,
1030 f: F,
1031 ) -> SignalHandlerId {
1032 unsafe extern "C" fn video_dimensions_changed_trampoline<
1033 F: Fn(&Player, i32, i32) + Send + 'static,
1034 >(
1035 this: *mut ffi::GstPlayer,
1036 object: std::ffi::c_int,
1037 p0: std::ffi::c_int,
1038 f: glib::ffi::gpointer,
1039 ) {
1040 unsafe {
1041 let f: &F = &*(f as *const F);
1042 f(&from_glib_borrow(this), object, p0)
1043 }
1044 }
1045 unsafe {
1046 let f: Box_<F> = Box_::new(f);
1047 connect_raw(
1048 self.as_ptr() as *mut _,
1049 c"video-dimensions-changed".as_ptr(),
1050 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1051 video_dimensions_changed_trampoline::<F> as *const (),
1052 )),
1053 Box_::into_raw(f),
1054 )
1055 }
1056 }
1057
1058 #[doc(alias = "volume-changed")]
1059 pub fn connect_volume_changed<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
1060 unsafe extern "C" fn volume_changed_trampoline<F: Fn(&Player) + Send + 'static>(
1061 this: *mut ffi::GstPlayer,
1062 f: glib::ffi::gpointer,
1063 ) {
1064 unsafe {
1065 let f: &F = &*(f as *const F);
1066 f(&from_glib_borrow(this))
1067 }
1068 }
1069 unsafe {
1070 let f: Box_<F> = Box_::new(f);
1071 connect_raw(
1072 self.as_ptr() as *mut _,
1073 c"volume-changed".as_ptr(),
1074 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1075 volume_changed_trampoline::<F> as *const (),
1076 )),
1077 Box_::into_raw(f),
1078 )
1079 }
1080 }
1081
1082 #[doc(alias = "warning")]
1083 pub fn connect_warning<F: Fn(&Self, &glib::Error) + Send + 'static>(
1084 &self,
1085 f: F,
1086 ) -> SignalHandlerId {
1087 unsafe extern "C" fn warning_trampoline<F: Fn(&Player, &glib::Error) + Send + 'static>(
1088 this: *mut ffi::GstPlayer,
1089 object: *mut glib::ffi::GError,
1090 f: glib::ffi::gpointer,
1091 ) {
1092 unsafe {
1093 let f: &F = &*(f as *const F);
1094 f(&from_glib_borrow(this), &from_glib_borrow(object))
1095 }
1096 }
1097 unsafe {
1098 let f: Box_<F> = Box_::new(f);
1099 connect_raw(
1100 self.as_ptr() as *mut _,
1101 c"warning".as_ptr(),
1102 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1103 warning_trampoline::<F> as *const (),
1104 )),
1105 Box_::into_raw(f),
1106 )
1107 }
1108 }
1109
1110 #[doc(alias = "audio-video-offset")]
1111 pub fn connect_audio_video_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
1112 &self,
1113 f: F,
1114 ) -> SignalHandlerId {
1115 unsafe extern "C" fn notify_audio_video_offset_trampoline<
1116 F: Fn(&Player) + Send + Sync + 'static,
1117 >(
1118 this: *mut ffi::GstPlayer,
1119 _param_spec: glib::ffi::gpointer,
1120 f: glib::ffi::gpointer,
1121 ) {
1122 unsafe {
1123 let f: &F = &*(f as *const F);
1124 f(&from_glib_borrow(this))
1125 }
1126 }
1127 unsafe {
1128 let f: Box_<F> = Box_::new(f);
1129 connect_raw(
1130 self.as_ptr() as *mut _,
1131 c"notify::audio-video-offset".as_ptr(),
1132 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1133 notify_audio_video_offset_trampoline::<F> as *const (),
1134 )),
1135 Box_::into_raw(f),
1136 )
1137 }
1138 }
1139
1140 #[doc(alias = "current-audio-track")]
1141 pub fn connect_current_audio_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
1142 &self,
1143 f: F,
1144 ) -> SignalHandlerId {
1145 unsafe extern "C" fn notify_current_audio_track_trampoline<
1146 F: Fn(&Player) + Send + Sync + 'static,
1147 >(
1148 this: *mut ffi::GstPlayer,
1149 _param_spec: glib::ffi::gpointer,
1150 f: glib::ffi::gpointer,
1151 ) {
1152 unsafe {
1153 let f: &F = &*(f as *const F);
1154 f(&from_glib_borrow(this))
1155 }
1156 }
1157 unsafe {
1158 let f: Box_<F> = Box_::new(f);
1159 connect_raw(
1160 self.as_ptr() as *mut _,
1161 c"notify::current-audio-track".as_ptr(),
1162 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1163 notify_current_audio_track_trampoline::<F> as *const (),
1164 )),
1165 Box_::into_raw(f),
1166 )
1167 }
1168 }
1169
1170 #[doc(alias = "current-subtitle-track")]
1171 pub fn connect_current_subtitle_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
1172 &self,
1173 f: F,
1174 ) -> SignalHandlerId {
1175 unsafe extern "C" fn notify_current_subtitle_track_trampoline<
1176 F: Fn(&Player) + Send + Sync + 'static,
1177 >(
1178 this: *mut ffi::GstPlayer,
1179 _param_spec: glib::ffi::gpointer,
1180 f: glib::ffi::gpointer,
1181 ) {
1182 unsafe {
1183 let f: &F = &*(f as *const F);
1184 f(&from_glib_borrow(this))
1185 }
1186 }
1187 unsafe {
1188 let f: Box_<F> = Box_::new(f);
1189 connect_raw(
1190 self.as_ptr() as *mut _,
1191 c"notify::current-subtitle-track".as_ptr(),
1192 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1193 notify_current_subtitle_track_trampoline::<F> as *const (),
1194 )),
1195 Box_::into_raw(f),
1196 )
1197 }
1198 }
1199
1200 #[doc(alias = "current-video-track")]
1201 pub fn connect_current_video_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
1202 &self,
1203 f: F,
1204 ) -> SignalHandlerId {
1205 unsafe extern "C" fn notify_current_video_track_trampoline<
1206 F: Fn(&Player) + Send + Sync + 'static,
1207 >(
1208 this: *mut ffi::GstPlayer,
1209 _param_spec: glib::ffi::gpointer,
1210 f: glib::ffi::gpointer,
1211 ) {
1212 unsafe {
1213 let f: &F = &*(f as *const F);
1214 f(&from_glib_borrow(this))
1215 }
1216 }
1217 unsafe {
1218 let f: Box_<F> = Box_::new(f);
1219 connect_raw(
1220 self.as_ptr() as *mut _,
1221 c"notify::current-video-track".as_ptr(),
1222 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1223 notify_current_video_track_trampoline::<F> as *const (),
1224 )),
1225 Box_::into_raw(f),
1226 )
1227 }
1228 }
1229
1230 #[doc(alias = "duration")]
1231 pub fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
1232 &self,
1233 f: F,
1234 ) -> SignalHandlerId {
1235 unsafe extern "C" fn notify_duration_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1236 this: *mut ffi::GstPlayer,
1237 _param_spec: glib::ffi::gpointer,
1238 f: glib::ffi::gpointer,
1239 ) {
1240 unsafe {
1241 let f: &F = &*(f as *const F);
1242 f(&from_glib_borrow(this))
1243 }
1244 }
1245 unsafe {
1246 let f: Box_<F> = Box_::new(f);
1247 connect_raw(
1248 self.as_ptr() as *mut _,
1249 c"notify::duration".as_ptr(),
1250 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1251 notify_duration_trampoline::<F> as *const (),
1252 )),
1253 Box_::into_raw(f),
1254 )
1255 }
1256 }
1257
1258 #[doc(alias = "media-info")]
1259 pub fn connect_media_info_notify<F: Fn(&Self) + Send + Sync + 'static>(
1260 &self,
1261 f: F,
1262 ) -> SignalHandlerId {
1263 unsafe extern "C" fn notify_media_info_trampoline<
1264 F: Fn(&Player) + Send + Sync + 'static,
1265 >(
1266 this: *mut ffi::GstPlayer,
1267 _param_spec: glib::ffi::gpointer,
1268 f: glib::ffi::gpointer,
1269 ) {
1270 unsafe {
1271 let f: &F = &*(f as *const F);
1272 f(&from_glib_borrow(this))
1273 }
1274 }
1275 unsafe {
1276 let f: Box_<F> = Box_::new(f);
1277 connect_raw(
1278 self.as_ptr() as *mut _,
1279 c"notify::media-info".as_ptr(),
1280 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1281 notify_media_info_trampoline::<F> as *const (),
1282 )),
1283 Box_::into_raw(f),
1284 )
1285 }
1286 }
1287
1288 #[doc(alias = "mute")]
1289 pub fn connect_mute_notify<F: Fn(&Self) + Send + Sync + 'static>(
1290 &self,
1291 f: F,
1292 ) -> SignalHandlerId {
1293 unsafe extern "C" fn notify_mute_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1294 this: *mut ffi::GstPlayer,
1295 _param_spec: glib::ffi::gpointer,
1296 f: glib::ffi::gpointer,
1297 ) {
1298 unsafe {
1299 let f: &F = &*(f as *const F);
1300 f(&from_glib_borrow(this))
1301 }
1302 }
1303 unsafe {
1304 let f: Box_<F> = Box_::new(f);
1305 connect_raw(
1306 self.as_ptr() as *mut _,
1307 c"notify::mute".as_ptr(),
1308 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1309 notify_mute_trampoline::<F> as *const (),
1310 )),
1311 Box_::into_raw(f),
1312 )
1313 }
1314 }
1315
1316 #[doc(alias = "pipeline")]
1317 pub fn connect_pipeline_notify<F: Fn(&Self) + Send + Sync + 'static>(
1318 &self,
1319 f: F,
1320 ) -> SignalHandlerId {
1321 unsafe extern "C" fn notify_pipeline_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1322 this: *mut ffi::GstPlayer,
1323 _param_spec: glib::ffi::gpointer,
1324 f: glib::ffi::gpointer,
1325 ) {
1326 unsafe {
1327 let f: &F = &*(f as *const F);
1328 f(&from_glib_borrow(this))
1329 }
1330 }
1331 unsafe {
1332 let f: Box_<F> = Box_::new(f);
1333 connect_raw(
1334 self.as_ptr() as *mut _,
1335 c"notify::pipeline".as_ptr(),
1336 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1337 notify_pipeline_trampoline::<F> as *const (),
1338 )),
1339 Box_::into_raw(f),
1340 )
1341 }
1342 }
1343
1344 #[doc(alias = "position")]
1345 pub fn connect_position_notify<F: Fn(&Self) + Send + Sync + 'static>(
1346 &self,
1347 f: F,
1348 ) -> SignalHandlerId {
1349 unsafe extern "C" fn notify_position_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1350 this: *mut ffi::GstPlayer,
1351 _param_spec: glib::ffi::gpointer,
1352 f: glib::ffi::gpointer,
1353 ) {
1354 unsafe {
1355 let f: &F = &*(f as *const F);
1356 f(&from_glib_borrow(this))
1357 }
1358 }
1359 unsafe {
1360 let f: Box_<F> = Box_::new(f);
1361 connect_raw(
1362 self.as_ptr() as *mut _,
1363 c"notify::position".as_ptr(),
1364 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1365 notify_position_trampoline::<F> as *const (),
1366 )),
1367 Box_::into_raw(f),
1368 )
1369 }
1370 }
1371
1372 #[doc(alias = "rate")]
1373 pub fn connect_rate_notify<F: Fn(&Self) + Send + Sync + 'static>(
1374 &self,
1375 f: F,
1376 ) -> SignalHandlerId {
1377 unsafe extern "C" fn notify_rate_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1378 this: *mut ffi::GstPlayer,
1379 _param_spec: glib::ffi::gpointer,
1380 f: glib::ffi::gpointer,
1381 ) {
1382 unsafe {
1383 let f: &F = &*(f as *const F);
1384 f(&from_glib_borrow(this))
1385 }
1386 }
1387 unsafe {
1388 let f: Box_<F> = Box_::new(f);
1389 connect_raw(
1390 self.as_ptr() as *mut _,
1391 c"notify::rate".as_ptr(),
1392 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1393 notify_rate_trampoline::<F> as *const (),
1394 )),
1395 Box_::into_raw(f),
1396 )
1397 }
1398 }
1399
1400 #[cfg(feature = "v1_16")]
1401 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
1402 #[doc(alias = "subtitle-video-offset")]
1403 pub fn connect_subtitle_video_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
1404 &self,
1405 f: F,
1406 ) -> SignalHandlerId {
1407 unsafe extern "C" fn notify_subtitle_video_offset_trampoline<
1408 F: Fn(&Player) + Send + Sync + 'static,
1409 >(
1410 this: *mut ffi::GstPlayer,
1411 _param_spec: glib::ffi::gpointer,
1412 f: glib::ffi::gpointer,
1413 ) {
1414 unsafe {
1415 let f: &F = &*(f as *const F);
1416 f(&from_glib_borrow(this))
1417 }
1418 }
1419 unsafe {
1420 let f: Box_<F> = Box_::new(f);
1421 connect_raw(
1422 self.as_ptr() as *mut _,
1423 c"notify::subtitle-video-offset".as_ptr(),
1424 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1425 notify_subtitle_video_offset_trampoline::<F> as *const (),
1426 )),
1427 Box_::into_raw(f),
1428 )
1429 }
1430 }
1431
1432 #[doc(alias = "suburi")]
1433 pub fn connect_suburi_notify<F: Fn(&Self) + Send + Sync + 'static>(
1434 &self,
1435 f: F,
1436 ) -> SignalHandlerId {
1437 unsafe extern "C" fn notify_suburi_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1438 this: *mut ffi::GstPlayer,
1439 _param_spec: glib::ffi::gpointer,
1440 f: glib::ffi::gpointer,
1441 ) {
1442 unsafe {
1443 let f: &F = &*(f as *const F);
1444 f(&from_glib_borrow(this))
1445 }
1446 }
1447 unsafe {
1448 let f: Box_<F> = Box_::new(f);
1449 connect_raw(
1450 self.as_ptr() as *mut _,
1451 c"notify::suburi".as_ptr(),
1452 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1453 notify_suburi_trampoline::<F> as *const (),
1454 )),
1455 Box_::into_raw(f),
1456 )
1457 }
1458 }
1459
1460 #[doc(alias = "uri")]
1461 pub fn connect_uri_notify<F: Fn(&Self) + Send + Sync + 'static>(
1462 &self,
1463 f: F,
1464 ) -> SignalHandlerId {
1465 unsafe extern "C" fn notify_uri_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1466 this: *mut ffi::GstPlayer,
1467 _param_spec: glib::ffi::gpointer,
1468 f: glib::ffi::gpointer,
1469 ) {
1470 unsafe {
1471 let f: &F = &*(f as *const F);
1472 f(&from_glib_borrow(this))
1473 }
1474 }
1475 unsafe {
1476 let f: Box_<F> = Box_::new(f);
1477 connect_raw(
1478 self.as_ptr() as *mut _,
1479 c"notify::uri".as_ptr(),
1480 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1481 notify_uri_trampoline::<F> as *const (),
1482 )),
1483 Box_::into_raw(f),
1484 )
1485 }
1486 }
1487
1488 #[doc(alias = "video-multiview-flags")]
1489 pub fn connect_video_multiview_flags_notify<F: Fn(&Self) + Send + Sync + 'static>(
1490 &self,
1491 f: F,
1492 ) -> SignalHandlerId {
1493 unsafe extern "C" fn notify_video_multiview_flags_trampoline<
1494 F: Fn(&Player) + Send + Sync + 'static,
1495 >(
1496 this: *mut ffi::GstPlayer,
1497 _param_spec: glib::ffi::gpointer,
1498 f: glib::ffi::gpointer,
1499 ) {
1500 unsafe {
1501 let f: &F = &*(f as *const F);
1502 f(&from_glib_borrow(this))
1503 }
1504 }
1505 unsafe {
1506 let f: Box_<F> = Box_::new(f);
1507 connect_raw(
1508 self.as_ptr() as *mut _,
1509 c"notify::video-multiview-flags".as_ptr(),
1510 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1511 notify_video_multiview_flags_trampoline::<F> as *const (),
1512 )),
1513 Box_::into_raw(f),
1514 )
1515 }
1516 }
1517
1518 #[doc(alias = "video-multiview-mode")]
1519 pub fn connect_video_multiview_mode_notify<F: Fn(&Self) + Send + Sync + 'static>(
1520 &self,
1521 f: F,
1522 ) -> SignalHandlerId {
1523 unsafe extern "C" fn notify_video_multiview_mode_trampoline<
1524 F: Fn(&Player) + Send + Sync + 'static,
1525 >(
1526 this: *mut ffi::GstPlayer,
1527 _param_spec: glib::ffi::gpointer,
1528 f: glib::ffi::gpointer,
1529 ) {
1530 unsafe {
1531 let f: &F = &*(f as *const F);
1532 f(&from_glib_borrow(this))
1533 }
1534 }
1535 unsafe {
1536 let f: Box_<F> = Box_::new(f);
1537 connect_raw(
1538 self.as_ptr() as *mut _,
1539 c"notify::video-multiview-mode".as_ptr(),
1540 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1541 notify_video_multiview_mode_trampoline::<F> as *const (),
1542 )),
1543 Box_::into_raw(f),
1544 )
1545 }
1546 }
1547
1548 #[doc(alias = "volume")]
1549 pub fn connect_volume_notify<F: Fn(&Self) + Send + Sync + 'static>(
1550 &self,
1551 f: F,
1552 ) -> SignalHandlerId {
1553 unsafe extern "C" fn notify_volume_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1554 this: *mut ffi::GstPlayer,
1555 _param_spec: glib::ffi::gpointer,
1556 f: glib::ffi::gpointer,
1557 ) {
1558 unsafe {
1559 let f: &F = &*(f as *const F);
1560 f(&from_glib_borrow(this))
1561 }
1562 }
1563 unsafe {
1564 let f: Box_<F> = Box_::new(f);
1565 connect_raw(
1566 self.as_ptr() as *mut _,
1567 c"notify::volume".as_ptr(),
1568 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1569 notify_volume_trampoline::<F> as *const (),
1570 )),
1571 Box_::into_raw(f),
1572 )
1573 }
1574 }
1575}
1576
1577unsafe impl Send for Player {}
1578unsafe impl Sync for Player {}