gstreamer-gl: generate constants and functions

This commit is contained in:
Jordan Petridis 2022-01-06 20:38:46 +02:00
parent 9eb479cf78
commit 07f2c46e0e
8 changed files with 467 additions and 21 deletions

View file

@ -82,6 +82,128 @@ name = "Gst.Structure"
status = "manual"
ref_mode = "ref"
[[object]]
name = "GstGL.*"
status = "generate"
[[object.function]]
name = "buffer_add_gl_sync_meta"
manual = true
[[object.function]]
name = "buffer_add_gl_sync_meta_full"
manual = true
[[object.function]]
name = "context_get_gl_display"
manual = true
[[object.function]]
name = "context_set_gl_display"
manual = true
[[object.function]]
name = "gl_sync_meta_api_get_type"
manual = true
[[object.function]]
name = "gl_handle_context_query"
manual = true
[[object.function]]
name = "gl_handle_set_context"
manual = true
# gir has issues with the inout annotation
[[object.function]]
name = "gl_ensure_element_data"
ignore = true
# These need manual bindings
[[object.function]]
name = "buffer_pool_config_get_gl_allocation_params"
ignore = true
[[object.function]]
name = "buffer_pool_config_set_gl_allocation_params"
ignore = true
# Needs manual binding to be an extension on gst_video::VideoAffineTransformationMeta
[[object.function]]
name = "gl_get_affine_transformation_meta_as_ndc"
ignore = true
[[object.function]]
name = "gl_set_affine_transformation_meta_from_ndc"
ignore = true
# Needs manual binding to be an extension on gst_video::VideoInfo
[[object.function]]
name = "gl_get_plane_data_size"
ignore = true
[[object.function]]
name = "gl_get_plane_start"
ignore = true
# Needs manual binding
[[object.function]]
name = "gl_insert_debug_marker"
ignore = true
# Needs manual binding around `[[f32;4];4]`
[[object.function]]
name = "gl_multiply_matrix4"
ignore = true
# Should be a method on GLContextExtManual
[[object.function]]
name = "gl_sized_gl_format_from_gl_format_type"
ignore = true
# Should be method on GLTextureTarget and/or Value
[[object.function]]
name = "gl_value_get_texture_target_mask"
ignore = true
# This needs to return a value
# target_mask is a bitwise mask of the GLTextureTarget enum
[[object.function]]
name = "gl_value_set_texture_target_from_mask"
ignore = true
# This needs more checks like target != GLTextureTarget::None
# and a value that's already initialized as a string.
# Could become GLTextureTarget::to_value() maybe.
[[object.function]]
name = "gl_value_set_texture_target"
ignore = true
# Should be a method/constructor on GLSLVersion
[[object.function]]
name = "gl_version_to_glsl_version"
ignore = true
# ffi constant is ignored
[[object.constant]]
name = "GL_COLOR_CONVERT_FORMATS"
ignore = true
[[object.constant]]
name = "GL_MEMORY_VIDEO_FORMATS_STR"
ignore = true
# the below need manual bindings
[[object.function]]
name = "is_gl_base_memory"
ignore = true
[[object.function]]
name = "is_gl_buffer"
ignore = true
[[object.function]]
name = "is_gl_memory"
ignore = true
[[object.function]]
name = "is_gl_memory_pbo"
ignore = true
[[object.function]]
name = "is_gl_renderbuffer"
ignore = true
# duplicate of gst_gl_stereo_downmix_get_type
[[object.function]]
name = "gl_stereo_downmix_mode_get_type"
ignore = true
[[object]]
name = "GstGL.GLAllocationParams"
status = "generate"

View file

