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
// 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 glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; 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`][crate::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 `GstBaseTransformClass.passthrough_on_same_caps` variable /// will automatically set/unset passthrough based on whether the /// element negotiates the same caps on both pads. /// /// * `GstBaseTransformClass.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. /// /// This is an Abstract Base Class, you cannot instantiate it. /// /// # Implements /// /// [`BaseTransformExt`][trait@crate::prelude::BaseTransformExt], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`BaseTransformExtManual`][trait@crate::prelude::BaseTransformExtManual] #[doc(alias = "GstBaseTransform")] pub struct BaseTransform(Object<ffi::GstBaseTransform, ffi::GstBaseTransformClass>) @extends gst::Element, gst::Object; match fn { type_ => || ffi::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 [`struct@BaseTransform`] methods. /// /// # Implementors /// /// [`BaseTransform`][struct@crate::BaseTransform] pub trait BaseTransformExt: 'static { /// /// # Returns /// /// the instance of the [`gst::BufferPool`][crate::gst::BufferPool] used /// by `self`; free it after use #[doc(alias = "gst_base_transform_get_buffer_pool")] #[doc(alias = "get_buffer_pool")] fn buffer_pool(&self) -> Option<gst::BufferPool>; /// See if `self` is configured as a in_place transform. /// /// # Returns /// /// [`true`] if the transform is configured in in_place mode. /// /// MT safe. #[doc(alias = "gst_base_transform_is_in_place")] fn is_in_place(&self) -> bool; /// See if `self` is configured as a passthrough transform. /// /// # Returns /// /// [`true`] if the transform is configured in passthrough mode. /// /// MT safe. #[doc(alias = "gst_base_transform_is_passthrough")] fn is_passthrough(&self) -> bool; /// Negotiates src pad caps with downstream elements if the source pad is /// marked as needing reconfiguring. Unmarks GST_PAD_FLAG_NEED_RECONFIGURE in /// any case. But marks it again if negotiation fails. /// /// Do not call this in the `GstBaseTransformClass::transform` or /// `GstBaseTransformClass::transform_ip` vmethod. Call this in /// `GstBaseTransformClass::submit_input_buffer`, /// `GstBaseTransformClass::prepare_output_buffer` or in /// `GstBaseTransformClass::generate_output` _before_ any output buffer is /// allocated. /// /// It will be default be called when handling an ALLOCATION query or at the /// very beginning of the default `GstBaseTransformClass::submit_input_buffer` /// implementation. /// /// # Returns /// /// [`true`] if the negotiation succeeded, else [`false`]. #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_base_transform_reconfigure")] fn reconfigure(&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. #[doc(alias = "gst_base_transform_reconfigure_sink")] 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. #[doc(alias = "gst_base_transform_reconfigure_src")] fn reconfigure_src(&self); /// If `gap_aware` is [`false`] (the default), output buffers will have the /// [`gst::BufferFlags::GAP`][crate::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 #[doc(alias = "gst_base_transform_set_gap_aware")] 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. #[doc(alias = "gst_base_transform_set_in_place")] 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 or generate_output method. /// /// MT safe. /// ## `passthrough` /// boolean indicating passthrough mode. #[doc(alias = "gst_base_transform_set_passthrough")] 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 #[doc(alias = "gst_base_transform_set_prefer_passthrough")] fn set_prefer_passthrough(&self, prefer_passthrough: 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. #[doc(alias = "gst_base_transform_update_qos")] fn update_qos(&self, proportion: f64, diff: gst::ClockTimeDiff, timestamp: gst::ClockTime); /// Updates the srcpad caps and sends 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 sent downstream [`false`] otherwise #[doc(alias = "gst_base_transform_update_src_caps")] fn update_src_caps(&self, updated_caps: &gst::Caps) -> Result<(), glib::error::BoolError>; fn is_qos(&self) -> bool; fn set_qos(&self, qos: bool); #[doc(alias = "qos")] fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId; } impl<O: IsA<BaseTransform>> BaseTransformExt for O { fn buffer_pool(&self) -> Option<gst::BufferPool> { unsafe { from_glib_full(ffi::gst_base_transform_get_buffer_pool( self.as_ref().to_glib_none().0, )) } } fn is_in_place(&self) -> bool { unsafe { from_glib(ffi::gst_base_transform_is_in_place( self.as_ref().to_glib_none().0, )) } } fn is_passthrough(&self) -> bool { unsafe { from_glib(ffi::gst_base_transform_is_passthrough( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] fn reconfigure(&self) -> bool { unsafe { from_glib(ffi::gst_base_transform_reconfigure( self.as_ref().to_glib_none().0, )) } } fn reconfigure_sink(&self) { unsafe { ffi::gst_base_transform_reconfigure_sink(self.as_ref().to_glib_none().0); } } fn reconfigure_src(&self) { unsafe { ffi::gst_base_transform_reconfigure_src(self.as_ref().to_glib_none().0); } } fn set_gap_aware(&self, gap_aware: bool) { unsafe { ffi::gst_base_transform_set_gap_aware( self.as_ref().to_glib_none().0, gap_aware.into_glib(), ); } } fn set_in_place(&self, in_place: bool) { unsafe { ffi::gst_base_transform_set_in_place( self.as_ref().to_glib_none().0, in_place.into_glib(), ); } } fn set_passthrough(&self, passthrough: bool) { unsafe { ffi::gst_base_transform_set_passthrough( self.as_ref().to_glib_none().0, passthrough.into_glib(), ); } } fn set_prefer_passthrough(&self, prefer_passthrough: bool) { unsafe { ffi::gst_base_transform_set_prefer_passthrough( self.as_ref().to_glib_none().0, prefer_passthrough.into_glib(), ); } } fn update_qos(&self, proportion: f64, diff: gst::ClockTimeDiff, timestamp: gst::ClockTime) { unsafe { ffi::gst_base_transform_update_qos( self.as_ref().to_glib_none().0, proportion, diff, timestamp.into_glib(), ); } } fn update_src_caps(&self, updated_caps: &gst::Caps) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::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 is_qos(&self) -> bool { unsafe { let mut value = glib::Value::from_type(<bool as StaticType>::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"qos\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value.get().expect("Return Value for property `qos` getter") } } fn set_qos(&self, qos: bool) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"qos\0".as_ptr() as *const _, qos.to_value().to_glib_none().0, ); } } #[doc(alias = "qos")] fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_qos_trampoline< P: IsA<BaseTransform>, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GstBaseTransform, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&BaseTransform::from_glib_borrow(this).unsafe_cast_ref()) } 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::<_, unsafe extern "C" fn()>( notify_qos_trampoline::<Self, F> as *const (), )), Box_::into_raw(f), ) } } }