Add API to get all sources from xptv project

This commit is contained in:
mathieu duponchelle 2012-01-03 11:59:29 +01:00 committed by Thibault Saunier
parent 2376c313a1
commit ac6f8599fe
4 changed files with 100 additions and 1 deletions

View file

@ -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

View file

@ -159,6 +159,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 *

View file

@ -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:

View file

@ -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 */