Skip to content

Commit

Permalink
gl: allow per feature registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Cerveau authored and GStreamer Marge Bot committed Mar 16, 2021
1 parent 5dcdc09 commit cd5d4b0
Show file tree
Hide file tree
Showing 35 changed files with 295 additions and 232 deletions.
6 changes: 6 additions & 0 deletions ext/gl/caopengllayersink.m
Expand Up @@ -30,6 +30,7 @@
#include "config.h"
#endif

#include "gstglelements.h"
#include "caopengllayersink.h"
#include "gstglsinkbin.h"
#include <QuartzCore/QuartzCore.h>
Expand All @@ -43,6 +44,11 @@
G_DEFINE_TYPE (GstCAOpenGLLayerSinkBin, gst_ca_opengl_layer_sink_bin,
GST_TYPE_GL_SINK_BIN);

#define _do_init \
gl_element_init (plugin);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (caopengllayersink, "caopengllayersink",
GST_RANK_NONE, GST_TYPE_CA_OPENGL_LAYER_SINK, _do_init);

enum
{
PROP_BIN_0,
Expand Down
3 changes: 3 additions & 0 deletions ext/gl/gstglalpha.c
Expand Up @@ -45,6 +45,7 @@
#include "config.h"
#endif

#include "gstglelements.h"
#include "gstglalpha.h"
#include <string.h>
#include <math.h>
Expand Down Expand Up @@ -222,6 +223,8 @@ static void gst_gl_alpha_get_property (GObject * object, guint prop_id,

#define gst_gl_alpha_parent_class parent_class
G_DEFINE_TYPE (GstGLAlpha, gst_gl_alpha, GST_TYPE_GL_FILTER);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glalpha, "glalpha",
GST_RANK_NONE, GST_TYPE_GL_ALPHA, gl_element_init (plugin));

static gboolean
gst_gl_alpha_is_passthrough (GstGLAlpha * glalpha)
Expand Down
4 changes: 4 additions & 0 deletions ext/gl/gstglbumper.c
Expand Up @@ -39,6 +39,8 @@

#include <stdlib.h>
#include <png.h>

#include "gstglelements.h"
#include "gstglbumper.h"

#if PNG_LIBPNG_VER >= 10400
Expand All @@ -60,6 +62,8 @@ enum

G_DEFINE_TYPE_WITH_CODE (GstGLBumper, gst_gl_bumper, GST_TYPE_GL_FILTER,
DEBUG_INIT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glbumper, "glbumper",
GST_RANK_NONE, GST_TYPE_GL_BUMPER, gl_element_init (plugin));

static void gst_gl_bumper_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
Expand Down
3 changes: 3 additions & 0 deletions ext/gl/gstglcolorbalance.c
Expand Up @@ -43,6 +43,7 @@
#include <gst/math-compat.h>
#include <gst/video/colorbalance.h>

#include "gstglelements.h"
#include "gstglcolorbalance.h"

GST_DEBUG_CATEGORY_STATIC (glcolorbalance_debug);
Expand Down Expand Up @@ -131,6 +132,8 @@ G_DEFINE_TYPE_WITH_CODE (GstGLColorBalance, gst_gl_color_balance,
GST_TYPE_GL_FILTER,
G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE,
gst_gl_color_balance_colorbalance_init));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glcolorbalance, "glcolorbalance",
GST_RANK_NONE, GST_TYPE_GL_COLOR_BALANCE, gl_element_init (plugin));

static GstCaps *
gcb_transform_internal_caps (GstGLFilter * filter,
Expand Down
4 changes: 4 additions & 0 deletions ext/gl/gstglcolorconvertelement.c
Expand Up @@ -24,6 +24,8 @@
#endif

#include <gst/gl/gl.h>

#include "gstglelements.h"
#include "gstglcolorconvertelement.h"

GST_DEBUG_CATEGORY_STATIC (gst_gl_color_convert_element_debug);
Expand All @@ -35,6 +37,8 @@ G_DEFINE_TYPE_WITH_CODE (GstGLColorConvertElement, gst_gl_color_convert_element,
GST_DEBUG_CATEGORY_INIT (gst_gl_color_convert_element_debug,
"glconvertelement", 0, "convert");
);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glcolorconvert, "glcolorconvert",
GST_RANK_NONE, GST_TYPE_GL_COLOR_CONVERT_ELEMENT, gl_element_init (plugin));

