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
// 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::BaseEffect;
use crate::Extractable;
use crate::TimelineElement;
use crate::TrackElement;
use glib::object::IsA;
use glib::translate::*;
use glib::StaticType;

glib::wrapper! {
    /// Currently we only support effects with N sinkpads and one single srcpad.
    /// Apart from `gesaudiomixer` and `gescompositor` which can be used as effects
    /// and where sinkpads will be requested as needed based on the timeline topology
    /// GES will always request at most one sinkpad per effect (when required).
    ///
    /// > Note: GES always adds converters (`audioconvert ! audioresample !
    /// > audioconvert` for audio effects and `videoconvert` for video effects) to
    /// > make it simpler for end users.
    ///
    /// # Implements
    ///
    /// [`EffectExt`][trait@crate::prelude::EffectExt], [`BaseEffectExt`][trait@crate::prelude::BaseEffectExt], [`TrackElementExt`][trait@crate::prelude::TrackElementExt], [`TimelineElementExt`][trait@crate::prelude::TimelineElementExt], [`trait@glib::ObjectExt`], [`ExtractableExt`][trait@crate::prelude::ExtractableExt], [`TimelineElementExtManual`][trait@crate::prelude::TimelineElementExtManual]
    #[doc(alias = "GESEffect")]
    pub struct Effect(Object<ffi::GESEffect, ffi::GESEffectClass>) @extends BaseEffect, TrackElement, TimelineElement, @implements Extractable;

    match fn {
        type_ => || ffi::ges_effect_get_type(),
    }
}

impl Effect {
    /// Creates a new [`Effect`][crate::Effect] from the description of the bin. It should be
    /// possible to determine the type of the effect through the element
    /// 'klass' metadata of the GstElements that will be created.
    /// In that corner case, you should use:
    /// `ges_asset_request` (GES_TYPE_EFFECT, "audio your ! bin ! description", NULL);
    /// and extract that asset to be in full control.
    /// ## `bin_description`
    /// The gst-launch like bin description of the effect
    ///
    /// # Returns
    ///
    /// a newly created [`Effect`][crate::Effect], or [`None`] if something went
    /// wrong.
    #[doc(alias = "ges_effect_new")]
    pub fn new(bin_description: &str) -> Result<Effect, glib::BoolError> {
        assert_initialized_main_thread!();
        unsafe {
            Option::<_>::from_glib_none(ffi::ges_effect_new(bin_description.to_glib_none().0))
                .ok_or_else(|| glib::bool_error!("Failed to create effect from description"))
        }
    }
}

pub const NONE_EFFECT: Option<&Effect> = None;

/// Trait containing all [`struct@Effect`] methods.
///
/// # Implementors
///
/// [`Effect`][struct@crate::Effect]
pub trait EffectExt: 'static {
    /// The description of the effect bin with a gst-launch-style
    /// pipeline description.
    ///
    /// Example: "videobalance saturation=1.5 hue=+0.5"
    #[doc(alias = "bin-description")]
    fn bin_description(&self) -> Option<glib::GString>;
}

impl<O: IsA<Effect>> EffectExt for O {
    fn bin_description(&self) -> Option<glib::GString> {
        unsafe {
            let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type());
            glib::gobject_ffi::g_object_get_property(
                self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
                b"bin-description\0".as_ptr() as *const _,
                value.to_glib_none_mut().0,
            );
            value
                .get()
                .expect("Return Value for property `bin-description` getter")
        }
    }
}