flv: 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-15 17:37:09 +01:00
parent 1f8dd4029b
commit 6fdbe19b3f
6 changed files with 132 additions and 22 deletions

View file

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include "gstflvelements.h"
#include "gstflvdemux.h" #include "gstflvdemux.h"
#include "gstflvmux.h" #include "gstflvmux.h"
@ -85,11 +86,10 @@ static GstStaticPadTemplate video_src_template =
"video/x-h264, stream-format=avc;") "video/x-h264, stream-format=avc;")
); );
GST_DEBUG_CATEGORY_STATIC (flvdemux_debug);
#define GST_CAT_DEFAULT flvdemux_debug
#define gst_flv_demux_parent_class parent_class #define gst_flv_demux_parent_class parent_class
G_DEFINE_TYPE (GstFlvDemux, gst_flv_demux, GST_TYPE_ELEMENT); G_DEFINE_TYPE (GstFlvDemux, gst_flv_demux, GST_TYPE_ELEMENT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (flvdemux, "flvdemux",
GST_RANK_PRIMARY, GST_TYPE_FLV_DEMUX, flv_element_init (plugin));
/* 9 bytes of header + 4 bytes of first previous tag size */ /* 9 bytes of header + 4 bytes of first previous tag size */
#define FLV_HEADER_SIZE 13 #define FLV_HEADER_SIZE 13
@ -3777,21 +3777,3 @@ gst_flv_demux_init (GstFlvDemux * demux)
gst_flv_demux_cleanup (demux); gst_flv_demux_cleanup (demux);
} }
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (flvdemux_debug, "flvdemux", 0, "FLV demuxer");
if (!gst_element_register (plugin, "flvdemux", GST_RANK_PRIMARY,
gst_flv_demux_get_type ()) ||
!gst_element_register (plugin, "flvmux", GST_RANK_PRIMARY,
gst_flv_mux_get_type ()))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR,
flv, "FLV muxing and demuxing plugin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

43
gst/flv/gstflvelement.c Normal file
View file

@ -0,0 +1,43 @@
/*
* Copyright (C) <2007> Julien Moutte <julien@moutte.net>
* Copyright (c) 2008,2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* Copyright (c) 2008-2017 Collabora Ltd
* @author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
* @author: Vincent Penquerc'h <vincent.penquerch@collabora.com>
* 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstflvelements.h"
GST_DEBUG_CATEGORY_STATIC (flvdemux_debug);
#define GST_CAT_DEFAULT flvdemux_debug
void
flv_element_init (GstPlugin * plugin)
{
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
GST_DEBUG_CATEGORY_INIT (flvdemux_debug, "flvdemux", 0, "FLV demuxer");
g_once_init_leave (&res, TRUE);
}
}

43
gst/flv/gstflvelements.h Normal file
View file

@ -0,0 +1,43 @@
/*
* Copyright (C) <2007> Julien Moutte <julien@moutte.net>
* Copyright (c) 2008,2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* Copyright (c) 2008-2017 Collabora Ltd
* @author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
* @author: Vincent Penquerc'h <vincent.penquerch@collabora.com>
* 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_FLV_ELEMENTS_H__
#define __GST_FLV_ELEMENTS_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
G_BEGIN_DECLS
void flv_element_init (GstPlugin * plugin);
GST_ELEMENT_REGISTER_DECLARE (flvdemux);
GST_ELEMENT_REGISTER_DECLARE (flvmux);
G_END_DECLS
#endif /* __GST_FLV_ELEMENTS_H__ */

View file

@ -43,6 +43,7 @@
#include <gst/audio/audio.h> #include <gst/audio/audio.h>
#include "gstflvelements.h"
#include "gstflvmux.h" #include "gstflvmux.h"
#include "amfdefs.h" #include "amfdefs.h"
@ -97,6 +98,8 @@ G_DEFINE_TYPE (GstFlvMuxPad, gst_flv_mux_pad, GST_TYPE_AGGREGATOR_PAD);
#define gst_flv_mux_parent_class parent_class #define gst_flv_mux_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstFlvMux, gst_flv_mux, GST_TYPE_AGGREGATOR, G_DEFINE_TYPE_WITH_CODE (GstFlvMux, gst_flv_mux, GST_TYPE_AGGREGATOR,
G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL)); G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (flvmux, "flvmux",
GST_RANK_PRIMARY, GST_TYPE_FLV_MUX, flv_element_init (plugin));
static GstFlowReturn static GstFlowReturn
gst_flv_mux_aggregate (GstAggregator * aggregator, gboolean timeout); gst_flv_mux_aggregate (GstAggregator * aggregator, gboolean timeout);

39
gst/flv/gstflvplugin.c Normal file
View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2020 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 "gstflvelements.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean ret = FALSE;
ret |= GST_ELEMENT_REGISTER (flvdemux, plugin);
ret |= GST_ELEMENT_REGISTER (flvmux, plugin);
return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR,
flv, "FLV muxing and demuxing plugin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)

View file

@ -1,5 +1,5 @@
gstflv = library('gstflv', gstflv = library('gstflv',
'gstflvdemux.c', 'gstflvmux.c', 'gstflvdemux.c', 'gstflvmux.c', 'gstflvplugin.c','gstflvelement.c',
c_args : gst_plugins_good_args, c_args : gst_plugins_good_args,
include_directories : [configinc, libsinc], include_directories : [configinc, libsinc],
dependencies : [gstpbutils_dep, gstvideo_dep, gsttag_dep, gstaudio_dep], dependencies : [gstpbutils_dep, gstvideo_dep, gsttag_dep, gstaudio_dep],