diff --git a/ext/vpx/gstvp8dec.c b/ext/vpx/gstvp8dec.c index 65ed836ca02..16a1b5ae21f 100644 --- a/ext/vpx/gstvp8dec.c +++ b/ext/vpx/gstvp8dec.c @@ -44,6 +44,7 @@ #include +#include "gstvpxelements.h" #include "gstvp8dec.h" #include "gstvp8utils.h" @@ -77,6 +78,8 @@ GST_STATIC_PAD_TEMPLATE ("src", #define parent_class gst_vp8_dec_parent_class G_DEFINE_TYPE (GstVP8Dec, gst_vp8_dec, GST_TYPE_VPX_DEC); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vp8dec, "vp8dec", GST_RANK_PRIMARY, + gst_vp8_dec_get_type (), vpx_element_init (plugin)); static void gst_vp8_dec_class_init (GstVP8DecClass * klass) diff --git a/ext/vpx/gstvp8enc.c b/ext/vpx/gstvp8enc.c index bf8ec981519..93ef43e83b7 100644 --- a/ext/vpx/gstvp8enc.c +++ b/ext/vpx/gstvp8enc.c @@ -62,6 +62,7 @@ #include #include +#include "gstvpxelements.h" #include "gstvp8utils.h" #include "gstvp8enc.h" @@ -139,6 +140,8 @@ GST_STATIC_PAD_TEMPLATE ("src", #define parent_class gst_vp8_enc_parent_class G_DEFINE_TYPE (GstVP8Enc, gst_vp8_enc, GST_TYPE_VPX_ENC); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vp8enc, "vp8enc", GST_RANK_PRIMARY, + gst_vp8_enc_get_type (), vpx_element_init (plugin)); static void gst_vp8_enc_class_init (GstVP8EncClass * klass) diff --git a/ext/vpx/gstvp9dec.c b/ext/vpx/gstvp9dec.c index a80ef917d3d..1aa45a2d9cf 100644 --- a/ext/vpx/gstvp9dec.c +++ b/ext/vpx/gstvp9dec.c @@ -44,6 +44,7 @@ #include +#include "gstvpxelements.h" #include "gstvp8utils.h" #include "gstvp9dec.h" @@ -80,6 +81,8 @@ GST_STATIC_PAD_TEMPLATE ("src", #define parent_class gst_vp9_dec_parent_class G_DEFINE_TYPE (GstVP9Dec, gst_vp9_dec, GST_TYPE_VPX_DEC); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vp9dec, "vp9dec", GST_RANK_PRIMARY, + gst_vp9_dec_get_type (), vpx_element_init (plugin)); static void gst_vp9_dec_class_init (GstVP9DecClass * klass) diff --git a/ext/vpx/gstvp9enc.c b/ext/vpx/gstvp9enc.c index 47fe47f5f68..09f39450b22 100644 --- a/ext/vpx/gstvp9enc.c +++ b/ext/vpx/gstvp9enc.c @@ -62,6 +62,7 @@ #include #include +#include "gstvpxelements.h" #include "gstvp8utils.h" #include "gstvp9enc.h" @@ -99,6 +100,8 @@ GST_STATIC_PAD_TEMPLATE ("src", #define parent_class gst_vp9_enc_parent_class G_DEFINE_TYPE (GstVP9Enc, gst_vp9_enc, GST_TYPE_VPX_ENC); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vp9enc, "vp9enc", GST_RANK_PRIMARY, + gst_vp9_enc_get_type (), vpx_element_init (plugin)); static vpx_codec_iface_t *gst_vp9_enc_get_algo (GstVPXEnc * enc); static gboolean gst_vp9_enc_enable_scaling (GstVPXEnc * enc); diff --git a/ext/vpx/gstvpxelement.c b/ext/vpx/gstvpxelement.c new file mode 100644 index 00000000000..2550283bf6d --- /dev/null +++ b/ext/vpx/gstvpxelement.c @@ -0,0 +1,39 @@ +/* VPX + * Copyright (C) 2006 David Schleef + * Copyright (C) 2010 Entropy Wave Inc + * + * 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 +#endif + +#include "gstvpxelements.h" + +#include + +void +vpx_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + static const gchar *tags[] = { NULL }; + if (g_once_init_enter (&res)) { + gst_meta_register_custom ("GstVP8Meta", tags, NULL, NULL, NULL); + g_once_init_leave (&res, TRUE); + } +} diff --git a/ext/vpx/gstvpxelements.h b/ext/vpx/gstvpxelements.h new file mode 100644 index 00000000000..b2c1f88f345 --- /dev/null +++ b/ext/vpx/gstvpxelements.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * @Author: Julian Bouzas + * + * 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_VPX_ELEMENTS_H__ +#define __GST_VPX_ELEMENTS_H__ + +#include + +G_BEGIN_DECLS + +void vpx_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (vp8dec); +GST_ELEMENT_REGISTER_DECLARE (vp8enc); +GST_ELEMENT_REGISTER_DECLARE (vp9dec); +GST_ELEMENT_REGISTER_DECLARE (vp9enc); + +G_END_DECLS + +#endif /* __GST_VPX_ELEMENTS_H__ */ diff --git a/ext/vpx/meson.build b/ext/vpx/meson.build index bedaff03cbb..9d503495a2f 100644 --- a/ext/vpx/meson.build +++ b/ext/vpx/meson.build @@ -6,6 +6,7 @@ vpx_sources = [ 'gstvp9enc.c', 'gstvpxdec.c', 'gstvpxenc.c', + 'gstvpxelement.c', 'plugin.c', ] diff --git a/ext/vpx/plugin.c b/ext/vpx/plugin.c index f5cfce21285..1887aee70e2 100644 --- a/ext/vpx/plugin.c +++ b/ext/vpx/plugin.c @@ -25,40 +25,30 @@ #include -#include "gstvp8dec.h" -#include "gstvp8enc.h" -#include "gstvp9dec.h" -#include "gstvp9enc.h" +#include "gstvpxelements.h" static gboolean plugin_init (GstPlugin * plugin) { - static const gchar *tags[] = { NULL }; + gboolean ret = FALSE; #ifdef HAVE_VP8_DECODER - gst_element_register (plugin, "vp8dec", GST_RANK_PRIMARY, - gst_vp8_dec_get_type ()); + ret |= GST_ELEMENT_REGISTER (vp8dec, plugin); #endif #ifdef HAVE_VP8_ENCODER - gst_element_register (plugin, "vp8enc", GST_RANK_PRIMARY, - gst_vp8_enc_get_type ()); + ret |= GST_ELEMENT_REGISTER (vp8enc, plugin); #endif #ifdef HAVE_VP9_DECODER - gst_element_register (plugin, "vp9dec", GST_RANK_PRIMARY, - gst_vp9_dec_get_type ()); + ret |= GST_ELEMENT_REGISTER (vp9dec, plugin); #endif #ifdef HAVE_VP9_ENCODER - gst_element_register (plugin, "vp9enc", GST_RANK_PRIMARY, - gst_vp9_enc_get_type ()); + ret |= GST_ELEMENT_REGISTER (vp9enc, plugin); #endif - if (!gst_meta_register_custom ("GstVP8Meta", tags, NULL, NULL, NULL)) - return FALSE; - - return TRUE; + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,