ogg: allow per feature registration

Split plugin into features including
elements and device providers 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/900>
This commit is contained in:
Julian Bouzas 2020-08-11 11:47:02 -04:00 committed by GStreamer Merge Bot
parent 1e02717e83
commit d58cf8b8d3
9 changed files with 106 additions and 160 deletions

View file

@ -37,7 +37,7 @@
#include <ogg/ogg.h> #include <ogg/ogg.h>
#include <string.h> #include <string.h>
#include "gstogg.h" #include "gstoggelements.h"
GST_DEBUG_CATEGORY_STATIC (gst_ogg_avi_parse_debug); GST_DEBUG_CATEGORY_STATIC (gst_ogg_avi_parse_debug);
#define GST_CAT_DEFAULT gst_ogg_avi_parse_debug #define GST_CAT_DEFAULT gst_ogg_avi_parse_debug
@ -72,85 +72,58 @@ struct _GstOggAviParseClass
GstElementClass parent_class; GstElementClass parent_class;
}; };
static void gst_ogg_avi_parse_base_init (gpointer g_class);
static void gst_ogg_avi_parse_class_init (GstOggAviParseClass * klass);
static void gst_ogg_avi_parse_init (GstOggAviParse * ogg);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
static GType G_DEFINE_TYPE (GstOggAviParse, gst_ogg_avi_parse, GST_TYPE_ELEMENT);
gst_ogg_avi_parse_get_type (void)
{
static GType ogg_avi_parse_type = 0;
if (!ogg_avi_parse_type) { #define _do_init \
static const GTypeInfo ogg_avi_parse_info = { GST_DEBUG_CATEGORY_INIT (gst_ogg_avi_parse_debug, "oggaviparse", 0, "ogg avi parser");
sizeof (GstOggAviParseClass), GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (oggaviparse, "oggaviparse",
gst_ogg_avi_parse_base_init, GST_RANK_PRIMARY, GST_TYPE_OGG_AVI_PARSE, _do_init)
NULL,
(GClassInitFunc) gst_ogg_avi_parse_class_init, enum
NULL, {
NULL, PROP_0
sizeof (GstOggAviParse),
0,
(GInstanceInitFunc) gst_ogg_avi_parse_init,
}; };
ogg_avi_parse_type = static GstStaticPadTemplate ogg_avi_parse_src_template_factory =
g_type_register_static (GST_TYPE_ELEMENT, "GstOggAviParse", GST_STATIC_PAD_TEMPLATE ("src",
&ogg_avi_parse_info, 0);
}
return ogg_avi_parse_type;
}
enum
{
PROP_0
};
static GstStaticPadTemplate ogg_avi_parse_src_template_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-vorbis") GST_STATIC_CAPS ("audio/x-vorbis")
); );
static GstStaticPadTemplate ogg_avi_parse_sink_template_factory = static GstStaticPadTemplate ogg_avi_parse_sink_template_factory =
GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
GST_PAD_ALWAYS, GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-ogg-avi") GST_STATIC_CAPS ("application/x-ogg-avi")
); );
static void gst_ogg_avi_parse_finalize (GObject * object); static void gst_ogg_avi_parse_finalize (GObject * object);
static GstStateChangeReturn gst_ogg_avi_parse_change_state (GstElement * static GstStateChangeReturn gst_ogg_avi_parse_change_state (GstElement *
element, GstStateChange transition); element, GstStateChange transition);
static gboolean gst_ogg_avi_parse_event (GstPad * pad, GstObject * parent, static gboolean gst_ogg_avi_parse_event (GstPad * pad, GstObject * parent,
GstEvent * event); GstEvent * event);
static GstFlowReturn gst_ogg_avi_parse_chain (GstPad * pad, GstObject * parent, static GstFlowReturn gst_ogg_avi_parse_chain (GstPad * pad,
GstBuffer * buffer); GstObject * parent, GstBuffer * buffer);
static gboolean gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps); static gboolean gst_ogg_avi_parse_setcaps (GstPad * pad, GstCaps * caps);
static void static void gst_ogg_avi_parse_class_init (GstOggAviParseClass * klass)
gst_ogg_avi_parse_base_init (gpointer g_class)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gst_element_class_set_static_metadata (element_class, gst_element_class_set_static_metadata (gstelement_class,
"Ogg AVI parser", "Codec/Parser", "Ogg AVI parser", "Codec/Parser",
"parse an ogg avi stream into pages (info about ogg: http://xiph.org)", "parse an ogg avi stream into pages (info about ogg: http://xiph.org)",
"Wim Taymans <wim@fluendo.com>"); "Wim Taymans <wim@fluendo.com>");
gst_element_class_add_static_pad_template (element_class, gst_element_class_add_static_pad_template (gstelement_class,
&ogg_avi_parse_sink_template_factory); &ogg_avi_parse_sink_template_factory);
gst_element_class_add_static_pad_template (element_class, gst_element_class_add_static_pad_template (gstelement_class,
&ogg_avi_parse_src_template_factory); &ogg_avi_parse_src_template_factory);
}
static void
gst_ogg_avi_parse_class_init (GstOggAviParseClass * klass)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
@ -476,13 +449,3 @@ gst_ogg_avi_parse_change_state (GstElement * element, GstStateChange transition)
} }
return result; return result;
} }
gboolean
gst_ogg_avi_parse_plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_ogg_avi_parse_debug, "oggaviparse", 0,
"ogg avi parser");
return gst_element_register (plugin, "oggaviparse", GST_RANK_PRIMARY,
GST_TYPE_OGG_AVI_PARSE);
}

