1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
use crate::{
ffi, PlayAudioInfo, PlayColorBalanceType, PlayMediaInfo, PlaySubtitleInfo, PlayVideoInfo,
PlayVideoRenderer, PlayVisualization,
};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// The goal of the GstPlay library is to ease the integration of multimedia
/// playback features in applications. Thus, if you need to build a media player
/// from the ground-up, GstPlay provides the features you will most likely need.
///
/// An example player is available in gst-examples/playback/player/gst-play/.
///
/// Internally the GstPlay makes use of the `playbin3` element. The legacy
/// `playbin2` can be selected if the `GST_PLAY_USE_PLAYBIN3=0` environment
/// variable has been set.
///
/// **Important note**: If your application relies on the GstBus to get
/// notifications from GstPlay, you need to add some explicit clean-up code in
/// order to prevent the GstPlay object from leaking. See below for the details.
/// If you use the GstPlaySignalAdapter, no special clean-up is required.
///
/// When the GstPlaySignalAdapter is not used, the GstBus owned by GstPlay should
/// be set to flushing state before any attempt to drop the last reference of the
/// GstPlay object. An example in C:
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// ...
/// GstBus *bus = gst_play_get_message_bus (player);
/// gst_bus_set_flushing (bus, TRUE);
/// gst_object_unref (bus);
/// gst_object_unref (player);
/// ```
///
/// The messages managed by the player contain a reference to itself, and if the
/// bus watch is just removed together with dropping the player then the bus will
/// simply keep them around forever (and the bus never goes away because the
/// player has a strong reference to it, so there's a reference cycle as long as
/// there are messages). Setting the bus to flushing state forces it to get rid
/// of its queued messages, thus breaking any possible reference cycle.
///
/// ## Properties
///
///
/// #### `audio-video-offset`
/// Readable | Writeable
///
///
/// #### `current-audio-track`
/// Readable
///
///
/// #### `current-subtitle-track`
/// Readable
///
///
/// #### `current-video-track`
/// Readable
///
///
/// #### `duration`
/// Readable
///
///
/// #### `media-info`
/// Readable
///
///
/// #### `mute`
/// Readable | Writeable
///
///
/// #### `pipeline`
/// Readable
///
///
/// #### `position`
/// Readable
///
///
/// #### `rate`
/// Readable | Writeable
///
///
/// #### `subtitle-video-offset`
/// Readable | Writeable
///
///
/// #### `suburi`
/// Readable | Writeable
///
///
/// #### `uri`
/// Readable | Writeable
///
///
/// #### `video-multiview-flags`
/// Readable | Writeable
///
///
/// #### `video-multiview-mode`
/// Readable | Writeable
///
///
/// #### `video-renderer`
/// Readable | Writeable
///
///
/// #### `volume`
/// Readable | Writeable
/// <details><summary><h4>Object</h4></summary>
///
///
/// #### `name`
/// Readable | Writeable | Construct
///
///
/// #### `parent`
/// The parent of the object. Please note, that when changing the 'parent'
/// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
/// signals due to locking issues. In some cases one can use
/// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
/// achieve a similar effect.
///
/// Readable | Writeable
/// </details>
///
/// # Implements
///
/// [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
#[doc(alias = "GstPlay")]
pub struct Play(Object<ffi::GstPlay, ffi::GstPlayClass>) @extends gst::Object;
match fn {
type_ => || ffi::gst_play_get_type(),
}
}
impl Play {
/// Creates a new [`Play`][crate::Play] instance.
///
/// Video is going to be rendered by `video_renderer`, or if [`None`] is provided
/// no special video set up will be done and some default handling will be
/// performed.
///
/// This also initializes GStreamer via ``gst_init()`` on the first call if this
/// didn't happen before.
/// ## `video_renderer`
/// GstPlayVideoRenderer to use
///
/// # Returns
///
/// a new [`Play`][crate::Play] instance
#[doc(alias = "gst_play_new")]
pub fn new(video_renderer: Option<impl IsA<PlayVideoRenderer>>) -> Play {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_play_new(
video_renderer.map(|p| p.upcast()).into_glib_ptr(),
))
}
}
/// Retrieve the current value of audio-video-offset property
///
/// # Returns
///
/// The current value of audio-video-offset in nanoseconds
#[doc(alias = "gst_play_get_audio_video_offset")]
#[doc(alias = "get_audio_video_offset")]
#[doc(alias = "audio-video-offset")]
pub fn audio_video_offset(&self) -> i64 {
unsafe { ffi::gst_play_get_audio_video_offset(self.to_glib_none().0) }
}
/// Retrieve the current value of the indicated `type_`.
/// ## `type_`
/// [`PlayColorBalanceType`][crate::PlayColorBalanceType]
///
/// # Returns
///
/// The current value of `type_`, between [0,1]. In case of
/// error -1 is returned.
#[doc(alias = "gst_play_get_color_balance")]
#[doc(alias = "get_color_balance")]
pub fn color_balance(&self, type_: PlayColorBalanceType) -> f64 {
unsafe { ffi::gst_play_get_color_balance(self.to_glib_none().0, type_.into_glib()) }
}
/// A Function to get current audio [`PlayAudioInfo`][crate::PlayAudioInfo] instance.
///
/// # Returns
///
/// current audio track.
///
/// The caller should free it with `g_object_unref()`
#[doc(alias = "gst_play_get_current_audio_track")]
#[doc(alias = "get_current_audio_track")]
#[doc(alias = "current-audio-track")]
pub fn current_audio_track(&self) -> Option<PlayAudioInfo> {
unsafe { from_glib_full(ffi::gst_play_get_current_audio_track(self.to_glib_none().0)) }
}
/// A Function to get current subtitle [`PlaySubtitleInfo`][crate::PlaySubtitleInfo] instance.
///
/// # Returns
///
/// current subtitle track.
///
/// The caller should free it with `g_object_unref()`
#[doc(alias = "gst_play_get_current_subtitle_track")]
#[doc(alias = "get_current_subtitle_track")]
#[doc(alias = "current-subtitle-track")]
pub fn current_subtitle_track(&self) -> Option<PlaySubtitleInfo> {
unsafe {
from_glib_full(ffi::gst_play_get_current_subtitle_track(
self.to_glib_none().0,
))
}
}
/// A Function to get current video [`PlayVideoInfo`][crate::PlayVideoInfo] instance.
///
/// # Returns
///
/// current video track.
///
/// The caller should free it with `g_object_unref()`
#[doc(alias = "gst_play_get_current_video_track")]
#[doc(alias = "get_current_video_track")]
#[doc(alias = "current-video-track")]
pub fn current_video_track(&self) -> Option<PlayVideoInfo> {
unsafe { from_glib_full(ffi::gst_play_get_current_video_track(self.to_glib_none().0)) }
}
///
/// # Returns
///
/// Name of the currently enabled
/// visualization.
/// `g_free()` after usage.
#[doc(alias = "gst_play_get_current_visualization")]
#[doc(alias = "get_current_visualization")]
pub fn current_visualization(&self) -> Option<glib::GString> {
unsafe {
from_glib_full(ffi::gst_play_get_current_visualization(
self.to_glib_none().0,
))
}
}
/// Retrieves the duration of the media stream that self represents.
///
/// # Returns
///
/// the duration of the currently-playing media stream, in
/// nanoseconds.
#[doc(alias = "gst_play_get_duration")]
#[doc(alias = "get_duration")]
pub fn duration(&self) -> Option<gst::ClockTime> {
unsafe { from_glib(ffi::gst_play_get_duration(self.to_glib_none().0)) }
}
/// A Function to get the current media info [`PlayMediaInfo`][crate::PlayMediaInfo] instance.
///
/// # Returns
///
/// media info instance.
///
/// The caller should free it with `g_object_unref()`
#[doc(alias = "gst_play_get_media_info")]
#[doc(alias = "get_media_info")]
#[doc(alias = "media-info")]
pub fn media_info(&self) -> Option<PlayMediaInfo> {
unsafe { from_glib_full(ffi::gst_play_get_media_info(self.to_glib_none().0)) }
}
/// GstPlay API exposes a [`gst::Bus`][crate::gst::Bus] instance which purpose is to provide data
/// structures representing play-internal events in form of [`gst::Message`][crate::gst::Message]<!-- -->s of
/// type GST_MESSAGE_APPLICATION.
///
/// Each message carries a "play-message" field of type [`PlayMessage`][crate::PlayMessage].
/// Further fields of the message data are specific to each possible value of
/// that enumeration.
///
/// Applications can consume the messages asynchronously within their own
/// event-loop / UI-thread etc. Note that in case the application does not
/// consume the messages, the bus will accumulate these internally and eventually
/// fill memory. To avoid that, the bus has to be set "flushing".
///
/// # Returns
///
/// The play message bus instance
#[doc(alias = "gst_play_get_message_bus")]
#[doc(alias = "get_message_bus")]
pub fn message_bus(&self) -> gst::Bus {
unsafe { from_glib_full(ffi::gst_play_get_message_bus(self.to_glib_none().0)) }
}
/// Retrieve the current value of the indicated `type_`.
///
/// # Returns
///
/// The current value of `type_`, Default: 0x00000000 "none
#[doc(alias = "gst_play_get_multiview_flags")]
#[doc(alias = "get_multiview_flags")]
pub fn multiview_flags(&self) -> gst_video::VideoMultiviewFlags {
unsafe { from_glib(ffi::gst_play_get_multiview_flags(self.to_glib_none().0)) }
}
/// Retrieve the current value of the indicated `type_`.
///
/// # Returns
///
/// The current value of `type_`, Default: -1 "none"
#[doc(alias = "gst_play_get_multiview_mode")]
#[doc(alias = "get_multiview_mode")]
pub fn multiview_mode(&self) -> gst_video::VideoMultiviewFramePacking {
unsafe { from_glib(ffi::gst_play_get_multiview_mode(self.to_glib_none().0)) }
}
///
/// # Returns
///
/// [`true`] if the currently-playing stream is muted.
#[doc(alias = "gst_play_get_mute")]
#[doc(alias = "get_mute")]
#[doc(alias = "mute")]
pub fn is_muted(&self) -> bool {
unsafe { from_glib(ffi::gst_play_get_mute(self.to_glib_none().0)) }
}
///
/// # Returns
///
/// The internal playbin instance.
///
/// The caller should free it with `g_object_unref()`
#[doc(alias = "gst_play_get_pipeline")]
#[doc(alias = "get_pipeline")]
pub fn pipeline(&self) -> gst::Element {
unsafe { from_glib_full(ffi::gst_play_get_pipeline(self.to_glib_none().0)) }
}
///
/// # Returns
///
/// the absolute position time, in nanoseconds, of the
/// currently-playing stream.
#[doc(alias = "gst_play_get_position")]
#[doc(alias = "get_position")]
pub fn position(&self) -> Option<gst::ClockTime> {
unsafe { from_glib(ffi::gst_play_get_position(self.to_glib_none().0)) }
}
///
/// # Returns
///
/// current playback rate
#[doc(alias = "gst_play_get_rate")]
#[doc(alias = "get_rate")]
pub fn rate(&self) -> f64 {
unsafe { ffi::gst_play_get_rate(self.to_glib_none().0) }
}
/// Current subtitle URI
///
/// # Returns
///
/// URI of the current external subtitle.
/// `g_free()` after usage.
#[doc(alias = "gst_play_get_subtitle_uri")]
#[doc(alias = "get_subtitle_uri")]
pub fn subtitle_uri(&self) -> Option<glib::GString> {
unsafe { from_glib_full(ffi::gst_play_get_subtitle_uri(self.to_glib_none().0)) }
}
/// Retrieve the current value of subtitle-video-offset property
///
/// # Returns
///
/// The current value of subtitle-video-offset in nanoseconds
#[doc(alias = "gst_play_get_subtitle_video_offset")]
#[doc(alias = "get_subtitle_video_offset")]
#[doc(alias = "subtitle-video-offset")]
pub fn subtitle_video_offset(&self) -> i64 {
unsafe { ffi::gst_play_get_subtitle_video_offset(self.to_glib_none().0) }
}
/// Gets the URI of the currently-playing stream.
///
/// # Returns
///
/// a string containing the URI of the
/// currently-playing stream. `g_free()` after usage.
#[doc(alias = "gst_play_get_uri")]
#[doc(alias = "get_uri")]
pub fn uri(&self) -> Option<glib::GString> {
unsafe { from_glib_full(ffi::gst_play_get_uri(self.to_glib_none().0)) }
}
/// Returns the current volume level, as a percentage between 0 and 1.
///
/// # Returns
///
/// the volume as percentage between 0 and 1.
#[doc(alias = "gst_play_get_volume")]
#[doc(alias = "get_volume")]
pub fn volume(&self) -> f64 {
unsafe { ffi::gst_play_get_volume(self.to_glib_none().0) }
}
/// Checks whether the `self` has color balance support available.
///
/// # Returns
///
/// [`true`] if `self` has color balance support. Otherwise,
/// [`false`].
#[doc(alias = "gst_play_has_color_balance")]
pub fn has_color_balance(&self) -> bool {
unsafe { from_glib(ffi::gst_play_has_color_balance(self.to_glib_none().0)) }
}
/// Pauses the current stream.
#[doc(alias = "gst_play_pause")]
pub fn pause(&self) {
unsafe {
ffi::gst_play_pause(self.to_glib_none().0);
}
}
/// Request to play the loaded stream.
#[doc(alias = "gst_play_play")]
pub fn play(&self) {
unsafe {
ffi::gst_play_play(self.to_glib_none().0);
}
}
/// Seeks the currently-playing stream to the absolute `position` time
/// in nanoseconds.
/// ## `position`
/// position to seek in nanoseconds
#[doc(alias = "gst_play_seek")]
pub fn seek(&self, position: gst::ClockTime) {
unsafe {
ffi::gst_play_seek(self.to_glib_none().0, position.into_glib());
}
}
/// ## `stream_index`
/// stream index
///
/// # Returns
///
/// [`true`] or [`false`]
///
/// Sets the audio track `stream_index`.
#[doc(alias = "gst_play_set_audio_track")]
pub fn set_audio_track(&self, stream_index: i32) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gst_play_set_audio_track(self.to_glib_none().0, stream_index),
"Failed to set audio track"
)
}
}
/// Enable or disable the current audio track.
/// ## `enabled`
/// TRUE or FALSE
#[doc(alias = "gst_play_set_audio_track_enabled")]
pub fn set_audio_track_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_play_set_audio_track_enabled(self.to_glib_none().0, enabled.into_glib());
}
}
/// Sets audio-video-offset property by value of `offset`
/// ## `offset`
/// `gint64` in nanoseconds
#[doc(alias = "gst_play_set_audio_video_offset")]
#[doc(alias = "audio-video-offset")]
pub fn set_audio_video_offset(&self, offset: i64) {
unsafe {
ffi::gst_play_set_audio_video_offset(self.to_glib_none().0, offset);
}
}
/// Sets the current value of the indicated channel `type_` to the passed
/// value.
/// ## `type_`
/// [`PlayColorBalanceType`][crate::PlayColorBalanceType]
/// ## `value`
/// The new value for the `type_`, ranged [0,1]
#[doc(alias = "gst_play_set_color_balance")]
pub fn set_color_balance(&self, type_: PlayColorBalanceType, value: f64) {
unsafe {
ffi::gst_play_set_color_balance(self.to_glib_none().0, type_.into_glib(), value);
}
}
/// Sets the current value of the indicated mode `type_` to the passed
/// value.
/// ## `flags`
/// The new value for the `type_`
#[doc(alias = "gst_play_set_multiview_flags")]
pub fn set_multiview_flags(&self, flags: gst_video::VideoMultiviewFlags) {
unsafe {
ffi::gst_play_set_multiview_flags(self.to_glib_none().0, flags.into_glib());
}
}
/// Sets the current value of the indicated mode `type_` to the passed
/// value.
/// ## `mode`
/// The new value for the `type_`
#[doc(alias = "gst_play_set_multiview_mode")]
pub fn set_multiview_mode(&self, mode: gst_video::VideoMultiviewFramePacking) {
unsafe {
ffi::gst_play_set_multiview_mode(self.to_glib_none().0, mode.into_glib());
}
}
/// [`true`] if the currently-playing stream should be muted.
/// ## `val`
/// Mute state the should be set
#[doc(alias = "gst_play_set_mute")]
#[doc(alias = "mute")]
pub fn set_mute(&self, val: bool) {
unsafe {
ffi::gst_play_set_mute(self.to_glib_none().0, val.into_glib());
}
}
/// Playback at specified rate
/// ## `rate`
/// playback rate
#[doc(alias = "gst_play_set_rate")]
#[doc(alias = "rate")]
pub fn set_rate(&self, rate: f64) {
unsafe {
ffi::gst_play_set_rate(self.to_glib_none().0, rate);
}
}
/// ## `stream_index`
/// stream index
///
/// # Returns
///
/// [`true`] or [`false`]
///
/// Sets the subtitle stack `stream_index`.
#[doc(alias = "gst_play_set_subtitle_track")]
pub fn set_subtitle_track(&self, stream_index: i32) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gst_play_set_subtitle_track(self.to_glib_none().0, stream_index),
"Failed to set subtitle track"
)
}
}
/// Enable or disable the current subtitle track.
/// ## `enabled`
/// TRUE or FALSE
#[doc(alias = "gst_play_set_subtitle_track_enabled")]
pub fn set_subtitle_track_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_play_set_subtitle_track_enabled(self.to_glib_none().0, enabled.into_glib());
}
}
/// Sets the external subtitle URI. This should be combined with a call to
/// gst_play_set_subtitle_track_enabled(`self`, TRUE) so the subtitles are actually
/// rendered.
/// ## `uri`
/// subtitle URI
#[doc(alias = "gst_play_set_subtitle_uri")]
pub fn set_subtitle_uri(&self, uri: Option<&str>) {
unsafe {
ffi::gst_play_set_subtitle_uri(self.to_glib_none().0, uri.to_glib_none().0);
}
}
/// Sets subtitle-video-offset property by value of `offset`
/// ## `offset`
/// `gint64` in nanoseconds
#[doc(alias = "gst_play_set_subtitle_video_offset")]
#[doc(alias = "subtitle-video-offset")]
pub fn set_subtitle_video_offset(&self, offset: i64) {
unsafe {
ffi::gst_play_set_subtitle_video_offset(self.to_glib_none().0, offset);
}
}
/// Sets the next URI to play.
/// ## `uri`
/// next URI to play.
#[doc(alias = "gst_play_set_uri")]
#[doc(alias = "uri")]
pub fn set_uri(&self, uri: Option<&str>) {
unsafe {
ffi::gst_play_set_uri(self.to_glib_none().0, uri.to_glib_none().0);
}
}
/// ## `stream_index`
/// stream index
///
/// # Returns
///
/// [`true`] or [`false`]
///
/// Sets the video track `stream_index`.
#[doc(alias = "gst_play_set_video_track")]
pub fn set_video_track(&self, stream_index: i32) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gst_play_set_video_track(self.to_glib_none().0, stream_index),
"Failed to set video track"
)
}
}
/// Enable or disable the current video track.
/// ## `enabled`
/// TRUE or FALSE
#[doc(alias = "gst_play_set_video_track_enabled")]
pub fn set_video_track_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_play_set_video_track_enabled(self.to_glib_none().0, enabled.into_glib());
}
}
/// ## `name`
/// visualization element obtained from
/// [`visualizations_get()`][Self::visualizations_get()]
///
/// # Returns
///
/// [`true`] if the visualization was set correctly. Otherwise,
/// [`false`].
#[doc(alias = "gst_play_set_visualization")]
pub fn set_visualization(&self, name: Option<&str>) -> Result<(), glib::error::BoolError> {
unsafe {
glib::result_from_gboolean!(
ffi::gst_play_set_visualization(self.to_glib_none().0, name.to_glib_none().0),
"Failed to set visualization"
)
}
}
/// Enable or disable the visualization.
/// ## `enabled`
/// TRUE or FALSE
#[doc(alias = "gst_play_set_visualization_enabled")]
pub fn set_visualization_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_play_set_visualization_enabled(self.to_glib_none().0, enabled.into_glib());
}
}
/// Sets the volume level of the stream as a percentage between 0 and 1.
/// ## `val`
/// the new volume level, as a percentage between 0 and 1
#[doc(alias = "gst_play_set_volume")]
#[doc(alias = "volume")]
pub fn set_volume(&self, val: f64) {
unsafe {
ffi::gst_play_set_volume(self.to_glib_none().0, val);
}
}
/// Stops playing the current stream and resets to the first position
/// in the stream.
#[doc(alias = "gst_play_stop")]
pub fn stop(&self) {
unsafe {
ffi::gst_play_stop(self.to_glib_none().0);
}
}
pub fn suburi(&self) -> Option<glib::GString> {
ObjectExt::property(self, "suburi")
}
pub fn set_suburi(&self, suburi: Option<&str>) {
ObjectExt::set_property(self, "suburi", suburi)
}
#[doc(alias = "video-multiview-flags")]
pub fn video_multiview_flags(&self) -> gst_video::VideoMultiviewFlags {
ObjectExt::property(self, "video-multiview-flags")
}
#[doc(alias = "video-multiview-flags")]
pub fn set_video_multiview_flags(&self, video_multiview_flags: gst_video::VideoMultiviewFlags) {
ObjectExt::set_property(self, "video-multiview-flags", video_multiview_flags)
}
#[doc(alias = "video-multiview-mode")]
pub fn video_multiview_mode(&self) -> gst_video::VideoMultiviewFramePacking {
ObjectExt::property(self, "video-multiview-mode")
}
#[doc(alias = "video-multiview-mode")]
pub fn set_video_multiview_mode(
&self,
video_multiview_mode: gst_video::VideoMultiviewFramePacking,
) {
ObjectExt::set_property(self, "video-multiview-mode", video_multiview_mode)
}
#[doc(alias = "video-renderer")]
pub fn video_renderer(&self) -> Option<PlayVideoRenderer> {
ObjectExt::property(self, "video-renderer")
}
#[doc(alias = "video-renderer")]
pub fn set_video_renderer<P: IsA<PlayVideoRenderer>>(&self, video_renderer: Option<&P>) {
ObjectExt::set_property(self, "video-renderer", video_renderer)
}
/// ## `info`
/// a [`PlayMediaInfo`][crate::PlayMediaInfo]
///
/// # Returns
///
/// A `GList` of
/// matching [`PlayAudioInfo`][crate::PlayAudioInfo].
#[doc(alias = "gst_play_get_audio_streams")]
#[doc(alias = "get_audio_streams")]
pub fn audio_streams(info: &PlayMediaInfo) -> Vec<PlayAudioInfo> {
skip_assert_initialized!();
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::gst_play_get_audio_streams(
info.to_glib_none().0,
))
}
}
/// ## `info`
/// a [`PlayMediaInfo`][crate::PlayMediaInfo]
///
/// # Returns
///
/// A `GList` of
/// matching [`PlaySubtitleInfo`][crate::PlaySubtitleInfo].
#[doc(alias = "gst_play_get_subtitle_streams")]
#[doc(alias = "get_subtitle_streams")]
pub fn subtitle_streams(info: &PlayMediaInfo) -> Vec<PlaySubtitleInfo> {
skip_assert_initialized!();
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::gst_play_get_subtitle_streams(
info.to_glib_none().0,
))
}
}
/// ## `info`
/// a [`PlayMediaInfo`][crate::PlayMediaInfo]
///
/// # Returns
///
/// A `GList` of
/// matching [`PlayVideoInfo`][crate::PlayVideoInfo].
#[doc(alias = "gst_play_get_video_streams")]
#[doc(alias = "get_video_streams")]
pub fn video_streams(info: &PlayMediaInfo) -> Vec<PlayVideoInfo> {
skip_assert_initialized!();
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::gst_play_get_video_streams(
info.to_glib_none().0,
))
}
}
/// ## `msg`
/// A [`gst::Message`][crate::gst::Message]
///
/// # Returns
///
/// A `gboolean` indicating whether the passed message represents a [`Play`][crate::Play] message or not.
#[doc(alias = "gst_play_is_play_message")]
pub fn is_play_message(msg: &gst::Message) -> bool {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::gst_play_is_play_message(msg.to_glib_none().0)) }
}
///
/// # Returns
///
///
/// a [`None`] terminated array containing all available
/// visualizations. Use `gst_play_visualizations_free()` after
/// usage.
#[doc(alias = "gst_play_visualizations_get")]
pub fn visualizations_get() -> Vec<PlayVisualization> {
assert_initialized_main_thread!();
unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_play_visualizations_get()) }
}
#[doc(alias = "audio-video-offset")]
pub fn connect_audio_video_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_audio_video_offset_trampoline<
F: Fn(&Play) + Send + Sync + 'static,
>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::audio-video-offset\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_audio_video_offset_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "current-audio-track")]
pub fn connect_current_audio_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_current_audio_track_trampoline<
F: Fn(&Play) + Send + Sync + 'static,
>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::current-audio-track\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_current_audio_track_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "current-subtitle-track")]
pub fn connect_current_subtitle_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_current_subtitle_track_trampoline<
F: Fn(&Play) + Send + Sync + 'static,
>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::current-subtitle-track\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_current_subtitle_track_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "current-video-track")]
pub fn connect_current_video_track_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_current_video_track_trampoline<
F: Fn(&Play) + Send + Sync + 'static,
>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::current-video-track\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_current_video_track_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "duration")]
pub fn connect_duration_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_duration_trampoline<F: Fn(&Play) + Send + Sync + 'static>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::duration\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_duration_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "media-info")]
pub fn connect_media_info_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_media_info_trampoline<F: Fn(&Play) + Send + Sync + 'static>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::media-info\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_media_info_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "mute")]
pub fn connect_mute_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_mute_trampoline<F: Fn(&Play) + Send + Sync + 'static>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::mute\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_mute_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "pipeline")]
pub fn connect_pipeline_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_pipeline_trampoline<F: Fn(&Play) + Send + Sync + 'static>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::pipeline\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_pipeline_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "position")]
pub fn connect_position_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_position_trampoline<F: Fn(&Play) + Send + Sync + 'static>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::position\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_position_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "rate")]
pub fn connect_rate_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_rate_trampoline<F: Fn(&Play) + Send + Sync + 'static>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::rate\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_rate_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "subtitle-video-offset")]
pub fn connect_subtitle_video_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_subtitle_video_offset_trampoline<
F: Fn(&Play) + Send + Sync + 'static,
>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::subtitle-video-offset\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_subtitle_video_offset_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "suburi")]
pub fn connect_suburi_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_suburi_trampoline<F: Fn(&Play) + Send + Sync + 'static>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::suburi\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_suburi_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "uri")]
pub fn connect_uri_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_uri_trampoline<F: Fn(&Play) + Send + Sync + 'static>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::uri\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_uri_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "video-multiview-flags")]
pub fn connect_video_multiview_flags_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_video_multiview_flags_trampoline<
F: Fn(&Play) + Send + Sync + 'static,
>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::video-multiview-flags\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_video_multiview_flags_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "video-multiview-mode")]
pub fn connect_video_multiview_mode_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_video_multiview_mode_trampoline<
F: Fn(&Play) + Send + Sync + 'static,
>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::video-multiview-mode\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_video_multiview_mode_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "video-renderer")]
pub fn connect_video_renderer_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_video_renderer_trampoline<
F: Fn(&Play) + Send + Sync + 'static,
>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::video-renderer\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_video_renderer_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "volume")]
pub fn connect_volume_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_volume_trampoline<F: Fn(&Play) + Send + Sync + 'static>(
this: *mut ffi::GstPlay,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::volume\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_volume_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
unsafe impl Send for Play {}
unsafe impl Sync for Play {}