GESTrackObject: add a ges_track_object_lookup_child method
authorThibault Saunier <thibault.saunier@collabora.co.uk>
Fri, 25 Feb 2011 10:32:44 +0000 (11:32 +0100)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Fri, 6 May 2011 08:39:05 +0000 (10:39 +0200)
docs/libs/ges-sections.txt
ges/ges-track-object.c
ges/ges-track-object.h

index 82035bcf3b7aaf8f73f71a68ae6c12a9291c36c0..ae4695a37d109db1e016d932dfebc5aec49db252 100644 (file)
@@ -83,6 +83,7 @@ ges_track_object_get_inpoint
 ges_track_object_get_duration
 ges_track_object_get_priority
 ges_track_object_is_active
+ges_track_object_lookup_child
 ges_track_object_set_child_property
 ges_track_object_get_child_property
 <SUBSECTION Standard>
index 312363a2abd0bc06700877502363c2f9d86bf23b..a5c716a393eee404c7bb7f8464324c9d9d9cf69a 100644 (file)
@@ -988,6 +988,68 @@ ges_track_object_is_active (GESTrackObject * object)
     return object->active;
 }
 
+/*
+ * ges_track_object_lookup_child:
+ * @object: object to lookup the property in
+ * @prop_name: name of the property to look up. You can specify the name of the
+ *     class as such: ClassName::property-name, to guarantee that you get the
+ *     proper GParamSpec in case various GstElement-s contain the same property
+ *     name. If you don't do so, you will get the first element found, having
+ *     this property and the and the corresponding GParamSpec.
+ * @element: (out) (allow-none) (transfer full): pointer to a #GstElement that
+ *     takes the real object to set property on
+ * @pspec: (out) (allow-none) (transfer full): pointer to take the #GParamSpec
+ *     describing the property
+ *
+ * Looks up which @element and @pspec would be effected by the given @name. If various
+ * contained elements have this property name you will get the first one, unless you
+ * specify the class name in @name.
+ *
+ * Returns: TRUE if @element and @pspec could be found. FALSE otherwise. In that
+ * case the values for @pspec and @element are not modified. Unref @element after
+ * usage.
+ */
+gboolean
+ges_track_object_lookup_child (GESTrackObject * object, const gchar * prop_name,
+    GstElement ** element, GParamSpec ** pspec)
+{
+  GHashTableIter iter;
+  gpointer key, value;
+  gchar **names, *name, *classename;
+  gboolean res;
+  GESTrackObjectPrivate *priv = object->priv;
+
+  classename = NULL;
+  res = FALSE;
+
+  names = g_strsplit (prop_name, "::", 2);
+  if (names[1] != NULL) {
+    classename = names[0];
+    name = names[1];
+  } else
+    name = names[0];
+
+  g_hash_table_iter_init (&iter, priv->properties_hashtable);
+  while (g_hash_table_iter_next (&iter, &key, &value)) {
+    if (g_strcmp0 (G_PARAM_SPEC (key)->name, name) == 0) {
+      if (classename == NULL ||
+          g_strcmp0 (G_OBJECT_TYPE_NAME (G_OBJECT (value)), classename) == 0) {
+        GST_DEBUG ("The %s property from %s has been found in %s", name,
+            classename, GST_OBJECT_NAME (GST_OBJECT (element)));
+        if (element)
+          *element = g_object_ref (value);
+
+        *pspec = g_param_spec_ref (key);
+        res = TRUE;
+        break;
+      }
+    }
+  }
+  g_strfreev (names);
+
+  return res;
+}
+
 /**
  * ges_track_object_set_child_property:
  * @object: a #GESTrackObject
index e2fcea263bbc770cfae6b46d44cb48ece86eb0db..64c693ced9d65652aa0cae7cea60a006b925acfb 100644 (file)
@@ -161,8 +161,9 @@ guint64 ges_track_object_get_duration (GESTrackObject * object);
 guint32 ges_track_object_get_priority (GESTrackObject * object);
 gboolean ges_track_object_is_active (GESTrackObject * object);
 
-void ges_track_object_set_child_property (GESTrackObject * object,
-    const gchar * property_name, GValue * value);
+gboolean ges_track_object_lookup_child (GESTrackObject *object,
+     const gchar *prop_name, GstElement **element, GParamSpec **pspec);
+
 void ges_track_object_get_child_property (GESTrackObject *object,
                                           const gchar *property_name,
                                           gpointer value);