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
// 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::Extractable;
use crate::MetaContainer;
use crate::Source;
use crate::TimelineElement;
use crate::TrackElement;
use glib::object::IsA;
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
use glib::translate::*;
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
use std::mem;

glib::wrapper! {
    /// Base class for video sources
    ///
    /// This is an Abstract Base Class, you cannot instantiate it.
    ///
    /// # Implements
    ///
    /// [`VideoSourceExt`][trait@crate::prelude::VideoSourceExt], [`SourceExt`][trait@crate::prelude::SourceExt], [`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]
    #[doc(alias = "GESVideoSource")]
    pub struct VideoSource(Object<ffi::GESVideoSource, ffi::GESVideoSourceClass>) @extends Source, TrackElement, TimelineElement, @implements Extractable, MetaContainer;

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

impl VideoSource {
    pub const NONE: Option<&'static VideoSource> = None;
}

/// Trait containing all [`struct@VideoSource`] methods.
///
/// # Implementors
///
/// [`ImageSource`][struct@crate::ImageSource], [`MultiFileSource`][struct@crate::MultiFileSource], [`TitleSource`][struct@crate::TitleSource], [`VideoSource`][struct@crate::VideoSource], [`VideoTestSource`][struct@crate::VideoTestSource], [`VideoUriSource`][struct@crate::VideoUriSource]
pub trait VideoSourceExt: 'static {
    /// Retrieves the natural size of the video stream. The natural size, is
    /// the size at which it will be displayed if no scaling is being applied.
    ///
    /// NOTE: The sources take into account the potential video rotation applied
    /// by the `videoflip` element that is inside the source, effects applied on
    /// the clip which potentially also rotate the element are not taken into
    /// account.
    ///
    /// # Returns
    ///
    /// [`true`] if the object has a natural size, [`false`] otherwise.
    ///
    /// ## `width`
    /// The natural width of the underlying source
    ///
    /// ## `height`
    /// The natural height of the underlying source
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    #[doc(alias = "ges_video_source_get_natural_size")]
    #[doc(alias = "get_natural_size")]
    fn natural_size(&self) -> Option<(i32, i32)>;
}

impl<O: IsA<VideoSource>> VideoSourceExt for O {
    #[cfg(any(feature = "v1_18", feature = "dox"))]
    #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    fn natural_size(&self) -> Option<(i32, i32)> {
        unsafe {
            let mut width = mem::MaybeUninit::uninit();
            let mut height = mem::MaybeUninit::uninit();
            let ret = from_glib(ffi::ges_video_source_get_natural_size(
                self.as_ref().to_glib_none().0,
                width.as_mut_ptr(),
                height.as_mut_ptr(),
            ));
            let width = width.assume_init();
            let height = height.assume_init();
            if ret {
                Some((width, height))
            } else {
                None
            }
        }
    }
}