static gboolean gst_gl_color_convert_element_gl_set_caps (GstGLBaseFilter *
base_filter, GstCaps * in_caps, GstCaps * out_caps);
Expand Down
3 changes: 3 additions & 0 deletions ext/gl/gstglcolorscale.c
Expand Up @@ -44,6 +44,7 @@
#include "config.h"
#endif

#include "gstglelements.h"
#include "gstglcolorscale.h"

#define GST_CAT_DEFAULT gst_gl_colorscale_debug
Expand All @@ -60,6 +61,8 @@ enum
#define gst_gl_colorscale_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLColorscale, gst_gl_colorscale,
GST_TYPE_GL_FILTER, DEBUG_INIT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glcolorscale, "glcolorscale",
GST_RANK_NONE, GST_TYPE_GL_COLORSCALE, gl_element_init (plugin));

static void gst_gl_colorscale_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
Expand Down
3 changes: 3 additions & 0 deletions ext/gl/gstgldeinterlace.c
Expand Up @@ -38,6 +38,7 @@

#include <gst/gl/gstglfuncs.h>

#include "gstglelements.h"
#include "gstgldeinterlace.h"

#define GST_CAT_DEFAULT gst_gl_deinterlace_debug
Expand All @@ -54,6 +55,8 @@ enum
#define gst_gl_deinterlace_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLDeinterlace, gst_gl_deinterlace,
GST_TYPE_GL_FILTER, DEBUG_INIT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (gldeinterlace, "gldeinterlace",
GST_RANK_NONE, GST_TYPE_GL_DEINTERLACE, gl_element_init (plugin));

static void gst_gl_deinterlace_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
Expand Down
3 changes: 3 additions & 0 deletions ext/gl/gstgldifferencematte.c
Expand Up @@ -41,6 +41,7 @@

#include <gst/gl/gstglfuncs.h>

#include "gstglelements.h"
#include "gstgldifferencematte.h"
#include "effects/gstgleffectssources.h"

Expand All @@ -58,6 +59,8 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
#define gst_gl_differencematte_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLDifferenceMatte, gst_gl_differencematte,
GST_TYPE_GL_FILTER, DEBUG_INIT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (gldifferencematte, "gldifferencematte",
GST_RANK_NONE, GST_TYPE_GL_DIFFERENCEMATTE, gl_element_init (plugin));

static void gst_gl_differencematte_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
Expand Down
3 changes: 3 additions & 0 deletions ext/gl/gstgldownloadelement.c
Expand Up @@ -28,6 +28,7 @@
#include <gst/allocators/gstdmabuf.h>
#endif

#include "gstglelements.h"
#include "gstgldownloadelement.h"

GST_DEBUG_CATEGORY_STATIC (gst_gl_download_element_debug);
Expand All @@ -38,6 +39,8 @@ G_DEFINE_TYPE_WITH_CODE (GstGLDownloadElement, gst_gl_download_element,
GST_TYPE_GL_BASE_FILTER,
GST_DEBUG_CATEGORY_INIT (gst_gl_download_element_debug, "gldownloadelement",
0, "download element"););
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (gldownload, "gldownload",
GST_RANK_NONE, GST_TYPE_GL_DOWNLOAD_ELEMENT, gl_element_init (plugin));

static gboolean gst_gl_download_element_start (GstBaseTransform * bt);
static gboolean gst_gl_download_element_stop (GstBaseTransform * bt);
Expand Down
10 changes: 10 additions & 0 deletions ext/gl/gstgleffects.c
Expand Up @@ -36,6 +36,7 @@
#include "config.h"
#endif

#include "gstglelements.h"
#include "gstgleffects.h"

#define GST_CAT_DEFAULT gst_gl_effects_debug
Expand All @@ -56,6 +57,15 @@ enum
G_DEFINE_TYPE_WITH_CODE (GstGLEffects, gst_gl_effects, GST_TYPE_GL_FILTER,
DEBUG_INIT);

