matroska: 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-16 11:14:17 +01:00
parent 1166a250fa
commit 859b608acf
10 changed files with 112 additions and 56 deletions

View file

@ -0,0 +1,43 @@
/* GStreamer Matroska muxer/demuxer
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
*
* matroska.c: plugin loader
*
* 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 "gstmatroskaelements.h"
#include "matroska-parse.h"
#include "matroska-read-common.h"
#include <gst/pbutils/pbutils.h>
void
matroska_element_init (GstPlugin * plugin)
{
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
gst_pb_utils_init ();
gst_matroska_register_tags ();
GST_DEBUG_CATEGORY_INIT (matroskareadcommon_debug, "matroskareadcommon", 0,
"Matroska demuxer/parser shared debug");
g_once_init_leave (&res, TRUE);
}
}

View file

@ -0,0 +1,41 @@
/*
* (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Stéphane Cerveau <stephane.cerveau@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_MATROSKA_ELEMENTS_H__
#define __GST_MATROSKA_ELEMENTS_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
G_BEGIN_DECLS
void matroska_element_init (GstPlugin * plugin);
GST_ELEMENT_REGISTER_DECLARE (matroskademux);
GST_ELEMENT_REGISTER_DECLARE (matroskaparse);
GST_ELEMENT_REGISTER_DECLARE (matroskamux);
GST_ELEMENT_REGISTER_DECLARE (webmmux);
G_END_DECLS
#endif /* __GST_MATROSKA_ELEMENTS_H__ */

View file

@ -66,6 +66,7 @@
#include <gst/pbutils/pbutils.h>
#include <gst/video/video.h>
#include "gstmatroskaelements.h"
#include "matroska-demux.h"
#include "matroska-ids.h"
@ -195,6 +196,13 @@ static void gst_matroska_demux_get_property (GObject * object,
GType gst_matroska_demux_get_type (void);
#define parent_class gst_matroska_demux_parent_class
G_DEFINE_TYPE (GstMatroskaDemux, gst_matroska_demux, GST_TYPE_ELEMENT);
#define _do_init \
gst_riff_init (); \
matroska_element_init (plugin); \
GST_DEBUG_CATEGORY_INIT (ebmlread_debug, "ebmlread", 0, "EBML stream helper class");
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (matroskademux, "matroskademux",
GST_RANK_PRIMARY, GST_TYPE_MATROSKA_DEMUX, _do_init);
static void
gst_matroska_demux_finalize (GObject * object)
@ -7303,20 +7311,3 @@ gst_matroska_track_encoding_scope_name (gint val)
en = g_enum_get_value (G_ENUM_CLASS (enum_class), val);
return en ? en->value_nick : NULL;
}
gboolean
gst_matroska_demux_plugin_init (GstPlugin * plugin)
{
gst_riff_init ();
/* parser helper separate debug */
GST_DEBUG_CATEGORY_INIT (ebmlread_debug, "ebmlread",
0, "EBML stream helper class");
/* create an elementfactory for the matroska_demux element */
if (!gst_element_register (plugin, "matroskademux",
GST_RANK_PRIMARY, GST_TYPE_MATROSKA_DEMUX))
return FALSE;
return TRUE;
}

View file

@ -135,8 +135,6 @@ typedef struct _GstMatroskaDemuxClass {
GstElementClass parent;
} GstMatroskaDemuxClass;
gboolean gst_matroska_demux_plugin_init (GstPlugin *plugin);
G_END_DECLS
#endif /* __GST_MATROSKA_DEMUX_H__ */

View file

