1 /* GStreamer Editing Services
2 * Copyright (C) 2010 Thibault Saunier <tsaunier@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * SECTION:ges-track-effect
22 * @short_description: adds an effect to a stream in a #GESTimelineSource or a
28 #include <glib/gprintf.h>
31 #include "ges-internal.h"
32 #include "ges-track-object.h"
33 #include "ges-track-effect.h"
35 G_DEFINE_ABSTRACT_TYPE (GESTrackEffect, ges_track_effect,
36 GES_TYPE_TRACK_OPERATION);
38 static GHashTable *ges_track_effect_get_props_hashtable (GESTrackObject * self);
39 guint pspec_hash (gconstpointer key_spec);
40 static gboolean pspec_equal (gconstpointer key_spec_1,
41 gconstpointer key_spec_2);
43 struct _GESTrackEffectPrivate
49 ges_track_effect_class_init (GESTrackEffectClass * klass)
51 GESTrackObjectClass *obj_bg_class = GES_TRACK_OBJECT_CLASS (klass);
53 g_type_class_add_private (klass, sizeof (GESTrackEffectPrivate));
55 obj_bg_class->get_props_hastable = ges_track_effect_get_props_hashtable;
59 ges_track_effect_init (GESTrackEffect * self)
62 G_TYPE_INSTANCE_GET_PRIVATE (self, GES_TYPE_TRACK_EFFECT,
63 GESTrackEffectPrivate);
67 pspec_equal (gconstpointer key_spec_1, gconstpointer key_spec_2)
69 const GParamSpec *key1 = key_spec_1;
70 const GParamSpec *key2 = key_spec_2;
72 return (key1->owner_type == key2->owner_type &&
73 strcmp (key1->name, key2->name) == 0);
77 pspec_hash (gconstpointer key_spec)
79 const GParamSpec *key = key_spec;
81 guint h = key->owner_type;
83 for (p = key->name; *p; p++)
84 h = (h << 5) - h + *p;
91 ges_track_effect_get_props_hashtable (GESTrackObject * self)
98 GstElementFactory *factory;
100 gboolean done = FALSE;
101 GHashTable *ret = NULL;
103 element = ges_track_object_get_element (self);
106 ("Can't build the property hashtable until the gnlobject is created");
110 ret = g_hash_table_new_full ((GHashFunc) pspec_hash, pspec_equal,
111 (GDestroyNotify) g_param_spec_unref, gst_object_unref);
113 /* We go over child elements recursivly, and add writable properties to the
115 * FIXME: Add a blacklist of properties */
116 it = gst_bin_iterate_recurse (GST_BIN (element));
119 switch (gst_iterator_next (it, &item)) {
120 case GST_ITERATOR_OK:
124 GstElement *child = g_value_get_object (&item);
126 factory = gst_element_get_factory (child);
127 klass = gst_element_factory_get_klass (factory);
129 GST_DEBUG ("Looking at element '%s' of klass '%s'",
130 GST_ELEMENT_NAME (child), klass);
132 categories = g_strsplit (klass, "/", 0);
134 for (category = 0; categories[category]; category++) {
135 if (g_strcmp0 (categories[category], "Effect") == 0) {
138 class = G_OBJECT_GET_CLASS (child);
139 parray = g_object_class_list_properties (class, &nb_specs);
140 for (i = 0; i < nb_specs; i++) {
141 if (parray[i]->flags & G_PARAM_WRITABLE) {
142 g_hash_table_insert (ret, g_param_spec_ref (parray[i]),
143 gst_object_ref (child));
149 ("%d configurable properties of '%s' added to property hashtable",
150 nb_specs, GST_ELEMENT_NAME (child));
155 g_strfreev (categories);
156 g_value_reset (&item);
159 case GST_ITERATOR_RESYNC:
160 /* FIXME, properly restart the process */
161 GST_DEBUG ("iterator resync");
162 gst_iterator_resync (it);
165 case GST_ITERATOR_DONE:
166 GST_DEBUG ("iterator done");
174 g_value_unset (&item);
175 gst_iterator_free (it);