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 1278 1279 1280 1281 1282 1283 1284
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use glib; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib_sys; use gst_sys; use std::boxed::Box as Box_; use std::mem::transmute; use std::ptr; use Bus; use Caps; use Clock; use ClockTime; use Context; use ElementFactory; use Object; use Pad; use PadLinkCheck; use PadTemplate; use URIType; glib_wrapper! { /// GstElement is the abstract base class needed to construct an element that /// can be used in a GStreamer pipeline. Please refer to the plugin writers /// guide for more information on creating `Element` subclasses. /// /// The name of a `Element` can be get with `gst_element_get_name` and set with /// `gst_element_set_name`. For speed, GST_ELEMENT_NAME() can be used in the /// core when using the appropriate locking. Do not use this in plug-ins or /// applications in order to retain ABI compatibility. /// /// Elements can have pads (of the type `Pad`). These pads link to pads on /// other elements. `Buffer` flow between these linked pads. /// A `Element` has a `glib::List` of `Pad` structures for all their input (or sink) /// and output (or source) pads. /// Core and plug-in writers can add and remove pads with `ElementExt::add_pad` /// and `ElementExt::remove_pad`. /// /// An existing pad of an element can be retrieved by name with /// `ElementExt::get_static_pad`. A new dynamic pad can be created using /// `ElementExt::request_pad` with a `PadTemplate`. /// An iterator of all pads can be retrieved with `ElementExt::iterate_pads`. /// /// Elements can be linked through their pads. /// If the link is straightforward, use the `ElementExt::link` /// convenience function to link two elements, or `ElementExt::link_many` /// for more elements in a row. /// Use `ElementExt::link_filtered` to link two elements constrained by /// a specified set of `Caps`. /// For finer control, use `ElementExt::link_pads` and /// `ElementExt::link_pads_filtered` to specify the pads to link on /// each element by name. /// /// Each element has a state (see `State`). You can get and set the state /// of an element with `Element::get_state` and `Element::set_state`. /// Setting a state triggers a `StateChange`. To get a string representation /// of a `State`, use `Element::state_get_name`. /// /// You can get and set a `Clock` on an element using `ElementExt::get_clock` /// and `ElementExt::set_clock`. /// Some elements can provide a clock for the pipeline if /// the `ElementFlags::ProvideClock` flag is set. With the /// `ElementExt::provide_clock` method one can retrieve the clock provided by /// such an element. /// Not all elements require a clock to operate correctly. If the /// `ElementFlags::RequireClock`() flag is set, a clock should be set on the /// element with `ElementExt::set_clock`. /// /// Note that clock selection and distribution is normally handled by the /// toplevel `Pipeline` so the clock functions are only to be used in very /// specific situations. /// /// # Implements /// /// [`ElementExt`](trait.ElementExt.html), [`GstObjectExt`](trait.GstObjectExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html), [`ElementExtManual`](prelude/trait.ElementExtManual.html) pub struct Element(Object<gst_sys::GstElement, gst_sys::GstElementClass, ElementClass>) @extends Object; match fn { get_type => || gst_sys::gst_element_get_type(), } } impl Element { /// Creates an element for handling the given URI. /// ## `type_` /// Whether to create a source or a sink /// ## `uri` /// URI to create an element for /// ## `elementname` /// Name of created element, can be `None`. /// /// # Returns /// /// a new element or `None` if none /// could be created pub fn make_from_uri( type_: URIType, uri: &str, elementname: Option<&str>, ) -> Result<Element, glib::Error> { assert_initialized_main_thread!(); unsafe { let mut error = ptr::null_mut(); let ret = gst_sys::gst_element_make_from_uri( type_.to_glib(), uri.to_glib_none().0, elementname.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_none(ret)) } else { Err(from_glib_full(error)) } } } } unsafe impl Send for Element {} unsafe impl Sync for Element {} pub const NONE_ELEMENT: Option<&Element> = None; /// Trait containing all `Element` methods. /// /// # Implementors /// /// [`Bin`](struct.Bin.html), [`Element`](struct.Element.html), [`TagSetter`](struct.TagSetter.html), [`TocSetter`](struct.TocSetter.html) pub trait ElementExt: 'static { /// Abort the state change of the element. This function is used /// by elements that do asynchronous state changes and find out /// something is wrong. /// /// This function should be called with the STATE_LOCK held. /// /// MT safe. fn abort_state(&self); /// Adds a pad (link point) to `self`. `pad`'s parent will be set to `self`; /// see `GstObjectExt::set_parent` for refcounting information. /// /// Pads are automatically activated when added in the PAUSED or PLAYING /// state. /// /// The pad and the element should be unlocked when calling this function. /// /// This function will emit the `Element::pad-added` signal on the element. /// ## `pad` /// the `Pad` to add to the element. /// /// # Returns /// /// `true` if the pad could be added. This function can fail when /// a pad with the same name already existed or the pad already had another /// parent. /// /// MT safe. fn add_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>; /// Creates a pad for each pad template that is always available. /// This function is only useful during object initialization of /// subclasses of `Element`. fn create_all_pads(&self); /// Call `func` with `user_data` for each of `self`'s pads. `func` will be called /// exactly once for each pad that exists at the time of this call, unless /// one of the calls to `func` returns `false` in which case we will stop /// iterating pads and return early. If new pads are added or pads are removed /// while pads are being iterated, this will not be taken into account until /// next time this function is used. /// /// Feature: `v1_14` /// /// ## `func` /// function to call for each pad /// ## `user_data` /// user data passed to `func` /// /// # Returns /// /// `false` if `self` had no pads or if one of the calls to `func` /// returned `false`. #[cfg(any(feature = "v1_14", feature = "dox"))] fn foreach_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool; /// Call `func` with `user_data` for each of `self`'s sink pads. `func` will be /// called exactly once for each sink pad that exists at the time of this call, /// unless one of the calls to `func` returns `false` in which case we will stop /// iterating pads and return early. If new sink pads are added or sink pads /// are removed while the sink pads are being iterated, this will not be taken /// into account until next time this function is used. /// /// Feature: `v1_14` /// /// ## `func` /// function to call for each sink pad /// ## `user_data` /// user data passed to `func` /// /// # Returns /// /// `false` if `self` had no sink pads or if one of the calls to `func` /// returned `false`. #[cfg(any(feature = "v1_14", feature = "dox"))] fn foreach_sink_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool; /// Call `func` with `user_data` for each of `self`'s source pads. `func` will be /// called exactly once for each source pad that exists at the time of this call, /// unless one of the calls to `func` returns `false` in which case we will stop /// iterating pads and return early. If new source pads are added or source pads /// are removed while the source pads are being iterated, this will not be taken /// into account until next time this function is used. /// /// Feature: `v1_14` /// /// ## `func` /// function to call for each source pad /// ## `user_data` /// user data passed to `func` /// /// # Returns /// /// `false` if `self` had no source pads or if one of the calls /// to `func` returned `false`. #[cfg(any(feature = "v1_14", feature = "dox"))] fn foreach_src_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool; /// Returns the base time of the element. The base time is the /// absolute time of the clock when this element was last put to /// PLAYING. Subtracting the base time from the clock time gives /// the running time of the element. /// /// # Returns /// /// the base time of the element. /// /// MT safe. fn get_base_time(&self) -> ClockTime; /// Returns the bus of the element. Note that only a `Pipeline` will provide a /// bus for the application. /// /// # Returns /// /// the element's `Bus`. unref after /// usage. /// /// MT safe. fn get_bus(&self) -> Option<Bus>; /// Gets the currently configured clock of the element. This is the clock as was /// last set with `ElementExt::set_clock`. /// /// Elements in a pipeline will only have their clock set when the /// pipeline is in the PLAYING state. /// /// # Returns /// /// the `Clock` of the element. unref after usage. /// /// MT safe. fn get_clock(&self) -> Option<Clock>; /// Looks for an unlinked pad to which the given pad can link. It is not /// guaranteed that linking the pads will work, though it should work in most /// cases. /// /// This function will first attempt to find a compatible unlinked ALWAYS pad, /// and if none can be found, it will request a compatible REQUEST pad by looking /// at the templates of `self`. /// ## `pad` /// the `Pad` to find a compatible one for. /// ## `caps` /// the `Caps` to use as a filter. /// /// # Returns /// /// the `Pad` to which a link /// can be made, or `None` if one cannot be found. `GstObjectExt::unref` /// after usage. fn get_compatible_pad<P: IsA<Pad>>(&self, pad: &P, caps: Option<&Caps>) -> Option<Pad>; /// Retrieves a pad template from `self` that is compatible with `compattempl`. /// Pads from compatible templates can be linked together. /// ## `compattempl` /// the `PadTemplate` to find a compatible /// template for /// /// # Returns /// /// a compatible `PadTemplate`, /// or `None` if none was found. No unreferencing is necessary. fn get_compatible_pad_template(&self, compattempl: &PadTemplate) -> Option<PadTemplate>; /// Gets the context with `context_type` set on the element or NULL. /// /// MT safe. /// ## `context_type` /// a name of a context to retrieve /// /// # Returns /// /// A `Context` or NULL fn get_context(&self, context_type: &str) -> Option<Context>; /// Gets the contexts set on the element. /// /// MT safe. /// /// # Returns /// /// List of `Context` fn get_contexts(&self) -> Vec<Context>; /// Retrieves the factory that was used to create this element. /// /// # Returns /// /// the `ElementFactory` used for creating this /// element or `None` if element has not been registered (static element). no refcounting is needed. fn get_factory(&self) -> Option<ElementFactory>; /// Retrieves a pad from the element by name (e.g. "src_\%d"). This version only /// retrieves request pads. The pad should be released with /// `ElementExt::release_request_pad`. /// /// This method is slower than manually getting the pad template and calling /// `ElementExt::request_pad` if the pads should have a specific name (e.g. /// `name` is "src_1" instead of "src_\%u"). /// ## `name` /// the name of the request `Pad` to retrieve. /// /// # Returns /// /// requested `Pad` if found, /// otherwise `None`. Release after usage. fn get_request_pad(&self, name: &str) -> Option<Pad>; /// Returns the start time of the element. The start time is the /// running time of the clock when this element was last put to PAUSED. /// /// Usually the start_time is managed by a toplevel element such as /// `Pipeline`. /// /// MT safe. /// /// # Returns /// /// the start time of the element. fn get_start_time(&self) -> ClockTime; /// Retrieves a pad from `self` by name. This version only retrieves /// already-existing (i.e. 'static') pads. /// ## `name` /// the name of the static `Pad` to retrieve. /// /// # Returns /// /// the requested `Pad` if /// found, otherwise `None`. unref after usage. /// /// MT safe. fn get_static_pad(&self, name: &str) -> Option<Pad>; /// Checks if the state of an element is locked. /// If the state of an element is locked, state changes of the parent don't /// affect the element. /// This way you can leave currently unused elements inside bins. Just lock their /// state before changing the state from `State::Null`. /// /// MT safe. /// /// # Returns /// /// `true`, if the element's state is locked. fn is_locked_state(&self) -> bool; //fn iterate_pads(&self) -> /*Ignored*/Option<Iterator>; //fn iterate_sink_pads(&self) -> /*Ignored*/Option<Iterator>; //fn iterate_src_pads(&self) -> /*Ignored*/Option<Iterator>; /// Links `self` to `dest`. The link must be from source to /// destination; the other direction will not be tried. The function looks for /// existing pads that aren't linked yet. It will request new pads if necessary. /// Such pads need to be released manually when unlinking. /// If multiple links are possible, only one is established. /// /// Make sure you have added your elements to a bin or pipeline with /// `GstBinExt::add` before trying to link them. /// ## `dest` /// the `Element` containing the destination pad. /// /// # Returns /// /// `true` if the elements could be linked, `false` otherwise. fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError>; /// Links `self` to `dest` using the given caps as filtercaps. /// The link must be from source to /// destination; the other direction will not be tried. The function looks for /// existing pads that aren't linked yet. It will request new pads if necessary. /// If multiple links are possible, only one is established. /// /// Make sure you have added your elements to a bin or pipeline with /// `GstBinExt::add` before trying to link them. /// ## `dest` /// the `Element` containing the destination pad. /// ## `filter` /// the `Caps` to filter the link, /// or `None` for no filter. /// /// # Returns /// /// `true` if the pads could be linked, `false` otherwise. fn link_filtered<P: IsA<Element>>( &self, dest: &P, filter: Option<&Caps>, ) -> Result<(), glib::error::BoolError>; //fn link_many<P: IsA<Element>>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool; /// Links the two named pads of the source and destination elements. /// Side effect is that if one of the pads has no parent, it becomes a /// child of the parent of the other element. If they have different /// parents, the link fails. /// ## `srcpadname` /// the name of the `Pad` in source element /// or `None` for any pad. /// ## `dest` /// the `Element` containing the destination pad. /// ## `destpadname` /// the name of the `Pad` in destination element, /// or `None` for any pad. /// /// # Returns /// /// `true` if the pads could be linked, `false` otherwise. fn link_pads<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, ) -> Result<(), glib::error::BoolError>; /// Links the two named pads of the source and destination elements. Side effect /// is that if one of the pads has no parent, it becomes a child of the parent of /// the other element. If they have different parents, the link fails. If `caps` /// is not `None`, makes sure that the caps of the link is a subset of `caps`. /// ## `srcpadname` /// the name of the `Pad` in source element /// or `None` for any pad. /// ## `dest` /// the `Element` containing the destination pad. /// ## `destpadname` /// the name of the `Pad` in destination element /// or `None` for any pad. /// ## `filter` /// the `Caps` to filter the link, /// or `None` for no filter. /// /// # Returns /// /// `true` if the pads could be linked, `false` otherwise. fn link_pads_filtered<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, filter: Option<&Caps>, ) -> Result<(), glib::error::BoolError>; /// Links the two named pads of the source and destination elements. /// Side effect is that if one of the pads has no parent, it becomes a /// child of the parent of the other element. If they have different /// parents, the link fails. /// /// Calling `ElementExt::link_pads_full` with `flags` == `PadLinkCheck::Default` /// is the same as calling `ElementExt::link_pads` and the recommended way of /// linking pads with safety checks applied. /// /// This is a convenience function for `Pad::link_full`. /// ## `srcpadname` /// the name of the `Pad` in source element /// or `None` for any pad. /// ## `dest` /// the `Element` containing the destination pad. /// ## `destpadname` /// the name of the `Pad` in destination element, /// or `None` for any pad. /// ## `flags` /// the `PadLinkCheck` to be performed when linking pads. /// /// # Returns /// /// `true` if the pads could be linked, `false` otherwise. fn link_pads_full<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, flags: PadLinkCheck, ) -> Result<(), glib::error::BoolError>; /// Brings the element to the lost state. The current state of the /// element is copied to the pending state so that any call to /// `Element::get_state` will return `StateChangeReturn::Async`. /// /// An ASYNC_START message is posted. If the element was PLAYING, it will /// go to PAUSED. The element will be restored to its PLAYING state by /// the parent pipeline when it prerolls again. /// /// This is mostly used for elements that lost their preroll buffer /// in the `State::Paused` or `State::Playing` state after a flush, /// they will go to their pending state again when a new preroll buffer is /// queued. This function can only be called when the element is currently /// not in error or an async state change. /// /// This function is used internally and should normally not be called from /// plugins or applications. fn lost_state(&self); //fn message_full(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: Option<&str>, debug: Option<&str>, file: &str, function: &str, line: i32); //#[cfg(any(feature = "v1_10", feature = "dox"))] //fn message_full_with_details(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: Option<&str>, debug: Option<&str>, file: &str, function: &str, line: i32, structure: &mut Structure); /// Use this function to signal that the element does not expect any more pads /// to show up in the current pipeline. This function should be called whenever /// pads have been added by the element itself. Elements with `PadPresence::Sometimes` /// pad templates use this in combination with autopluggers to figure out that /// the element is done initializing its pads. /// /// This function emits the `Element::no-more-pads` signal. /// /// MT safe. fn no_more_pads(&self); /// Get the clock provided by the given element. /// > An element is only required to provide a clock in the PAUSED /// > state. Some elements can provide a clock in other states. /// /// # Returns /// /// the GstClock provided by the /// element or `None` if no clock could be provided. Unref after usage. /// /// MT safe. fn provide_clock(&self) -> Option<Clock>; /// Makes the element free the previously requested pad as obtained /// with `ElementExt::request_pad`. /// /// This does not unref the pad. If the pad was created by using /// `ElementExt::request_pad`, `ElementExt::release_request_pad` needs to be /// followed by `GstObjectExt::unref` to free the `pad`. /// /// MT safe. /// ## `pad` /// the `Pad` to release. fn release_request_pad<P: IsA<Pad>>(&self, pad: &P); /// Removes `pad` from `self`. `pad` will be destroyed if it has not been /// referenced elsewhere using `GstObjectExt::unparent`. /// /// This function is used by plugin developers and should not be used /// by applications. Pads that were dynamically requested from elements /// with `ElementExt::request_pad` should be released with the /// `ElementExt::release_request_pad` function instead. /// /// Pads are not automatically deactivated so elements should perform the needed /// steps to deactivate the pad in case this pad is removed in the PAUSED or /// PLAYING state. See `PadExt::set_active` for more information about /// deactivating pads. /// /// The pad and the element should be unlocked when calling this function. /// /// This function will emit the `Element::pad-removed` signal on the element. /// ## `pad` /// the `Pad` to remove from the element. /// /// # Returns /// /// `true` if the pad could be removed. Can return `false` if the /// pad does not belong to the provided element. /// /// MT safe. fn remove_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>; /// Retrieves a request pad from the element according to the provided template. /// Pad templates can be looked up using /// `ElementFactory::get_static_pad_templates`. /// /// The pad should be released with `ElementExt::release_request_pad`. /// ## `templ` /// a `PadTemplate` of which we want a pad of. /// ## `name` /// the name of the request `Pad` /// to retrieve. Can be `None`. /// ## `caps` /// the caps of the pad we want to /// request. Can be `None`. /// /// # Returns /// /// requested `Pad` if found, /// otherwise `None`. Release after usage. fn request_pad( &self, templ: &PadTemplate, name: Option<&str>, caps: Option<&Caps>, ) -> Option<Pad>; /// Set the base time of an element. See `ElementExt::get_base_time`. /// /// MT safe. /// ## `time` /// the base time to set. fn set_base_time(&self, time: ClockTime); /// Sets the bus of the element. Increases the refcount on the bus. /// For internal use only, unless you're testing elements. /// /// MT safe. /// ## `bus` /// the `Bus` to set. fn set_bus(&self, bus: Option<&Bus>); /// Sets the clock for the element. This function increases the /// refcount on the clock. Any previously set clock on the object /// is unreffed. /// ## `clock` /// the `Clock` to set for the element. /// /// # Returns /// /// `true` if the element accepted the clock. An element can refuse a /// clock when it, for example, is not able to slave its internal clock to the /// `clock` or when it requires a specific clock to operate. /// /// MT safe. fn set_clock<P: IsA<Clock>>(&self, clock: Option<&P>) -> Result<(), glib::error::BoolError>; /// Sets the context of the element. Increases the refcount of the context. /// /// MT safe. /// ## `context` /// the `Context` to set. fn set_context(&self, context: &Context); /// Locks the state of an element, so state changes of the parent don't affect /// this element anymore. /// /// Note that this is racy if the state lock of the parent bin is not taken. /// The parent bin might've just checked the flag in another thread and as the /// next step proceed to change the child element's state. /// /// MT safe. /// ## `locked_state` /// `true` to lock the element's state /// /// # Returns /// /// `true` if the state was changed, `false` if bad parameters were given /// or the elements state-locking needed no change. fn set_locked_state(&self, locked_state: bool) -> bool; /// Set the start time of an element. The start time of the element is the /// running time of the element when it last went to the PAUSED state. In READY /// or after a flushing seek, it is set to 0. /// /// Toplevel elements like `Pipeline` will manage the start_time and /// base_time on its children. Setting the start_time to `GST_CLOCK_TIME_NONE` /// on such a toplevel element will disable the distribution of the base_time to /// the children and can be useful if the application manages the base_time /// itself, for example if you want to synchronize capture from multiple /// pipelines, and you can also ensure that the pipelines have the same clock. /// /// MT safe. /// ## `time` /// the base time to set. fn set_start_time(&self, time: ClockTime); /// Tries to change the state of the element to the same as its parent. /// If this function returns `false`, the state of element is undefined. /// /// # Returns /// /// `true`, if the element's state could be synced to the parent's state. /// /// MT safe. fn sync_state_with_parent(&self) -> Result<(), glib::error::BoolError>; /// Unlinks all source pads of the source element with all sink pads /// of the sink element to which they are linked. /// /// If the link has been made using `ElementExt::link`, it could have created an /// requestpad, which has to be released using `ElementExt::release_request_pad`. /// ## `dest` /// the sink `Element` to unlink. fn unlink<P: IsA<Element>>(&self, dest: &P); //fn unlink_many<P: IsA<Element>>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); /// Unlinks the two named pads of the source and destination elements. /// /// This is a convenience function for `PadExt::unlink`. /// ## `srcpadname` /// the name of the `Pad` in source element. /// ## `dest` /// a `Element` containing the destination pad. /// ## `destpadname` /// the name of the `Pad` in destination element. fn unlink_pads<P: IsA<Element>>(&self, srcpadname: &str, dest: &P, destpadname: &str); /// This signals that the element will not generate more dynamic pads. /// Note that this signal will usually be emitted from the context of /// the streaming thread. fn connect_no_more_pads<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId; /// a new `Pad` has been added to the element. Note that this signal will /// usually be emitted from the context of the streaming thread. Also keep in /// mind that if you add new elements to the pipeline in the signal handler /// you will need to set them to the desired target state with /// `Element::set_state` or `ElementExt::sync_state_with_parent`. /// ## `new_pad` /// the pad that has been added fn connect_pad_added<F: Fn(&Self, &Pad) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId; /// a `Pad` has been removed from the element /// ## `old_pad` /// the pad that has been removed fn connect_pad_removed<F: Fn(&Self, &Pad) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId; } impl<O: IsA<Element>> ElementExt for O { fn abort_state(&self) { unsafe { gst_sys::gst_element_abort_state(self.as_ref().to_glib_none().0); } } fn add_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_element_add_pad( self.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0 ), "Failed to add pad" ) } } fn create_all_pads(&self) { unsafe { gst_sys::gst_element_create_all_pads(self.as_ref().to_glib_none().0); } } #[cfg(any(feature = "v1_14", feature = "dox"))] fn foreach_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool { let func_data: P = func; unsafe extern "C" fn func_func<P: FnMut(&Element, &Pad) -> bool>( element: *mut gst_sys::GstElement, pad: *mut gst_sys::GstPad, user_data: glib_sys::gpointer, ) -> glib_sys::gboolean { let element = from_glib_borrow(element); let pad = from_glib_borrow(pad); let callback: *mut P = user_data as *const _ as usize as *mut P; let res = (*callback)(&element, &pad); res.to_glib() } let func = Some(func_func::<P> as _); let super_callback0: &P = &func_data; unsafe { from_glib(gst_sys::gst_element_foreach_pad( self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _, )) } } #[cfg(any(feature = "v1_14", feature = "dox"))] fn foreach_sink_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool { let func_data: P = func; unsafe extern "C" fn func_func<P: FnMut(&Element, &Pad) -> bool>( element: *mut gst_sys::GstElement, pad: *mut gst_sys::GstPad, user_data: glib_sys::gpointer, ) -> glib_sys::gboolean { let element = from_glib_borrow(element); let pad = from_glib_borrow(pad); let callback: *mut P = user_data as *const _ as usize as *mut P; let res = (*callback)(&element, &pad); res.to_glib() } let func = Some(func_func::<P> as _); let super_callback0: &P = &func_data; unsafe { from_glib(gst_sys::gst_element_foreach_sink_pad( self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _, )) } } #[cfg(any(feature = "v1_14", feature = "dox"))] fn foreach_src_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool { let func_data: P = func; unsafe extern "C" fn func_func<P: FnMut(&Element, &Pad) -> bool>( element: *mut gst_sys::GstElement, pad: *mut gst_sys::GstPad, user_data: glib_sys::gpointer, ) -> glib_sys::gboolean { let element = from_glib_borrow(element); let pad = from_glib_borrow(pad); let callback: *mut P = user_data as *const _ as usize as *mut P; let res = (*callback)(&element, &pad); res.to_glib() } let func = Some(func_func::<P> as _); let super_callback0: &P = &func_data; unsafe { from_glib(gst_sys::gst_element_foreach_src_pad( self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _, )) } } fn get_base_time(&self) -> ClockTime { unsafe { from_glib(gst_sys::gst_element_get_base_time( self.as_ref().to_glib_none().0, )) } } fn get_bus(&self) -> Option<Bus> { unsafe { from_glib_full(gst_sys::gst_element_get_bus(self.as_ref().to_glib_none().0)) } } fn get_clock(&self) -> Option<Clock> { unsafe { from_glib_full(gst_sys::gst_element_get_clock( self.as_ref().to_glib_none().0, )) } } fn get_compatible_pad<P: IsA<Pad>>(&self, pad: &P, caps: Option<&Caps>) -> Option<Pad> { unsafe { from_glib_full(gst_sys::gst_element_get_compatible_pad( self.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0, caps.to_glib_none().0, )) } } fn get_compatible_pad_template(&self, compattempl: &PadTemplate) -> Option<PadTemplate> { unsafe { from_glib_none(gst_sys::gst_element_get_compatible_pad_template( self.as_ref().to_glib_none().0, compattempl.to_glib_none().0, )) } } fn get_context(&self, context_type: &str) -> Option<Context> { unsafe { from_glib_full(gst_sys::gst_element_get_context( self.as_ref().to_glib_none().0, context_type.to_glib_none().0, )) } } fn get_contexts(&self) -> Vec<Context> { unsafe { FromGlibPtrContainer::from_glib_full(gst_sys::gst_element_get_contexts( self.as_ref().to_glib_none().0, )) } } fn get_factory(&self) -> Option<ElementFactory> { unsafe { from_glib_none(gst_sys::gst_element_get_factory( self.as_ref().to_glib_none().0, )) } } fn get_request_pad(&self, name: &str) -> Option<Pad> { unsafe { from_glib_full(gst_sys::gst_element_get_request_pad( self.as_ref().to_glib_none().0, name.to_glib_none().0, )) } } fn get_start_time(&self) -> ClockTime { unsafe { from_glib(gst_sys::gst_element_get_start_time( self.as_ref().to_glib_none().0, )) } } fn get_static_pad(&self, name: &str) -> Option<Pad> { unsafe { from_glib_full(gst_sys::gst_element_get_static_pad( self.as_ref().to_glib_none().0, name.to_glib_none().0, )) } } fn is_locked_state(&self) -> bool { unsafe { from_glib(gst_sys::gst_element_is_locked_state( self.as_ref().to_glib_none().0, )) } } //fn iterate_pads(&self) -> /*Ignored*/Option<Iterator> { // unsafe { TODO: call gst_sys:gst_element_iterate_pads() } //} //fn iterate_sink_pads(&self) -> /*Ignored*/Option<Iterator> { // unsafe { TODO: call gst_sys:gst_element_iterate_sink_pads() } //} //fn iterate_src_pads(&self) -> /*Ignored*/Option<Iterator> { // unsafe { TODO: call gst_sys:gst_element_iterate_src_pads() } //} fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_element_link( self.as_ref().to_glib_none().0, dest.as_ref().to_glib_none().0 ), "Failed to link elements" ) } } fn link_filtered<P: IsA<Element>>( &self, dest: &P, filter: Option<&Caps>, ) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_element_link_filtered( self.as_ref().to_glib_none().0, dest.as_ref().to_glib_none().0, filter.to_glib_none().0 ), "Failed to link elements" ) } } //fn link_many<P: IsA<Element>>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call gst_sys:gst_element_link_many() } //} fn link_pads<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, ) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_element_link_pads( self.as_ref().to_glib_none().0, srcpadname.to_glib_none().0, dest.as_ref().to_glib_none().0, destpadname.to_glib_none().0 ), "Failed to link pads" ) } } fn link_pads_filtered<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, filter: Option<&Caps>, ) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_element_link_pads_filtered( self.as_ref().to_glib_none().0, srcpadname.to_glib_none().0, dest.as_ref().to_glib_none().0, destpadname.to_glib_none().0, filter.to_glib_none().0 ), "Failed to link pads" ) } } fn link_pads_full<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, flags: PadLinkCheck, ) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_element_link_pads_full( self.as_ref().to_glib_none().0, srcpadname.to_glib_none().0, dest.as_ref().to_glib_none().0, destpadname.to_glib_none().0, flags.to_glib() ), "Failed to link pads" ) } } fn lost_state(&self) { unsafe { gst_sys::gst_element_lost_state(self.as_ref().to_glib_none().0); } } //fn message_full(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: Option<&str>, debug: Option<&str>, file: &str, function: &str, line: i32) { // unsafe { TODO: call gst_sys:gst_element_message_full() } //} //#[cfg(any(feature = "v1_10", feature = "dox"))] //fn message_full_with_details(&self, type_: /*Ignored*/MessageType, domain: /*Ignored*/glib::Quark, code: i32, text: Option<&str>, debug: Option<&str>, file: &str, function: &str, line: i32, structure: &mut Structure) { // unsafe { TODO: call gst_sys:gst_element_message_full_with_details() } //} fn no_more_pads(&self) { unsafe { gst_sys::gst_element_no_more_pads(self.as_ref().to_glib_none().0); } } fn provide_clock(&self) -> Option<Clock> { unsafe { from_glib_full(gst_sys::gst_element_provide_clock( self.as_ref().to_glib_none().0, )) } } fn release_request_pad<P: IsA<Pad>>(&self, pad: &P) { unsafe { gst_sys::gst_element_release_request_pad( self.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0, ); } } fn remove_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_element_remove_pad( self.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0 ), "Failed to remove pad" ) } } fn request_pad( &self, templ: &PadTemplate, name: Option<&str>, caps: Option<&Caps>, ) -> Option<Pad> { unsafe { from_glib_full(gst_sys::gst_element_request_pad( self.as_ref().to_glib_none().0, templ.to_glib_none().0, name.to_glib_none().0, caps.to_glib_none().0, )) } } fn set_base_time(&self, time: ClockTime) { unsafe { gst_sys::gst_element_set_base_time(self.as_ref().to_glib_none().0, time.to_glib()); } } fn set_bus(&self, bus: Option<&Bus>) { unsafe { gst_sys::gst_element_set_bus(self.as_ref().to_glib_none().0, bus.to_glib_none().0); } } fn set_clock<P: IsA<Clock>>(&self, clock: Option<&P>) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_element_set_clock( self.as_ref().to_glib_none().0, clock.map(|p| p.as_ref()).to_glib_none().0 ), "Failed to set clock" ) } } fn set_context(&self, context: &Context) { unsafe { gst_sys::gst_element_set_context( self.as_ref().to_glib_none().0, context.to_glib_none().0, ); } } fn set_locked_state(&self, locked_state: bool) -> bool { unsafe { from_glib(gst_sys::gst_element_set_locked_state( self.as_ref().to_glib_none().0, locked_state.to_glib(), )) } } fn set_start_time(&self, time: ClockTime) { unsafe { gst_sys::gst_element_set_start_time(self.as_ref().to_glib_none().0, time.to_glib()); } } fn sync_state_with_parent(&self) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_sys::gst_element_sync_state_with_parent(self.as_ref().to_glib_none().0), "Failed to sync state with parent" ) } } fn unlink<P: IsA<Element>>(&self, dest: &P) { unsafe { gst_sys::gst_element_unlink( self.as_ref().to_glib_none().0, dest.as_ref().to_glib_none().0, ); } } //fn unlink_many<P: IsA<Element>>(&self, element_2: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call gst_sys:gst_element_unlink_many() } //} fn unlink_pads<P: IsA<Element>>(&self, srcpadname: &str, dest: &P, destpadname: &str) { unsafe { gst_sys::gst_element_unlink_pads( self.as_ref().to_glib_none().0, srcpadname.to_glib_none().0, dest.as_ref().to_glib_none().0, destpadname.to_glib_none().0, ); } } fn connect_no_more_pads<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn no_more_pads_trampoline<P, F: Fn(&P) + Send + Sync + 'static>( this: *mut gst_sys::GstElement, f: glib_sys::gpointer, ) where P: IsA<Element>, { let f: &F = &*(f as *const F); f(&Element::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"no-more-pads\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( no_more_pads_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } fn connect_pad_added<F: Fn(&Self, &Pad) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn pad_added_trampoline<P, F: Fn(&P, &Pad) + Send + Sync + 'static>( this: *mut gst_sys::GstElement, new_pad: *mut gst_sys::GstPad, f: glib_sys::gpointer, ) where P: IsA<Element>, { let f: &F = &*(f as *const F); f( &Element::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(new_pad), ) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"pad-added\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( pad_added_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } fn connect_pad_removed<F: Fn(&Self, &Pad) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn pad_removed_trampoline<P, F: Fn(&P, &Pad) + Send + Sync + 'static>( this: *mut gst_sys::GstElement, old_pad: *mut gst_sys::GstPad, f: glib_sys::gpointer, ) where P: IsA<Element>, { let f: &F = &*(f as *const F); f( &Element::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(old_pad), ) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"pad-removed\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( pad_removed_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } }