speex: 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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/876>
This commit is contained in:
Stéphane Cerveau 2021-02-12 16:09:53 +01:00
parent 58779e7538
commit 801a2243e5
6 changed files with 82 additions and 13 deletions

View file

@ -20,26 +20,18 @@
#include <config.h> #include <config.h>
#endif #endif
#include "gstspeexdec.h" #include "gstspeexelements.h"
#include "gstspeexenc.h"
#include <gst/tag/tag.h>
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
{ {
gboolean ret = FALSE;
if (!gst_element_register (plugin, "speexenc", GST_RANK_PRIMARY, ret |= GST_ELEMENT_REGISTER (speexenc, plugin);
GST_TYPE_SPEEX_ENC)) ret |= GST_ELEMENT_REGISTER (speexdec, plugin);
return FALSE;
if (!gst_element_register (plugin, "speexdec", GST_RANK_PRIMARY, return ret;
GST_TYPE_SPEEX_DEC))
return FALSE;
gst_tag_register_musicbrainz_tags ();
return TRUE;
} }
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View file

@ -39,6 +39,7 @@
# include "config.h" # include "config.h"
#endif #endif
#include "gstspeexelements.h"
#include "gstspeexdec.h" #include "gstspeexdec.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -77,6 +78,8 @@ GST_STATIC_PAD_TEMPLATE ("sink",
#define gst_speex_dec_parent_class parent_class #define gst_speex_dec_parent_class parent_class
G_DEFINE_TYPE (GstSpeexDec, gst_speex_dec, GST_TYPE_AUDIO_DECODER); G_DEFINE_TYPE (GstSpeexDec, gst_speex_dec, GST_TYPE_AUDIO_DECODER);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (speexdec, "speexdec",
GST_RANK_PRIMARY, GST_TYPE_SPEEX_DEC, speex_element_init (plugin));
static gboolean gst_speex_dec_start (GstAudioDecoder * dec); static gboolean gst_speex_dec_start (GstAudioDecoder * dec);
static gboolean gst_speex_dec_stop (GstAudioDecoder * dec); static gboolean gst_speex_dec_stop (GstAudioDecoder * dec);

View file

@ -0,0 +1,36 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* 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 "gstspeexelements.h"
#include <gst/tag/tag.h>
void
speex_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);
}
}

View file

@ -0,0 +1,34 @@
/*
* 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_SPEEX_ELEMENTS_H__
#define __GST_SPEEX_ELEMENTS_H__
#include <gst/gst.h>
G_BEGIN_DECLS
void speex_element_init (GstPlugin * plugin);
GST_ELEMENT_REGISTER_DECLARE (speexenc);
GST_ELEMENT_REGISTER_DECLARE (speexdec);
G_END_DECLS
#endif /* __GST_SPEEX_ELEMENTS_H__ */

View file

@ -46,6 +46,7 @@
#include <gst/gsttagsetter.h> #include <gst/gsttagsetter.h>
#include <gst/tag/tag.h> #include <gst/tag/tag.h>
#include <gst/audio/audio.h> #include <gst/audio/audio.h>
#include "gstspeexelements.h"
#include "gstspeexenc.h" #include "gstspeexenc.h"
GST_DEBUG_CATEGORY_STATIC (speexenc_debug); GST_DEBUG_CATEGORY_STATIC (speexenc_debug);
@ -143,6 +144,8 @@ static gboolean gst_speex_enc_sink_event (GstAudioEncoder * enc,
G_DEFINE_TYPE_WITH_CODE (GstSpeexEnc, gst_speex_enc, GST_TYPE_AUDIO_ENCODER, G_DEFINE_TYPE_WITH_CODE (GstSpeexEnc, gst_speex_enc, GST_TYPE_AUDIO_ENCODER,
G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL); G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL);
G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL)); G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (speexenc, "speexenc",
GST_RANK_PRIMARY, GST_TYPE_SPEEX_ENC, speex_element_init (plugin));
static void static void
gst_speex_enc_class_init (GstSpeexEncClass * klass) gst_speex_enc_class_init (GstSpeexEncClass * klass)

View file

@ -1,4 +1,5 @@
speex_sources = [ speex_sources = [
'gstspeexelement.c',
'gstspeex.c', 'gstspeex.c',
'gstspeexdec.c', 'gstspeexdec.c',
'gstspeexenc.c', 'gstspeexenc.c',