taglib: 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 17:26:36 +01:00
parent 6cbba1e470
commit a047a1144b
6 changed files with 88 additions and 9 deletions

View file

@ -46,6 +46,7 @@
#include <config.h> #include <config.h>
#endif #endif
#include "gsttaglibelements.h"
#include "gstapev2mux.h" #include "gstapev2mux.h"
#include <string.h> #include <string.h>
@ -69,6 +70,10 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("ANY")); GST_STATIC_CAPS ("ANY"));
G_DEFINE_TYPE (GstApev2Mux, gst_apev2_mux, GST_TYPE_TAG_MUX); G_DEFINE_TYPE (GstApev2Mux, gst_apev2_mux, GST_TYPE_TAG_MUX);
#define _do_init \
taglib_element_init (plugin);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (apev2mux, "apev2mux",
GST_RANK_NONE, GST_TYPE_APEV2_MUX, _do_init);
static GstBuffer *gst_apev2_mux_render_start_tag (GstTagMux * mux, static GstBuffer *gst_apev2_mux_render_start_tag (GstTagMux * mux,
const GstTagList * taglist); const GstTagList * taglist);

View file

@ -47,6 +47,7 @@
#include <config.h> #include <config.h>
#endif #endif
#include "gsttaglibelements.h"
#include "gstid3v2mux.h" #include "gstid3v2mux.h"
#include <string.h> #include <string.h>
@ -77,6 +78,10 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("ANY")); GST_STATIC_CAPS ("ANY"));
G_DEFINE_TYPE (GstId3v2Mux, gst_id3v2_mux, GST_TYPE_TAG_MUX); G_DEFINE_TYPE (GstId3v2Mux, gst_id3v2_mux, GST_TYPE_TAG_MUX);
#define _do_init \
taglib_element_init (plugin);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (id3v2mux, "id3v2mux",
GST_RANK_NONE, GST_TYPE_ID3V2_MUX, _do_init);
static GstBuffer *gst_id3v2_mux_render_tag (GstTagMux * mux, static GstBuffer *gst_id3v2_mux_render_tag (GstTagMux * mux,
const GstTagList * taglist); const GstTagList * taglist);

View file

@ -0,0 +1,38 @@
/* GStreamer taglib-based muxer base class
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2006 Sebastian Dröge <slomo@circular-chaos.org>
* 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 "gsttaglibelements.h"
#include <gst/tag/tag.h>
void
taglib_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_TAGLIB_ELEMENTS_H__
#define __GST_TAGLIB_ELEMENTS_H__
#include <gst/gst.h>
G_BEGIN_DECLS
void taglib_element_init (GstPlugin * plugin);
GST_ELEMENT_REGISTER_DECLARE (id3v2mux);
GST_ELEMENT_REGISTER_DECLARE (apev2mux);
G_END_DECLS
#endif /* __GST_TAGLIB_ELEMENTS_H__ */

View file

@ -23,23 +23,19 @@
#include <config.h> #include <config.h>
#endif #endif
#include "gstapev2mux.h" #include "gsttaglibelements.h"
#include "gstid3v2mux.h"
#include <gst/tag/tag.h> #include <gst/tag/tag.h>
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
{ {
if (!gst_element_register (plugin, "id3v2mux", GST_RANK_NONE, gboolean ret = FALSE;
GST_TYPE_ID3V2_MUX) ||
!gst_element_register (plugin, "apev2mux", GST_RANK_NONE,
GST_TYPE_APEV2_MUX))
return FALSE;
gst_tag_register_musicbrainz_tags (); ret |= GST_ELEMENT_REGISTER (id3v2mux, plugin);
ret |= GST_ELEMENT_REGISTER (apev2mux, plugin);
return TRUE; return ret;
} }
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View file

@ -1,6 +1,7 @@
taglib_sources = [ taglib_sources = [
'gstapev2mux.cc', 'gstapev2mux.cc',
'gstid3v2mux.cc', 'gstid3v2mux.cc',
'gsttaglibelement.c',
'gsttaglibplugin.c', 'gsttaglibplugin.c',
] ]