static gboolean
gst_element_init_gleffects (GstPlugin * plugin)
{
gl_element_init (plugin);
return gst_gl_effects_register_filters (plugin, GST_RANK_NONE);
}

GST_ELEMENT_REGISTER_DEFINE_CUSTOM (gleffects, gst_element_init_gleffects);

static void gst_gl_effects_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_gl_effects_get_property (GObject * object, guint prop_id,
Expand Down
70 changes: 70 additions & 0 deletions ext/gl/gstglelement.c
@@ -0,0 +1,70 @@
/*
* GStreamer
* Copyright (C) 2003 Julien Moutte <julien@moutte.net>
* Copyright (C) 2005,2006,2007 David A. Schleef <ds@schleef.org>
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Stéphane Cerveau <scerveau@collabora.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 "gstglelements.h"

#include "gstglmixerbin.h"
#include "gstglvideomixer.h"
#include "gstglstereomix.h"

#if GST_GL_HAVE_WINDOW_COCOA
/* avoid including Cocoa/CoreFoundation from a C file... */
extern GType gst_ca_opengl_layer_sink_bin_get_type (void);
#endif

#if GST_GL_HAVE_WINDOW_DISPMANX
extern void bcm_host_init (void);
#endif

#if GST_GL_HAVE_WINDOW_X11
#include <X11/Xlib.h>
#endif

#define GST_CAT_DEFAULT gst_gl_gstgl_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);

void
gl_element_init (GstPlugin * plugin)
{
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
GST_DEBUG_CATEGORY_INIT (gst_gl_gstgl_debug, "gstopengl", 0, "gstopengl");

#if GST_GL_HAVE_WINDOW_DISPMANX
GST_DEBUG ("Initialize BCM host");
bcm_host_init ();
#endif

#if GST_GL_HAVE_WINDOW_X11
if (g_getenv ("GST_GL_XINITTHREADS"))
XInitThreads ();
#endif
g_once_init_leave (&res, TRUE);
}
}
69 changes: 69 additions & 0 deletions ext/gl/gstglelements.h
@@ -0,0 +1,69 @@
/*
* Copyright (C) 2003 Julien Moutte <julien@moutte.net>
* Copyright (C) 2005,2006,2007 David A. Schleef <ds@schleef.org>
* Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
* Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Julian Bouzas <julian.bouzas@collabora.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_ELEMENTS_H__
#define __GST_GL_ELEMENTS_H__

#include <gst/gst.h>

G_BEGIN_DECLS

G_GNUC_INTERNAL void gl_element_init (GstPlugin * plugin);

GST_ELEMENT_REGISTER_DECLARE (glimagesink);
GST_ELEMENT_REGISTER_DECLARE (glimagesinkelement);
GST_ELEMENT_REGISTER_DECLARE (glupload);
GST_ELEMENT_REGISTER_DECLARE (gldownload);
GST_ELEMENT_REGISTER_DECLARE (glcolorconvert);
GST_ELEMENT_REGISTER_DECLARE (glcolorbalance);
GST_ELEMENT_REGISTER_DECLARE (glfilterbin);
GST_ELEMENT_REGISTER_DECLARE (glsinkbin);
GST_ELEMENT_REGISTER_DECLARE (glsrcbin);
GST_ELEMENT_REGISTER_DECLARE (glmixerbin);
GST_ELEMENT_REGISTER_DECLARE (glfiltercube);
GST_ELEMENT_REGISTER_DECLARE (gltransformation);
GST_ELEMENT_REGISTER_DECLARE (glvideoflip);
GST_ELEMENT_REGISTER_DECLARE (gleffects);
GST_ELEMENT_REGISTER_DECLARE (glcolorscale);
GST_ELEMENT_REGISTER_DECLARE (glvideomixer);
GST_ELEMENT_REGISTER_DECLARE (glvideomixerelement);
GST_ELEMENT_REGISTER_DECLARE (glshader);
GST_ELEMENT_REGISTER_DECLARE (glfilterapp);
GST_ELEMENT_REGISTER_DECLARE (glviewconvert);
GST_ELEMENT_REGISTER_DECLARE (glstereosplit);
GST_ELEMENT_REGISTER_DECLARE (glstereomix);
GST_ELEMENT_REGISTER_DECLARE (gltestsrc);
GST_ELEMENT_REGISTER_DECLARE (gldeinterlace);
GST_ELEMENT_REGISTER_DECLARE (glalpha);
GST_ELEMENT_REGISTER_DECLARE (gloverlaycompositor);
GST_ELEMENT_REGISTER_DECLARE (gloverlay);
GST_ELEMENT_REGISTER_DECLARE (glfilterglass);
GST_ELEMENT_REGISTER_DECLARE (glfilterreflectedscreen);
GST_ELEMENT_REGISTER_DECLARE (glmosaic);
GST_ELEMENT_REGISTER_DECLARE (gldifferencematte);
GST_ELEMENT_REGISTER_DECLARE (glbumper);
GST_ELEMENT_REGISTER_DECLARE (caopengllayersink);

G_END_DECLS

#endif /* __GST_GL_ELEMENTS_H__ */
3 changes: 3 additions & 0 deletions ext/gl/gstglfilterapp.c
Expand Up @@ -38,6 +38,7 @@
#include "config.h"
#endif

