avi: 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 13:38:21 +01:00
parent 277daa8286
commit 434955e0ff
7 changed files with 100 additions and 20 deletions

View file

@ -23,32 +23,18 @@
#include "config.h"
#endif
#include "gst/gst-i18n-plugin.h"
#include "gstavidemux.h"
#include "gstavimux.h"
#include "gstavisubtitle.h"
#include "gstavielements.h"
static gboolean
plugin_init (GstPlugin * plugin)
{
gst_riff_init ();
gboolean ret = FALSE;
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
ret |= GST_ELEMENT_REGISTER (avidemux, plugin);
ret |= GST_ELEMENT_REGISTER (avimux, plugin);
ret |= GST_ELEMENT_REGISTER (avisubtitle, plugin);
if (!gst_element_register (plugin, "avidemux", GST_RANK_PRIMARY,
GST_TYPE_AVI_DEMUX) ||
!gst_element_register (plugin, "avimux", GST_RANK_PRIMARY,
GST_TYPE_AVI_MUX) ||
!gst_element_register (plugin, "avisubtitle", GST_RANK_PRIMARY,
GST_TYPE_AVI_SUBTITLE)) {
return FALSE;
}
return TRUE;
return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,

View file

@ -47,6 +47,7 @@
#include <stdio.h>
#include "gst/riff/riff-media.h"
#include "gstavielements.h"
#include "gstavidemux.h"
#include "avi-ids.h"
#include <gst/gst-i18n-plugin.h>
@ -132,6 +133,8 @@ static void parse_tag_value (GstAviDemux * avi, GstTagList * taglist,
#define gst_avi_demux_parent_class parent_class
G_DEFINE_TYPE (GstAviDemux, gst_avi_demux, GST_TYPE_ELEMENT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (avidemux, "avidemux", GST_RANK_PRIMARY,
GST_TYPE_AVI_DEMUX, avi_element_init (plugin));
static void
gst_avi_demux_class_init (GstAviDemuxClass * klass)

44
gst/avi/gstavielement.c Normal file
View file

@ -0,0 +1,44 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@temple-baptist.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 "gst/gst-i18n-plugin.h"
#include "gst/riff/riff-read.h"
#include "gstavielements.h"
void
avi_element_init (GstPlugin * plugin)
{
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
gst_riff_init ();
#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
g_once_init_leave (&res, TRUE);
}
}

40
gst/avi/gstavielements.h Normal file
View file

@ -0,0 +1,40 @@
/*
* Copyright (C) <1999> Erik Walthinsen <omega@temple-baptist.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_AVI_ELEMENTS_H__
#define __GST_AVI_ELEMENTS_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
G_BEGIN_DECLS
void avi_element_init (GstPlugin * plugin);
GST_ELEMENT_REGISTER_DECLARE (avidemux);
GST_ELEMENT_REGISTER_DECLARE (avimux);
GST_ELEMENT_REGISTER_DECLARE (avisubtitle);
G_END_DECLS
#endif /* __GST_AVI_ELEMENT_H__ */

View file

@ -69,6 +69,7 @@
#include <gst/audio/audio.h>
#include <gst/base/gstbytewriter.h>
#include "gstavielements.h"
#include "gstavimux.h"
GST_DEBUG_CATEGORY_STATIC (avimux_debug);
@ -202,6 +203,8 @@ static GstStateChangeReturn gst_avi_mux_change_state (GstElement * element,
#define gst_avi_mux_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstAviMux, gst_avi_mux, GST_TYPE_ELEMENT,
G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL));
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (avimux, "avimux", GST_RANK_PRIMARY,
GST_TYPE_AVI_MUX, avi_element_init (plugin));
static void
gst_avi_mux_finalize (GObject * object)

View file

@ -53,6 +53,7 @@
#include <string.h>
#include "gstavielements.h"
#include "gstavisubtitle.h"
GST_DEBUG_CATEGORY_STATIC (avisubtitle_debug);
@ -80,6 +81,8 @@ static gboolean gst_avi_subtitle_send_event (GstElement * element,
#define gst_avi_subtitle_parent_class parent_class
G_DEFINE_TYPE (GstAviSubtitle, gst_avi_subtitle, GST_TYPE_ELEMENT);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (avisubtitle, "avisubtitle",
GST_RANK_PRIMARY, GST_TYPE_AVI_SUBTITLE, avi_element_init (plugin));
#define IS_BOM_UTF8(data) ((GST_READ_UINT32_BE(data) >> 8) == 0xEFBBBF)
#define IS_BOM_UTF16_BE(data) (GST_READ_UINT16_BE(data) == 0xFEFF)

View file

@ -1,4 +1,5 @@
avi_sources = [
'gstavielement.c',
'gstavi.c',
'gstavimux.c',
'gstavidemux.c',