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
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT use crate::Object; use glib::object::IsA; use glib::translate::*; glib::wrapper! { /// A [`BufferPool`][crate::BufferPool] is an object that can be used to pre-allocate and recycle /// buffers of the same size and with the same properties. /// /// A [`BufferPool`][crate::BufferPool] is created with [`new()`][Self::new()]. /// /// Once a pool is created, it needs to be configured. A call to /// [`BufferPoolExtManual::config()`][crate::prelude::BufferPoolExtManual::config()] returns the current configuration structure from /// the pool. With `gst_buffer_pool_config_set_params()` and /// `gst_buffer_pool_config_set_allocator()` the bufferpool parameters and /// allocator can be configured. Other properties can be configured in the pool /// depending on the pool implementation. /// /// A bufferpool can have extra options that can be enabled with /// `gst_buffer_pool_config_add_option()`. The available options can be retrieved /// with [`BufferPoolExt::options()`][crate::prelude::BufferPoolExt::options()]. Some options allow for additional /// configuration properties to be set. /// /// After the configuration structure has been configured, /// [`BufferPoolExtManual::set_config()`][crate::prelude::BufferPoolExtManual::set_config()] updates the configuration in the pool. This can /// fail when the configuration structure is not accepted. /// /// After the pool has been configured, it can be activated with /// [`BufferPoolExt::set_active()`][crate::prelude::BufferPoolExt::set_active()]. This will preallocate the configured resources /// in the pool. /// /// When the pool is active, [`BufferPoolExtManual::acquire_buffer()`][crate::prelude::BufferPoolExtManual::acquire_buffer()] can be used to /// retrieve a buffer from the pool. /// /// Buffers allocated from a bufferpool will automatically be returned to the /// pool with [`BufferPoolExtManual::release_buffer()`][crate::prelude::BufferPoolExtManual::release_buffer()] when their refcount drops to 0. /// /// The bufferpool can be deactivated again with [`BufferPoolExt::set_active()`][crate::prelude::BufferPoolExt::set_active()]. /// All further [`BufferPoolExtManual::acquire_buffer()`][crate::prelude::BufferPoolExtManual::acquire_buffer()] calls will return an error. When /// all buffers are returned to the pool they will be freed. /// /// # Implements /// /// [`BufferPoolExt`][trait@crate::prelude::BufferPoolExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`BufferPoolExtManual`][trait@crate::prelude::BufferPoolExtManual] #[doc(alias = "GstBufferPool")] pub struct BufferPool(Object<ffi::GstBufferPool, ffi::GstBufferPoolClass>) @extends Object; match fn { type_ => || ffi::gst_buffer_pool_get_type(), } } unsafe impl Send for BufferPool {} unsafe impl Sync for BufferPool {} pub const NONE_BUFFER_POOL: Option<&BufferPool> = None; /// Trait containing all [`struct@BufferPool`] methods. /// /// # Implementors /// /// [`BufferPool`][struct@crate::BufferPool] pub trait BufferPoolExt: 'static { /// Gets a [`None`] terminated array of string with supported bufferpool options for /// `self`. An option would typically be enabled with /// `gst_buffer_pool_config_add_option()`. /// /// # Returns /// /// a [`None`] terminated array /// of strings. #[doc(alias = "gst_buffer_pool_get_options")] #[doc(alias = "get_options")] fn options(&self) -> Vec<glib::GString>; /// Checks if the bufferpool supports `option`. /// ## `option` /// an option /// /// # Returns /// /// [`true`] if the buffer pool contains `option`. #[doc(alias = "gst_buffer_pool_has_option")] fn has_option(&self, option: &str) -> bool; /// Checks if `self` is active. A pool can be activated with the /// [`set_active()`][Self::set_active()] call. /// /// # Returns /// /// [`true`] when the pool is active. #[doc(alias = "gst_buffer_pool_is_active")] fn is_active(&self) -> bool; /// Controls the active state of `self`. When the pool is inactive, new calls to /// [`BufferPoolExtManual::acquire_buffer()`][crate::prelude::BufferPoolExtManual::acquire_buffer()] will return with [`FlowReturn::Flushing`][crate::FlowReturn::Flushing]. /// /// Activating the bufferpool will preallocate all resources in the pool based on /// the configuration of the pool. /// /// Deactivating will free the resources again when there are no outstanding /// buffers. When there are outstanding buffers, they will be freed as soon as /// they are all returned to the pool. /// ## `active` /// the new active state /// /// # Returns /// /// [`false`] when the pool was not configured or when preallocation of the /// buffers failed. #[doc(alias = "gst_buffer_pool_set_active")] fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError>; /// Enables or disables the flushing state of a `self` without freeing or /// allocating buffers. /// ## `flushing` /// whether to start or stop flushing #[doc(alias = "gst_buffer_pool_set_flushing")] fn set_flushing(&self, flushing: bool); } impl<O: IsA<BufferPool>> BufferPoolExt for O { fn options(&self) -> Vec<glib::GString> { unsafe { FromGlibPtrContainer::from_glib_none(ffi::gst_buffer_pool_get_options( self.as_ref().to_glib_none().0, )) } } fn has_option(&self, option: &str) -> bool { unsafe { from_glib(ffi::gst_buffer_pool_has_option( self.as_ref().to_glib_none().0, option.to_glib_none().0, )) } } fn is_active(&self) -> bool { unsafe { from_glib(ffi::gst_buffer_pool_is_active( self.as_ref().to_glib_none().0, )) } } fn set_active(&self, active: bool) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gst_buffer_pool_set_active(self.as_ref().to_glib_none().0, active.into_glib()), "Failed to activate buffer pool" ) } } fn set_flushing(&self, flushing: bool) { unsafe { ffi::gst_buffer_pool_set_flushing(self.as_ref().to_glib_none().0, flushing.into_glib()); } } }