@ -0,0 +1,201 @@
// 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 std::ffi::CStr;
#[doc(alias = "GST_BUFFER_POOL_OPTION_GL_SYNC_META")]
pub static BUFFER_POOL_OPTION_GL_SYNC_META: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_BUFFER_POOL_OPTION_GL_SYNC_META)
.to_str()
.unwrap()
});
#[doc(alias = "GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D")]
pub static BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D)
.to_str()
.unwrap()
});
#[doc(alias = "GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_EXTERNAL_OES")]
pub static BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_EXTERNAL_OES: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_EXTERNAL_OES)
.to_str()
.unwrap()
});
#[doc(alias = "GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE")]
pub static BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE)
.to_str()
.unwrap()
});
#[doc(alias = "GST_CAPS_FEATURE_MEMORY_GL_BUFFER")]
pub static CAPS_FEATURE_MEMORY_GL_BUFFER: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_CAPS_FEATURE_MEMORY_GL_BUFFER)
.to_str()
.unwrap()
});
#[doc(alias = "GST_CAPS_FEATURE_MEMORY_GL_MEMORY")]
pub static CAPS_FEATURE_MEMORY_GL_MEMORY: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_API_GLES1_NAME")]
pub static GL_API_GLES1_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_API_GLES1_NAME).to_str().unwrap()
});
#[doc(alias = "GST_GL_API_GLES2_NAME")]
pub static GL_API_GLES2_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_API_GLES2_NAME).to_str().unwrap()
});
#[doc(alias = "GST_GL_API_OPENGL3_NAME")]
pub static GL_API_OPENGL3_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_API_OPENGL3_NAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_API_OPENGL_NAME")]
pub static GL_API_OPENGL_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_API_OPENGL_NAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_BASE_MEMORY_ALLOCATOR_NAME")]
pub static GL_BASE_MEMORY_ALLOCATOR_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_BASE_MEMORY_ALLOCATOR_NAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_BUFFER_ALLOCATOR_NAME")]
pub static GL_BUFFER_ALLOCATOR_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_BUFFER_ALLOCATOR_NAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_COLOR_CONVERT_EXT_FORMATS")]
pub static GL_COLOR_CONVERT_EXT_FORMATS: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_COLOR_CONVERT_EXT_FORMATS)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_COLOR_CONVERT_VIDEO_CAPS")]
pub static GL_COLOR_CONVERT_VIDEO_CAPS: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_COLOR_CONVERT_VIDEO_CAPS)
.to_str()
.unwrap()
});
#[cfg(any(feature = "v1_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
#[doc(alias = "GST_GL_CONFIG_STRUCTURE_NAME")]
pub static GL_CONFIG_STRUCTURE_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_CONFIG_STRUCTURE_NAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_CONTEXT_TYPE_CGL")]
pub static GL_CONTEXT_TYPE_CGL: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_CONTEXT_TYPE_CGL)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_CONTEXT_TYPE_EAGL")]
pub static GL_CONTEXT_TYPE_EAGL: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_CONTEXT_TYPE_EAGL)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_CONTEXT_TYPE_EGL")]
pub static GL_CONTEXT_TYPE_EGL: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_CONTEXT_TYPE_EGL)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_CONTEXT_TYPE_GLX")]
pub static GL_CONTEXT_TYPE_GLX: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_CONTEXT_TYPE_GLX)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_CONTEXT_TYPE_WGL")]
pub static GL_CONTEXT_TYPE_WGL: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_CONTEXT_TYPE_WGL)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_DISPLAY_CONTEXT_TYPE")]
pub static GL_DISPLAY_CONTEXT_TYPE: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_DISPLAY_CONTEXT_TYPE)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_MEMORY_ALLOCATOR_NAME")]
pub static GL_MEMORY_ALLOCATOR_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_MEMORY_ALLOCATOR_NAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_MEMORY_PBO_ALLOCATOR_NAME")]
pub static GL_MEMORY_PBO_ALLOCATOR_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_MEMORY_PBO_ALLOCATOR_NAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_MEMORY_VIDEO_EXT_FORMATS")]
pub static GL_MEMORY_VIDEO_EXT_FORMATS: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_MEMORY_VIDEO_EXT_FORMATS)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_RENDERBUFFER_ALLOCATOR_NAME")]
pub static GL_RENDERBUFFER_ALLOCATOR_NAME: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_RENDERBUFFER_ALLOCATOR_NAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_TEXTURE_TARGET_2D_STR")]
pub static GL_TEXTURE_TARGET_2D_STR: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_TEXTURE_TARGET_2D_STR)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR")]
pub static GL_TEXTURE_TARGET_EXTERNAL_OES_STR: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_TEXTURE_TARGET_EXTERNAL_OES_STR)
.to_str()
.unwrap()
});
#[doc(alias = "GST_GL_TEXTURE_TARGET_RECTANGLE_STR")]
pub static GL_TEXTURE_TARGET_RECTANGLE_STR: once_cell::sync::Lazy<&'static str> =
once_cell::sync::Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_TEXTURE_TARGET_RECTANGLE_STR)
.to_str()
.unwrap()
});

