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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1029>
This commit is contained in:
Stéphane Cerveau 2020-12-11 16:59:50 +01:00 committed by GStreamer Marge Bot
parent cd5d4b025d
commit 5e728ee5b5
6 changed files with 89 additions and 14 deletions

View file

@ -21,26 +21,17 @@
#include <config.h>
#endif
#include "gstopusdec.h"
#include "gstopusenc.h"
#include <gst/tag/tag.h>
#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;
ret |= GST_ELEMENT_REGISTER (opusenc, plugin);
ret |= GST_ELEMENT_REGISTER (opusdec, plugin);
if (!gst_element_register (plugin, "opusdec", GST_RANK_PRIMARY,
GST_TYPE_OPUS_DEC))
return FALSE;
gst_tag_register_musicbrainz_tags ();
return TRUE;
return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View file

@ -46,6 +46,7 @@
#include <math.h>
#include <string.h>
#include <stdio.h>
#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.)

39
ext/opus/gstopuselement.c Normal file
View file

@ -0,0 +1,39 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
* 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstopuselements.h"
#include <gst/tag/tag.h>
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);
}
}

View file

@ -0,0 +1,37 @@
/*
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
* 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_OPUS_ELEMENTS_H__
#define __GST_OPUS_ELEMENTS_H__
#include <gst/gst.h>
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__ */

View file

@ -52,6 +52,8 @@
#include <gst/pbutils/pbutils.h>
#include <gst/tag/tag.h>
#include <gst/glib-compat-private.h>
#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)

View file

@ -1,5 +1,6 @@
opus_sources = [
'gstopus.c',
'gstopuselement.c',
'gstopuscommon.c',
'gstopusdec.c',
'gstopusenc.c',