mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
gstreamer-editing-services: Add bindings for FrameCompositionMeta
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1348>
This commit is contained in:
parent
6371b82c48
commit
9ab8dee59c
9 changed files with 203 additions and 4 deletions
|
@ -18,6 +18,7 @@ external_libraries = [
|
|||
]
|
||||
|
||||
manual = [
|
||||
"GES.FrameCompositionMeta",
|
||||
"Gio.AsyncReadyCallback",
|
||||
"Gio.Cancellable",
|
||||
"GLib.Date",
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d)
|
||||
Generated by gir (https://github.com/gtk-rs/gir @ 22c3351f8d7f)
|
||||
from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40)
|
||||
from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ edec6c70b41a)
|
||||
from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ 62054dc7234d)
|
||||
|
|
141
gstreamer-editing-services/src/composition_meta.rs
Normal file
141
gstreamer-editing-services/src/composition_meta.rs
Normal file
|
@ -0,0 +1,141 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use glib::translate::from_glib;
|
||||
use gst::prelude::*;
|
||||
|
||||
#[repr(transparent)]
|
||||
#[doc(alias = "GESFrameCompositionMeta")]
|
||||
pub struct FrameCompositionMeta(ffi::GESFrameCompositionMeta);
|
||||
|
||||
unsafe impl Send for FrameCompositionMeta {}
|
||||
|
||||
unsafe impl Sync for FrameCompositionMeta {}
|
||||
|
||||
impl FrameCompositionMeta {
|
||||
#[inline]
|
||||
pub fn alpha(&self) -> f64 {
|
||||
self.0.alpha
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn position(&self) -> (i32, i32) {
|
||||
(self.0.posx, self.0.posy)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn pos_x(&self) -> i32 {
|
||||
self.0.posx
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn pos_y(&self) -> i32 {
|
||||
self.0.posy
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn size(&self) -> (i32, i32) {
|
||||
(self.0.width, self.0.height)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn width(&self) -> i32 {
|
||||
self.0.width
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn height(&self) -> i32 {
|
||||
self.0.height
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn zorder(&self) -> u32 {
|
||||
self.0.zorder
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn operator(&self) -> i32 {
|
||||
self.0.operator
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl MetaAPI for FrameCompositionMeta {
|
||||
type GstType = ffi::GESFrameCompositionMeta;
|
||||
|
||||
#[doc(alias = "ges_frame_composition_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::ges_frame_composition_meta_api_get_type()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for FrameCompositionMeta {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("FrameCompositionMeta")
|
||||
.field("pos-x", &self.pos_x())
|
||||
.field("pos-y", &self.pos_y())
|
||||
.field("width", &self.width())
|
||||
.field("height", &self.height())
|
||||
.field("zorder", &self.zorder())
|
||||
.field("alpha", &self.alpha())
|
||||
.field("operator", &self.operator())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn add_composition_meta(
|
||||
buffer: &mut gst::BufferRef,
|
||||
position: (i32, i32),
|
||||
size: (i32, i32),
|
||||
alpha: f64,
|
||||
zorder: u32,
|
||||
operator: i32,
|
||||
) -> Result<gst::MetaRefMut<FrameCompositionMeta, gst::meta::Standalone>, glib::BoolError> {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe {
|
||||
let meta = ffi::ges_buffer_add_frame_composition_meta(buffer.as_mut_ptr());
|
||||
|
||||
if meta.is_null() {
|
||||
return Err(glib::bool_error!("Failed to add frame composition meta"));
|
||||
}
|
||||
|
||||
let mut result = FrameCompositionMeta::from_mut_ptr(buffer, meta);
|
||||
result.0.posx = position.0;
|
||||
result.0.posy = position.1;
|
||||
result.0.width = size.0;
|
||||
result.0.height = size.1;
|
||||
result.0.alpha = alpha;
|
||||
result.0.zorder = zorder;
|
||||
result.0.operator = operator;
|
||||
Ok(result)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_add_get_meta() {
|
||||
gst::init().unwrap();
|
||||
crate::init().unwrap();
|
||||
|
||||
let mut buffer = gst::Buffer::with_size(320 * 240 * 4).unwrap();
|
||||
{
|
||||
let _meta =
|
||||
add_composition_meta(buffer.get_mut().unwrap(), (42, 42), (20, 22), 0.42, 2, 42)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
{
|
||||
let meta = buffer.meta::<FrameCompositionMeta>().unwrap();
|
||||
assert_eq!(meta.position(), (42, 42));
|
||||
assert_eq!(meta.size(), (20, 22));
|
||||
assert_eq!(meta.alpha(), 0.42);
|
||||
assert_eq!(meta.zorder(), 2);
|
||||
assert_eq!(meta.operator(), 42);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,6 +56,9 @@ macro_rules! skip_assert_initialized {
|
|||
mod auto;
|
||||
mod formatter;
|
||||
pub use crate::auto::*;
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
mod composition_meta;
|
||||
pub mod subclass;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
|
@ -74,5 +77,8 @@ pub mod prelude {
|
|||
pub use gst_pbutils::prelude::*;
|
||||
|
||||
pub use crate::auto::traits::*;
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
pub use crate::composition_meta::FrameCompositionMeta;
|
||||
pub use crate::formatter::FormatterExtManual;
|
||||
}
|
||||
|
|
|
@ -30,3 +30,10 @@ ignore = [
|
|||
[external_libraries]
|
||||
gstreamer="Gst"
|
||||
gstreamer_pbutils="GstPbutils"
|
||||
|
||||
[[object]]
|
||||
name = "GES.*"
|
||||
status = "generate"
|
||||
[[object.function]]
|
||||
name = "frame_composition_meta_api_get_type"
|
||||
version = "1.24"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
Generated by gir (https://github.com/gtk-rs/gir @ c0970367709d)
|
||||
Generated by gir (https://github.com/gtk-rs/gir @ 22c3351f8d7f)
|
||||
from gir-files (https://github.com/gtk-rs/gir-files @ 20031a537e40)
|
||||
from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ edec6c70b41a)
|
||||
from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ 62054dc7234d)
|
||||
|
|
|
@ -868,6 +868,34 @@ pub struct _GESFormatterPrivate {
|
|||
|
||||
pub type GESFormatterPrivate = *mut _GESFormatterPrivate;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct GESFrameCompositionMeta {
|
||||
pub meta: gst::GstMeta,
|
||||
pub alpha: c_double,
|
||||
pub posx: c_int,
|
||||
pub posy: c_int,
|
||||
pub height: c_int,
|
||||
pub width: c_int,
|
||||
pub zorder: c_uint,
|
||||
pub operator: c_int,
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for GESFrameCompositionMeta {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
f.debug_struct(&format!("GESFrameCompositionMeta @ {self:p}"))
|
||||
.field("meta", &self.meta)
|
||||
.field("alpha", &self.alpha)
|
||||
.field("posx", &self.posx)
|
||||
.field("posy", &self.posy)
|
||||
.field("height", &self.height)
|
||||
.field("width", &self.width)
|
||||
.field("zorder", &self.zorder)
|
||||
.field("operator", &self.operator)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct GESGroupClass {
|
||||
|
@ -4395,10 +4423,18 @@ extern "C" {
|
|||
// Other functions
|
||||
//=========================================================================
|
||||
pub fn ges_add_missing_uri_relocation_uri(uri: *const c_char, recurse: gboolean) -> gboolean;
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
pub fn ges_buffer_add_frame_composition_meta(
|
||||
buffer: *mut gst::GstBuffer,
|
||||
) -> *mut GESFrameCompositionMeta;
|
||||
pub fn ges_deinit();
|
||||
#[cfg(feature = "v1_18")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
|
||||
pub fn ges_find_formatter_for_uri(uri: *const c_char) -> *mut GESAsset;
|
||||
#[cfg(feature = "v1_24")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
|
||||
pub fn ges_frame_composition_meta_api_get_type() -> GType;
|
||||
pub fn ges_init() -> gboolean;
|
||||
pub fn ges_init_check(
|
||||
argc: *mut c_int,
|
||||
|
|
|
@ -503,6 +503,13 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &[
|
|||
alignment: align_of::<GESFormatterClass>(),
|
||||
},
|
||||
),
|
||||
(
|
||||
"GESFrameCompositionMeta",
|
||||
Layout {
|
||||
size: size_of::<GESFrameCompositionMeta>(),
|
||||
alignment: align_of::<GESFrameCompositionMeta>(),
|
||||
},
|
||||
),
|
||||
(
|
||||
"GESFrameNumber",
|
||||
Layout {
|
||||
|
|
|
@ -51,6 +51,7 @@ int main() {
|
|||
printf("%s;%zu;%zu\n", "GESExtractableInterface", sizeof(GESExtractableInterface), alignof(GESExtractableInterface));
|
||||
printf("%s;%zu;%zu\n", "GESFormatter", sizeof(GESFormatter), alignof(GESFormatter));
|
||||
printf("%s;%zu;%zu\n", "GESFormatterClass", sizeof(GESFormatterClass), alignof(GESFormatterClass));
|
||||
printf("%s;%zu;%zu\n", "GESFrameCompositionMeta", sizeof(GESFrameCompositionMeta), alignof(GESFrameCompositionMeta));
|
||||
printf("%s;%zu;%zu\n", "GESFrameNumber", sizeof(GESFrameNumber), alignof(GESFrameNumber));
|
||||
printf("%s;%zu;%zu\n", "GESGroup", sizeof(GESGroup), alignof(GESGroup));
|
||||
printf("%s;%zu;%zu\n", "GESGroupClass", sizeof(GESGroupClass), alignof(GESGroupClass));
|
||||
|
|
Loading…
Reference in a new issue