mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
gst/:
Original commit message from CVS: * gst/arg-types.py: * gst/gst.defs: * gst/gst.override: GstXML support, based on patch by poelzi.
This commit is contained in:
parent
19ba5c793a
commit
1a232d7366
4 changed files with 142 additions and 3 deletions
|
@ -1,3 +1,11 @@
|
|||
2004-10-11 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
* gst/arg-types.py:
|
||||
* gst/gst.defs:
|
||||
* gst/gst.override:
|
||||
|
||||
GstXML support, based on patch by poelzi.
|
||||
|
||||
2004-10-10 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
|
||||
* gst/gstmodule.c: (init_gst):
|
||||
|
|
|
@ -48,10 +48,66 @@ class GstDataPtrArg(ArgType):
|
|||
info.arglist.append(pname)
|
||||
info.codebefore.append(self.normal % {'name': pname})
|
||||
|
||||
class XmlNodeArg(ArgType):
|
||||
"""libxml2 node generator"""
|
||||
|
||||
names = {"xobj":"xmlNode",
|
||||
"xptr":"xmlNodePtr",
|
||||
"xwrap":"libxml_xmlNodePtrWrap"}
|
||||
|
||||
parm = (' if(xml == NULL) return NULL;\n'
|
||||
' xobj = PyObject_GetAttrString(xml, "%(xobj)s");\n'
|
||||
' if(!PyObject_IsInstance(py%(name)s, xobj)) {\n'
|
||||
' PyErr_Clear();\n'
|
||||
' PyErr_SetString(PyExc_RuntimeError,"%(name)s is not a %(xobj)s instance");\n'
|
||||
' Py_DECREF(xobj);Py_DECREF(xml);\n'
|
||||
' return NULL;\n'
|
||||
' }\n'
|
||||
' o = PyObject_GetAttrString(py%(name)s, "_o");\n'
|
||||
' %(name)s = PyCObject_AsVoidPtr(o);\n')
|
||||
parmp = (' Py_DECREF(o); Py_DECREF(xobj);Py_DECREF(xml);\n')
|
||||
|
||||
ret = (' if(xml == NULL) return NULL;\n')
|
||||
retp = (' xargs = PyTuple_New(1);\n'
|
||||
' xobj = PyObject_GetAttrString(xml, "%(xobj)s");\n'
|
||||
' o = %(xwrap)s(ret);\n'
|
||||
' PyTuple_SetItem(xargs, 0, o);\n'
|
||||
' return PyInstance_New(xobj, xargs, PyDict_New());\n')
|
||||
|
||||
def write_param(self, ptype, pname, pdflt, pnull, info):
|
||||
info.varlist.add('PyObject', '*xml = _gst_get_libxml2_module()')
|
||||
info.varlist.add('PyObject', '*o')
|
||||
info.varlist.add('PyObject', '*xobj')
|
||||
info.varlist.add('PyObject', '*py' + pname)
|
||||
info.varlist.add(self.names["xptr"], pname)
|
||||
#if pnull:
|
||||
info.add_parselist('O', ['&py'+pname], [pname])
|
||||
info.arglist.append(pname)
|
||||
self.names["name"] = pname
|
||||
info.codebefore.append(self.parm %self.names)
|
||||
info.codeafter.append(self.parmp % self.names);
|
||||
def write_return(self, ptype, ownsreturn, info):
|
||||
info.varlist.add('PyObject', '*xml = _gst_get_libxml2_module()')
|
||||
info.varlist.add('PyObject', '*xargs')
|
||||
info.varlist.add('PyObject', '*xobj')
|
||||
info.varlist.add('PyObject', '*o')
|
||||
info.varlist.add(self.names["xptr"], 'ret')
|
||||
info.codebefore.append(self.ret % self.names)
|
||||
info.codeafter.append(self.retp % self.names)
|
||||
|
||||
class XmlDocArg(XmlNodeArg):
|
||||
"""libxml2 doc generator"""
|
||||
names = {"xobj":"xmlDoc",
|
||||
"xptr":"xmlDocPtr",
|
||||
"xwrap":"libxml_xmlDocPtrWrap"}
|
||||
|
||||
|
||||
arg = GstDataPtrArg()
|
||||
matcher.register('GstData*', arg)
|
||||
matcher.register('GstClockTime', UInt64Arg())
|
||||
matcher.register('GstClockTimeDiff', Int64Arg())
|
||||
matcher.register('xmlNodePtr', XmlNodeArg())
|
||||
matcher.register('xmlDocPtr', XmlDocArg())
|
||||
|
||||
arg = PointerArg('gpointer', 'G_TYPE_POINTER')
|
||||
matcher.register('GstClockID', arg)
|
||||
|
|
|
@ -6024,7 +6024,7 @@
|
|||
|
||||
(define-function xml_new
|
||||
(c-name "gst_xml_new")
|
||||
(is-constructor-of "GstXml")
|
||||
(is-constructor-of "GstXML")
|
||||
(return-type "GstXML*")
|
||||
)
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ headers
|
|||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "gstmain.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/gsterror.h>
|
||||
|
@ -89,7 +88,6 @@ ignore-glob
|
|||
gst_interface_*
|
||||
gst_tag_list_get_*
|
||||
gst_value_*
|
||||
gst_xml_*
|
||||
%%
|
||||
ignore
|
||||
gst_alloc_trace_list
|
||||
|
@ -1167,3 +1165,80 @@ _wrap_gst_registry_pool_feature_list(PyGObject *self, PyObject *args)
|
|||
|
||||
return list;
|
||||
}
|
||||
%%
|
||||
override gst_xml_new noargs
|
||||
|
||||
/* libxml2 available check */
|
||||
static PyObject *
|
||||
_gst_get_libxml2_module(void)
|
||||
{
|
||||
PyObject *xml = NULL;
|
||||
|
||||
xml = PyImport_ImportModule("libxml2");
|
||||
if (!xml) {
|
||||
PyErr_Clear();
|
||||
PyErr_SetString(PyExc_RuntimeError,"libxml2 bindings required");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
static int
|
||||
_wrap_gst_xml_new(PyGObject *self)
|
||||
{
|
||||
PyObject *xml = _gst_get_libxml2_module();
|
||||
|
||||
if(!xml)
|
||||
return -1;
|
||||
|
||||
self->obj = (GObject *)gst_xml_new();
|
||||
|
||||
if (!self->obj) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "could not create GstXML object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pygobject_register_wrapper((PyObject *)self);
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override gst_xml_get_topelements noargs
|
||||
static PyObject *
|
||||
_wrap_gst_xml_get_topelements(PyGObject *self)
|
||||
{
|
||||
GList *l, *xml_elements;
|
||||
PyObject *py_list;
|
||||
|
||||
py_list = PyList_New(0);
|
||||
|
||||
xml_elements = gst_xml_get_topelements(GST_XML(self->obj));
|
||||
for (l = xml_elements; l; l = l->next) {
|
||||
GstElement *element = (GstElement*)l->data;
|
||||
|
||||
PyList_Append(py_list, pygobject_new(G_OBJECT(element)));
|
||||
}
|
||||
|
||||
return py_list;
|
||||
}
|
||||
%%
|
||||
override gst_xml_parse_memory kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_xml_parse_memory(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "buffer", "root", NULL };
|
||||
int buffer_len, ret;
|
||||
char *root = NULL;
|
||||
guchar *buffer;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"s#|s:GstXML.parse_memory",
|
||||
kwlist, &buffer, &buffer_len, &root))
|
||||
return NULL;
|
||||
|
||||
ret = gst_xml_parse_memory(GST_XML(self->obj),
|
||||
buffer, buffer_len, root);
|
||||
|
||||
return PyBool_FromLong(ret);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue