mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
gdk_pixbuf: 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:
parent
e4d26e69d3
commit
f86147cb6d
7 changed files with 144 additions and 68 deletions
|
@ -27,6 +27,7 @@
|
|||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gstgdkpixbufelements.h"
|
||||
#include "gstgdkpixbufdec.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gdkpixbufdec_debug);
|
||||
|
@ -74,6 +75,9 @@ static gboolean gst_gdk_pixbuf_dec_sink_event (GstPad * pad, GstObject * parent,
|
|||
|
||||
#define gst_gdk_pixbuf_dec_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstGdkPixbufDec, gst_gdk_pixbuf_dec, GST_TYPE_ELEMENT);
|
||||
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (gdkpixbufdec, "gdkpixbufdec",
|
||||
GST_RANK_SECONDARY, GST_TYPE_GDK_PIXBUF_DEC,
|
||||
gdk_pixbuf_element_init (plugin));
|
||||
|
||||
static gboolean
|
||||
gst_gdk_pixbuf_dec_sink_setcaps (GstGdkPixbufDec * filter, GstCaps * caps)
|
||||
|
|
89
ext/gdk_pixbuf/gstgdkpixbufelement.c
Normal file
89
ext/gdk_pixbuf/gstgdkpixbufelement.c
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* GStreamer GdkPixbuf plugin
|
||||
* Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* Copyright (C) 2003 David A. Schleef <ds@schleef.org>
|
||||
*
|
||||
* 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.h>
|
||||
|
||||
#include "gstgdkpixbufelements.h"
|
||||
|
||||
#if 0
|
||||
static void gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore);
|
||||
|
||||
#define GST_GDK_PIXBUF_TYPE_FIND_SIZE 1024
|
||||
|
||||
static void
|
||||
gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore)
|
||||
{
|
||||
guint8 *data;
|
||||
GdkPixbufLoader *pixbuf_loader;
|
||||
GdkPixbufFormat *format;
|
||||
|
||||
data = gst_type_find_peek (tf, 0, GST_GDK_PIXBUF_TYPE_FIND_SIZE);
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
GST_DEBUG ("creating new loader");
|
||||
|
||||
pixbuf_loader = gdk_pixbuf_loader_new ();
|
||||
|
||||
gdk_pixbuf_loader_write (pixbuf_loader, data, GST_GDK_PIXBUF_TYPE_FIND_SIZE,
|
||||
NULL);
|
||||
|
||||
format = gdk_pixbuf_loader_get_format (pixbuf_loader);
|
||||
|
||||
if (format != NULL) {
|
||||
GstCaps *caps;
|
||||
gchar **p;
|
||||
gchar **mlist = gdk_pixbuf_format_get_mime_types (format);
|
||||
|
||||
for (p = mlist; *p; ++p) {
|
||||
GST_DEBUG ("suggesting mime type %s", *p);
|
||||
caps = gst_caps_new_simple (*p, NULL);
|
||||
gst_type_find_suggest (tf, GST_TYPE_FIND_MINIMUM, caps);
|
||||
gst_caps_free (caps);
|
||||
}
|
||||
g_strfreev (mlist);
|
||||
}
|
||||
|
||||
GST_DEBUG ("closing pixbuf loader, hope it doesn't hang ...");
|
||||
/* librsvg 2.4.x has a bug where it triggers an endless loop in trying
|
||||
to close a gzip that's not an svg; fixed upstream but no good way
|
||||
to work around it */
|
||||
gdk_pixbuf_loader_close (pixbuf_loader, NULL);
|
||||
GST_DEBUG ("closed pixbuf loader");
|
||||
g_object_unref (G_OBJECT (pixbuf_loader));
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
gdk_pixbuf_element_init (GstPlugin * plugin)
|
||||
{
|
||||
static gsize res = FALSE;
|
||||
if (g_once_init_enter (&res)) {
|
||||
#if 0
|
||||
gst_type_find_register (plugin, "image/*", GST_RANK_MARGINAL,
|
||||
gst_gdk_pixbuf_type_find, NULL, GST_CAPS_ANY, NULL);
|
||||
#endif
|
||||
g_once_init_leave (&res, TRUE);
|
||||
}
|
||||
}
|
37
ext/gdk_pixbuf/gstgdkpixbufelements.h
Normal file
37
ext/gdk_pixbuf/gstgdkpixbufelements.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* Copyright (C) 2003 David A. Schleef <ds@schleef.org>
|
||||
* 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_GDK_PIXBUF_ELEMENTS_H__
|
||||
#define __GST_GDK_PIXBUF_ELEMENTS_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
void gdk_pixbuf_element_init (GstPlugin * plugin);
|
||||
|
||||
GST_ELEMENT_REGISTER_DECLARE (gdkpixbufdec);
|
||||
GST_ELEMENT_REGISTER_DECLARE (gdkpixbufoverlay);
|
||||
GST_ELEMENT_REGISTER_DECLARE (gdkpixbufsink);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_GDK_PIXBUF_ELEMENTS_H__ */
|
|
@ -49,6 +49,7 @@
|
|||
#include <gst/gst.h>
|
||||
#include "gstgdkpixbufoverlay.h"
|
||||
|
||||
#include "gstgdkpixbufelements.h"
|
||||
#include <gst/video/gstvideometa.h>
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gdkpixbufoverlay_debug);
|
||||
|
@ -113,6 +114,9 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
|
||||
G_DEFINE_TYPE (GstGdkPixbufOverlay, gst_gdk_pixbuf_overlay,
|
||||
GST_TYPE_VIDEO_FILTER);
|
||||
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (gdkpixbufoverlay, "gdkpixbufoverlay",
|
||||
GST_RANK_NONE, GST_TYPE_GDK_PIXBUF_OVERLAY,
|
||||
gdk_pixbuf_element_init (plugin));
|
||||
|
||||
#define GST_TYPE_GDK_PIXBUF_POSITIONING_MODE \
|
||||
(gst_gdk_pixbuf_positioning_mode_get_type())
|
||||
|
|
|
@ -24,81 +24,19 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "gstgdkpixbufdec.h"
|
||||
#include "gstgdkpixbufoverlay.h"
|
||||
#include "gstgdkpixbufsink.h"
|
||||
#include "gstgdkpixbufelements.h"
|
||||
|
||||
|
||||
#if 0
|
||||
static void gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore);
|
||||
|
||||
#define GST_GDK_PIXBUF_TYPE_FIND_SIZE 1024
|
||||
|
||||
static void
|
||||
gst_gdk_pixbuf_type_find (GstTypeFind * tf, gpointer ignore)
|
||||
{
|
||||
guint8 *data;
|
||||
GdkPixbufLoader *pixbuf_loader;
|
||||
GdkPixbufFormat *format;
|
||||
|
||||
data = gst_type_find_peek (tf, 0, GST_GDK_PIXBUF_TYPE_FIND_SIZE);
|
||||
if (data == NULL)
|
||||
return;
|
||||
|
||||
GST_DEBUG ("creating new loader");
|
||||
|
||||
pixbuf_loader = gdk_pixbuf_loader_new ();
|
||||
|
||||
gdk_pixbuf_loader_write (pixbuf_loader, data, GST_GDK_PIXBUF_TYPE_FIND_SIZE,
|
||||
NULL);
|
||||
|
||||
format = gdk_pixbuf_loader_get_format (pixbuf_loader);
|
||||
|
||||
if (format != NULL) {
|
||||
GstCaps *caps;
|
||||
gchar **p;
|
||||
gchar **mlist = gdk_pixbuf_format_get_mime_types (format);
|
||||
|
||||
for (p = mlist; *p; ++p) {
|
||||
GST_DEBUG ("suggesting mime type %s", *p);
|
||||
caps = gst_caps_new_simple (*p, NULL);
|
||||
gst_type_find_suggest (tf, GST_TYPE_FIND_MINIMUM, caps);
|
||||
gst_caps_free (caps);
|
||||
}
|
||||
g_strfreev (mlist);
|
||||
}
|
||||
|
||||
GST_DEBUG ("closing pixbuf loader, hope it doesn't hang ...");
|
||||
/* librsvg 2.4.x has a bug where it triggers an endless loop in trying
|
||||
to close a gzip that's not an svg; fixed upstream but no good way
|
||||
to work around it */
|
||||
gdk_pixbuf_loader_close (pixbuf_loader, NULL);
|
||||
GST_DEBUG ("closed pixbuf loader");
|
||||
g_object_unref (G_OBJECT (pixbuf_loader));
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
if (!gst_element_register (plugin, "gdkpixbufdec", GST_RANK_SECONDARY,
|
||||
GST_TYPE_GDK_PIXBUF_DEC))
|
||||
return FALSE;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
#if 0
|
||||
gst_type_find_register (plugin, "image/*", GST_RANK_MARGINAL,
|
||||
gst_gdk_pixbuf_type_find, NULL, GST_CAPS_ANY, NULL);
|
||||
#endif
|
||||
ret |= GST_ELEMENT_REGISTER (gdkpixbufdec, plugin);
|
||||
ret |= GST_ELEMENT_REGISTER (gdkpixbufoverlay, plugin);
|
||||
ret |= GST_ELEMENT_REGISTER (gdkpixbufsink, plugin);
|
||||
|
||||
if (!gst_element_register (plugin, "gdkpixbufoverlay", GST_RANK_NONE,
|
||||
GST_TYPE_GDK_PIXBUF_OVERLAY))
|
||||
return FALSE;
|
||||
|
||||
if (!gst_element_register (plugin, "gdkpixbufsink", GST_RANK_NONE,
|
||||
GST_TYPE_GDK_PIXBUF_SINK))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstgdkpixbufelements.h"
|
||||
#include "gstgdkpixbufsink.h"
|
||||
|
||||
#include <gst/video/video.h>
|
||||
|
@ -101,6 +102,8 @@ enum
|
|||
|
||||
|
||||
G_DEFINE_TYPE (GstGdkPixbufSink, gst_gdk_pixbuf_sink, GST_TYPE_VIDEO_SINK);
|
||||
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (gdkpixbufsink, "gdkpixbufsink",
|
||||
GST_RANK_NONE, GST_TYPE_GDK_PIXBUF_SINK, gdk_pixbuf_element_init (plugin));
|
||||
|
||||
static void gst_gdk_pixbuf_sink_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
pixbuf_sources = [
|
||||
'gstgdkpixbufdec.c',
|
||||
'gstgdkpixbufoverlay.c',
|
||||
'gstgdkpixbufelement.c',
|
||||
'gstgdkpixbufplugin.c',
|
||||
'gstgdkpixbufsink.c',
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue