Skip to content

Commit

Permalink
vorbis: 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 5e728ee commit 2a8adec
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 43 deletions.
11 changes: 5 additions & 6 deletions ext/vorbis/gstivorbisdec.c
Expand Up @@ -21,22 +21,21 @@
#include "config.h"
#endif

#include "gstvorbisdec.h"
#include "gstvorbiselements.h"

GST_DEBUG_CATEGORY (ivorbisdec_debug);

static gboolean
plugin_init (GstPlugin * plugin)
{

if (!gst_element_register (plugin, "ivorbisdec", GST_RANK_SECONDARY,
gst_vorbis_dec_get_type ()))
return FALSE;
gboolean ret = FALSE;

GST_DEBUG_CATEGORY_INIT (ivorbisdec_debug, "ivorbisdec", 0,
"vorbis decoding element (integer decoder)");

return TRUE;
ret |= GST_ELEMENT_REGISTER (ivorbisdec, plugin);

return ret;
}

GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
Expand Down
44 changes: 7 additions & 37 deletions ext/vorbis/gstvorbis.c
Expand Up @@ -21,49 +21,19 @@
#include "config.h"
#endif

#include "gst/tag/tag.h"

#include "gstvorbisenc.h"
#include "gstvorbisdec.h"
#include "gstvorbisparse.h"
#include "gstvorbistag.h"

GST_DEBUG_CATEGORY (vorbisenc_debug);
GST_DEBUG_CATEGORY (vorbisdec_debug);
GST_DEBUG_CATEGORY (vorbisparse_debug);
GST_DEBUG_CATEGORY (vorbistag_debug);
#include "gstvorbiselements.h"

static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "vorbisenc", GST_RANK_PRIMARY,
GST_TYPE_VORBISENC))
return FALSE;

if (!gst_element_register (plugin, "vorbisdec", GST_RANK_PRIMARY,
gst_vorbis_dec_get_type ()))
return FALSE;

if (!gst_element_register (plugin, "vorbisparse", GST_RANK_NONE,
gst_vorbis_parse_get_type ()))
return FALSE;

if (!gst_element_register (plugin, "vorbistag", GST_RANK_NONE,
gst_vorbis_tag_get_type ()))
return FALSE;

GST_DEBUG_CATEGORY_INIT (vorbisenc_debug, "vorbisenc", 0,
"vorbis encoding element");
GST_DEBUG_CATEGORY_INIT (vorbisdec_debug, "vorbisdec", 0,
"vorbis decoding element");
GST_DEBUG_CATEGORY_INIT (vorbisparse_debug, "vorbisparse", 0,
"vorbis parsing element");
GST_DEBUG_CATEGORY_INIT (vorbistag_debug, "vorbistag", 0,
"vorbis tagging element");
gboolean ret = FALSE;

gst_tag_register_musicbrainz_tags ();
ret |= GST_ELEMENT_REGISTER (vorbisenc, plugin);
ret |= GST_ELEMENT_REGISTER (vorbisdec, plugin);
ret |= GST_ELEMENT_REGISTER (vorbisparse, plugin);
ret |= GST_ELEMENT_REGISTER (vorbistag, plugin);

return TRUE;
return ret;
}

GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
Expand Down
6 changes: 6 additions & 0 deletions ext/vorbis/gstvorbisdec.c
Expand Up @@ -44,6 +44,7 @@
#include <gst/audio/audio.h>
#include <gst/tag/tag.h>

#include "gstvorbiselements.h"
#include "gstvorbiscommon.h"

#ifndef TREMOR
Expand All @@ -69,6 +70,11 @@ GST_STATIC_PAD_TEMPLATE ("sink",

#define gst_vorbis_dec_parent_class parent_class
G_DEFINE_TYPE (GstVorbisDec, gst_vorbis_dec, GST_TYPE_AUDIO_DECODER);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vorbisdec, "vorbisdec",
GST_RANK_PRIMARY, GST_TYPE_VORBIS_DEC, vorbis_element_init (plugin));

GST_ELEMENT_REGISTER_DEFINE (ivorbisdec, "ivorbisdec",
GST_RANK_SECONDARY, GST_TYPE_VORBIS_DEC);

static void vorbis_dec_finalize (GObject * object);

Expand Down
43 changes: 43 additions & 0 deletions ext/vorbis/gstvorbiselement.c
@@ -0,0 +1,43 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* 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 "gstvorbiselements.h"
#include "gst/tag/tag.h"

