[0.11] gst-editing-services: Add API to get all sources from xptv project

Tim Müller tpm at kemper.freedesktop.org
Tue Mar 13 13:39:46 PDT 2012


Module: gst-editing-services
Branch: 0.11
Commit: ac6f8599fe95d6c662577621db5300af5fcf7bfe
URL:    http://cgit.freedesktop.org/gstreamer/gst-editing-services/commit/?id=ac6f8599fe95d6c662577621db5300af5fcf7bfe

Author: mathieu duponchelle <duponc_m at Meh.(none)>
Date:   Tue Jan  3 11:59:29 2012 +0100

Add API to get all sources from xptv project

---

 bindings/python/ges.defs     |    9 ++++++
 bindings/python/ges.override |   27 ++++++++++++++++++
 ges/ges-pitivi-formatter.c   |   63 ++++++++++++++++++++++++++++++++++++++++++
 ges/ges-pitivi-formatter.h   |    2 +-
 4 files changed, 100 insertions(+), 1 deletions(-)

diff --git a/bindings/python/ges.defs b/bindings/python/ges.defs
index 5536e63..e8c5735 100644
--- a/bindings/python/ges.defs
+++ b/bindings/python/ges.defs
@@ -659,6 +659,15 @@
   (return-type "GESPitiviFormatter*")
 )
 
+(define-method get_sources
+  (of-object "GESPitiviFormatter")
+  (c-name "ges_pitivi_formatter_get_sources")
+  (return-type "GList*")
+  (parameters
+    '("const-gchar*" "uri")
+  )
+)
+
 ;; From ges-timeline-effect.h
 
 (define-function timeline_effect_get_type
diff --git a/bindings/python/ges.override b/bindings/python/ges.override
index e3e68e3..bb4e2c7 100644
--- a/bindings/python/ges.override
+++ b/bindings/python/ges.override
@@ -160,6 +160,33 @@ _wrap_ges_timeline_parse_launch_effect_new(PyGObject *self, PyObject *args, PyOb
 /* I did not override ges_formatter_get_data and set_data for these functions are deprecated */
 
 %%
+override ges_pitivi_formatter_get_sources kwargs
+static PyObject *
+_wrap_ges_pitivi_formatter_get_sources(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    const GList *l, *list;
+    PyObject *py_list;
+    gchar *uri;
+
+    g_return_val_if_fail (GES_IS_PITIVI_FORMATTER (self->obj),PyList_New(0));
+
+    if (!PyArg_ParseTuple(args, "s:GES.TrackObject.lookup_child", &uri))
+        return FALSE;
+    pyg_begin_allow_threads;
+    list = ges_pitivi_formatter_get_sources (GES_PITIVI_FORMATTER (self->obj), uri);
+    pyg_end_allow_threads;
+
+    py_list = PyList_New(0);
+    for (l = list; l; l = l->next) {
+	gchar * source = (gchar *)l->data;
+	PyList_Append(py_list, PyString_FromString(source));
+	Py_DECREF(source);
+    }
+
+    return py_list;
+}
+
+%%
 override ges_timeline_object_get_top_effects noargs
 static PyObject *
 _wrap_ges_timeline_object_get_top_effects(PyGObject *self)
diff --git a/ges/ges-pitivi-formatter.c b/ges/ges-pitivi-formatter.c
index 42ff823..73a3090 100644
--- a/ges/ges-pitivi-formatter.c
+++ b/ges/ges-pitivi-formatter.c
@@ -461,6 +461,69 @@ save_pitivi_timeline_to_uri (GESFormatter * pitivi_formatter,
   return TRUE;
 }
 
+GList *
+ges_pitivi_formatter_get_sources (GESPitiviFormatter * formatter, gchar * uri)
+{
+  GList *source_list = NULL;
+  xmlXPathContextPtr xpathCtx;
+  xmlDocPtr doc;
+  xmlXPathObjectPtr xpathObj;
+  int size, j;
+  xmlNodeSetPtr nodes;
+
+  if (!(doc = xmlParseFile (uri))) {
+    GST_ERROR ("The xptv file for uri %s was badly formed or did not exist",
+        uri);
+    return FALSE;
+  }
+
+  xpathCtx = xmlXPathNewContext (doc);
+
+  xpathObj = xmlXPathEvalExpression ((const xmlChar *)
+      "/pitivi/factories/sources/source", xpathCtx);
+
+  nodes = xpathObj->nodesetval;
+
+  size = (nodes) ? nodes->nodeNr : 0;
+  for (j = 0; j < size; ++j) {
+    xmlAttr *cur_attr;
+    gchar *name, *value;
+    xmlNodePtr node;
+
+    node = nodes->nodeTab[j];
+    for (cur_attr = node->properties; cur_attr; cur_attr = cur_attr->next) {
+      name = (gchar *) cur_attr->name;
+      value = (gchar *) xmlGetProp (node, cur_attr->name);
+      if (!g_strcmp0 (name, (gchar *) "filename"))
+        source_list = g_list_append (source_list, g_strdup (value));
+      xmlFree (value);
+    }
+  }
+
+  xmlXPathFreeObject (xpathObj);
+
+  xpathObj = xmlXPathEvalExpression ((const xmlChar *)
+      "/pitivi/factories/sources/unused_source", xpathCtx);
+
+  nodes = xpathObj->nodesetval;
+
+  size = (nodes) ? nodes->nodeNr : 0;
+  for (j = 0; j < size; ++j) {
+    xmlNodePtr node;
+
+    node = nodes->nodeTab[j];
+    source_list =
+        g_list_append (source_list,
+        g_strdup ((gchar *) xmlNodeGetContent (node)));
+  }
+
+  xmlXPathFreeObject (xpathObj);
+
+  xmlXPathFreeContext (xpathCtx);
+  xmlFreeDoc (doc);
+  return source_list;
+}
+
 /* Project loading functions */
 
 /* Return: a GHashTable containing:
diff --git a/ges/ges-pitivi-formatter.h b/ges/ges-pitivi-formatter.h
index 8965316..44956e3 100644
--- a/ges/ges-pitivi-formatter.h
+++ b/ges/ges-pitivi-formatter.h
@@ -56,6 +56,6 @@ GType ges_pitivi_formatter_get_type (void);
 
 GESPitiviFormatter *ges_pitivi_formatter_new (void);
 
-
+GList * ges_pitivi_formatter_get_sources(GESPitiviFormatter * formatter, gchar * uri);
 
 #endif /* _GES_PITIVI_FORMATTER */



More information about the gstreamer-commits mailing list