From: Stéphane Cerveau Date: Fri, 11 Dec 2020 15:59:50 +0000 (+0100) Subject: opus: allow per feature registration X-Git-Tag: 1.19.3~511^2~234 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e728ee5b5a535242113fb2aece0b3dcd4b7c1f1;p=platform%2Fupstream%2Fgstreamer.git opus: allow per feature registration Split plugin into features including dynamic types which can be indiviually registered during a static build. More details here: https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199 https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661 Part-of: --- diff --git a/ext/opus/gstopus.c b/ext/opus/gstopus.c index e16acea..43e5954 100644 --- a/ext/opus/gstopus.c +++ b/ext/opus/gstopus.c @@ -21,26 +21,17 @@ #include #endif -#include "gstopusdec.h" -#include "gstopusenc.h" - -#include +#include "gstopuselements.h" static gboolean plugin_init (GstPlugin * plugin) { + gboolean ret = FALSE; - if (!gst_element_register (plugin, "opusenc", GST_RANK_PRIMARY, - GST_TYPE_OPUS_ENC)) - return FALSE; - - if (!gst_element_register (plugin, "opusdec", GST_RANK_PRIMARY, - GST_TYPE_OPUS_DEC)) - return FALSE; - - gst_tag_register_musicbrainz_tags (); + ret |= GST_ELEMENT_REGISTER (opusenc, plugin); + ret |= GST_ELEMENT_REGISTER (opusdec, plugin); - return TRUE; + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, diff --git a/ext/opus/gstopusdec.c b/ext/opus/gstopusdec.c index 987c8f0..c4f5df8 100644 --- a/ext/opus/gstopusdec.c +++ b/ext/opus/gstopusdec.c @@ -46,6 +46,7 @@ #include #include #include +#include "gstopuselements.h" #include "gstopusheader.h" #include "gstopuscommon.h" #include "gstopusdec.h" @@ -78,6 +79,8 @@ static GstStaticPadTemplate opus_dec_sink_factory = ); G_DEFINE_TYPE (GstOpusDec, gst_opus_dec, GST_TYPE_AUDIO_DECODER); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (opusdec, "opusdec", + GST_RANK_PRIMARY, GST_TYPE_OPUS_DEC, opus_element_init (plugin)); #define DB_TO_LINEAR(x) pow (10., (x) / 20.) diff --git a/ext/opus/gstopuselement.c b/ext/opus/gstopuselement.c new file mode 100644 index 0000000..3c661d2 --- /dev/null +++ b/ext/opus/gstopuselement.c @@ -0,0 +1,39 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2008> Sebastian Dröge + * 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. + */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gstopuselements.h" + +#include + +void +opus_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + + if (g_once_init_enter (&res)) { + gst_tag_register_musicbrainz_tags (); + g_once_init_leave (&res, TRUE); + } +} diff --git a/ext/opus/gstopuselements.h b/ext/opus/gstopuselements.h new file mode 100644 index 0000000..e4e671b --- /dev/null +++ b/ext/opus/gstopuselements.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2008> Sebastian Dröge + * 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_OPUS_ELEMENTS_H__ +#define __GST_OPUS_ELEMENTS_H__ + +#include + +G_BEGIN_DECLS + + +G_GNUC_INTERNAL void opus_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (opusenc); +GST_ELEMENT_REGISTER_DECLARE (opusdec); + +G_END_DECLS + +#endif /* __GST_OPUS_ELEMENTS_H__ */ diff --git a/ext/opus/gstopusenc.c b/ext/opus/gstopusenc.c index bbe1f99..305663a 100644 --- a/ext/opus/gstopusenc.c +++ b/ext/opus/gstopusenc.c @@ -52,6 +52,8 @@ #include #include #include + +#include "gstopuselements.h" #include "gstopusheader.h" #include "gstopuscommon.h" #include "gstopusenc.h" @@ -243,6 +245,8 @@ static GstFlowReturn gst_opus_enc_encode (GstOpusEnc * enc, GstBuffer * buffer); G_DEFINE_TYPE_WITH_CODE (GstOpusEnc, gst_opus_enc, GST_TYPE_AUDIO_ENCODER, G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL); G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL)); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (opusenc, "opusenc", + GST_RANK_PRIMARY, GST_TYPE_OPUS_ENC, opus_element_init (plugin)); static void gst_opus_enc_set_tags (GstOpusEnc * enc) diff --git a/ext/opus/meson.build b/ext/opus/meson.build index cca4a3b..2b49902 100644 --- a/ext/opus/meson.build +++ b/ext/opus/meson.build @@ -1,5 +1,6 @@ opus_sources = [ 'gstopus.c', + 'gstopuselement.c', 'gstopuscommon.c', 'gstopusdec.c', 'gstopusenc.c',