flac: 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-11 19:53:30 +01:00
parent 0b257dd1d5
commit 762e3c31b5
7 changed files with 98 additions and 24 deletions

View file

@ -21,36 +21,18 @@
#include "config.h"
#endif
#include "gstflacenc.h"
#include "gstflacdec.h"
#include "gstflactag.h"
#include <gst/tag/tag.h>
#include <gst/gst-i18n-plugin.h>
#include "gstflacelements.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
gboolean ret = FALSE;
if (!gst_element_register (plugin, "flacenc", GST_RANK_PRIMARY,
GST_TYPE_FLAC_ENC))
return FALSE;
if (!gst_element_register (plugin, "flacdec", GST_RANK_PRIMARY,
GST_TYPE_FLAC_DEC))
return FALSE;
if (!gst_element_register (plugin, "flactag", GST_RANK_PRIMARY,
gst_flac_tag_get_type ()))
return FALSE;
ret |= GST_ELEMENT_REGISTER (flacdec, plugin);
ret |= GST_ELEMENT_REGISTER (flacenc, plugin);
ret |= GST_ELEMENT_REGISTER (flactag, plugin);
gst_tag_register_musicbrainz_tags ();
return TRUE;
return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View file

@ -47,6 +47,8 @@
#include <gst/gst-i18n-plugin.h>
#include <gst/tag/tag.h>
#include "gstflacelements.h"
/* Taken from http://flac.sourceforge.net/format.html#frame_header */
static const GstAudioChannelPosition channel_positions[8][8] = {
{GST_AUDIO_CHANNEL_POSITION_MONO},
@ -114,6 +116,9 @@ static GstFlowReturn gst_flac_dec_handle_frame (GstAudioDecoder * audio_dec,
GstBuffer * buf);
G_DEFINE_TYPE (GstFlacDec, gst_flac_dec, GST_TYPE_AUDIO_DECODER);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (flacdec, "flacdec", GST_RANK_PRIMARY,
GST_TYPE_FLAC_DEC, flac_element_init (plugin));
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define FORMATS "{ S8, S16LE, S24_32LE, S32LE } "

43
ext/flac/gstflacelement.c Normal file
View file

@ -0,0 +1,43 @@
/* 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 "gstflacelements.h"
#include <gst/tag/tag.h>
#include <gst/gst-i18n-plugin.h>
void
flac_element_init (GstPlugin * plugin)
{
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif
gst_tag_register_musicbrainz_tags ();
g_once_init_leave (&res, TRUE);
}
}

View file

@ -0,0 +1,36 @@
/*
* 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_FLAC_ELEMENTS_H__
#define __GST_FLAC_ELEMENTS_H__
#include <gst/gst.h>
G_BEGIN_DECLS
void flac_element_init (GstPlugin * plugin);
GST_ELEMENT_REGISTER_DECLARE (flacenc);
GST_ELEMENT_REGISTER_DECLARE (flacdec);
GST_ELEMENT_REGISTER_DECLARE (flactag);
G_END_DECLS
#endif /* __GST_FLAC_ELEMENTS_H__ */

View file

@ -55,6 +55,8 @@
#include <gst/tag/tag.h>
#include <gst/gsttagsetter.h>
#include "gstflacelements.h"
/* Taken from http://flac.sourceforge.net/format.html#frame_header */
static const GstAudioChannelPosition channel_positions[8][8] = {
{GST_AUDIO_CHANNEL_POSITION_MONO},
@ -131,6 +133,8 @@ G_DEFINE_TYPE_WITH_CODE (GstFlacEnc, gst_flac_enc, GST_TYPE_AUDIO_ENCODER,
G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL)
G_IMPLEMENT_INTERFACE (GST_TYPE_TOC_SETTER, NULL)
);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (flacenc, "flacenc", GST_RANK_PRIMARY,
GST_TYPE_FLAC_ENC, flac_element_init (plugin));
static gboolean gst_flac_enc_start (GstAudioEncoder * enc);
static gboolean gst_flac_enc_stop (GstAudioEncoder * enc);

View file

@ -54,6 +54,7 @@
#include <gst/tag/tag.h>
#include <string.h>
#include "gstflacelements.h"
#include "gstflactag.h"
GST_DEBUG_CATEGORY_STATIC (flactag_debug);
@ -89,6 +90,8 @@ static gboolean gst_flac_tag_sink_event (GstPad * pad, GstObject * parent,
#define gst_flac_tag_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstFlacTag, gst_flac_tag, GST_TYPE_ELEMENT,
G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (flactag, "flactag", GST_RANK_PRIMARY,
GST_TYPE_FLAC_TAG, flac_element_init (plugin));
static void

View file

@ -1,5 +1,6 @@
flac_sources = [
'gstflac.c',
'gstflacelement.c',
'gstflacdec.c',
'gstflacenc.c',
'gstflactag.c',