gstreamer-rs/gstreamer-editing-services/src/auto/layer.rs

378 lines
12 KiB
Rust
Raw Normal View History

// 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
#![allow(deprecated)]
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2020-11-22 10:12:36 +00:00
use crate::Track;
use crate::{Asset, Clip, Extractable, MetaContainer, Timeline, TrackType};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
2020-06-03 12:26:16 +00:00
use std::ptr;
use std::{boxed::Box as Box_, mem::transmute};
2020-12-17 22:34:53 +00:00
glib::wrapper! {
#[doc(alias = "GESLayer")]
2021-09-19 08:07:33 +00:00
pub struct Layer(Object<ffi::GESLayer, ffi::GESLayerClass>) @implements Extractable, MetaContainer;
match fn {
type_ => || ffi::ges_layer_get_type(),
}
}
impl Layer {
2021-11-16 14:02:58 +00:00
pub const NONE: Option<&'static Layer> = None;
2020-12-08 13:00:17 +00:00
#[doc(alias = "ges_layer_new")]
pub fn new() -> Layer {
assert_initialized_main_thread!();
2020-11-22 10:12:36 +00:00
unsafe { from_glib_none(ffi::ges_layer_new()) }
}
}
impl Default for Layer {
fn default() -> Self {
Self::new()
}
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Layer>> Sealed for T {}
}
pub trait LayerExt: IsA<Layer> + sealed::Sealed + 'static {
#[doc(alias = "ges_layer_add_asset")]
fn add_asset(
&self,
asset: &impl IsA<Asset>,
start: impl Into<Option<gst::ClockTime>>,
inpoint: impl Into<Option<gst::ClockTime>>,
duration: impl Into<Option<gst::ClockTime>>,
track_types: TrackType,
) -> Result<Clip, glib::BoolError> {
unsafe {
2020-11-22 10:12:36 +00:00
Option::<_>::from_glib_none(ffi::ges_layer_add_asset(
self.as_ref().to_glib_none().0,
asset.as_ref().to_glib_none().0,
start.into().into_glib(),
inpoint.into().into_glib(),
duration.into().into_glib(),
track_types.into_glib(),
))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Failed to add asset"))
}
}
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "ges_layer_add_asset_full")]
fn add_asset_full(
2020-06-03 12:26:16 +00:00
&self,
asset: &impl IsA<Asset>,
start: impl Into<Option<gst::ClockTime>>,
inpoint: impl Into<Option<gst::ClockTime>>,
duration: impl Into<Option<gst::ClockTime>>,
2020-06-03 12:26:16 +00:00
track_types: TrackType,
) -> Result<Clip, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
2020-11-22 10:12:36 +00:00
let ret = ffi::ges_layer_add_asset_full(
2020-06-03 12:26:16 +00:00
self.as_ref().to_glib_none().0,
asset.as_ref().to_glib_none().0,
start.into().into_glib(),
inpoint.into().into_glib(),
duration.into().into_glib(),
track_types.into_glib(),
2020-06-03 12:26:16 +00:00
&mut error,
);
if error.is_null() {
Ok(from_glib_none(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "ges_layer_add_clip")]
fn add_clip(&self, clip: &impl IsA<Clip>) -> Result<(), glib::error::BoolError> {
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
2020-11-22 10:12:36 +00:00
ffi::ges_layer_add_clip(
self.as_ref().to_glib_none().0,
clip.as_ref().to_glib_none().0
),
"Failed to add clip"
)
}
}
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "ges_layer_add_clip_full")]
fn add_clip_full(&self, clip: &impl IsA<Clip>) -> Result<(), glib::Error> {
2020-06-03 12:26:16 +00:00
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::ges_layer_add_clip_full(
2020-06-03 12:26:16 +00:00
self.as_ref().to_glib_none().0,
clip.as_ref().to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
2020-06-03 12:26:16 +00:00
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "ges_layer_get_active_for_track")]
#[doc(alias = "get_active_for_track")]
fn is_active_for_track(&self, track: &impl IsA<Track>) -> bool {
2020-04-30 16:51:41 +00:00
unsafe {
2020-11-22 10:12:36 +00:00
from_glib(ffi::ges_layer_get_active_for_track(
2020-04-30 16:51:41 +00:00
self.as_ref().to_glib_none().0,
track.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "ges_layer_get_auto_transition")]
#[doc(alias = "get_auto_transition")]
2021-04-11 19:38:18 +00:00
fn is_auto_transition(&self) -> bool {
unsafe {
2020-11-22 10:12:36 +00:00
from_glib(ffi::ges_layer_get_auto_transition(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "ges_layer_get_clips")]
#[doc(alias = "get_clips")]
2021-04-11 19:38:18 +00:00
fn clips(&self) -> Vec<Clip> {
unsafe {
2020-11-22 10:12:36 +00:00
FromGlibPtrContainer::from_glib_full(ffi::ges_layer_get_clips(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "ges_layer_get_clips_in_interval")]
#[doc(alias = "get_clips_in_interval")]
fn clips_in_interval(
&self,
start: impl Into<Option<gst::ClockTime>>,
end: impl Into<Option<gst::ClockTime>>,
) -> Vec<Clip> {
unsafe {
2020-11-22 10:12:36 +00:00
FromGlibPtrContainer::from_glib_full(ffi::ges_layer_get_clips_in_interval(
self.as_ref().to_glib_none().0,
start.into().into_glib(),
end.into().into_glib(),
))
}
}
#[doc(alias = "ges_layer_get_duration")]
#[doc(alias = "get_duration")]
2021-04-11 19:38:18 +00:00
fn duration(&self) -> gst::ClockTime {
unsafe {
try_from_glib(ffi::ges_layer_get_duration(self.as_ref().to_glib_none().0))
.expect("mandatory glib value is None")
}
}
#[doc(alias = "ges_layer_get_priority")]
#[doc(alias = "get_priority")]
2021-04-11 19:38:18 +00:00
fn priority(&self) -> u32 {
2020-11-22 10:12:36 +00:00
unsafe { ffi::ges_layer_get_priority(self.as_ref().to_glib_none().0) }
}
#[doc(alias = "ges_layer_get_timeline")]
#[doc(alias = "get_timeline")]
2021-04-11 19:38:18 +00:00
fn timeline(&self) -> Option<Timeline> {
2020-11-22 10:12:36 +00:00
unsafe { from_glib_none(ffi::ges_layer_get_timeline(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "ges_layer_is_empty")]
fn is_empty(&self) -> bool {
2020-11-22 10:12:36 +00:00
unsafe { from_glib(ffi::ges_layer_is_empty(self.as_ref().to_glib_none().0)) }
}
#[doc(alias = "ges_layer_remove_clip")]
fn remove_clip(&self, clip: &impl IsA<Clip>) -> Result<(), glib::error::BoolError> {
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
2020-11-22 10:12:36 +00:00
ffi::ges_layer_remove_clip(
self.as_ref().to_glib_none().0,
clip.as_ref().to_glib_none().0
),
"Failed to remove clip"
)
}
}
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "ges_layer_set_active_for_tracks")]
2020-04-30 16:51:41 +00:00
fn set_active_for_tracks(&self, active: bool, tracks: &[Track]) -> bool {
unsafe {
2020-11-22 10:12:36 +00:00
from_glib(ffi::ges_layer_set_active_for_tracks(
2020-04-30 16:51:41 +00:00
self.as_ref().to_glib_none().0,
active.into_glib(),
2020-04-30 16:51:41 +00:00
tracks.to_glib_none().0,
))
}
}
#[doc(alias = "ges_layer_set_auto_transition")]
fn set_auto_transition(&self, auto_transition: bool) {
unsafe {
2020-11-22 10:12:36 +00:00
ffi::ges_layer_set_auto_transition(
self.as_ref().to_glib_none().0,
auto_transition.into_glib(),
);
}
}
#[cfg_attr(feature = "v1_16", deprecated = "Since 1.16")]
#[allow(deprecated)]
#[doc(alias = "ges_layer_set_priority")]
fn set_priority(&self, priority: u32) {
unsafe {
2020-11-22 10:12:36 +00:00
ffi::ges_layer_set_priority(self.as_ref().to_glib_none().0, priority);
}
}
#[doc(alias = "ges_layer_set_timeline")]
fn set_timeline(&self, timeline: &impl IsA<Timeline>) {
unsafe {
2020-11-22 10:12:36 +00:00
ffi::ges_layer_set_timeline(
self.as_ref().to_glib_none().0,
timeline.as_ref().to_glib_none().0,
);
}
}
//#[cfg(feature = "v1_18")]
//#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
//#[doc(alias = "active-changed")]
2020-04-30 16:51:41 +00:00
//fn connect_active_changed<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
// Empty ctype tracks: *.PtrArray TypeId { ns_id: 1, id: 17 }
//}
#[doc(alias = "clip-added")]
fn connect_clip_added<F: Fn(&Self, &Clip) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn clip_added_trampoline<P: IsA<Layer>, F: Fn(&P, &Clip) + 'static>(
2020-11-22 10:12:36 +00:00
this: *mut ffi::GESLayer,
clip: *mut ffi::GESClip,
f: glib::ffi::gpointer,
) {
2019-06-18 10:10:46 +00:00
let f: &F = &*(f as *const F);
f(
2021-06-21 21:07:45 +00:00
Layer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(clip),
)
2019-06-18 10:10:46 +00:00
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"clip-added\0".as_ptr() as *const _,
2020-04-13 16:11:33 +00:00
Some(transmute::<_, unsafe extern "C" fn()>(
clip_added_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "clip-removed")]
fn connect_clip_removed<F: Fn(&Self, &Clip) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn clip_removed_trampoline<P: IsA<Layer>, F: Fn(&P, &Clip) + 'static>(
2020-11-22 10:12:36 +00:00
this: *mut ffi::GESLayer,
clip: *mut ffi::GESClip,
f: glib::ffi::gpointer,
) {
2019-06-18 10:10:46 +00:00
let f: &F = &*(f as *const F);
f(
2021-06-21 21:07:45 +00:00
Layer::from_glib_borrow(this).unsafe_cast_ref(),
&from_glib_borrow(clip),
)
2019-06-18 10:10:46 +00:00
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"clip-removed\0".as_ptr() as *const _,
2020-04-13 16:11:33 +00:00
Some(transmute::<_, unsafe extern "C" fn()>(
clip_removed_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "auto-transition")]
fn connect_auto_transition_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_auto_transition_trampoline<
P: IsA<Layer>,
F: Fn(&P) + 'static,
>(
2020-11-22 10:12:36 +00:00
this: *mut ffi::GESLayer,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
2019-06-18 10:10:46 +00:00
let f: &F = &*(f as *const F);
2021-06-21 21:07:45 +00:00
f(Layer::from_glib_borrow(this).unsafe_cast_ref())
2019-06-18 10:10:46 +00:00
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::auto-transition\0".as_ptr() as *const _,
2020-04-13 16:11:33 +00:00
Some(transmute::<_, unsafe extern "C" fn()>(
notify_auto_transition_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[cfg_attr(feature = "v1_16", deprecated = "Since 1.16")]
#[doc(alias = "priority")]
fn connect_priority_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_priority_trampoline<P: IsA<Layer>, F: Fn(&P) + 'static>(
2020-11-22 10:12:36 +00:00
this: *mut ffi::GESLayer,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
2019-06-18 10:10:46 +00:00
let f: &F = &*(f as *const F);
2021-06-21 21:07:45 +00:00
f(Layer::from_glib_borrow(this).unsafe_cast_ref())
2019-06-18 10:10:46 +00:00
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::priority\0".as_ptr() as *const _,
2020-04-13 16:11:33 +00:00
Some(transmute::<_, unsafe extern "C" fn()>(
notify_priority_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<Layer>> LayerExt for O {}