1use crate::{
7 ffi, PlayerAudioInfo, PlayerColorBalanceType, PlayerMediaInfo, PlayerSignalDispatcher,
8 PlayerState, PlayerSubtitleInfo, PlayerVideoInfo, PlayerVideoRenderer, PlayerVisualization,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{connect_raw, SignalHandlerId},
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 let f: &F = &*(f as *const F);
846 f(&from_glib_borrow(this), object)
847 }
848 unsafe {
849 let f: Box_<F> = Box_::new(f);
850 connect_raw(
851 self.as_ptr() as *mut _,
852 c"buffering".as_ptr() as *const _,
853 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
854 buffering_trampoline::<F> as *const (),
855 )),
856 Box_::into_raw(f),
857 )
858 }
859 }
860
861 #[doc(alias = "end-of-stream")]
862 pub fn connect_end_of_stream<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
863 unsafe extern "C" fn end_of_stream_trampoline<F: Fn(&Player) + Send + 'static>(
864 this: *mut ffi::GstPlayer,
865 f: glib::ffi::gpointer,
866 ) {
867 let f: &F = &*(f as *const F);
868 f(&from_glib_borrow(this))
869 }
870 unsafe {
871 let f: Box_<F> = Box_::new(f);
872 connect_raw(
873 self.as_ptr() as *mut _,
874 c"end-of-stream".as_ptr() as *const _,
875 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
876 end_of_stream_trampoline::<F> as *const (),
877 )),
878 Box_::into_raw(f),
879 )
880 }
881 }
882
883 #[doc(alias = "error")]
884 pub fn connect_error<F: Fn(&Self, &glib::Error) + Send + 'static>(
885 &self,
886 f: F,
887 ) -> SignalHandlerId {
888 unsafe extern "C" fn error_trampoline<F: Fn(&Player, &glib::Error) + Send + 'static>(
889 this: *mut ffi::GstPlayer,
890 object: *mut glib::ffi::GError,
891 f: glib::ffi::gpointer,
892 ) {
893 let f: &F = &*(f as *const F);
894 f(&from_glib_borrow(this), &from_glib_borrow(object))
895 }
896 unsafe {
897 let f: Box_<F> = Box_::new(f);
898 connect_raw(
899 self.as_ptr() as *mut _,
900 c"error".as_ptr() as *const _,
901 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
902 error_trampoline::<F> as *const (),
903 )),
904 Box_::into_raw(f),
905 )
906 }
907 }
908
909 #[doc(alias = "media-info-updated")]
910 pub fn connect_media_info_updated<F: Fn(&Self, &PlayerMediaInfo) + Send + 'static>(
911 &self,
912 f: F,
913 ) -> SignalHandlerId {
914 unsafe extern "C" fn media_info_updated_trampoline<
915 F: Fn(&Player, &PlayerMediaInfo) + Send + 'static,
916 >(
917 this: *mut ffi::GstPlayer,
918 object: *mut ffi::GstPlayerMediaInfo,
919 f: glib::ffi::gpointer,
920 ) {
921 let f: &F = &*(f as *const F);
922 f(&from_glib_borrow(this), &from_glib_borrow(object))
923 }
924 unsafe {
925 let f: Box_<F> = Box_::new(f);
926 connect_raw(
927 self.as_ptr() as *mut _,
928 c"media-info-updated".as_ptr() as *const _,
929 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
930 media_info_updated_trampoline::<F> as *const (),
931 )),
932 Box_::into_raw(f),
933 )
934 }
935 }
936
937 #[doc(alias = "mute-changed")]
938 pub fn connect_mute_changed<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
939 unsafe extern "C" fn mute_changed_trampoline<F: Fn(&Player) + Send + 'static>(
940 this: *mut ffi::GstPlayer,
941 f: glib::ffi::gpointer,
942 ) {
943 let f: &F = &*(f as *const F);
944 f(&from_glib_borrow(this))
945 }
946 unsafe {
947 let f: Box_<F> = Box_::new(f);
948 connect_raw(
949 self.as_ptr() as *mut _,
950 c"mute-changed".as_ptr() as *const _,
951 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
952 mute_changed_trampoline::<F> as *const (),
953 )),
954 Box_::into_raw(f),
955 )
956 }
957 }
958
959 #[doc(alias = "state-changed")]
960 pub fn connect_state_changed<F: Fn(&Self, PlayerState) + Send + 'static>(
961 &self,
962 f: F,
963 ) -> SignalHandlerId {
964 unsafe extern "C" fn state_changed_trampoline<
965 F: Fn(&Player, PlayerState) + Send + 'static,
966 >(
967 this: *mut ffi::GstPlayer,
968 object: ffi::GstPlayerState,
969 f: glib::ffi::gpointer,
970 ) {
971 let f: &F = &*(f as *const F);
972 f(&from_glib_borrow(this), from_glib(object))
973 }
974 unsafe {
975 let f: Box_<F> = Box_::new(f);
976 connect_raw(
977 self.as_ptr() as *mut _,
978 c"state-changed".as_ptr() as *const _,
979 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
980 state_changed_trampoline::<F> as *const (),
981 )),
982 Box_::into_raw(f),
983 )
984 }
985 }
986
987 #[doc(alias = "uri-loaded")]
988 pub fn connect_uri_loaded<F: Fn(&Self, &str) + Send + 'static>(&self, f: F) -> SignalHandlerId {
989 unsafe extern "C" fn uri_loaded_trampoline<F: Fn(&Player, &str) + Send + 'static>(
990 this: *mut ffi::GstPlayer,
991 object: *mut std::ffi::c_char,
992 f: glib::ffi::gpointer,
993 ) {
994 let f: &F = &*(f as *const F);
995 f(
996 &from_glib_borrow(this),
997 &glib::GString::from_glib_borrow(object),
998 )
999 }
1000 unsafe {
1001 let f: Box_<F> = Box_::new(f);
1002 connect_raw(
1003 self.as_ptr() as *mut _,
1004 c"uri-loaded".as_ptr() as *const _,
1005 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1006 uri_loaded_trampoline::<F> as *const (),
1007 )),
1008 Box_::into_raw(f),
1009 )
1010 }
1011 }
1012
1013 #[doc(alias = "video-dimensions-changed")]
1014 pub fn connect_video_dimensions_changed<F: Fn(&Self, i32, i32) + Send + 'static>(
1015 &self,
1016 f: F,
1017 ) -> SignalHandlerId {
1018 unsafe extern "C" fn video_dimensions_changed_trampoline<
1019 F: Fn(&Player, i32, i32) + Send + 'static,
1020 >(
1021 this: *mut ffi::GstPlayer,
1022 object: std::ffi::c_int,
1023 p0: std::ffi::c_int,
1024 f: glib::ffi::gpointer,
1025 ) {
1026 let f: &F = &*(f as *const F);
1027 f(&from_glib_borrow(this), object, p0)
1028 }
1029 unsafe {
1030 let f: Box_<F> = Box_::new(f);
1031 connect_raw(
1032 self.as_ptr() as *mut _,
1033 c"video-dimensions-changed".as_ptr() as *const _,
1034 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1035 video_dimensions_changed_trampoline::<F> as *const (),
1036 )),
1037 Box_::into_raw(f),
1038 )
1039 }
1040 }
1041
1042 #[doc(alias = "volume-changed")]
1043 pub fn connect_volume_changed<F: Fn(&Self) + Send + 'static>(&self, f: F) -> SignalHandlerId {
1044 unsafe extern "C" fn volume_changed_trampoline<F: Fn(&Player) + Send + 'static>(
1045 this: *mut ffi::GstPlayer,
1046 f: glib::ffi::gpointer,
1047 ) {
1048 let f: &F = &*(f as *const F);
1049 f(&from_glib_borrow(this))
1050 }
1051 unsafe {
1052 let f: Box_<F> = Box_::new(f);
1053 connect_raw(
1054 self.as_ptr() as *mut _,
1055 c"volume-changed".as_ptr() as *const _,
1056 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1057 volume_changed_trampoline::<F> as *const (),
1058 )),
1059 Box_::into_raw(f),
1060 )
1061 }
1062 }
1063
1064 #[doc(alias = "warning")]
1065 pub fn connect_warning<F: Fn(&Self, &glib::Error) + Send + 'static>(
1066 &self,
1067 f: F,
1068 ) -> SignalHandlerId {
1069 unsafe extern "C" fn warning_trampoline<F: Fn(&Player, &glib::Error) + Send + 'static>(
1070 this: *mut ffi::GstPlayer,
1071 object: *mut glib::ffi::GError,
1072 f: glib::ffi::gpointer,
1073 ) {
1074 let f: &F = &*(f as *const F);
1075 f(&from_glib_borrow(this), &from_glib_borrow(object))
1076 }
1077 unsafe {
1078 let f: Box_<F> = Box_::new(f);
1079 connect_raw(
1080 self.as_ptr() as *mut _,
1081 c"warning".as_ptr() as *const _,
1082 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1083 warning_trampoline::<F> as *const (),
1084 )),
1085 Box_::into_raw(f),
1086 )
1087 }
1088 }
1089
1090 #[doc(alias = "audio-video-offset")]
1091 pub fn connect_audio_video_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
1092 &self,
1093 f: F,
1094 ) -> SignalHandlerId {
1095 unsafe extern "C" fn notify_audio_video_offset_trampoline<
1096 F: Fn(&Player) + Send + Sync + 'static,
1097 >(
1098 this: *mut ffi::GstPlayer,
1099 _param_spec: glib::ffi::gpointer,
1100 f: glib::ffi::gpointer,
1101 ) {
1102 let f: &F = &*(f as *const F);
1103 f(&from_glib_borrow(this))
1104 }
1105 unsafe {
1106 let f: Box_<F> = Box_::new(f);
1107 connect_raw(
1108 self.as_ptr() as *mut _,
1109 c"notify::audio-video-offset".as_ptr() as *const _,
1110 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1111 notify_audio_video_offset_trampoline::<F> as *const (),
1112 )),
1113 Box_::into_raw(f),
1114 )
1115 }
1116 }
1117
1118 #[doc(alias = "current-audio-track")]
1119 pub fn connect_current_audio_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
1120 &self,
1121 f: F,
1122 ) -> SignalHandlerId {
1123 unsafe extern "C" fn notify_current_audio_track_trampoline<
1124 F: Fn(&Player) + Send + Sync + 'static,
1125 >(
1126 this: *mut ffi::GstPlayer,
1127 _param_spec: glib::ffi::gpointer,
1128 f: glib::ffi::gpointer,
1129 ) {
1130 let f: &F = &*(f as *const F);
1131 f(&from_glib_borrow(this))
1132 }
1133 unsafe {
1134 let f: Box_<F> = Box_::new(f);
1135 connect_raw(
1136 self.as_ptr() as *mut _,
1137 c"notify::current-audio-track".as_ptr() as *const _,
1138 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1139 notify_current_audio_track_trampoline::<F> as *const (),
1140 )),
1141 Box_::into_raw(f),
1142 )
1143 }
1144 }
1145
1146 #[doc(alias = "current-subtitle-track")]
1147 pub fn connect_current_subtitle_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
1148 &self,
1149 f: F,
1150 ) -> SignalHandlerId {
1151 unsafe extern "C" fn notify_current_subtitle_track_trampoline<
1152 F: Fn(&Player) + Send + Sync + 'static,
1153 >(
1154 this: *mut ffi::GstPlayer,
1155 _param_spec: glib::ffi::gpointer,
1156 f: glib::ffi::gpointer,
1157 ) {
1158 let f: &F = &*(f as *const F);
1159 f(&from_glib_borrow(this))
1160 }
1161 unsafe {
1162 let f: Box_<F> = Box_::new(f);
1163 connect_raw(
1164 self.as_ptr() as *mut _,
1165 c"notify::current-subtitle-track".as_ptr() as *const _,
1166 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1167 notify_current_subtitle_track_trampoline::<F> as *const (),
1168 )),
1169 Box_::into_raw(f),
1170 )
1171 }
1172 }
1173
1174 #[doc(alias = "current-video-track")]
1175 pub fn connect_current_video_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
1176 &self,
1177 f: F,
1178 ) -> SignalHandlerId {
1179 unsafe extern "C" fn notify_current_video_track_trampoline<
1180 F: Fn(&Player) + Send + Sync + 'static,
1181 >(
1182 this: *mut ffi::GstPlayer,
1183 _param_spec: glib::ffi::gpointer,
1184 f: glib::ffi::gpointer,
1185 ) {
1186 let f: &F = &*(f as *const F);
1187 f(&from_glib_borrow(this))
1188 }
1189 unsafe {
1190 let f: Box_<F> = Box_::new(f);
1191 connect_raw(
1192 self.as_ptr() as *mut _,
1193 c"notify::current-video-track".as_ptr() as *const _,
1194 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1195 notify_current_video_track_trampoline::<F> as *const (),
1196 )),
1197 Box_::into_raw(f),
1198 )
1199 }
1200 }
1201
1202 #[doc(alias = "duration")]
1203 pub fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
1204 &self,
1205 f: F,
1206 ) -> SignalHandlerId {
1207 unsafe extern "C" fn notify_duration_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1208 this: *mut ffi::GstPlayer,
1209 _param_spec: glib::ffi::gpointer,
1210 f: glib::ffi::gpointer,
1211 ) {
1212 let f: &F = &*(f as *const F);
1213 f(&from_glib_borrow(this))
1214 }
1215 unsafe {
1216 let f: Box_<F> = Box_::new(f);
1217 connect_raw(
1218 self.as_ptr() as *mut _,
1219 c"notify::duration".as_ptr() as *const _,
1220 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1221 notify_duration_trampoline::<F> as *const (),
1222 )),
1223 Box_::into_raw(f),
1224 )
1225 }
1226 }
1227
1228 #[doc(alias = "media-info")]
1229 pub fn connect_media_info_notify<F: Fn(&Self) + Send + Sync + 'static>(
1230 &self,
1231 f: F,
1232 ) -> SignalHandlerId {
1233 unsafe extern "C" fn notify_media_info_trampoline<
1234 F: Fn(&Player) + Send + Sync + 'static,
1235 >(
1236 this: *mut ffi::GstPlayer,
1237 _param_spec: glib::ffi::gpointer,
1238 f: glib::ffi::gpointer,
1239 ) {
1240 let f: &F = &*(f as *const F);
1241 f(&from_glib_borrow(this))
1242 }
1243 unsafe {
1244 let f: Box_<F> = Box_::new(f);
1245 connect_raw(
1246 self.as_ptr() as *mut _,
1247 c"notify::media-info".as_ptr() as *const _,
1248 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1249 notify_media_info_trampoline::<F> as *const (),
1250 )),
1251 Box_::into_raw(f),
1252 )
1253 }
1254 }
1255
1256 #[doc(alias = "mute")]
1257 pub fn connect_mute_notify<F: Fn(&Self) + Send + Sync + 'static>(
1258 &self,
1259 f: F,
1260 ) -> SignalHandlerId {
1261 unsafe extern "C" fn notify_mute_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1262 this: *mut ffi::GstPlayer,
1263 _param_spec: glib::ffi::gpointer,
1264 f: glib::ffi::gpointer,
1265 ) {
1266 let f: &F = &*(f as *const F);
1267 f(&from_glib_borrow(this))
1268 }
1269 unsafe {
1270 let f: Box_<F> = Box_::new(f);
1271 connect_raw(
1272 self.as_ptr() as *mut _,
1273 c"notify::mute".as_ptr() as *const _,
1274 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1275 notify_mute_trampoline::<F> as *const (),
1276 )),
1277 Box_::into_raw(f),
1278 )
1279 }
1280 }
1281
1282 #[doc(alias = "pipeline")]
1283 pub fn connect_pipeline_notify<F: Fn(&Self) + Send + Sync + 'static>(
1284 &self,
1285 f: F,
1286 ) -> SignalHandlerId {
1287 unsafe extern "C" fn notify_pipeline_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1288 this: *mut ffi::GstPlayer,
1289 _param_spec: glib::ffi::gpointer,
1290 f: glib::ffi::gpointer,
1291 ) {
1292 let f: &F = &*(f as *const F);
1293 f(&from_glib_borrow(this))
1294 }
1295 unsafe {
1296 let f: Box_<F> = Box_::new(f);
1297 connect_raw(
1298 self.as_ptr() as *mut _,
1299 c"notify::pipeline".as_ptr() as *const _,
1300 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1301 notify_pipeline_trampoline::<F> as *const (),
1302 )),
1303 Box_::into_raw(f),
1304 )
1305 }
1306 }
1307
1308 #[doc(alias = "position")]
1309 pub fn connect_position_notify<F: Fn(&Self) + Send + Sync + 'static>(
1310 &self,
1311 f: F,
1312 ) -> SignalHandlerId {
1313 unsafe extern "C" fn notify_position_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1314 this: *mut ffi::GstPlayer,
1315 _param_spec: glib::ffi::gpointer,
1316 f: glib::ffi::gpointer,
1317 ) {
1318 let f: &F = &*(f as *const F);
1319 f(&from_glib_borrow(this))
1320 }
1321 unsafe {
1322 let f: Box_<F> = Box_::new(f);
1323 connect_raw(
1324 self.as_ptr() as *mut _,
1325 c"notify::position".as_ptr() as *const _,
1326 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1327 notify_position_trampoline::<F> as *const (),
1328 )),
1329 Box_::into_raw(f),
1330 )
1331 }
1332 }
1333
1334 #[doc(alias = "rate")]
1335 pub fn connect_rate_notify<F: Fn(&Self) + Send + Sync + 'static>(
1336 &self,
1337 f: F,
1338 ) -> SignalHandlerId {
1339 unsafe extern "C" fn notify_rate_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1340 this: *mut ffi::GstPlayer,
1341 _param_spec: glib::ffi::gpointer,
1342 f: glib::ffi::gpointer,
1343 ) {
1344 let f: &F = &*(f as *const F);
1345 f(&from_glib_borrow(this))
1346 }
1347 unsafe {
1348 let f: Box_<F> = Box_::new(f);
1349 connect_raw(
1350 self.as_ptr() as *mut _,
1351 c"notify::rate".as_ptr() as *const _,
1352 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1353 notify_rate_trampoline::<F> as *const (),
1354 )),
1355 Box_::into_raw(f),
1356 )
1357 }
1358 }
1359
1360 #[cfg(feature = "v1_16")]
1361 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
1362 #[doc(alias = "subtitle-video-offset")]
1363 pub fn connect_subtitle_video_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
1364 &self,
1365 f: F,
1366 ) -> SignalHandlerId {
1367 unsafe extern "C" fn notify_subtitle_video_offset_trampoline<
1368 F: Fn(&Player) + Send + Sync + 'static,
1369 >(
1370 this: *mut ffi::GstPlayer,
1371 _param_spec: glib::ffi::gpointer,
1372 f: glib::ffi::gpointer,
1373 ) {
1374 let f: &F = &*(f as *const F);
1375 f(&from_glib_borrow(this))
1376 }
1377 unsafe {
1378 let f: Box_<F> = Box_::new(f);
1379 connect_raw(
1380 self.as_ptr() as *mut _,
1381 c"notify::subtitle-video-offset".as_ptr() as *const _,
1382 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1383 notify_subtitle_video_offset_trampoline::<F> as *const (),
1384 )),
1385 Box_::into_raw(f),
1386 )
1387 }
1388 }
1389
1390 #[doc(alias = "suburi")]
1391 pub fn connect_suburi_notify<F: Fn(&Self) + Send + Sync + 'static>(
1392 &self,
1393 f: F,
1394 ) -> SignalHandlerId {
1395 unsafe extern "C" fn notify_suburi_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1396 this: *mut ffi::GstPlayer,
1397 _param_spec: glib::ffi::gpointer,
1398 f: glib::ffi::gpointer,
1399 ) {
1400 let f: &F = &*(f as *const F);
1401 f(&from_glib_borrow(this))
1402 }
1403 unsafe {
1404 let f: Box_<F> = Box_::new(f);
1405 connect_raw(
1406 self.as_ptr() as *mut _,
1407 c"notify::suburi".as_ptr() as *const _,
1408 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1409 notify_suburi_trampoline::<F> as *const (),
1410 )),
1411 Box_::into_raw(f),
1412 )
1413 }
1414 }
1415
1416 #[doc(alias = "uri")]
1417 pub fn connect_uri_notify<F: Fn(&Self) + Send + Sync + 'static>(
1418 &self,
1419 f: F,
1420 ) -> SignalHandlerId {
1421 unsafe extern "C" fn notify_uri_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1422 this: *mut ffi::GstPlayer,
1423 _param_spec: glib::ffi::gpointer,
1424 f: glib::ffi::gpointer,
1425 ) {
1426 let f: &F = &*(f as *const F);
1427 f(&from_glib_borrow(this))
1428 }
1429 unsafe {
1430 let f: Box_<F> = Box_::new(f);
1431 connect_raw(
1432 self.as_ptr() as *mut _,
1433 c"notify::uri".as_ptr() as *const _,
1434 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1435 notify_uri_trampoline::<F> as *const (),
1436 )),
1437 Box_::into_raw(f),
1438 )
1439 }
1440 }
1441
1442 #[doc(alias = "video-multiview-flags")]
1443 pub fn connect_video_multiview_flags_notify<F: Fn(&Self) + Send + Sync + 'static>(
1444 &self,
1445 f: F,
1446 ) -> SignalHandlerId {
1447 unsafe extern "C" fn notify_video_multiview_flags_trampoline<
1448 F: Fn(&Player) + Send + Sync + 'static,
1449 >(
1450 this: *mut ffi::GstPlayer,
1451 _param_spec: glib::ffi::gpointer,
1452 f: glib::ffi::gpointer,
1453 ) {
1454 let f: &F = &*(f as *const F);
1455 f(&from_glib_borrow(this))
1456 }
1457 unsafe {
1458 let f: Box_<F> = Box_::new(f);
1459 connect_raw(
1460 self.as_ptr() as *mut _,
1461 c"notify::video-multiview-flags".as_ptr() as *const _,
1462 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1463 notify_video_multiview_flags_trampoline::<F> as *const (),
1464 )),
1465 Box_::into_raw(f),
1466 )
1467 }
1468 }
1469
1470 #[doc(alias = "video-multiview-mode")]
1471 pub fn connect_video_multiview_mode_notify<F: Fn(&Self) + Send + Sync + 'static>(
1472 &self,
1473 f: F,
1474 ) -> SignalHandlerId {
1475 unsafe extern "C" fn notify_video_multiview_mode_trampoline<
1476 F: Fn(&Player) + Send + Sync + 'static,
1477 >(
1478 this: *mut ffi::GstPlayer,
1479 _param_spec: glib::ffi::gpointer,
1480 f: glib::ffi::gpointer,
1481 ) {
1482 let f: &F = &*(f as *const F);
1483 f(&from_glib_borrow(this))
1484 }
1485 unsafe {
1486 let f: Box_<F> = Box_::new(f);
1487 connect_raw(
1488 self.as_ptr() as *mut _,
1489 c"notify::video-multiview-mode".as_ptr() as *const _,
1490 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1491 notify_video_multiview_mode_trampoline::<F> as *const (),
1492 )),
1493 Box_::into_raw(f),
1494 )
1495 }
1496 }
1497
1498 #[doc(alias = "volume")]
1499 pub fn connect_volume_notify<F: Fn(&Self) + Send + Sync + 'static>(
1500 &self,
1501 f: F,
1502 ) -> SignalHandlerId {
1503 unsafe extern "C" fn notify_volume_trampoline<F: Fn(&Player) + Send + Sync + 'static>(
1504 this: *mut ffi::GstPlayer,
1505 _param_spec: glib::ffi::gpointer,
1506 f: glib::ffi::gpointer,
1507 ) {
1508 let f: &F = &*(f as *const F);
1509 f(&from_glib_borrow(this))
1510 }
1511 unsafe {
1512 let f: Box_<F> = Box_::new(f);
1513 connect_raw(
1514 self.as_ptr() as *mut _,
1515 c"notify::volume".as_ptr() as *const _,
1516 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1517 notify_volume_trampoline::<F> as *const (),
1518 )),
1519 Box_::into_raw(f),
1520 )
1521 }
1522 }
1523}
1524
1525unsafe impl Send for Player {}
1526unsafe impl Sync for Player {}