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
// 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::Caps; use crate::Element; use crate::Event; use crate::EventType; use crate::FlowError; use crate::FlowSuccess; use crate::Object; use crate::PadDirection; use crate::PadLinkCheck; use crate::PadLinkError; use crate::PadLinkSuccess; use crate::PadMode; use crate::PadTemplate; #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] use crate::Stream; #[cfg(any(feature = "v1_12", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))] use crate::TaskState; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::mem::transmute; glib::wrapper! { /// A [`crate::Element`] is linked to other elements via "pads", which are extremely /// light-weight generic link points. /// /// Pads have a [`crate::PadDirection`], source pads produce data, sink pads consume /// data. /// /// Pads are typically created from a [`crate::PadTemplate`] with /// [`Self::new_from_template()`] and are then added to a [`crate::Element`]. This usually /// happens when the element is created but it can also happen dynamically based /// on the data that the element is processing or based on the pads that the /// application requests. /// /// Pads without pad templates can be created with [`Self::new()`], /// which takes a direction and a name as an argument. If the name is [`None`], /// then a guaranteed unique name will be assigned to it. /// /// A [`crate::Element`] creating a pad will typically use the various /// gst_pad_set_*_function\() calls to register callbacks for events, queries or /// dataflow on the pads. /// /// `gst_pad_get_parent()` will retrieve the [`crate::Element`] that owns the pad. /// /// After two pads are retrieved from an element by [`crate::prelude::ElementExt::get_static_pad()`], /// the pads can be linked with [`crate::prelude::PadExt::link()`]. (For quick links, /// you can also use [`crate::prelude::ElementExt::link()`], which will make the obvious /// link for you if it's straightforward.). Pads can be unlinked again with /// [`crate::prelude::PadExt::unlink()`]. [`crate::prelude::PadExt::get_peer()`] can be used to check what the pad is /// linked to. /// /// Before dataflow is possible on the pads, they need to be activated with /// [`crate::prelude::PadExt::set_active()`]. /// /// [`Self::query()`] and [`Self::peer_query()`] can be used to query various /// properties of the pad and the stream. /// /// To send a [`crate::Event`] on a pad, use [`Self::send_event()`] and /// [`Self::push_event()`]. Some events will be sticky on the pad, meaning that /// after they pass on the pad they can be queried later with /// [`crate::prelude::PadExt::get_sticky_event()`] and [`Self::sticky_events_foreach()`]. /// [`crate::prelude::PadExt::get_current_caps()`] and [`crate::prelude::PadExt::has_current_caps()`] are convenience /// functions to query the current sticky CAPS event on a pad. /// /// GstElements will use [`Self::push()`] and [`Self::pull_range()`] to push out /// or pull in a buffer. /// /// The dataflow, events and queries that happen on a pad can be monitored with /// probes that can be installed with [`Self::add_probe()`]. [`crate::prelude::PadExt::is_blocked()`] /// can be used to check if a block probe is installed on the pad. /// [`crate::prelude::PadExt::is_blocking()`] checks if the blocking probe is currently blocking the /// pad. [`Self::remove_probe()`] is used to remove a previously installed probe /// and unblock blocking probes if any. /// /// Pad have an offset that can be retrieved with [`crate::prelude::PadExt::get_offset()`]. This /// offset will be applied to the running_time of all data passing over the pad. /// [`crate::prelude::PadExt::set_offset()`] can be used to change the offset. /// /// Convenience functions exist to start, pause and stop the task on a pad with /// [`Self::start_task()`], [`crate::prelude::PadExt::pause_task()`] and [`crate::prelude::PadExt::stop_task()`] /// respectively. /// /// # Implements /// /// [`trait@crate::prelude::PadExt`], [`trait@crate::prelude::GstObjectExt`], [`trait@glib::object::ObjectExt`], [`trait@crate::prelude::PadExtManual`] pub struct Pad(Object<ffi::GstPad, ffi::GstPadClass>) @extends Object; match fn { type_ => || ffi::gst_pad_get_type(), } } unsafe impl Send for Pad {} unsafe impl Sync for Pad {} pub const NONE_PAD: Option<&Pad> = None; /// Trait containing all `Pad` methods. /// /// # Implementors /// /// [`struct@crate::Pad`], [`struct@crate::ProxyPad`] pub trait PadExt: 'static { /// Activates or deactivates the given pad in `mode` via dispatching to the /// pad's activatemodefunc. For use from within pad activation functions only. /// /// If you don't know what this is, you probably don't want to call it. /// ## `mode` /// the requested activation mode /// ## `active` /// whether or not the pad should be active. /// /// # Returns /// /// [`true`] if the operation was successful. /// /// MT safe. #[doc(alias = "gst_pad_activate_mode")] fn activate_mode(&self, mode: PadMode, active: bool) -> Result<(), glib::error::BoolError>; /// Checks if the source pad and the sink pad are compatible so they can be /// linked. /// ## `sinkpad` /// the sink [`crate::Pad`]. /// /// # Returns /// /// [`true`] if the pads can be linked. #[doc(alias = "gst_pad_can_link")] fn can_link<P: IsA<Pad>>(&self, sinkpad: &P) -> bool; /// Check and clear the [`crate::PadFlags::NeedReconfigure`] flag on `self` and return [`true`] /// if the flag was set. /// /// # Returns /// /// [`true`] is the GST_PAD_FLAG_NEED_RECONFIGURE flag was set on `self`. #[doc(alias = "gst_pad_check_reconfigure")] fn check_reconfigure(&self) -> bool; /// Creates a stream-id for the source [`crate::Pad`] `self` by combining the /// upstream information with the optional `stream_id` of the stream /// of `self`. `self` must have a parent [`crate::Element`] and which must have zero /// or one sinkpad. `stream_id` can only be [`None`] if the parent element /// of `self` has only a single source pad. /// /// This function generates an unique stream-id by getting the upstream /// stream-start event stream ID and appending `stream_id` to it. If the /// element has no sinkpad it will generate an upstream stream-id by /// doing an URI query on the element and in the worst case just uses /// a random number. Source elements that don't implement the URI /// handler interface should ideally generate a unique, deterministic /// stream-id manually instead. /// /// Since stream IDs are sorted alphabetically, any numbers in the /// stream ID should be printed with a fixed number of characters, /// preceded by 0's, such as by using the format \%03u instead of \%u. /// ## `parent` /// Parent [`crate::Element`] of `self` /// ## `stream_id` /// The stream-id /// /// # Returns /// /// A stream-id for `self`. `g_free()` after usage. #[doc(alias = "gst_pad_create_stream_id")] fn create_stream_id<P: IsA<Element>>( &self, parent: &P, stream_id: Option<&str>, ) -> glib::GString; //#[doc(alias = "gst_pad_create_stream_id_printf")] //fn create_stream_id_printf<P: IsA<Element>>(&self, parent: &P, stream_id: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> glib::GString; //#[doc(alias = "gst_pad_create_stream_id_printf_valist")] //fn create_stream_id_printf_valist<P: IsA<Element>>(&self, parent: &P, stream_id: Option<&str>, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> glib::GString; /// Calls `forward` for all internally linked pads of `self`. This function deals with /// dynamically changing internal pads and will make sure that the `forward` /// function is only called once for each pad. /// /// When `forward` returns [`true`], no further pads will be processed. /// ## `forward` /// a `GstPadForwardFunction` /// ## `user_data` /// user data passed to `forward` /// /// # Returns /// /// [`true`] if one of the dispatcher functions returned [`true`]. #[doc(alias = "gst_pad_forward")] fn forward<P: FnMut(&Pad) -> bool>(&self, forward: P) -> bool; /// Gets the capabilities of the allowed media types that can flow through /// `self` and its peer. /// /// The allowed capabilities is calculated as the intersection of the results of /// calling [`Self::query_caps()`] on `self` and its peer. The caller owns a reference /// on the resulting caps. /// /// # Returns /// /// the allowed [`crate::Caps`] of the /// pad link. Unref the caps when you no longer need it. This /// function returns [`None`] when `self` has no peer. /// /// MT safe. #[doc(alias = "gst_pad_get_allowed_caps")] #[doc(alias = "get_allowed_caps")] fn allowed_caps(&self) -> Option<Caps>; /// Gets the capabilities currently configured on `self` with the last /// [`crate::EventType::Caps`] event. /// /// # Returns /// /// the current caps of the pad with /// incremented ref-count or [`None`] when pad has no caps. Unref after usage. #[doc(alias = "gst_pad_get_current_caps")] #[doc(alias = "get_current_caps")] fn current_caps(&self) -> Option<Caps>; /// Gets the direction of the pad. The direction of the pad is /// decided at construction time so this function does not take /// the LOCK. /// /// # Returns /// /// the [`crate::PadDirection`] of the pad. /// /// MT safe. #[doc(alias = "gst_pad_get_direction")] #[doc(alias = "get_direction")] fn direction(&self) -> PadDirection; //#[doc(alias = "gst_pad_get_element_private")] //#[doc(alias = "get_element_private")] //fn element_private(&self) -> /*Unimplemented*/Option<Fundamental: Pointer>; /// Gets the [`crate::FlowReturn`] return from the last data passed by this pad. #[doc(alias = "gst_pad_get_last_flow_return")] #[doc(alias = "get_last_flow_return")] fn last_flow_result(&self) -> Result<FlowSuccess, FlowError>; /// Get the offset applied to the running time of `self`. `self` has to be a source /// pad. /// /// # Returns /// /// the offset. #[doc(alias = "gst_pad_get_offset")] #[doc(alias = "get_offset")] fn offset(&self) -> i64; /// Gets the template for `self`. /// /// # Returns /// /// the [`crate::PadTemplate`] from which /// this pad was instantiated, or [`None`] if this pad has no /// template. Unref after usage. #[doc(alias = "gst_pad_get_pad_template")] #[doc(alias = "get_pad_template")] fn pad_template(&self) -> Option<PadTemplate>; /// Gets the capabilities for `self`'s template. /// /// # Returns /// /// the [`crate::Caps`] of this pad template. /// Unref after usage. #[doc(alias = "gst_pad_get_pad_template_caps")] #[doc(alias = "get_pad_template_caps")] fn pad_template_caps(&self) -> Caps; /// Gets the parent of `self`, cast to a [`crate::Element`]. If a `self` has no parent or /// its parent is not an element, return [`None`]. /// /// # Returns /// /// the parent of the pad. The /// caller has a reference on the parent, so unref when you're finished /// with it. /// /// MT safe. #[doc(alias = "gst_pad_get_parent_element")] #[doc(alias = "get_parent_element")] fn parent_element(&self) -> Option<Element>; /// Gets the peer of `self`. This function refs the peer pad so /// you need to unref it after use. /// /// # Returns /// /// the peer [`crate::Pad`]. Unref after usage. /// /// MT safe. #[doc(alias = "gst_pad_get_peer")] #[doc(alias = "get_peer")] fn peer(&self) -> Option<Pad>; /// If there is a single internal link of the given pad, this function will /// return it. Otherwise, it will return NULL. /// /// # Returns /// /// a [`crate::Pad`], or [`None`] if `self` has none /// or more than one internal links. Unref returned pad with /// [`crate::prelude::GstObjectExt::unref()`]. #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_pad_get_single_internal_link")] #[doc(alias = "get_single_internal_link")] fn single_internal_link(&self) -> Option<Pad>; /// Returns a new reference of the sticky event of type `event_type` /// from the event. /// ## `event_type` /// the [`crate::EventType`] that should be retrieved. /// ## `idx` /// the index of the event /// /// # Returns /// /// a [`crate::Event`] of type /// `event_type` or [`None`] when no event of `event_type` was on /// `self`. Unref after usage. #[doc(alias = "gst_pad_get_sticky_event")] #[doc(alias = "get_sticky_event")] fn sticky_event(&self, event_type: EventType, idx: u32) -> Option<Event>; /// Returns the current [`crate::Stream`] for the `self`, or [`None`] if none has been /// set yet, i.e. the pad has not received a stream-start event yet. /// /// This is a convenience wrapper around [`Self::get_sticky_event()`] and /// [`crate::Event::parse_stream()`]. /// /// # Returns /// /// the current [`crate::Stream`] for `self`, or [`None`]. /// unref the returned stream when no longer needed. #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[doc(alias = "gst_pad_get_stream")] #[doc(alias = "get_stream")] fn stream(&self) -> Option<Stream>; /// Returns the current stream-id for the `self`, or [`None`] if none has been /// set yet, i.e. the pad has not received a stream-start event yet. /// /// This is a convenience wrapper around [`Self::get_sticky_event()`] and /// [`crate::Event::parse_stream_start()`]. /// /// The returned stream-id string should be treated as an opaque string, its /// contents should not be interpreted. /// /// # Returns /// /// a newly-allocated copy of the stream-id for /// `self`, or [`None`]. `g_free()` the returned string when no longer /// needed. #[doc(alias = "gst_pad_get_stream_id")] #[doc(alias = "get_stream_id")] fn stream_id(&self) -> Option<glib::GString>; /// Get `self` task state. If no task is currently /// set, [`crate::TaskState::Stopped`] is returned. /// /// # Returns /// /// The current state of `self`'s task. #[cfg(any(feature = "v1_12", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))] #[doc(alias = "gst_pad_get_task_state")] #[doc(alias = "get_task_state")] fn task_state(&self) -> TaskState; /// Check if `self` has caps set on it with a [`crate::EventType::Caps`] event. /// /// # Returns /// /// [`true`] when `self` has caps associated with it. #[doc(alias = "gst_pad_has_current_caps")] fn has_current_caps(&self) -> bool; /// Query if a pad is active /// /// # Returns /// /// [`true`] if the pad is active. /// /// MT safe. #[doc(alias = "gst_pad_is_active")] fn is_active(&self) -> bool; /// Checks if the pad is blocked or not. This function returns the /// last requested state of the pad. It is not certain that the pad /// is actually blocking at this point (see [`Self::is_blocking()`]). /// /// # Returns /// /// [`true`] if the pad is blocked. /// /// MT safe. #[doc(alias = "gst_pad_is_blocked")] fn is_blocked(&self) -> bool; /// Checks if the pad is blocking or not. This is a guaranteed state /// of whether the pad is actually blocking on a [`crate::Buffer`] or a [`crate::Event`]. /// /// # Returns /// /// [`true`] if the pad is blocking. /// /// MT safe. #[doc(alias = "gst_pad_is_blocking")] fn is_blocking(&self) -> bool; /// Checks if a `self` is linked to another pad or not. /// /// # Returns /// /// [`true`] if the pad is linked, [`false`] otherwise. /// /// MT safe. #[doc(alias = "gst_pad_is_linked")] fn is_linked(&self) -> bool; //#[doc(alias = "gst_pad_iterate_internal_links")] //fn iterate_internal_links(&self) -> /*Ignored*/Option<Iterator>; //#[doc(alias = "gst_pad_iterate_internal_links_default")] //fn iterate_internal_links_default<P: IsA<Object>>(&self, parent: Option<&P>) -> /*Ignored*/Option<Iterator>; /// Links the source pad and the sink pad. /// ## `sinkpad` /// the sink [`crate::Pad`] to link. /// /// # Returns /// /// A result code indicating if the connection worked or /// what went wrong. /// /// MT Safe. #[doc(alias = "gst_pad_link")] fn link<P: IsA<Pad>>(&self, sinkpad: &P) -> Result<PadLinkSuccess, PadLinkError>; /// Links the source pad and the sink pad. /// /// This variant of [`Self::link`] provides a more granular control on the /// checks being done when linking. While providing some considerable speedups /// the caller of this method must be aware that wrong usage of those flags /// can cause severe issues. Refer to the documentation of [`crate::PadLinkCheck`] /// for more information. /// /// MT Safe. /// ## `sinkpad` /// the sink [`crate::Pad`] to link. /// ## `flags` /// the checks to validate when linking /// /// # Returns /// /// A result code indicating if the connection worked or /// what went wrong. #[doc(alias = "gst_pad_link_full")] fn link_full<P: IsA<Pad>>( &self, sinkpad: &P, flags: PadLinkCheck, ) -> Result<PadLinkSuccess, PadLinkError>; /// Links `self` to `sink`, creating any [`crate::GhostPad`]'s in between as necessary. /// /// This is a convenience function to save having to create and add intermediate /// [`crate::GhostPad`]'s as required for linking across [`crate::Bin`] boundaries. /// /// If `self` or `sink` pads don't have parent elements or do not share a common /// ancestor, the link will fail. /// ## `sink` /// a [`crate::Pad`] /// /// # Returns /// /// whether the link succeeded. #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[doc(alias = "gst_pad_link_maybe_ghosting")] fn link_maybe_ghosting<P: IsA<Pad>>(&self, sink: &P) -> Result<(), glib::error::BoolError>; /// Links `self` to `sink`, creating any [`crate::GhostPad`]'s in between as necessary. /// /// This is a convenience function to save having to create and add intermediate /// [`crate::GhostPad`]'s as required for linking across [`crate::Bin`] boundaries. /// /// If `self` or `sink` pads don't have parent elements or do not share a common /// ancestor, the link will fail. /// /// Calling [`Self::link_maybe_ghosting_full()`] with /// `flags` == [`crate::PadLinkCheck::Default`] is the recommended way of linking /// pads with safety checks applied. /// ## `sink` /// a [`crate::Pad`] /// ## `flags` /// some [`crate::PadLinkCheck`] flags /// /// # Returns /// /// whether the link succeeded. #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] #[doc(alias = "gst_pad_link_maybe_ghosting_full")] fn link_maybe_ghosting_full<P: IsA<Pad>>( &self, sink: &P, flags: PadLinkCheck, ) -> Result<(), glib::error::BoolError>; /// Mark a pad for needing reconfiguration. The next call to /// [`Self::check_reconfigure()`] will return [`true`] after this call. #[doc(alias = "gst_pad_mark_reconfigure")] fn mark_reconfigure(&self); /// Check the [`crate::PadFlags::NeedReconfigure`] flag on `self` and return [`true`] /// if the flag was set. /// /// # Returns /// /// [`true`] is the GST_PAD_FLAG_NEED_RECONFIGURE flag is set on `self`. #[doc(alias = "gst_pad_needs_reconfigure")] fn needs_reconfigure(&self) -> bool; /// Pause the task of `self`. This function will also wait until the /// function executed by the task is finished if this function is not /// called from the task function. /// /// # Returns /// /// a [`true`] if the task could be paused or [`false`] when the pad /// has no task. #[doc(alias = "gst_pad_pause_task")] fn pause_task(&self) -> Result<(), glib::error::BoolError>; /// Check if the peer of `self` accepts `caps`. If `self` has no peer, this function /// returns [`true`]. /// ## `caps` /// a [`crate::Caps`] to check on the pad /// /// # Returns /// /// [`true`] if the peer of `self` can accept the caps or `self` has no peer. #[doc(alias = "gst_pad_peer_query_accept_caps")] fn peer_query_accept_caps(&self, caps: &Caps) -> bool; /// Gets the capabilities of the peer connected to this pad. Similar to /// [`Self::query_caps()`]. /// /// When called on srcpads `filter` contains the caps that /// upstream could produce in the order preferred by upstream. When /// called on sinkpads `filter` contains the caps accepted by /// downstream in the preferred order. `filter` might be [`None`] but /// if it is not [`None`] the returned caps will be a subset of `filter`. /// ## `filter` /// a [`crate::Caps`] filter, or [`None`]. /// /// # Returns /// /// the caps of the peer pad with incremented /// ref-count. When there is no peer pad, this function returns `filter` or, /// when `filter` is [`None`], ANY caps. #[doc(alias = "gst_pad_peer_query_caps")] fn peer_query_caps(&self, filter: Option<&Caps>) -> Caps; /// Check if the given pad accepts the caps. /// ## `caps` /// a [`crate::Caps`] to check on the pad /// /// # Returns /// /// [`true`] if the pad can accept the caps. #[doc(alias = "gst_pad_query_accept_caps")] fn query_accept_caps(&self, caps: &Caps) -> bool; /// Gets the capabilities this pad can produce or consume. /// Note that this method doesn't necessarily return the caps set by sending a /// [`crate::Event::new_caps()`] - use [`Self::get_current_caps()`] for that instead. /// gst_pad_query_caps returns all possible caps a pad can operate with, using /// the pad's CAPS query function, If the query fails, this function will return /// `filter`, if not [`None`], otherwise ANY. /// /// When called on sinkpads `filter` contains the caps that /// upstream could produce in the order preferred by upstream. When /// called on srcpads `filter` contains the caps accepted by /// downstream in the preferred order. `filter` might be [`None`] but /// if it is not [`None`] the returned caps will be a subset of `filter`. /// /// Note that this function does not return writable [`crate::Caps`], use /// `gst_caps_make_writable()` before modifying the caps. /// ## `filter` /// suggested [`crate::Caps`], or [`None`] /// /// # Returns /// /// the caps of the pad with incremented ref-count. #[doc(alias = "gst_pad_query_caps")] fn query_caps(&self, filter: Option<&Caps>) -> Caps; /// Activates or deactivates the given pad. /// Normally called from within core state change functions. /// /// If `active`, makes sure the pad is active. If it is already active, either in /// push or pull mode, just return. Otherwise dispatches to the pad's activate /// function to perform the actual activation. /// /// If not `active`, calls [`Self::activate_mode()`] with the pad's current mode /// and a [`false`] argument. /// ## `active` /// whether or not the pad should be active. /// /// # Returns /// /// [`true`] if the operation was successful. /// /// MT safe. #[doc(alias = "gst_pad_set_active")] fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError>; //#[doc(alias = "gst_pad_set_element_private")] //fn set_element_private(&self, priv_: /*Unimplemented*/Option<Fundamental: Pointer>); /// Set the offset that will be applied to the running time of `self`. /// ## `offset` /// the offset #[doc(alias = "gst_pad_set_offset")] fn set_offset(&self, offset: i64); /// Stop the task of `self`. This function will also make sure that the /// function executed by the task will effectively stop if not called /// from the GstTaskFunction. /// /// This function will deadlock if called from the GstTaskFunction of /// the task. Use [`crate::Task::pause()`] instead. /// /// Regardless of whether the pad has a task, the stream lock is acquired and /// released so as to ensure that streaming through this pad has finished. /// /// # Returns /// /// a [`true`] if the task could be stopped or [`false`] on error. #[doc(alias = "gst_pad_stop_task")] fn stop_task(&self) -> Result<(), glib::error::BoolError>; /// Store the sticky `event` on `self` /// ## `event` /// a [`crate::Event`] /// /// # Returns /// /// [`crate::FlowReturn::Ok`] on success, [`crate::FlowReturn::Flushing`] when the pad /// was flushing or [`crate::FlowReturn::Eos`] when the pad was EOS. #[doc(alias = "gst_pad_store_sticky_event")] fn store_sticky_event(&self, event: &Event) -> Result<FlowSuccess, FlowError>; /// Unlinks the source pad from the sink pad. Will emit the [`crate::Pad::unlinked`] /// signal on both pads. /// ## `sinkpad` /// the sink [`crate::Pad`] to unlink. /// /// # Returns /// /// [`true`] if the pads were unlinked. This function returns [`false`] if /// the pads were not linked together. /// /// MT safe. #[doc(alias = "gst_pad_unlink")] fn unlink<P: IsA<Pad>>(&self, sinkpad: &P) -> Result<(), glib::error::BoolError>; /// A helper function you can use that sets the FIXED_CAPS flag /// This way the default CAPS query will always return the negotiated caps /// or in case the pad is not negotiated, the padtemplate caps. /// /// The negotiated caps are the caps of the last CAPS event that passed on the /// pad. Use this function on a pad that, once it negotiated to a CAPS, cannot /// be renegotiated to something else. #[doc(alias = "gst_pad_use_fixed_caps")] fn use_fixed_caps(&self); fn caps(&self) -> Option<Caps>; /// Signals that a pad has been linked to the peer pad. /// ## `peer` /// the peer pad that has been connected #[doc(alias = "linked")] fn connect_linked<F: Fn(&Self, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId; /// Signals that a pad has been unlinked from the peer pad. /// ## `peer` /// the peer pad that has been disconnected #[doc(alias = "unlinked")] fn connect_unlinked<F: Fn(&Self, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId; #[doc(alias = "caps")] fn connect_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId; #[doc(alias = "offset")] fn connect_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId; } impl<O: IsA<Pad>> PadExt for O { fn activate_mode(&self, mode: PadMode, active: bool) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_pad_activate_mode( self.as_ref().to_glib_none().0, mode.into_glib(), active.into_glib() ), "Failed to activate mode pad" ) } } fn can_link<P: IsA<Pad>>(&self, sinkpad: &P) -> bool { unsafe { from_glib(ffi::gst_pad_can_link( self.as_ref().to_glib_none().0, sinkpad.as_ref().to_glib_none().0, )) } } fn check_reconfigure(&self) -> bool { unsafe { from_glib(ffi::gst_pad_check_reconfigure( self.as_ref().to_glib_none().0, )) } } fn create_stream_id<P: IsA<Element>>( &self, parent: &P, stream_id: Option<&str>, ) -> glib::GString { unsafe { from_glib_full(ffi::gst_pad_create_stream_id( self.as_ref().to_glib_none().0, parent.as_ref().to_glib_none().0, stream_id.to_glib_none().0, )) } } //fn create_stream_id_printf<P: IsA<Element>>(&self, parent: &P, stream_id: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> glib::GString { // unsafe { TODO: call ffi:gst_pad_create_stream_id_printf() } //} //fn create_stream_id_printf_valist<P: IsA<Element>>(&self, parent: &P, stream_id: Option<&str>, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> glib::GString { // unsafe { TODO: call ffi:gst_pad_create_stream_id_printf_valist() } //} fn forward<P: FnMut(&Pad) -> bool>(&self, forward: P) -> bool { let forward_data: P = forward; unsafe extern "C" fn forward_func<P: FnMut(&Pad) -> bool>( pad: *mut ffi::GstPad, user_data: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let pad = from_glib_borrow(pad); let callback: *mut P = user_data as *const _ as usize as *mut P; let res = (*callback)(&pad); res.into_glib() } let forward = Some(forward_func::<P> as _); let super_callback0: &P = &forward_data; unsafe { from_glib(ffi::gst_pad_forward( self.as_ref().to_glib_none().0, forward, super_callback0 as *const _ as usize as *mut _, )) } } fn allowed_caps(&self) -> Option<Caps> { unsafe { from_glib_full(ffi::gst_pad_get_allowed_caps( self.as_ref().to_glib_none().0, )) } } fn current_caps(&self) -> Option<Caps> { unsafe { from_glib_full(ffi::gst_pad_get_current_caps( self.as_ref().to_glib_none().0, )) } } fn direction(&self) -> PadDirection { unsafe { from_glib(ffi::gst_pad_get_direction(self.as_ref().to_glib_none().0)) } } //fn element_private(&self) -> /*Unimplemented*/Option<Fundamental: Pointer> { // unsafe { TODO: call ffi:gst_pad_get_element_private() } //} fn last_flow_result(&self) -> Result<FlowSuccess, FlowError> { unsafe { FlowSuccess::try_from_glib(ffi::gst_pad_get_last_flow_return( self.as_ref().to_glib_none().0, )) } } fn offset(&self) -> i64 { unsafe { ffi::gst_pad_get_offset(self.as_ref().to_glib_none().0) } } fn pad_template(&self) -> Option<PadTemplate> { unsafe { from_glib_full(ffi::gst_pad_get_pad_template( self.as_ref().to_glib_none().0, )) } } fn pad_template_caps(&self) -> Caps { unsafe { from_glib_full(ffi::gst_pad_get_pad_template_caps( self.as_ref().to_glib_none().0, )) } } fn parent_element(&self) -> Option<Element> { unsafe { from_glib_full(ffi::gst_pad_get_parent_element( self.as_ref().to_glib_none().0, )) } } fn peer(&self) -> Option<Pad> { unsafe { from_glib_full(ffi::gst_pad_get_peer(self.as_ref().to_glib_none().0)) } } #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] fn single_internal_link(&self) -> Option<Pad> { unsafe { from_glib_full(ffi::gst_pad_get_single_internal_link( self.as_ref().to_glib_none().0, )) } } fn sticky_event(&self, event_type: EventType, idx: u32) -> Option<Event> { unsafe { from_glib_full(ffi::gst_pad_get_sticky_event( self.as_ref().to_glib_none().0, event_type.into_glib(), idx, )) } } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] fn stream(&self) -> Option<Stream> { unsafe { from_glib_full(ffi::gst_pad_get_stream(self.as_ref().to_glib_none().0)) } } fn stream_id(&self) -> Option<glib::GString> { unsafe { from_glib_full(ffi::gst_pad_get_stream_id(self.as_ref().to_glib_none().0)) } } #[cfg(any(feature = "v1_12", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))] fn task_state(&self) -> TaskState { unsafe { from_glib(ffi::gst_pad_get_task_state(self.as_ref().to_glib_none().0)) } } fn has_current_caps(&self) -> bool { unsafe { from_glib(ffi::gst_pad_has_current_caps( self.as_ref().to_glib_none().0, )) } } fn is_active(&self) -> bool { unsafe { from_glib(ffi::gst_pad_is_active(self.as_ref().to_glib_none().0)) } } fn is_blocked(&self) -> bool { unsafe { from_glib(ffi::gst_pad_is_blocked(self.as_ref().to_glib_none().0)) } } fn is_blocking(&self) -> bool { unsafe { from_glib(ffi::gst_pad_is_blocking(self.as_ref().to_glib_none().0)) } } fn is_linked(&self) -> bool { unsafe { from_glib(ffi::gst_pad_is_linked(self.as_ref().to_glib_none().0)) } } //fn iterate_internal_links(&self) -> /*Ignored*/Option<Iterator> { // unsafe { TODO: call ffi:gst_pad_iterate_internal_links() } //} //fn iterate_internal_links_default<P: IsA<Object>>(&self, parent: Option<&P>) -> /*Ignored*/Option<Iterator> { // unsafe { TODO: call ffi:gst_pad_iterate_internal_links_default() } //} fn link<P: IsA<Pad>>(&self, sinkpad: &P) -> Result<PadLinkSuccess, PadLinkError> { unsafe { PadLinkSuccess::try_from_glib(ffi::gst_pad_link( self.as_ref().to_glib_none().0, sinkpad.as_ref().to_glib_none().0, )) } } fn link_full<P: IsA<Pad>>( &self, sinkpad: &P, flags: PadLinkCheck, ) -> Result<PadLinkSuccess, PadLinkError> { unsafe { PadLinkSuccess::try_from_glib(ffi::gst_pad_link_full( self.as_ref().to_glib_none().0, sinkpad.as_ref().to_glib_none().0, flags.into_glib(), )) } } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] fn link_maybe_ghosting<P: IsA<Pad>>(&self, sink: &P) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_pad_link_maybe_ghosting( self.as_ref().to_glib_none().0, sink.as_ref().to_glib_none().0 ), "Failed to link pads, possibly ghosting" ) } } #[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] fn link_maybe_ghosting_full<P: IsA<Pad>>( &self, sink: &P, flags: PadLinkCheck, ) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_pad_link_maybe_ghosting_full( self.as_ref().to_glib_none().0, sink.as_ref().to_glib_none().0, flags.into_glib() ), "Failed to link pads, possibly ghosting" ) } } fn mark_reconfigure(&self) { unsafe { ffi::gst_pad_mark_reconfigure(self.as_ref().to_glib_none().0); } } fn needs_reconfigure(&self) -> bool { unsafe { from_glib(ffi::gst_pad_needs_reconfigure( self.as_ref().to_glib_none().0, )) } } fn pause_task(&self) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_pad_pause_task(self.as_ref().to_glib_none().0), "Failed to pause pad task" ) } } fn peer_query_accept_caps(&self, caps: &Caps) -> bool { unsafe { from_glib(ffi::gst_pad_peer_query_accept_caps( self.as_ref().to_glib_none().0, caps.to_glib_none().0, )) } } fn peer_query_caps(&self, filter: Option<&Caps>) -> Caps { unsafe { from_glib_full(ffi::gst_pad_peer_query_caps( self.as_ref().to_glib_none().0, filter.to_glib_none().0, )) } } fn query_accept_caps(&self, caps: &Caps) -> bool { unsafe { from_glib(ffi::gst_pad_query_accept_caps( self.as_ref().to_glib_none().0, caps.to_glib_none().0, )) } } fn query_caps(&self, filter: Option<&Caps>) -> Caps { unsafe { from_glib_full(ffi::gst_pad_query_caps( self.as_ref().to_glib_none().0, filter.to_glib_none().0, )) } } fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_pad_set_active(self.as_ref().to_glib_none().0, active.into_glib()), "Failed to activate pad" ) } } //fn set_element_private(&self, priv_: /*Unimplemented*/Option<Fundamental: Pointer>) { // unsafe { TODO: call ffi:gst_pad_set_element_private() } //} fn set_offset(&self, offset: i64) { unsafe { ffi::gst_pad_set_offset(self.as_ref().to_glib_none().0, offset); } } fn stop_task(&self) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_pad_stop_task(self.as_ref().to_glib_none().0), "Failed to stop pad task" ) } } fn store_sticky_event(&self, event: &Event) -> Result<FlowSuccess, FlowError> { unsafe { FlowSuccess::try_from_glib(ffi::gst_pad_store_sticky_event( self.as_ref().to_glib_none().0, event.to_glib_none().0, )) } } fn unlink<P: IsA<Pad>>(&self, sinkpad: &P) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_pad_unlink( self.as_ref().to_glib_none().0, sinkpad.as_ref().to_glib_none().0 ), "Failed to unlink pad" ) } } fn use_fixed_caps(&self) { unsafe { ffi::gst_pad_use_fixed_caps(self.as_ref().to_glib_none().0); } } fn caps(&self) -> Option<Caps> { unsafe { let mut value = glib::Value::from_type(<Caps as StaticType>::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"caps\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `caps` getter") } } #[doc(alias = "linked")] fn connect_linked<F: Fn(&Self, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn linked_trampoline<P, F: Fn(&P, &Pad) + Send + Sync + 'static>( this: *mut ffi::GstPad, peer: *mut ffi::GstPad, f: glib::ffi::gpointer, ) where P: IsA<Pad>, { let f: &F = &*(f as *const F); f( &Pad::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(peer), ) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"linked\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( linked_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "unlinked")] fn connect_unlinked<F: Fn(&Self, &Pad) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn unlinked_trampoline<P, F: Fn(&P, &Pad) + Send + Sync + 'static>( this: *mut ffi::GstPad, peer: *mut ffi::GstPad, f: glib::ffi::gpointer, ) where P: IsA<Pad>, { let f: &F = &*(f as *const F); f( &Pad::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(peer), ) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"unlinked\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( unlinked_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "caps")] fn connect_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_caps_trampoline<P, F: Fn(&P) + Send + Sync + 'static>( this: *mut ffi::GstPad, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) where P: IsA<Pad>, { let f: &F = &*(f as *const F); f(&Pad::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::caps\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_caps_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "offset")] fn connect_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_offset_trampoline<P, F: Fn(&P) + Send + Sync + 'static>( this: *mut ffi::GstPad, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) where P: IsA<Pad>, { let f: &F = &*(f as *const F); f(&Pad::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::offset\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_offset_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } }