mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-18 05:16:05 +00:00
gl: move control binding proxy implementation from glvideomixer
Other elements may need to use it's functionality
This commit is contained in:
parent
e3f53deb32
commit
2cef90184e
5 changed files with 248 additions and 168 deletions
|
@ -137,151 +137,6 @@ gst_gl_video_mixer_blend_function_get_type (void)
|
|||
return mixer_blend_function_type;
|
||||
}
|
||||
|
||||
typedef struct _GstGLMixerControlBindingProxy GstGLMixerControlBindingProxy;
|
||||
typedef struct _GstGLMixerControlBindingProxyClass
|
||||
GstGLMixerControlBindingProxyClass;
|
||||
|
||||
struct _GstGLMixerControlBindingProxy
|
||||
{
|
||||
GstControlBinding parent;
|
||||
|
||||
GstObject *ref_object;
|
||||
const gchar *property_name;
|
||||
};
|
||||
|
||||
struct _GstGLMixerControlBindingProxyClass
|
||||
{
|
||||
GstControlBindingClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_gl_mixer_control_binding_proxy_get_type (void);
|
||||
#define GST_TYPE_GL_MIXER_CONTROL_BINDING \
|
||||
(gst_gl_mixer_control_binding_proxy_get_type())
|
||||
|
||||
G_DEFINE_TYPE (GstGLMixerControlBindingProxy,
|
||||
gst_gl_mixer_control_binding_proxy, GST_TYPE_CONTROL_BINDING);
|
||||
|
||||
static void
|
||||
gst_gl_mixer_control_binding_proxy_init (GstGLMixerControlBindingProxy * self)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_mixer_control_binding_proxy_sync_values (GstControlBinding * binding,
|
||||
GstObject * object, GstClockTime timestamp, GstClockTime last_sync)
|
||||
{
|
||||
GstGLMixerControlBindingProxy *self = (GstGLMixerControlBindingProxy *)
|
||||
binding;
|
||||
GstControlBinding *ref_binding;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
ref_binding = gst_object_get_control_binding (self->ref_object,
|
||||
self->property_name);
|
||||
|
||||
if (ref_binding) {
|
||||
ret = gst_control_binding_sync_values (ref_binding, self->ref_object,
|
||||
timestamp, last_sync);
|
||||
gst_object_unref (ref_binding);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
gst_gl_mixer_control_binding_proxy_get_value (GstControlBinding * binding,
|
||||
GstClockTime timestamp)
|
||||
{
|
||||
GstGLMixerControlBindingProxy *self = (GstGLMixerControlBindingProxy *)
|
||||
binding;
|
||||
GstControlBinding *ref_binding;
|
||||
GValue *ret = NULL;
|
||||
|
||||
ref_binding = gst_object_get_control_binding (self->ref_object,
|
||||
self->property_name);
|
||||
|
||||
if (ref_binding) {
|
||||
ret = gst_control_binding_get_value (ref_binding, timestamp);
|
||||
gst_object_unref (ref_binding);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_mixer_control_binding_proxy_get_value_array (GstControlBinding * binding,
|
||||
GstClockTime timestamp, GstClockTime interval, guint n_values,
|
||||
gpointer values)
|
||||
{
|
||||
GstGLMixerControlBindingProxy *self = (GstGLMixerControlBindingProxy *)
|
||||
binding;
|
||||
GstControlBinding *ref_binding;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
ref_binding = gst_object_get_control_binding (self->ref_object,
|
||||
self->property_name);
|
||||
|
||||
if (ref_binding) {
|
||||
ret = gst_control_binding_get_value_array (ref_binding, timestamp,
|
||||
interval, n_values, values);
|
||||
gst_object_unref (ref_binding);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_mixer_control_binding_proxy_get_g_value_array (GstControlBinding *
|
||||
binding, GstClockTime timestamp, GstClockTime interval, guint n_values,
|
||||
GValue * values)
|
||||
{
|
||||
GstGLMixerControlBindingProxy *self = (GstGLMixerControlBindingProxy *)
|
||||
binding;
|
||||
GstControlBinding *ref_binding;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
ref_binding = gst_object_get_control_binding (self->ref_object,
|
||||
self->property_name);
|
||||
|
||||
if (ref_binding) {
|
||||
ret = gst_control_binding_get_g_value_array (ref_binding, timestamp,
|
||||
interval, n_values, values);
|
||||
gst_object_unref (ref_binding);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gst_gl_mixer_control_binding_proxy_class_init
|
||||
(GstGLMixerControlBindingProxyClass * klass)
|
||||
{
|
||||
GstControlBindingClass *cb_class = GST_CONTROL_BINDING_CLASS (klass);
|
||||
|
||||
cb_class->sync_values = gst_gl_mixer_control_binding_proxy_sync_values;
|
||||
cb_class->get_value = gst_gl_mixer_control_binding_proxy_get_value;
|
||||
cb_class->get_value_array =
|
||||
gst_gl_mixer_control_binding_proxy_get_value_array;
|
||||
cb_class->get_g_value_array =
|
||||
gst_gl_mixer_control_binding_proxy_get_g_value_array;
|
||||
}
|
||||
|
||||
static GstControlBinding *
|
||||
gst_gl_mixer_control_binding_proxy_new (GstObject * object,
|
||||
const gchar * property_name, GstObject * ref_object,
|
||||
const gchar * ref_property_name)
|
||||
{
|
||||
GstGLMixerControlBindingProxy *self =
|
||||
g_object_new (GST_TYPE_GL_MIXER_CONTROL_BINDING, "object", object,
|
||||
"name", property_name, NULL);
|
||||
|
||||
self->ref_object = ref_object;
|
||||
self->property_name = ref_property_name;
|
||||
|
||||
return (GstControlBinding *) self;
|
||||
}
|
||||
|
||||
|
||||
#define DEFAULT_PAD_XPOS 0
|
||||
#define DEFAULT_PAD_YPOS 0
|
||||
#define DEFAULT_PAD_WIDTH 0
|
||||
|
@ -475,35 +330,44 @@ _create_video_mixer_input (GstGLMixerBin * self, GstPad * mixer_pad)
|
|||
g_object_new (gst_gl_video_mixer_input_get_type (), "name",
|
||||
GST_OBJECT_NAME (mixer_pad), "direction", GST_PAD_DIRECTION (mixer_pad),
|
||||
NULL);
|
||||
GstControlBinding *cb;
|
||||
|
||||
if (!gst_ghost_pad_construct (GST_GHOST_PAD (input))) {
|
||||
gst_object_unref (input);
|
||||
return NULL;
|
||||
}
|
||||
#define ADD_PROXY_CONTROL_BINDING(prop) \
|
||||
cb = gst_gl_mixer_control_binding_proxy_new (GST_OBJECT (mixer_pad), \
|
||||
prop, GST_OBJECT (input), prop); \
|
||||
gst_object_add_control_binding (GST_OBJECT (mixer_pad), cb)
|
||||
|
||||
ADD_PROXY_CONTROL_BINDING ("zorder");
|
||||
ADD_PROXY_CONTROL_BINDING ("xpos");
|
||||
ADD_PROXY_CONTROL_BINDING ("ypos");
|
||||
ADD_PROXY_CONTROL_BINDING ("width");
|
||||
ADD_PROXY_CONTROL_BINDING ("height");
|
||||
ADD_PROXY_CONTROL_BINDING ("alpha");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-equation-rgb");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-equation-alpha");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-function-src-rgb");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-function-src-alpha");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-function-dst-rgb");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-function-dst-alpha");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-constant-color-red");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-constant-color-green");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-constant-color-blue");
|
||||
ADD_PROXY_CONTROL_BINDING ("blend-constant-color-alpha");
|
||||
|
||||
#undef ADD_PROXY_CONTROL_BINDING
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "zorder");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "xpos");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "ypos");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "width");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "height");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "alpha");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-equation-rgb");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-equation-alpha");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-function-src-rgb");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-function-src-alpha");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-function-dst-rgb");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-function-dst-alpha");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-constant-color-red");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-constant-color-green");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-constant-color-blue");
|
||||
gst_gl_object_add_control_binding_proxy (GST_OBJECT (mixer_pad),
|
||||
GST_OBJECT (input), "blend-constant-color-alpha");
|
||||
|
||||
input->mixer_pad = mixer_pad;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ libgstgl_@GST_API_VERSION@_la_SOURCES = \
|
|||
gstglviewconvert.c \
|
||||
gstgloverlaycompositor.c \
|
||||
gstglquery.c \
|
||||
gstglcontrolbindingproxy.c \
|
||||
gstglsl_private.h \
|
||||
utils/opengl_versions.h
|
||||
|
||||
|
@ -66,6 +67,7 @@ libgstgl_@GST_API_VERSION@include_HEADERS = \
|
|||
gstglviewconvert.h \
|
||||
gstgloverlaycompositor.h \
|
||||
gstglquery.h \
|
||||
gstglcontrolbindingproxy.h \
|
||||
gstgl_fwd.h \
|
||||
gstgl_enums.h \
|
||||
gl.h
|
||||
|
|
|
@ -53,5 +53,6 @@
|
|||
#include <gst/gl/gstglsyncmeta.h>
|
||||
#include <gst/gl/gstgloverlaycompositor.h>
|
||||
#include <gst/gl/gstglquery.h>
|
||||
#include <gst/gl/gstglcontrolbindingproxy.h>
|
||||
|
||||
#endif /* __GST_GL_H__ */
|
||||
|
|
155
gst-libs/gst/gl/gstglcontrolbindingproxy.c
Normal file
155
gst-libs/gst/gl/gstglcontrolbindingproxy.c
Normal file
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2016 Matthew Waters <matthew@centricular.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstglcontrolbindingproxy.h"
|
||||
|
||||
G_DEFINE_TYPE (GstGLControlBindingProxy,
|
||||
gst_gl_control_binding_proxy, GST_TYPE_CONTROL_BINDING);
|
||||
|
||||
static void
|
||||
gst_gl_control_binding_proxy_init (GstGLControlBindingProxy * self)
|
||||
{
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_control_binding_proxy_sync_values (GstControlBinding * binding,
|
||||
GstObject * object, GstClockTime timestamp, GstClockTime last_sync)
|
||||
{
|
||||
GstGLControlBindingProxy *self = (GstGLControlBindingProxy *)
|
||||
binding;
|
||||
GstControlBinding *ref_binding;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
ref_binding = gst_object_get_control_binding (self->ref_object,
|
||||
self->property_name);
|
||||
|
||||
if (ref_binding) {
|
||||
ret = gst_control_binding_sync_values (ref_binding, self->ref_object,
|
||||
timestamp, last_sync);
|
||||
gst_object_unref (ref_binding);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
gst_gl_control_binding_proxy_get_value (GstControlBinding * binding,
|
||||
GstClockTime timestamp)
|
||||
{
|
||||
GstGLControlBindingProxy *self = (GstGLControlBindingProxy *)
|
||||
binding;
|
||||
GstControlBinding *ref_binding;
|
||||
GValue *ret = NULL;
|
||||
|
||||
ref_binding = gst_object_get_control_binding (self->ref_object,
|
||||
self->property_name);
|
||||
|
||||
if (ref_binding) {
|
||||
ret = gst_control_binding_get_value (ref_binding, timestamp);
|
||||
gst_object_unref (ref_binding);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_control_binding_proxy_get_value_array (GstControlBinding * binding,
|
||||
GstClockTime timestamp, GstClockTime interval, guint n_values,
|
||||
gpointer values)
|
||||
{
|
||||
GstGLControlBindingProxy *self = (GstGLControlBindingProxy *)
|
||||
binding;
|
||||
GstControlBinding *ref_binding;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
ref_binding = gst_object_get_control_binding (self->ref_object,
|
||||
self->property_name);
|
||||
|
||||
if (ref_binding) {
|
||||
ret = gst_control_binding_get_value_array (ref_binding, timestamp,
|
||||
interval, n_values, values);
|
||||
gst_object_unref (ref_binding);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_control_binding_proxy_get_g_value_array (GstControlBinding *
|
||||
binding, GstClockTime timestamp, GstClockTime interval, guint n_values,
|
||||
GValue * values)
|
||||
{
|
||||
GstGLControlBindingProxy *self = (GstGLControlBindingProxy *)
|
||||
binding;
|
||||
GstControlBinding *ref_binding;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
ref_binding = gst_object_get_control_binding (self->ref_object,
|
||||
self->property_name);
|
||||
|
||||
if (ref_binding) {
|
||||
ret = gst_control_binding_get_g_value_array (ref_binding, timestamp,
|
||||
interval, n_values, values);
|
||||
gst_object_unref (ref_binding);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gst_gl_control_binding_proxy_class_init
|
||||
(GstGLControlBindingProxyClass * klass)
|
||||
{
|
||||
GstControlBindingClass *cb_class = GST_CONTROL_BINDING_CLASS (klass);
|
||||
|
||||
cb_class->sync_values = gst_gl_control_binding_proxy_sync_values;
|
||||
cb_class->get_value = gst_gl_control_binding_proxy_get_value;
|
||||
cb_class->get_value_array = gst_gl_control_binding_proxy_get_value_array;
|
||||
cb_class->get_g_value_array = gst_gl_control_binding_proxy_get_g_value_array;
|
||||
}
|
||||
|
||||
GstControlBinding *
|
||||
gst_gl_control_binding_proxy_new (GstObject * object,
|
||||
const gchar * property_name, GstObject * ref_object,
|
||||
const gchar * ref_property_name)
|
||||
{
|
||||
GstGLControlBindingProxy *self =
|
||||
g_object_new (GST_TYPE_GL_CONTROL_BINDING_PROXY, "object", object,
|
||||
"name", property_name, NULL);
|
||||
|
||||
self->ref_object = ref_object;
|
||||
self->property_name = ref_property_name;
|
||||
|
||||
return (GstControlBinding *) self;
|
||||
}
|
||||
|
||||
void
|
||||
gst_gl_object_add_control_binding_proxy (GstObject * object,
|
||||
GstObject * ref_object, const gchar * prop)
|
||||
{
|
||||
GstControlBinding *cb;
|
||||
|
||||
cb = gst_gl_control_binding_proxy_new (object, prop, ref_object, prop);
|
||||
gst_object_add_control_binding (object, cb);
|
||||
}
|
58
gst-libs/gst/gl/gstglcontrolbindingproxy.h
Normal file
58
gst-libs/gst/gl/gstglcontrolbindingproxy.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* GStreamer
|
||||
* Copyright (C) 2016 Matthew Waters <matthew@centricular.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_GL_PROXY_CONTROL_BINDING_H__
|
||||
#define __GST_GL_PROXY_CONTROL_BINDING_H__
|
||||
|
||||
#include <gst/gl/gl.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GType gst_gl_control_binding_proxy_get_type (void);
|
||||
#define GST_TYPE_GL_CONTROL_BINDING_PROXY (gst_gl_control_binding_proxy_get_type())
|
||||
|
||||
typedef struct _GstGLControlBindingProxy GstGLControlBindingProxy;
|
||||
typedef struct _GstGLControlBindingProxyClass GstGLControlBindingProxyClass;
|
||||
|
||||
struct _GstGLControlBindingProxy
|
||||
{
|
||||
GstControlBinding parent;
|
||||
|
||||
GstObject *ref_object;
|
||||
const gchar *property_name;
|
||||
};
|
||||
|
||||
struct _GstGLControlBindingProxyClass
|
||||
{
|
||||
GstControlBindingClass parent_class;
|
||||
};
|
||||
|
||||
GstControlBinding * gst_gl_control_binding_proxy_new (GstObject * object,
|
||||
const gchar * property_name,
|
||||
GstObject * ref_object,
|
||||
const gchar * ref_property_name);
|
||||
|
||||
void gst_gl_object_add_control_binding_proxy (GstObject * object,
|
||||
GstObject * ref_object,
|
||||
const gchar * prop);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_GL_PROXY_CONTROL_BINDING_H__ */
|
Loading…
Reference in a new issue