View file

@ -44,6 +44,7 @@
#include <gst/tag/tag.h> #include <gst/tag/tag.h>
#include <gst/audio/audio.h> #include <gst/audio/audio.h>
#include "gstoggelements.h"
#include "gstoggdemux.h" #include "gstoggdemux.h"
#define CHUNKSIZE (8500) /* this is out of vorbisfile */ #define CHUNKSIZE (8500) /* this is out of vorbisfile */
@ -2291,10 +2292,16 @@ static GstStateChangeReturn gst_ogg_demux_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
static void gst_ogg_print (GstOggDemux * demux); static void gst_ogg_print (GstOggDemux * demux);
static gboolean gst_ogg_demux_plugin_init (GstPlugin * plugin);
#define gst_ogg_demux_parent_class parent_class #define gst_ogg_demux_parent_class parent_class
G_DEFINE_TYPE (GstOggDemux, gst_ogg_demux, GST_TYPE_ELEMENT); G_DEFINE_TYPE (GstOggDemux, gst_ogg_demux, GST_TYPE_ELEMENT);
#define _do_init \
ret |= gst_ogg_demux_plugin_init (plugin);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (oggdemux, "oggdemux", GST_RANK_PRIMARY,
GST_TYPE_OGG_DEMUX, _do_init);
static void static void
gst_ogg_demux_class_init (GstOggDemuxClass * klass) gst_ogg_demux_class_init (GstOggDemuxClass * klass)
{ {
@ -5253,7 +5260,7 @@ gst_ogg_demux_change_state (GstElement * element, GstStateChange transition)
return result; return result;
} }
gboolean static gboolean
gst_ogg_demux_plugin_init (GstPlugin * plugin) gst_ogg_demux_plugin_init (GstPlugin * plugin)
{ {
GST_DEBUG_CATEGORY_INIT (gst_ogg_demux_debug, "oggdemux", 0, "ogg demuxer"); GST_DEBUG_CATEGORY_INIT (gst_ogg_demux_debug, "oggdemux", 0, "ogg demuxer");
@ -5267,8 +5274,7 @@ gst_ogg_demux_plugin_init (GstPlugin * plugin)
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif #endif
return gst_element_register (plugin, "oggdemux", GST_RANK_PRIMARY, return TRUE;
GST_TYPE_OGG_DEMUX);
} }
/* prints all info about the element */ /* prints all info about the element */

View file

@ -219,8 +219,6 @@ struct _GstOggDemuxClass
GstElementClass parent_class; GstElementClass parent_class;
}; };
gboolean gst_ogg_demux_plugin_init (GstPlugin * plugin);
G_END_DECLS G_END_DECLS
#endif /* __GST_OGG_DEMUX_H__ */ #endif /* __GST_OGG_DEMUX_H__ */

