1 // This file was generated by gir (https://github.com/gtk-rs/gir) 2 // from gir-files (https://github.com/gtk-rs/gir-files) 3 // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) 4 // DO NOT EDIT 5 6 use crate::Bus; 7 use crate::Caps; 8 use crate::Clock; 9 use crate::ClockTime; 10 use crate::Context; 11 use crate::ElementFactory; 12 use crate::Object; 13 use crate::Pad; 14 use crate::PadLinkCheck; 15 use crate::PadTemplate; 16 use crate::State; 17 use crate::StateChange; 18 use crate::StateChangeError; 19 use crate::StateChangeReturn; 20 use crate::StateChangeSuccess; 21 use crate::URIType; 22 use glib::object::Cast; 23 use glib::object::IsA; 24 use glib::signal::connect_raw; 25 use glib::signal::SignalHandlerId; 26 use glib::translate::*; 27 use std::boxed::Box as Box_; 28 use std::mem; 29 use std::mem::transmute; 30 use std::ptr; 31 32 glib::wrapper! { 33 #[doc(alias = "GstElement")] 34 pub struct Element(Object<ffi::GstElement, ffi::GstElementClass>) @extends Object; 35 36 match fn { 37 type_ => || ffi::gst_element_get_type(), 38 } 39 } 40 41 impl Element { 42 #[doc(alias = "gst_element_make_from_uri")] make_from_uri( type_: URIType, uri: &str, elementname: Option<&str>, ) -> Result<Element, glib::Error>43 pub fn make_from_uri( 44 type_: URIType, 45 uri: &str, 46 elementname: Option<&str>, 47 ) -> Result<Element, glib::Error> { 48 assert_initialized_main_thread!(); 49 unsafe { 50 let mut error = ptr::null_mut(); 51 let ret = ffi::gst_element_make_from_uri( 52 type_.into_glib(), 53 uri.to_glib_none().0, 54 elementname.to_glib_none().0, 55 &mut error, 56 ); 57 if error.is_null() { 58 Ok(from_glib_none(ret)) 59 } else { 60 Err(from_glib_full(error)) 61 } 62 } 63 } 64 } 65 66 unsafe impl Send for Element {} 67 unsafe impl Sync for Element {} 68 69 pub const NONE_ELEMENT: Option<&Element> = None; 70 71 pub trait ElementExt: 'static { 72 #[doc(alias = "gst_element_abort_state")] abort_state(&self)73 fn abort_state(&self); 74 75 #[doc(alias = "gst_element_add_pad")] add_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>76 fn add_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>; 77 78 #[doc(alias = "gst_element_change_state")] change_state(&self, transition: StateChange) -> Result<StateChangeSuccess, StateChangeError>79 fn change_state(&self, transition: StateChange) 80 -> Result<StateChangeSuccess, StateChangeError>; 81 82 #[doc(alias = "gst_element_continue_state")] continue_state( &self, ret: impl Into<StateChangeReturn>, ) -> Result<StateChangeSuccess, StateChangeError>83 fn continue_state( 84 &self, 85 ret: impl Into<StateChangeReturn>, 86 ) -> Result<StateChangeSuccess, StateChangeError>; 87 88 #[doc(alias = "gst_element_create_all_pads")] create_all_pads(&self)89 fn create_all_pads(&self); 90 91 #[cfg(any(feature = "v1_14", feature = "dox"))] 92 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] 93 #[doc(alias = "gst_element_foreach_pad")] foreach_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool94 fn foreach_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool; 95 96 #[cfg(any(feature = "v1_14", feature = "dox"))] 97 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] 98 #[doc(alias = "gst_element_foreach_sink_pad")] foreach_sink_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool99 fn foreach_sink_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool; 100 101 #[cfg(any(feature = "v1_14", feature = "dox"))] 102 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] 103 #[doc(alias = "gst_element_foreach_src_pad")] foreach_src_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool104 fn foreach_src_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool; 105 106 #[doc(alias = "gst_element_get_base_time")] 107 #[doc(alias = "get_base_time")] base_time(&self) -> Option<ClockTime>108 fn base_time(&self) -> Option<ClockTime>; 109 110 #[doc(alias = "gst_element_get_bus")] 111 #[doc(alias = "get_bus")] bus(&self) -> Option<Bus>112 fn bus(&self) -> Option<Bus>; 113 114 #[doc(alias = "gst_element_get_clock")] 115 #[doc(alias = "get_clock")] clock(&self) -> Option<Clock>116 fn clock(&self) -> Option<Clock>; 117 118 #[doc(alias = "gst_element_get_compatible_pad")] 119 #[doc(alias = "get_compatible_pad")] compatible_pad<P: IsA<Pad>>(&self, pad: &P, caps: Option<&Caps>) -> Option<Pad>120 fn compatible_pad<P: IsA<Pad>>(&self, pad: &P, caps: Option<&Caps>) -> Option<Pad>; 121 122 #[doc(alias = "gst_element_get_compatible_pad_template")] 123 #[doc(alias = "get_compatible_pad_template")] compatible_pad_template(&self, compattempl: &PadTemplate) -> Option<PadTemplate>124 fn compatible_pad_template(&self, compattempl: &PadTemplate) -> Option<PadTemplate>; 125 126 #[doc(alias = "gst_element_get_context")] 127 #[doc(alias = "get_context")] context(&self, context_type: &str) -> Option<Context>128 fn context(&self, context_type: &str) -> Option<Context>; 129 130 #[doc(alias = "gst_element_get_contexts")] 131 #[doc(alias = "get_contexts")] contexts(&self) -> Vec<Context>132 fn contexts(&self) -> Vec<Context>; 133 134 #[doc(alias = "gst_element_get_factory")] 135 #[doc(alias = "get_factory")] factory(&self) -> Option<ElementFactory>136 fn factory(&self) -> Option<ElementFactory>; 137 138 #[doc(alias = "gst_element_get_start_time")] 139 #[doc(alias = "get_start_time")] start_time(&self) -> Option<ClockTime>140 fn start_time(&self) -> Option<ClockTime>; 141 142 #[doc(alias = "gst_element_get_state")] 143 #[doc(alias = "get_state")] state( &self, timeout: impl Into<Option<ClockTime>>, ) -> (Result<StateChangeSuccess, StateChangeError>, State, State)144 fn state( 145 &self, 146 timeout: impl Into<Option<ClockTime>>, 147 ) -> (Result<StateChangeSuccess, StateChangeError>, State, State); 148 149 #[doc(alias = "gst_element_get_static_pad")] 150 #[doc(alias = "get_static_pad")] static_pad(&self, name: &str) -> Option<Pad>151 fn static_pad(&self, name: &str) -> Option<Pad>; 152 153 #[doc(alias = "gst_element_is_locked_state")] is_locked_state(&self) -> bool154 fn is_locked_state(&self) -> bool; 155 156 #[doc(alias = "gst_element_link")] link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError>157 fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError>; 158 159 #[doc(alias = "gst_element_link_filtered")] link_filtered<P: IsA<Element>>( &self, dest: &P, filter: &Caps, ) -> Result<(), glib::error::BoolError>160 fn link_filtered<P: IsA<Element>>( 161 &self, 162 dest: &P, 163 filter: &Caps, 164 ) -> Result<(), glib::error::BoolError>; 165 166 #[doc(alias = "gst_element_link_pads")] link_pads<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, ) -> Result<(), glib::error::BoolError>167 fn link_pads<P: IsA<Element>>( 168 &self, 169 srcpadname: Option<&str>, 170 dest: &P, 171 destpadname: Option<&str>, 172 ) -> Result<(), glib::error::BoolError>; 173 174 #[doc(alias = "gst_element_link_pads_filtered")] link_pads_filtered<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, filter: &Caps, ) -> Result<(), glib::error::BoolError>175 fn link_pads_filtered<P: IsA<Element>>( 176 &self, 177 srcpadname: Option<&str>, 178 dest: &P, 179 destpadname: Option<&str>, 180 filter: &Caps, 181 ) -> Result<(), glib::error::BoolError>; 182 183 #[doc(alias = "gst_element_link_pads_full")] link_pads_full<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, flags: PadLinkCheck, ) -> Result<(), glib::error::BoolError>184 fn link_pads_full<P: IsA<Element>>( 185 &self, 186 srcpadname: Option<&str>, 187 dest: &P, 188 destpadname: Option<&str>, 189 flags: PadLinkCheck, 190 ) -> Result<(), glib::error::BoolError>; 191 192 #[doc(alias = "gst_element_lost_state")] lost_state(&self)193 fn lost_state(&self); 194 195 #[doc(alias = "gst_element_no_more_pads")] no_more_pads(&self)196 fn no_more_pads(&self); 197 198 #[doc(alias = "gst_element_provide_clock")] provide_clock(&self) -> Option<Clock>199 fn provide_clock(&self) -> Option<Clock>; 200 201 #[doc(alias = "gst_element_release_request_pad")] release_request_pad<P: IsA<Pad>>(&self, pad: &P)202 fn release_request_pad<P: IsA<Pad>>(&self, pad: &P); 203 204 #[doc(alias = "gst_element_remove_pad")] remove_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>205 fn remove_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>; 206 207 #[doc(alias = "gst_element_request_pad")] request_pad( &self, templ: &PadTemplate, name: Option<&str>, caps: Option<&Caps>, ) -> Option<Pad>208 fn request_pad( 209 &self, 210 templ: &PadTemplate, 211 name: Option<&str>, 212 caps: Option<&Caps>, 213 ) -> Option<Pad>; 214 215 #[cfg(any(feature = "v1_20", feature = "dox"))] 216 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] 217 #[doc(alias = "gst_element_request_pad_simple")] request_pad_simple(&self, name: &str) -> Option<Pad>218 fn request_pad_simple(&self, name: &str) -> Option<Pad>; 219 220 #[doc(alias = "gst_element_set_base_time")] set_base_time(&self, time: ClockTime)221 fn set_base_time(&self, time: ClockTime); 222 223 #[doc(alias = "gst_element_set_bus")] set_bus(&self, bus: Option<&Bus>)224 fn set_bus(&self, bus: Option<&Bus>); 225 226 #[doc(alias = "gst_element_set_clock")] set_clock<P: IsA<Clock>>(&self, clock: Option<&P>) -> Result<(), glib::error::BoolError>227 fn set_clock<P: IsA<Clock>>(&self, clock: Option<&P>) -> Result<(), glib::error::BoolError>; 228 229 #[doc(alias = "gst_element_set_context")] set_context(&self, context: &Context)230 fn set_context(&self, context: &Context); 231 232 #[doc(alias = "gst_element_set_locked_state")] set_locked_state(&self, locked_state: bool) -> bool233 fn set_locked_state(&self, locked_state: bool) -> bool; 234 235 #[doc(alias = "gst_element_set_start_time")] set_start_time(&self, time: impl Into<Option<ClockTime>>)236 fn set_start_time(&self, time: impl Into<Option<ClockTime>>); 237 238 #[doc(alias = "gst_element_set_state")] set_state(&self, state: State) -> Result<StateChangeSuccess, StateChangeError>239 fn set_state(&self, state: State) -> Result<StateChangeSuccess, StateChangeError>; 240 241 #[doc(alias = "gst_element_sync_state_with_parent")] sync_state_with_parent(&self) -> Result<(), glib::error::BoolError>242 fn sync_state_with_parent(&self) -> Result<(), glib::error::BoolError>; 243 244 #[doc(alias = "gst_element_unlink")] unlink<P: IsA<Element>>(&self, dest: &P)245 fn unlink<P: IsA<Element>>(&self, dest: &P); 246 247 #[doc(alias = "gst_element_unlink_pads")] unlink_pads<P: IsA<Element>>(&self, srcpadname: &str, dest: &P, destpadname: &str)248 fn unlink_pads<P: IsA<Element>>(&self, srcpadname: &str, dest: &P, destpadname: &str); 249 250 #[doc(alias = "no-more-pads")] connect_no_more_pads<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId251 fn connect_no_more_pads<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId; 252 253 #[doc(alias = "pad-added")] connect_pad_added<F: Fn(&Self, &Pad) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId254 fn connect_pad_added<F: Fn(&Self, &Pad) + Send + Sync + 'static>( 255 &self, 256 f: F, 257 ) -> SignalHandlerId; 258 259 #[doc(alias = "pad-removed")] connect_pad_removed<F: Fn(&Self, &Pad) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId260 fn connect_pad_removed<F: Fn(&Self, &Pad) + Send + Sync + 'static>( 261 &self, 262 f: F, 263 ) -> SignalHandlerId; 264 } 265 266 impl<O: IsA<Element>> ElementExt for O { abort_state(&self)267 fn abort_state(&self) { 268 unsafe { 269 ffi::gst_element_abort_state(self.as_ref().to_glib_none().0); 270 } 271 } 272 add_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>273 fn add_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError> { 274 unsafe { 275 glib::result_from_gboolean!( 276 ffi::gst_element_add_pad( 277 self.as_ref().to_glib_none().0, 278 pad.as_ref().to_glib_none().0 279 ), 280 "Failed to add pad" 281 ) 282 } 283 } 284 change_state( &self, transition: StateChange, ) -> Result<StateChangeSuccess, StateChangeError>285 fn change_state( 286 &self, 287 transition: StateChange, 288 ) -> Result<StateChangeSuccess, StateChangeError> { 289 unsafe { 290 try_from_glib(ffi::gst_element_change_state( 291 self.as_ref().to_glib_none().0, 292 transition.into_glib(), 293 )) 294 } 295 } 296 continue_state( &self, ret: impl Into<StateChangeReturn>, ) -> Result<StateChangeSuccess, StateChangeError>297 fn continue_state( 298 &self, 299 ret: impl Into<StateChangeReturn>, 300 ) -> Result<StateChangeSuccess, StateChangeError> { 301 unsafe { 302 try_from_glib(ffi::gst_element_continue_state( 303 self.as_ref().to_glib_none().0, 304 ret.into().into_glib(), 305 )) 306 } 307 } 308 create_all_pads(&self)309 fn create_all_pads(&self) { 310 unsafe { 311 ffi::gst_element_create_all_pads(self.as_ref().to_glib_none().0); 312 } 313 } 314 315 #[cfg(any(feature = "v1_14", feature = "dox"))] 316 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] foreach_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool317 fn foreach_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool { 318 let func_data: P = func; 319 unsafe extern "C" fn func_func<P: FnMut(&Element, &Pad) -> bool>( 320 element: *mut ffi::GstElement, 321 pad: *mut ffi::GstPad, 322 user_data: glib::ffi::gpointer, 323 ) -> glib::ffi::gboolean { 324 let element = from_glib_borrow(element); 325 let pad = from_glib_borrow(pad); 326 let callback: *mut P = user_data as *const _ as usize as *mut P; 327 let res = (*callback)(&element, &pad); 328 res.into_glib() 329 } 330 let func = Some(func_func::<P> as _); 331 let super_callback0: &P = &func_data; 332 unsafe { 333 from_glib(ffi::gst_element_foreach_pad( 334 self.as_ref().to_glib_none().0, 335 func, 336 super_callback0 as *const _ as usize as *mut _, 337 )) 338 } 339 } 340 341 #[cfg(any(feature = "v1_14", feature = "dox"))] 342 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] foreach_sink_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool343 fn foreach_sink_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool { 344 let func_data: P = func; 345 unsafe extern "C" fn func_func<P: FnMut(&Element, &Pad) -> bool>( 346 element: *mut ffi::GstElement, 347 pad: *mut ffi::GstPad, 348 user_data: glib::ffi::gpointer, 349 ) -> glib::ffi::gboolean { 350 let element = from_glib_borrow(element); 351 let pad = from_glib_borrow(pad); 352 let callback: *mut P = user_data as *const _ as usize as *mut P; 353 let res = (*callback)(&element, &pad); 354 res.into_glib() 355 } 356 let func = Some(func_func::<P> as _); 357 let super_callback0: &P = &func_data; 358 unsafe { 359 from_glib(ffi::gst_element_foreach_sink_pad( 360 self.as_ref().to_glib_none().0, 361 func, 362 super_callback0 as *const _ as usize as *mut _, 363 )) 364 } 365 } 366 367 #[cfg(any(feature = "v1_14", feature = "dox"))] 368 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))] foreach_src_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool369 fn foreach_src_pad<P: FnMut(&Element, &Pad) -> bool>(&self, func: P) -> bool { 370 let func_data: P = func; 371 unsafe extern "C" fn func_func<P: FnMut(&Element, &Pad) -> bool>( 372 element: *mut ffi::GstElement, 373 pad: *mut ffi::GstPad, 374 user_data: glib::ffi::gpointer, 375 ) -> glib::ffi::gboolean { 376 let element = from_glib_borrow(element); 377 let pad = from_glib_borrow(pad); 378 let callback: *mut P = user_data as *const _ as usize as *mut P; 379 let res = (*callback)(&element, &pad); 380 res.into_glib() 381 } 382 let func = Some(func_func::<P> as _); 383 let super_callback0: &P = &func_data; 384 unsafe { 385 from_glib(ffi::gst_element_foreach_src_pad( 386 self.as_ref().to_glib_none().0, 387 func, 388 super_callback0 as *const _ as usize as *mut _, 389 )) 390 } 391 } 392 base_time(&self) -> Option<ClockTime>393 fn base_time(&self) -> Option<ClockTime> { 394 unsafe { 395 from_glib(ffi::gst_element_get_base_time( 396 self.as_ref().to_glib_none().0, 397 )) 398 } 399 } 400 bus(&self) -> Option<Bus>401 fn bus(&self) -> Option<Bus> { 402 unsafe { from_glib_full(ffi::gst_element_get_bus(self.as_ref().to_glib_none().0)) } 403 } 404 clock(&self) -> Option<Clock>405 fn clock(&self) -> Option<Clock> { 406 unsafe { from_glib_full(ffi::gst_element_get_clock(self.as_ref().to_glib_none().0)) } 407 } 408 compatible_pad<P: IsA<Pad>>(&self, pad: &P, caps: Option<&Caps>) -> Option<Pad>409 fn compatible_pad<P: IsA<Pad>>(&self, pad: &P, caps: Option<&Caps>) -> Option<Pad> { 410 unsafe { 411 from_glib_full(ffi::gst_element_get_compatible_pad( 412 self.as_ref().to_glib_none().0, 413 pad.as_ref().to_glib_none().0, 414 caps.to_glib_none().0, 415 )) 416 } 417 } 418 compatible_pad_template(&self, compattempl: &PadTemplate) -> Option<PadTemplate>419 fn compatible_pad_template(&self, compattempl: &PadTemplate) -> Option<PadTemplate> { 420 unsafe { 421 from_glib_none(ffi::gst_element_get_compatible_pad_template( 422 self.as_ref().to_glib_none().0, 423 compattempl.to_glib_none().0, 424 )) 425 } 426 } 427 context(&self, context_type: &str) -> Option<Context>428 fn context(&self, context_type: &str) -> Option<Context> { 429 unsafe { 430 from_glib_full(ffi::gst_element_get_context( 431 self.as_ref().to_glib_none().0, 432 context_type.to_glib_none().0, 433 )) 434 } 435 } 436 contexts(&self) -> Vec<Context>437 fn contexts(&self) -> Vec<Context> { 438 unsafe { 439 FromGlibPtrContainer::from_glib_full(ffi::gst_element_get_contexts( 440 self.as_ref().to_glib_none().0, 441 )) 442 } 443 } 444 factory(&self) -> Option<ElementFactory>445 fn factory(&self) -> Option<ElementFactory> { 446 unsafe { from_glib_none(ffi::gst_element_get_factory(self.as_ref().to_glib_none().0)) } 447 } 448 start_time(&self) -> Option<ClockTime>449 fn start_time(&self) -> Option<ClockTime> { 450 unsafe { 451 from_glib(ffi::gst_element_get_start_time( 452 self.as_ref().to_glib_none().0, 453 )) 454 } 455 } 456 state( &self, timeout: impl Into<Option<ClockTime>>, ) -> (Result<StateChangeSuccess, StateChangeError>, State, State)457 fn state( 458 &self, 459 timeout: impl Into<Option<ClockTime>>, 460 ) -> (Result<StateChangeSuccess, StateChangeError>, State, State) { 461 unsafe { 462 let mut state = mem::MaybeUninit::uninit(); 463 let mut pending = mem::MaybeUninit::uninit(); 464 let ret = try_from_glib(ffi::gst_element_get_state( 465 self.as_ref().to_glib_none().0, 466 state.as_mut_ptr(), 467 pending.as_mut_ptr(), 468 timeout.into().into_glib(), 469 )); 470 let state = state.assume_init(); 471 let pending = pending.assume_init(); 472 (ret, from_glib(state), from_glib(pending)) 473 } 474 } 475 static_pad(&self, name: &str) -> Option<Pad>476 fn static_pad(&self, name: &str) -> Option<Pad> { 477 unsafe { 478 from_glib_full(ffi::gst_element_get_static_pad( 479 self.as_ref().to_glib_none().0, 480 name.to_glib_none().0, 481 )) 482 } 483 } 484 is_locked_state(&self) -> bool485 fn is_locked_state(&self) -> bool { 486 unsafe { 487 from_glib(ffi::gst_element_is_locked_state( 488 self.as_ref().to_glib_none().0, 489 )) 490 } 491 } 492 link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError>493 fn link<P: IsA<Element>>(&self, dest: &P) -> Result<(), glib::error::BoolError> { 494 unsafe { 495 glib::result_from_gboolean!( 496 ffi::gst_element_link( 497 self.as_ref().to_glib_none().0, 498 dest.as_ref().to_glib_none().0 499 ), 500 "Failed to link elements" 501 ) 502 } 503 } 504 link_filtered<P: IsA<Element>>( &self, dest: &P, filter: &Caps, ) -> Result<(), glib::error::BoolError>505 fn link_filtered<P: IsA<Element>>( 506 &self, 507 dest: &P, 508 filter: &Caps, 509 ) -> Result<(), glib::error::BoolError> { 510 unsafe { 511 glib::result_from_gboolean!( 512 ffi::gst_element_link_filtered( 513 self.as_ref().to_glib_none().0, 514 dest.as_ref().to_glib_none().0, 515 filter.to_glib_none().0 516 ), 517 "Failed to link elements" 518 ) 519 } 520 } 521 link_pads<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, ) -> Result<(), glib::error::BoolError>522 fn link_pads<P: IsA<Element>>( 523 &self, 524 srcpadname: Option<&str>, 525 dest: &P, 526 destpadname: Option<&str>, 527 ) -> Result<(), glib::error::BoolError> { 528 unsafe { 529 glib::result_from_gboolean!( 530 ffi::gst_element_link_pads( 531 self.as_ref().to_glib_none().0, 532 srcpadname.to_glib_none().0, 533 dest.as_ref().to_glib_none().0, 534 destpadname.to_glib_none().0 535 ), 536 "Failed to link pads" 537 ) 538 } 539 } 540 link_pads_filtered<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, filter: &Caps, ) -> Result<(), glib::error::BoolError>541 fn link_pads_filtered<P: IsA<Element>>( 542 &self, 543 srcpadname: Option<&str>, 544 dest: &P, 545 destpadname: Option<&str>, 546 filter: &Caps, 547 ) -> Result<(), glib::error::BoolError> { 548 unsafe { 549 glib::result_from_gboolean!( 550 ffi::gst_element_link_pads_filtered( 551 self.as_ref().to_glib_none().0, 552 srcpadname.to_glib_none().0, 553 dest.as_ref().to_glib_none().0, 554 destpadname.to_glib_none().0, 555 filter.to_glib_none().0 556 ), 557 "Failed to link pads" 558 ) 559 } 560 } 561 link_pads_full<P: IsA<Element>>( &self, srcpadname: Option<&str>, dest: &P, destpadname: Option<&str>, flags: PadLinkCheck, ) -> Result<(), glib::error::BoolError>562 fn link_pads_full<P: IsA<Element>>( 563 &self, 564 srcpadname: Option<&str>, 565 dest: &P, 566 destpadname: Option<&str>, 567 flags: PadLinkCheck, 568 ) -> Result<(), glib::error::BoolError> { 569 unsafe { 570 glib::result_from_gboolean!( 571 ffi::gst_element_link_pads_full( 572 self.as_ref().to_glib_none().0, 573 srcpadname.to_glib_none().0, 574 dest.as_ref().to_glib_none().0, 575 destpadname.to_glib_none().0, 576 flags.into_glib() 577 ), 578 "Failed to link pads" 579 ) 580 } 581 } 582 lost_state(&self)583 fn lost_state(&self) { 584 unsafe { 585 ffi::gst_element_lost_state(self.as_ref().to_glib_none().0); 586 } 587 } 588 no_more_pads(&self)589 fn no_more_pads(&self) { 590 unsafe { 591 ffi::gst_element_no_more_pads(self.as_ref().to_glib_none().0); 592 } 593 } 594 provide_clock(&self) -> Option<Clock>595 fn provide_clock(&self) -> Option<Clock> { 596 unsafe { 597 from_glib_full(ffi::gst_element_provide_clock( 598 self.as_ref().to_glib_none().0, 599 )) 600 } 601 } 602 release_request_pad<P: IsA<Pad>>(&self, pad: &P)603 fn release_request_pad<P: IsA<Pad>>(&self, pad: &P) { 604 unsafe { 605 ffi::gst_element_release_request_pad( 606 self.as_ref().to_glib_none().0, 607 pad.as_ref().to_glib_none().0, 608 ); 609 } 610 } 611 remove_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError>612 fn remove_pad<P: IsA<Pad>>(&self, pad: &P) -> Result<(), glib::error::BoolError> { 613 unsafe { 614 glib::result_from_gboolean!( 615 ffi::gst_element_remove_pad( 616 self.as_ref().to_glib_none().0, 617 pad.as_ref().to_glib_none().0 618 ), 619 "Failed to remove pad" 620 ) 621 } 622 } 623 request_pad( &self, templ: &PadTemplate, name: Option<&str>, caps: Option<&Caps>, ) -> Option<Pad>624 fn request_pad( 625 &self, 626 templ: &PadTemplate, 627 name: Option<&str>, 628 caps: Option<&Caps>, 629 ) -> Option<Pad> { 630 unsafe { 631 from_glib_full(ffi::gst_element_request_pad( 632 self.as_ref().to_glib_none().0, 633 templ.to_glib_none().0, 634 name.to_glib_none().0, 635 caps.to_glib_none().0, 636 )) 637 } 638 } 639 640 #[cfg(any(feature = "v1_20", feature = "dox"))] 641 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] request_pad_simple(&self, name: &str) -> Option<Pad>642 fn request_pad_simple(&self, name: &str) -> Option<Pad> { 643 unsafe { 644 from_glib_full(ffi::gst_element_request_pad_simple( 645 self.as_ref().to_glib_none().0, 646 name.to_glib_none().0, 647 )) 648 } 649 } 650 set_base_time(&self, time: ClockTime)651 fn set_base_time(&self, time: ClockTime) { 652 unsafe { 653 ffi::gst_element_set_base_time(self.as_ref().to_glib_none().0, time.into_glib()); 654 } 655 } 656 set_bus(&self, bus: Option<&Bus>)657 fn set_bus(&self, bus: Option<&Bus>) { 658 unsafe { 659 ffi::gst_element_set_bus(self.as_ref().to_glib_none().0, bus.to_glib_none().0); 660 } 661 } 662 set_clock<P: IsA<Clock>>(&self, clock: Option<&P>) -> Result<(), glib::error::BoolError>663 fn set_clock<P: IsA<Clock>>(&self, clock: Option<&P>) -> Result<(), glib::error::BoolError> { 664 unsafe { 665 glib::result_from_gboolean!( 666 ffi::gst_element_set_clock( 667 self.as_ref().to_glib_none().0, 668 clock.map(|p| p.as_ref()).to_glib_none().0 669 ), 670 "Failed to set clock" 671 ) 672 } 673 } 674 set_context(&self, context: &Context)675 fn set_context(&self, context: &Context) { 676 unsafe { 677 ffi::gst_element_set_context(self.as_ref().to_glib_none().0, context.to_glib_none().0); 678 } 679 } 680 set_locked_state(&self, locked_state: bool) -> bool681 fn set_locked_state(&self, locked_state: bool) -> bool { 682 unsafe { 683 from_glib(ffi::gst_element_set_locked_state( 684 self.as_ref().to_glib_none().0, 685 locked_state.into_glib(), 686 )) 687 } 688 } 689 set_start_time(&self, time: impl Into<Option<ClockTime>>)690 fn set_start_time(&self, time: impl Into<Option<ClockTime>>) { 691 unsafe { 692 ffi::gst_element_set_start_time( 693 self.as_ref().to_glib_none().0, 694 time.into().into_glib(), 695 ); 696 } 697 } 698 set_state(&self, state: State) -> Result<StateChangeSuccess, StateChangeError>699 fn set_state(&self, state: State) -> Result<StateChangeSuccess, StateChangeError> { 700 unsafe { 701 try_from_glib(ffi::gst_element_set_state( 702 self.as_ref().to_glib_none().0, 703 state.into_glib(), 704 )) 705 } 706 } 707 sync_state_with_parent(&self) -> Result<(), glib::error::BoolError>708 fn sync_state_with_parent(&self) -> Result<(), glib::error::BoolError> { 709 unsafe { 710 glib::result_from_gboolean!( 711 ffi::gst_element_sync_state_with_parent(self.as_ref().to_glib_none().0), 712 "Failed to sync state with parent" 713 ) 714 } 715 } 716 unlink<P: IsA<Element>>(&self, dest: &P)717 fn unlink<P: IsA<Element>>(&self, dest: &P) { 718 unsafe { 719 ffi::gst_element_unlink( 720 self.as_ref().to_glib_none().0, 721 dest.as_ref().to_glib_none().0, 722 ); 723 } 724 } 725 unlink_pads<P: IsA<Element>>(&self, srcpadname: &str, dest: &P, destpadname: &str)726 fn unlink_pads<P: IsA<Element>>(&self, srcpadname: &str, dest: &P, destpadname: &str) { 727 unsafe { 728 ffi::gst_element_unlink_pads( 729 self.as_ref().to_glib_none().0, 730 srcpadname.to_glib_none().0, 731 dest.as_ref().to_glib_none().0, 732 destpadname.to_glib_none().0, 733 ); 734 } 735 } 736 connect_no_more_pads<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId737 fn connect_no_more_pads<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { 738 unsafe extern "C" fn no_more_pads_trampoline< 739 P: IsA<Element>, 740 F: Fn(&P) + Send + Sync + 'static, 741 >( 742 this: *mut ffi::GstElement, 743 f: glib::ffi::gpointer, 744 ) { 745 let f: &F = &*(f as *const F); 746 f(Element::from_glib_borrow(this).unsafe_cast_ref()) 747 } 748 unsafe { 749 let f: Box_<F> = Box_::new(f); 750 connect_raw( 751 self.as_ptr() as *mut _, 752 b"no-more-pads\0".as_ptr() as *const _, 753 Some(transmute::<_, unsafe extern "C" fn()>( 754 no_more_pads_trampoline::<Self, F> as *const (), 755 )), 756 Box_::into_raw(f), 757 ) 758 } 759 } 760 connect_pad_added<F: Fn(&Self, &Pad) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId761 fn connect_pad_added<F: Fn(&Self, &Pad) + Send + Sync + 'static>( 762 &self, 763 f: F, 764 ) -> SignalHandlerId { 765 unsafe extern "C" fn pad_added_trampoline< 766 P: IsA<Element>, 767 F: Fn(&P, &Pad) + Send + Sync + 'static, 768 >( 769 this: *mut ffi::GstElement, 770 new_pad: *mut ffi::GstPad, 771 f: glib::ffi::gpointer, 772 ) { 773 let f: &F = &*(f as *const F); 774 f( 775 Element::from_glib_borrow(this).unsafe_cast_ref(), 776 &from_glib_borrow(new_pad), 777 ) 778 } 779 unsafe { 780 let f: Box_<F> = Box_::new(f); 781 connect_raw( 782 self.as_ptr() as *mut _, 783 b"pad-added\0".as_ptr() as *const _, 784 Some(transmute::<_, unsafe extern "C" fn()>( 785 pad_added_trampoline::<Self, F> as *const (), 786 )), 787 Box_::into_raw(f), 788 ) 789 } 790 } 791 connect_pad_removed<F: Fn(&Self, &Pad) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId792 fn connect_pad_removed<F: Fn(&Self, &Pad) + Send + Sync + 'static>( 793 &self, 794 f: F, 795 ) -> SignalHandlerId { 796 unsafe extern "C" fn pad_removed_trampoline< 797 P: IsA<Element>, 798 F: Fn(&P, &Pad) + Send + Sync + 'static, 799 >( 800 this: *mut ffi::GstElement, 801 old_pad: *mut ffi::GstPad, 802 f: glib::ffi::gpointer, 803 ) { 804 let f: &F = &*(f as *const F); 805 f( 806 Element::from_glib_borrow(this).unsafe_cast_ref(), 807 &from_glib_borrow(old_pad), 808 ) 809 } 810 unsafe { 811 let f: Box_<F> = Box_::new(f); 812 connect_raw( 813 self.as_ptr() as *mut _, 814 b"pad-removed\0".as_ptr() as *const _, 815 Some(transmute::<_, unsafe extern "C" fn()>( 816 pad_removed_trampoline::<Self, F> as *const (), 817 )), 818 Box_::into_raw(f), 819 ) 820 } 821 } 822 } 823