GST_DEBUG_CATEGORY (vorbisenc_debug);
GST_DEBUG_CATEGORY (vorbisdec_debug);
GST_DEBUG_CATEGORY (vorbisparse_debug);
GST_DEBUG_CATEGORY (vorbistag_debug);

void
vorbis_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);
}
}
38 changes: 38 additions & 0 deletions ext/vorbis/gstvorbiselements.h
@@ -0,0 +1,38 @@
/*
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* 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.
*/

#ifndef __GST_VORBIS_ELEMENTS_H__
#define __GST_VORBIS_ELEMENTS_H__

#include <gst/gst.h>

G_BEGIN_DECLS

G_GNUC_INTERNAL void vorbis_element_init (GstPlugin * plugin);

GST_ELEMENT_REGISTER_DECLARE (vorbisenc);
GST_ELEMENT_REGISTER_DECLARE (vorbisdec);
GST_ELEMENT_REGISTER_DECLARE (vorbisparse);
GST_ELEMENT_REGISTER_DECLARE (vorbistag);
GST_ELEMENT_REGISTER_DECLARE (ivorbisdec);

G_END_DECLS

#endif /* __GST_VORBIS_ELEMENTS_H__ */
3 changes: 3 additions & 0 deletions ext/vorbis/gstvorbisenc.c
Expand Up @@ -52,6 +52,7 @@
#include <gst/audio/audio.h>
#include "gstvorbisenc.h"

#include "gstvorbiselements.h"
#include "gstvorbiscommon.h"

GST_DEBUG_CATEGORY_EXTERN (vorbisenc_debug);
Expand Down Expand Up @@ -108,6 +109,8 @@ static void gst_vorbis_enc_flush (GstAudioEncoder * vorbisenc);
#define gst_vorbis_enc_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstVorbisEnc, gst_vorbis_enc,
GST_TYPE_AUDIO_ENCODER, G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vorbisenc, "vorbisenc",
GST_RANK_PRIMARY, GST_TYPE_VORBISENC, vorbis_element_init (plugin));

static void
gst_vorbis_enc_class_init (GstVorbisEncClass * klass)
Expand Down
3 changes: 3 additions & 0 deletions ext/vorbis/gstvorbisparse.c
Expand Up @@ -53,6 +53,7 @@
# include "config.h"
#endif

#include "gstvorbiselements.h"
#include "gstvorbisparse.h"

GST_DEBUG_CATEGORY_EXTERN (vorbisparse_debug);
Expand All @@ -74,6 +75,8 @@ GST_STATIC_PAD_TEMPLATE ("src",

#define gst_vorbis_parse_parent_class parent_class
G_DEFINE_TYPE (GstVorbisParse, gst_vorbis_parse, GST_TYPE_ELEMENT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vorbisparse, "vorbisparse",
GST_RANK_NONE, GST_TYPE_VORBIS_PARSE, vorbis_element_init (plugin));

static GstFlowReturn vorbis_parse_chain (GstPad * pad, GstObject * parent,
GstBuffer * buffer);
Expand Down
3 changes: 3 additions & 0 deletions ext/vorbis/gstvorbistag.c
Expand Up @@ -55,6 +55,7 @@

#include <vorbis/codec.h>

#include "gstvorbiselements.h"
#include "gstvorbistag.h"


Expand All @@ -67,6 +68,8 @@ static GstFlowReturn gst_vorbis_tag_parse_packet (GstVorbisParse * parse,
#define gst_vorbis_tag_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstVorbisTag, gst_vorbis_tag,
GST_TYPE_VORBIS_PARSE, G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (vorbistag, "vorbistag",
GST_RANK_NONE, GST_TYPE_VORBIS_TAG, vorbis_element_init (plugin));

static void
gst_vorbis_tag_class_init (GstVorbisTagClass * klass)
Expand Down
2 changes: 2 additions & 0 deletions ext/vorbis/meson.build
@@ -1,5 +1,6 @@
vorbis_sources = [
'gstvorbis.c',
'gstvorbiselement.c',
'gstvorbisdec.c',
'gstvorbisdeclib.c',
'gstvorbisenc.c',
Expand All @@ -10,6 +11,7 @@ vorbis_sources = [

vorbisidec_sources = [
'gstivorbisdec.c',
'gstvorbiselement.c',
'gstvorbisdec.c',
'gstvorbisdeclib.c',
'gstvorbiscommon.c',
Expand Down

0 comments on commit 2a8adec

Please sign in to comment.