@ -55,6 +55,7 @@
#include <gst/tag/tag.h>
#include <gst/pbutils/codec-utils.h>
#include "gstmatroskaelements.h"
#include "matroska-mux.h"
#include "matroska-ids.h"
@ -299,6 +300,9 @@ gst_matroska_mux_get_type (void)
return object_type;
}
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (matroskamux, "matroskamux",
GST_RANK_PRIMARY, GST_TYPE_MATROSKA_MUX, matroska_element_init (plugin));
static void
gst_matroska_mux_class_init (GstMatroskaMuxClass * klass)
{

View file

@ -63,6 +63,7 @@
#include <gst/pbutils/pbutils.h>
#include "gstmatroskaelements.h"
#include "matroska-parse.h"
#include "matroska-ids.h"
@ -141,6 +142,11 @@ static GstCaps *gst_matroska_parse_forge_caps (gboolean is_webm,
GType gst_matroska_parse_get_type (void);
#define parent_class gst_matroska_parse_parent_class
G_DEFINE_TYPE (GstMatroskaParse, gst_matroska_parse, GST_TYPE_ELEMENT);
#define _do_init \
gst_riff_init (); \
matroska_element_init (plugin);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (matroskaparse, "matroskaparse",
GST_RANK_NONE, GST_TYPE_MATROSKA_PARSE, _do_init);
static void
gst_matroska_parse_finalize (GObject * object)
@ -3264,16 +3270,3 @@ gst_matroska_parse_change_state (GstElement * element,
return ret;
}
gboolean
gst_matroska_parse_plugin_init (GstPlugin * plugin)
{
gst_riff_init ();
/* create an elementfactory for the matroska_parse element */
if (!gst_element_register (plugin, "matroskaparse",
GST_RANK_NONE, GST_TYPE_MATROSKA_PARSE))
return FALSE;
return TRUE;
}

View file

@ -98,8 +98,6 @@ typedef struct _GstMatroskaParseClass {
GstElementClass parent;
} GstMatroskaParseClass;
gboolean gst_matroska_parse_plugin_init (GstPlugin *plugin);
G_END_DECLS
#endif /* __GST_MATROSKA_PARSE_H__ */

View file

@ -23,33 +23,17 @@
#include "config.h"
#endif
#include "matroska-demux.h"
#include "matroska-parse.h"
#include "matroska-read-common.h"
#include "matroska-mux.h"
#include "matroska-ids.h"
#include "webm-mux.h"
#include <gst/pbutils/pbutils.h>
#include "gstmatroskaelements.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean ret;
gboolean ret = FALSE;
gst_pb_utils_init ();
gst_matroska_register_tags ();
GST_DEBUG_CATEGORY_INIT (matroskareadcommon_debug, "matroskareadcommon", 0,
"Matroska demuxer/parser shared debug");
ret = gst_matroska_demux_plugin_init (plugin);
ret &= gst_matroska_parse_plugin_init (plugin);
ret &= gst_element_register (plugin, "matroskamux", GST_RANK_PRIMARY,
GST_TYPE_MATROSKA_MUX);
ret &= gst_element_register (plugin, "webmmux", GST_RANK_PRIMARY,
GST_TYPE_WEBM_MUX);
ret |= GST_ELEMENT_REGISTER (matroskademux, plugin);
ret |= GST_ELEMENT_REGISTER (matroskaparse, plugin);
ret |= GST_ELEMENT_REGISTER (matroskamux, plugin);
ret |= GST_ELEMENT_REGISTER (webmmux, plugin);
return ret;
}

View file

@ -1,6 +1,7 @@
matroska_sources = [
'ebml-read.c',
'ebml-write.c',
'gstmatroskaelement.c',
'matroska.c',
'matroska-demux.c',
'matroska-parse.c',

View file

@ -42,6 +42,7 @@
#include "config.h"
#endif
#include "gstmatroskaelements.h"
#include "webm-mux.h"
#define COMMON_VIDEO_CAPS \
@ -54,6 +55,8 @@
"rate = (int) [ 1, MAX ]"
G_DEFINE_TYPE (GstWebMMux, gst_webm_mux, GST_TYPE_MATROSKA_MUX);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (webmmux, "webmmux",
GST_RANK_PRIMARY, GST_TYPE_WEBM_MUX, matroska_element_init (plugin));
static GstStaticPadTemplate webm_src_templ = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,