2010-11-05 11:12:24 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2010 Thibault Saunier <tsaunier@gnome.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
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-11-05 11:12:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-01-26 15:35:19 +00:00
|
|
|
* SECTION:ges-base-effect
|
2013-01-17 03:35:39 +00:00
|
|
|
* @short_description: adds an effect to a stream in a GESSourceClip or a
|
2010-11-05 11:12:24 +00:00
|
|
|
* #GESTimelineLayer
|
|
|
|
*/
|
|
|
|
|
2011-02-23 19:30:04 +00:00
|
|
|
#include <glib/gprintf.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2010-11-05 11:12:24 +00:00
|
|
|
#include "ges-internal.h"
|
2013-01-26 15:31:33 +00:00
|
|
|
#include "ges-track-element.h"
|
2013-01-26 15:35:19 +00:00
|
|
|
#include "ges-base-effect.h"
|
2010-11-05 11:12:24 +00:00
|
|
|
|
2013-01-27 15:27:19 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE (GESBaseEffect, ges_base_effect, GES_TYPE_OPERATION);
|
2010-11-05 11:12:24 +00:00
|
|
|
|
2013-01-26 15:35:19 +00:00
|
|
|
static GHashTable *ges_base_effect_get_props_hashtable (GESTrackElement * self);
|
2011-02-23 19:30:04 +00:00
|
|
|
guint pspec_hash (gconstpointer key_spec);
|
|
|
|
static gboolean pspec_equal (gconstpointer key_spec_1,
|
|
|
|
gconstpointer key_spec_2);
|
2011-02-16 17:35:02 +00:00
|
|
|
|
2013-01-26 15:35:19 +00:00
|
|
|
struct _GESBaseEffectPrivate
|
2010-11-05 11:12:24 +00:00
|
|
|
{
|
2011-02-10 11:17:50 +00:00
|
|
|
void *nothing;
|
2010-11-05 11:12:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2013-01-26 15:35:19 +00:00
|
|
|
ges_base_effect_class_init (GESBaseEffectClass * klass)
|
2010-11-05 11:12:24 +00:00
|
|
|
{
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElementClass *obj_bg_class = GES_TRACK_ELEMENT_CLASS (klass);
|
2011-02-16 17:35:02 +00:00
|
|
|
|
2013-01-26 15:35:19 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GESBaseEffectPrivate));
|
2011-02-16 17:35:02 +00:00
|
|
|
|
2013-01-26 15:35:19 +00:00
|
|
|
obj_bg_class->get_props_hastable = ges_base_effect_get_props_hashtable;
|
2010-11-05 11:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-26 15:35:19 +00:00
|
|
|
ges_base_effect_init (GESBaseEffect * self)
|
2010-11-05 11:12:24 +00:00
|
|
|
{
|
|
|
|
self->priv =
|
2013-01-26 15:35:19 +00:00
|
|
|
G_TYPE_INSTANCE_GET_PRIVATE (self, GES_TYPE_BASE_EFFECT,
|
|
|
|
GESBaseEffectPrivate);
|
2010-11-05 11:12:24 +00:00
|
|
|
}
|
2011-02-16 17:35:02 +00:00
|
|
|
|
2011-02-23 19:30:04 +00:00
|
|
|
static gboolean
|
|
|
|
pspec_equal (gconstpointer key_spec_1, gconstpointer key_spec_2)
|
|
|
|
{
|
|
|
|
const GParamSpec *key1 = key_spec_1;
|
|
|
|
const GParamSpec *key2 = key_spec_2;
|
|
|
|
|
|
|
|
return (key1->owner_type == key2->owner_type &&
|
|
|
|
strcmp (key1->name, key2->name) == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
guint
|
|
|
|
pspec_hash (gconstpointer key_spec)
|
|
|
|
{
|
|
|
|
const GParamSpec *key = key_spec;
|
|
|
|
const gchar *p;
|
|
|
|
guint h = key->owner_type;
|
|
|
|
|
|
|
|
for (p = key->name; *p; p++)
|
|
|
|
h = (h << 5) - h + *p;
|
|
|
|
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
2011-02-16 17:35:02 +00:00
|
|
|
/* Virtual methods */
|
|
|
|
static GHashTable *
|
2013-01-26 15:35:19 +00:00
|
|
|
ges_base_effect_get_props_hashtable (GESTrackElement * self)
|
2011-02-16 17:35:02 +00:00
|
|
|
{
|
2011-10-11 07:51:35 +00:00
|
|
|
GValue item = { 0, };
|
2011-02-16 17:35:02 +00:00
|
|
|
GstIterator *it;
|
|
|
|
GParamSpec **parray;
|
|
|
|
GObjectClass *class;
|
2011-02-23 19:30:04 +00:00
|
|
|
const gchar *klass;
|
2011-02-16 17:35:02 +00:00
|
|
|
GstElementFactory *factory;
|
2011-05-07 11:40:11 +00:00
|
|
|
GstElement *element;
|
2011-02-16 17:35:02 +00:00
|
|
|
gboolean done = FALSE;
|
|
|
|
GHashTable *ret = NULL;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
element = ges_track_element_get_element (self);
|
2011-02-16 17:35:02 +00:00
|
|
|
if (!element) {
|
|
|
|
GST_DEBUG
|
|
|
|
("Can't build the property hashtable until the gnlobject is created");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-23 19:30:04 +00:00
|
|
|
ret = g_hash_table_new_full ((GHashFunc) pspec_hash, pspec_equal,
|
2011-05-07 11:22:50 +00:00
|
|
|
(GDestroyNotify) g_param_spec_unref, gst_object_unref);
|
2011-02-16 17:35:02 +00:00
|
|
|
|
|
|
|
/* We go over child elements recursivly, and add writable properties to the
|
|
|
|
* hashtable
|
|
|
|
* FIXME: Add a blacklist of properties */
|
|
|
|
it = gst_bin_iterate_recurse (GST_BIN (element));
|
2011-05-07 11:40:11 +00:00
|
|
|
|
2011-02-16 17:35:02 +00:00
|
|
|
while (!done) {
|
2011-10-11 07:51:35 +00:00
|
|
|
switch (gst_iterator_next (it, &item)) {
|
2011-02-16 17:35:02 +00:00
|
|
|
case GST_ITERATOR_OK:
|
2011-05-07 11:40:11 +00:00
|
|
|
{
|
|
|
|
gchar **categories;
|
|
|
|
guint category;
|
2011-10-11 07:51:35 +00:00
|
|
|
GstElement *child = g_value_get_object (&item);
|
2011-05-07 11:40:11 +00:00
|
|
|
|
2011-02-16 17:35:02 +00:00
|
|
|
factory = gst_element_get_factory (child);
|
2012-11-17 00:10:20 +00:00
|
|
|
klass = gst_element_factory_get_metadata (factory,
|
|
|
|
GST_ELEMENT_METADATA_KLASS);
|
2011-05-07 11:40:11 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Looking at element '%s' of klass '%s'",
|
|
|
|
GST_ELEMENT_NAME (child), klass);
|
|
|
|
|
2011-02-16 17:35:02 +00:00
|
|
|
categories = g_strsplit (klass, "/", 0);
|
|
|
|
|
2011-05-07 11:40:11 +00:00
|
|
|
for (category = 0; categories[category]; category++) {
|
|
|
|
if (g_strcmp0 (categories[category], "Effect") == 0) {
|
|
|
|
guint i, nb_specs;
|
2011-02-16 17:35:02 +00:00
|
|
|
|
|
|
|
class = G_OBJECT_GET_CLASS (child);
|
|
|
|
parray = g_object_class_list_properties (class, &nb_specs);
|
|
|
|
for (i = 0; i < nb_specs; i++) {
|
|
|
|
if (parray[i]->flags & G_PARAM_WRITABLE) {
|
2011-02-23 19:30:04 +00:00
|
|
|
g_hash_table_insert (ret, g_param_spec_ref (parray[i]),
|
2011-05-07 11:25:06 +00:00
|
|
|
gst_object_ref (child));
|
2011-02-16 17:35:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-06 20:21:22 +00:00
|
|
|
g_free (parray);
|
|
|
|
|
2011-05-07 11:40:11 +00:00
|
|
|
GST_DEBUG
|
|
|
|
("%d configurable properties of '%s' added to property hashtable",
|
|
|
|
nb_specs, GST_ELEMENT_NAME (child));
|
2011-02-16 17:35:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-05-07 11:40:11 +00:00
|
|
|
|
2011-02-16 17:35:02 +00:00
|
|
|
g_strfreev (categories);
|
2011-10-11 07:51:35 +00:00
|
|
|
g_value_reset (&item);
|
2011-02-16 17:35:02 +00:00
|
|
|
break;
|
2011-05-07 11:40:11 +00:00
|
|
|
}
|
2011-02-16 17:35:02 +00:00
|
|
|
case GST_ITERATOR_RESYNC:
|
2011-05-07 11:40:11 +00:00
|
|
|
/* FIXME, properly restart the process */
|
2011-02-16 17:35:02 +00:00
|
|
|
GST_DEBUG ("iterator resync");
|
|
|
|
gst_iterator_resync (it);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GST_ITERATOR_DONE:
|
|
|
|
GST_DEBUG ("iterator done");
|
|
|
|
done = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-10-11 07:51:35 +00:00
|
|
|
g_value_unset (&item);
|
2011-02-16 17:35:02 +00:00
|
|
|
gst_iterator_free (it);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|