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
// 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::StaticType; use glib::Value; use glib_sys; use gobject_sys; use gst; use gst_base_sys; use std::boxed::Box as Box_; use std::mem::transmute; glib_wrapper! { /// This base class is for filter elements that process data. Elements /// that are suitable for implementation using `BaseTransform` are ones /// where the size and caps of the output is known entirely from the input /// caps and buffer sizes. These include elements that directly transform /// one buffer into another, modify the contents of a buffer in-place, as /// well as elements that collate multiple input buffers into one output buffer, /// or that expand one input buffer into multiple output buffers. See below /// for more concrete use cases. /// /// It provides for: /// /// * one sinkpad and one srcpad /// * Possible formats on sink and source pad implemented /// with custom transform_caps function. By default uses /// same format on sink and source. /// /// * Handles state changes /// * Does flushing /// * Push mode /// * Pull mode if the sub-class transform can operate on arbitrary data /// /// # Use Cases /// /// ## Passthrough mode /// /// * Element has no interest in modifying the buffer. It may want to inspect it, /// in which case the element should have a transform_ip function. If there /// is no transform_ip function in passthrough mode, the buffer is pushed /// intact. /// /// * The `BaseTransformClass.passthrough_on_same_caps` variable /// will automatically set/unset passthrough based on whether the /// element negotiates the same caps on both pads. /// /// * `BaseTransformClass.passthrough_on_same_caps` on an element that /// doesn't implement a transform_caps function is useful for elements that /// only inspect data (such as level) /// /// * Example elements /// /// * Level /// * Videoscale, audioconvert, videoconvert, audioresample in certain modes. /// /// ## Modifications in-place - input buffer and output buffer are the same thing. /// /// * The element must implement a transform_ip function. /// * Output buffer size must <= input buffer size /// * If the always_in_place flag is set, non-writable buffers will be copied /// and passed to the transform_ip function, otherwise a new buffer will be /// created and the transform function called. /// /// * Incoming writable buffers will be passed to the transform_ip function /// immediately. /// * only implementing transform_ip and not transform implies always_in_place = `true` /// /// * Example elements: /// * Volume /// * Audioconvert in certain modes (signed/unsigned conversion) /// * videoconvert in certain modes (endianness swapping) /// /// ## Modifications only to the caps/metadata of a buffer /// /// * The element does not require writable data, but non-writable buffers /// should be subbuffered so that the meta-information can be replaced. /// /// * Elements wishing to operate in this mode should replace the /// prepare_output_buffer method to create subbuffers of the input buffer /// and set always_in_place to `true` /// /// * Example elements /// * Capsfilter when setting caps on outgoing buffers that have /// none. /// * identity when it is going to re-timestamp buffers by /// datarate. /// /// ## Normal mode /// * always_in_place flag is not set, or there is no transform_ip function /// * Element will receive an input buffer and output buffer to operate on. /// * Output buffer is allocated by calling the prepare_output_buffer function. /// * Example elements: /// * Videoscale, videoconvert, audioconvert when doing /// scaling/conversions /// /// ## Special output buffer allocations /// * Elements which need to do special allocation of their output buffers /// beyond allocating output buffers via the negotiated allocator or /// buffer pool should implement the prepare_output_buffer method. /// /// * Example elements: /// * efence /// /// # Sub-class settable flags on GstBaseTransform /// /// * passthrough /// /// * Implies that in the current configuration, the sub-class is not interested in modifying the buffers. /// * Elements which are always in passthrough mode whenever the same caps has been negotiated on both pads can set the class variable passthrough_on_same_caps to have this behaviour automatically. /// /// * always_in_place /// * Determines whether a non-writable buffer will be copied before passing /// to the transform_ip function. /// /// * Implied `true` if no transform function is implemented. /// * Implied `false` if ONLY transform function is implemented. /// /// # Implements /// /// [`BaseTransformExt`](trait.BaseTransformExt.html), [`gst::ElementExt`](../gst/trait.ElementExt.html), [`gst::ObjectExt`](../gst/trait.ObjectExt.html), [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html) pub struct BaseTransform(Object<gst_base_sys::GstBaseTransform, gst_base_sys::GstBaseTransformClass, BaseTransformClass>) @extends gst::Element, gst::Object; match fn { get_type => || gst_base_sys::gst_base_transform_get_type(), } } unsafe impl Send for BaseTransform {} unsafe impl Sync for BaseTransform {} pub const NONE_BASE_TRANSFORM: Option<&BaseTransform> = None; /// Trait containing all `BaseTransform` methods. /// /// # Implementors /// /// [`BaseTransform`](struct.BaseTransform.html) pub trait BaseTransformExt: 'static { //fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams); /// /// # Returns /// /// the instance of the `gst::BufferPool` used /// by `self`; free it after use it fn get_buffer_pool(&self) -> Option<gst::BufferPool>; /// See if `self` is configured as a in_place transform. /// /// # Returns /// /// `true` is the transform is configured in in_place mode. /// /// MT safe. fn is_in_place(&self) -> bool; /// See if `self` is configured as a passthrough transform. /// /// # Returns /// /// `true` is the transform is configured in passthrough mode. /// /// MT safe. fn is_passthrough(&self) -> bool; /// Queries if the transform will handle QoS. /// /// # Returns /// /// `true` if QoS is enabled. /// /// MT safe. fn is_qos_enabled(&self) -> bool; /// Instructs `self` to request renegotiation upstream. This function is /// typically called after properties on the transform were set that /// influence the input format. fn reconfigure_sink(&self); /// Instructs `self` to renegotiate a new downstream transform on the next /// buffer. This function is typically called after properties on the transform /// were set that influence the output format. fn reconfigure_src(&self); /// If `gap_aware` is `false` (the default), output buffers will have the /// `gst::BufferFlags::Gap` flag unset. /// /// If set to `true`, the element must handle output buffers with this flag set /// correctly, i.e. it can assume that the buffer contains neutral data but must /// unset the flag if the output is no neutral data. /// /// MT safe. /// ## `gap_aware` /// New state fn set_gap_aware(&self, gap_aware: bool); /// Determines whether a non-writable buffer will be copied before passing /// to the transform_ip function. /// /// * Always `true` if no transform function is implemented. /// * Always `false` if ONLY transform function is implemented. /// /// MT safe. /// ## `in_place` /// Boolean value indicating that we would like to operate /// on in_place buffers. fn set_in_place(&self, in_place: bool); /// Set passthrough mode for this filter by default. This is mostly /// useful for filters that do not care about negotiation. /// /// Always `true` for filters which don't implement either a transform /// or transform_ip method. /// /// MT safe. /// ## `passthrough` /// boolean indicating passthrough mode. fn set_passthrough(&self, passthrough: bool); /// If `prefer_passthrough` is `true` (the default), `self` will check and /// prefer passthrough caps from the list of caps returned by the /// transform_caps vmethod. /// /// If set to `false`, the element must order the caps returned from the /// transform_caps function in such a way that the preferred format is /// first in the list. This can be interesting for transforms that can do /// passthrough transforms but prefer to do something else, like a /// capsfilter. /// /// MT safe. /// ## `prefer_passthrough` /// New state fn set_prefer_passthrough(&self, prefer_passthrough: bool); /// Enable or disable QoS handling in the transform. /// /// MT safe. /// ## `enabled` /// new state fn set_qos_enabled(&self, enabled: bool); /// Set the QoS parameters in the transform. This function is called internally /// when a QOS event is received but subclasses can provide custom information /// when needed. /// /// MT safe. /// ## `proportion` /// the proportion /// ## `diff` /// the diff against the clock /// ## `timestamp` /// the timestamp of the buffer generating the QoS expressed in /// running_time. fn update_qos(&self, proportion: f64, diff: gst::ClockTimeDiff, timestamp: gst::ClockTime); /// Updates the srcpad caps and send the caps downstream. This function /// can be used by subclasses when they have already negotiated their caps /// but found a change in them (or computed new information). This way, /// they can notify downstream about that change without losing any /// buffer. /// ## `updated_caps` /// An updated version of the srcpad caps to be pushed /// downstream /// /// # Returns /// /// `true` if the caps could be send downstream `false` otherwise fn update_src_caps(&self, updated_caps: &gst::Caps) -> Result<(), glib::error::BoolError>; fn get_property_qos(&self) -> bool; fn set_property_qos(&self, qos: bool); fn connect_property_qos_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId; } impl<O: IsA<BaseTransform>> BaseTransformExt for O { //fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams) { // unsafe { TODO: call gst_base_sys:gst_base_transform_get_allocator() } //} fn get_buffer_pool(&self) -> Option<gst::BufferPool> { unsafe { from_glib_full(gst_base_sys::gst_base_transform_get_buffer_pool( self.as_ref().to_glib_none().0, )) } } fn is_in_place(&self) -> bool { unsafe { from_glib(gst_base_sys::gst_base_transform_is_in_place( self.as_ref().to_glib_none().0, )) } } fn is_passthrough(&self) -> bool { unsafe { from_glib(gst_base_sys::gst_base_transform_is_passthrough( self.as_ref().to_glib_none().0, )) } } fn is_qos_enabled(&self) -> bool { unsafe { from_glib(gst_base_sys::gst_base_transform_is_qos_enabled( self.as_ref().to_glib_none().0, )) } } fn reconfigure_sink(&self) { unsafe { gst_base_sys::gst_base_transform_reconfigure_sink(self.as_ref().to_glib_none().0); } } fn reconfigure_src(&self) { unsafe { gst_base_sys::gst_base_transform_reconfigure_src(self.as_ref().to_glib_none().0); } } fn set_gap_aware(&self, gap_aware: bool) { unsafe { gst_base_sys::gst_base_transform_set_gap_aware( self.as_ref().to_glib_none().0, gap_aware.to_glib(), ); } } fn set_in_place(&self, in_place: bool) { unsafe { gst_base_sys::gst_base_transform_set_in_place( self.as_ref().to_glib_none().0, in_place.to_glib(), ); } } fn set_passthrough(&self, passthrough: bool) { unsafe { gst_base_sys::gst_base_transform_set_passthrough( self.as_ref().to_glib_none().0, passthrough.to_glib(), ); } } fn set_prefer_passthrough(&self, prefer_passthrough: bool) { unsafe { gst_base_sys::gst_base_transform_set_prefer_passthrough( self.as_ref().to_glib_none().0, prefer_passthrough.to_glib(), ); } } fn set_qos_enabled(&self, enabled: bool) { unsafe { gst_base_sys::gst_base_transform_set_qos_enabled( self.as_ref().to_glib_none().0, enabled.to_glib(), ); } } fn update_qos(&self, proportion: f64, diff: gst::ClockTimeDiff, timestamp: gst::ClockTime) { unsafe { gst_base_sys::gst_base_transform_update_qos( self.as_ref().to_glib_none().0, proportion, diff, timestamp.to_glib(), ); } } fn update_src_caps(&self, updated_caps: &gst::Caps) -> Result<(), glib::error::BoolError> { unsafe { glib_result_from_gboolean!( gst_base_sys::gst_base_transform_update_src_caps( self.as_ref().to_glib_none().0, updated_caps.to_glib_none().0 ), "Failed to update src caps" ) } } fn get_property_qos(&self) -> bool { unsafe { let mut value = Value::from_type(<bool as StaticType>::static_type()); gobject_sys::g_object_get_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"qos\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `qos` getter") .unwrap() } } fn set_property_qos(&self, qos: bool) { unsafe { gobject_sys::g_object_set_property( self.to_glib_none().0 as *mut gobject_sys::GObject, b"qos\0".as_ptr() as *const _, Value::from(&qos).to_glib_none().0, ); } } fn connect_property_qos_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_qos_trampoline<P, F: Fn(&P) + Send + Sync + 'static>( this: *mut gst_base_sys::GstBaseTransform, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer, ) where P: IsA<BaseTransform>, { let f: &F = &*(f as *const F); f(&BaseTransform::from_glib_borrow(this).unsafe_cast()) } unsafe { let f: Box_<F> = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::qos\0".as_ptr() as *const _, Some(transmute(notify_qos_trampoline::<Self, F> as usize)), Box_::into_raw(f), ) } } }