python bindings: add arg type for GstRTSPUrl

This commit is contained in:
Alessandro Decina 2011-04-20 10:17:07 +02:00
parent 61ae57cbdf
commit 8ab79b0f4b

View file

@ -145,6 +145,54 @@ class GstIteratorArg(ArgType):
info.varlist.add('GstIterator', '*ret')
info.codeafter.append(' return pygst_iterator_new(ret);')
class GstRTSPUrlArg(ArgType):
"""GstRTSPUrl node generator"""
before = (' parse_result = gst_rtsp_url_parse (py_%(name)s, &%(name)s);\n'
' if (parse_result != GST_RTSP_OK) {\n'
' PyErr_SetString(PyExc_TypeError, "invalid url");\n'
' return NULL;\n'
' }')
beforenull = (' if (py_%(name)s == NULL)\n'
' %(name)s = NULL;\n'
' else\n'
' ' + before)
after = (' if (%(name)s)\n'
' gst_rtsp_url_free (%(name)s);\n')
def write_param(self, ptype, pname, pdflt, pnull, keeprefcount, info):
if ptype in ('const-GstRTSPUrl*', 'GstRTSPUrl*'):
self.write_normal_param(pname, pdflt, pnull, info)
else:
raise RuntimeError, "write_param not implemented for %s" % ptype
def write_normal_param(self, pname, pdflt, pnull, info):
info.varlist.add('GstRTSPResult', 'parse_result')
if pdflt:
assert pdflt == 'NULL'
info.varlist.add('const char', '*py_' + pname + ' = NULL')
else:
info.varlist.add('const char', '*py_' + pname)
info.varlist.add('GstRTSPUrl', '*'+pname)
info.add_parselist('s', ['&py_'+pname], [pname])
info.arglist.append(pname)
if pnull:
info.codebefore.append (self.beforenull % { 'name' : pname })
else:
info.codebefore.append (self.before % { 'name' : pname })
info.codeafter.append (self.after % { 'name' : pname })
def write_return(self, ptype, ownsreturn, info):
if ptype == 'GstRTSPUrl*':
info.varlist.add('GstRTSPUrl', '*ret')
copyval = 'FALSE'
elif ptype == 'const-GstRTSPUrl*':
info.varlist.add('const GstRTSPUrl', '*ret')
copyval = 'TRUE'
else:
raise RuntimeError, "write_return not implemented for %s" % ptype
info.codeafter.append(' return pyg_boxed_new (GST_TYPE_CAPS, ret, '+copyval+', TRUE);')
class GstMiniObjectParam(Parameter):
def get_c_type(self):
@ -343,6 +391,8 @@ matcher.register('GstCaps', GstCapsArg()) #FIXME: does this work?
matcher.register('GstCaps*', GstCapsArg()) #FIXME: does this work?
matcher.register('const-GstCaps*', GstCapsArg())
matcher.register('GstIterator*', GstIteratorArg())
matcher.register('const-GstRTSPUrl*', GstRTSPUrlArg())
matcher.register('GstRTSPUrl*', GstRTSPUrlArg())
arg = PointerArg('gpointer', 'G_TYPE_POINTER')
matcher.register('GstClockID', arg)