gstreamer_editing_services/auto/
effect.rs

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
6use crate::{
7    ffi, BaseEffect, Extractable, MetaContainer, Operation, TimelineElement, TrackElement,
8};
9use glib::{prelude::*, translate::*};
10
11glib::wrapper! {
12    /// Any GStreamer filter can be used as effects in GES. The only restriction we
13    /// have is that effects element should have a single [sinkpad](GST_PAD_SINK)
14    /// (which will be requested if necessary) and a single [srcpad](GST_PAD_SRC).
15    ///
16    /// Note that `gesaudiomixer` and `gescompositor` can be used as effects even
17    /// though they can have several sinkpads.
18    ///
19    /// ## GES specific effects:
20    ///
21    /// * **`gesvideoscale`**: GES implements a specific scaling bin that allows
22    ///  specifying where scaling will happen inside the chain of effects. By
23    ///  default scaling can happen either in the source (if the source doesn't have
24    ///  a specific size, like `videotestsrc` or [mixing](ges_track_set_mixing) has
25    ///  been disabled) or in the mixing element otherwise, when adding that element
26    ///  as an effect, GES guarantees that the scaling will happen in it. This can
27    ///  be useful for example if you want to crop the video before scaling or apply
28    ///  rounding corners to the video after scaling, etc...
29    ///
30    /// > Note: GES always adds converters (`audioconvert ! audioresample !
31    /// > audioconvert` for audio effects and `videoconvert` for video effects) to
32    /// > make it simpler for end users.
33    ///
34    /// ## Properties
35    ///
36    ///
37    /// #### `bin-description`
38    ///  The description of the effect bin with a gst-launch-style
39    /// pipeline description.
40    ///
41    /// Example: "videobalance saturation=1.5 hue=+0.5"
42    ///
43    /// Readable | Writeable | Construct Only
44    /// <details><summary><h4>TrackElement</h4></summary>
45    ///
46    ///
47    /// #### `active`
48    ///  Whether the effect of the element should be applied in its
49    /// [`track`][struct@crate::TrackElement#track]. If set to [`false`], it will not be used in
50    /// the output of the track.
51    ///
52    /// Readable | Writeable
53    ///
54    ///
55    /// #### `auto-clamp-control-sources`
56    ///  Whether the control sources on the element (see
57    /// [`TrackElementExt::set_control_source()`][crate::prelude::TrackElementExt::set_control_source()]) will be automatically
58    /// updated whenever the [`in-point`][struct@crate::TimelineElement#in-point] or out-point of the
59    /// element change in value.
60    ///
61    /// See [`TrackElementExt::clamp_control_source()`][crate::prelude::TrackElementExt::clamp_control_source()] for how this is done
62    /// per control source.
63    ///
64    /// Default value: [`true`]
65    ///
66    /// Readable | Writeable
67    ///
68    ///
69    /// #### `has-internal-source`
70    ///  This property is used to determine whether the 'internal time'
71    /// properties of the element have any meaning. In particular, unless
72    /// this is set to [`true`], the [`in-point`][struct@crate::TimelineElement#in-point] and
73    /// [`max-duration`][struct@crate::TimelineElement#max-duration] can not be set to any value other
74    /// than the default 0 and `GST_CLOCK_TIME_NONE`, respectively.
75    ///
76    /// If an element has some *internal* *timed* source [`gst::Element`][crate::gst::Element] that it
77    /// reads stream data from as part of its function in a [`Track`][crate::Track], then
78    /// you'll likely want to set this to [`true`] to allow the
79    /// [`in-point`][struct@crate::TimelineElement#in-point] and [`max-duration`][struct@crate::TimelineElement#max-duration] to
80    /// be set.
81    ///
82    /// The default value is determined by the `GESTrackElementClass`
83    /// `default_has_internal_source` class property. For most
84    /// `GESSourceClass`-es, this will be [`true`], with the exception of those
85    /// that have a potentially *static* source, such as `GESImageSourceClass`
86    /// and `GESTitleSourceClass`. Otherwise, this will usually be [`false`].
87    ///
88    /// For most [`Operation`][crate::Operation]-s you will likely want to leave this set to
89    /// [`false`]. The exception may be for an operation that reads some stream
90    /// data from some private internal source as part of manipulating the
91    /// input data from the usual linked upstream [`TrackElement`][crate::TrackElement].
92    ///
93    /// For example, you may want to set this to [`true`] for a
94    /// [`TrackType::VIDEO`][crate::TrackType::VIDEO] operation that wraps a `textoverlay` that reads
95    /// from a subtitle file and places its text on top of the received video
96    /// data. The [`in-point`][struct@crate::TimelineElement#in-point] of the element would be used
97    /// to shift the initial seek time on the `textoverlay` away from 0, and
98    /// the [`max-duration`][struct@crate::TimelineElement#max-duration] could be set to reflect the
99    /// time at which the subtitle file runs out of data.
100    ///
101    /// Note that GES can not support track elements that have both internal
102    /// content and manipulate the timing of their data streams (time
103    /// effects).
104    ///
105    /// Readable | Writeable
106    ///
107    ///
108    /// #### `track`
109    ///  The track that this element belongs to, or [`None`] if it does not
110    /// belong to a track.
111    ///
112    /// Readable
113    ///
114    ///
115    /// #### `track-type`
116    ///  The track type of the element, which determines the type of track the
117    /// element can be added to (see [`track-type`][struct@crate::Track#track-type]). This should
118    /// correspond to the type of data that the element can produce or
119    /// process.
120    ///
121    /// Readable | Writeable | Construct
122    /// </details>
123    /// <details><summary><h4>TimelineElement</h4></summary>
124    ///
125    ///
126    /// #### `duration`
127    ///  The duration that the element is in effect for in the timeline (a
128    /// time difference in nanoseconds using the time coordinates of the
129    /// timeline). For example, for a source element, this would determine
130    /// for how long it should output its internal content for. For an
131    /// operation element, this would determine for how long its effect
132    /// should be applied to any source content.
133    ///
134    /// Readable | Writeable
135    ///
136    ///
137    /// #### `in-point`
138    ///  The initial offset to use internally when outputting content (in
139    /// nanoseconds, but in the time coordinates of the internal content).
140    ///
141    /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
142    /// file, the "internal content" is the media file data, and the
143    /// in-point would correspond to some timestamp in the media file.
144    /// When playing the timeline, and when the element is first reached at
145    /// timeline-time [`start`][struct@crate::TimelineElement#start], it will begin outputting the
146    /// data from the timestamp in-point **onwards**, until it reaches the
147    /// end of its [`duration`][struct@crate::TimelineElement#duration] in the timeline.
148    ///
149    /// For elements that have no internal content, this should be kept
150    /// as 0.
151    ///
152    /// Readable | Writeable
153    ///
154    ///
155    /// #### `max-duration`
156    ///  The full duration of internal content that is available (a time
157    /// difference in nanoseconds using the time coordinates of the internal
158    /// content).
159    ///
160    /// This will act as a cap on the [`in-point`][struct@crate::TimelineElement#in-point] of the
161    /// element (which is in the same time coordinates), and will sometimes
162    /// be used to limit the [`duration`][struct@crate::TimelineElement#duration] of the element in
163    /// the timeline.
164    ///
165    /// For example, for a [`VideoUriSource`][crate::VideoUriSource] that references some media
166    /// file, this would be the length of the media file.
167    ///
168    /// For elements that have no internal content, or whose content is
169    /// indefinite, this should be kept as `GST_CLOCK_TIME_NONE`.
170    ///
171    /// Readable | Writeable | Construct
172    ///
173    ///
174    /// #### `name`
175    ///  The name of the element. This should be unique within its timeline.
176    ///
177    /// Readable | Writeable | Construct
178    ///
179    ///
180    /// #### `parent`
181    ///  The parent container of the element.
182    ///
183    /// Readable | Writeable
184    ///
185    ///
186    /// #### `priority`
187    ///  The priority of the element.
188    ///
189    /// Readable | Writeable
190    ///
191    ///
192    /// #### `serialize`
193    ///  Whether the element should be serialized.
194    ///
195    /// Readable | Writeable
196    ///
197    ///
198    /// #### `start`
199    ///  The starting position of the element in the timeline (in nanoseconds
200    /// and in the time coordinates of the timeline). For example, for a
201    /// source element, this would determine the time at which it should
202    /// start outputting its internal content. For an operation element, this
203    /// would determine the time at which it should start applying its effect
204    /// to any source content.
205    ///
206    /// Readable | Writeable
207    ///
208    ///
209    /// #### `timeline`
210    ///  The timeline that the element lies within.
211    ///
212    /// Readable | Writeable
213    /// </details>
214    ///
215    /// # Implements
216    ///
217    /// [`EffectExt`][trait@crate::prelude::EffectExt], [`BaseEffectExt`][trait@crate::prelude::BaseEffectExt], [`OperationExt`][trait@crate::prelude::OperationExt], [`TrackElementExt`][trait@crate::prelude::TrackElementExt], [`TimelineElementExt`][trait@crate::prelude::TimelineElementExt], [`trait@glib::ObjectExt`], [`ExtractableExt`][trait@crate::prelude::ExtractableExt], [`MetaContainerExt`][trait@crate::prelude::MetaContainerExt], [`TimelineElementExtManual`][trait@crate::prelude::TimelineElementExtManual]
218    #[doc(alias = "GESEffect")]
219    pub struct Effect(Object<ffi::GESEffect, ffi::GESEffectClass>) @extends BaseEffect, Operation, TrackElement, TimelineElement, @implements Extractable, MetaContainer;
220
221    match fn {
222        type_ => || ffi::ges_effect_get_type(),
223    }
224}
225
226impl Effect {
227    pub const NONE: Option<&'static Effect> = None;
228
229    /// Creates a new [`Effect`][crate::Effect] from the description of the bin. It should be
230    /// possible to determine the type of the effect through the element
231    /// 'klass' metadata of the GstElements that will be created.
232    /// In that corner case, you should use:
233    /// `ges_asset_request` (GES_TYPE_EFFECT, "audio your ! bin ! description", NULL);
234    /// and extract that asset to be in full control.
235    /// ## `bin_description`
236    /// The gst-launch like bin description of the effect
237    ///
238    /// # Returns
239    ///
240    /// a newly created [`Effect`][crate::Effect], or [`None`] if something went
241    /// wrong.
242    #[doc(alias = "ges_effect_new")]
243    pub fn new(bin_description: &str) -> Result<Effect, glib::BoolError> {
244        assert_initialized_main_thread!();
245        unsafe {
246            Option::<_>::from_glib_none(ffi::ges_effect_new(bin_description.to_glib_none().0))
247                .ok_or_else(|| glib::bool_error!("Failed to create effect from description"))
248        }
249    }
250}
251
252/// Trait containing all [`struct@Effect`] methods.
253///
254/// # Implementors
255///
256/// [`Effect`][struct@crate::Effect]
257pub trait EffectExt: IsA<Effect> + 'static {
258    /// The description of the effect bin with a gst-launch-style
259    /// pipeline description.
260    ///
261    /// Example: "videobalance saturation=1.5 hue=+0.5"
262    #[doc(alias = "bin-description")]
263    fn bin_description(&self) -> Option<glib::GString> {
264        ObjectExt::property(self.as_ref(), "bin-description")
265    }
266}
267
268impl<O: IsA<Effect>> EffectExt for O {}