View file

@ -0,0 +1,57 @@
// 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::GLDisplay;
use crate::GLSLProfile;
use crate::GLSLVersion;
use glib::object::IsA;
use glib::translate::*;
use std::mem;
#[doc(alias = "gst_gl_check_extension")]
pub fn gl_check_extension(name: &str, ext: &str) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::gst_gl_check_extension(
name.to_glib_none().0,
ext.to_glib_none().0,
))
}
}
#[doc(alias = "gst_gl_element_propagate_display_context")]
pub fn gl_element_propagate_display_context(
element: &impl IsA<gst::Element>,
display: &impl IsA<GLDisplay>,
) {
skip_assert_initialized!();
unsafe {
ffi::gst_gl_element_propagate_display_context(
element.as_ref().to_glib_none().0,
display.as_ref().to_glib_none().0,
);
}
}
#[doc(alias = "gst_glsl_string_get_version_profile")]
pub fn glsl_string_get_version_profile(s: &str) -> Option<(GLSLVersion, GLSLProfile)> {
assert_initialized_main_thread!();
unsafe {
let mut version = mem::MaybeUninit::uninit();
let mut profile = mem::MaybeUninit::uninit();
let ret = from_glib(ffi::gst_glsl_string_get_version_profile(
s.to_glib_none().0,
version.as_mut_ptr(),
profile.as_mut_ptr(),
));
let version = version.assume_init();
let profile = profile.assume_init();
if ret {
Some((from_glib(version), from_glib(profile)))
} else {
None
}
}
}

View file

@ -84,6 +84,40 @@ pub use self::flags::GLPlatform;
pub use self::flags::GLSLProfile;
pub use self::flags::GLAPI;
pub mod functions;
mod constants;
pub use self::constants::BUFFER_POOL_OPTION_GL_SYNC_META;
pub use self::constants::BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_2D;
pub use self::constants::BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_EXTERNAL_OES;
pub use self::constants::BUFFER_POOL_OPTION_GL_TEXTURE_TARGET_RECTANGLE;
pub use self::constants::CAPS_FEATURE_MEMORY_GL_BUFFER;
pub use self::constants::CAPS_FEATURE_MEMORY_GL_MEMORY;
pub use self::constants::GL_API_GLES1_NAME;
pub use self::constants::GL_API_GLES2_NAME;
pub use self::constants::GL_API_OPENGL3_NAME;
pub use self::constants::GL_API_OPENGL_NAME;
pub use self::constants::GL_BASE_MEMORY_ALLOCATOR_NAME;
pub use self::constants::GL_BUFFER_ALLOCATOR_NAME;
pub use self::constants::GL_COLOR_CONVERT_EXT_FORMATS;
pub use self::constants::GL_COLOR_CONVERT_VIDEO_CAPS;
#[cfg(any(feature = "v1_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
pub use self::constants::GL_CONFIG_STRUCTURE_NAME;
pub use self::constants::GL_CONTEXT_TYPE_CGL;
pub use self::constants::GL_CONTEXT_TYPE_EAGL;
pub use self::constants::GL_CONTEXT_TYPE_EGL;
pub use self::constants::GL_CONTEXT_TYPE_GLX;
pub use self::constants::GL_CONTEXT_TYPE_WGL;
pub use self::constants::GL_DISPLAY_CONTEXT_TYPE;
pub use self::constants::GL_MEMORY_ALLOCATOR_NAME;
pub use self::constants::GL_MEMORY_PBO_ALLOCATOR_NAME;
pub use self::constants::GL_MEMORY_VIDEO_EXT_FORMATS;
pub use self::constants::GL_RENDERBUFFER_ALLOCATOR_NAME;
pub use self::constants::GL_TEXTURE_TARGET_2D_STR;
pub use self::constants::GL_TEXTURE_TARGET_EXTERNAL_OES_STR;
pub use self::constants::GL_TEXTURE_TARGET_RECTANGLE_STR;
#[doc(hidden)]
pub mod traits {
pub use super::gl_base_filter::GLBaseFilterExt;

View file

@ -1,14 +1,8 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use gst::CapsFeatures;
use std::ffi::CStr;
use once_cell::sync::Lazy;
pub static CAPS_FEATURE_MEMORY_GL_MEMORY: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_CAPS_FEATURE_MEMORY_GL_MEMORY)
.to_str()
.unwrap()
});
pub static CAPS_FEATURES_MEMORY_GL_MEMORY: Lazy<CapsFeatures> =
Lazy::new(|| CapsFeatures::new(&[*CAPS_FEATURE_MEMORY_GL_MEMORY]));
Lazy::new(|| CapsFeatures::new(&[*crate::CAPS_FEATURE_MEMORY_GL_MEMORY]));

