mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
visual: split the plugin wrapper and the actual element
This commit is contained in:
parent
0dd87d7eb7
commit
85565952ee
4 changed files with 283 additions and 224 deletions
|
@ -1,6 +1,6 @@
|
||||||
plugin_LTLIBRARIES = libgstlibvisual.la
|
plugin_LTLIBRARIES = libgstlibvisual.la
|
||||||
|
|
||||||
libgstlibvisual_la_SOURCES = visual.c
|
libgstlibvisual_la_SOURCES = plugin.c visual.c
|
||||||
libgstlibvisual_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LIBVISUAL_CFLAGS)
|
libgstlibvisual_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LIBVISUAL_CFLAGS)
|
||||||
libgstlibvisual_la_LIBADD = \
|
libgstlibvisual_la_LIBADD = \
|
||||||
$(top_builddir)/gst-libs/gst/audio/libgstaudio-$(GST_API_VERSION).la \
|
$(top_builddir)/gst-libs/gst/audio/libgstaudio-$(GST_API_VERSION).la \
|
||||||
|
@ -9,3 +9,4 @@ libgstlibvisual_la_LIBADD = \
|
||||||
libgstlibvisual_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
libgstlibvisual_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
libgstlibvisual_la_LIBTOOLFLAGS = --tag=disable-static
|
libgstlibvisual_la_LIBTOOLFLAGS = --tag=disable-static
|
||||||
|
|
||||||
|
noinst_HEADERS = visual.h
|
||||||
|
|
178
ext/libvisual/plugin.c
Normal file
178
ext/libvisual/plugin.c
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
||||||
|
* 2012 Stefan Sauer <ensonic@users.sf.net>
|
||||||
|
*
|
||||||
|
* 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., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "visual.h"
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY (libvisual_debug);
|
||||||
|
#define GST_CAT_DEFAULT (libvisual_debug)
|
||||||
|
|
||||||
|
static void
|
||||||
|
libvisual_log_handler (const char *message, const char *funcname, void *priv)
|
||||||
|
{
|
||||||
|
GST_CAT_LEVEL_LOG (libvisual_debug, (GstDebugLevel) (priv), NULL, "%s - %s",
|
||||||
|
funcname, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Replace invalid chars with _ in the type name
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
make_valid_name (gchar * name)
|
||||||
|
{
|
||||||
|
static const gchar extra_chars[] = "-_+";
|
||||||
|
gchar *p = name;
|
||||||
|
|
||||||
|
for (; *p; p++) {
|
||||||
|
gint valid = ((p[0] >= 'A' && p[0] <= 'Z') ||
|
||||||
|
(p[0] >= 'a' && p[0] <= 'z') ||
|
||||||
|
(p[0] >= '0' && p[0] <= '9') || strchr (extra_chars, p[0]));
|
||||||
|
if (!valid)
|
||||||
|
*p = '_';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_visual_actor_plugin_is_gl (VisObject * plugin, const gchar * name)
|
||||||
|
{
|
||||||
|
gboolean is_gl;
|
||||||
|
gint depth;
|
||||||
|
|
||||||
|
#if !defined(VISUAL_API_VERSION)
|
||||||
|
|
||||||
|
depth = VISUAL_PLUGIN_ACTOR (plugin)->depth;
|
||||||
|
is_gl = (depth == VISUAL_VIDEO_DEPTH_GL);
|
||||||
|
|
||||||
|
#elif VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
|
||||||
|
|
||||||
|
depth = VISUAL_ACTOR_PLUGIN (plugin)->vidoptions.depth;
|
||||||
|
/* FIXME: how to figure this out correctly in 0.4? */
|
||||||
|
is_gl = (depth & VISUAL_VIDEO_DEPTH_GL) == VISUAL_VIDEO_DEPTH_GL;
|
||||||
|
|
||||||
|
#else
|
||||||
|
# error what libvisual version is this?
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!is_gl) {
|
||||||
|
GST_DEBUG ("plugin %s is not a GL plugin (%d), registering", name, depth);
|
||||||
|
} else {
|
||||||
|
GST_DEBUG ("plugin %s is a GL plugin (%d), ignoring", name, depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_gl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
plugin_init (GstPlugin * plugin)
|
||||||
|
{
|
||||||
|
guint i, count;
|
||||||
|
VisList *list;
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (libvisual_debug, "libvisual", 0,
|
||||||
|
"libvisual audio visualisations");
|
||||||
|
|
||||||
|
#ifdef LIBVISUAL_PLUGINSBASEDIR
|
||||||
|
gst_plugin_add_dependency_simple (plugin, "HOME/.libvisual/actor",
|
||||||
|
LIBVISUAL_PLUGINSBASEDIR "/actor", NULL, GST_PLUGIN_DEPENDENCY_FLAG_NONE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
visual_log_set_verboseness (VISUAL_LOG_VERBOSENESS_LOW);
|
||||||
|
visual_log_set_info_handler (libvisual_log_handler, (void *) GST_LEVEL_INFO);
|
||||||
|
visual_log_set_warning_handler (libvisual_log_handler,
|
||||||
|
(void *) GST_LEVEL_WARNING);
|
||||||
|
visual_log_set_critical_handler (libvisual_log_handler,
|
||||||
|
(void *) GST_LEVEL_ERROR);
|
||||||
|
visual_log_set_error_handler (libvisual_log_handler,
|
||||||
|
(void *) GST_LEVEL_ERROR);
|
||||||
|
|
||||||
|
if (!visual_is_initialized ())
|
||||||
|
if (visual_init (NULL, NULL) != 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
list = visual_actor_get_list ();
|
||||||
|
|
||||||
|
#if !defined(VISUAL_API_VERSION)
|
||||||
|
count = visual_list_count (list);
|
||||||
|
#elif VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
|
||||||
|
count = visual_collection_size (VISUAL_COLLECTION (list));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
VisPluginRef *ref = visual_list_get (list, i);
|
||||||
|
VisPluginData *visplugin = NULL;
|
||||||
|
gboolean skip = FALSE;
|
||||||
|
GType type;
|
||||||
|
gchar *name;
|
||||||
|
GTypeInfo info = {
|
||||||
|
sizeof (GstVisualClass),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
gst_visual_class_init,
|
||||||
|
NULL,
|
||||||
|
ref,
|
||||||
|
sizeof (GstVisual),
|
||||||
|
0,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
visplugin = visual_plugin_load (ref);
|
||||||
|
|
||||||
|
if (ref->info->plugname == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Blacklist some plugins */
|
||||||
|
if (strcmp (ref->info->plugname, "gstreamer") == 0 ||
|
||||||
|
strcmp (ref->info->plugname, "gdkpixbuf") == 0) {
|
||||||
|
skip = TRUE;
|
||||||
|
} else {
|
||||||
|
/* Ignore plugins that only support GL output for now */
|
||||||
|
skip = gst_visual_actor_plugin_is_gl (visplugin->info->plugin,
|
||||||
|
visplugin->info->plugname);
|
||||||
|
}
|
||||||
|
|
||||||
|
visual_plugin_unload (visplugin);
|
||||||
|
|
||||||
|
if (!skip) {
|
||||||
|
name = g_strdup_printf ("GstVisual%s", ref->info->plugname);
|
||||||
|
make_valid_name (name);
|
||||||
|
type = g_type_register_static (GST_TYPE_VISUAL, name, &info, 0);
|
||||||
|
g_free (name);
|
||||||
|
|
||||||
|
name = g_strdup_printf ("libvisual_%s", ref->info->plugname);
|
||||||
|
make_valid_name (name);
|
||||||
|
if (!gst_element_register (plugin, name, GST_RANK_NONE, type)) {
|
||||||
|
g_free (name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
g_free (name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||||
|
GST_VERSION_MINOR,
|
||||||
|
libvisual,
|
||||||
|
"libvisual visualization plugins",
|
||||||
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|
|
@ -1,5 +1,6 @@
|
||||||
/* GStreamer
|
/* GStreamer
|
||||||
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
||||||
|
* 2012 Stefan Sauer <ensonic@users.sf.net>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
|
@ -21,25 +22,9 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include "visual.h"
|
||||||
#include <gst/base/gstadapter.h>
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <gst/video/gstvideopool.h>
|
|
||||||
#include <gst/audio/audio.h>
|
|
||||||
#include <libvisual/libvisual.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define GST_TYPE_VISUAL (gst_visual_get_type())
|
GST_DEBUG_CATEGORY_EXTERN (libvisual_debug);
|
||||||
#define GST_IS_VISUAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VISUAL))
|
|
||||||
#define GST_VISUAL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VISUAL,GstVisual))
|
|
||||||
#define GST_IS_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VISUAL))
|
|
||||||
#define GST_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VISUAL,GstVisualClass))
|
|
||||||
#define GST_VISUAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VISUAL, GstVisualClass))
|
|
||||||
|
|
||||||
typedef struct _GstVisual GstVisual;
|
|
||||||
typedef struct _GstVisualClass GstVisualClass;
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (libvisual_debug);
|
|
||||||
#define GST_CAT_DEFAULT (libvisual_debug)
|
#define GST_CAT_DEFAULT (libvisual_debug)
|
||||||
|
|
||||||
/* amounf of samples before we can feed libvisual */
|
/* amounf of samples before we can feed libvisual */
|
||||||
|
@ -50,54 +35,6 @@ GST_DEBUG_CATEGORY_STATIC (libvisual_debug);
|
||||||
#define DEFAULT_FPS_N 25
|
#define DEFAULT_FPS_N 25
|
||||||
#define DEFAULT_FPS_D 1
|
#define DEFAULT_FPS_D 1
|
||||||
|
|
||||||
struct _GstVisual
|
|
||||||
{
|
|
||||||
GstElement element;
|
|
||||||
|
|
||||||
/* pads */
|
|
||||||
GstPad *sinkpad;
|
|
||||||
GstPad *srcpad;
|
|
||||||
GstSegment segment;
|
|
||||||
|
|
||||||
/* libvisual stuff */
|
|
||||||
VisAudio *audio;
|
|
||||||
VisVideo *video;
|
|
||||||
VisActor *actor;
|
|
||||||
|
|
||||||
/* audio/video state */
|
|
||||||
GstAudioInfo info;
|
|
||||||
|
|
||||||
/* framerate numerator & denominator */
|
|
||||||
gint fps_n;
|
|
||||||
gint fps_d;
|
|
||||||
gint width;
|
|
||||||
gint height;
|
|
||||||
GstClockTime duration;
|
|
||||||
guint outsize;
|
|
||||||
GstBufferPool *pool;
|
|
||||||
|
|
||||||
/* samples per frame based on caps */
|
|
||||||
guint spf;
|
|
||||||
|
|
||||||
/* state stuff */
|
|
||||||
GstAdapter *adapter;
|
|
||||||
guint count;
|
|
||||||
|
|
||||||
/* QoS stuff *//* with LOCK */
|
|
||||||
gdouble proportion;
|
|
||||||
GstClockTime earliest_time;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GstVisualClass
|
|
||||||
{
|
|
||||||
GstElementClass parent_class;
|
|
||||||
|
|
||||||
VisPluginRef *plugin;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gst_visual_get_type (void);
|
|
||||||
|
|
||||||
|
|
||||||
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
|
@ -125,7 +62,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
static void gst_visual_class_init (gpointer g_class, gpointer class_data);
|
|
||||||
static void gst_visual_init (GstVisual * visual);
|
static void gst_visual_init (GstVisual * visual);
|
||||||
static void gst_visual_finalize (GObject * object);
|
static void gst_visual_finalize (GObject * object);
|
||||||
|
|
||||||
|
@ -143,8 +80,6 @@ static gboolean gst_visual_src_query (GstPad * pad, GstObject * parent,
|
||||||
|
|
||||||
static gboolean gst_visual_sink_setcaps (GstPad * pad, GstCaps * caps);
|
static gboolean gst_visual_sink_setcaps (GstPad * pad, GstCaps * caps);
|
||||||
static GstCaps *gst_visual_getcaps (GstPad * pad, GstCaps * filter);
|
static GstCaps *gst_visual_getcaps (GstPad * pad, GstCaps * filter);
|
||||||
static void libvisual_log_handler (const char *message, const char *funcname,
|
|
||||||
void *priv);
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
|
|
||||||
|
@ -171,14 +106,7 @@ gst_visual_get_type (void)
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
libvisual_log_handler (const char *message, const char *funcname, void *priv)
|
|
||||||
{
|
|
||||||
GST_CAT_LEVEL_LOG (libvisual_debug, (GstDebugLevel) (priv), NULL, "%s - %s",
|
|
||||||
funcname, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_visual_class_init (gpointer g_class, gpointer class_data)
|
gst_visual_class_init (gpointer g_class, gpointer class_data)
|
||||||
{
|
{
|
||||||
GstVisualClass *klass = GST_VISUAL_CLASS (g_class);
|
GstVisualClass *klass = GST_VISUAL_CLASS (g_class);
|
||||||
|
@ -192,7 +120,7 @@ gst_visual_class_init (gpointer g_class, gpointer class_data)
|
||||||
if (class_data == NULL) {
|
if (class_data == NULL) {
|
||||||
parent_class = g_type_class_peek_parent (g_class);
|
parent_class = g_type_class_peek_parent (g_class);
|
||||||
} else {
|
} else {
|
||||||
char *longname = g_strdup_printf ("libvisual %s plugin v.%s",
|
gchar *longname = g_strdup_printf ("libvisual %s plugin v.%s",
|
||||||
klass->plugin->info->name, klass->plugin->info->version);
|
klass->plugin->info->name, klass->plugin->info->version);
|
||||||
|
|
||||||
/* FIXME: improve to only register what plugin supports? */
|
/* FIXME: improve to only register what plugin supports? */
|
||||||
|
@ -904,8 +832,8 @@ gst_visual_change_state (GstElement * element, GstStateChange transition)
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_NULL_TO_READY:
|
case GST_STATE_CHANGE_NULL_TO_READY:
|
||||||
visual->actor =
|
visual->actor =
|
||||||
visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->
|
visual_actor_new (GST_VISUAL_GET_CLASS (visual)->plugin->info->
|
||||||
info->plugname);
|
plugname);
|
||||||
visual->video = visual_video_new ();
|
visual->video = visual_video_new ();
|
||||||
visual->audio = visual_audio_new ();
|
visual->audio = visual_audio_new ();
|
||||||
/* can't have a play without actors */
|
/* can't have a play without actors */
|
||||||
|
@ -963,146 +891,3 @@ no_realize:
|
||||||
return GST_STATE_CHANGE_FAILURE;
|
return GST_STATE_CHANGE_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
make_valid_name (char *name)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Replace invalid chars with _ in the type name
|
|
||||||
*/
|
|
||||||
static const gchar extra_chars[] = "-_+";
|
|
||||||
gchar *p = name;
|
|
||||||
|
|
||||||
for (; *p; p++) {
|
|
||||||
int valid = ((p[0] >= 'A' && p[0] <= 'Z') ||
|
|
||||||
(p[0] >= 'a' && p[0] <= 'z') ||
|
|
||||||
(p[0] >= '0' && p[0] <= '9') || strchr (extra_chars, p[0]));
|
|
||||||
if (!valid)
|
|
||||||
*p = '_';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_visual_actor_plugin_is_gl (VisObject * plugin, const gchar * name)
|
|
||||||
{
|
|
||||||
gboolean is_gl;
|
|
||||||
gint depth;
|
|
||||||
|
|
||||||
#if !defined(VISUAL_API_VERSION)
|
|
||||||
|
|
||||||
depth = VISUAL_PLUGIN_ACTOR (plugin)->depth;
|
|
||||||
is_gl = (depth == VISUAL_VIDEO_DEPTH_GL);
|
|
||||||
|
|
||||||
#elif VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
|
|
||||||
|
|
||||||
depth = VISUAL_ACTOR_PLUGIN (plugin)->vidoptions.depth;
|
|
||||||
/* FIXME: how to figure this out correctly in 0.4? */
|
|
||||||
is_gl = (depth & VISUAL_VIDEO_DEPTH_GL) == VISUAL_VIDEO_DEPTH_GL;
|
|
||||||
|
|
||||||
#else
|
|
||||||
# error what libvisual version is this?
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!is_gl) {
|
|
||||||
GST_DEBUG ("plugin %s is not a GL plugin (%d), registering", name, depth);
|
|
||||||
} else {
|
|
||||||
GST_DEBUG ("plugin %s is a GL plugin (%d), ignoring", name, depth);
|
|
||||||
}
|
|
||||||
|
|
||||||
return is_gl;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
plugin_init (GstPlugin * plugin)
|
|
||||||
{
|
|
||||||
guint i, count;
|
|
||||||
VisList *list;
|
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_INIT (libvisual_debug, "libvisual", 0,
|
|
||||||
"libvisual audio visualisations");
|
|
||||||
|
|
||||||
#ifdef LIBVISUAL_PLUGINSBASEDIR
|
|
||||||
gst_plugin_add_dependency_simple (plugin, "HOME/.libvisual/actor",
|
|
||||||
LIBVISUAL_PLUGINSBASEDIR "/actor", NULL, GST_PLUGIN_DEPENDENCY_FLAG_NONE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
visual_log_set_verboseness (VISUAL_LOG_VERBOSENESS_LOW);
|
|
||||||
visual_log_set_info_handler (libvisual_log_handler, (void *) GST_LEVEL_INFO);
|
|
||||||
visual_log_set_warning_handler (libvisual_log_handler,
|
|
||||||
(void *) GST_LEVEL_WARNING);
|
|
||||||
visual_log_set_critical_handler (libvisual_log_handler,
|
|
||||||
(void *) GST_LEVEL_ERROR);
|
|
||||||
visual_log_set_error_handler (libvisual_log_handler,
|
|
||||||
(void *) GST_LEVEL_ERROR);
|
|
||||||
|
|
||||||
if (!visual_is_initialized ())
|
|
||||||
if (visual_init (NULL, NULL) != 0)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
list = visual_actor_get_list ();
|
|
||||||
|
|
||||||
#if !defined(VISUAL_API_VERSION)
|
|
||||||
count = visual_list_count (list);
|
|
||||||
#elif VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
|
|
||||||
count = visual_collection_size (VISUAL_COLLECTION (list));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
|
||||||
VisPluginRef *ref = visual_list_get (list, i);
|
|
||||||
VisPluginData *visplugin = NULL;
|
|
||||||
gboolean skip = FALSE;
|
|
||||||
GType type;
|
|
||||||
gchar *name;
|
|
||||||
GTypeInfo info = {
|
|
||||||
sizeof (GstVisualClass),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
gst_visual_class_init,
|
|
||||||
NULL,
|
|
||||||
ref,
|
|
||||||
sizeof (GstVisual),
|
|
||||||
0,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
visplugin = visual_plugin_load (ref);
|
|
||||||
|
|
||||||
if (ref->info->plugname == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* Blacklist some plugins */
|
|
||||||
if (strcmp (ref->info->plugname, "gstreamer") == 0 ||
|
|
||||||
strcmp (ref->info->plugname, "gdkpixbuf") == 0) {
|
|
||||||
skip = TRUE;
|
|
||||||
} else {
|
|
||||||
/* Ignore plugins that only support GL output for now */
|
|
||||||
skip = gst_visual_actor_plugin_is_gl (visplugin->info->plugin,
|
|
||||||
visplugin->info->plugname);
|
|
||||||
}
|
|
||||||
|
|
||||||
visual_plugin_unload (visplugin);
|
|
||||||
|
|
||||||
if (!skip) {
|
|
||||||
name = g_strdup_printf ("GstVisual%s", ref->info->plugname);
|
|
||||||
make_valid_name (name);
|
|
||||||
type = g_type_register_static (GST_TYPE_VISUAL, name, &info, 0);
|
|
||||||
g_free (name);
|
|
||||||
|
|
||||||
name = g_strdup_printf ("libvisual_%s", ref->info->plugname);
|
|
||||||
make_valid_name (name);
|
|
||||||
if (!gst_element_register (plugin, name, GST_RANK_NONE, type)) {
|
|
||||||
g_free (name);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
g_free (name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
||||||
GST_VERSION_MINOR,
|
|
||||||
libvisual,
|
|
||||||
"libvisual visualization plugins",
|
|
||||||
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|
|
||||||
|
|
95
ext/libvisual/visual.h
Normal file
95
ext/libvisual/visual.h
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
||||||
|
* 2012 Stefan Sauer <ensonic@users.sf.net>
|
||||||
|
*
|
||||||
|
* 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., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GST_VISUAL_H__
|
||||||
|
#define __GST_VISUAL_H__
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/base/gstadapter.h>
|
||||||
|
#include <gst/video/video.h>
|
||||||
|
#include <gst/video/gstvideopool.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
|
#include <libvisual/libvisual.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GST_TYPE_VISUAL (gst_visual_get_type())
|
||||||
|
#define GST_IS_VISUAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VISUAL))
|
||||||
|
#define GST_VISUAL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VISUAL,GstVisual))
|
||||||
|
#define GST_IS_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VISUAL))
|
||||||
|
#define GST_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VISUAL,GstVisualClass))
|
||||||
|
#define GST_VISUAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VISUAL, GstVisualClass))
|
||||||
|
|
||||||
|
typedef struct _GstVisual GstVisual;
|
||||||
|
typedef struct _GstVisualClass GstVisualClass;
|
||||||
|
|
||||||
|
struct _GstVisual
|
||||||
|
{
|
||||||
|
GstElement element;
|
||||||
|
|
||||||
|
/* pads */
|
||||||
|
GstPad *sinkpad;
|
||||||
|
GstPad *srcpad;
|
||||||
|
GstSegment segment;
|
||||||
|
|
||||||
|
/* libvisual stuff */
|
||||||
|
VisAudio *audio;
|
||||||
|
VisVideo *video;
|
||||||
|
VisActor *actor;
|
||||||
|
|
||||||
|
/* audio/video state */
|
||||||
|
GstAudioInfo info;
|
||||||
|
|
||||||
|
/* framerate numerator & denominator */
|
||||||
|
gint fps_n;
|
||||||
|
gint fps_d;
|
||||||
|
gint width;
|
||||||
|
gint height;
|
||||||
|
GstClockTime duration;
|
||||||
|
guint outsize;
|
||||||
|
GstBufferPool *pool;
|
||||||
|
|
||||||
|
/* samples per frame based on caps */
|
||||||
|
guint spf;
|
||||||
|
|
||||||
|
/* state stuff */
|
||||||
|
GstAdapter *adapter;
|
||||||
|
guint count;
|
||||||
|
|
||||||
|
/* QoS stuff *//* with LOCK */
|
||||||
|
gdouble proportion;
|
||||||
|
GstClockTime earliest_time;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstVisualClass
|
||||||
|
{
|
||||||
|
GstElementClass parent_class;
|
||||||
|
|
||||||
|
VisPluginRef *plugin;
|
||||||
|
};
|
||||||
|
|
||||||
|
void gst_visual_class_init (gpointer g_class, gpointer class_data);
|
||||||
|
|
||||||
|
GType gst_visual_get_type (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_VISUAL_H__ */
|
||||||
|
|
Loading…
Reference in a new issue