View file

@ -1,7 +1,6 @@
/* GStreamer /* GStreamer
* Copyright (C) 2004 Wim Taymans <wim@fluendo.com> * Copyright (C) 2020 Huawei Technologies Co., Ltd.
* * @Author: Stéphane Cerveau <scerveau@collabora.com>
* gstoggdemux.c: ogg stream demuxer
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -19,13 +18,17 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef __GST_OGG_H__ #ifndef __GST_OGG_ELEMENT_H__
#define __GST_OGG_H__ #define __GST_OGG_ELEMENT_H__
#include <gst/gst.h> #include <gst/gst.h>
gboolean gst_ogm_parse_plugin_init (GstPlugin * plugin); GST_ELEMENT_REGISTER_DECLARE (oggdemux);
gboolean gst_ogg_parse_plugin_init (GstPlugin * plugin); GST_ELEMENT_REGISTER_DECLARE (oggmux);
gboolean gst_ogg_avi_parse_plugin_init (GstPlugin * plugin); GST_ELEMENT_REGISTER_DECLARE (ogmaudioparse);
GST_ELEMENT_REGISTER_DECLARE (ogmvideoparse);
GST_ELEMENT_REGISTER_DECLARE (ogmtextparse);
GST_ELEMENT_REGISTER_DECLARE (oggparse);
GST_ELEMENT_REGISTER_DECLARE (oggaviparse);
#endif /* __GST_OGG_H__ */ #endif /* __GST_OGG_ELEMENT_H__ */

View file

@ -43,6 +43,7 @@
#include <gst/audio/audio.h> #include <gst/audio/audio.h>
#include <gst/tag/tag.h> #include <gst/tag/tag.h>
#include "gstoggelements.h"
#include "gstoggmux.h" #include "gstoggmux.h"
/* memcpy - if someone knows a way to get rid of it, please speak up /* memcpy - if someone knows a way to get rid of it, please speak up
@ -134,10 +135,17 @@ static GstStateChangeReturn gst_ogg_mux_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
/*static guint gst_ogg_mux_signals[LAST_SIGNAL] = { 0 }; */ /*static guint gst_ogg_mux_signals[LAST_SIGNAL] = { 0 }; */
#define gst_ogg_mux_parent_class parent_class #define gst_ogg_mux_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstOggMux, gst_ogg_mux, GST_TYPE_ELEMENT, G_DEFINE_TYPE_WITH_CODE (GstOggMux, gst_ogg_mux, GST_TYPE_ELEMENT,
G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL)); G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
#define _do_init \
GST_DEBUG_CATEGORY_INIT (gst_ogg_mux_debug, "oggmux", 0, "ogg muxer");
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (oggmux, "oggmux", GST_RANK_PRIMARY,
GST_TYPE_OGG_MUX, _do_init);
static void static void
gst_ogg_mux_class_init (GstOggMuxClass * klass) gst_ogg_mux_class_init (GstOggMuxClass * klass)
{ {
@ -2253,12 +2261,3 @@ gst_ogg_mux_change_state (GstElement * element, GstStateChange transition)
return ret; return ret;
} }
gboolean
gst_ogg_mux_plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_ogg_mux_debug, "oggmux", 0, "ogg muxer");
return gst_element_register (plugin, "oggmux", GST_RANK_PRIMARY,
GST_TYPE_OGG_MUX);
}

View file

@ -36,7 +36,7 @@
#include <ogg/ogg.h> #include <ogg/ogg.h>
#include <string.h> #include <string.h>
#include "gstogg.h" #include "gstoggelements.h"
#include "gstoggstream.h" #include "gstoggstream.h"
GST_DEBUG_CATEGORY_STATIC (gst_ogg_parse_debug); GST_DEBUG_CATEGORY_STATIC (gst_ogg_parse_debug);
@ -81,34 +81,14 @@ struct _GstOggParseClass
GstElementClass parent_class; GstElementClass parent_class;
}; };
static void gst_ogg_parse_base_init (gpointer g_class);
static void gst_ogg_parse_class_init (GstOggParseClass * klass);
static void gst_ogg_parse_init (GstOggParse * ogg);
static GstElementClass *parent_class = NULL; static GstElementClass *parent_class = NULL;
G_DEFINE_TYPE (GstOggParse, gst_ogg_parse, GST_TYPE_ELEMENT);
static GType #define _do_init \
gst_ogg_parse_get_type (void) GST_DEBUG_CATEGORY_INIT (gst_ogg_parse_debug, "oggparse", 0, "ogg parser");
{ GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (oggparse, "oggparse", GST_RANK_NONE,
static GType ogg_parse_type = 0; GST_TYPE_OGG_PARSE, _do_init);
if (!ogg_parse_type) {
static const GTypeInfo ogg_parse_info = {
sizeof (GstOggParseClass),
gst_ogg_parse_base_init,
NULL,
(GClassInitFunc) gst_ogg_parse_class_init,
NULL,
NULL,
sizeof (GstOggParse),
0,
(GInstanceInitFunc) gst_ogg_parse_init,
};
ogg_parse_type = g_type_register_static (GST_TYPE_ELEMENT, "GstOggParse",
&ogg_parse_info, 0);
}
return ogg_parse_type;
}
static void static void
free_stream (GstOggStream * stream) free_stream (GstOggStream * stream)
@ -222,28 +202,22 @@ static GstStateChangeReturn gst_ogg_parse_change_state (GstElement * element,
static GstFlowReturn gst_ogg_parse_chain (GstPad * pad, GstObject * parent, static GstFlowReturn gst_ogg_parse_chain (GstPad * pad, GstObject * parent,
GstBuffer * buffer); GstBuffer * buffer);
static void
gst_ogg_parse_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_static_metadata (element_class,
"Ogg parser", "Codec/Parser",
"parse ogg streams into pages (info about ogg: http://xiph.org)",
"Michael Smith <msmith@fluendo.com>");
gst_element_class_add_static_pad_template (element_class,
&ogg_parse_sink_template_factory);
gst_element_class_add_static_pad_template (element_class,
&ogg_parse_src_template_factory);
}
static void static void
gst_ogg_parse_class_init (GstOggParseClass * klass) gst_ogg_parse_class_init (GstOggParseClass * klass)
{ {
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gst_element_class_set_static_metadata (gstelement_class,
"Ogg parser", "Codec/Parser",
"parse ogg streams into pages (info about ogg: http://xiph.org)",
"Michael Smith <msmith@fluendo.com>");
gst_element_class_add_static_pad_template (gstelement_class,
&ogg_parse_sink_template_factory);
gst_element_class_add_static_pad_template (gstelement_class,
&ogg_parse_src_template_factory);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
gstelement_class->change_state = gst_ogg_parse_change_state; gstelement_class->change_state = gst_ogg_parse_change_state;
@ -747,12 +721,3 @@ gst_ogg_parse_change_state (GstElement * element, GstStateChange transition)
} }
return result; return result;
} }
gboolean
gst_ogg_parse_plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_ogg_parse_debug, "oggparse", 0, "ogg parser");
return gst_element_register (plugin, "oggparse", GST_RANK_NONE,
GST_TYPE_OGG_PARSE);
}

View file

@ -23,20 +23,24 @@
#include <gst/gst.h> #include <gst/gst.h>
#include "gstogg.h" #include "gstoggelements.h"
#include "gstoggdemux.h" #include "gstoggdemux.h"
#include "gstoggmux.h" #include "gstoggmux.h"
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
{ {
gst_ogg_demux_plugin_init (plugin); gboolean ret = FALSE;
gst_ogg_mux_plugin_init (plugin);
gst_ogm_parse_plugin_init (plugin);
gst_ogg_parse_plugin_init (plugin);
gst_ogg_avi_parse_plugin_init (plugin);
return TRUE; ret |= GST_ELEMENT_REGISTER (oggdemux, plugin);
ret |= GST_ELEMENT_REGISTER (oggmux, plugin);
ret |= GST_ELEMENT_REGISTER (ogmaudioparse, plugin);
ret |= GST_ELEMENT_REGISTER (ogmvideoparse, plugin);
ret |= GST_ELEMENT_REGISTER (ogmtextparse, plugin);
ret |= GST_ELEMENT_REGISTER (oggparse, plugin);
ret |= GST_ELEMENT_REGISTER (oggaviparse, plugin);
return ret;
} }
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View file