View file

@ -0,0 +1,48 @@
use crate::GLContext;
use crate::GLDisplay;
use glib::object::IsA;
use glib::translate::*;
use std::ptr;
#[doc(alias = "gst_gl_handle_context_query")]
pub fn gl_handle_context_query(
element: &impl IsA<gst::Element>,
query: gst::query::Context<&mut gst::QueryRef>,
display: Option<&impl IsA<GLDisplay>>,
context: Option<&impl IsA<GLContext>>,
other_context: Option<&impl IsA<GLContext>>,
) -> bool {
assert_initialized_main_thread!();
unsafe {
from_glib(ffi::gst_gl_handle_context_query(
element.as_ref().to_glib_none().0,
query.as_mut_ptr(),
display.map(|p| p.as_ref()).to_glib_none().0,
context.map(|p| p.as_ref()).to_glib_none().0,
other_context.map(|p| p.as_ref()).to_glib_none().0,
))
}
}
#[doc(alias = "gst_gl_handle_set_context")]
pub fn gl_handle_set_context(
element: &impl IsA<gst::Element>,
context: &gst::Context,
) -> (Option<GLDisplay>, Option<GLContext>) {
assert_initialized_main_thread!();
unsafe {
let mut display = ptr::null_mut();
let mut other_context = ptr::null_mut();
let ret = from_glib(ffi::gst_gl_handle_set_context(
element.as_ref().to_glib_none().0,
context.to_glib_none().0,
&mut display,
&mut other_context,
));
if ret {
(from_glib_full(display), from_glib_full(other_context))
} else {
(None, None)
}
}
}

View file

@ -1,11 +0,0 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use std::ffi::CStr;
use once_cell::sync::Lazy;
pub static GL_DISPLAY_CONTEXT_TYPE: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_GL_DISPLAY_CONTEXT_TYPE)
.to_str()
.unwrap()
});

View file

@ -28,14 +28,15 @@ macro_rules! skip_assert_initialized {
#[allow(clippy::use_self)]
#[allow(unused_imports)]
mod auto;
pub use crate::auto::functions::*;
pub use crate::auto::*;
mod caps_features;
pub use crate::caps_features::{CAPS_FEATURES_MEMORY_GL_MEMORY, CAPS_FEATURE_MEMORY_GL_MEMORY};
pub use crate::caps_features::CAPS_FEATURES_MEMORY_GL_MEMORY;
mod context;
pub mod functions;
pub use crate::functions::*;
mod gl_context;
mod gl_display;
pub use crate::gl_display::GL_DISPLAY_CONTEXT_TYPE;
mod gl_sync_meta;
mod gl_video_frame;
pub use crate::gl_sync_meta::*;