From 01f0988a48c60af99109aa2651979149d094d608 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Fri, 28 Aug 2020 13:22:10 +0200 Subject: [PATCH] gl/gir: Configure generation for GLFilter with miniobject quirks GLMemory input/output objects cannot be passed as mutable: to_glib_none_mut checks if the miniobject is writable, even though the underlying implementation should really only care about whether the _data_ owned by this miniobject is. (This temporary GLMemory object references its parent buffer object that is also referenced externally, resulting in two references making the object itself immutable) Furthermore take care of automatically calling `add_rgba_pad_templates` in `class_init` if `ADD_RGBA_PAD_TEMPLATES` is set to `true` (the default). --- gstreamer-gl/Gir.toml | 26 ++++++++++++++++++++++++++ gstreamer-gl/src/lib.rs | 2 ++ gstreamer-gl/src/subclass/gl_filter.rs | 8 ++++++++ 3 files changed, 36 insertions(+) diff --git a/gstreamer-gl/Gir.toml b/gstreamer-gl/Gir.toml index 23341f286..f171caa48 100644 --- a/gstreamer-gl/Gir.toml +++ b/gstreamer-gl/Gir.toml @@ -507,3 +507,29 @@ status = "generate" name = "attach" # attachment_point parameter unchecked unsafe = true + +[[object]] +name = "GstGL.GLFilter" +status = "generate" + + [[object.function]] + name = "add_rgba_pad_templates" + # Automatically called if + # GLFilterImpl::ADD_RGBA_PAD_TEMPLATES is true + ignore = true + + [[object.function]] + pattern = "render_to_target\\w*" + [[object.function.parameter]] + pattern = "input|output" + const = true + + [[object.function]] + name = "render_to_target" + [object.function.return] + bool_return_is_error = "`func` returned `false`" + + [[object.function]] + name = "filter_texture" + [object.function.return] + bool_return_is_error = "Failed to transform texture" diff --git a/gstreamer-gl/src/lib.rs b/gstreamer-gl/src/lib.rs index ee6c6243d..2b271e797 100644 --- a/gstreamer-gl/src/lib.rs +++ b/gstreamer-gl/src/lib.rs @@ -58,3 +58,5 @@ pub mod prelude { pub use crate::gl_context::GLContextExtManual; pub use crate::gl_video_frame::VideoFrameGLExt; } + +pub mod subclass; diff --git a/gstreamer-gl/src/subclass/gl_filter.rs b/gstreamer-gl/src/subclass/gl_filter.rs index 58a6ee98f..20e55c4ac 100644 --- a/gstreamer-gl/src/subclass/gl_filter.rs +++ b/gstreamer-gl/src/subclass/gl_filter.rs @@ -21,6 +21,10 @@ pub enum GLFilterMode { pub trait GLFilterImpl: GLFilterImplExt + GLBaseFilterImpl { const MODE: GLFilterMode; + // rustdoc-stripper-ignore-next + /// Calls [`add_rgba_pad_templates`](ffi::gst_gl_filter_add_rgba_pad_templates) + /// in [`GLFilter::class_init`] if [`true`]. + const ADD_RGBA_PAD_TEMPLATES: bool = true; fn set_caps( &self, @@ -239,6 +243,10 @@ unsafe impl IsSubclassable for GLFilter { klass.filter_texture = Some(filter_texture::); } } + + if ::ADD_RGBA_PAD_TEMPLATES { + unsafe { ffi::gst_gl_filter_add_rgba_pad_templates(klass) } + } } fn instance_init(instance: &mut glib::subclass::InitializingObject) {