@ -30,7 +30,7 @@
#include <gst/riff/riff-media.h> #include <gst/riff/riff-media.h>
#include <gst/riff/riff-read.h> #include <gst/riff/riff-read.h>
#include "gstogg.h" #include "gstoggelements.h"
GST_DEBUG_CATEGORY_STATIC (gst_ogm_parse_debug); GST_DEBUG_CATEGORY_STATIC (gst_ogm_parse_debug);
#define GST_CAT_DEFAULT gst_ogm_parse_debug #define GST_CAT_DEFAULT gst_ogm_parse_debug
@ -150,6 +150,7 @@ static void gst_ogm_parse_init (GstOgmParse * ogm);
static void gst_ogm_video_parse_init (GstOgmParse * ogm); static void gst_ogm_video_parse_init (GstOgmParse * ogm);
static void gst_ogm_audio_parse_init (GstOgmParse * ogm); static void gst_ogm_audio_parse_init (GstOgmParse * ogm);
static void gst_ogm_text_parse_init (GstOgmParse * ogm); static void gst_ogm_text_parse_init (GstOgmParse * ogm);
static gboolean gst_ogm_parse_element_init (GstPlugin * plugin);
static gboolean gst_ogm_parse_sink_event (GstPad * pad, GstObject * parent, static gboolean gst_ogm_parse_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event); GstEvent * event);
@ -270,6 +271,16 @@ gst_ogm_text_parse_get_type (void)
return ogm_text_parse_type; return ogm_text_parse_type;
} }
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (ogmaudioparse, "ogmaudioparse",
GST_RANK_PRIMARY, GST_TYPE_OGM_AUDIO_PARSE,
gst_ogm_parse_element_init (plugin));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (ogmvideoparse, "ogmvideoparse",
GST_RANK_PRIMARY, GST_TYPE_OGM_VIDEO_PARSE,
gst_ogm_parse_element_init (plugin));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (ogmtextparse, "ogmtextparse",
GST_RANK_PRIMARY, GST_TYPE_OGM_TEXT_PARSE,
gst_ogm_parse_element_init (plugin));
static void static void
gst_ogm_audio_parse_base_init (GstOgmParseClass * klass) gst_ogm_audio_parse_base_init (GstOgmParseClass * klass)
{ {
@ -955,17 +966,14 @@ gst_ogm_parse_change_state (GstElement * element, GstStateChange transition)
return ret; return ret;
} }
gboolean static gboolean
gst_ogm_parse_plugin_init (GstPlugin * plugin) gst_ogm_parse_element_init (GstPlugin * plugin)
{ {
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
gst_riff_init (); gst_riff_init ();
GST_DEBUG_CATEGORY_INIT (gst_ogm_parse_debug, "ogmparse", 0, "ogm parser"); GST_DEBUG_CATEGORY_INIT (gst_ogm_parse_debug, "ogmparse", 0, "ogm parser");
g_once_init_leave (&res, TRUE);
return gst_element_register (plugin, "ogmaudioparse", GST_RANK_PRIMARY, }
GST_TYPE_OGM_AUDIO_PARSE) && return res;
gst_element_register (plugin, "ogmvideoparse", GST_RANK_PRIMARY,
GST_TYPE_OGM_VIDEO_PARSE) &&
gst_element_register (plugin, "ogmtextparse", GST_RANK_PRIMARY,
GST_TYPE_OGM_TEXT_PARSE);
} }

View file

@ -1,7 +1,7 @@
ogg_sources = [ ogg_sources = [
'dirac_parse.c', 'dirac_parse.c',
'gstoggaviparse.c', 'gstoggaviparse.c',
'gstogg.c', 'gstoggplugin.c',
'gstoggdemux.c', 'gstoggdemux.c',
'gstoggmux.c', 'gstoggmux.c',
'gstoggparse.c', 'gstoggparse.c',