#include "gstglelements.h"
#include "gstglfilterapp.h"

#define GST_CAT_DEFAULT gst_gl_filter_app_debug
Expand All @@ -58,6 +59,8 @@ static guint gst_gl_filter_app_signals[LAST_SIGNAL] = { 0 };
#define gst_gl_filter_app_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLFilterApp, gst_gl_filter_app,
GST_TYPE_GL_FILTER, DEBUG_INIT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glfilterapp, "glfilterapp",
GST_RANK_NONE, GST_TYPE_GL_FILTER_APP, gl_element_init (plugin));

static void gst_gl_filter_app_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
Expand Down
3 changes: 3 additions & 0 deletions ext/gl/gstglfilterbin.c
Expand Up @@ -22,6 +22,7 @@
#include "config.h"
#endif

#include "gstglelements.h"
#include "gstglfilterbin.h"

#define GST_CAT_DEFAULT gst_gl_filter_bin_debug
Expand All @@ -47,6 +48,8 @@ static guint gst_gl_filter_bin_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_CODE (GstGLFilterBin, gst_gl_filter_bin,
GST_TYPE_BIN, GST_DEBUG_CATEGORY_INIT (gst_gl_filter_bin_debug,
"glfilterbin", 0, "glfilterbin element"););
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glfilterbin, "glfilterbin",
GST_RANK_NONE, GST_TYPE_GL_FILTER_BIN, gl_element_init (plugin));

static void gst_gl_filter_bin_finalize (GObject * object);
static void gst_gl_filter_bin_get_property (GObject * object, guint prop_id,
Expand Down
4 changes: 4 additions & 0 deletions ext/gl/gstglfiltercube.c
Expand Up @@ -45,6 +45,8 @@
#endif

#include <gst/gl/gstglapi.h>

#include "gstglelements.h"
#include "gstglfiltercube.h"
#include "gstglutils.h"

Expand All @@ -68,6 +70,8 @@ enum
#define gst_gl_filter_cube_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLFilterCube, gst_gl_filter_cube,
GST_TYPE_GL_FILTER, DEBUG_INIT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glfiltercube, "glfiltercube",
GST_RANK_NONE, GST_TYPE_GL_FILTER_CUBE, gl_element_init (plugin));

static void gst_gl_filter_cube_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
Expand Down
3 changes: 3 additions & 0 deletions ext/gl/gstglfilterglass.c
Expand Up @@ -43,6 +43,7 @@
#include <math.h>
#include <gst/gl/gstglfuncs.h>

#include "gstglelements.h"
#include "gstglfilterglass.h"

#include "gstglutils.h"
Expand All @@ -60,6 +61,8 @@ enum
#define gst_gl_filter_glass_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstGLFilterGlass, gst_gl_filter_glass,
GST_TYPE_GL_FILTER, DEBUG_INIT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (glfilterglass, "glfilterglass",
GST_RANK_NONE, GST_TYPE_GL_FILTER_GLASS, gl_element_init (plugin));

static void gst_gl_filter_glass_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
Expand Down

0 comments on commit cd5d4b0

Please sign in to comment.