mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
Keep only the testsuite as we are now using GObject Introspection for bindings
This commit is contained in:
parent
1b3a68c10c
commit
a4b7a67f84
114 changed files with 13 additions and 39566 deletions
53
Makefile.am
53
Makefile.am
|
@ -1,68 +1,19 @@
|
|||
SUBDIRS = common codegen gst examples plugin testsuite pkgconfig
|
||||
|
||||
common_cflags = $(PYTHON_INCLUDES) $(PYGOBJECT_CFLAGS) $(GST_CFLAGS) $(GST_OPTION_CFLAGS) -fno-strict-aliasing
|
||||
common_libadd = $(GST_LIBS) $(GST_OPTION_LIBS)
|
||||
common_ldflags = -module -avoid-version
|
||||
SUBDIRS = common examples testsuite
|
||||
|
||||
# include before EXTRA_DIST for win32 assignment
|
||||
include $(top_srcdir)/common/win32.mak
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4 -I common/m4
|
||||
|
||||
pyexec_LTLIBRARIES =
|
||||
|
||||
if HAVE_PYGOBJECT_2_16
|
||||
pyexec_LTLIBRARIES += gstoption.la
|
||||
endif
|
||||
|
||||
# GStreamer option bindings
|
||||
gstoption_la_CFLAGS = $(common_cflags)
|
||||
gstoption_la_LIBADD = $(common_libadd)
|
||||
gstoption_la_LDFLAGS = $(common_ldflags) \
|
||||
-export-symbols-regex "^(initgstoption|_PyGObject_API).*"
|
||||
gstoption_la_SOURCES = gstoptionmodule.c
|
||||
|
||||
EXTRA_DIST = \
|
||||
gstlibtoolimporter.py \
|
||||
pygst.py.in \
|
||||
gst-python.spec.in \
|
||||
gst-python.spec \
|
||||
RELEASE gst-python.doap \
|
||||
$(win32)
|
||||
|
||||
BUILT_SOURCES = pygst.py
|
||||
CLEANFILES = pygst.py pygst.pyc
|
||||
|
||||
include $(top_srcdir)/common/release.mak
|
||||
|
||||
pygst.py: $(top_srcdir)/pygst.py.in Makefile
|
||||
if test -f $@; then chmod +w $@; fi
|
||||
sed -e "s|@PYGSTDIR\@|$(shell pwd)|g" \
|
||||
-e "s|@GST_MAJORMINOR\@|$(GST_MAJORMINOR)|g" \
|
||||
$< > $@
|
||||
chmod -w $@
|
||||
|
||||
# rewrite pygst path in installed pygst.py, install pth file.
|
||||
# they go in pyexecdir, should make 64bit users happy
|
||||
install-exec-local: Makefile
|
||||
$(mkinstalldirs) $(DESTDIR)$(pyexecdir)
|
||||
sed -e "s|@PYGSTDIR\@|$(PYEXECDIR)/gst-$(GST_MAJORMINOR)|g" \
|
||||
-e "s|@GST_MAJORMINOR\@|$(GST_MAJORMINOR)|g" \
|
||||
$(srcdir)/pygst.py.in > $(DESTDIR)$(pyexecdir)/pygst.py
|
||||
chmod 644 $(DESTDIR)$(pyexecdir)/pygst.py
|
||||
echo "gst-$(GST_MAJORMINOR)" > $(DESTDIR)$(pyexecdir)/pygst.pth
|
||||
|
||||
uninstall-local:
|
||||
@rm $(DESTDIR)/$(pyexecdir)/pygst.py > /dev/null 2>&1 || true
|
||||
@rm $(DESTDIR)/$(pyexecdir)/pygst.pth > /dev/null 2>&1 || true
|
||||
|
||||
check-valgrind:
|
||||
cd testsuite/ && make check-valgrind
|
||||
|
||||
check-torture:
|
||||
@true
|
||||
|
||||
include $(top_srcdir)/common/coverage/lcov.mak
|
||||
#include $(top_srcdir)/common/coverage/lcov.mak
|
||||
|
||||
CRUFT_FILES = \
|
||||
$(top_builddir)/common/shave \
|
||||
|
|
1
codegen/.gitignore
vendored
1
codegen/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
*.pyc
|
|
@ -1,15 +0,0 @@
|
|||
EXTRA_DIST = \
|
||||
argtypes.py \
|
||||
code-coverage.py \
|
||||
codegen.py \
|
||||
definitions.py \
|
||||
defsparser.py \
|
||||
docextract.py \
|
||||
docgen.py \
|
||||
h2def.py \
|
||||
__init__.py \
|
||||
mergedefs.py \
|
||||
mkskel.py \
|
||||
override.py \
|
||||
reversewrapper.py \
|
||||
scmexpr.py
|
|
@ -1,15 +0,0 @@
|
|||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
|
||||
__all__ = [
|
||||
'argtypes',
|
||||
'codegen',
|
||||
'definitions',
|
||||
'defsparser',
|
||||
'docextract',
|
||||
'docgen',
|
||||
'h2def',
|
||||
'mergedefs',
|
||||
'mkskel',
|
||||
'override',
|
||||
'scmexpr'
|
||||
]
|
1085
codegen/argtypes.py
1085
codegen/argtypes.py
File diff suppressed because it is too large
Load diff
|
@ -1,42 +0,0 @@
|
|||
from __future__ import generators
|
||||
import sys, os
|
||||
|
||||
def read_symbols(file, type=None, dynamic=0):
|
||||
if dynamic:
|
||||
cmd = 'nm -D %s' % file
|
||||
else:
|
||||
cmd = 'nm %s' % file
|
||||
for line in os.popen(cmd, 'r'):
|
||||
if line[0] != ' ': # has an address as first bit of line
|
||||
while line[0] != ' ':
|
||||
line = line[1:]
|
||||
while line[0] == ' ':
|
||||
line = line[1:]
|
||||
# we should be up to "type symbolname" now
|
||||
sym_type = line[0]
|
||||
symbol = line[1:].strip()
|
||||
|
||||
if not type or type == sym_type:
|
||||
yield symbol
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
sys.stderr.write('usage: coverage-check library.so wrapper.so\n')
|
||||
sys.exit(1)
|
||||
library = sys.argv[1]
|
||||
wrapper = sys.argv[2]
|
||||
|
||||
# first create a dict with all referenced symbols in the wrapper
|
||||
# should really be a set, but a dict will do ...
|
||||
wrapper_symbols = {}
|
||||
for symbol in read_symbols(wrapper, type='U', dynamic=1):
|
||||
wrapper_symbols[symbol] = 1
|
||||
|
||||
# now go through the library looking for matches on the defined symbols:
|
||||
for symbol in read_symbols(library, type='T', dynamic=1):
|
||||
if symbol[0] == '_': continue
|
||||
if symbol not in wrapper_symbols:
|
||||
print symbol
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
1577
codegen/codegen.py
1577
codegen/codegen.py
File diff suppressed because it is too large
Load diff
|
@ -1,607 +0,0 @@
|
|||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
import copy
|
||||
import sys
|
||||
|
||||
def get_valid_scheme_definitions(defs):
|
||||
return [x for x in defs if isinstance(x, tuple) and len(x) >= 2]
|
||||
|
||||
def unescape(s):
|
||||
s = s.replace('\r\n', '\\r\\n').replace('\t', '\\t')
|
||||
return s.replace('\r', '\\r').replace('\n', '\\n')
|
||||
|
||||
def make_docstring(lines):
|
||||
return "(char *) " + '\n'.join(['"%s"' % unescape(s) for s in lines])
|
||||
|
||||
# New Parameter class, wich emulates a tuple for compatibility reasons
|
||||
class Parameter(object):
|
||||
def __init__(self, ptype, pname, pdflt, pnull, pdir=None, keeprefcount = False):
|
||||
self.ptype = ptype
|
||||
self.pname = pname
|
||||
self.pdflt = pdflt
|
||||
self.pnull = pnull
|
||||
self.pdir = pdir
|
||||
self.keeprefcount = keeprefcount
|
||||
|
||||
def __len__(self): return 4
|
||||
def __getitem__(self, i):
|
||||
return (self.ptype, self.pname, self.pdflt, self.pnull)[i]
|
||||
|
||||
def merge(self, old):
|
||||
if old.pdflt is not None:
|
||||
self.pdflt = old.pdflt
|
||||
if old.pnull is not None:
|
||||
self.pnull = old.pnull
|
||||
|
||||
# Parameter for property based constructors
|
||||
class Property(object):
|
||||
def __init__(self, pname, optional, argname):
|
||||
self.pname = pname
|
||||
self.optional = optional
|
||||
self.argname = argname
|
||||
|
||||
def merge(self, old):
|
||||
if old.optional is not None:
|
||||
self.optional = old.optional
|
||||
if old.argname is not None:
|
||||
self.argname = old.argname
|
||||
|
||||
|
||||
class Definition:
|
||||
docstring = "NULL"
|
||||
def __init__(self, *args):
|
||||
"""Create a new defs object of this type. The arguments are the
|
||||
components of the definition"""
|
||||
raise RuntimeError, "this is an abstract class"
|
||||
def merge(self, old):
|
||||
"""Merge in customisations from older version of definition"""
|
||||
raise RuntimeError, "this is an abstract class"
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
"""write out this definition in defs file format"""
|
||||
raise RuntimeError, "this is an abstract class"
|
||||
|
||||
def guess_return_value_ownership(self):
|
||||
"return 1 if caller owns return value"
|
||||
if getattr(self, 'is_constructor_of', False):
|
||||
self.caller_owns_return = True
|
||||
elif self.ret in ('char*', 'gchar*', 'string'):
|
||||
self.caller_owns_return = True
|
||||
else:
|
||||
self.caller_owns_return = False
|
||||
|
||||
|
||||
class ObjectDef(Definition):
|
||||
def __init__(self, name, *args):
|
||||
self.name = name
|
||||
self.module = None
|
||||
self.parent = None
|
||||
self.c_name = None
|
||||
self.typecode = None
|
||||
self.fields = []
|
||||
self.implements = []
|
||||
self.class_init_func = None
|
||||
self.has_new_constructor_api = False
|
||||
for arg in get_valid_scheme_definitions(args):
|
||||
if arg[0] == 'in-module':
|
||||
self.module = arg[1]
|
||||
elif arg[0] == 'docstring':
|
||||
self.docstring = make_docstring(arg[1:])
|
||||
elif arg[0] == 'parent':
|
||||
self.parent = arg[1]
|
||||
elif arg[0] == 'c-name':
|
||||
self.c_name = arg[1]
|
||||
elif arg[0] == 'gtype-id':
|
||||
self.typecode = arg[1]
|
||||
elif arg[0] == 'fields':
|
||||
for parg in arg[1:]:
|
||||
self.fields.append((parg[0], parg[1]))
|
||||
elif arg[0] == 'implements':
|
||||
self.implements.append(arg[1])
|
||||
def merge(self, old):
|
||||
# currently the .h parser doesn't try to work out what fields of
|
||||
# an object structure should be public, so we just copy the list
|
||||
# from the old version ...
|
||||
self.fields = old.fields
|
||||
self.implements = old.implements
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
fp.write('(define-object ' + self.name + '\n')
|
||||
if self.module:
|
||||
fp.write(' (in-module "' + self.module + '")\n')
|
||||
if self.parent != (None, None):
|
||||
fp.write(' (parent "' + self.parent + '")\n')
|
||||
for interface in self.implements:
|
||||
fp.write(' (implements "' + interface + '")\n')
|
||||
if self.c_name:
|
||||
fp.write(' (c-name "' + self.c_name + '")\n')
|
||||
if self.typecode:
|
||||
fp.write(' (gtype-id "' + self.typecode + '")\n')
|
||||
if self.fields:
|
||||
fp.write(' (fields\n')
|
||||
for (ftype, fname) in self.fields:
|
||||
fp.write(' \'("' + ftype + '" "' + fname + '")\n')
|
||||
fp.write(' )\n')
|
||||
fp.write(')\n\n')
|
||||
|
||||
class MiniObjectDef(Definition):
|
||||
def __init__(self, name, *args):
|
||||
self.name = name
|
||||
self.module = None
|
||||
self.parent = None
|
||||
self.c_name = None
|
||||
self.typecode = None
|
||||
self.fields = []
|
||||
self.implements = []
|
||||
for arg in args:
|
||||
if type(arg) != type(()) or len(arg) < 2:
|
||||
continue
|
||||
if arg[0] == 'in-module':
|
||||
self.module = arg[1]
|
||||
elif arg[0] == 'parent':
|
||||
self.parent = arg[1]
|
||||
elif arg[0] == 'c-name':
|
||||
self.c_name = arg[1]
|
||||
elif arg[0] == 'gtype-id':
|
||||
self.typecode = arg[1]
|
||||
elif arg[0] == 'fields':
|
||||
for parg in arg[1:]:
|
||||
self.fields.append((parg[0], parg[1]))
|
||||
elif arg[0] == 'implements':
|
||||
self.implements.append(arg[1])
|
||||
def merge(self, old):
|
||||
# currently the .h parser doesn't try to work out what fields of
|
||||
# an object structure should be public, so we just copy the list
|
||||
# from the old version ...
|
||||
self.fields = old.fields
|
||||
self.implements = old.implements
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
fp.write('(define-object ' + self.name + '\n')
|
||||
if self.module:
|
||||
fp.write(' (in-module "' + self.module + '")\n')
|
||||
if self.parent != (None, None):
|
||||
fp.write(' (parent "' + self.parent + '")\n')
|
||||
for interface in self.implements:
|
||||
fp.write(' (implements "' + interface + '")\n')
|
||||
if self.c_name:
|
||||
fp.write(' (c-name "' + self.c_name + '")\n')
|
||||
if self.typecode:
|
||||
fp.write(' (gtype-id "' + self.typecode + '")\n')
|
||||
if self.fields:
|
||||
fp.write(' (fields\n')
|
||||
for (ftype, fname) in self.fields:
|
||||
fp.write(' \'("' + ftype + '" "' + fname + '")\n')
|
||||
fp.write(' )\n')
|
||||
fp.write(')\n\n')
|
||||
|
||||
|
||||
class InterfaceDef(Definition):
|
||||
def __init__(self, name, *args):
|
||||
self.name = name
|
||||
self.module = None
|
||||
self.c_name = None
|
||||
self.typecode = None
|
||||
self.vtable = None
|
||||
self.fields = []
|
||||
self.interface_info = None
|
||||
for arg in get_valid_scheme_definitions(args):
|
||||
if arg[0] == 'in-module':
|
||||
self.module = arg[1]
|
||||
elif arg[0] == 'docstring':
|
||||
self.docstring = make_docstring(arg[1:])
|
||||
elif arg[0] == 'c-name':
|
||||
self.c_name = arg[1]
|
||||
elif arg[0] == 'gtype-id':
|
||||
self.typecode = arg[1]
|
||||
elif arg[0] == 'vtable':
|
||||
self.vtable = arg[1]
|
||||
if self.vtable is None:
|
||||
self.vtable = self.c_name + "Iface"
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
fp.write('(define-interface ' + self.name + '\n')
|
||||
if self.module:
|
||||
fp.write(' (in-module "' + self.module + '")\n')
|
||||
if self.c_name:
|
||||
fp.write(' (c-name "' + self.c_name + '")\n')
|
||||
if self.typecode:
|
||||
fp.write(' (gtype-id "' + self.typecode + '")\n')
|
||||
fp.write(')\n\n')
|
||||
|
||||
class EnumDef(Definition):
|
||||
def __init__(self, name, *args):
|
||||
self.deftype = 'enum'
|
||||
self.name = name
|
||||
self.in_module = None
|
||||
self.c_name = None
|
||||
self.typecode = None
|
||||
self.values = []
|
||||
for arg in get_valid_scheme_definitions(args):
|
||||
if arg[0] == 'in-module':
|
||||
self.in_module = arg[1]
|
||||
elif arg[0] == 'c-name':
|
||||
self.c_name = arg[1]
|
||||
elif arg[0] == 'gtype-id':
|
||||
self.typecode = arg[1]
|
||||
elif arg[0] == 'values':
|
||||
for varg in arg[1:]:
|
||||
self.values.append((varg[0], varg[1]))
|
||||
def merge(self, old):
|
||||
pass
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
fp.write('(define-' + self.deftype + ' ' + self.name + '\n')
|
||||
if self.in_module:
|
||||
fp.write(' (in-module "' + self.in_module + '")\n')
|
||||
fp.write(' (c-name "' + self.c_name + '")\n')
|
||||
fp.write(' (gtype-id "' + self.typecode + '")\n')
|
||||
if self.values:
|
||||
fp.write(' (values\n')
|
||||
for name, val in self.values:
|
||||
fp.write(' \'("' + name + '" "' + val + '")\n')
|
||||
fp.write(' )\n')
|
||||
fp.write(')\n\n')
|
||||
|
||||
class FlagsDef(EnumDef):
|
||||
def __init__(self, *args):
|
||||
apply(EnumDef.__init__, (self,) + args)
|
||||
self.deftype = 'flags'
|
||||
|
||||
class BoxedDef(Definition):
|
||||
def __init__(self, name, *args):
|
||||
self.name = name
|
||||
self.module = None
|
||||
self.c_name = None
|
||||
self.typecode = None
|
||||
self.copy = None
|
||||
self.release = None
|
||||
self.fields = []
|
||||
for arg in get_valid_scheme_definitions(args):
|
||||
if arg[0] == 'in-module':
|
||||
self.module = arg[1]
|
||||
elif arg[0] == 'c-name':
|
||||
self.c_name = arg[1]
|
||||
elif arg[0] == 'gtype-id':
|
||||
self.typecode = arg[1]
|
||||
elif arg[0] == 'copy-func':
|
||||
self.copy = arg[1]
|
||||
elif arg[0] == 'release-func':
|
||||
self.release = arg[1]
|
||||
elif arg[0] == 'fields':
|
||||
for parg in arg[1:]:
|
||||
self.fields.append((parg[0], parg[1]))
|
||||
def merge(self, old):
|
||||
# currently the .h parser doesn't try to work out what fields of
|
||||
# an object structure should be public, so we just copy the list
|
||||
# from the old version ...
|
||||
self.fields = old.fields
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
fp.write('(define-boxed ' + self.name + '\n')
|
||||
if self.module:
|
||||
fp.write(' (in-module "' + self.module + '")\n')
|
||||
if self.c_name:
|
||||
fp.write(' (c-name "' + self.c_name + '")\n')
|
||||
if self.typecode:
|
||||
fp.write(' (gtype-id "' + self.typecode + '")\n')
|
||||
if self.copy:
|
||||
fp.write(' (copy-func "' + self.copy + '")\n')
|
||||
if self.release:
|
||||
fp.write(' (release-func "' + self.release + '")\n')
|
||||
if self.fields:
|
||||
fp.write(' (fields\n')
|
||||
for (ftype, fname) in self.fields:
|
||||
fp.write(' \'("' + ftype + '" "' + fname + '")\n')
|
||||
fp.write(' )\n')
|
||||
fp.write(')\n\n')
|
||||
|
||||
class PointerDef(Definition):
|
||||
def __init__(self, name, *args):
|
||||
self.name = name
|
||||
self.module = None
|
||||
self.c_name = None
|
||||
self.typecode = None
|
||||
self.fields = []
|
||||
for arg in get_valid_scheme_definitions(args):
|
||||
if arg[0] == 'in-module':
|
||||
self.module = arg[1]
|
||||
elif arg[0] == 'c-name':
|
||||
self.c_name = arg[1]
|
||||
elif arg[0] == 'gtype-id':
|
||||
self.typecode = arg[1]
|
||||
elif arg[0] == 'fields':
|
||||
for parg in arg[1:]:
|
||||
self.fields.append((parg[0], parg[1]))
|
||||
def merge(self, old):
|
||||
# currently the .h parser doesn't try to work out what fields of
|
||||
# an object structure should be public, so we just copy the list
|
||||
# from the old version ...
|
||||
self.fields = old.fields
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
fp.write('(define-pointer ' + self.name + '\n')
|
||||
if self.module:
|
||||
fp.write(' (in-module "' + self.module + '")\n')
|
||||
if self.c_name:
|
||||
fp.write(' (c-name "' + self.c_name + '")\n')
|
||||
if self.typecode:
|
||||
fp.write(' (gtype-id "' + self.typecode + '")\n')
|
||||
if self.fields:
|
||||
fp.write(' (fields\n')
|
||||
for (ftype, fname) in self.fields:
|
||||
fp.write(' \'("' + ftype + '" "' + fname + '")\n')
|
||||
fp.write(' )\n')
|
||||
fp.write(')\n\n')
|
||||
|
||||
class MethodDefBase(Definition):
|
||||
def __init__(self, name, *args):
|
||||
dump = 0
|
||||
self.name = name
|
||||
self.ret = None
|
||||
self.caller_owns_return = None
|
||||
self.unblock_threads = None
|
||||
self.c_name = None
|
||||
self.typecode = None
|
||||
self.of_object = None
|
||||
self.params = [] # of form (type, name, default, nullok)
|
||||
self.varargs = 0
|
||||
self.deprecated = None
|
||||
for arg in get_valid_scheme_definitions(args):
|
||||
if arg[0] == 'of-object':
|
||||
self.of_object = arg[1]
|
||||
elif arg[0] == 'docstring':
|
||||
self.docstring = make_docstring(arg[1:])
|
||||
elif arg[0] == 'c-name':
|
||||
self.c_name = arg[1]
|
||||
elif arg[0] == 'gtype-id':
|
||||
self.typecode = arg[1]
|
||||
elif arg[0] == 'return-type':
|
||||
self.ret = arg[1]
|
||||
elif arg[0] == 'caller-owns-return':
|
||||
self.caller_owns_return = arg[1] in ('t', '#t')
|
||||
elif arg[0] == 'unblock-threads':
|
||||
self.unblock_threads = arg[1] in ('t', '#t')
|
||||
elif arg[0] == 'parameters':
|
||||
for parg in arg[1:]:
|
||||
ptype = parg[0]
|
||||
pname = parg[1]
|
||||
pdflt = None
|
||||
pnull = 0
|
||||
pdir = None
|
||||
keeprefcount = False
|
||||
for farg in parg[2:]:
|
||||
assert isinstance(farg, tuple)
|
||||
if farg[0] == 'default':
|
||||
pdflt = farg[1]
|
||||
elif farg[0] == 'null-ok':
|
||||
pnull = 1
|
||||
elif farg[0] == 'direction':
|
||||
pdir = farg[1]
|
||||
elif farg[0] == 'keep-refcount':
|
||||
keeprefcount = True
|
||||
self.params.append(Parameter(ptype, pname, pdflt, pnull, pdir,
|
||||
keeprefcount=keeprefcount))
|
||||
elif arg[0] == 'varargs':
|
||||
self.varargs = arg[1] in ('t', '#t')
|
||||
elif arg[0] == 'deprecated':
|
||||
self.deprecated = arg[1]
|
||||
else:
|
||||
sys.stderr.write("Warning: %s argument unsupported.\n"
|
||||
% (arg[0]))
|
||||
dump = 1
|
||||
if dump:
|
||||
self.write_defs(sys.stderr)
|
||||
|
||||
if self.caller_owns_return is None and self.ret is not None:
|
||||
self.guess_return_value_ownership()
|
||||
|
||||
def merge(self, old, parmerge):
|
||||
self.caller_owns_return = old.caller_owns_return
|
||||
self.varargs = old.varargs
|
||||
# here we merge extra parameter flags accross to the new object.
|
||||
if not parmerge:
|
||||
self.params = copy.deepcopy(old.params)
|
||||
return
|
||||
for i in range(len(self.params)):
|
||||
ptype, pname, pdflt, pnull = self.params[i]
|
||||
for p2 in old.params:
|
||||
if p2[1] == pname:
|
||||
self.params[i] = (ptype, pname, p2[2], p2[3])
|
||||
break
|
||||
def _write_defs(self, fp=sys.stdout):
|
||||
if self.of_object != (None, None):
|
||||
fp.write(' (of-object "' + self.of_object + '")\n')
|
||||
if self.c_name:
|
||||
fp.write(' (c-name "' + self.c_name + '")\n')
|
||||
if self.typecode:
|
||||
fp.write(' (gtype-id "' + self.typecode + '")\n')
|
||||
if self.caller_owns_return:
|
||||
fp.write(' (caller-owns-return #t)\n')
|
||||
if self.unblock_threads:
|
||||
fp.write(' (unblock_threads #t)\n')
|
||||
if self.ret:
|
||||
fp.write(' (return-type "' + self.ret + '")\n')
|
||||
if self.deprecated:
|
||||
fp.write(' (deprecated "' + self.deprecated + '")\n')
|
||||
if self.params:
|
||||
fp.write(' (parameters\n')
|
||||
for ptype, pname, pdflt, pnull in self.params:
|
||||
fp.write(' \'("' + ptype + '" "' + pname +'"')
|
||||
if pdflt: fp.write(' (default "' + pdflt + '")')
|
||||
if pnull: fp.write(' (null-ok)')
|
||||
fp.write(')\n')
|
||||
fp.write(' )\n')
|
||||
if self.varargs:
|
||||
fp.write(' (varargs #t)\n')
|
||||
fp.write(')\n\n')
|
||||
|
||||
|
||||
class MethodDef(MethodDefBase):
|
||||
def __init__(self, name, *args):
|
||||
MethodDefBase.__init__(self, name, *args)
|
||||
for item in ('c_name', 'of_object'):
|
||||
if self.__dict__[item] == None:
|
||||
self.write_defs(sys.stderr)
|
||||
raise RuntimeError, "definition missing required %s" % (item,)
|
||||
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
fp.write('(define-method ' + self.name + '\n')
|
||||
self._write_defs(fp)
|
||||
|
||||
class VirtualDef(MethodDefBase):
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
fp.write('(define-virtual ' + self.name + '\n')
|
||||
self._write_defs(fp)
|
||||
|
||||
class FunctionDef(Definition):
|
||||
def __init__(self, name, *args):
|
||||
dump = 0
|
||||
self.name = name
|
||||
self.in_module = None
|
||||
self.is_constructor_of = None
|
||||
self.ret = None
|
||||
self.caller_owns_return = None
|
||||
self.unblock_threads = None
|
||||
self.c_name = None
|
||||
self.typecode = None
|
||||
self.params = [] # of form (type, name, default, nullok)
|
||||
self.varargs = 0
|
||||
self.deprecated = None
|
||||
for arg in get_valid_scheme_definitions(args):
|
||||
if arg[0] == 'in-module':
|
||||
self.in_module = arg[1]
|
||||
elif arg[0] == 'docstring':
|
||||
self.docstring = make_docstring(arg[1:])
|
||||
elif arg[0] == 'is-constructor-of':
|
||||
self.is_constructor_of = arg[1]
|
||||
elif arg[0] == 'c-name':
|
||||
self.c_name = arg[1]
|
||||
elif arg[0] == 'gtype-id':
|
||||
self.typecode = arg[1]
|
||||
elif arg[0] == 'return-type':
|
||||
self.ret = arg[1]
|
||||
elif arg[0] == 'caller-owns-return':
|
||||
self.caller_owns_return = arg[1] in ('t', '#t')
|
||||
elif arg[0] == 'unblock-threads':
|
||||
self.unblock_threads = arg[1] in ('t', '#t')
|
||||
elif arg[0] == 'parameters':
|
||||
for parg in arg[1:]:
|
||||
ptype = parg[0]
|
||||
pname = parg[1]
|
||||
pdflt = None
|
||||
pnull = 0
|
||||
keeprefcount = False
|
||||
for farg in parg[2:]:
|
||||
if farg[0] == 'default':
|
||||
pdflt = farg[1]
|
||||
elif farg[0] == 'null-ok':
|
||||
pnull = 1
|
||||
elif farg[0] == 'keep-refcount':
|
||||
keeprefcount = True
|
||||
self.params.append(Parameter(ptype, pname, pdflt, pnull,
|
||||
keeprefcount = keeprefcount))
|
||||
elif arg[0] == 'properties':
|
||||
if self.is_constructor_of is None:
|
||||
print >> sys.stderr, "Warning: (properties ...) "\
|
||||
"is only valid for constructors"
|
||||
for prop in arg[1:]:
|
||||
pname = prop[0]
|
||||
optional = False
|
||||
argname = pname
|
||||
for farg in prop[1:]:
|
||||
if farg[0] == 'optional':
|
||||
optional = True
|
||||
elif farg[0] == 'argname':
|
||||
argname = farg[1]
|
||||
self.params.append(Property(pname, optional, argname))
|
||||
elif arg[0] == 'varargs':
|
||||
self.varargs = arg[1] in ('t', '#t')
|
||||
elif arg[0] == 'deprecated':
|
||||
self.deprecated = arg[1]
|
||||
else:
|
||||
sys.stderr.write("Warning: %s argument unsupported\n"
|
||||
% (arg[0],))
|
||||
dump = 1
|
||||
if dump:
|
||||
self.write_defs(sys.stderr)
|
||||
|
||||
if self.caller_owns_return is None and self.ret is not None:
|
||||
self.guess_return_value_ownership()
|
||||
for item in ('c_name',):
|
||||
if self.__dict__[item] == None:
|
||||
self.write_defs(sys.stderr)
|
||||
raise RuntimeError, "definition missing required %s" % (item,)
|
||||
|
||||
_method_write_defs = MethodDef.__dict__['write_defs']
|
||||
|
||||
def merge(self, old, parmerge):
|
||||
self.caller_owns_return = old.caller_owns_return
|
||||
self.varargs = old.varargs
|
||||
if not parmerge:
|
||||
self.params = copy.deepcopy(old.params)
|
||||
return
|
||||
# here we merge extra parameter flags accross to the new object.
|
||||
def merge_param(param):
|
||||
for old_param in old.params:
|
||||
if old_param.pname == param.pname:
|
||||
if isinstance(old_param, Property):
|
||||
# h2def never scans Property's, therefore if
|
||||
# we have one it was manually written, so we
|
||||
# keep it.
|
||||
return copy.deepcopy(old_param)
|
||||
else:
|
||||
param.merge(old_param)
|
||||
return param
|
||||
raise RuntimeError, "could not find %s in old_parameters %r" % (
|
||||
param.pname, [p.pname for p in old.params])
|
||||
try:
|
||||
self.params = map(merge_param, self.params)
|
||||
except RuntimeError:
|
||||
# parameter names changed and we can't find a match; it's
|
||||
# safer to keep the old parameter list untouched.
|
||||
self.params = copy.deepcopy(old.params)
|
||||
|
||||
if not self.is_constructor_of:
|
||||
try:
|
||||
self.is_constructor_of = old.is_constructor_of
|
||||
except AttributeError:
|
||||
pass
|
||||
if isinstance(old, MethodDef):
|
||||
self.name = old.name
|
||||
# transmogrify from function into method ...
|
||||
self.write_defs = self._method_write_defs
|
||||
self.of_object = old.of_object
|
||||
del self.params[0]
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
fp.write('(define-function ' + self.name + '\n')
|
||||
if self.in_module:
|
||||
fp.write(' (in-module "' + self.in_module + '")\n')
|
||||
if self.is_constructor_of:
|
||||
fp.write(' (is-constructor-of "' + self.is_constructor_of +'")\n')
|
||||
if self.c_name:
|
||||
fp.write(' (c-name "' + self.c_name + '")\n')
|
||||
if self.typecode:
|
||||
fp.write(' (gtype-id "' + self.typecode + '")\n')
|
||||
if self.caller_owns_return:
|
||||
fp.write(' (caller-owns-return #t)\n')
|
||||
if self.unblock_threads:
|
||||
fp.write(' (unblock-threads #t)\n')
|
||||
if self.ret:
|
||||
fp.write(' (return-type "' + self.ret + '")\n')
|
||||
if self.deprecated:
|
||||
fp.write(' (deprecated "' + self.deprecated + '")\n')
|
||||
if self.params:
|
||||
if isinstance(self.params[0], Parameter):
|
||||
fp.write(' (parameters\n')
|
||||
for ptype, pname, pdflt, pnull in self.params:
|
||||
fp.write(' \'("' + ptype + '" "' + pname +'"')
|
||||
if pdflt: fp.write(' (default "' + pdflt + '")')
|
||||
if pnull: fp.write(' (null-ok)')
|
||||
fp.write(')\n')
|
||||
fp.write(' )\n')
|
||||
elif isinstance(self.params[0], Property):
|
||||
fp.write(' (properties\n')
|
||||
for prop in self.params:
|
||||
fp.write(' \'("' + prop.pname +'"')
|
||||
if prop.optional: fp.write(' (optional)')
|
||||
fp.write(')\n')
|
||||
fp.write(' )\n')
|
||||
else:
|
||||
assert False, "strange parameter list %r" % self.params[0]
|
||||
if self.varargs:
|
||||
fp.write(' (varargs #t)\n')
|
||||
|
||||
fp.write(')\n\n')
|
|
@ -1,143 +0,0 @@
|
|||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
import os, sys
|
||||
import scmexpr
|
||||
from definitions import BoxedDef, EnumDef, FlagsDef, FunctionDef, \
|
||||
InterfaceDef, MethodDef, ObjectDef, MiniObjectDef, PointerDef, \
|
||||
VirtualDef
|
||||
|
||||
class IncludeParser(scmexpr.Parser):
|
||||
"""A simple parser that follows include statements automatically"""
|
||||
def include(self, filename):
|
||||
if not os.path.isabs(filename):
|
||||
filename = os.path.join(os.path.dirname(self.filename), filename)
|
||||
|
||||
# set self.filename to the include name, to handle recursive includes
|
||||
oldfile = self.filename
|
||||
self.filename = filename
|
||||
self.startParsing()
|
||||
self.filename = oldfile
|
||||
|
||||
class DefsParser(IncludeParser):
|
||||
def __init__(self, arg, defines={}):
|
||||
IncludeParser.__init__(self, arg)
|
||||
self.objects = []
|
||||
self.miniobjects = []
|
||||
self.interfaces = []
|
||||
self.enums = [] # enums and flags
|
||||
self.boxes = [] # boxed types
|
||||
self.pointers = [] # pointer types
|
||||
self.functions = [] # functions and methods
|
||||
self.virtuals = [] # virtual methods
|
||||
self.c_name = {} # hash of c names of functions
|
||||
self.methods = {} # hash of methods of particular objects
|
||||
self.defines = defines # -Dfoo=bar options, as dictionary
|
||||
|
||||
def define_object(self, *args):
|
||||
odef = apply(ObjectDef, args)
|
||||
self.objects.append(odef)
|
||||
self.c_name[odef.c_name] = odef
|
||||
# TODO: define_mini_object
|
||||
def define_miniobject(self, *args):
|
||||
odef = apply(MiniObjectDef, args)
|
||||
self.miniobjects.append(odef)
|
||||
self.c_name[odef.c_name] = odef
|
||||
def define_interface(self, *args):
|
||||
idef = apply(InterfaceDef, args)
|
||||
self.interfaces.append(idef)
|
||||
self.c_name[idef.c_name] = idef
|
||||
def define_enum(self, *args):
|
||||
edef = apply(EnumDef, args)
|
||||
self.enums.append(edef)
|
||||
self.c_name[edef.c_name] = edef
|
||||
def define_flags(self, *args):
|
||||
fdef = apply(FlagsDef, args)
|
||||
self.enums.append(fdef)
|
||||
self.c_name[fdef.c_name] = fdef
|
||||
def define_boxed(self, *args):
|
||||
bdef = apply(BoxedDef, args)
|
||||
self.boxes.append(bdef)
|
||||
self.c_name[bdef.c_name] = bdef
|
||||
def define_pointer(self, *args):
|
||||
pdef = apply(PointerDef, args)
|
||||
self.pointers.append(pdef)
|
||||
self.c_name[pdef.c_name] = pdef
|
||||
def define_function(self, *args):
|
||||
fdef = apply(FunctionDef, args)
|
||||
self.functions.append(fdef)
|
||||
self.c_name[fdef.c_name] = fdef
|
||||
def define_method(self, *args):
|
||||
mdef = apply(MethodDef, args)
|
||||
self.functions.append(mdef)
|
||||
self.c_name[mdef.c_name] = mdef
|
||||
def define_virtual(self, *args):
|
||||
vdef = apply(VirtualDef, args)
|
||||
self.virtuals.append(vdef)
|
||||
def merge(self, old, parmerge):
|
||||
for obj in self.objects:
|
||||
if old.c_name.has_key(obj.c_name):
|
||||
obj.merge(old.c_name[obj.c_name])
|
||||
for f in self.functions:
|
||||
if old.c_name.has_key(f.c_name):
|
||||
f.merge(old.c_name[f.c_name], parmerge)
|
||||
|
||||
def printMissing(self, old):
|
||||
for obj in self.objects:
|
||||
if not old.c_name.has_key(obj.c_name):
|
||||
obj.write_defs()
|
||||
for f in self.functions:
|
||||
if not old.c_name.has_key(f.c_name):
|
||||
f.write_defs()
|
||||
|
||||
def write_defs(self, fp=sys.stdout):
|
||||
for obj in self.objects:
|
||||
obj.write_defs(fp)
|
||||
# TODO: Add miniobject
|
||||
for obj in self.miniobjects:
|
||||
obj.write_defs(fp)
|
||||
for enum in self.enums:
|
||||
enum.write_defs(fp)
|
||||
for boxed in self.boxes:
|
||||
boxed.write_defs(fp)
|
||||
for pointer in self.pointers:
|
||||
pointer.write_defs(fp)
|
||||
for func in self.functions:
|
||||
func.write_defs(fp)
|
||||
|
||||
def find_object(self, c_name):
|
||||
for obj in self.objects:
|
||||
if obj.c_name == c_name:
|
||||
return obj
|
||||
else:
|
||||
raise ValueError, 'object not found'
|
||||
|
||||
def find_constructor(self, obj, overrides):
|
||||
for func in self.functions:
|
||||
if isinstance(func, FunctionDef) and \
|
||||
func.is_constructor_of == obj.c_name and \
|
||||
not overrides.is_ignored(func.c_name):
|
||||
return func
|
||||
|
||||
def find_methods(self, obj):
|
||||
objname = obj.c_name
|
||||
return filter(lambda func, on=objname: isinstance(func, MethodDef) and
|
||||
func.of_object == on, self.functions)
|
||||
|
||||
def find_virtuals(self, obj):
|
||||
objname = obj.c_name
|
||||
retval = filter(lambda func, on=objname: isinstance(func, VirtualDef) and
|
||||
func.of_object == on, self.virtuals)
|
||||
return retval
|
||||
|
||||
def find_functions(self):
|
||||
return filter(lambda func: isinstance(func, FunctionDef) and
|
||||
not func.is_constructor_of, self.functions)
|
||||
|
||||
def ifdef(self, *args):
|
||||
if args[0] in self.defines:
|
||||
for arg in args[1:]:
|
||||
self.handle(arg)
|
||||
|
||||
def ifndef(self, *args):
|
||||
if args[0] not in self.defines:
|
||||
for arg in args[1:]:
|
||||
self.handle(arg)
|
|
@ -1,185 +0,0 @@
|
|||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
'''Simple module for extracting GNOME style doc comments from C
|
||||
sources, so I can use them for other purposes.'''
|
||||
|
||||
import sys, os, string, re
|
||||
|
||||
__all__ = ['extract']
|
||||
|
||||
class FunctionDoc:
|
||||
def __init__(self):
|
||||
self.name = None
|
||||
self.params = []
|
||||
self.description = ''
|
||||
self.ret = ''
|
||||
def set_name(self, name):
|
||||
self.name = name
|
||||
def add_param(self, name, description):
|
||||
if name == '...':
|
||||
name = 'Varargs'
|
||||
self.params.append((name, description))
|
||||
def append_to_last_param(self, extra):
|
||||
self.params[-1] = (self.params[-1][0], self.params[-1][1] + extra)
|
||||
def append_to_named_param(self, name, extra):
|
||||
for i in range(len(self.params)):
|
||||
if self.params[i][0] == name:
|
||||
self.params[i] = (name, self.params[i][1] + extra)
|
||||
return
|
||||
# fall through to adding extra parameter ...
|
||||
self.add_param(name, extra)
|
||||
def append_description(self, extra):
|
||||
self.description = self.description + extra
|
||||
def append_return(self, extra):
|
||||
self.ret = self.ret + extra
|
||||
|
||||
def get_param_description(self, name):
|
||||
for param, description in self.params:
|
||||
if param == name:
|
||||
return description
|
||||
else:
|
||||
return ''
|
||||
|
||||
comment_start_pat = re.compile(r'^\s*/\*\*\s')
|
||||
comment_end_pat = re.compile(r'^\s*\*+/')
|
||||
comment_line_lead = re.compile(r'^\s*\*\s*')
|
||||
funcname_pat = re.compile(r'^(\w+)\s*:?')
|
||||
return_pat = re.compile(r'^(returns:|return\s+value:|returns\s*)(.*\n?)$',
|
||||
re.IGNORECASE)
|
||||
param_pat = re.compile(r'^@(\S+)\s*:(.*\n?)$')
|
||||
|
||||
def parse_file(fp, doc_dict):
|
||||
line = fp.readline()
|
||||
in_comment_block = 0
|
||||
while line:
|
||||
if not in_comment_block:
|
||||
if comment_start_pat.match(line):
|
||||
in_comment_block = 1
|
||||
cur_doc = FunctionDoc()
|
||||
in_description = 0
|
||||
in_return = 0
|
||||
line = fp.readline()
|
||||
continue
|
||||
|
||||
# we are inside a comment block ...
|
||||
if comment_end_pat.match(line):
|
||||
if not cur_doc.name:
|
||||
sys.stderr.write("no function name found in doc comment\n")
|
||||
else:
|
||||
doc_dict[cur_doc.name] = cur_doc
|
||||
in_comment_block = 0
|
||||
line = fp.readline()
|
||||
continue
|
||||
|
||||
# inside a comment block, and not the end of the block ...
|
||||
line = comment_line_lead.sub('', line)
|
||||
if not line: line = '\n'
|
||||
|
||||
if not cur_doc.name:
|
||||
match = funcname_pat.match(line)
|
||||
if match:
|
||||
cur_doc.set_name(match.group(1))
|
||||
elif in_return:
|
||||
match = return_pat.match(line)
|
||||
if match:
|
||||
# assume the last return statement was really part of the
|
||||
# description
|
||||
return_start = match.group(1)
|
||||
cur_doc.ret = match.group(2)
|
||||
cur_doc.description = cur_doc.description + return_start + \
|
||||
cur_doc.ret
|
||||
else:
|
||||
cur_doc.append_return(line)
|
||||
elif in_description:
|
||||
if line[:12] == 'Description:':
|
||||
line = line[12:]
|
||||
match = return_pat.match(line)
|
||||
if match:
|
||||
in_return = 1
|
||||
return_start = match.group(1)
|
||||
cur_doc.append_return(match.group(2))
|
||||
else:
|
||||
cur_doc.append_description(line)
|
||||
elif line == '\n':
|
||||
# end of parameters
|
||||
in_description = 1
|
||||
else:
|
||||
match = param_pat.match(line)
|
||||
if match:
|
||||
param = match.group(1)
|
||||
desc = match.group(2)
|
||||
if param == 'returns':
|
||||
cur_doc.ret = desc
|
||||
else:
|
||||
cur_doc.add_param(param, desc)
|
||||
else:
|
||||
# must be continuation
|
||||
try:
|
||||
if param == 'returns':
|
||||
cur_doc.append_return(line)
|
||||
else:
|
||||
cur_doc.append_to_last_param(line)
|
||||
except:
|
||||
sys.stderr.write('something weird while reading param\n')
|
||||
line = fp.readline()
|
||||
|
||||
def parse_dir(dir, doc_dict):
|
||||
for file in os.listdir(dir):
|
||||
if file in ('.', '..'): continue
|
||||
path = os.path.join(dir, file)
|
||||
if os.path.isdir(path):
|
||||
parse_dir(path, doc_dict)
|
||||
if len(file) > 2 and file[-2:] == '.c':
|
||||
parse_file(open(path, 'r'), doc_dict)
|
||||
|
||||
def extract(dirs, doc_dict=None):
|
||||
if not doc_dict: doc_dict = {}
|
||||
for dir in dirs:
|
||||
parse_dir(dir, doc_dict)
|
||||
return doc_dict
|
||||
|
||||
tmpl_section_pat = re.compile(r'^<!-- ##### (\w+) (\w+) ##### -->$')
|
||||
def parse_tmpl(fp, doc_dict):
|
||||
cur_doc = None
|
||||
|
||||
line = fp.readline()
|
||||
while line:
|
||||
match = tmpl_section_pat.match(line)
|
||||
if match:
|
||||
cur_doc = None # new input shouldn't affect the old doc dict
|
||||
sect_type = match.group(1)
|
||||
sect_name = match.group(2)
|
||||
|
||||
if sect_type == 'FUNCTION':
|
||||
cur_doc = doc_dict.get(sect_name)
|
||||
if not cur_doc:
|
||||
cur_doc = FunctionDoc()
|
||||
cur_doc.set_name(sect_name)
|
||||
doc_dict[sect_name] = cur_doc
|
||||
elif line == '<!-- # Unused Parameters # -->\n':
|
||||
cur_doc = None # don't worry about unused params.
|
||||
elif cur_doc:
|
||||
if line[:10] == '@Returns: ':
|
||||
if string.strip(line[10:]):
|
||||
cur_doc.append_return(line[10:])
|
||||
elif line[0] == '@':
|
||||
pos = string.find(line, ':')
|
||||
if pos >= 0:
|
||||
cur_doc.append_to_named_param(line[1:pos], line[pos+1:])
|
||||
else:
|
||||
cur_doc.append_description(line)
|
||||
else:
|
||||
cur_doc.append_description(line)
|
||||
|
||||
line = fp.readline()
|
||||
|
||||
def extract_tmpl(dirs, doc_dict=None):
|
||||
if not doc_dict: doc_dict = {}
|
||||
for dir in dirs:
|
||||
for file in os.listdir(dir):
|
||||
if file in ('.', '..'): continue
|
||||
path = os.path.join(dir, file)
|
||||
if os.path.isdir(path):
|
||||
continue
|
||||
if len(file) > 2 and file[-2:] == '.sgml':
|
||||
parse_tmpl(open(path, 'r'), doc_dict)
|
||||
return doc_dict
|
|
@ -1,752 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
import sys, os, string, re, getopt
|
||||
|
||||
import defsparser
|
||||
import definitions
|
||||
import override
|
||||
import docextract
|
||||
|
||||
class Node:
|
||||
def __init__(self, name, interfaces=[]):
|
||||
self.name = name
|
||||
self.interfaces = interfaces
|
||||
self.subclasses = []
|
||||
def add_child(self, node):
|
||||
self.subclasses.append(node)
|
||||
|
||||
def build_object_tree(parser):
|
||||
# reorder objects so that parent classes come first ...
|
||||
objects = parser.objects[:]
|
||||
pos = 0
|
||||
while pos < len(objects):
|
||||
parent = objects[pos].parent
|
||||
for i in range(pos+1, len(objects)):
|
||||
if objects[i].c_name == parent:
|
||||
objects.insert(i+1, objects[pos])
|
||||
del objects[pos]
|
||||
break
|
||||
else:
|
||||
pos = pos + 1
|
||||
|
||||
root = Node(None)
|
||||
nodes = { None: root }
|
||||
for obj_def in objects:
|
||||
print obj_def.name
|
||||
parent_node = nodes[obj_def.parent]
|
||||
node = Node(obj_def.c_name, obj_def.implements)
|
||||
parent_node.add_child(node)
|
||||
nodes[node.name] = node
|
||||
|
||||
if parser.interfaces:
|
||||
interfaces = Node('gobject.GInterface')
|
||||
root.add_child(interfaces)
|
||||
nodes[interfaces.name] = interfaces
|
||||
for obj_def in parser.interfaces:
|
||||
node = Node(obj_def.c_name)
|
||||
interfaces.add_child(node)
|
||||
nodes[node.name] = node
|
||||
|
||||
if parser.boxes:
|
||||
boxed = Node('gobject.GBoxed')
|
||||
root.add_child(boxed)
|
||||
nodes[boxed.name] = boxed
|
||||
for obj_def in parser.boxes:
|
||||
node = Node(obj_def.c_name)
|
||||
boxed.add_child(node)
|
||||
nodes[node.name] = node
|
||||
|
||||
if parser.pointers:
|
||||
pointers = Node('gobject.GPointer')
|
||||
root.add_child(pointers)
|
||||
nodes[pointers.name] = pointers
|
||||
for obj_def in parser.pointers:
|
||||
node = Node(obj_def.c_name)
|
||||
pointers.add_child(node)
|
||||
nodes[node.name] = node
|
||||
|
||||
return root
|
||||
|
||||
class DocWriter:
|
||||
def __init__(self):
|
||||
# parse the defs file
|
||||
self.parser = defsparser.DefsParser(())
|
||||
self.overrides = override.Overrides()
|
||||
self.classmap = {}
|
||||
self.docs = {}
|
||||
|
||||
def add_sourcedirs(self, source_dirs):
|
||||
self.docs = docextract.extract(source_dirs, self.docs)
|
||||
def add_tmpldirs(self, tmpl_dirs):
|
||||
self.docs = docextract.extract_tmpl(tmpl_dirs, self.docs)
|
||||
|
||||
def add_docs(self, defs_file, overrides_file, module_name):
|
||||
'''parse information about a given defs file'''
|
||||
self.parser.filename = defs_file
|
||||
self.parser.startParsing(defs_file)
|
||||
if overrides_file:
|
||||
self.overrides.handle_file(overrides_file)
|
||||
|
||||
for obj in self.parser.objects:
|
||||
if not self.classmap.has_key(obj.c_name):
|
||||
self.classmap[obj.c_name] = '%s.%s' % (module_name, obj.name)
|
||||
for obj in self.parser.interfaces:
|
||||
if not self.classmap.has_key(obj.c_name):
|
||||
self.classmap[obj.c_name] = '%s.%s' % (module_name, obj.name)
|
||||
for obj in self.parser.boxes:
|
||||
if not self.classmap.has_key(obj.c_name):
|
||||
self.classmap[obj.c_name] = '%s.%s' % (module_name, obj.name)
|
||||
for obj in self.parser.pointers:
|
||||
if not self.classmap.has_key(obj.c_name):
|
||||
self.classmap[obj.c_name] = '%s.%s' % (module_name, obj.name)
|
||||
|
||||
def pyname(self, name):
|
||||
return self.classmap.get(name, name)
|
||||
|
||||
def __compare(self, obja, objb):
|
||||
return cmp(self.pyname(obja.c_name), self.pyname(objb.c_name))
|
||||
def output_docs(self, output_prefix):
|
||||
files = []
|
||||
|
||||
# class hierarchy
|
||||
hierarchy = build_object_tree(self.parser)
|
||||
filename = self.create_filename('hierarchy', output_prefix)
|
||||
fp = open(filename, 'w')
|
||||
self.write_full_hierarchy(hierarchy, fp)
|
||||
fp.close()
|
||||
|
||||
obj_defs = self.parser.objects + self.parser.interfaces + \
|
||||
self.parser.boxes + self.parser.pointers
|
||||
obj_defs.sort(self.__compare)
|
||||
for obj_def in obj_defs:
|
||||
filename = self.create_filename(obj_def.c_name, output_prefix)
|
||||
fp = open(filename, 'w')
|
||||
if isinstance(obj_def, definitions.ObjectDef):
|
||||
self.output_object_docs(obj_def, fp)
|
||||
elif isinstance(obj_def, definitions.InterfaceDef):
|
||||
self.output_interface_docs(obj_def, fp)
|
||||
elif isinstance(obj_def, definitions.BoxedDef):
|
||||
self.output_boxed_docs(obj_def, fp)
|
||||
elif isinstance(obj_def, definitions.PointerDef):
|
||||
self.output_boxed_docs(obj_def, fp)
|
||||
fp.close()
|
||||
files.append((os.path.basename(filename), obj_def))
|
||||
|
||||
if files:
|
||||
filename = self.create_toc_filename(output_prefix)
|
||||
fp = open(filename, 'w')
|
||||
self.output_toc(files, fp)
|
||||
fp.close()
|
||||
|
||||
def output_object_docs(self, obj_def, fp=sys.stdout):
|
||||
self.write_class_header(obj_def.c_name, fp)
|
||||
|
||||
self.write_heading('Synopsis', fp)
|
||||
self.write_synopsis(obj_def, fp)
|
||||
self.close_section(fp)
|
||||
|
||||
# construct the inheritence hierarchy ...
|
||||
ancestry = [ (obj_def.c_name, obj_def.implements) ]
|
||||
try:
|
||||
parent = obj_def.parent
|
||||
while parent != None:
|
||||
if parent == 'GObject':
|
||||
ancestry.append(('GObject', []))
|
||||
parent = None
|
||||
else:
|
||||
parent_def = self.parser.find_object(parent)
|
||||
ancestry.append((parent_def.c_name, parent_def.implements))
|
||||
parent = parent_def.parent
|
||||
except ValueError:
|
||||
pass
|
||||
ancestry.reverse()
|
||||
self.write_heading('Ancestry', fp)
|
||||
self.write_hierarchy(obj_def.c_name, ancestry, fp)
|
||||
self.close_section(fp)
|
||||
|
||||
constructor = self.parser.find_constructor(obj_def, self.overrides)
|
||||
if constructor:
|
||||
self.write_heading('Constructor', fp)
|
||||
self.write_constructor(constructor,
|
||||
self.docs.get(constructor.c_name, None),
|
||||
fp)
|
||||
self.close_section(fp)
|
||||
|
||||
methods = self.parser.find_methods(obj_def)
|
||||
methods = filter(lambda meth, self=self:
|
||||
not self.overrides.is_ignored(meth.c_name), methods)
|
||||
if methods:
|
||||
self.write_heading('Methods', fp)
|
||||
for method in methods:
|
||||
self.write_method(method, self.docs.get(method.c_name, None), fp)
|
||||
self.close_section(fp)
|
||||
|
||||
self.write_class_footer(obj_def.c_name, fp)
|
||||
|
||||
def output_interface_docs(self, int_def, fp=sys.stdout):
|
||||
self.write_class_header(int_def.c_name, fp)
|
||||
|
||||
self.write_heading('Synopsis', fp)
|
||||
self.write_synopsis(int_def, fp)
|
||||
self.close_section(fp)
|
||||
|
||||
methods = self.parser.find_methods(int_def)
|
||||
methods = filter(lambda meth, self=self:
|
||||
not self.overrides.is_ignored(meth.c_name), methods)
|
||||
if methods:
|
||||
self.write_heading('Methods', fp)
|
||||
for method in methods:
|
||||
self.write_method(method, self.docs.get(method.c_name, None), fp)
|
||||
self.close_section(fp)
|
||||
|
||||
self.write_class_footer(int_def.c_name, fp)
|
||||
|
||||
def output_boxed_docs(self, box_def, fp=sys.stdout):
|
||||
self.write_class_header(box_def.c_name, fp)
|
||||
|
||||
self.write_heading('Synopsis', fp)
|
||||
self.write_synopsis(box_def, fp)
|
||||
self.close_section(fp)
|
||||
|
||||
constructor = self.parser.find_constructor(box_def, self.overrides)
|
||||
if constructor:
|
||||
self.write_heading('Constructor', fp)
|
||||
self.write_constructor(constructor,
|
||||
self.docs.get(constructor.c_name, None),
|
||||
fp)
|
||||
self.close_section(fp)
|
||||
|
||||
methods = self.parser.find_methods(box_def)
|
||||
methods = filter(lambda meth, self=self:
|
||||
not self.overrides.is_ignored(meth.c_name), methods)
|
||||
if methods:
|
||||
self.write_heading('Methods', fp)
|
||||
for method in methods:
|
||||
self.write_method(method, self.docs.get(method.c_name, None), fp)
|
||||
self.close_section(fp)
|
||||
|
||||
self.write_class_footer(box_def.c_name, fp)
|
||||
|
||||
def output_toc(self, files, fp=sys.stdout):
|
||||
fp.write('TOC\n\n')
|
||||
for filename, obj_def in files:
|
||||
fp.write(obj_def.c_name + ' - ' + filename + '\n')
|
||||
|
||||
# override the following to create a more complex output format
|
||||
def create_filename(self, obj_name, output_prefix):
|
||||
'''Create output filename for this particular object'''
|
||||
return output_prefix + '-' + string.lower(obj_name) + '.txt'
|
||||
def create_toc_filename(self, output_prefix):
|
||||
return self.create_filename(self, 'docs', output_prefix)
|
||||
|
||||
def write_full_hierarchy(self, hierarchy, fp):
|
||||
def handle_node(node, fp, indent=''):
|
||||
for child in node.subclasses:
|
||||
fp.write(indent + node.name)
|
||||
if node.interfaces:
|
||||
fp.write(' (implements ')
|
||||
fp.write(string.join(node.interfaces, ', '))
|
||||
fp.write(')\n')
|
||||
else:
|
||||
fp.write('\n')
|
||||
handle_node(child, fp, indent + ' ')
|
||||
handle_node(hierarchy, fp)
|
||||
|
||||
# these need to handle default args ...
|
||||
def create_constructor_prototype(self, func_def):
|
||||
return func_def.is_constructor_of + '(' + \
|
||||
string.join(map(lambda x: x[1], func_def.params), ', ') + \
|
||||
')'
|
||||
def create_function_prototype(self, func_def):
|
||||
return func_def.name + '(' + \
|
||||
string.join(map(lambda x: x[1], func_def.params), ', ') + \
|
||||
')'
|
||||
def create_method_prototype(self, meth_def):
|
||||
return meth_def.of_object + '.' + \
|
||||
meth_def.name + '(' + \
|
||||
string.join(map(lambda x: x[1], meth_def.params), ', ') + \
|
||||
')'
|
||||
|
||||
def write_class_header(self, obj_name, fp):
|
||||
fp.write('Class %s\n' % obj_name)
|
||||
fp.write('======%s\n\n' % ('=' * len(obj_name)))
|
||||
def write_class_footer(self, obj_name, fp):
|
||||
pass
|
||||
def write_heading(self, text, fp):
|
||||
fp.write('\n' + text + '\n' + ('-' * len(text)) + '\n')
|
||||
def close_section(self, fp):
|
||||
pass
|
||||
def write_synopsis(self, obj_def, fp):
|
||||
fp.write('class %s' % obj_def.c_name)
|
||||
if isinstance(obj_def, definitions.ObjectDef):
|
||||
bases = []
|
||||
if obj_def.parent: bases.append(obj_def.parent)
|
||||
bases = bases = obj_def.implements
|
||||
if bases:
|
||||
fp.write('(%s)' % string.join(bases, ', '))
|
||||
fp.write(':\n')
|
||||
|
||||
constructor = self.parser.find_constructor(obj_def, self.overrides)
|
||||
if constructor:
|
||||
prototype = self.create_constructor_prototype(constructor)
|
||||
fp.write(' def %s\n' % prototype)
|
||||
methods = self.parser.find_methods(obj_def)
|
||||
methods = filter(lambda meth, self=self:
|
||||
not self.overrides.is_ignored(meth.c_name), methods)
|
||||
for meth in methods:
|
||||
prototype = self.create_method_prototype(meth)
|
||||
fp.write(' def %s\n' % prototype)
|
||||
|
||||
def write_hierarchy(self, obj_name, ancestry, fp):
|
||||
indent = ''
|
||||
for name, interfaces in ancestry:
|
||||
fp.write(indent + '+-- ' + name)
|
||||
if interfaces:
|
||||
fp.write(' (implements ')
|
||||
fp.write(string.join(interfaces, ', '))
|
||||
fp.write(')\n')
|
||||
else:
|
||||
fp.write('\n')
|
||||
indent = indent + ' '
|
||||
fp.write('\n')
|
||||
def write_constructor(self, func_def, func_doc, fp):
|
||||
prototype = self.create_constructor_prototype(func_def)
|
||||
fp.write(prototype + '\n\n')
|
||||
for type, name, dflt, null in func_def.params:
|
||||
if func_doc:
|
||||
descr = func_doc.get_param_description(name)
|
||||
else:
|
||||
descr = 'a ' + type
|
||||
fp.write(' ' + name + ': ' + descr + '\n')
|
||||
if func_def.ret and func_def.ret != 'none':
|
||||
if func_doc and func_doc.ret:
|
||||
descr = func_doc.ret
|
||||
else:
|
||||
descr = 'a ' + func_def.ret
|
||||
fp.write(' Returns: ' + descr + '\n')
|
||||
if func_doc and func_doc.description:
|
||||
fp.write(func_doc.description)
|
||||
fp.write('\n\n\n')
|
||||
def write_method(self, meth_def, func_doc, fp):
|
||||
prototype = self.create_method_prototype(meth_def)
|
||||
fp.write(prototype + '\n\n')
|
||||
for type, name, dflt, null in meth_def.params:
|
||||
if func_doc:
|
||||
descr = func_doc.get_param_description(name)
|
||||
else:
|
||||
descr = 'a ' + type
|
||||
fp.write(' ' + name + ': ' + descr + '\n')
|
||||
if meth_def.ret and meth_def.ret != 'none':
|
||||
if func_doc and func_doc.ret:
|
||||
descr = func_doc.ret
|
||||
else:
|
||||
descr = 'a ' + meth_def.ret
|
||||
fp.write(' Returns: ' + descr + '\n')
|
||||
if func_doc and func_doc.description:
|
||||
fp.write('\n')
|
||||
fp.write(func_doc.description)
|
||||
fp.write('\n\n')
|
||||
|
||||
class DocbookDocWriter(DocWriter):
|
||||
def __init__(self, use_xml=0):
|
||||
DocWriter.__init__(self)
|
||||
self.use_xml = use_xml
|
||||
|
||||
def create_filename(self, obj_name, output_prefix):
|
||||
'''Create output filename for this particular object'''
|
||||
stem = output_prefix + '-' + string.lower(obj_name)
|
||||
if self.use_xml:
|
||||
return stem + '.xml'
|
||||
else:
|
||||
return stem + '.sgml'
|
||||
def create_toc_filename(self, output_prefix):
|
||||
if self.use_xml:
|
||||
return self.create_filename('classes', output_prefix)
|
||||
else:
|
||||
return self.create_filename('docs', output_prefix)
|
||||
|
||||
# make string -> reference translation func
|
||||
__transtable = [ '-' ] * 256
|
||||
for digit in '0123456789':
|
||||
__transtable[ord(digit)] = digit
|
||||
for letter in 'abcdefghijklmnopqrstuvwxyz':
|
||||
__transtable[ord(letter)] = letter
|
||||
__transtable[ord(string.upper(letter))] = letter
|
||||
__transtable = string.join(__transtable, '')
|
||||
|
||||
def make_class_ref(self, obj_name):
|
||||
return 'class-' + string.translate(obj_name, self.__transtable)
|
||||
def make_method_ref(self, meth_def):
|
||||
return 'method-' + string.translate(meth_def.of_object,
|
||||
self.__transtable) + \
|
||||
'--' + string.translate(meth_def.name, self.__transtable)
|
||||
|
||||
__function_pat = re.compile(r'(\w+)\s*\(\)')
|
||||
def __format_function(self, match):
|
||||
info = self.parser.c_name.get(match.group(1), None)
|
||||
if info:
|
||||
if isinstance(info, defsparser.FunctionDef):
|
||||
if info.is_constructor_of is not None:
|
||||
# should have a link here
|
||||
return '<function>%s()</function>' % \
|
||||
self.pyname(info.is_constructor_of)
|
||||
else:
|
||||
return '<function>' + info.name + '()</function>'
|
||||
if isinstance(info, defsparser.MethodDef):
|
||||
return '<link linkend="' + self.make_method_ref(info) + \
|
||||
'"><function>' + self.pyname(info.of_object) + '.' + \
|
||||
info.name + '()</function></link>'
|
||||
# fall through through
|
||||
return '<function>' + match.group(1) + '()</function>'
|
||||
__parameter_pat = re.compile(r'\@(\w+)')
|
||||
def __format_param(self, match):
|
||||
return '<parameter>' + match.group(1) + '</parameter>'
|
||||
__constant_pat = re.compile(r'\%(-?\w+)')
|
||||
def __format_const(self, match):
|
||||
return '<literal>' + match.group(1) + '</literal>'
|
||||
__symbol_pat = re.compile(r'#([\w-]+)')
|
||||
def __format_symbol(self, match):
|
||||
info = self.parser.c_name.get(match.group(1), None)
|
||||
if info:
|
||||
if isinstance(info, defsparser.FunctionDef):
|
||||
if info.is_constructor_of is not None:
|
||||
# should have a link here
|
||||
return '<methodname>' + self.pyname(info.is_constructor_of) + \
|
||||
'</methodname>'
|
||||
else:
|
||||
return '<function>' + info.name + '</function>'
|
||||
if isinstance(info, defsparser.MethodDef):
|
||||
return '<link linkend="' + self.make_method_ref(info) + \
|
||||
'"><methodname>' + self.pyname(info.of_object) + '.' + \
|
||||
info.name + '</methodname></link>'
|
||||
if isinstance(info, defsparser.ObjectDef) or \
|
||||
isinstance(info, defsparser.InterfaceDef) or \
|
||||
isinstance(info, defsparser.BoxedDef) or \
|
||||
isinstance(info, defsparser.PointerDef):
|
||||
return '<link linkend="' + self.make_class_ref(info.c_name) + \
|
||||
'"><classname>' + self.pyname(info.c_name) + \
|
||||
'</classname></link>'
|
||||
# fall through through
|
||||
return '<literal>' + match.group(1) + '</literal>'
|
||||
|
||||
def reformat_text(self, text, singleline=0):
|
||||
# replace special strings ...
|
||||
text = self.__function_pat.sub(self.__format_function, text)
|
||||
text = self.__parameter_pat.sub(self.__format_param, text)
|
||||
text = self.__constant_pat.sub(self.__format_const, text)
|
||||
text = self.__symbol_pat.sub(self.__format_symbol, text)
|
||||
|
||||
# don't bother with <para> expansion for single line text.
|
||||
if singleline: return text
|
||||
|
||||
lines = string.split(string.strip(text), '\n')
|
||||
for index in range(len(lines)):
|
||||
if string.strip(lines[index]) == '':
|
||||
lines[index] = '</para>\n<para>'
|
||||
continue
|
||||
lines.insert(0, '<para>')
|
||||
lines.append('</para>')
|
||||
return string.join(lines, '\n')
|
||||
|
||||
# write out hierarchy
|
||||
def write_full_hierarchy(self, hierarchy, fp):
|
||||
def handle_node(node, fp, indent=''):
|
||||
if node.name:
|
||||
fp.write('%s<link linkend="%s">%s</link>' %
|
||||
(indent, self.make_class_ref(node.name),
|
||||
self.pyname(node.name)))
|
||||
if node.interfaces:
|
||||
fp.write(' (implements ')
|
||||
for i in range(len(node.interfaces)):
|
||||
fp.write('<link linkend="%s">%s</link>' %
|
||||
(self.make_class_ref(node.interfaces[i]),
|
||||
self.pyname(node.interfaces[i])))
|
||||
if i != len(node.interfaces) - 1:
|
||||
fp.write(', ')
|
||||
fp.write(')\n')
|
||||
else:
|
||||
fp.write('\n')
|
||||
|
||||
indent = indent + ' '
|
||||
node.subclasses.sort(lambda a,b:
|
||||
cmp(self.pyname(a.name), self.pyname(b.name)))
|
||||
for child in node.subclasses:
|
||||
handle_node(child, fp, indent)
|
||||
if self.use_xml:
|
||||
fp.write('<?xml version="1.0" standalone="no"?>\n')
|
||||
fp.write('<!DOCTYPE synopsis PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"\n')
|
||||
fp.write(' "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">\n')
|
||||
fp.write('<synopsis>')
|
||||
handle_node(hierarchy, fp)
|
||||
fp.write('</synopsis>\n')
|
||||
|
||||
# these need to handle default args ...
|
||||
def create_constructor_prototype(self, func_def):
|
||||
sgml = [ '<constructorsynopsis language="python">\n']
|
||||
sgml.append(' <methodname>__init__</methodname>\n')
|
||||
for type, name, dflt, null in func_def.params:
|
||||
sgml.append(' <methodparam><parameter>')
|
||||
sgml.append(name)
|
||||
sgml.append('</parameter>')
|
||||
if dflt:
|
||||
sgml.append('<initializer>')
|
||||
sgml.append(dflt)
|
||||
sgml.append('</initializer>')
|
||||
sgml.append('</methodparam>\n')
|
||||
if not func_def.params:
|
||||
sgml.append(' <methodparam></methodparam>')
|
||||
sgml.append(' </constructorsynopsis>')
|
||||
return string.join(sgml, '')
|
||||
def create_function_prototype(self, func_def):
|
||||
sgml = [ '<funcsynopsis language="python">\n <funcprototype>\n']
|
||||
sgml.append(' <funcdef><function>')
|
||||
sgml.append(func_def.name)
|
||||
sgml.append('</function></funcdef>\n')
|
||||
for type, name, dflt, null in func_def.params:
|
||||
sgml.append(' <paramdef><parameter>')
|
||||
sgml.append(name)
|
||||
sgml.append('</parameter>')
|
||||
if dflt:
|
||||
sgml.append('<initializer>')
|
||||
sgml.append(dflt)
|
||||
sgml.append('</initializer>')
|
||||
sgml.append('</paramdef>\n')
|
||||
if not func_def.params:
|
||||
sgml.append(' <paramdef></paramdef')
|
||||
sgml.append(' </funcprototype>\n </funcsynopsis>')
|
||||
return string.join(sgml, '')
|
||||
def create_method_prototype(self, meth_def, addlink=0):
|
||||
sgml = [ '<methodsynopsis language="python">\n']
|
||||
sgml.append(' <methodname>')
|
||||
if addlink:
|
||||
sgml.append('<link linkend="%s">' % self.make_method_ref(meth_def))
|
||||
sgml.append(self.pyname(meth_def.name))
|
||||
if addlink:
|
||||
sgml.append('</link>')
|
||||
sgml.append('</methodname>\n')
|
||||
for type, name, dflt, null in meth_def.params:
|
||||
sgml.append(' <methodparam><parameter>')
|
||||
sgml.append(name)
|
||||
sgml.append('</parameter>')
|
||||
if dflt:
|
||||
sgml.append('<initializer>')
|
||||
sgml.append(dflt)
|
||||
sgml.append('</initializer>')
|
||||
sgml.append('</methodparam>\n')
|
||||
if not meth_def.params:
|
||||
sgml.append(' <methodparam></methodparam>')
|
||||
sgml.append(' </methodsynopsis>')
|
||||
return string.join(sgml, '')
|
||||
|
||||
def write_class_header(self, obj_name, fp):
|
||||
if self.use_xml:
|
||||
fp.write('<?xml version="1.0" standalone="no"?>\n')
|
||||
fp.write('<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"\n')
|
||||
fp.write(' "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">\n')
|
||||
fp.write('<refentry id="' + self.make_class_ref(obj_name) + '">\n')
|
||||
fp.write(' <refmeta>\n')
|
||||
fp.write(' <refentrytitle>%s</refentrytitle>\n'
|
||||
% self.pyname(obj_name))
|
||||
fp.write(' <manvolnum>3</manvolnum>\n')
|
||||
fp.write(' <refmiscinfo>PyGTK Docs</refmiscinfo>\n')
|
||||
fp.write(' </refmeta>\n\n')
|
||||
fp.write(' <refnamediv>\n')
|
||||
fp.write(' <refname>%s</refname><refpurpose></refpurpose>\n'
|
||||
% self.pyname(obj_name))
|
||||
fp.write(' </refnamediv>\n\n')
|
||||
def write_class_footer(self, obj_name, fp):
|
||||
fp.write('</refentry>\n')
|
||||
def write_heading(self, text, fp):
|
||||
fp.write(' <refsect1>\n')
|
||||
fp.write(' <title>' + text + '</title>\n\n')
|
||||
def close_section(self, fp):
|
||||
fp.write(' </refsect1>\n')
|
||||
|
||||
def write_synopsis(self, obj_def, fp):
|
||||
fp.write('<classsynopsis language="python">\n')
|
||||
fp.write(' <ooclass><classname>%s</classname></ooclass>\n'
|
||||
% self.pyname(obj_def.c_name))
|
||||
if isinstance(obj_def, definitions.ObjectDef):
|
||||
if obj_def.parent:
|
||||
fp.write(' <ooclass><classname><link linkend="%s">%s'
|
||||
'</link></classname></ooclass>\n'
|
||||
% (self.make_class_ref(obj_def.parent),
|
||||
self.pyname(obj_def.parent)))
|
||||
for base in obj_def.implements:
|
||||
fp.write(' <ooclass><classname><link linkend="%s">%s'
|
||||
'</link></classname></ooclass>\n'
|
||||
% (self.make_class_ref(base), self.pyname(base)))
|
||||
elif isinstance(obj_def, definitions.InterfaceDef):
|
||||
fp.write(' <ooclass><classname>gobject.GInterface'
|
||||
'</classname></ooclass>\n')
|
||||
elif isinstance(obj_def, definitions.BoxedDef):
|
||||
fp.write(' <ooclass><classname>gobject.GBoxed'
|
||||
'</classname></ooclass>\n')
|
||||
elif isinstance(obj_def, definitions.PointerDef):
|
||||
fp.write(' <ooclass><classname>gobject.GPointer'
|
||||
'</classname></ooclass>\n')
|
||||
|
||||
constructor = self.parser.find_constructor(obj_def, self.overrides)
|
||||
if constructor:
|
||||
fp.write('%s\n' % self.create_constructor_prototype(constructor))
|
||||
methods = self.parser.find_methods(obj_def)
|
||||
methods = filter(lambda meth, self=self:
|
||||
not self.overrides.is_ignored(meth.c_name), methods)
|
||||
for meth in methods:
|
||||
fp.write('%s\n' % self.create_method_prototype(meth, addlink=1))
|
||||
fp.write('</classsynopsis>\n\n')
|
||||
|
||||
def write_hierarchy(self, obj_name, ancestry, fp):
|
||||
fp.write('<synopsis>')
|
||||
indent = ''
|
||||
for name, interfaces in ancestry:
|
||||
fp.write(indent + '+-- <link linkend="' +
|
||||
self.make_class_ref(name) + '">'+ self.pyname(name) + '</link>')
|
||||
if interfaces:
|
||||
fp.write(' (implements ')
|
||||
for i in range(len(interfaces)):
|
||||
fp.write('<link linkend="%s">%s</link>' %
|
||||
(self.make_class_ref(interfaces[i]),
|
||||
self.pyname(interfaces[i])))
|
||||
if i != len(interfaces) - 1:
|
||||
fp.write(', ')
|
||||
fp.write(')\n')
|
||||
else:
|
||||
fp.write('\n')
|
||||
indent = indent + ' '
|
||||
fp.write('</synopsis>\n\n')
|
||||
|
||||
def write_params(self, params, ret, func_doc, fp):
|
||||
if not params and (not ret or ret == 'none'):
|
||||
return
|
||||
fp.write(' <variablelist>\n')
|
||||
for type, name, dflt, null in params:
|
||||
if func_doc:
|
||||
descr = string.strip(func_doc.get_param_description(name))
|
||||
else:
|
||||
descr = 'a ' + type
|
||||
fp.write(' <varlistentry>\n')
|
||||
fp.write(' <term><parameter>%s</parameter> :</term>\n' % name)
|
||||
fp.write(' <listitem><simpara>%s</simpara></listitem>\n' %
|
||||
self.reformat_text(descr, singleline=1))
|
||||
fp.write(' </varlistentry>\n')
|
||||
if ret and ret != 'none':
|
||||
if func_doc and func_doc.ret:
|
||||
descr = string.strip(func_doc.ret)
|
||||
else:
|
||||
descr = 'a ' + ret
|
||||
fp.write(' <varlistentry>\n')
|
||||
fp.write(' <term><emphasis>Returns</emphasis> :</term>\n')
|
||||
fp.write(' <listitem><simpara>%s</simpara></listitem>\n' %
|
||||
self.reformat_text(descr, singleline=1))
|
||||
fp.write(' </varlistentry>\n')
|
||||
fp.write(' </variablelist>\n')
|
||||
|
||||
def write_constructor(self, func_def, func_doc, fp):
|
||||
prototype = self.create_constructor_prototype(func_def)
|
||||
fp.write('<programlisting>%s</programlisting>\n' % prototype)
|
||||
self.write_params(func_def.params, func_def.ret, func_doc, fp)
|
||||
|
||||
if func_doc and func_doc.description:
|
||||
fp.write(self.reformat_text(func_doc.description))
|
||||
fp.write('\n\n\n')
|
||||
|
||||
def write_method(self, meth_def, func_doc, fp):
|
||||
fp.write(' <refsect2 id="' + self.make_method_ref(meth_def) + '">\n')
|
||||
fp.write(' <title>' + self.pyname(meth_def.of_object) + '.' +
|
||||
meth_def.name + '</title>\n\n')
|
||||
prototype = self.create_method_prototype(meth_def)
|
||||
fp.write('<programlisting>%s</programlisting>\n' % prototype)
|
||||
self.write_params(meth_def.params, meth_def.ret, func_doc, fp)
|
||||
if func_doc and func_doc.description:
|
||||
fp.write(self.reformat_text(func_doc.description))
|
||||
fp.write(' </refsect2>\n\n\n')
|
||||
|
||||
def output_toc(self, files, fp=sys.stdout):
|
||||
if self.use_xml:
|
||||
fp.write('<?xml version="1.0" standalone="no"?>\n')
|
||||
fp.write('<!DOCTYPE reference PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"\n')
|
||||
fp.write(' "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">\n')
|
||||
#for filename, obj_def in files:
|
||||
# fp.write(' <!ENTITY ' + string.translate(obj_def.c_name,
|
||||
# self.__transtable) +
|
||||
# ' SYSTEM "' + filename + '" >\n')
|
||||
#fp.write(']>\n\n')
|
||||
|
||||
#fp.write('<reference id="class-reference">\n')
|
||||
#fp.write(' <title>Class Documentation</title>\n')
|
||||
#for filename, obj_def in files:
|
||||
# fp.write('&' + string.translate(obj_def.c_name,
|
||||
# self.__transtable) + ';\n')
|
||||
#fp.write('</reference>\n')
|
||||
|
||||
fp.write('<reference id="class-reference" xmlns:xi="http://www.w3.org/2001/XInclude">\n')
|
||||
fp.write(' <title>Class Reference</title>\n')
|
||||
for filename, obj_def in files:
|
||||
fp.write(' <xi:include href="%s"/>\n' % filename)
|
||||
fp.write('</reference>\n')
|
||||
else:
|
||||
fp.write('<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1.2//EN" [\n')
|
||||
for filename, obj_def in files:
|
||||
fp.write(' <!ENTITY ' + string.translate(obj_def.c_name,
|
||||
self.__transtable) +
|
||||
' SYSTEM "' + filename + '" >\n')
|
||||
fp.write(']>\n\n')
|
||||
|
||||
fp.write('<book id="index">\n\n')
|
||||
fp.write(' <bookinfo>\n')
|
||||
fp.write(' <title>PyGTK Docs</title>\n')
|
||||
fp.write(' <authorgroup>\n')
|
||||
fp.write(' <author>\n')
|
||||
fp.write(' <firstname>James</firstname>\n')
|
||||
fp.write(' <surname>Henstridge</surname>\n')
|
||||
fp.write(' </author>\n')
|
||||
fp.write(' </authorgroup>\n')
|
||||
fp.write(' </bookinfo>\n\n')
|
||||
|
||||
fp.write(' <chapter id="class-hierarchy">\n')
|
||||
fp.write(' <title>Class Hierarchy</title>\n')
|
||||
fp.write(' <para>Not done yet</para>\n')
|
||||
fp.write(' </chapter>\n\n')
|
||||
|
||||
fp.write(' <reference id="class-reference">\n')
|
||||
fp.write(' <title>Class Documentation</title>\n')
|
||||
for filename, obj_def in files:
|
||||
fp.write('&' + string.translate(obj_def.c_name,
|
||||
self.__transtable) + ';\n')
|
||||
|
||||
fp.write(' </reference>\n')
|
||||
fp.write('</book>\n')
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "d:s:o:",
|
||||
["defs-file=", "override=", "source-dir=",
|
||||
"output-prefix="])
|
||||
except getopt.error, e:
|
||||
sys.stderr.write('docgen.py: %s\n' % e)
|
||||
sys.stderr.write(
|
||||
'usage: docgen.py -d file.defs [-s /src/dir] [-o output-prefix]\n')
|
||||
sys.exit(1)
|
||||
defs_file = None
|
||||
overrides_file = None
|
||||
source_dirs = []
|
||||
output_prefix = 'docs'
|
||||
for opt, arg in opts:
|
||||
if opt in ('-d', '--defs-file'):
|
||||
defs_file = arg
|
||||
if opt in ('--override',):
|
||||
overrides_file = arg
|
||||
elif opt in ('-s', '--source-dir'):
|
||||
source_dirs.append(arg)
|
||||
elif opt in ('-o', '--output-prefix'):
|
||||
output_prefix = arg
|
||||
if len(args) != 0 or not defs_file:
|
||||
sys.stderr.write(
|
||||
'usage: docgen.py -d file.defs [-s /src/dir] [-o output-prefix]\n')
|
||||
sys.exit(1)
|
||||
|
||||
d = DocbookDocWriter()
|
||||
d.add_sourcedirs(source_dirs)
|
||||
d.add_docs(defs_file, overrides_file, 'gtk')
|
||||
d.output_docs(output_prefix)
|
536
codegen/h2def.py
536
codegen/h2def.py
|
@ -1,536 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
# Search through a header file looking for function prototypes.
|
||||
# For each prototype, generate a scheme style definition.
|
||||
# GPL'ed
|
||||
# Toby D. Reeves <toby@max.rl.plh.af.mil>
|
||||
#
|
||||
# Modified by James Henstridge <james@daa.com.au> to output stuff in
|
||||
# Havoc's new defs format. Info on this format can be seen at:
|
||||
# http://www.gnome.org/mailing-lists/archives/gtk-devel-list/2000-January/0085.shtml
|
||||
# Updated to be PEP-8 compatible and refactored to use OOP
|
||||
|
||||
import getopt
|
||||
import os
|
||||
import re
|
||||
import string
|
||||
import sys
|
||||
|
||||
import defsparser
|
||||
|
||||
# ------------------ Create typecodes from typenames ---------
|
||||
|
||||
_upperstr_pat1 = re.compile(r'([^A-Z])([A-Z])')
|
||||
_upperstr_pat2 = re.compile(r'([A-Z][A-Z])([A-Z][0-9a-z])')
|
||||
_upperstr_pat3 = re.compile(r'^([A-Z])([A-Z])')
|
||||
|
||||
def to_upper_str(name):
|
||||
"""Converts a typename to the equivalent upercase and underscores
|
||||
name. This is used to form the type conversion macros and enum/flag
|
||||
name variables"""
|
||||
name = _upperstr_pat1.sub(r'\1_\2', name)
|
||||
name = _upperstr_pat2.sub(r'\1_\2', name)
|
||||
name = _upperstr_pat3.sub(r'\1_\2', name, count=1)
|
||||
return string.upper(name)
|
||||
|
||||
def typecode(typename):
|
||||
"""create a typecode (eg. GTK_TYPE_WIDGET) from a typename"""
|
||||
return string.replace(to_upper_str(typename), '_', '_TYPE_', 1)
|
||||
|
||||
|
||||
# ------------------ Find object definitions -----------------
|
||||
|
||||
def strip_comments(buf):
|
||||
parts = []
|
||||
lastpos = 0
|
||||
while 1:
|
||||
pos = string.find(buf, '/*', lastpos)
|
||||
if pos >= 0:
|
||||
parts.append(buf[lastpos:pos])
|
||||
pos = string.find(buf, '*/', pos)
|
||||
if pos >= 0:
|
||||
lastpos = pos + 2
|
||||
else:
|
||||
break
|
||||
else:
|
||||
parts.append(buf[lastpos:])
|
||||
break
|
||||
return string.join(parts, '')
|
||||
|
||||
obj_name_pat = "[A-Z][a-z]*[A-Z][A-Za-z0-9]*"
|
||||
|
||||
split_prefix_pat = re.compile('([A-Z]+[a-z]*)([A-Za-z0-9]+)')
|
||||
|
||||
def find_obj_defs(buf, objdefs=[]):
|
||||
"""
|
||||
Try to find object definitions in header files.
|
||||
"""
|
||||
|
||||
# filter out comments from buffer.
|
||||
buf = strip_comments(buf)
|
||||
|
||||
maybeobjdefs = [] # contains all possible objects from file
|
||||
|
||||
# first find all structures that look like they may represent a GtkObject
|
||||
pat = re.compile("struct _(" + obj_name_pat + ")\s*{\s*" +
|
||||
"(" + obj_name_pat + ")\s+", re.MULTILINE)
|
||||
pos = 0
|
||||
while pos < len(buf):
|
||||
m = pat.search(buf, pos)
|
||||
if not m: break
|
||||
maybeobjdefs.append((m.group(1), m.group(2)))
|
||||
pos = m.end()
|
||||
|
||||
# handle typedef struct { ... } style struct defs.
|
||||
pat = re.compile("typedef struct\s+[_\w]*\s*{\s*" +
|
||||
"(" + obj_name_pat + ")\s+[^}]*}\s*" +
|
||||
"(" + obj_name_pat + ")\s*;", re.MULTILINE)
|
||||
pos = 0
|
||||
while pos < len(buf):
|
||||
m = pat.search(buf, pos)
|
||||
if not m: break
|
||||
maybeobjdefs.append((m.group(2), m.group(2)))
|
||||
pos = m.end()
|
||||
|
||||
# now find all structures that look like they might represent a class:
|
||||
pat = re.compile("struct _(" + obj_name_pat + ")Class\s*{\s*" +
|
||||
"(" + obj_name_pat + ")Class\s+", re.MULTILINE)
|
||||
pos = 0
|
||||
while pos < len(buf):
|
||||
m = pat.search(buf, pos)
|
||||
if not m: break
|
||||
t = (m.group(1), m.group(2))
|
||||
# if we find an object structure together with a corresponding
|
||||
# class structure, then we have probably found a GtkObject subclass.
|
||||
if t in maybeobjdefs:
|
||||
objdefs.append(t)
|
||||
pos = m.end()
|
||||
|
||||
pat = re.compile("typedef struct\s+[_\w]*\s*{\s*" +
|
||||
"(" + obj_name_pat + ")Class\s+[^}]*}\s*" +
|
||||
"(" + obj_name_pat + ")Class\s*;", re.MULTILINE)
|
||||
pos = 0
|
||||
while pos < len(buf):
|
||||
m = pat.search(buf, pos)
|
||||
if not m: break
|
||||
t = (m.group(2), m.group(1))
|
||||
# if we find an object structure together with a corresponding
|
||||
# class structure, then we have probably found a GtkObject subclass.
|
||||
if t in maybeobjdefs:
|
||||
objdefs.append(t)
|
||||
pos = m.end()
|
||||
|
||||
# now find all structures that look like they might represent
|
||||
# a class inherited from GTypeInterface:
|
||||
pat = re.compile("struct _(" + obj_name_pat + ")Class\s*{\s*" +
|
||||
"GTypeInterface\s+", re.MULTILINE)
|
||||
pos = 0
|
||||
while pos < len(buf):
|
||||
m = pat.search(buf, pos)
|
||||
if not m: break
|
||||
t = (m.group(1), '')
|
||||
t2 = (m.group(1)+'Class', 'GTypeInterface')
|
||||
# if we find an object structure together with a corresponding
|
||||
# class structure, then we have probably found a GtkObject subclass.
|
||||
if t2 in maybeobjdefs:
|
||||
objdefs.append(t)
|
||||
pos = m.end()
|
||||
|
||||
# now find all structures that look like they might represent
|
||||
# an Iface inherited from GTypeInterface:
|
||||
pat = re.compile("struct _(" + obj_name_pat + ")Iface\s*{\s*" +
|
||||
"GTypeInterface\s+", re.MULTILINE)
|
||||
pos = 0
|
||||
while pos < len(buf):
|
||||
m = pat.search(buf, pos)
|
||||
if not m: break
|
||||
t = (m.group(1), '')
|
||||
t2 = (m.group(1)+'Iface', 'GTypeInterface')
|
||||
# if we find an object structure together with a corresponding
|
||||
# class structure, then we have probably found a GtkObject subclass.
|
||||
if t2 in maybeobjdefs:
|
||||
objdefs.append(t)
|
||||
pos = m.end()
|
||||
|
||||
def sort_obj_defs(objdefs):
|
||||
objdefs.sort() # not strictly needed, but looks nice
|
||||
pos = 0
|
||||
while pos < len(objdefs):
|
||||
klass,parent = objdefs[pos]
|
||||
for i in range(pos+1, len(objdefs)):
|
||||
# parent below subclass ... reorder
|
||||
if objdefs[i][0] == parent:
|
||||
objdefs.insert(i+1, objdefs[pos])
|
||||
del objdefs[pos]
|
||||
break
|
||||
else:
|
||||
pos = pos + 1
|
||||
return objdefs
|
||||
|
||||
# ------------------ Find enum definitions -----------------
|
||||
|
||||
def find_enum_defs(buf, enums=[]):
|
||||
# strip comments
|
||||
# bulk comments
|
||||
buf = strip_comments(buf)
|
||||
|
||||
buf = re.sub('\n', ' ', buf)
|
||||
|
||||
enum_pat = re.compile(r'enum\s*{([^}]*)}\s*([A-Z][A-Za-z]*)(\s|;)')
|
||||
splitter = re.compile(r'\s*,\s', re.MULTILINE)
|
||||
pos = 0
|
||||
while pos < len(buf):
|
||||
m = enum_pat.search(buf, pos)
|
||||
if not m: break
|
||||
|
||||
name = m.group(2)
|
||||
vals = m.group(1)
|
||||
isflags = string.find(vals, '<<') >= 0
|
||||
entries = []
|
||||
for val in splitter.split(vals):
|
||||
if not string.strip(val): continue
|
||||
entries.append(string.split(val)[0])
|
||||
if name != 'GdkCursorType':
|
||||
enums.append((name, isflags, entries))
|
||||
|
||||
pos = m.end()
|
||||
|
||||
# ------------------ Find function definitions -----------------
|
||||
|
||||
def clean_func(buf):
|
||||
"""
|
||||
Ideally would make buf have a single prototype on each line.
|
||||
Actually just cuts out a good deal of junk, but leaves lines
|
||||
where a regex can figure prototypes out.
|
||||
"""
|
||||
# bulk comments
|
||||
buf = strip_comments(buf)
|
||||
|
||||
# compact continued lines
|
||||
pat = re.compile(r"""\\\n""", re.MULTILINE)
|
||||
buf = pat.sub('', buf)
|
||||
|
||||
# Preprocess directives
|
||||
pat = re.compile(r"""^[#].*?$""", re.MULTILINE)
|
||||
buf = pat.sub('', buf)
|
||||
|
||||
#typedefs, stucts, and enums
|
||||
pat = re.compile(r"""^(typedef|struct|enum)(\s|.|\n)*?;\s*""",
|
||||
re.MULTILINE)
|
||||
buf = pat.sub('', buf)
|
||||
|
||||
#strip DECLS macros
|
||||
pat = re.compile(r"""G_BEGIN_DECLS|BEGIN_LIBGTOP_DECLS""", re.MULTILINE)
|
||||
buf = pat.sub('', buf)
|
||||
|
||||
#extern "C"
|
||||
pat = re.compile(r"""^\s*(extern)\s+\"C\"\s+{""", re.MULTILINE)
|
||||
buf = pat.sub('', buf)
|
||||
|
||||
#multiple whitespace
|
||||
pat = re.compile(r"""\s+""", re.MULTILINE)
|
||||
buf = pat.sub(' ', buf)
|
||||
|
||||
#clean up line ends
|
||||
pat = re.compile(r""";\s*""", re.MULTILINE)
|
||||
buf = pat.sub('\n', buf)
|
||||
buf = buf.lstrip()
|
||||
|
||||
#associate *, &, and [] with type instead of variable
|
||||
#pat = re.compile(r'\s+([*|&]+)\s*(\w+)')
|
||||
pat = re.compile(r' \s* ([*|&]+) \s* (\w+)', re.VERBOSE)
|
||||
buf = pat.sub(r'\1 \2', buf)
|
||||
pat = re.compile(r'\s+ (\w+) \[ \s* \]', re.VERBOSE)
|
||||
buf = pat.sub(r'[] \1', buf)
|
||||
|
||||
# make return types that are const work.
|
||||
buf = string.replace(buf, 'G_CONST_RETURN ', 'const-')
|
||||
buf = string.replace(buf, 'const ', 'const-')
|
||||
|
||||
return buf
|
||||
|
||||
proto_pat=re.compile(r"""
|
||||
(?P<ret>(-|\w|\&|\*)+\s*) # return type
|
||||
\s+ # skip whitespace
|
||||
(?P<func>\w+)\s*[(] # match the function name until the opening (
|
||||
\s*(?P<args>.*?)\s*[)] # group the function arguments
|
||||
""", re.IGNORECASE|re.VERBOSE)
|
||||
#"""
|
||||
arg_split_pat = re.compile("\s*,\s*")
|
||||
|
||||
get_type_pat = re.compile(r'(const-)?([A-Za-z0-9]+)\*?\s+')
|
||||
pointer_pat = re.compile('.*\*$')
|
||||
func_new_pat = re.compile('(\w+)_new$')
|
||||
|
||||
class DefsWriter:
|
||||
def __init__(self, fp=None, prefix=None, verbose=False,
|
||||
defsfilter=None):
|
||||
if not fp:
|
||||
fp = sys.stdout
|
||||
|
||||
self.fp = fp
|
||||
self.prefix = prefix
|
||||
self.verbose = verbose
|
||||
|
||||
self._enums = {}
|
||||
self._objects = {}
|
||||
self._functions = {}
|
||||
if defsfilter:
|
||||
filter = defsparser.DefsParser(defsfilter)
|
||||
filter.startParsing()
|
||||
for func in filter.functions + filter.methods.values():
|
||||
self._functions[func.c_name] = func
|
||||
for obj in filter.objects + filter.boxes + filter.interfaces:
|
||||
self._objects[obj.c_name] = func
|
||||
for obj in filter.enums:
|
||||
self._enums[obj.c_name] = func
|
||||
|
||||
def write_def(self, deffile):
|
||||
buf = open(deffile).read()
|
||||
|
||||
self.fp.write('\n;; From %s\n\n' % os.path.basename(deffile))
|
||||
self._define_func(buf)
|
||||
self.fp.write('\n')
|
||||
|
||||
def write_enum_defs(self, enums, fp=None):
|
||||
if not fp:
|
||||
fp = self.fp
|
||||
|
||||
fp.write(';; Enumerations and flags ...\n\n')
|
||||
trans = string.maketrans(string.uppercase + '_',
|
||||
string.lowercase + '-')
|
||||
filter = self._enums
|
||||
for cname, isflags, entries in enums:
|
||||
if filter:
|
||||
if cname in filter:
|
||||
continue
|
||||
name = cname
|
||||
module = None
|
||||
m = split_prefix_pat.match(cname)
|
||||
if m:
|
||||
module = m.group(1)
|
||||
name = m.group(2)
|
||||
if isflags:
|
||||
fp.write('(define-flags ' + name + '\n')
|
||||
else:
|
||||
fp.write('(define-enum ' + name + '\n')
|
||||
if module:
|
||||
fp.write(' (in-module "' + module + '")\n')
|
||||
fp.write(' (c-name "' + cname + '")\n')
|
||||
fp.write(' (gtype-id "' + typecode(cname) + '")\n')
|
||||
prefix = entries[0]
|
||||
for ent in entries:
|
||||
# shorten prefix til we get a match ...
|
||||
# and handle GDK_FONT_FONT, GDK_FONT_FONTSET case
|
||||
while ent[:len(prefix)] != prefix or len(prefix) >= len(ent):
|
||||
prefix = prefix[:-1]
|
||||
prefix_len = len(prefix)
|
||||
fp.write(' (values\n')
|
||||
for ent in entries:
|
||||
fp.write(' \'("%s" "%s")\n' %
|
||||
(string.translate(ent[prefix_len:], trans), ent))
|
||||
fp.write(' )\n')
|
||||
fp.write(')\n\n')
|
||||
|
||||
def write_obj_defs(self, objdefs, fp=None):
|
||||
if not fp:
|
||||
fp = self.fp
|
||||
|
||||
fp.write(';; -*- scheme -*-\n')
|
||||
fp.write('; object definitions ...\n')
|
||||
|
||||
filter = self._objects
|
||||
for klass, parent in objdefs:
|
||||
if filter:
|
||||
if klass in filter:
|
||||
continue
|
||||
m = split_prefix_pat.match(klass)
|
||||
cmodule = None
|
||||
cname = klass
|
||||
if m:
|
||||
cmodule = m.group(1)
|
||||
cname = m.group(2)
|
||||
fp.write('(define-object ' + cname + '\n')
|
||||
if cmodule:
|
||||
fp.write(' (in-module "' + cmodule + '")\n')
|
||||
if parent:
|
||||
fp.write(' (parent "' + parent + '")\n')
|
||||
fp.write(' (c-name "' + klass + '")\n')
|
||||
fp.write(' (gtype-id "' + typecode(klass) + '")\n')
|
||||
# should do something about accessible fields
|
||||
fp.write(')\n\n')
|
||||
|
||||
def _define_func(self, buf):
|
||||
buf = clean_func(buf)
|
||||
buf = string.split(buf,'\n')
|
||||
filter = self._functions
|
||||
for p in buf:
|
||||
if not p:
|
||||
continue
|
||||
m = proto_pat.match(p)
|
||||
if m == None:
|
||||
if self.verbose:
|
||||
sys.stderr.write('No match:|%s|\n' % p)
|
||||
continue
|
||||
func = m.group('func')
|
||||
if func[0] == '_':
|
||||
continue
|
||||
if filter:
|
||||
if func in filter:
|
||||
continue
|
||||
ret = m.group('ret')
|
||||
args = m.group('args')
|
||||
args = arg_split_pat.split(args)
|
||||
for i in range(len(args)):
|
||||
spaces = string.count(args[i], ' ')
|
||||
if spaces > 1:
|
||||
args[i] = string.replace(args[i], ' ', '-', spaces - 1)
|
||||
|
||||
self._write_func(func, ret, args)
|
||||
|
||||
def _write_func(self, name, ret, args):
|
||||
if len(args) >= 1:
|
||||
# methods must have at least one argument
|
||||
munged_name = name.replace('_', '')
|
||||
m = get_type_pat.match(args[0])
|
||||
if m:
|
||||
obj = m.group(2)
|
||||
if munged_name[:len(obj)] == obj.lower():
|
||||
self._write_method(obj, name, ret, args)
|
||||
return
|
||||
|
||||
if self.prefix:
|
||||
l = len(self.prefix)
|
||||
if name[:l] == self.prefix and name[l] == '_':
|
||||
fname = name[l+1:]
|
||||
else:
|
||||
fname = name
|
||||
else:
|
||||
fname = name
|
||||
|
||||
# it is either a constructor or normal function
|
||||
self.fp.write('(define-function ' + fname + '\n')
|
||||
self.fp.write(' (c-name "' + name + '")\n')
|
||||
|
||||
# Hmmm... Let's asume that a constructor function name
|
||||
# ends with '_new' and it returns a pointer.
|
||||
m = func_new_pat.match(name)
|
||||
if pointer_pat.match(ret) and m:
|
||||
cname = ''
|
||||
for s in m.group(1).split ('_'):
|
||||
cname += s.title()
|
||||
if cname != '':
|
||||
self.fp.write(' (is-constructor-of "' + cname + '")\n')
|
||||
|
||||
self._write_return(ret)
|
||||
self._write_arguments(args)
|
||||
|
||||
def _write_method(self, obj, name, ret, args):
|
||||
regex = string.join(map(lambda x: x+'_?', string.lower(obj)),'')
|
||||
mname = re.sub(regex, '', name, 1)
|
||||
if self.prefix:
|
||||
l = len(self.prefix) + 1
|
||||
if mname[:l] == self.prefix and mname[l+1] == '_':
|
||||
mname = mname[l+1:]
|
||||
self.fp.write('(define-method ' + mname + '\n')
|
||||
self.fp.write(' (of-object "' + obj + '")\n')
|
||||
self.fp.write(' (c-name "' + name + '")\n')
|
||||
self._write_return(ret)
|
||||
self._write_arguments(args[1:])
|
||||
|
||||
def _write_return(self, ret):
|
||||
if ret != 'void':
|
||||
self.fp.write(' (return-type "' + ret + '")\n')
|
||||
else:
|
||||
self.fp.write(' (return-type "none")\n')
|
||||
|
||||
def _write_arguments(self, args):
|
||||
is_varargs = 0
|
||||
has_args = len(args) > 0
|
||||
for arg in args:
|
||||
if arg == '...':
|
||||
is_varargs = 1
|
||||
elif arg in ('void', 'void '):
|
||||
has_args = 0
|
||||
if has_args:
|
||||
self.fp.write(' (parameters\n')
|
||||
for arg in args:
|
||||
if arg != '...':
|
||||
tupleArg = tuple(string.split(arg))
|
||||
if len(tupleArg) == 2:
|
||||
self.fp.write(' \'("%s" "%s")\n' % tupleArg)
|
||||
self.fp.write(' )\n')
|
||||
if is_varargs:
|
||||
self.fp.write(' (varargs #t)\n')
|
||||
self.fp.write(')\n\n')
|
||||
|
||||
# ------------------ Main function -----------------
|
||||
|
||||
def main(args):
|
||||
verbose = False
|
||||
onlyenums = False
|
||||
onlyobjdefs = False
|
||||
separate = False
|
||||
modulename = None
|
||||
defsfilter = None
|
||||
opts, args = getopt.getopt(args[1:], 'vs:m:f:',
|
||||
['onlyenums', 'onlyobjdefs',
|
||||
'modulename=', 'separate=',
|
||||
'defsfilter='])
|
||||
for o, v in opts:
|
||||
if o == '-v':
|
||||
verbose = True
|
||||
if o == '--onlyenums':
|
||||
onlyenums = True
|
||||
if o == '--onlyobjdefs':
|
||||
onlyobjdefs = True
|
||||
if o in ('-s', '--separate'):
|
||||
separate = v
|
||||
if o in ('-m', '--modulename'):
|
||||
modulename = v
|
||||
if o in ('-f', '--defsfilter'):
|
||||
defsfilter = v
|
||||
|
||||
if not args[0:1]:
|
||||
print 'Must specify at least one input file name'
|
||||
return -1
|
||||
|
||||
# read all the object definitions in
|
||||
objdefs = []
|
||||
enums = []
|
||||
for filename in args:
|
||||
buf = open(filename).read()
|
||||
find_obj_defs(buf, objdefs)
|
||||
find_enum_defs(buf, enums)
|
||||
objdefs = sort_obj_defs(objdefs)
|
||||
|
||||
if separate:
|
||||
methods = file(separate + '.defs', 'w')
|
||||
types = file(separate + '-types.defs', 'w')
|
||||
|
||||
dw = DefsWriter(methods, prefix=modulename, verbose=verbose,
|
||||
defsfilter=defsfilter)
|
||||
dw.write_obj_defs(objdefs, types)
|
||||
dw.write_enum_defs(enums, types)
|
||||
print "Wrote %s-types.defs" % separate
|
||||
|
||||
for filename in args:
|
||||
dw.write_def(filename)
|
||||
print "Wrote %s.defs" % separate
|
||||
else:
|
||||
dw = DefsWriter(prefix=modulename, verbose=verbose,
|
||||
defsfilter=defsfilter)
|
||||
|
||||
if onlyenums:
|
||||
dw.write_enum_defs(enums)
|
||||
elif onlyobjdefs:
|
||||
dw.write_obj_defs(objdefs)
|
||||
else:
|
||||
dw.write_obj_defs(objdefs)
|
||||
dw.write_enum_defs(enums)
|
||||
|
||||
for filename in args:
|
||||
dw.write_def(filename)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
|
||||
import optparse
|
||||
|
||||
import defsparser
|
||||
|
||||
parser = optparse.OptionParser(
|
||||
usage="usage: %prog [options] generated-defs old-defs")
|
||||
parser.add_option("-p", "--merge-parameters",
|
||||
help="Merge changes in function/methods parameter lists",
|
||||
action="store_true", dest="parmerge", default=False)
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if len(args) != 2:
|
||||
parser.error("wrong number of arguments")
|
||||
|
||||
newp = defsparser.DefsParser(args[0])
|
||||
oldp = defsparser.DefsParser(args[1])
|
||||
|
||||
newp.startParsing()
|
||||
oldp.startParsing()
|
||||
|
||||
newp.merge(oldp, options.parmerge)
|
||||
|
||||
newp.write_defs()
|
|
@ -1,89 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
|
||||
import sys, os, getopt
|
||||
|
||||
module_init_template = \
|
||||
'/* -*- Mode: C; c-basic-offset: 4 -*- */\n' + \
|
||||
'#ifdef HAVE_CONFIG_H\n' + \
|
||||
'# include "config.h"\n' + \
|
||||
'#endif\n' + \
|
||||
'#include <Python.h>\n' + \
|
||||
'#include <pygtk.h>\n' + \
|
||||
'\n' + \
|
||||
'/* include any extra headers needed here */\n' + \
|
||||
'\n' + \
|
||||
'void %(prefix)s_register_classes(PyObject *d);\n' + \
|
||||
'extern PyMethodDef %(prefix)s_functions[];\n' + \
|
||||
'\n' + \
|
||||
'DL_EXPORT(void)\n' + \
|
||||
'init%(module)s(void)\n' + \
|
||||
'{\n' + \
|
||||
' PyObject *m, *d;\n' + \
|
||||
'\n' + \
|
||||
' /* perform any initialisation required by the library here */\n' + \
|
||||
'\n' + \
|
||||
' m = Py_InitModule("%(module)s", %(prefix)s_functions);\n' + \
|
||||
' d = PyModule_GetDict(m);\n' + \
|
||||
'\n' + \
|
||||
' init_pygtk();\n' + \
|
||||
'\n' + \
|
||||
' %(prefix)s_register_classes(d);\n' + \
|
||||
'\n' + \
|
||||
' /* add anything else to the module dictionary (such as constants) */\n' +\
|
||||
'\n' + \
|
||||
' if (PyErr_Occurred())\n' + \
|
||||
' Py_FatalError("could not initialise module %(module)s");\n' + \
|
||||
'}\n'
|
||||
|
||||
override_template = \
|
||||
'/* -*- Mode: C; c-basic-offset: 4 -*- */\n' + \
|
||||
'%%%%\n' + \
|
||||
'headers\n' + \
|
||||
'/* include any required headers here */\n' + \
|
||||
'%%%%\n' + \
|
||||
'init\n' + \
|
||||
' /* include any code here that needs to be executed before the\n' + \
|
||||
' * extension classes get initialised */\n' + \
|
||||
'%%%%\n' + \
|
||||
'\n' + \
|
||||
'/* you should add appropriate ignore, ignore-glob and\n' + \
|
||||
' * override sections here */\n'
|
||||
|
||||
def open_with_backup(file):
|
||||
if os.path.exists(file):
|
||||
try:
|
||||
os.rename(file, file+'~')
|
||||
except OSError:
|
||||
# fail silently if we can't make a backup
|
||||
pass
|
||||
return open(file, 'w')
|
||||
|
||||
def write_skels(fileprefix, prefix, module):
|
||||
fp = open_with_backup(fileprefix+'module.c')
|
||||
fp.write(module_init_template % { 'prefix': prefix, 'module': module })
|
||||
fp.close()
|
||||
fp = open_with_backup(fileprefix+'.override')
|
||||
fp.write(override_template % { 'prefix': prefix, 'module': module })
|
||||
fp.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
opts, args = getopt.getopt(sys.argv[1:], 'f:p:m:h',
|
||||
['file-prefix=', 'prefix=', 'module=', 'help'])
|
||||
fileprefix = None
|
||||
prefix = None
|
||||
module = None
|
||||
for opt, arg in opts:
|
||||
if opt in ('-f', '--file-prefix'):
|
||||
fileprefix = arg
|
||||
elif opt in ('-p', '--prefix'):
|
||||
prefix = arg
|
||||
elif opt in ('-m', '--module'):
|
||||
module = arg
|
||||
elif opt in ('-h', '--help'):
|
||||
print 'usage: mkskel.py -f fileprefix -p prefix -m module'
|
||||
sys.exit(0)
|
||||
if not fileprefix or not prefix or not module:
|
||||
print 'usage: mkskel.py -f fileprefix -p prefix -m module'
|
||||
sys.exit(1)
|
||||
write_skels(fileprefix, prefix, module)
|
|
@ -1,290 +0,0 @@
|
|||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
|
||||
# this file contains code for loading up an override file. The override file
|
||||
# provides implementations of functions where the code generator could not
|
||||
# do its job correctly.
|
||||
|
||||
import fnmatch
|
||||
import os
|
||||
import re
|
||||
import string
|
||||
import sys
|
||||
|
||||
def class2cname(klass, method):
|
||||
c_name = ''
|
||||
for c in klass:
|
||||
if c.isupper():
|
||||
c_name += '_' + c.lower()
|
||||
else:
|
||||
c_name += c
|
||||
return c_name[1:] + '_' + method
|
||||
|
||||
import_pat = re.compile(r'\s*import\s+(\S+)\.([^\s.]+)\s+as\s+(\S+)')
|
||||
|
||||
class Overrides:
|
||||
def __init__(self, filename=None, path=[]):
|
||||
self.modulename = None
|
||||
self.ignores = {}
|
||||
self.glob_ignores = []
|
||||
self.type_ignores = {}
|
||||
self.overrides = {}
|
||||
self.overridden = {}
|
||||
self.kwargs = {}
|
||||
self.noargs = {}
|
||||
self.onearg = {}
|
||||
self.staticmethod = {}
|
||||
self.classmethod = {}
|
||||
self.startlines = {}
|
||||
self.override_attrs = {}
|
||||
self.override_slots = {}
|
||||
self.headers = ''
|
||||
self.body = ''
|
||||
self.init = ''
|
||||
self.imports = []
|
||||
self.defines = {}
|
||||
self.functions = {}
|
||||
self.newstyle_constructors = {}
|
||||
self.path = [os.path.abspath(x) for x in path]
|
||||
if filename:
|
||||
self.handle_file(filename)
|
||||
|
||||
def handle_file(self, filename):
|
||||
oldpath = os.getcwd()
|
||||
|
||||
fp = None
|
||||
for path in self.path:
|
||||
os.chdir(oldpath)
|
||||
os.chdir(path)
|
||||
try:
|
||||
fp = open(filename, 'r')
|
||||
break
|
||||
except:
|
||||
os.chdir(oldpath)
|
||||
if not fp:
|
||||
raise Exception, "Couldn't find file %s" % filename
|
||||
|
||||
dirname = path
|
||||
|
||||
if dirname != oldpath:
|
||||
os.chdir(dirname)
|
||||
|
||||
# read all the components of the file ...
|
||||
bufs = []
|
||||
startline = 1
|
||||
lines = []
|
||||
line = fp.readline()
|
||||
linenum = 1
|
||||
while line:
|
||||
if line == '%%\n' or line == '%%':
|
||||
if lines:
|
||||
bufs.append((string.join(lines, ''), startline))
|
||||
startline = linenum + 1
|
||||
lines = []
|
||||
else:
|
||||
lines.append(line)
|
||||
line = fp.readline()
|
||||
linenum = linenum + 1
|
||||
if lines:
|
||||
bufs.append((string.join(lines, ''), startline))
|
||||
if not bufs: return
|
||||
|
||||
for buf, startline in bufs:
|
||||
self.__parse_override(buf, startline, filename)
|
||||
|
||||
os.chdir(oldpath)
|
||||
|
||||
def __parse_override(self, buffer, startline, filename):
|
||||
pos = string.find(buffer, '\n')
|
||||
if pos >= 0:
|
||||
line = buffer[:pos]
|
||||
rest = buffer[pos+1:]
|
||||
else:
|
||||
line = buffer ; rest = ''
|
||||
words = string.split(line)
|
||||
if len(words) == 0:
|
||||
return
|
||||
command = words[0]
|
||||
if (command == 'ignore' or
|
||||
command == 'ignore-' + sys.platform):
|
||||
"ignore/ignore-platform [functions..]"
|
||||
for func in words[1:]:
|
||||
self.ignores[func] = 1
|
||||
for func in string.split(rest):
|
||||
self.ignores[func] = 1
|
||||
elif (command == 'ignore-glob' or
|
||||
command == 'ignore-glob-' + sys.platform):
|
||||
"ignore-glob/ignore-glob-platform [globs..]"
|
||||
for func in words[1:]:
|
||||
self.glob_ignores.append(func)
|
||||
for func in string.split(rest):
|
||||
self.glob_ignores.append(func)
|
||||
elif (command == 'ignore-type' or
|
||||
command == 'ignore-type-' + sys.platform):
|
||||
"ignore-type/ignore-type-platform [typenames..]"
|
||||
for typename in words[1:]:
|
||||
self.type_ignores[typename] = 1
|
||||
for typename in string.split(rest):
|
||||
self.type_ignores[typename] = 1
|
||||
elif command == 'override':
|
||||
"override function/method [kwargs|noargs|onearg] [staticmethod|classmethod]"
|
||||
func = words[1]
|
||||
if 'kwargs' in words[1:]:
|
||||
self.kwargs[func] = 1
|
||||
elif 'noargs' in words[1:]:
|
||||
self.noargs[func] = 1
|
||||
elif 'onearg' in words[1:]:
|
||||
self.onearg[func] = True
|
||||
|
||||
if 'staticmethod' in words[1:]:
|
||||
self.staticmethod[func] = True
|
||||
elif 'classmethod' in words[1:]:
|
||||
self.classmethod[func] = True
|
||||
if func in self.overrides:
|
||||
raise RuntimeError("Function %s is being overridden more than once" % (func,))
|
||||
self.overrides[func] = rest
|
||||
self.startlines[func] = (startline + 1, filename)
|
||||
elif command == 'override-attr':
|
||||
"override-slot Class.attr"
|
||||
attr = words[1]
|
||||
self.override_attrs[attr] = rest
|
||||
self.startlines[attr] = (startline + 1, filename)
|
||||
elif command == 'override-slot':
|
||||
"override-slot Class.slot"
|
||||
slot = words[1]
|
||||
self.override_slots[slot] = rest
|
||||
self.startlines[slot] = (startline + 1, filename)
|
||||
elif command == 'headers':
|
||||
"headers"
|
||||
self.headers = '%s\n#line %d "%s"\n%s' % \
|
||||
(self.headers, startline + 1, filename, rest)
|
||||
elif command == 'body':
|
||||
"body"
|
||||
self.body = '%s\n#line %d "%s"\n%s' % \
|
||||
(self.body, startline + 1, filename, rest)
|
||||
elif command == 'init':
|
||||
"init"
|
||||
self.init = '%s\n#line %d "%s"\n%s' % \
|
||||
(self.init, startline + 1, filename, rest)
|
||||
elif command == 'modulename':
|
||||
"modulename name"
|
||||
self.modulename = words[1]
|
||||
elif command == 'include':
|
||||
"include filename"
|
||||
for filename in words[1:]:
|
||||
self.handle_file(filename)
|
||||
for filename in string.split(rest):
|
||||
self.handle_file(filename)
|
||||
elif command == 'import':
|
||||
"import module1 [\n module2, \n module3 ...]"
|
||||
for line in string.split(buffer, '\n'):
|
||||
match = import_pat.match(line)
|
||||
if match:
|
||||
self.imports.append(match.groups())
|
||||
elif command == 'define':
|
||||
"define funcname [kwargs|noargs|onearg] [classmethod|staticmethod]"
|
||||
"define Class.method [kwargs|noargs|onearg] [classmethod|staticmethod]"
|
||||
func = words[1]
|
||||
klass = None
|
||||
if func.find('.') != -1:
|
||||
klass, func = func.split('.', 1)
|
||||
|
||||
if not self.defines.has_key(klass):
|
||||
self.defines[klass] = {}
|
||||
self.defines[klass][func] = rest
|
||||
else:
|
||||
self.functions[func] = rest
|
||||
|
||||
if 'kwargs' in words[1:]:
|
||||
self.kwargs[func] = 1
|
||||
elif 'noargs' in words[1:]:
|
||||
self.noargs[func] = 1
|
||||
elif 'onearg' in words[1:]:
|
||||
self.onearg[func] = 1
|
||||
|
||||
if 'staticmethod' in words[1:]:
|
||||
self.staticmethod[func] = True
|
||||
elif 'classmethod' in words[1:]:
|
||||
self.classmethod[func] = True
|
||||
|
||||
self.startlines[func] = (startline + 1, filename)
|
||||
|
||||
elif command == 'new-constructor':
|
||||
"new-constructor GType"
|
||||
gtype, = words[1:]
|
||||
self.newstyle_constructors[gtype] = True
|
||||
|
||||
def is_ignored(self, name):
|
||||
if self.ignores.has_key(name):
|
||||
return 1
|
||||
for glob in self.glob_ignores:
|
||||
if fnmatch.fnmatchcase(name, glob):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def is_type_ignored(self, name):
|
||||
return name.rstrip('*') in self.type_ignores
|
||||
|
||||
def is_overriden(self, name):
|
||||
return self.overrides.has_key(name)
|
||||
|
||||
def is_already_included(self, name):
|
||||
return self.overridden.has_key(name)
|
||||
|
||||
def override(self, name):
|
||||
self.overridden[name] = 1
|
||||
return self.overrides[name]
|
||||
|
||||
def define(self, klass, name):
|
||||
self.overridden[class2cname(klass, name)] = 1
|
||||
return self.defines[klass][name]
|
||||
|
||||
def function(self, name):
|
||||
return self.functions[name]
|
||||
|
||||
def getstartline(self, name):
|
||||
return self.startlines[name]
|
||||
|
||||
def wants_kwargs(self, name):
|
||||
return self.kwargs.has_key(name)
|
||||
|
||||
def wants_noargs(self, name):
|
||||
return self.noargs.has_key(name)
|
||||
|
||||
def wants_onearg(self, name):
|
||||
return self.onearg.has_key(name)
|
||||
|
||||
def is_staticmethod(self, name):
|
||||
return self.staticmethod.has_key(name)
|
||||
|
||||
def is_classmethod(self, name):
|
||||
return self.classmethod.has_key(name)
|
||||
|
||||
def attr_is_overriden(self, attr):
|
||||
return self.override_attrs.has_key(attr)
|
||||
|
||||
def attr_override(self, attr):
|
||||
return self.override_attrs[attr]
|
||||
|
||||
def slot_is_overriden(self, slot):
|
||||
return self.override_slots.has_key(slot)
|
||||
|
||||
def slot_override(self, slot):
|
||||
return self.override_slots[slot]
|
||||
|
||||
def get_headers(self):
|
||||
return self.headers
|
||||
|
||||
def get_body(self):
|
||||
return self.body
|
||||
|
||||
def get_init(self):
|
||||
return self.init
|
||||
|
||||
def get_imports(self):
|
||||
return self.imports
|
||||
|
||||
def get_defines_for(self, klass):
|
||||
return self.defines.get(klass, {})
|
||||
|
||||
def get_functions(self):
|
||||
return self.functions
|
|
@ -1,771 +0,0 @@
|
|||
### -*- python -*-
|
||||
### Code to generate "Reverse Wrappers", i.e. C->Python wrappers
|
||||
### (C) 2004 Gustavo Carneiro <gjc@gnome.org>
|
||||
import argtypes
|
||||
import os
|
||||
|
||||
DEBUG_MODE = ('PYGTK_CODEGEN_DEBUG' in os.environ)
|
||||
|
||||
def join_ctype_name(ctype, name):
|
||||
'''Joins a C type and a variable name into a single string'''
|
||||
if ctype[-1] != '*':
|
||||
return " ".join((ctype, name))
|
||||
else:
|
||||
return "".join((ctype, name))
|
||||
|
||||
|
||||
class CodeSink(object):
|
||||
def __init__(self):
|
||||
self.indent_level = 0 # current indent level
|
||||
self.indent_stack = [] # previous indent levels
|
||||
|
||||
def _format_code(self, code):
|
||||
assert isinstance(code, str)
|
||||
l = []
|
||||
for line in code.split('\n'):
|
||||
l.append(' '*self.indent_level + line)
|
||||
if l[-1]:
|
||||
l.append('')
|
||||
return '\n'.join(l)
|
||||
|
||||
def writeln(self, line=''):
|
||||
raise NotImplementedError
|
||||
|
||||
def indent(self, level=4):
|
||||
'''Add a certain ammount of indentation to all lines written
|
||||
from now on and until unindent() is called'''
|
||||
self.indent_stack.append(self.indent_level)
|
||||
self.indent_level += level
|
||||
|
||||
def unindent(self):
|
||||
'''Revert indentation level to the value before last indent() call'''
|
||||
self.indent_level = self.indent_stack.pop()
|
||||
|
||||
|
||||
class FileCodeSink(CodeSink):
|
||||
def __init__(self, fp):
|
||||
CodeSink.__init__(self)
|
||||
assert isinstance(fp, file)
|
||||
self.fp = fp
|
||||
|
||||
def writeln(self, line=''):
|
||||
self.fp.write(self._format_code(line))
|
||||
|
||||
class MemoryCodeSink(CodeSink):
|
||||
def __init__(self):
|
||||
CodeSink.__init__(self)
|
||||
self.lines = []
|
||||
|
||||
def writeln(self, line=''):
|
||||
self.lines.append(self._format_code(line))
|
||||
|
||||
def flush_to(self, sink):
|
||||
assert isinstance(sink, CodeSink)
|
||||
for line in self.lines:
|
||||
sink.writeln(line.rstrip())
|
||||
self.lines = []
|
||||
|
||||
def flush(self):
|
||||
l = []
|
||||
for line in self.lines:
|
||||
l.append(self._format_code(line))
|
||||
self.lines = []
|
||||
return "".join(l)
|
||||
|
||||
class ReverseWrapper(object):
|
||||
'''Object that generates a C->Python wrapper'''
|
||||
def __init__(self, cname, is_static=True):
|
||||
assert isinstance(cname, str)
|
||||
|
||||
self.cname = cname
|
||||
## function object we will call, or object whose method we will call
|
||||
self.called_pyobj = None
|
||||
## name of method of self.called_pyobj we will call
|
||||
self.method_name = None
|
||||
self.is_static = is_static
|
||||
|
||||
self.parameters = []
|
||||
self.declarations = MemoryCodeSink()
|
||||
self.post_return_code = MemoryCodeSink()
|
||||
self.body = MemoryCodeSink()
|
||||
self.cleanup_actions = []
|
||||
self.pyargv_items = []
|
||||
self.pyargv_optional_items = []
|
||||
self.pyret_parse_items = [] # list of (format_spec, parameter)
|
||||
|
||||
def set_call_target(self, called_pyobj, method_name=None):
|
||||
assert called_pyobj is not None
|
||||
assert self.called_pyobj is None
|
||||
self.called_pyobj = called_pyobj
|
||||
self.method_name = method_name
|
||||
|
||||
def set_return_type(self, return_type):
|
||||
assert isinstance(return_type, ReturnType)
|
||||
self.return_type = return_type
|
||||
|
||||
def add_parameter(self, param):
|
||||
assert isinstance(param, Parameter)
|
||||
self.parameters.append(param)
|
||||
|
||||
def add_declaration(self, decl_code):
|
||||
self.declarations.writeln(decl_code)
|
||||
|
||||
def add_pyargv_item(self, variable, optional=False):
|
||||
if optional:
|
||||
self.pyargv_optional_items.append(variable)
|
||||
else:
|
||||
self.pyargv_items.append(variable)
|
||||
|
||||
def add_pyret_parse_item(self, format_specifier, parameter, prepend=False):
|
||||
if prepend:
|
||||
self.pyret_parse_items.insert(0, (format_specifier, parameter))
|
||||
else:
|
||||
self.pyret_parse_items.append((format_specifier, parameter))
|
||||
|
||||
def write_code(self, code,
|
||||
cleanup=None,
|
||||
failure_expression=None,
|
||||
failure_cleanup=None,
|
||||
failure_exception=None,
|
||||
code_sink=None):
|
||||
'''Add a chunk of code with cleanup and error handling
|
||||
|
||||
This method is to be used by TypeHandlers when generating code
|
||||
|
||||
Keywork arguments:
|
||||
code -- code to add
|
||||
cleanup -- code to cleanup any dynamic resources created by @code
|
||||
(except in case of failure) (default None)
|
||||
failure_expression -- C boolean expression to indicate
|
||||
if anything failed (default None)
|
||||
failure_cleanup -- code to cleanup any dynamic resources
|
||||
created by @code in case of failure (default None)
|
||||
failure_exception -- code to raise an exception in case of
|
||||
failure (which will be immediately
|
||||
printed and cleared), (default None)
|
||||
code_sink -- "code sink" to use; by default,
|
||||
ReverseWrapper.body is used, which writes the
|
||||
main body of the wrapper, before calling the
|
||||
python method. Alternatively,
|
||||
ReverseWrapper.after_pyret_parse can be used, to
|
||||
write code after the PyArg_ParseTuple that
|
||||
parses the python method return value.
|
||||
'''
|
||||
if code_sink is None:
|
||||
code_sink = self.body
|
||||
if code is not None:
|
||||
code_sink.writeln(code)
|
||||
if failure_expression is not None:
|
||||
code_sink.writeln("if (%s) {" % (failure_expression,))
|
||||
code_sink.indent()
|
||||
if failure_exception is None:
|
||||
code_sink.writeln("if (PyErr_Occurred())")
|
||||
code_sink.indent()
|
||||
code_sink.writeln("PyErr_Print();")
|
||||
code_sink.unindent()
|
||||
else:
|
||||
code_sink.writeln(failure_exception)
|
||||
code_sink.writeln("PyErr_Print();")
|
||||
if failure_cleanup is not None:
|
||||
code_sink.writeln(failure_cleanup)
|
||||
for cleanup_action in self.cleanup_actions:
|
||||
code_sink.writeln(cleanup_action)
|
||||
self.return_type.write_error_return()
|
||||
code_sink.unindent()
|
||||
code_sink.writeln("}")
|
||||
if cleanup is not None:
|
||||
self.cleanup_actions.insert(0, cleanup)
|
||||
|
||||
def generate(self, sink):
|
||||
'''Generate the code into a CodeSink object'''
|
||||
assert isinstance(sink, CodeSink)
|
||||
|
||||
if DEBUG_MODE:
|
||||
self.declarations.writeln("/* begin declarations */")
|
||||
self.body.writeln("/* begin main body */")
|
||||
self.post_return_code.writeln("/* begin post-return code */")
|
||||
|
||||
self.add_declaration("PyGILState_STATE __py_state;")
|
||||
self.write_code(code="__py_state = pyg_gil_state_ensure();",
|
||||
cleanup="pyg_gil_state_release(__py_state);")
|
||||
|
||||
for param in self.parameters:
|
||||
param.convert_c2py()
|
||||
|
||||
assert self.called_pyobj is not None,\
|
||||
"Parameters failed to provide a target function or method."
|
||||
|
||||
if self.is_static:
|
||||
sink.writeln('static %s' % self.return_type.get_c_type())
|
||||
else:
|
||||
sink.writeln(self.return_type.get_c_type())
|
||||
c_proto_params = map(Parameter.format_for_c_proto, self.parameters)
|
||||
sink.writeln("%s(%s)\n{" % (self.cname, ", ".join(c_proto_params)))
|
||||
|
||||
self.return_type.write_decl()
|
||||
self.add_declaration("PyObject *py_retval;")
|
||||
|
||||
## Handle number of arguments
|
||||
if self.pyargv_items:
|
||||
self.add_declaration("PyObject *py_args;")
|
||||
py_args = "py_args"
|
||||
if self.pyargv_optional_items:
|
||||
self.add_declaration("int argc = %i;" % len(self.pyargv_items))
|
||||
argc = "argc"
|
||||
for arg in self.pyargv_optional_items:
|
||||
self.body.writeln("if (%s)" % arg)
|
||||
self.body.indent()
|
||||
self.body.writeln("++argc;")
|
||||
self.body.unindent()
|
||||
else:
|
||||
argc = str(len(self.pyargv_items))
|
||||
else:
|
||||
if self.pyargv_optional_items:
|
||||
self.add_declaration("PyObject *py_args;")
|
||||
py_args = "py_args"
|
||||
self.add_declaration("int argc = 0;")
|
||||
argc = "argc"
|
||||
for arg in self.pyargv_optional_items:
|
||||
self.body.writeln("if (%s)" % arg)
|
||||
self.body.indent()
|
||||
self.body.writeln("++argc;")
|
||||
self.body.unindent()
|
||||
else:
|
||||
py_args = "NULL"
|
||||
argc = None
|
||||
|
||||
self.body.writeln()
|
||||
|
||||
if py_args != "NULL":
|
||||
self.write_code("py_args = PyTuple_New(%s);" % argc,
|
||||
cleanup="Py_DECREF(py_args);")
|
||||
pos = 0
|
||||
for arg in self.pyargv_items:
|
||||
try: # try to remove the Py_DECREF cleanup action, if we can
|
||||
self.cleanup_actions.remove("Py_DECREF(%s);" % arg)
|
||||
except ValueError: # otherwise we have to Py_INCREF..
|
||||
self.body.writeln("Py_INCREF(%s);" % arg)
|
||||
self.body.writeln("PyTuple_SET_ITEM(%s, %i, %s);" % (py_args, pos, arg))
|
||||
pos += 1
|
||||
for arg in self.pyargv_optional_items:
|
||||
self.body.writeln("if (%s) {" % arg)
|
||||
self.body.indent()
|
||||
try: # try to remove the Py_DECREF cleanup action, if we can
|
||||
self.cleanup_actions.remove("Py_XDECREF(%s);" % arg)
|
||||
except ValueError: # otherwise we have to Py_INCREF..
|
||||
self.body.writeln("Py_INCREF(%s);" % arg)
|
||||
self.body.writeln("PyTuple_SET_ITEM(%s, %i, %s);" % (py_args, pos, arg))
|
||||
self.body.unindent()
|
||||
self.body.writeln("}")
|
||||
pos += 1
|
||||
|
||||
self.body.writeln()
|
||||
|
||||
## Call the python method
|
||||
if self.method_name is None:
|
||||
self.write_code("py_retval = PyObject_Call(%s, %s);"
|
||||
% (self.called_pyobj, py_args),
|
||||
cleanup="Py_DECREF(py_retval);",
|
||||
failure_expression="!py_retval")
|
||||
else:
|
||||
self.add_declaration("PyObject *py_method;")
|
||||
self.write_code("py_method = PyObject_GetAttrString(%s, \"%s\");"
|
||||
% (self.called_pyobj, self.method_name),
|
||||
cleanup="Py_DECREF(py_method);",
|
||||
failure_expression="!py_method")
|
||||
self.write_code("py_retval = PyObject_CallObject(py_method, %s);"
|
||||
% (py_args,),
|
||||
cleanup="Py_DECREF(py_retval);",
|
||||
failure_expression="!py_retval")
|
||||
|
||||
## -- Handle the return value --
|
||||
|
||||
## we need to check if the return_type object is prepared to cooperate with multiple return values
|
||||
len_before = len(self.pyret_parse_items)
|
||||
self.return_type.write_conversion()
|
||||
len_after = len(self.pyret_parse_items)
|
||||
assert (self.return_type.get_c_type() == 'void'
|
||||
or not (len_before == len_after and len_after > 0)),\
|
||||
("Bug in reverse wrappers: return type handler %s"
|
||||
" is not prepared to cooperate multiple return values") % (type(self.return_type),)
|
||||
|
||||
sink.indent()
|
||||
|
||||
if len(self.pyret_parse_items) == 1:
|
||||
## if retval is one item only, pack it in a tuple so we
|
||||
## can use PyArg_ParseTuple as usual..
|
||||
self.write_code('py_retval = Py_BuildValue("(N)", py_retval);')
|
||||
if len(self.pyret_parse_items) > 0:
|
||||
## Parse return values using PyArg_ParseTuple
|
||||
self.write_code(code=None, failure_expression=(
|
||||
'!PyArg_ParseTuple(py_retval, "%s", %s)' % (
|
||||
"".join([format for format, param in self.pyret_parse_items]),
|
||||
", ".join([param for format, param in self.pyret_parse_items]))))
|
||||
|
||||
if DEBUG_MODE:
|
||||
self.declarations.writeln("/* end declarations */")
|
||||
self.declarations.flush_to(sink)
|
||||
sink.writeln()
|
||||
if DEBUG_MODE:
|
||||
self.body.writeln("/* end main body */")
|
||||
self.body.flush_to(sink)
|
||||
sink.writeln()
|
||||
if DEBUG_MODE:
|
||||
self.post_return_code.writeln("/* end post-return code */")
|
||||
self.post_return_code.flush_to(sink)
|
||||
sink.writeln()
|
||||
|
||||
for cleanup_action in self.cleanup_actions:
|
||||
sink.writeln(cleanup_action)
|
||||
if self.return_type.get_c_type() != 'void':
|
||||
sink.writeln()
|
||||
sink.writeln("return retval;")
|
||||
sink.unindent()
|
||||
sink.writeln("}")
|
||||
|
||||
class TypeHandler(object):
|
||||
def __init__(self, wrapper, **props):
|
||||
assert isinstance(wrapper, ReverseWrapper)
|
||||
self.wrapper = wrapper
|
||||
self.props = props
|
||||
|
||||
class ReturnType(TypeHandler):
|
||||
|
||||
def get_c_type(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def write_decl(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def write_error_return(self):
|
||||
'''Write "return <value>" code in case of error'''
|
||||
raise NotImplementedError
|
||||
|
||||
def write_conversion(self):
|
||||
'''Writes code to convert Python return value in 'py_retval'
|
||||
into C 'retval'. Returns a string with C boolean expression
|
||||
that determines if anything went wrong. '''
|
||||
raise NotImplementedError
|
||||
|
||||
class Parameter(TypeHandler):
|
||||
|
||||
def __init__(self, wrapper, name, **props):
|
||||
TypeHandler.__init__(self, wrapper, **props)
|
||||
self.name = name
|
||||
|
||||
def get_c_type(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def convert_c2py(self):
|
||||
'''Write some code before calling the Python method.'''
|
||||
pass
|
||||
|
||||
def format_for_c_proto(self):
|
||||
return join_ctype_name(self.get_c_type(), self.name)
|
||||
|
||||
|
||||
###---
|
||||
class StringParam(Parameter):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'char *').replace('const-', 'const ')
|
||||
|
||||
def convert_c2py(self):
|
||||
if self.props.get('optional', False):
|
||||
self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
|
||||
self.wrapper.write_code(code=("if (%s)\n"
|
||||
" py_%s = PyString_FromString(%s);\n"
|
||||
% (self.name, self.name, self.name)),
|
||||
cleanup=("Py_XDECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name, optional=True)
|
||||
else:
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = PyString_FromString(%s);" %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name),
|
||||
failure_expression=("!py_%s" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
for ctype in ('char*', 'gchar*', 'const-char*', 'char-const*', 'const-gchar*',
|
||||
'gchar-const*', 'string', 'static_string'):
|
||||
argtypes.matcher.register_reverse(ctype, StringParam)
|
||||
del ctype
|
||||
|
||||
class StringReturn(ReturnType):
|
||||
|
||||
def get_c_type(self):
|
||||
return "char *"
|
||||
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("char *retval;")
|
||||
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return NULL;")
|
||||
|
||||
def write_conversion(self):
|
||||
self.wrapper.add_pyret_parse_item("s", "&retval", prepend=True)
|
||||
self.wrapper.write_code("retval = g_strdup(retval);", code_sink=self.wrapper.post_return_code)
|
||||
|
||||
for ctype in ('char*', 'gchar*'):
|
||||
argtypes.matcher.register_reverse_ret(ctype, StringReturn)
|
||||
del ctype
|
||||
|
||||
|
||||
class VoidReturn(ReturnType):
|
||||
|
||||
def get_c_type(self):
|
||||
return "void"
|
||||
|
||||
def write_decl(self):
|
||||
pass
|
||||
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return;")
|
||||
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
code=None,
|
||||
failure_expression="py_retval != Py_None",
|
||||
failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be None");')
|
||||
|
||||
argtypes.matcher.register_reverse_ret('void', VoidReturn)
|
||||
argtypes.matcher.register_reverse_ret('none', VoidReturn)
|
||||
|
||||
class GObjectParam(Parameter):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'GObject *')
|
||||
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
|
||||
self.wrapper.write_code(code=("if (%s)\n"
|
||||
" py_%s = pygobject_new((GObject *) %s);\n"
|
||||
"else {\n"
|
||||
" Py_INCREF(Py_None);\n"
|
||||
" py_%s = Py_None;\n"
|
||||
"}"
|
||||
% (self.name, self.name, self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
argtypes.matcher.register_reverse('GObject*', GObjectParam)
|
||||
|
||||
class GObjectReturn(ReturnType):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'GObject *')
|
||||
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("%s retval;" % self.get_c_type())
|
||||
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return NULL;")
|
||||
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
code=None,
|
||||
failure_expression="!PyObject_TypeCheck(py_retval, &PyGObject_Type)",
|
||||
failure_exception='PyErr_SetString(PyExc_TypeError, "retval should be a GObject");')
|
||||
self.wrapper.write_code("retval = (%s) pygobject_get(py_retval);"
|
||||
% self.get_c_type())
|
||||
self.wrapper.write_code("g_object_ref((GObject *) retval);")
|
||||
|
||||
argtypes.matcher.register_reverse_ret('GObject*', GObjectReturn)
|
||||
|
||||
|
||||
|
||||
class IntParam(Parameter):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'int')
|
||||
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = PyInt_FromLong(%s);" %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
class IntReturn(ReturnType):
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'int')
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("%s retval;" % self.get_c_type())
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return -G_MAXINT;")
|
||||
def write_conversion(self):
|
||||
self.wrapper.add_pyret_parse_item("i", "&retval", prepend=True)
|
||||
|
||||
for argtype in ('int', 'gint', 'guint', 'short', 'gshort', 'gushort', 'long',
|
||||
'glong', 'gsize', 'gssize', 'guint8', 'gint8', 'guint16',
|
||||
'gint16', 'gint32', 'GTime'):
|
||||
argtypes.matcher.register_reverse(argtype, IntParam)
|
||||
argtypes.matcher.register_reverse_ret(argtype, IntReturn)
|
||||
del argtype
|
||||
|
||||
class IntPtrParam(Parameter):
|
||||
def __init__(self, wrapper, name, **props):
|
||||
if "direction" not in props:
|
||||
raise ValueError("cannot use int* parameter without direction")
|
||||
if props["direction"] not in ("out", "inout"):
|
||||
raise ValueError("cannot use int* parameter with direction '%s'" % (props["direction"],))
|
||||
Parameter.__init__(self, wrapper, name, **props)
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'int*')
|
||||
def convert_c2py(self):
|
||||
if self.props["direction"] == "inout":
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = PyInt_FromLong(*%s);" %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
self.wrapper.add_pyret_parse_item("i", self.name)
|
||||
for argtype in ('int*', 'gint*'):
|
||||
argtypes.matcher.register_reverse(argtype, IntPtrParam)
|
||||
del argtype
|
||||
|
||||
|
||||
class GEnumReturn(IntReturn):
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
code=None,
|
||||
failure_expression=("pyg_enum_get_value(%s, py_retval, (gint *)&retval)" %
|
||||
self.props['typecode']))
|
||||
|
||||
argtypes.matcher.register_reverse_ret("GEnum", GEnumReturn)
|
||||
|
||||
class GEnumParam(IntParam):
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = pyg_enum_from_gtype(%s, %s);" %
|
||||
(self.name, self.props['typecode'], self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name),
|
||||
failure_expression=("!py_%s" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
argtypes.matcher.register_reverse("GEnum", GEnumParam)
|
||||
|
||||
class GFlagsReturn(IntReturn):
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
code=None,
|
||||
failure_expression=("pyg_flags_get_value(%s, py_retval, (gint *)&retval)" %
|
||||
self.props['typecode']))
|
||||
|
||||
argtypes.matcher.register_reverse_ret("GFlags", GFlagsReturn)
|
||||
|
||||
class GFlagsParam(IntParam):
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = pyg_flags_from_gtype(%s, %s);" %
|
||||
(self.name, self.props['typecode'], self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name),
|
||||
failure_expression=("!py_%s" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
argtypes.matcher.register_reverse("GFlags", GFlagsParam)
|
||||
|
||||
|
||||
class GtkTreePathParam(IntParam):
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = pygtk_tree_path_to_pyobject(%s);" %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name),
|
||||
failure_expression=("!py_%s" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
argtypes.matcher.register_reverse("GtkTreePath*", GtkTreePathParam)
|
||||
|
||||
|
||||
class BooleanReturn(ReturnType):
|
||||
def get_c_type(self):
|
||||
return "gboolean"
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("gboolean retval;")
|
||||
self.wrapper.add_declaration("PyObject *py_main_retval;")
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return FALSE;")
|
||||
def write_conversion(self):
|
||||
self.wrapper.add_pyret_parse_item("O", "&py_main_retval", prepend=True)
|
||||
self.wrapper.write_code("retval = PyObject_IsTrue(py_main_retval)? TRUE : FALSE;",
|
||||
code_sink=self.wrapper.post_return_code)
|
||||
argtypes.matcher.register_reverse_ret("gboolean", BooleanReturn)
|
||||
|
||||
class BooleanParam(Parameter):
|
||||
def get_c_type(self):
|
||||
return "gboolean"
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code("py_%s = %s? Py_True : Py_False;"
|
||||
% (self.name, self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
argtypes.matcher.register_reverse("gboolean", BooleanParam)
|
||||
|
||||
|
||||
class DoubleParam(Parameter):
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'gdouble')
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = PyFloat_FromDouble(%s);" %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
class DoublePtrParam(Parameter):
|
||||
def __init__(self, wrapper, name, **props):
|
||||
if "direction" not in props:
|
||||
raise ValueError("cannot use double* parameter without direction")
|
||||
if props["direction"] not in ("out", ): # inout not yet implemented
|
||||
raise ValueError("cannot use double* parameter with direction '%s'" % (props["direction"],))
|
||||
Parameter.__init__(self, wrapper, name, **props)
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'double*')
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_pyret_parse_item("d", self.name)
|
||||
for argtype in ('double*', 'gdouble*'):
|
||||
argtypes.matcher.register_reverse(argtype, DoublePtrParam)
|
||||
del argtype
|
||||
|
||||
class DoubleReturn(ReturnType):
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'gdouble')
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("%s retval;" % self.get_c_type())
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return -G_MAXFLOAT;")
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
code=None,
|
||||
failure_expression="!PyFloat_AsDouble(py_retval)",
|
||||
failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be a float");')
|
||||
self.wrapper.write_code("retval = PyFloat_AsDouble(py_retval);")
|
||||
|
||||
for argtype in ('float', 'double', 'gfloat', 'gdouble'):
|
||||
argtypes.matcher.register_reverse(argtype, DoubleParam)
|
||||
argtypes.matcher.register_reverse_ret(argtype, DoubleReturn)
|
||||
|
||||
|
||||
class GBoxedParam(Parameter):
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type').replace('const-', 'const ')
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
ctype = self.get_c_type()
|
||||
if ctype.startswith('const '):
|
||||
ctype_no_const = ctype[len('const '):]
|
||||
self.wrapper.write_code(
|
||||
code=('py_%s = pyg_boxed_new(%s, (%s) %s, TRUE, TRUE);' %
|
||||
(self.name, self.props['typecode'],
|
||||
ctype_no_const, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
else:
|
||||
self.wrapper.write_code(
|
||||
code=('py_%s = pyg_boxed_new(%s, %s, FALSE, FALSE);' %
|
||||
(self.name, self.props['typecode'], self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
argtypes.matcher.register_reverse("GBoxed", GBoxedParam)
|
||||
|
||||
class GBoxedReturn(ReturnType):
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type')
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("%s retval;" % self.get_c_type())
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return retval;")
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
failure_expression=("!pyg_boxed_check(py_retval, %s)" %
|
||||
(self.props['typecode'],)),
|
||||
failure_cleanup=('PyErr_SetString(PyExc_TypeError, "retval should be a %s");'
|
||||
% (self.props['typename'],)))
|
||||
self.wrapper.write_code('retval = pyg_boxed_get(py_retval, %s);' %
|
||||
self.props['typename'])
|
||||
|
||||
argtypes.matcher.register_reverse_ret("GBoxed", GBoxedReturn)
|
||||
|
||||
|
||||
class GdkRectanglePtrParam(Parameter):
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type').replace('const-', 'const ')
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(
|
||||
code=('py_%s = pyg_boxed_new(GDK_TYPE_RECTANGLE, %s, TRUE, TRUE);' %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
argtypes.matcher.register_reverse("GdkRectangle*", GdkRectanglePtrParam)
|
||||
argtypes.matcher.register_reverse('GtkAllocation*', GdkRectanglePtrParam)
|
||||
|
||||
|
||||
class PyGObjectMethodParam(Parameter):
|
||||
def __init__(self, wrapper, name, method_name, **props):
|
||||
Parameter.__init__(self, wrapper, name, **props)
|
||||
self.method_name = method_name
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'GObject *')
|
||||
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = pygobject_new((GObject *) %s);" %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name),
|
||||
failure_expression=("!py_%s" % self.name))
|
||||
self.wrapper.set_call_target("py_%s" % self.name, self.method_name)
|
||||
|
||||
class CallbackInUserDataParam(Parameter):
|
||||
def __init__(self, wrapper, name, free_it, **props):
|
||||
Parameter.__init__(self, wrapper, name, **props)
|
||||
self.free_it = free_it
|
||||
|
||||
def get_c_type(self):
|
||||
return "gpointer"
|
||||
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject **_user_data;")
|
||||
cleanup = self.free_it and ("g_free(%s);" % self.name) or None
|
||||
self.wrapper.write_code(code=("_real_user_data = (PyObject **) %s;"
|
||||
% self.name),
|
||||
cleanup=cleanup)
|
||||
|
||||
self.wrapper.add_declaration("PyObject *py_func;")
|
||||
cleanup = self.free_it and "Py_DECREF(py_func);" or None
|
||||
self.wrapper.write_code(code="py_func = _user_data[0];",
|
||||
cleanup=cleanup)
|
||||
self.wrapper.set_call_target("py_func")
|
||||
|
||||
self.wrapper.add_declaration("PyObject *py_user_data;")
|
||||
cleanup = self.free_it and "Py_XDECREF(py_user_data);" or None
|
||||
self.wrapper.write_code(code="py_user_data = _user_data[1];",
|
||||
cleanup=cleanup)
|
||||
self.wrapper.add_pyargv_item("py_user_data", optional=True)
|
||||
|
||||
def _test():
|
||||
import sys
|
||||
|
||||
if 1:
|
||||
wrapper = ReverseWrapper("this_is_the_c_function_name", is_static=True)
|
||||
wrapper.set_return_type(StringReturn(wrapper))
|
||||
wrapper.add_parameter(PyGObjectMethodParam(wrapper, "self", method_name="do_xxx"))
|
||||
wrapper.add_parameter(StringParam(wrapper, "param2", optional=True))
|
||||
wrapper.add_parameter(GObjectParam(wrapper, "param3"))
|
||||
#wrapper.add_parameter(InoutIntParam(wrapper, "param4"))
|
||||
wrapper.generate(FileCodeSink(sys.stderr))
|
||||
|
||||
if 0:
|
||||
wrapper = ReverseWrapper("this_a_callback_wrapper")
|
||||
wrapper.set_return_type(VoidReturn(wrapper))
|
||||
wrapper.add_parameter(StringParam(wrapper, "param1", optional=False))
|
||||
wrapper.add_parameter(GObjectParam(wrapper, "param2"))
|
||||
wrapper.add_parameter(CallbackInUserDataParam(wrapper, "data", free_it=True))
|
||||
wrapper.generate(FileCodeSink(sys.stderr))
|
||||
|
||||
if __name__ == '__main__':
|
||||
_test()
|
|
@ -1,144 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python; py-indent-offset: 4 -*-
|
||||
from __future__ import generators
|
||||
|
||||
import string
|
||||
import types
|
||||
from cStringIO import StringIO
|
||||
|
||||
class error(Exception):
|
||||
def __init__(self, filename, lineno, msg):
|
||||
Exception.__init__(self, msg)
|
||||
self.filename = filename
|
||||
self.lineno = lineno
|
||||
self.msg = msg
|
||||
def __str__(self):
|
||||
return '%s:%d: error: %s' % (self.filename, self.lineno, self.msg)
|
||||
|
||||
trans = [' '] * 256
|
||||
for i in range(256):
|
||||
if chr(i) in string.letters + string.digits + '_':
|
||||
trans[i] = chr(i)
|
||||
else:
|
||||
trans[i] = '_'
|
||||
trans = string.join(trans, '')
|
||||
|
||||
def parse(filename):
|
||||
if isinstance(filename, str):
|
||||
fp = open(filename, 'r')
|
||||
else: # if not string, assume it is some kind of iterator
|
||||
fp = filename
|
||||
filename = getattr(fp, 'name', '<unknown>')
|
||||
whitespace = ' \t\n\r\x0b\x0c'
|
||||
nonsymbol = whitespace + '();\'"'
|
||||
stack = []
|
||||
openlines = []
|
||||
lineno = 0
|
||||
for line in fp:
|
||||
pos = 0
|
||||
lineno += 1
|
||||
while pos < len(line):
|
||||
if line[pos] in whitespace: # ignore whitespace
|
||||
pass
|
||||
elif line[pos] == ';': # comment
|
||||
break
|
||||
elif line[pos:pos+2] == "'(":
|
||||
pass # the open parenthesis will be handled next iteration
|
||||
elif line[pos] == '(':
|
||||
stack.append(())
|
||||
openlines.append(lineno)
|
||||
elif line[pos] == ')':
|
||||
if len(stack) == 0:
|
||||
raise error(filename, lineno, 'close parenthesis found when none open')
|
||||
closed = stack[-1]
|
||||
del stack[-1]
|
||||
del openlines[-1]
|
||||
if stack:
|
||||
stack[-1] += (closed,)
|
||||
else:
|
||||
yield closed
|
||||
elif line[pos] == '"': # quoted string
|
||||
if not stack:
|
||||
raise error(filename, lineno,
|
||||
'string found outside of s-expression')
|
||||
endpos = pos + 1
|
||||
chars = []
|
||||
while endpos < len(line):
|
||||
if endpos+1 < len(line) and line[endpos] == '\\':
|
||||
endpos += 1
|
||||
if line[endpos] == 'n':
|
||||
chars.append('\n')
|
||||
elif line[endpos] == 'r':
|
||||
chars.append('\r')
|
||||
elif line[endpos] == 't':
|
||||
chars.append('\t')
|
||||
else:
|
||||
chars.append('\\')
|
||||
chars.append(line[endpos])
|
||||
elif line[endpos] == '"':
|
||||
break
|
||||
else:
|
||||
chars.append(line[endpos])
|
||||
endpos += 1
|
||||
if endpos >= len(line):
|
||||
raise error(filename, lineno, "unclosed quoted string")
|
||||
pos = endpos
|
||||
stack[-1] += (''.join(chars),)
|
||||
else: # symbol/number
|
||||
if not stack:
|
||||
raise error(filename, lineno,
|
||||
'identifier found outside of s-expression')
|
||||
endpos = pos
|
||||
while endpos < len(line) and line[endpos] not in nonsymbol:
|
||||
endpos += 1
|
||||
symbol = line[pos:endpos]
|
||||
pos = max(pos, endpos-1)
|
||||
try: symbol = int(symbol)
|
||||
except ValueError:
|
||||
try: symbol = float(symbol)
|
||||
except ValueError: pass
|
||||
stack[-1] += (symbol,)
|
||||
pos += 1
|
||||
if len(stack) != 0:
|
||||
msg = '%d unclosed parentheses found at end of ' \
|
||||
'file (opened on line(s) %s)' % (len(stack),
|
||||
', '.join(map(str, openlines)))
|
||||
raise error(filename, lineno, msg)
|
||||
|
||||
class Parser:
|
||||
def __init__(self, filename):
|
||||
"""Argument is either a string, a parse tree, or file object"""
|
||||
self.filename = filename
|
||||
def startParsing(self, filename=None):
|
||||
statements = parse(filename or self.filename)
|
||||
for statement in statements:
|
||||
self.handle(statement)
|
||||
def handle(self, tup):
|
||||
cmd = string.translate(tup[0], trans)
|
||||
if hasattr(self, cmd):
|
||||
getattr(self, cmd)(*tup[1:])
|
||||
else:
|
||||
self.unknown(tup)
|
||||
def unknown(self, tup):
|
||||
pass
|
||||
|
||||
_testString = """; a scheme file
|
||||
(define-func gdk_font_load ; a comment at end of line
|
||||
GdkFont
|
||||
((string name)))
|
||||
|
||||
(define-boxed GdkEvent
|
||||
gdk_event_copy
|
||||
gdk_event_free
|
||||
"sizeof(GdkEvent)")
|
||||
"""
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
if sys.argv[1:]:
|
||||
fp = open(sys.argv[1])
|
||||
else:
|
||||
fp = StringIO(_testString)
|
||||
statements = parse(fp)
|
||||
for s in statements:
|
||||
print `s`
|
422
configure.ac
422
configure.ac
|
@ -3,12 +3,10 @@ AC_PREREQ(2.60)
|
|||
dnl initialize autoconf
|
||||
dnl when going to/from release please set the nano (fourth number) right !
|
||||
dnl releases only do Wall, cvs and prerelease does Werror too
|
||||
AC_INIT(GStreamer Python Bindings, 0.10.22.1,
|
||||
AC_INIT(GStreamer GObject Introspectin tests for Python , 0.11.92,
|
||||
http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
|
||||
gst-python)
|
||||
|
||||
AG_GST_INIT
|
||||
|
||||
dnl initialize automake
|
||||
AM_INIT_AUTOMAKE([-Wno-portability 1.10])
|
||||
|
||||
|
@ -19,7 +17,7 @@ dnl check if this is a release version
|
|||
AS_NANO(GST_CVS="no", GST_CVS="yes")
|
||||
|
||||
dnl can autoconf find the source ?
|
||||
AC_CONFIG_SRCDIR([gst/gstmodule.c])
|
||||
AC_CONFIG_SRCDIR([testsuite/common.py])
|
||||
|
||||
dnl define the output header for config
|
||||
AM_CONFIG_HEADER([config.h])
|
||||
|
@ -27,63 +25,26 @@ AM_CONFIG_HEADER([config.h])
|
|||
dnl AM_MAINTAINER_MODE only provides the option to configure to enable it
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
dnl error out
|
||||
AC_MSG_ERROR([
|
||||
================================================================================
|
||||
Development of gst-python for GStreamer 0.10 has switched to the 0.10
|
||||
branch in git. Do: git checkout -b 0.10 origin/0.10
|
||||
|
||||
The master branch of gst-python is not used any longer for GStreamer 0.11/1.0.
|
||||
Applications will need to be ported over to the new pygi bindings.
|
||||
================================================================================
|
||||
])
|
||||
|
||||
dnl use pretty build output with automake >= 1.11
|
||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],
|
||||
[AM_DEFAULT_VERBOSITY=1
|
||||
AC_SUBST(AM_DEFAULT_VERBOSITY)])
|
||||
|
||||
AC_DEFINE_UNQUOTED(PYGST_MAJOR_VERSION, $PACKAGE_VERSION_MAJOR, [PyGst major version])
|
||||
AC_DEFINE_UNQUOTED(PYGST_MINOR_VERSION, $PACKAGE_VERSION_MINOR, [PyGst minor version])
|
||||
AC_DEFINE_UNQUOTED(PYGST_MICRO_VERSION, $PACKAGE_VERSION_MICRO, [PyGst micro version])
|
||||
AC_DEFINE_UNQUOTED(PYGST_NANO_VERSION, $PACKAGE_VERSION_NANO, [PyGst nano version])
|
||||
AC_SUBST(PACKAGE_VERSION_MAJOR)
|
||||
AC_SUBST(PACKAGE_VERSION_MINOR)
|
||||
AC_SUBST(PACKAGE_VERSION_MICRO)
|
||||
AC_SUBST(PACKAGE_VERSION_NANO)
|
||||
|
||||
dnl Add parameters for aclocal
|
||||
AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I common/m4")
|
||||
|
||||
dnl required versions of other packages
|
||||
AC_SUBST(PYGTK_REQ, 2.6.3)
|
||||
AC_SUBST(PYGOBJECT_REQ, 2.11.2)
|
||||
AC_SUBST(GLIB_REQ, 2.8.0)
|
||||
AC_SUBST(GTK_REQ, 2.6.0)
|
||||
AC_SUBST(GST_REQ, 0.10.20)
|
||||
AC_SUBST(GSTPB_REQ, 0.10.20)
|
||||
|
||||
AC_DISABLE_STATIC
|
||||
|
||||
AC_LIBTOOL_WIN32_DLL
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
dnl find a compiler
|
||||
AC_PROG_CC
|
||||
AC_PROG_CC_STDC
|
||||
|
||||
dnl check if the compiler supports '-c' and '-o' options
|
||||
AM_PROG_CC_C_O
|
||||
|
||||
AG_GST_ARG_GCOV
|
||||
dnl Note that they are runtime requirements
|
||||
AC_SUBST(GST_REQ, 0.11.92)
|
||||
AC_SUBST(GSTPB_REQ, 0.11.92)
|
||||
|
||||
dnl check for python
|
||||
dnl AM_PATH_PYTHON(2.2)
|
||||
AM_PATH_PYTHON
|
||||
AC_MSG_CHECKING(for python >= 2.3)
|
||||
AC_MSG_CHECKING(for python >= 2.5)
|
||||
prog="
|
||||
import sys, string
|
||||
minver = (2,3,0,'final',0)
|
||||
minver = (2,5,0,'final',0)
|
||||
if sys.version_info < minver:
|
||||
sys.exit(1)
|
||||
sys.exit(0)"
|
||||
|
@ -94,384 +55,15 @@ then
|
|||
else
|
||||
AC_MSG_ERROR(too old)
|
||||
fi
|
||||
AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
|
||||
|
||||
dnl check for GStreamer
|
||||
GST_MAJORMINOR=0.10
|
||||
AC_SUBST(GST_MAJORMINOR)
|
||||
PKG_CHECK_MODULES(GST, gstreamer-$GST_MAJORMINOR >= $GST_REQ)
|
||||
AC_DEFINE_UNQUOTED(GST_MAJORMINOR, "$GST_MAJORMINOR", [Gst MajorMinor version])
|
||||
GST_CFLAGS="$GST_CFLAGS $GLIB_EXTRA_CFLAGS"
|
||||
AC_SUBST(GST_CFLAGS)
|
||||
AC_SUBST(GST_LIBS)
|
||||
|
||||
dnl get the installed GStreamer core version
|
||||
GST_MINOR_VERSION=`$PKG_CONFIG --modversion gstreamer-$GST_MAJORMINOR | cut -f 3 -d.`
|
||||
GST_PB_MINOR_VERSION=`$PKG_CONFIG --modversion gstreamer-plugins-base-$GST_MAJORMINOR | cut -f 3 -d.`
|
||||
GST_CVS_VERSION=`$PKG_CONFIG --modversion gstreamer-$GST_MAJORMINOR | cut -f 4 -d.`
|
||||
|
||||
echo "Building against GStreamer core 0.10.$GST_MINOR_VERSION , ignoring API additions if needed"
|
||||
|
||||
dnl Magic for allowing new API additions without forcing dependency on new core
|
||||
dnl release. The lines do the magic so that new API additions are ignored at
|
||||
dnl compile time.
|
||||
dnl * Also see gst/gstversion.override.in and gst-0.10.*.override
|
||||
dnl The following lines should be updated whenever:
|
||||
dnl _ GST_REQ is up-ed (remove obsolete lines + gst-0.10.MINOR.ignore)
|
||||
dnl _ new core/base is released (add lines + gst-0.10.MINOR.ignore)
|
||||
|
||||
if test "x$GST_CVS_VERSION" = "x"
|
||||
then
|
||||
if test $GST_MINOR_VERSION -lt "21"
|
||||
then
|
||||
IGNORE_GST_0_10_21="gst-0.10.21.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_21=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "22"
|
||||
then
|
||||
IGNORE_GST_0_10_22="gst-0.10.22.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_22=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "23"
|
||||
then
|
||||
IGNORE_GST_0_10_23="gst-0.10.23.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_23=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "24"
|
||||
then
|
||||
IGNORE_GST_0_10_24="gst-0.10.24.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_24=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "25"
|
||||
then
|
||||
IGNORE_GST_0_10_25="gst-0.10.25.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_25=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "26"
|
||||
then
|
||||
IGNORE_GST_0_10_26="gst-0.10.26.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_26=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "29"
|
||||
then
|
||||
IGNORE_GST_0_10_29="gst-0.10.29.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_29=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "30"
|
||||
then
|
||||
IGNORE_GST_0_10_30="gst-0.10.30.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_30=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "31"
|
||||
then
|
||||
IGNORE_GST_0_10_31="gst-0.10.31.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_31=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "32"
|
||||
then
|
||||
IGNORE_GST_0_10_32="gst-0.10.32.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_32=""
|
||||
fi
|
||||
|
||||
if test $GST_MINOR_VERSION -lt "36"
|
||||
then
|
||||
IGNORE_GST_0_10_36="gst-0.10.36.ignore"
|
||||
else
|
||||
IGNORE_GST_0_10_36=""
|
||||
fi
|
||||
|
||||
dnl plugins base
|
||||
if test $GST_PB_MINOR_VERSION -ge "22"
|
||||
then
|
||||
AC_DEFINE_UNQUOTED(HAVE_GST_AUDIO, 1, [We can use the gst-audio library])
|
||||
AC_DEFINE_UNQUOTED(HAVE_GST_VIDEO, 1, [We can use the gst-video library])
|
||||
AC_DEFINE_UNQUOTED(HAVE_GST_TAG, 1, [We can use the gst-tag library])
|
||||
fi
|
||||
|
||||
if test $GST_PB_MINOR_VERSION -lt "23"
|
||||
then
|
||||
IGNORE_GST_PB_0_10_23="gst-pb-0.10.23.ignore"
|
||||
else
|
||||
IGNORE_GST_PB_0_10_23=""
|
||||
fi
|
||||
|
||||
if test $GST_PB_MINOR_VERSION -lt "25"
|
||||
then
|
||||
IGNORE_GST_PB_0_10_25="gst-pb-0.10.25.ignore"
|
||||
else
|
||||
IGNORE_GST_PB_0_10_25=""
|
||||
AC_DEFINE_UNQUOTED(HAVE_STREAM_VOLUME_INTERFACE, 1, [We can use the streamvolume interface])
|
||||
fi
|
||||
|
||||
if test $GST_PB_MINOR_VERSION -lt "26"
|
||||
then
|
||||
IGNORE_GST_PB_0_10_26="gst-pb-0.10.26.ignore"
|
||||
else
|
||||
IGNORE_GST_PB_0_10_26=""
|
||||
fi
|
||||
|
||||
if test $GST_PB_MINOR_VERSION -lt "29"
|
||||
then
|
||||
IGNORE_GST_PB_0_10_29="gst-pb-0.10.29.ignore"
|
||||
else
|
||||
IGNORE_GST_PB_0_10_29=""
|
||||
fi
|
||||
|
||||
if test $GST_PB_MINOR_VERSION -lt "30"
|
||||
then
|
||||
IGNORE_GST_PB_0_10_30="gst-pb-0.10.30.ignore"
|
||||
else
|
||||
IGNORE_GST_PB_0_10_30=""
|
||||
fi
|
||||
|
||||
if test $GST_PB_MINOR_VERSION -lt "31"
|
||||
then
|
||||
IGNORE_GST_PB_0_10_31="gst-pb-0.10.31.ignore"
|
||||
else
|
||||
IGNORE_GST_PB_0_10_31=""
|
||||
fi
|
||||
|
||||
if test $GST_PB_MINOR_VERSION -lt "32"
|
||||
then
|
||||
IGNORE_GST_PB_0_10_32="gst-pb-0.10.32.ignore"
|
||||
else
|
||||
IGNORE_GST_PB_0_10_32=""
|
||||
fi
|
||||
|
||||
if test $GST_PB_MINOR_VERSION -lt "36"
|
||||
then
|
||||
IGNORE_GST_PB_0_10_36="gst-pb-0.10.36.ignore"
|
||||
else
|
||||
IGNORE_GST_PB_0_10_36=""
|
||||
fi
|
||||
|
||||
else
|
||||
IGNORE_GST_0_10_18=""
|
||||
IGNORE_GST_0_10_21=""
|
||||
IGNORE_GST_0_10_22=""
|
||||
IGNORE_GST_0_10_23=""
|
||||
IGNORE_GST_0_10_24=""
|
||||
IGNORE_GST_0_10_25=""
|
||||
IGNORE_GST_0_10_26=""
|
||||
IGNORE_GST_0_10_29=""
|
||||
IGNORE_GST_0_10_30=""
|
||||
IGNORE_GST_0_10_31=""
|
||||
IGNORE_GST_0_10_32=""
|
||||
IGNORE_GST_0_10_36=""
|
||||
IGNORE_GST_PB_0_10_23=""
|
||||
IGNORE_GST_PB_0_10_25=""
|
||||
IGNORE_GST_PB_0_10_26=""
|
||||
IGNORE_GST_PB_0_10_29=""
|
||||
IGNORE_GST_PB_0_10_30=""
|
||||
IGNORE_GST_PB_0_10_31=""
|
||||
IGNORE_GST_PB_0_10_32=""
|
||||
IGNORE_GST_PB_0_10_36=""
|
||||
AC_DEFINE_UNQUOTED(HAVE_GST_AUDIO, 1, [We can use the gst-audio library])
|
||||
AC_DEFINE_UNQUOTED(HAVE_GST_VIDEO, 1, [We can use the gst-video library])
|
||||
AC_DEFINE_UNQUOTED(HAVE_GST_TAG, 1, [We can use the gst-tag library])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(HAVE_STREAM_VOLUME_INTERFACE, 1, [We can use the streamvolume interface])
|
||||
AC_SUBST(IGNORE_GST_0_10_21)
|
||||
AC_SUBST(IGNORE_GST_0_10_22)
|
||||
AC_SUBST(IGNORE_GST_0_10_23)
|
||||
AC_SUBST(IGNORE_GST_0_10_24)
|
||||
AC_SUBST(IGNORE_GST_0_10_25)
|
||||
AC_SUBST(IGNORE_GST_0_10_26)
|
||||
AC_SUBST(IGNORE_GST_0_10_29)
|
||||
AC_SUBST(IGNORE_GST_0_10_30)
|
||||
AC_SUBST(IGNORE_GST_0_10_31)
|
||||
AC_SUBST(IGNORE_GST_0_10_32)
|
||||
AC_SUBST(IGNORE_GST_0_10_36)
|
||||
AC_SUBST(IGNORE_GST_PB_0_10_23)
|
||||
AC_SUBST(IGNORE_GST_PB_0_10_25)
|
||||
AC_SUBST(IGNORE_GST_PB_0_10_26)
|
||||
AC_SUBST(IGNORE_GST_PB_0_10_29)
|
||||
AC_SUBST(IGNORE_GST_PB_0_10_30)
|
||||
AC_SUBST(IGNORE_GST_PB_0_10_31)
|
||||
AC_SUBST(IGNORE_GST_PB_0_10_32)
|
||||
AC_SUBST(IGNORE_GST_PB_0_10_36)
|
||||
AM_CONDITIONAL(HAVE_GST_AUDIO, $HAVE_GST_AUDIO)
|
||||
AM_CONDITIONAL(HAVE_GST_VIDEO, $HAVE_GST_VIDEO)
|
||||
AM_CONDITIONAL(HAVE_GST_TAG, $HAVE_GST_TAG)
|
||||
|
||||
dnl check for gstreamer-base; uninstalled is selected preferentially
|
||||
PKG_CHECK_MODULES(GST_BASE, gstreamer-base-$GST_MAJORMINOR >= $GST_REQ,
|
||||
HAVE_GST_BASE="yes", HAVE_GST_BASE="no")
|
||||
|
||||
if test "x$HAVE_GST_BASE" = "xno"; then
|
||||
AC_MSG_ERROR(no GStreamer Base Libs found)
|
||||
fi
|
||||
|
||||
AC_SUBST(GST_BASE_LIBS)
|
||||
AC_SUBST(GST_BASE_CFLAGS)
|
||||
|
||||
|
||||
dnl check for gstreamer core features (subsystems)
|
||||
GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h"
|
||||
AG_GST_PARSE_SUBSYSTEM_DISABLES($GST_CONFIGPATH)
|
||||
if test $GST_DISABLE_LOADSAVE = "1"; then
|
||||
AC_MSG_WARN("Load/Save XML persistence disabled")
|
||||
IGNORE_GST_LOADSAVE="gst-disable-loadsave.ignore"
|
||||
else
|
||||
IGNORE_GST_LOADSAVE=""
|
||||
fi
|
||||
AC_SUBST(IGNORE_GST_LOADSAVE)
|
||||
|
||||
dnl check for gstreamer-controller
|
||||
PKG_CHECK_MODULES(GST_CONTROLLER, gstreamer-controller-$GST_MAJORMINOR >= $GST_REQ,
|
||||
HAVE_GST_CONTROLLER="yes", HAVE_GST_CONTROLLER="no")
|
||||
|
||||
if test "x$HAVE_GST_CONTROLLER" = "xno"; then
|
||||
AC_MSG_ERROR(no GStreamer Controller Libs found)
|
||||
fi
|
||||
|
||||
AC_SUBST(GST_CONTROLLER_LIBS)
|
||||
AC_SUBST(GST_CONTROLLER_CFLAGS)
|
||||
|
||||
dnl check for gstreamer-net
|
||||
PKG_CHECK_MODULES(GST_NET, gstreamer-net-$GST_MAJORMINOR >= $GST_REQ,
|
||||
HAVE_GST_NET="yes", HAVE_GST_NET="no")
|
||||
|
||||
if test "x$HAVE_GST_NET" = "xno"; then
|
||||
AC_MSG_ERROR(no GStreamer Networking Libs found)
|
||||
fi
|
||||
|
||||
AC_SUBST(GST_NET_LIBS)
|
||||
AC_SUBST(GST_NET_CFLAGS)
|
||||
|
||||
dnl check for gstreamer-dataprotocol
|
||||
PKG_CHECK_MODULES(GST_DP, gstreamer-dataprotocol-$GST_MAJORMINOR >= $GST_REQ,
|
||||
HAVE_GST_DP="yes", HAVE_GST_DP="no")
|
||||
|
||||
if test "x$HAVE_GST_DP" = "xno"; then
|
||||
AC_MSG_ERROR(no GStreamer Data Protocol Libs found)
|
||||
fi
|
||||
|
||||
AC_SUBST(GST_DP_LIBS)
|
||||
AC_SUBST(GST_DP_CFLAGS)
|
||||
|
||||
|
||||
dnl check for gst-plugins-base
|
||||
PKG_CHECK_MODULES(GST_PLUGINS_BASE, gstreamer-plugins-base-$GST_MAJORMINOR >= $GSTPB_REQ,
|
||||
HAVE_GST_PLUGINS_BASE="yes", HAVE_GST_PLUGINS_BASE="no")
|
||||
|
||||
if test "x$HAVE_GST_PLUGINS_BASE" = "xno"; then
|
||||
AC_MSG_ERROR(no gst-plugins-base found)
|
||||
fi
|
||||
|
||||
AC_SUBST(GST_PLUGINS_BASE_LIBS)
|
||||
AC_SUBST(GST_PLUGINS_BASE_CFLAGS)
|
||||
|
||||
|
||||
dnl check for pygobject
|
||||
PKG_CHECK_MODULES(PYGOBJECT, pygobject-2.0 >= $PYGOBJECT_REQ,
|
||||
[
|
||||
HAVE_PYGOBJECT="yes"
|
||||
], HAVE_PYGOBJECT="no")
|
||||
|
||||
if test "x$HAVE_PYGOBJECT" = "xno"; then
|
||||
dnl If we don't have pygobject, then check for pygtk
|
||||
dnl check for pygtk
|
||||
PKG_CHECK_MODULES(PYGTK, pygtk-2.0 >= $PYGTK_REQ)
|
||||
AC_SUBST(PYGTK_CFLAGS)
|
||||
PYGOBJECT_CFLAGS="\$(PYGTK_CFLAGS)"
|
||||
fi
|
||||
AC_SUBST(PYGOBJECT_CFLAGS)
|
||||
|
||||
dnl FIXME: check for a pygobject with a correct pyg_param_gvalue_from_pyobject
|
||||
PKG_CHECK_MODULES(PYGOBJECT_2_12, pygobject-2.0 >= 2.11.1,
|
||||
[
|
||||
HAVE_PYGOBJECT_2_12="yes"
|
||||
AC_DEFINE_UNQUOTED(HAVE_PYGOBJECT_2_12, 1,
|
||||
[Defined if we have a 2.12 series pygobject])
|
||||
], HAVE_PYGOBJECT_2_12="no")
|
||||
|
||||
dnl FIXME: check for a pygobject which exports pyg_option_group_new
|
||||
PKG_CHECK_MODULES(PYGOBJECT_2_16, pygobject-2.0 >= 2.15.0,
|
||||
[
|
||||
HAVE_PYGOBJECT_2_16="yes"
|
||||
AC_DEFINE_UNQUOTED(HAVE_PYGOBJECT_2_16, 1,
|
||||
[Defined if we have a 2.16 series pygobject])
|
||||
], HAVE_PYGOBJECT_2_16="no")
|
||||
|
||||
AM_CONDITIONAL(HAVE_PYGOBJECT_2_16, test x$HAVE_PYGOBJECT_2_16 != xno)
|
||||
|
||||
dnl define an ERROR_CFLAGS Makefile variable
|
||||
AG_GST_SET_ERROR_CFLAGS($GST_CVS)
|
||||
|
||||
GST_OPTION_CFLAGS="\$(ERROR_CFLAGS) \$(GCOV_CFLAGS)"
|
||||
AC_SUBST(GST_OPTION_CFLAGS)
|
||||
GST_OPTION_LIBS="\$(GCOV_LIBS)"
|
||||
AC_SUBST(GST_OPTION_LIBS)
|
||||
|
||||
dnl full installation path
|
||||
AS_AC_EXPAND(PYTHONDIR, $pythondir)
|
||||
AS_AC_EXPAND(PYEXECDIR, $pyexecdir)
|
||||
|
||||
PYGST_CFLAGS="-I\$(top_srcdir)/gst -I\$(top_builddir)/gst"
|
||||
AC_SUBST(PYGST_CFLAGS)
|
||||
dnl add debugging options ...
|
||||
# changequote(,)dnl
|
||||
# if test "x$GCC" = xyes; then
|
||||
# case " $CFLAGS " in
|
||||
# *[\ \ ]-Wall[\ \ ]*) ;;
|
||||
# *) CFLAGS="$CFLAGS -Wall" ;;
|
||||
# esac
|
||||
|
||||
# case " $CFLAGS " in
|
||||
# *[\ \ ]-std=c9x[\ \ ]*) ;;
|
||||
# *) CFLAGS="$CFLAGS -std=c9x" ;;
|
||||
# esac
|
||||
# fi
|
||||
# changequote([,])dnl
|
||||
|
||||
AG_GST_VALGRIND_CHECK
|
||||
|
||||
dnl Stuff needed for the python plugin loader
|
||||
|
||||
AM_CHECK_PYTHON_LIBS(,[AC_MSG_ERROR(could not find Python lib)])
|
||||
|
||||
AG_GST_SET_PLUGINDIR
|
||||
|
||||
dnl set release date/time
|
||||
AG_GST_SET_PACKAGE_RELEASE_DATETIME_WITH_NANO([$PACKAGE_VERSION_NANO],
|
||||
["${srcdir}/gst-python.doap"],
|
||||
[$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_MICRO])
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
codegen/Makefile
|
||||
common/Makefile
|
||||
common/m4/Makefile
|
||||
gst/Makefile
|
||||
gst/gstversion.override
|
||||
gst/extend/Makefile
|
||||
examples/Makefile
|
||||
pkgconfig/Makefile
|
||||
pkgconfig/gst-python.pc
|
||||
pkgconfig/gst-python-uninstalled.pc
|
||||
plugin/Makefile
|
||||
testsuite/Makefile
|
||||
win32/common/config.h
|
||||
gst-python.spec
|
||||
gst/__init__.py
|
||||
])
|
||||
|
|
18
gst/.gitignore
vendored
18
gst/.gitignore
vendored
|
@ -1,18 +0,0 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
*.so
|
||||
*.py[co]
|
||||
.libs
|
||||
.deps
|
||||
gst.c
|
||||
pbutils.c
|
||||
gen-*.c
|
||||
interfaces.c
|
||||
play.c
|
||||
gstversion.override
|
||||
audio.c
|
||||
tag.c
|
||||
video.c
|
196
gst/Makefile.am
196
gst/Makefile.am
|
@ -1,196 +0,0 @@
|
|||
common_cflags = $(PYGOBJECT_CFLAGS) $(GST_CFLAGS) $(GST_OPTION_CFLAGS) -fno-strict-aliasing
|
||||
common_libadd = $(GST_LIBS) $(GST_OPTION_LIBS)
|
||||
common_ldflags = -module -avoid-version
|
||||
|
||||
pkgpyexecdir = $(pyexecdir)/gst-$(GST_MAJORMINOR)/gst
|
||||
|
||||
# we install everything in pyexecdir; otherwise you end up with a mess for
|
||||
# multilib
|
||||
pygstdir = $(pkgpyexecdir)
|
||||
pygst_PYTHON = __init__.py
|
||||
|
||||
pygstexecdir = $(pkgpyexecdir)
|
||||
pygstexec_LTLIBRARIES = _gst.la $(interface_lib) $(pbutils_lib)
|
||||
|
||||
interface_lib = interfaces.la
|
||||
pbutils_lib = pbutils.la
|
||||
|
||||
defs_DATA = gst-types.defs \
|
||||
gst-extrafuncs.defs \
|
||||
libs.defs \
|
||||
base.defs \
|
||||
pbutils.defs
|
||||
defsdir = $(pkgdatadir)/$(GST_MAJORMINOR)/defs
|
||||
|
||||
noinst_HEADERS = common.h pygst-private.h
|
||||
|
||||
pygst_installdir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/
|
||||
pygst_install_HEADERS = pygst.h pygstvalue.h pygstminiobject.h pygstexception.h
|
||||
|
||||
versioned_overrides = \
|
||||
gst-0.10.21.ignore \
|
||||
gst-0.10.22.ignore \
|
||||
gst-0.10.23.ignore \
|
||||
gst-0.10.24.ignore \
|
||||
gst-0.10.25.ignore \
|
||||
gst-0.10.26.ignore \
|
||||
gst-0.10.29.ignore \
|
||||
gst-0.10.30.ignore \
|
||||
gst-0.10.31.ignore \
|
||||
gst-0.10.32.ignore \
|
||||
gst-pb-0.10.23.ignore \
|
||||
gst-pb-0.10.25.ignore \
|
||||
gst-pb-0.10.26.ignore \
|
||||
gst-pb-0.10.29.ignore \
|
||||
gst-pb-0.10.30.ignore \
|
||||
gst-pb-0.10.31.ignore \
|
||||
gst-pb-0.10.32.ignore \
|
||||
gst-pb-0.10.36.ignore \
|
||||
gst-disable-loadsave.ignore
|
||||
|
||||
INCLUDES = $(PYTHON_INCLUDES)
|
||||
EXTRA_DIST = $(defs_DATA) $(versioned_overrides) common.h arg-types.py
|
||||
GEN_FILES = arg-types.py gst-types.defs libs.defs base.defs pbutils.defs
|
||||
|
||||
# GStreamer bindings
|
||||
_gst_la_CFLAGS = $(common_cflags)
|
||||
_gst_la_LIBADD = $(common_libadd) $(GST_BASE_LIBS)
|
||||
_gst_la_LDFLAGS = $(common_ldflags) -export-symbols-regex "^(init_gst|_PyGObject_API|pygstminiobject_).*" \
|
||||
$(GST_BASE_LIBS) $(GST_CONTROLLER_LIBS) $(GST_NET_LIBS) $(GST_DP_LIBS)
|
||||
_gst_la_SOURCES = \
|
||||
gst-argtypes.c \
|
||||
gstmodule.c \
|
||||
pygstiterator.c \
|
||||
pygstminiobject.c \
|
||||
pygstvalue.c \
|
||||
pygstexception.c
|
||||
|
||||
nodist__gst_la_SOURCES = gst.c
|
||||
GST_OVERRIDES = \
|
||||
gst.override \
|
||||
gstbin.override \
|
||||
gstbuffer.override \
|
||||
gstbus.override \
|
||||
gstevent.override \
|
||||
gstcaps.override \
|
||||
gstelement.override \
|
||||
gstelementfactory.override \
|
||||
gstmessage.override \
|
||||
gstobject.override \
|
||||
gstquery.override \
|
||||
gstpad.override \
|
||||
gststructure.override \
|
||||
gsttaglist.override \
|
||||
gstlibs.override \
|
||||
gstbase.override
|
||||
|
||||
GST_DEFS = gst.defs gst-types.defs gst-extrafuncs.defs libs.defs base.defs
|
||||
CLEANFILES = gst.c __init__.pyc
|
||||
EXTRA_DIST += $(GST_DEFS) $(GST_OVERRIDES) gstversion.override.in
|
||||
gst.c: $(GST_DEFS) $(GST_OVERRIDES) $(GEN_FILES) gstversion.override __init__.py
|
||||
|
||||
# GStreamer interfaces bindings
|
||||
interfaces_la_CFLAGS = $(common_cflags) $(GST_PLUGINS_BASE_CFLAGS)
|
||||
interfaces_la_LIBADD = $(common_libadd) -lgstinterfaces-$(GST_MAJORMINOR)
|
||||
interfaces_la_LDFLAGS = $(common_ldflags) \
|
||||
-export-symbols-regex "^(initinterface|_PyGObject_API).*" $(GST_PLUGINS_BASE_LIBS)
|
||||
interfaces_la_SOURCES = interfacesmodule.c
|
||||
nodist_interfaces_la_SOURCES = interfaces.c
|
||||
INTERFACES_OVERRIDES = interfaces.override xoverlay.override
|
||||
INTERFACES_DEFS = interfaces.defs xoverlay.defs
|
||||
CLEANFILES += interfaces.c
|
||||
EXTRA_DIST += $(INTERFACES_DEFS) $(INTERFACES_OVERRIDES)
|
||||
interfaces.c: $(INTERFACES_DEFS) $(INTERFACES_OVERRIDES) $(GEN_FILES)
|
||||
|
||||
# GStreamer pbutils bindings
|
||||
pbutils_la_CFLAGS = $(common_cflags) $(GST_PLUGINS_BASE_CFLAGS)
|
||||
pbutils_la_LIBADD = $(common_libadd) $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-0.10
|
||||
pbutils_la_LDFLAGS = $(common_ldflags) \
|
||||
-export-symbols-regex "^(initpbutils|_PyGObject_API).*" $(GST_PLUGINS_BASE_LIBS)
|
||||
pbutils_la_SOURCES = pbutilsmodule.c gst-argtypes.c
|
||||
nodist_pbutils_la_SOURCES = pbutils.c
|
||||
PBUTILS_OVERRIDES = pbutils.override
|
||||
PBUTILS_DEFS = pbutils.defs
|
||||
CLEANFILES += pbutils.c
|
||||
EXTRA_DIST += $(PBUTILS_DEFS) $(PBUTILS_OVERRIDES)
|
||||
pbutils.c: $(PBUTILS_DEFS) $(PBUTILS_OVERRIDES) $(GEN_FILES)
|
||||
|
||||
# GStreamer audio bindings
|
||||
AUDIO_OVERRIDES = audio.override
|
||||
AUDIO_DEFS = audio.defs
|
||||
CLEANFILES += audio.c
|
||||
EXTRA_DIST += $(AUDIO_DEFS) $(AUDIO_OVERRIDES)
|
||||
defs_DATA += $(AUDIO_DEFS)
|
||||
GEN_FILES += $(AUDIO_DEFS)
|
||||
|
||||
if HAVE_GST_AUDIO
|
||||
|
||||
audio_lib = audio.la
|
||||
pygstexec_LTLIBRARIES += $(audio_lib)
|
||||
audio_la_CFLAGS = $(common_cflags) $(GST_PLUGINS_BASE_CFLAGS)
|
||||
audio_la_LIBADD = $(common_libadd) $(GST_PLUGINS_BASE_LIBS) -lgstaudio-0.10
|
||||
audio_la_LDFLAGS = $(common_ldflags) \
|
||||
-export-symbols-regex "^(initaudio|_PyGObject_API).*" $(GST_PLUGINS_BASE_LIBS)
|
||||
audio_la_SOURCES = audiomodule.c gst-argtypes.c
|
||||
nodist_audio_la_SOURCES = audio.c
|
||||
audio.c: $(AUDIO_DEFS) $(AUDIO_OVERRIDES) $(GEN_FILES)
|
||||
|
||||
endif
|
||||
|
||||
# GStreamer video bindings
|
||||
VIDEO_OVERRIDES = video.override
|
||||
VIDEO_DEFS = video.defs
|
||||
CLEANFILES += video.c
|
||||
EXTRA_DIST += $(VIDEO_DEFS) $(VIDEO_OVERRIDES)
|
||||
defs_DATA += $(VIDEO_DEFS)
|
||||
GEN_FILES += $(VIDEO_DEFS)
|
||||
|
||||
if HAVE_GST_VIDEO
|
||||
|
||||
video_lib = video.la
|
||||
pygstexec_LTLIBRARIES += $(video_lib)
|
||||
video_la_CFLAGS = $(common_cflags) $(GST_PLUGINS_BASE_CFLAGS)
|
||||
video_la_LIBADD = $(common_libadd) $(GST_PLUGINS_BASE_LIBS) -lgstvideo-0.10
|
||||
video_la_LDFLAGS = $(common_ldflags) \
|
||||
-export-symbols-regex "^(initvideo|_PyGObject_API).*" $(GST_PLUGINS_BASE_LIBS)
|
||||
video_la_SOURCES = videomodule.c gst-argtypes.c
|
||||
nodist_video_la_SOURCES = video.c
|
||||
video.c: $(VIDEO_DEFS) $(VIDEO_OVERRIDES) $(GEN_FILES)
|
||||
|
||||
endif
|
||||
|
||||
# GStreamer tag bindings
|
||||
TAG_OVERRIDES = tag.override
|
||||
TAG_DEFS = tag.defs
|
||||
CLEANFILES += tag.c
|
||||
EXTRA_DIST += $(TAG_DEFS) $(TAG_OVERRIDES)
|
||||
defs_DATA += $(TAG_DEFS)
|
||||
GEN_FILES += $(TAG_DEFS)
|
||||
|
||||
if HAVE_GST_TAG
|
||||
|
||||
tag_lib = tag.la
|
||||
pygstexec_LTLIBRARIES += $(tag_lib)
|
||||
tag_la_CFLAGS = $(common_cflags) $(GST_PLUGINS_BASE_CFLAGS)
|
||||
tag_la_LIBADD = $(common_libadd) $(GST_PLUGINS_BASE_LIBS) -lgsttag-0.10
|
||||
tag_la_LDFLAGS = $(common_ldflags) \
|
||||
-export-symbols-regex "^(inittag|_PyGObject_API).*" $(GST_PLUGINS_BASE_LIBS)
|
||||
tag_la_SOURCES = tagmodule.c gst-argtypes.c
|
||||
nodist_tag_la_SOURCES = tag.c
|
||||
tag.c: $(TAG_DEFS) $(TAG_OVERRIDES) $(GEN_FILES)
|
||||
|
||||
endif
|
||||
|
||||
|
||||
.defs.c:
|
||||
$(AM_V_GEN)($(PYTHON) $(top_srcdir)/codegen/codegen.py \
|
||||
--load-types $(srcdir)/arg-types.py \
|
||||
--register $(srcdir)/gst-types.defs \
|
||||
--override $(srcdir)/$*.override \
|
||||
--extendpath $(top_builddir)/gst/ \
|
||||
--extendpath $(srcdir)/ \
|
||||
--prefix py$* $<) > gen-$*.c \
|
||||
&& cp gen-$*.c $*.c \
|
||||
&& rm -f gen-$*.c
|
||||
|
||||
SUBDIRS = extend
|
|
@ -1,229 +0,0 @@
|
|||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
#
|
||||
# gst-python
|
||||
# Copyright (C) 2002 David I. Lehn
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# Author: David I. Lehn <dlehn@users.sourceforge.net>
|
||||
|
||||
try:
|
||||
import gstlibtoolimporter
|
||||
gstlibtoolimporter.install()
|
||||
except ImportError:
|
||||
gstlibtoolimporter = None
|
||||
|
||||
import sys
|
||||
|
||||
# we always require 2.0 of pygtk; so if pygtk is not imported anywhere
|
||||
# yet, we import pygtk here and .require
|
||||
if 'gobject' not in sys.modules:
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
|
||||
class Value:
|
||||
def __init__(self, type):
|
||||
assert type in ('fourcc', 'intrange', 'doublerange', 'fractionrange', 'fraction')
|
||||
self.type = type
|
||||
|
||||
class Fourcc(Value):
|
||||
def __init__(self, string):
|
||||
Value.__init__(self, 'fourcc')
|
||||
self.fourcc = string
|
||||
|
||||
def __repr__(self):
|
||||
return '<gst.Fourcc %s>' % self.fourcc
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, Fourcc):
|
||||
return self.fourcc == other.fourcc
|
||||
|
||||
return False
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
class IntRange(Value):
|
||||
def __init__(self, low, high):
|
||||
Value.__init__(self, 'intrange')
|
||||
self.low = low
|
||||
self.high = high
|
||||
def __repr__(self):
|
||||
return '<gst.IntRange [%d, %d]>' % (self.low, self.high)
|
||||
|
||||
class DoubleRange(Value):
|
||||
def __init__(self, low, high):
|
||||
Value.__init__(self, 'doublerange')
|
||||
self.low = low
|
||||
self.high = high
|
||||
def __repr__(self):
|
||||
return '<gst.DoubleRange [%f, %f]>' % (self.low, self.high)
|
||||
|
||||
class FractionRange(Value):
|
||||
def __init__(self, low, high):
|
||||
Value.__init__(self, 'fractionrange')
|
||||
self.low = low
|
||||
self.high = high
|
||||
def __repr__(self):
|
||||
return '<gst.FractionRange [%d/%d, %d/%d]>' % (self.low.num,
|
||||
self.low.denom,
|
||||
self.high.num,
|
||||
self.high.denom)
|
||||
|
||||
class Fraction(Value):
|
||||
def __init__(self, num, denom=1):
|
||||
def __gcd(a,b):
|
||||
while b != 0:
|
||||
tmp = a
|
||||
a = b
|
||||
b = tmp % b
|
||||
return abs(a)
|
||||
|
||||
def __simplify():
|
||||
num = self.num
|
||||
denom = self.denom
|
||||
|
||||
if num < 0:
|
||||
num = -num
|
||||
denom = -denom
|
||||
|
||||
# Compute greatest common divisor
|
||||
gcd = __gcd(num,denom)
|
||||
if gcd != 0:
|
||||
num /= gcd
|
||||
denom /= gcd
|
||||
|
||||
self.num = num
|
||||
self.denom = denom
|
||||
|
||||
Value.__init__(self, 'fraction')
|
||||
|
||||
self.num = num
|
||||
self.denom = denom
|
||||
|
||||
__simplify()
|
||||
|
||||
def __repr__(self):
|
||||
return '<gst.Fraction %d/%d>' % (self.num, self.denom)
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, Fraction):
|
||||
return self.num * other.denom == other.num * self.denom
|
||||
return False
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __mul__(self, other):
|
||||
if isinstance(other, Fraction):
|
||||
return Fraction(self.num * other.num,
|
||||
self.denom * other.denom)
|
||||
elif isinstance(other, int):
|
||||
return Fraction(self.num * other, self.denom)
|
||||
raise TypeError
|
||||
|
||||
__rmul__ = __mul__
|
||||
|
||||
def __div__(self, other):
|
||||
if isinstance(other, Fraction):
|
||||
return Fraction(self.num * other.denom,
|
||||
self.denom * other.num)
|
||||
elif isinstance(other, int):
|
||||
return Fraction(self.num, self.denom * other)
|
||||
return TypeError
|
||||
|
||||
def __rdiv__(self, other):
|
||||
if isinstance(other, int):
|
||||
return Fraction(self.denom * other, self.num)
|
||||
return TypeError
|
||||
|
||||
def __float__(self):
|
||||
return float(self.num) / float(self.denom)
|
||||
|
||||
try:
|
||||
dlsave = sys.getdlopenflags()
|
||||
from DLFCN import RTLD_GLOBAL, RTLD_LAZY
|
||||
except AttributeError:
|
||||
# windows doesn't have sys.getdlopenflags()
|
||||
RTLD_GLOBAL = -1
|
||||
RTLD_LAZY = -1
|
||||
except ImportError:
|
||||
RTLD_GLOBAL = -1
|
||||
RTLD_LAZY = -1
|
||||
import os
|
||||
osname = os.uname()[0]
|
||||
if osname == 'Linux' or osname == 'SunOS' or osname == 'FreeBSD' or osname == 'GNU/kFreeBSD' or osname == 'GNU':
|
||||
machinename = os.uname()[4]
|
||||
if machinename == 'mips' or machinename == 'mips64':
|
||||
RTLD_GLOBAL = 0x4
|
||||
RTLD_LAZY = 0x1
|
||||
else:
|
||||
RTLD_GLOBAL = 0x100
|
||||
RTLD_LAZY = 0x1
|
||||
elif osname == 'Darwin':
|
||||
RTLD_GLOBAL = 0x8
|
||||
RTLD_LAZY = 0x1
|
||||
del os
|
||||
except:
|
||||
RTLD_GLOBAL = -1
|
||||
RTLD_LAZY = -1
|
||||
|
||||
if RTLD_GLOBAL != -1 and RTLD_LAZY != -1:
|
||||
sys.setdlopenflags(RTLD_LAZY | RTLD_GLOBAL)
|
||||
|
||||
try:
|
||||
import libxml2
|
||||
except:
|
||||
pass
|
||||
|
||||
from _gst import *
|
||||
import interfaces
|
||||
|
||||
if RTLD_GLOBAL != -1 and RTLD_LAZY != -1:
|
||||
sys.setdlopenflags(dlsave)
|
||||
del sys
|
||||
|
||||
version = get_gst_version
|
||||
|
||||
# Fixes for API cleanups that would cause an API breakage.
|
||||
# See #446674
|
||||
|
||||
import warnings
|
||||
if locals().has_key("parse_bin_from_description"):
|
||||
def gst_parse_bin_from_description(*args, **kwargs):
|
||||
warnings.warn("gst_parse_bin_from_description() is deprecated, please use parse_bin_from_description instead",
|
||||
DeprecationWarning)
|
||||
return parse_bin_from_description(*args, **kwargs)
|
||||
|
||||
if locals().has_key("message_new_buffering"):
|
||||
def gst_message_new_buffering(*args, **kwargs):
|
||||
warnings.warn("gst_message_new_buffering() is deprecated, please use message_new_buffering() instead",
|
||||
DeprecationWarning)
|
||||
return message_new_buffering(*args, **kwargs)
|
||||
|
||||
# this restores previously installed importhooks, so we don't interfere
|
||||
# with other people's module importers
|
||||
# it also clears out the module completely as if it were never loaded,
|
||||
# so that if anyone else imports gstltihooks the hooks get installed
|
||||
if gstlibtoolimporter is not None:
|
||||
import audio
|
||||
import pbutils
|
||||
import tag
|
||||
import video
|
||||
gstlibtoolimporter.uninstall()
|
||||
import sys
|
||||
del sys.modules["gstlibtoolimporter"]
|
418
gst/arg-types.py
418
gst/arg-types.py
|
@ -1,418 +0,0 @@
|
|||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
#
|
||||
# gst-python
|
||||
# Copyright (C) 2002 David I. Lehn
|
||||
# 2004 Johan Dahlin
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# Author: David I. Lehn <dlehn@users.sourceforge.net>
|
||||
|
||||
from argtypes import UInt64Arg, Int64Arg, PointerArg, ArgMatcher, ArgType, matcher
|
||||
from reversewrapper import Parameter, ReturnType, GBoxedParam, GBoxedReturn, IntParam, IntReturn
|
||||
|
||||
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, keeprefcount, 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"}
|
||||
|
||||
class GstCapsArg(ArgType):
|
||||
"""GstCaps node generator"""
|
||||
|
||||
before = (' %(name)s = pygst_caps_from_pyobject (py_%(name)s, %(namecopy)s);\n'
|
||||
' if (PyErr_Occurred())\n'
|
||||
' return NULL;\n')
|
||||
beforenull = (' if (py_%(name)s == Py_None || py_%(name)s == NULL)\n'
|
||||
' %(name)s = NULL;\n'
|
||||
' else\n'
|
||||
' ' + before)
|
||||
after = (' if (%(name)s && %(name)s_is_copy)\n'
|
||||
' gst_caps_unref (%(name)s);\n')
|
||||
|
||||
def write_param(self, ptype, pname, pdflt, pnull, keeprefcount, info):
|
||||
if ptype == 'const-GstCaps*':
|
||||
self.write_const_param(pname, pdflt, pnull, info)
|
||||
elif ptype == 'GstCaps*':
|
||||
self.write_normal_param(pname, pdflt, pnull, info)
|
||||
else:
|
||||
raise RuntimeError, "write_param not implemented for %s" % ptype
|
||||
|
||||
def write_const_param(self, pname, pdflt, pnull, info):
|
||||
if pdflt:
|
||||
assert pdflt == 'NULL'
|
||||
info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
|
||||
else:
|
||||
info.varlist.add('PyObject', '*py_' + pname)
|
||||
info.varlist.add('GstCaps', '*'+pname)
|
||||
info.varlist.add('gboolean', pname+'_is_copy')
|
||||
info.add_parselist('O', ['&py_'+pname], [pname])
|
||||
info.arglist.append(pname)
|
||||
if pnull:
|
||||
info.codebefore.append (self.beforenull % { 'name' : pname, 'namecopy' : '&'+pname+'_is_copy' })
|
||||
else:
|
||||
info.codebefore.append (self.before % { 'name' : pname, 'namecopy' : '&'+pname+'_is_copy' })
|
||||
info.codeafter.append (self.after % { 'name' : pname, 'namecopy' : '&'+pname+'_is_copy' })
|
||||
|
||||
def write_normal_param(self, pname, pdflt, pnull, info):
|
||||
if pdflt:
|
||||
assert pdflt == 'NULL'
|
||||
info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
|
||||
else:
|
||||
info.varlist.add('PyObject', '*py_' + pname)
|
||||
info.varlist.add('GstCaps', '*'+pname)
|
||||
info.add_parselist('O', ['&py_'+pname], [pname])
|
||||
info.arglist.append(pname)
|
||||
if pnull:
|
||||
info.codebefore.append (self.beforenull % { 'name' : pname, 'namecopy' : 'NULL' })
|
||||
else:
|
||||
info.codebefore.append (self.before % { 'name' : pname, 'namecopy' : 'NULL' })
|
||||
|
||||
def write_return(self, ptype, ownsreturn, info):
|
||||
if ptype == 'GstCaps*':
|
||||
info.varlist.add('GstCaps', '*ret')
|
||||
copyval = 'FALSE'
|
||||
elif ptype == 'const-GstCaps*':
|
||||
info.varlist.add('const GstCaps', '*ret')
|
||||
copyval = 'TRUE'
|
||||
else:
|
||||
raise RuntimeError, "write_return not implemented for %s" % ptype
|
||||
info.codeafter.append(' return pyg_boxed_new (GST_TYPE_CAPS, (GstCaps*) ret, '+copyval+', TRUE);')
|
||||
|
||||
class GstIteratorArg(ArgType):
|
||||
def write_return(self, ptype, ownsreturn, info):
|
||||
info.varlist.add('GstIterator', '*ret')
|
||||
info.codeafter.append(' return pygst_iterator_new(ret);')
|
||||
|
||||
class GstMiniObjectArg(ArgType):
|
||||
|
||||
before = (' %(name)s = %(macro)s(pygstminiobject_get (py_%(name)s));\n'
|
||||
' if (PyErr_Occurred())\n'
|
||||
' return NULL;\n')
|
||||
|
||||
def write_param(self, ptype, pname, pdflt, pnull, keeprefcount, info):
|
||||
if pdflt:
|
||||
assert pdflt == 'NULL'
|
||||
info.varlist.add('PyObject', '*py_' + pname + ' = NULL')
|
||||
else:
|
||||
info.varlist.add('PyObject', '*py_' + pname)
|
||||
|
||||
#Converts 'GstBuffer*' to 'GstBuffer'
|
||||
#and const-GstBuffer* to 'const GstBuffer'
|
||||
info.varlist.add(ptype.replace('-',' ').replace('*',''), '*'+pname)
|
||||
|
||||
if ptype in ['GstBuffer*', 'const-GstBuffer*']:
|
||||
info.codebefore.append(self.before % { 'name' : pname, 'macro' : 'GST_BUFFER' })
|
||||
|
||||
elif ptype in ['GstMessage*', 'const-GstMessage*']:
|
||||
info.codebefore.append(self.before % { 'name' : pname, 'macro' : 'GST_MESSAGE' })
|
||||
|
||||
elif ptype in ['GstEvent*', 'const-GstEvent*']:
|
||||
info.codebefore.append(self.before % { 'name' : pname, 'macro' : 'GST_EVENT' })
|
||||
|
||||
elif ptype in ['GstQuery*', 'const-GstQuery*']:
|
||||
info.codebefore.append(self.before % { 'name' : pname, 'macro' : 'GST_QUERY' })
|
||||
|
||||
else:
|
||||
raise RuntimeError, "write_param not implemented for %s" % ptype
|
||||
|
||||
info.add_parselist('O', ['&py_'+pname], [pname])
|
||||
info.arglist.append(pname)
|
||||
|
||||
def write_return(self, ptype, ownsreturn, info):
|
||||
info.varlist.add('GstMiniObject', '*ret')
|
||||
info.codeafter.append(' return pygstminiobject_new((GstMiniObject *) ret);')
|
||||
|
||||
class GstMiniObjectParam(Parameter):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'GstMiniObject *')
|
||||
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
|
||||
self.wrapper.write_code(code=("if (%s) {\n"
|
||||
" py_%s = pygstminiobject_new((GstMiniObject *) %s);\n"
|
||||
" gst_mini_object_unref ((GstMiniObject *) %s);\n"
|
||||
"} else {\n"
|
||||
" Py_INCREF(Py_None);\n"
|
||||
" py_%s = Py_None;\n"
|
||||
"}"
|
||||
% (self.name, self.name, self.name, self.name, self.name)),
|
||||
cleanup=("gst_mini_object_ref ((GstMiniObject *) %s); Py_DECREF(py_%s);" % (self.name, self.name)))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
matcher.register_reverse('GstMiniObject*', GstMiniObjectParam)
|
||||
|
||||
class GstMiniObjectReturn(ReturnType):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'GstMiniObject *')
|
||||
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("%s retval;" % self.get_c_type())
|
||||
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return NULL;")
|
||||
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code("retval = (%s) pygstminiobject_get(py_retval);"
|
||||
% self.get_c_type())
|
||||
self.wrapper.write_code("gst_mini_object_ref((GstMiniObject *) retval);")
|
||||
|
||||
matcher.register_reverse_ret('GstMiniObject*', GstMiniObjectReturn)
|
||||
|
||||
class GstCapsParam(Parameter):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'GstCaps *')
|
||||
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s = NULL;" % self.name)
|
||||
self.wrapper.write_code(code=("if (%s)\n"
|
||||
" py_%s = pyg_boxed_new (GST_TYPE_CAPS, %s, FALSE, TRUE);\n"
|
||||
"else {\n"
|
||||
" Py_INCREF(Py_None);\n"
|
||||
" py_%s = Py_None;\n"
|
||||
"}"
|
||||
% (self.name, self.name, self.name, self.name)),
|
||||
cleanup=("gst_caps_ref(%s);\nPy_DECREF(py_%s);" % (self.name, self.name)))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
matcher.register_reverse('GstCaps*', GstCapsParam)
|
||||
|
||||
class GstCapsReturn(ReturnType):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'GstCaps *')
|
||||
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("%s retval;" % self.get_c_type())
|
||||
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return NULL;")
|
||||
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code("retval = (%s) pygst_caps_from_pyobject (py_retval, NULL);"
|
||||
% self.get_c_type())
|
||||
## self.wrapper.write_code("gst_mini_object_ref((GstMiniObject *) retval);")
|
||||
|
||||
matcher.register_reverse_ret('GstCaps*', GstCapsReturn)
|
||||
|
||||
|
||||
class Int64Param(Parameter):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'gint64')
|
||||
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = PyLong_FromLongLong(%s);" %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
class Int64Return(ReturnType):
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'gint64')
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("%s retval;" % self.get_c_type())
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return -G_MAXINT;")
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
code=None,
|
||||
failure_expression="!PyLong_Check(py_retval)",
|
||||
failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be an long");')
|
||||
self.wrapper.write_code("retval = PyLong_AsLongLong(py_retval);")
|
||||
|
||||
class UInt64Param(Parameter):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'guint64')
|
||||
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = PyLong_FromUnsignedLongLong(%s);" %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
class UInt64Return(ReturnType):
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'guint64')
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("%s retval;" % self.get_c_type())
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return -G_MAXINT;")
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
code=None,
|
||||
failure_expression="!PyLong_Check(py_retval)",
|
||||
failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be an long");')
|
||||
self.wrapper.write_code("retval = PyLong_AsUnsignedLongLongMask(py_retval);")
|
||||
|
||||
class ULongParam(Parameter):
|
||||
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'gulong')
|
||||
|
||||
def convert_c2py(self):
|
||||
self.wrapper.add_declaration("PyObject *py_%s;" % self.name)
|
||||
self.wrapper.write_code(code=("py_%s = PyLong_FromUnsignedLong(%s);" %
|
||||
(self.name, self.name)),
|
||||
cleanup=("Py_DECREF(py_%s);" % self.name))
|
||||
self.wrapper.add_pyargv_item("py_%s" % self.name)
|
||||
|
||||
class ULongReturn(ReturnType):
|
||||
def get_c_type(self):
|
||||
return self.props.get('c_type', 'gulong')
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("%s retval;" % self.get_c_type())
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return -G_MAXINT;")
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
code=None,
|
||||
failure_expression="!PyLong_Check(py_retval)",
|
||||
failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be an long");')
|
||||
self.wrapper.write_code("retval = PyLong_AsUnsignedLongMask(py_retval);")
|
||||
|
||||
class ConstStringReturn(ReturnType):
|
||||
|
||||
def get_c_type(self):
|
||||
return "const gchar *"
|
||||
|
||||
def write_decl(self):
|
||||
self.wrapper.add_declaration("const gchar *retval;")
|
||||
|
||||
def write_error_return(self):
|
||||
self.wrapper.write_code("return NULL;")
|
||||
|
||||
def write_conversion(self):
|
||||
self.wrapper.write_code(
|
||||
code=None,
|
||||
failure_expression="!PyString_Check(py_retval)",
|
||||
failure_cleanup='PyErr_SetString(PyExc_TypeError, "retval should be a string");')
|
||||
self.wrapper.write_code("retval = g_strdup(PyString_AsString(py_retval));")
|
||||
|
||||
class StringArrayArg(ArgType):
|
||||
"""Arg type for NULL-terminated string pointer arrays (GStrv, aka gchar**)."""
|
||||
def write_return(self, ptype, ownsreturn, info):
|
||||
if ownsreturn:
|
||||
raise NotImplementedError ()
|
||||
else:
|
||||
info.varlist.add("gchar", "**ret")
|
||||
info.codeafter.append(" if (ret) {\n"
|
||||
" guint size = g_strv_length(ret);\n"
|
||||
" PyObject *py_ret = PyTuple_New(size);\n"
|
||||
" gint i;\n"
|
||||
" for (i = 0; i < size; i++)\n"
|
||||
" PyTuple_SetItem(py_ret, i,\n"
|
||||
" PyString_FromString(ret[i]));\n"
|
||||
" return py_ret;\n"
|
||||
" }\n"
|
||||
" return PyTuple_New (0);\n")
|
||||
|
||||
|
||||
matcher.register('GstClockTime', UInt64Arg())
|
||||
matcher.register('GstElementFactoryListType', UInt64Arg())
|
||||
matcher.register('GstClockTimeDiff', Int64Arg())
|
||||
matcher.register('xmlNodePtr', XmlNodeArg())
|
||||
matcher.register('xmlDocPtr', XmlDocArg())
|
||||
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())
|
||||
|
||||
arg = PointerArg('gpointer', 'G_TYPE_POINTER')
|
||||
matcher.register('GstClockID', arg)
|
||||
|
||||
for typename in ["GstPlugin", "GstStructure", "GstTagList", "GError", "GstDate", "GstSegment"]:
|
||||
matcher.register_reverse(typename, GBoxedParam)
|
||||
matcher.register_reverse_ret(typename, GBoxedReturn)
|
||||
|
||||
for typename in ["GstBuffer*", "const-GstBuffer*", "GstEvent*", "const-GstEvent*", "GstMessage*", "const-GstMessage*", "GstQuery*", "const-GstQuery*"]:
|
||||
matcher.register(typename, GstMiniObjectArg())
|
||||
matcher.register_reverse(typename, GstMiniObjectParam)
|
||||
matcher.register_reverse_ret(typename, GstMiniObjectReturn)
|
||||
|
||||
for typename in ["gint64", "GstClockTimeDiff"]:
|
||||
matcher.register_reverse(typename, Int64Param)
|
||||
matcher.register_reverse_ret(typename, Int64Return)
|
||||
|
||||
for typename in ["guint64", "GstClockTime", "GstElementFactoryListType"]:
|
||||
matcher.register_reverse(typename, UInt64Param)
|
||||
matcher.register_reverse_ret(typename, UInt64Return)
|
||||
|
||||
matcher.register_reverse_ret("const-gchar*", ConstStringReturn)
|
||||
|
||||
matcher.register_reverse("GType", IntParam)
|
||||
matcher.register_reverse_ret("GType", IntReturn)
|
||||
|
||||
matcher.register_reverse("gulong", ULongParam)
|
||||
matcher.register_reverse_ret("gulong", ULongReturn)
|
||||
|
||||
matcher.register("GStrv", StringArrayArg())
|
||||
|
||||
del arg
|
872
gst/audio.defs
872
gst/audio.defs
|
@ -1,872 +0,0 @@
|
|||
;; -*- scheme -*-
|
||||
; object definitions ...
|
||||
(define-object AudioClock
|
||||
(in-module "Gst")
|
||||
(parent "GstSystemClock")
|
||||
(c-name "GstAudioClock")
|
||||
(gtype-id "GST_TYPE_AUDIO_CLOCK")
|
||||
)
|
||||
|
||||
(define-object AudioFilter
|
||||
(in-module "Gst")
|
||||
(parent "GstBaseTransform")
|
||||
(c-name "GstAudioFilter")
|
||||
(gtype-id "GST_TYPE_AUDIO_FILTER")
|
||||
)
|
||||
|
||||
(define-object BaseAudioSink
|
||||
(in-module "Gst")
|
||||
(parent "GstBaseSink")
|
||||
(c-name "GstBaseAudioSink")
|
||||
(gtype-id "GST_TYPE_BASE_AUDIO_SINK")
|
||||
)
|
||||
|
||||
(define-object AudioSink
|
||||
(in-module "Gst")
|
||||
(parent "GstBaseAudioSink")
|
||||
(c-name "GstAudioSink")
|
||||
(gtype-id "GST_TYPE_AUDIO_SINK")
|
||||
)
|
||||
|
||||
;; (define-object BaseAudioSrc
|
||||
;; (in-module "Gst")
|
||||
;; (parent "GstPushSrc")
|
||||
;; (c-name "GstBaseAudioSrc")
|
||||
;; (gtype-id "GST_TYPE_BASE_AUDIO_SRC")
|
||||
;; )
|
||||
|
||||
;; (define-object AudioSrc
|
||||
;; (in-module "Gst")
|
||||
;; (parent "GstBaseAudioSrc")
|
||||
;; (c-name "GstAudioSrc")
|
||||
;; (gtype-id "GST_TYPE_AUDIO_SRC")
|
||||
;; )
|
||||
|
||||
(define-object RingBuffer
|
||||
(in-module "Gst")
|
||||
(parent "GstObject")
|
||||
(c-name "GstRingBuffer")
|
||||
(gtype-id "GST_TYPE_RING_BUFFER")
|
||||
)
|
||||
|
||||
;; Enumerations and flags ...
|
||||
|
||||
(define-enum BaseAudioSinkSlaveMethod
|
||||
(in-module "Gst")
|
||||
(c-name "GstBaseAudioSinkSlaveMethod")
|
||||
(gtype-id "GST_TYPE_BASE_AUDIO_SINK_SLAVE_METHOD")
|
||||
(values
|
||||
'("resample" "GST_BASE_AUDIO_SINK_SLAVE_RESAMPLE")
|
||||
'("skew" "GST_BASE_AUDIO_SINK_SLAVE_SKEW")
|
||||
'("none" "GST_BASE_AUDIO_SINK_SLAVE_NONE")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum BaseAudioSrcSlaveMethod
|
||||
(in-module "Gst")
|
||||
(c-name "GstBaseAudioSrcSlaveMethod")
|
||||
(gtype-id "GST_TYPE_BASE_AUDIO_SRC_SLAVE_METHOD")
|
||||
(values
|
||||
'("resample" "GST_BASE_AUDIO_SRC_SLAVE_RESAMPLE")
|
||||
'("retimestamp" "GST_BASE_AUDIO_SRC_SLAVE_RETIMESTAMP")
|
||||
'("skew" "GST_BASE_AUDIO_SRC_SLAVE_SKEW")
|
||||
'("none" "GST_BASE_AUDIO_SRC_SLAVE_NONE")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum RingBufferState
|
||||
(in-module "Gst")
|
||||
(c-name "GstRingBufferState")
|
||||
(gtype-id "GST_TYPE_RING_BUFFER_STATE")
|
||||
(values
|
||||
'("stopped" "GST_RING_BUFFER_STATE_STOPPED")
|
||||
'("paused" "GST_RING_BUFFER_STATE_PAUSED")
|
||||
'("started" "GST_RING_BUFFER_STATE_STARTED")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum RingBufferSegState
|
||||
(in-module "Gst")
|
||||
(c-name "GstRingBufferSegState")
|
||||
(gtype-id "GST_TYPE_RING_BUFFER_SEG_STATE")
|
||||
(values
|
||||
'("invalid" "GST_SEGSTATE_INVALID")
|
||||
'("empty" "GST_SEGSTATE_EMPTY")
|
||||
'("filled" "GST_SEGSTATE_FILLED")
|
||||
'("partial" "GST_SEGSTATE_PARTIAL")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum BufferFormatType
|
||||
(in-module "Gst")
|
||||
(c-name "GstBufferFormatType")
|
||||
(gtype-id "GST_TYPE_BUFFER_FORMAT_TYPE")
|
||||
(values
|
||||
'("linear" "GST_BUFTYPE_LINEAR")
|
||||
'("float" "GST_BUFTYPE_FLOAT")
|
||||
'("mu-law" "GST_BUFTYPE_MU_LAW")
|
||||
'("a-law" "GST_BUFTYPE_A_LAW")
|
||||
'("ima-adpcm" "GST_BUFTYPE_IMA_ADPCM")
|
||||
'("mpeg" "GST_BUFTYPE_MPEG")
|
||||
'("gsm" "GST_BUFTYPE_GSM")
|
||||
'("iec958" "GST_BUFTYPE_IEC958")
|
||||
'("ac3" "GST_BUFTYPE_AC3")
|
||||
'("eac3" "GST_BUFTYPE_EAC3")
|
||||
'("dts" "GST_BUFTYPE_DTS")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum BufferFormat
|
||||
(in-module "Gst")
|
||||
(c-name "GstBufferFormat")
|
||||
(gtype-id "GST_TYPE_BUFFER_FORMAT")
|
||||
(values
|
||||
'("unknown" "GST_UNKNOWN")
|
||||
'("s8" "GST_S8")
|
||||
'("u8" "GST_U8")
|
||||
'("s16-le" "GST_S16_LE")
|
||||
'("s16-be" "GST_S16_BE")
|
||||
'("u16-le" "GST_U16_LE")
|
||||
'("u16-be" "GST_U16_BE")
|
||||
'("s24-le" "GST_S24_LE")
|
||||
'("s24-be" "GST_S24_BE")
|
||||
'("u24-le" "GST_U24_LE")
|
||||
'("u24-be" "GST_U24_BE")
|
||||
'("s32-le" "GST_S32_LE")
|
||||
'("s32-be" "GST_S32_BE")
|
||||
'("u32-le" "GST_U32_LE")
|
||||
'("u32-be" "GST_U32_BE")
|
||||
'("s24-3le" "GST_S24_3LE")
|
||||
'("s24-3be" "GST_S24_3BE")
|
||||
'("u24-3le" "GST_U24_3LE")
|
||||
'("u24-3be" "GST_U24_3BE")
|
||||
'("s20-3le" "GST_S20_3LE")
|
||||
'("s20-3be" "GST_S20_3BE")
|
||||
'("u20-3le" "GST_U20_3LE")
|
||||
'("u20-3be" "GST_U20_3BE")
|
||||
'("s18-3le" "GST_S18_3LE")
|
||||
'("s18-3be" "GST_S18_3BE")
|
||||
'("u18-3le" "GST_U18_3LE")
|
||||
'("u18-3be" "GST_U18_3BE")
|
||||
'("float32-le" "GST_FLOAT32_LE")
|
||||
'("float32-be" "GST_FLOAT32_BE")
|
||||
'("float64-le" "GST_FLOAT64_LE")
|
||||
'("float64-be" "GST_FLOAT64_BE")
|
||||
'("mu-law" "GST_MU_LAW")
|
||||
'("a-law" "GST_A_LAW")
|
||||
'("ima-adpcm" "GST_IMA_ADPCM")
|
||||
'("mpeg" "GST_MPEG")
|
||||
'("gsm" "GST_GSM")
|
||||
'("iec958" "GST_IEC958")
|
||||
'("ac3" "GST_AC3")
|
||||
'("eac3" "GST_EAC3")
|
||||
'("dts" "GST_DTS")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum AudioChannelPosition
|
||||
(in-module "Gst")
|
||||
(c-name "GstAudioChannelPosition")
|
||||
(gtype-id "GST_TYPE_AUDIO_CHANNEL_POSITION")
|
||||
(values
|
||||
'("invalid" "GST_AUDIO_CHANNEL_POSITION_INVALID")
|
||||
'("front-mono" "GST_AUDIO_CHANNEL_POSITION_FRONT_MONO")
|
||||
'("front-left" "GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT")
|
||||
'("front-right" "GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT")
|
||||
'("rear-center" "GST_AUDIO_CHANNEL_POSITION_REAR_CENTER")
|
||||
'("rear-left" "GST_AUDIO_CHANNEL_POSITION_REAR_LEFT")
|
||||
'("rear-right" "GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT")
|
||||
'("lfe" "GST_AUDIO_CHANNEL_POSITION_LFE")
|
||||
'("front-center" "GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER")
|
||||
'("front-left-of-center" "GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER")
|
||||
'("front-right-of-center" "GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER")
|
||||
'("side-left" "GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT")
|
||||
'("side-right" "GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT")
|
||||
'("none" "GST_AUDIO_CHANNEL_POSITION_NONE")
|
||||
'("num" "GST_AUDIO_CHANNEL_POSITION_NUM")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; From audio.h
|
||||
|
||||
(define-function frame_byte_size
|
||||
(c-name "gst_audio_frame_byte_size")
|
||||
(return-type "int")
|
||||
(parameters
|
||||
'("GstPad*" "pad")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function frame_length
|
||||
(c-name "gst_audio_frame_length")
|
||||
(return-type "long")
|
||||
(parameters
|
||||
'("GstPad*" "pad")
|
||||
'("GstBuffer*" "buf")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function duration_from_pad_buffer
|
||||
(c-name "gst_audio_duration_from_pad_buffer")
|
||||
(return-type "GstClockTime")
|
||||
(parameters
|
||||
'("GstPad*" "pad")
|
||||
'("GstBuffer*" "buf")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function is_buffer_framed
|
||||
(c-name "gst_audio_is_buffer_framed")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstPad*" "pad")
|
||||
'("GstBuffer*" "buf")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function buffer_clip
|
||||
(c-name "gst_audio_buffer_clip")
|
||||
(return-type "GstBuffer*")
|
||||
(parameters
|
||||
'("GstBuffer*" "buffer")
|
||||
'("GstSegment*" "segment")
|
||||
'("gint" "rate")
|
||||
'("gint" "frame_size")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From gstaudioclock.h
|
||||
|
||||
(define-function gst_audio_clock_get_type
|
||||
(c-name "gst_audio_clock_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function gst_audio_clock_new
|
||||
(c-name "gst_audio_clock_new")
|
||||
(is-constructor-of "GstAudioClock")
|
||||
(return-type "GstClock*")
|
||||
(parameters
|
||||
'("gchar*" "name")
|
||||
'("GstAudioClockGetTimeFunc" "func")
|
||||
'("gpointer" "user_data")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function audio_clock_new_full
|
||||
(c-name "gst_audio_clock_new_full")
|
||||
(return-type "GstClock*")
|
||||
(parameters
|
||||
'("const-gchar*" "name")
|
||||
'("GstAudioClockGetTimeFunc" "func")
|
||||
'("gpointer" "user_data")
|
||||
'("GDestroyNotify" "destroy_notify")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method reset
|
||||
(of-object "GstAudioClock")
|
||||
(c-name "gst_audio_clock_reset")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstClockTime" "time")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function clock_get_time
|
||||
(c-name "gst_audio_clock_get_time")
|
||||
(return-type "GstClockTime")
|
||||
(parameters
|
||||
'("GstClock*" "clock")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function clock_adjust
|
||||
(c-name "gst_audio_clock_adjust")
|
||||
(return-type "GstClockTime")
|
||||
(parameters
|
||||
'("GstClock*" "clock")
|
||||
'("GstClockTime" "time")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function audio_clock_invalidate
|
||||
(c-name "gst_audio_clock_invalidate")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstClock*" "clock")
|
||||
)
|
||||
)
|
||||
|
||||
;; From gstaudiofilter.h
|
||||
|
||||
(define-function gst_audio_filter_get_type
|
||||
(c-name "gst_audio_filter_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-method add_pad_templates
|
||||
(of-object "GstAudioFilterClass")
|
||||
(c-name "gst_audio_filter_class_add_pad_templates")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-GstCaps*" "allowed_caps")
|
||||
)
|
||||
)
|
||||
|
||||
(define-virtual setup
|
||||
(of-object "GstAudioFilter")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstRingBufferSpec*" "format")
|
||||
)
|
||||
)
|
||||
|
||||
;; From gstaudiosink.h
|
||||
|
||||
(define-function gst_audio_sink_get_type
|
||||
(c-name "gst_audio_sink_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-virtual open
|
||||
(of-object "GstAudioSink")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual prepare
|
||||
(of-object "GstAudioSink")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstRingBufferSpec*" "spec")
|
||||
)
|
||||
)
|
||||
|
||||
(define-virtual unprepare
|
||||
(of-object "GstAudioSink")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual close
|
||||
(of-object "GstAudioSink")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual write
|
||||
(of-object "GstAudioSink")
|
||||
(return-type "guint")
|
||||
(parameters
|
||||
'("gpointer" "data")
|
||||
'("guint" "length")
|
||||
)
|
||||
)
|
||||
|
||||
(define-virtual delay
|
||||
(of-object "GstAudioSink")
|
||||
(return-type "guint")
|
||||
)
|
||||
|
||||
(define-virtual reset
|
||||
(of-object "GstAudioSink")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
;; From gstaudiosrc.h
|
||||
|
||||
(define-function gst_audio_src_get_type
|
||||
(c-name "gst_audio_src_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From gstbaseaudiosink.h
|
||||
|
||||
(define-function gst_base_audio_sink_get_type
|
||||
(c-name "gst_base_audio_sink_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-method create_ringbuffer
|
||||
(of-object "GstBaseAudioSink")
|
||||
(c-name "gst_base_audio_sink_create_ringbuffer")
|
||||
(return-type "GstRingBuffer*")
|
||||
)
|
||||
|
||||
(define-virtual create_ringbuffer
|
||||
(of-object "GstBaseAudioSink")
|
||||
(c-name "gst_base_audio_sink_create_ringbuffer")
|
||||
(return-type "GstRingBuffer*")
|
||||
)
|
||||
(define-method set_provide_clock
|
||||
(of-object "GstBaseAudioSink")
|
||||
(c-name "gst_base_audio_sink_set_provide_clock")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gboolean" "provide")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_provide_clock
|
||||
(of-object "GstBaseAudioSink")
|
||||
(c-name "gst_base_audio_sink_get_provide_clock")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method set_slave_method
|
||||
(of-object "GstBaseAudioSink")
|
||||
(c-name "gst_base_audio_sink_set_slave_method")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstBaseAudioSinkSlaveMethod" "method")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_slave_method
|
||||
(of-object "GstBaseAudioSink")
|
||||
(c-name "gst_base_audio_sink_get_slave_method")
|
||||
(return-type "GstBaseAudioSinkSlaveMethod")
|
||||
)
|
||||
|
||||
(define-method set_drift_tolerance
|
||||
(of-object "GstBaseAudioSink")
|
||||
(c-name "gst_base_audio_sink_set_drift_tolerance")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gint64" "drift_tolerance")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_drift_tolerance
|
||||
(of-object "GstBaseAudioSink")
|
||||
(c-name "gst_base_audio_sink_get_drift_tolerance")
|
||||
(return-type "gint64")
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From gstbaseaudiosrc.h
|
||||
|
||||
(define-function gst_base_audio_src_get_type
|
||||
(c-name "gst_base_audio_src_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-method create_ringbuffer
|
||||
(of-object "GstBaseAudioSrc")
|
||||
(c-name "gst_base_audio_src_create_ringbuffer")
|
||||
(return-type "GstRingBuffer*")
|
||||
)
|
||||
|
||||
(define-virtual create_ringbuffer
|
||||
(of-object "GstBaseAudioSrc")
|
||||
(c-name "gst_base_audio_src_create_ringbuffer")
|
||||
(return-type "GstRingBuffer*")
|
||||
)
|
||||
|
||||
(define-method set_provide_clock
|
||||
(of-object "GstBaseAudioSrc")
|
||||
(c-name "gst_base_audio_src_set_provide_clock")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gboolean" "provide")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_provide_clock
|
||||
(of-object "GstBaseAudioSrc")
|
||||
(c-name "gst_base_audio_src_get_provide_clock")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method set_slave_method
|
||||
(of-object "GstBaseAudioSrc")
|
||||
(c-name "gst_base_audio_src_set_slave_method")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstBaseAudioSrcSlaveMethod" "method")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_slave_method
|
||||
(of-object "GstBaseAudioSrc")
|
||||
(c-name "gst_base_audio_src_get_slave_method")
|
||||
(return-type "GstBaseAudioSrcSlaveMethod")
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From gstringbuffer.h
|
||||
|
||||
(define-function gst_ring_buffer_get_type
|
||||
(c-name "gst_ring_buffer_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-method set_callback
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_set_callback")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstRingBufferCallback" "cb")
|
||||
'("gpointer" "user_data")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function ring_buffer_parse_caps
|
||||
(c-name "gst_ring_buffer_parse_caps")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstRingBufferSpec*" "spec")
|
||||
'("GstCaps*" "caps")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function ring_buffer_debug_spec_caps
|
||||
(c-name "gst_ring_buffer_debug_spec_caps")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstRingBufferSpec*" "spec")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function ring_buffer_debug_spec_buff
|
||||
(c-name "gst_ring_buffer_debug_spec_buff")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstRingBufferSpec*" "spec")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method convert
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_convert")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstFormat" "src_fmt")
|
||||
'("gint64" "src_val")
|
||||
'("GstFormat" "dest_fmt")
|
||||
'("gint64*" "dest_val")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method open_device
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_open_device")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method close_device
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_close_device")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method device_is_open
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_device_is_open")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method acquire
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_acquire")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstRingBufferSpec*" "spec")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method release
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_release")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method is_acquired
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_is_acquired")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method activate
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_activate")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gboolean" "active")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method is_active
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_is_active")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method set_flushing
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_set_flushing")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gboolean" "flushing")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method start
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_start")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method pause
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_pause")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method stop
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_stop")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method delay
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_delay")
|
||||
(return-type "guint")
|
||||
)
|
||||
|
||||
(define-method samples_done
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_samples_done")
|
||||
(return-type "guint64")
|
||||
)
|
||||
|
||||
(define-method set_sample
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_set_sample")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint64" "sample")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method clear_all
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_clear_all")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-method commit
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_commit")
|
||||
(return-type "guint")
|
||||
(parameters
|
||||
'("guint64" "sample")
|
||||
'("guchar*" "data")
|
||||
'("guint" "len")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method commit_full
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_commit_full")
|
||||
(return-type "guint")
|
||||
(parameters
|
||||
'("guint64*" "sample")
|
||||
'("guchar*" "data")
|
||||
'("gint" "in_samples")
|
||||
'("gint" "out_samples")
|
||||
'("gint*" "accum")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method read
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_read")
|
||||
(return-type "guint")
|
||||
(parameters
|
||||
'("guint64" "sample")
|
||||
'("guchar*" "data")
|
||||
'("guint" "len")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method prepare_read
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_prepare_read")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gint*" "segment")
|
||||
'("guint8**" "readptr")
|
||||
'("gint*" "len")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method clear
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_clear")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gint" "segment")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method advance
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_advance")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint" "advance")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method may_start
|
||||
(of-object "GstRingBuffer")
|
||||
(c-name "gst_ring_buffer_may_start")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gboolean" "allowed")
|
||||
)
|
||||
)
|
||||
|
||||
(define-virtual open_device
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual acquire
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstRingBufferSpec*" "spec")
|
||||
)
|
||||
)
|
||||
|
||||
(define-virtual release
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual close_device
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual start
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual pause
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual resume
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual stop
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-virtual delay
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "guint")
|
||||
)
|
||||
|
||||
(define-virtual activate
|
||||
(of-object "GstRingBuffer")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gboolean" "active")
|
||||
)
|
||||
)
|
||||
|
||||
;; From mixerutils.h
|
||||
|
||||
(define-function default_registry_mixer_filter
|
||||
(c-name "gst_audio_default_registry_mixer_filter")
|
||||
(return-type "GList*")
|
||||
(parameters
|
||||
'("GstAudioMixerFilterFunc" "filter_func")
|
||||
'("gboolean" "first")
|
||||
'("gpointer" "user_data")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From multichannel-enumtypes.h
|
||||
|
||||
(define-function gst_audio_channel_position_get_type
|
||||
(c-name "gst_audio_channel_position_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From multichannel.h
|
||||
|
||||
(define-function get_channel_positions
|
||||
(c-name "gst_audio_get_channel_positions")
|
||||
(return-type "GstAudioChannelPosition*")
|
||||
(parameters
|
||||
'("GstStructure*" "str")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function set_channel_positions
|
||||
(c-name "gst_audio_set_channel_positions")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstStructure*" "str")
|
||||
'("const-GstAudioChannelPosition*" "pos")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function set_structure_channel_positions_list
|
||||
(c-name "gst_audio_set_structure_channel_positions_list")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstStructure*" "str")
|
||||
'("const-GstAudioChannelPosition*" "pos")
|
||||
'("gint" "num_positions")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function set_caps_channel_positions_list
|
||||
(c-name "gst_audio_set_caps_channel_positions_list")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstCaps*" "caps")
|
||||
'("const-GstAudioChannelPosition*" "pos")
|
||||
'("gint" "num_positions")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function fixate_channel_positions
|
||||
(c-name "gst_audio_fixate_channel_positions")
|
||||
(return-type "GstAudioChannelPosition*")
|
||||
(parameters
|
||||
'("GstStructure*" "str")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function check_channel_positions
|
||||
(c-name "gst_audio_check_channel_positions")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("const-GstAudioChannelPosition*" "pos")
|
||||
'("guint" "channels")
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2008 <edward.hervey@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
#include "common.h"
|
||||
#include "pygst.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/audio/gstaudioclock.h>
|
||||
#include <gst/audio/gstaudiofilter.h>
|
||||
#include <gst/audio/gstaudiosink.h>
|
||||
#include <gst/audio/gstaudiosrc.h>
|
||||
#include <gst/audio/gstbaseaudiosink.h>
|
||||
#include <gst/audio/gstbaseaudiosrc.h>
|
||||
#include <gst/audio/multichannel.h>
|
||||
#include "pygstminiobject.h"
|
||||
GST_DEBUG_CATEGORY_EXTERN (pygst_debug);
|
||||
#define GST_CAT_DEFAULT pygst_debug
|
||||
|
||||
/* Boonky define that allows for backwards compatibility with Python 2.4 */
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
#define Py_ssize_t int
|
||||
#endif
|
||||
|
||||
%%
|
||||
modulename gst.audio
|
||||
%%
|
||||
import gobject.GObject as PyGObject_Type
|
||||
import gst.Object as PyGstObject_Type
|
||||
import gst.Structure as PyGstStructure_Type
|
||||
import gst.Element as PyGstElement_Type
|
||||
import gst.Pad as PyGstPad_Type
|
||||
import gst.Buffer as PyGstBuffer_Type
|
||||
import gst.Message as PyGstMessage_Type
|
||||
import gst.SystemClock as PyGstSystemClock_Type
|
||||
import gst.BaseTransform as PyGstBaseTransform_Type
|
||||
import gst.BaseSink as PyGstBaseSink_Type
|
||||
import gst.Clock as PyGstClock_Type
|
||||
%%
|
||||
include
|
||||
gstversion.override
|
||||
%%
|
||||
ignore-glob
|
||||
_*
|
||||
*init
|
||||
*_free
|
||||
*_get_type
|
|
@ -1,58 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2008 Edward Hervey <edward.hervey@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
||||
#include <pygobject.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/audio/audio.h>
|
||||
#include <gst/audio/gstbaseaudiosink.h>
|
||||
#include <gst/audio/gstbaseaudiosrc.h>
|
||||
#include "pygst.h"
|
||||
|
||||
void pyaudio_register_classes (PyObject * d);
|
||||
void pyaudio_add_constants (PyObject * module, const gchar * strip_prefix);
|
||||
|
||||
extern PyMethodDef pyaudio_functions[];
|
||||
|
||||
GST_DEBUG_CATEGORY (pygst_debug); /* for python code */
|
||||
|
||||
DL_EXPORT (void)
|
||||
initaudio (void)
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
init_pygobject ();
|
||||
pygst_init ();
|
||||
|
||||
m = Py_InitModule ("audio", pyaudio_functions);
|
||||
d = PyModule_GetDict (m);
|
||||
|
||||
pyaudio_register_classes (d);
|
||||
pyaudio_add_constants (m, "GST_");
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
Py_FatalError ("can't initialize module gst.audio");
|
||||
}
|
||||
}
|
1164
gst/base.defs
1164
gst/base.defs
File diff suppressed because it is too large
Load diff
73
gst/common.h
73
gst/common.h
|
@ -1,73 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2004 Johan Dahlin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
#ifndef __COMMON_H__
|
||||
#define __COMMON_H__
|
||||
|
||||
#include <Python.h>
|
||||
#include <pygobject.h>
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "pygstminiobject.h"
|
||||
|
||||
#if (defined HAVE_OLD_PYGTK && (PY_VERSION_HEX < 0x02030000))
|
||||
typedef destructor freefunc;
|
||||
#endif
|
||||
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
#define lenfunc inquiry
|
||||
#define ssizeargfunc intargfunc
|
||||
#define ssizessizeargfunc intintargfunc
|
||||
#define ssizeobjargproc intobjargproc
|
||||
#define ssizessizeobjargproc intintobjargproc
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyGObject *pad;
|
||||
GClosure *link_function;
|
||||
GClosure *event_function;
|
||||
GClosure *chain_function;
|
||||
GClosure *get_function;
|
||||
GClosure *getcaps_function;
|
||||
GClosure *setcaps_function;
|
||||
GClosure *activate_function;
|
||||
GClosure *activatepull_function;
|
||||
GClosure *activatepush_function;
|
||||
/* Query is not implemented as a closure to avoid refcounting
|
||||
* making the query immutable and therefore useless */
|
||||
PyObject *query_function;
|
||||
} PyGstPadPrivate;
|
||||
|
||||
typedef struct {
|
||||
PyObject *func, *data;
|
||||
} PyGstCustomNotify;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
GstIterator *iter;
|
||||
} PyGstIterator;
|
||||
|
||||
extern PyTypeObject PyGstIterator_Type;
|
||||
|
||||
|
||||
#endif /* __COMMON_H__ */
|
1
gst/extend/.gitignore
vendored
1
gst/extend/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
*.pyc
|
|
@ -1,5 +0,0 @@
|
|||
pkgpyexecdir = $(pyexecdir)/gst-$(GST_MAJORMINOR)/gst/extend
|
||||
|
||||
pygstdir = $(pkgpyexecdir)
|
||||
pygst_PYTHON = __init__.py pygobject.py utils.py discoverer.py sources.py \
|
||||
leveller.py jukebox.py
|
|
@ -1,21 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
#
|
||||
# GStreamer python bindings
|
||||
# Copyright (C) 2002 David I. Lehn <dlehn@users.sourceforge.net>
|
||||
# 2004 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
@ -1,355 +0,0 @@
|
|||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
|
||||
# discoverer.py
|
||||
# (c) 2005-2008 Edward Hervey <bilboed at bilboed dot com>
|
||||
# Discovers multimedia information on files
|
||||
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
"""
|
||||
Class and functions for getting multimedia information about files
|
||||
"""
|
||||
|
||||
import os.path
|
||||
|
||||
import gobject
|
||||
|
||||
import gst
|
||||
|
||||
from gst.extend.pygobject import gsignal
|
||||
|
||||
class Discoverer(gst.Pipeline):
|
||||
"""
|
||||
Discovers information about files.
|
||||
This class is event-based and needs a mainloop to work properly.
|
||||
Emits the 'discovered' signal when discovery is finished.
|
||||
|
||||
The 'discovered' callback has one boolean argument, which is True if the
|
||||
file contains decodable multimedia streams.
|
||||
"""
|
||||
__gsignals__ = {
|
||||
'discovered' : (gobject.SIGNAL_RUN_FIRST,
|
||||
None,
|
||||
(gobject.TYPE_BOOLEAN, ))
|
||||
}
|
||||
|
||||
mimetype = None
|
||||
|
||||
audiocaps = {}
|
||||
videocaps = {}
|
||||
|
||||
videowidth = 0
|
||||
videoheight = 0
|
||||
videorate = 0
|
||||
|
||||
audiofloat = False
|
||||
audiorate = 0
|
||||
audiodepth = 0
|
||||
audiowidth = 0
|
||||
audiochannels = 0
|
||||
|
||||
audiolength = 0L
|
||||
videolength = 0L
|
||||
|
||||
is_video = False
|
||||
is_audio = False
|
||||
|
||||
otherstreams = []
|
||||
|
||||
finished = False
|
||||
sinknumber = 0
|
||||
tags = {}
|
||||
|
||||
|
||||
def __init__(self, filename, max_interleave=1.0, timeout=3000):
|
||||
"""
|
||||
filename: str; absolute path of the file to be discovered.
|
||||
max_interleave: int or float; the maximum frame interleave in seconds.
|
||||
The value must be greater than the input file frame interleave
|
||||
or the discoverer may not find out all input file's streams.
|
||||
The default value is 1 second and you shouldn't have to change it,
|
||||
changing it mean larger discovering time and bigger memory usage.
|
||||
timeout: int; duration in ms for the discovery to complete.
|
||||
"""
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
self.mimetype = None
|
||||
|
||||
self.audiocaps = {}
|
||||
self.videocaps = {}
|
||||
|
||||
self.videowidth = 0
|
||||
self.videoheight = 0
|
||||
self.videorate = gst.Fraction(0,1)
|
||||
|
||||
self.audiofloat = False
|
||||
self.audiorate = 0
|
||||
self.audiodepth = 0
|
||||
self.audiowidth = 0
|
||||
self.audiochannels = 0
|
||||
|
||||
self.audiolength = 0L
|
||||
self.videolength = 0L
|
||||
|
||||
self.is_video = False
|
||||
self.is_audio = False
|
||||
|
||||
self.otherstreams = []
|
||||
|
||||
self.finished = False
|
||||
self.tags = {}
|
||||
self._success = False
|
||||
self._nomorepads = False
|
||||
|
||||
self._timeoutid = 0
|
||||
self._timeout = timeout
|
||||
self._max_interleave = max_interleave
|
||||
|
||||
if not os.path.isfile(filename):
|
||||
self.debug("File '%s' does not exist, finished" % filename)
|
||||
self.finished = True
|
||||
return
|
||||
|
||||
# the initial elements of the pipeline
|
||||
self.src = gst.element_factory_make("filesrc")
|
||||
self.src.set_property("location", filename)
|
||||
self.src.set_property("blocksize", 1000000)
|
||||
self.dbin = gst.element_factory_make("decodebin")
|
||||
self.add(self.src, self.dbin)
|
||||
self.src.link(self.dbin)
|
||||
self.typefind = self.dbin.get_by_name("typefind")
|
||||
|
||||
# callbacks
|
||||
self.typefind.connect("have-type", self._have_type_cb)
|
||||
self.dbin.connect("new-decoded-pad", self._new_decoded_pad_cb)
|
||||
self.dbin.connect("no-more-pads", self._no_more_pads_cb)
|
||||
self.dbin.connect("unknown-type", self._unknown_type_cb)
|
||||
|
||||
def _timed_out_or_eos(self):
|
||||
if (not self.is_audio and not self.is_video) or \
|
||||
(self.is_audio and not self.audiocaps) or \
|
||||
(self.is_video and not self.videocaps):
|
||||
self._finished(False)
|
||||
else:
|
||||
self._finished(True)
|
||||
|
||||
def _finished(self, success=False):
|
||||
self.debug("success:%d" % success)
|
||||
self._success = success
|
||||
self.bus.remove_signal_watch()
|
||||
if self._timeoutid:
|
||||
gobject.source_remove(self._timeoutid)
|
||||
self._timeoutid = 0
|
||||
gobject.idle_add(self._stop)
|
||||
return False
|
||||
|
||||
def _stop(self):
|
||||
self.debug("success:%d" % self._success)
|
||||
self.finished = True
|
||||
self.set_state(gst.STATE_READY)
|
||||
self.debug("about to emit signal")
|
||||
self.emit('discovered', self._success)
|
||||
|
||||
def _bus_message_cb(self, bus, message):
|
||||
if message.type == gst.MESSAGE_EOS:
|
||||
self.debug("Got EOS")
|
||||
self._timed_out_or_eos()
|
||||
elif message.type == gst.MESSAGE_TAG:
|
||||
for key in message.parse_tag().keys():
|
||||
self.tags[key] = message.structure[key]
|
||||
elif message.type == gst.MESSAGE_ERROR:
|
||||
self.debug("Got error")
|
||||
self._finished()
|
||||
|
||||
def discover(self):
|
||||
"""Find the information on the given file asynchronously"""
|
||||
self.debug("starting discovery")
|
||||
if self.finished:
|
||||
self.emit('discovered', False)
|
||||
return
|
||||
|
||||
self.bus = self.get_bus()
|
||||
self.bus.add_signal_watch()
|
||||
self.bus.connect("message", self._bus_message_cb)
|
||||
|
||||
# 3s timeout
|
||||
self._timeoutid = gobject.timeout_add(self._timeout, self._timed_out_or_eos)
|
||||
|
||||
self.info("setting to PLAY")
|
||||
if not self.set_state(gst.STATE_PLAYING):
|
||||
self._finished()
|
||||
|
||||
def _time_to_string(self, value):
|
||||
"""
|
||||
transform a value in nanoseconds into a human-readable string
|
||||
"""
|
||||
ms = value / gst.MSECOND
|
||||
sec = ms / 1000
|
||||
ms = ms % 1000
|
||||
min = sec / 60
|
||||
sec = sec % 60
|
||||
return "%2dm %2ds %3d" % (min, sec, ms)
|
||||
|
||||
def print_info(self):
|
||||
"""prints out the information on the given file"""
|
||||
if not self.finished:
|
||||
return
|
||||
if not self.mimetype:
|
||||
print "Unknown media type"
|
||||
return
|
||||
print "Mime Type :\t", self.mimetype
|
||||
if not self.is_video and not self.is_audio:
|
||||
return
|
||||
print "Length :\t", self._time_to_string(max(self.audiolength, self.videolength))
|
||||
print "\tAudio:", self._time_to_string(self.audiolength), "\tVideo:", self._time_to_string(self.videolength)
|
||||
if self.is_video and self.videorate:
|
||||
print "Video :"
|
||||
print "\t%d x %d @ %d/%d fps" % (self.videowidth,
|
||||
self.videoheight,
|
||||
self.videorate.num, self.videorate.denom)
|
||||
if self.tags.has_key("video-codec"):
|
||||
print "\tCodec :", self.tags["video-codec"]
|
||||
if self.is_audio:
|
||||
print "Audio :"
|
||||
if self.audiofloat:
|
||||
print "\t%d channels(s) : %dHz @ %dbits (float)" % (self.audiochannels,
|
||||
self.audiorate,
|
||||
self.audiowidth)
|
||||
else:
|
||||
print "\t%d channels(s) : %dHz @ %dbits (int)" % (self.audiochannels,
|
||||
self.audiorate,
|
||||
self.audiodepth)
|
||||
if self.tags.has_key("audio-codec"):
|
||||
print "\tCodec :", self.tags["audio-codec"]
|
||||
for stream in self.otherstreams:
|
||||
if not stream == self.mimetype:
|
||||
print "Other unsuported Multimedia stream :", stream
|
||||
if self.tags:
|
||||
print "Additional information :"
|
||||
for tag in self.tags.keys():
|
||||
print "%20s :\t" % tag, self.tags[tag]
|
||||
|
||||
def _no_more_pads_cb(self, dbin):
|
||||
self.info("no more pads")
|
||||
self._nomorepads = True
|
||||
|
||||
def _unknown_type_cb(self, dbin, pad, caps):
|
||||
self.debug("unknown type : %s" % caps.to_string())
|
||||
# if we get an unknown type and we don't already have an
|
||||
# audio or video pad, we are finished !
|
||||
self.otherstreams.append(caps.to_string())
|
||||
if not self.is_video and not self.is_audio:
|
||||
self.finished = True
|
||||
self._finished()
|
||||
|
||||
def _have_type_cb(self, typefind, prob, caps):
|
||||
self.mimetype = caps.to_string()
|
||||
|
||||
def _notify_caps_cb(self, pad, args):
|
||||
caps = pad.get_negotiated_caps()
|
||||
if not caps:
|
||||
pad.info("no negotiated caps available")
|
||||
return
|
||||
pad.info("caps:%s" % caps.to_string())
|
||||
# the caps are fixed
|
||||
# We now get the total length of that stream
|
||||
q = gst.query_new_duration(gst.FORMAT_TIME)
|
||||
pad.info("sending duration query")
|
||||
if pad.get_peer().query(q):
|
||||
format, length = q.parse_duration()
|
||||
if format == gst.FORMAT_TIME:
|
||||
pad.info("got duration (time) : %s" % (gst.TIME_ARGS(length),))
|
||||
else:
|
||||
pad.info("got duration : %d [format:%d]" % (length, format))
|
||||
else:
|
||||
length = -1
|
||||
gst.warning("duration query failed")
|
||||
|
||||
# We store the caps and length in the proper location
|
||||
if "audio" in caps.to_string():
|
||||
self.audiocaps = caps
|
||||
self.audiolength = length
|
||||
self.audiorate = caps[0]["rate"]
|
||||
self.audiowidth = caps[0]["width"]
|
||||
self.audiochannels = caps[0]["channels"]
|
||||
if "x-raw-float" in caps.to_string():
|
||||
self.audiofloat = True
|
||||
else:
|
||||
self.audiodepth = caps[0]["depth"]
|
||||
if self._nomorepads and ((not self.is_video) or self.videocaps):
|
||||
self._finished(True)
|
||||
elif "video" in caps.to_string():
|
||||
self.videocaps = caps
|
||||
self.videolength = length
|
||||
self.videowidth = caps[0]["width"]
|
||||
self.videoheight = caps[0]["height"]
|
||||
self.videorate = caps[0]["framerate"]
|
||||
if self._nomorepads and ((not self.is_audio) or self.audiocaps):
|
||||
self._finished(True)
|
||||
|
||||
def _new_decoded_pad_cb(self, dbin, pad, is_last):
|
||||
# Does the file contain got audio or video ?
|
||||
caps = pad.get_caps()
|
||||
gst.info("caps:%s" % caps.to_string())
|
||||
if "audio" in caps.to_string():
|
||||
self.is_audio = True
|
||||
elif "video" in caps.to_string():
|
||||
self.is_video = True
|
||||
else:
|
||||
self.warning("got a different caps.. %s" % caps.to_string())
|
||||
return
|
||||
if is_last and not self.is_video and not self.is_audio:
|
||||
self.debug("is last, not video or audio")
|
||||
self._finished(False)
|
||||
return
|
||||
# we connect a fakesink to the new pad...
|
||||
pad.info("adding queue->fakesink")
|
||||
fakesink = gst.element_factory_make("fakesink", "fakesink%d-%s" %
|
||||
(self.sinknumber, "audio" in caps.to_string() and "audio" or "video"))
|
||||
self.sinknumber += 1
|
||||
queue = gst.element_factory_make("queue")
|
||||
# we want the queue to buffer up to the specified amount of data
|
||||
# before outputting. This enables us to cope with formats
|
||||
# that don't create their source pads straight away,
|
||||
# but instead wait for the first buffer of that stream.
|
||||
# The specified time must be greater than the input file
|
||||
# frame interleave for the discoverer to work properly.
|
||||
queue.props.min_threshold_time = int(self._max_interleave * gst.SECOND)
|
||||
queue.props.max_size_time = int(2 * self._max_interleave * gst.SECOND)
|
||||
queue.props.max_size_bytes = 0
|
||||
|
||||
# If durations are bad on the buffers (common for video decoders), we'll
|
||||
# never reach the min_threshold_time or max_size_time. So, set a
|
||||
# max size in buffers, and if reached, disable the min_threshold_time.
|
||||
# This ensures we don't fail to discover with various ffmpeg
|
||||
# demuxers/decoders that provide bogus (or no) duration.
|
||||
queue.props.max_size_buffers = int(100 * self._max_interleave)
|
||||
def _disable_min_threshold_cb(queue):
|
||||
queue.props.min_threshold_time = 0
|
||||
queue.disconnect(signal_id)
|
||||
signal_id = queue.connect('overrun', _disable_min_threshold_cb)
|
||||
|
||||
self.add(fakesink, queue)
|
||||
queue.link(fakesink)
|
||||
sinkpad = fakesink.get_pad("sink")
|
||||
queuepad = queue.get_pad("sink")
|
||||
# ... and connect a callback for when the caps are fixed
|
||||
sinkpad.connect("notify::caps", self._notify_caps_cb)
|
||||
if pad.link(queuepad):
|
||||
pad.warning("##### Couldn't link pad to queue")
|
||||
queue.set_state(gst.STATE_PLAYING)
|
||||
fakesink.set_state(gst.STATE_PLAYING)
|
||||
gst.info('finished here')
|
|
@ -1,356 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
#
|
||||
# GStreamer python bindings
|
||||
# Copyright (C) 2005 Edward Hervey <edward at fluendo dot com>
|
||||
# Copyright (C) 2005 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import os
|
||||
import sys
|
||||
import pickle
|
||||
import random as rand
|
||||
|
||||
import gobject
|
||||
gobject.threads_init()
|
||||
import pygst
|
||||
pygst.require('0.10')
|
||||
import gst
|
||||
|
||||
import utils
|
||||
from pygobject import gsignal
|
||||
import sources
|
||||
from leveller import Leveller
|
||||
|
||||
class Jukebox(gst.Bin):
|
||||
gsignal('done', str)
|
||||
gsignal('prerolled') # emitted when at least 2 sources are ready
|
||||
gsignal('changed', str, gobject.TYPE_UINT64) # clocktime, filename
|
||||
gsignal('looped')
|
||||
|
||||
def __init__(self, files, rms=0.2, loops=0, random=False,
|
||||
caps="audio/x-raw-int,channels=2,rate=44100",
|
||||
picklepath='level.pck'):
|
||||
# with pygtk 2.4 this call is needed for the gsignal to work
|
||||
self.__gobject_init__()
|
||||
|
||||
self._target_rms = rms
|
||||
self._loopsleft = loops
|
||||
self._loopsdone = 0
|
||||
self._random = random
|
||||
self._picklepath = picklepath
|
||||
self._caps = gst.caps_from_string(caps)
|
||||
self._files = files[:] # copy
|
||||
self._levels = {} # filename -> rms, mixin, mixout, length
|
||||
self._prerolled = False
|
||||
self._playing = False
|
||||
self._scani = 0 # index into self._files for scanning
|
||||
self._playi = 0 # index into self._files for playing
|
||||
|
||||
self._lastadded = None # last file added to composition
|
||||
self._lastposition = long(0) # last position where file was added
|
||||
|
||||
if not len(files) > 1:
|
||||
raise TypeError, 'Must have at least 2 files'
|
||||
|
||||
self._composition = gst.element_factory_make("gnlcomposition")
|
||||
self._composition.connect('pad-added', self._composition_pad_added_cb)
|
||||
self.add(self._composition)
|
||||
|
||||
self._srcpad = None
|
||||
|
||||
# load our pickle if it exists
|
||||
if os.path.exists(self._picklepath):
|
||||
file = open(self._picklepath)
|
||||
self._levels = pickle.load(file)
|
||||
file.close()
|
||||
|
||||
# randomize our list if asked for
|
||||
if self._random:
|
||||
self._files = rand.sample(self._files, len(self._files))
|
||||
|
||||
|
||||
## public API
|
||||
|
||||
def preroll(self):
|
||||
# scan the first few files and start playing
|
||||
gst.debug("starting jukebox prerolling")
|
||||
self._scan()
|
||||
|
||||
def start(self):
|
||||
##
|
||||
## FIXME : THIS SHOULD'T BE NEEDED !
|
||||
## USE STATE CHANGES INSTEAD
|
||||
##
|
||||
if not self._prerolled:
|
||||
raise Exception, "baby"
|
||||
self.set_state(gst.STATE_PAUSED)
|
||||
|
||||
|
||||
## Scanning private methods
|
||||
|
||||
def _scan(self):
|
||||
# start a leveller for a new _toscan file
|
||||
if self._scani >= len(self._files):
|
||||
gst.debug("We're done scanning !")
|
||||
return
|
||||
|
||||
file = self._files[self._scani]
|
||||
self._scani += 1
|
||||
|
||||
if file in self._levels.keys():
|
||||
gst.debug("already did file %s" % file)
|
||||
self._check_prerolled()
|
||||
gobject.timeout_add(0, self._scan)
|
||||
return
|
||||
|
||||
gst.debug("creating leveller for %s" % file)
|
||||
leveller = Leveller(file)
|
||||
leveller.connect('done', self._leveller_done_cb, file)
|
||||
gobject.timeout_add(0, leveller.start)
|
||||
##gobject.idle_add(leveller.iterate)
|
||||
|
||||
def _leveller_done_cb(self, l, reason, file):
|
||||
if reason != sources.EOS:
|
||||
gst.debug("Error: %s" % reason)
|
||||
return
|
||||
|
||||
gst.debug("in: %s, out: %s" % (gst.TIME_ARGS(l.mixin),
|
||||
gst.TIME_ARGS(l.mixout)))
|
||||
gst.debug("rms: %f, %f dB" % (l.rms, l.rmsdB))
|
||||
|
||||
# store infos
|
||||
self._levels[file] = (l.rms, l.mixin, l.mixout, l.length)
|
||||
|
||||
gst.debug("writing level pickle")
|
||||
file = open(self._picklepath, "w")
|
||||
pickle.dump(self._levels, file)
|
||||
file.close()
|
||||
|
||||
self._check_prerolled()
|
||||
self._scan()
|
||||
|
||||
# clean up leveller after this handler
|
||||
gobject.timeout_add(0, l.clean)
|
||||
|
||||
|
||||
## GnlSource-related methods
|
||||
|
||||
def _new_gnl_source(self, location, start):
|
||||
"""
|
||||
Creates a new GnlSource containing an AudioSource with the following
|
||||
properties correctly set:
|
||||
_ volume level
|
||||
_ priority
|
||||
_ duration
|
||||
The start position MUST be given
|
||||
"""
|
||||
if not self._levels[location]:
|
||||
return None
|
||||
self.debug("Creating new GnlSource at %s for %s" % (gst.TIME_ARGS(start), location))
|
||||
idx = self._files.index(location) + self._loopsdone * len(self._files)
|
||||
rms, mixin, mixout, duration = self._levels[location]
|
||||
gnls = gst.element_factory_make("gnlsource", "source-%d-%s" % (idx, location))
|
||||
src = sources.AudioSource(location)
|
||||
gnls.add(src)
|
||||
|
||||
# set volume
|
||||
level = 1.0
|
||||
if rms > self._target_rms:
|
||||
level = self._target_rms / rms
|
||||
gst.debug('setting volume of %f' % level)
|
||||
else:
|
||||
gst.debug('not going to go above 1.0 level')
|
||||
src.set_volume(level)
|
||||
|
||||
# set proper position/duration/priority in composition
|
||||
gnls.props.priority = (2 * self._loopsdone) + 1 + (idx % 2)
|
||||
gnls.props.start = long(start)
|
||||
gnls.props.duration = long(duration)
|
||||
gnls.props.media_duration = long(duration)
|
||||
gnls.props.media_start = long(0)
|
||||
|
||||
return gnls
|
||||
|
||||
def _new_mixer(self, start, duration):
|
||||
gnlo = gst.element_factory_make("gnloperation")
|
||||
ad = gst.element_factory_make("adder")
|
||||
gnlo.add(ad)
|
||||
gnlo.props.sinks = 2
|
||||
gnlo.props.start = start
|
||||
gnlo.props.duration = duration
|
||||
gnlo.props.priority = 0
|
||||
|
||||
return gnlo
|
||||
|
||||
def _append_file(self, location):
|
||||
"""
|
||||
Appends the given file to the composition, along with the proper mixer effect
|
||||
"""
|
||||
self.debug("location:%s" % location)
|
||||
start = self._lastposition
|
||||
if self._lastadded:
|
||||
start += self._levels[self._lastadded][2]
|
||||
start -= self._levels[location][1]
|
||||
|
||||
gnls = self._new_gnl_source(location, start)
|
||||
self._composition.add(gnls)
|
||||
|
||||
if self._lastadded:
|
||||
# create the mixer
|
||||
duration = self._levels[self._lastadded][3] - self._levels[self._lastadded][2] + self._levels[location][1]
|
||||
mixer = self._new_mixer(start, duration)
|
||||
self._composition.add(mixer)
|
||||
|
||||
self._lastposition = start
|
||||
self._lastadded = location
|
||||
|
||||
self.debug("lastposition:%s , lastadded:%s" % (gst.TIME_ARGS(self._lastposition),
|
||||
self._lastadded))
|
||||
|
||||
def _check_prerolled(self):
|
||||
gst.debug("_check_prerolled: index: scan %d, play %d" % (
|
||||
self._scani, self._playi))
|
||||
if not self._prerolled and self._scani > self._playi + 1:
|
||||
self._prerolled = True
|
||||
# add initial sources here
|
||||
self._append_file(self._files[0])
|
||||
self._append_file(self._files[1])
|
||||
self.debug("now prerolled and ready to play")
|
||||
self.emit('prerolled')
|
||||
|
||||
|
||||
def _emit_changed(self, file, when):
|
||||
print "emitting changed for %s at %r" % (file, when)
|
||||
self.emit('changed', file, when)
|
||||
|
||||
def _source_clean(self, source):
|
||||
source.set_state(gst.STATE_NULL)
|
||||
self.remove(source)
|
||||
source.clean()
|
||||
|
||||
## composition callbacks
|
||||
|
||||
def _composition_pad_added_cb(self, comp, pad):
|
||||
if self._srcpad:
|
||||
return
|
||||
self.debug("Ghosting source pad %s" % pad)
|
||||
self._srcpad = gst.GhostPad("src", pad)
|
||||
self._srcpad.set_active(True)
|
||||
self.add_pad(self._srcpad)
|
||||
|
||||
## gst.Bin/Element virtual methods
|
||||
|
||||
def do_handle_message(self, message):
|
||||
self.debug("got message %s / %s / %r" % (message.src.get_name(), message.type.first_value_name, message))
|
||||
|
||||
# chaining up
|
||||
gst.Bin.do_handle_message(self, message)
|
||||
|
||||
def do_state_change(self, transition):
|
||||
if not self._prerolled:
|
||||
gst.error("Call Jukebox.preroll() before!")
|
||||
return gst.STATE_CHANGE_FAILURE
|
||||
# chaining up
|
||||
return gst.Bin.do_state_change(self, message)
|
||||
|
||||
gobject.type_register(Jukebox)
|
||||
|
||||
# helper functions
|
||||
def _find_elements_recurse(element):
|
||||
if not isinstance(element, gst.Bin):
|
||||
return [element, ]
|
||||
l = []
|
||||
for e in element.elements():
|
||||
l.extend(_find_elements_recurse(e))
|
||||
return l
|
||||
|
||||
def _find_unconnected_pad(bin, direction):
|
||||
for e in _find_elements_recurse(bin):
|
||||
for p in e.pads():
|
||||
if p.get_direction() == direction and not p.get_peer():
|
||||
return p
|
||||
|
||||
return None
|
||||
|
||||
# run us to test
|
||||
if __name__ == "__main__":
|
||||
main = gobject.MainLoop()
|
||||
pipeline = gst.Pipeline('jukebox')
|
||||
list = open(sys.argv[1]).read().rstrip().split('\n')
|
||||
print list
|
||||
#source = Jukebox(list, random=True, loops=-1)
|
||||
source = Jukebox(list, random=True, loops=1)
|
||||
|
||||
def _jukebox_prerolled_cb(jukebox):
|
||||
print "prerolled"
|
||||
_start()
|
||||
|
||||
def _jukebox_changed_cb(jukebox, filename, when):
|
||||
print "changed file to %s at %s" % (filename, float(when) / gst.TIME_ARGS(gst.SECOND))
|
||||
|
||||
def _jukebox_looped_cb(jukebox):
|
||||
print "jukebox looped"
|
||||
|
||||
def _start():
|
||||
source.start()
|
||||
print "setting pipeline to PLAYING"
|
||||
pipeline.set_state(gst.STATE_PLAYING)
|
||||
print "set pipeline to PLAYING"
|
||||
|
||||
def jukebox_pad_added(comp, pad, sinkpad):
|
||||
pad.link(sinkpad)
|
||||
|
||||
def jukebox_message(bus, message):
|
||||
if message.type == gst.MESSAGE_ERROR:
|
||||
print "Error: %s" % message.parse_error()
|
||||
main.quit()
|
||||
elif message.type == gst.MESSAGE_EOS:
|
||||
print "done"
|
||||
main.quit()
|
||||
|
||||
source.connect('prerolled', _jukebox_prerolled_cb)
|
||||
source.connect('changed', _jukebox_changed_cb)
|
||||
source.connect('looped', _jukebox_looped_cb)
|
||||
source.preroll()
|
||||
pipeline.add(source)
|
||||
|
||||
bus = pipeline.get_bus()
|
||||
bus.add_signal_watch()
|
||||
bus.connect("message", jukebox_message)
|
||||
|
||||
p = "alsasink"
|
||||
if len(sys.argv) > 2:
|
||||
p = " ".join(sys.argv[2:])
|
||||
|
||||
print "parsing output pipeline %s" % p
|
||||
sinkbin = gst.parse_launch("bin.( %s )" % p)
|
||||
pipeline.add(sinkbin)
|
||||
apad = _find_unconnected_pad(sinkbin, gst.PAD_SINK)
|
||||
if not apad:
|
||||
raise TypeError, "No unconnected sink pad found in bin %r" % sinkbin
|
||||
sinkpad = gst.GhostPad("sink", apad)
|
||||
sinkbin.add_pad(sinkpad)
|
||||
source.connect('pad-added', jukebox_pad_added, sinkpad)
|
||||
|
||||
print "Going into main loop"
|
||||
sys.stdout.flush()
|
||||
main.run()
|
||||
print "Left main loop"
|
||||
sys.stdout.flush()
|
||||
|
||||
pipeline.set_state(gst.STATE_NULL)
|
|
@ -1,285 +0,0 @@
|
|||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
#
|
||||
# GStreamer python bindings
|
||||
# Copyright (C) 2005 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import os
|
||||
import sys
|
||||
import math
|
||||
|
||||
import gobject
|
||||
import pygst
|
||||
pygst.require('0.10')
|
||||
import gst
|
||||
|
||||
import utils
|
||||
from pygobject import gsignal
|
||||
|
||||
import sources
|
||||
from sources import EOS, ERROR, UNKNOWN_TYPE, WRONG_TYPE
|
||||
|
||||
class Leveller(gst.Pipeline):
|
||||
"""
|
||||
I am a pipeline that calculates RMS values and mix-in/out points.
|
||||
I will signal 'done' when I'm done scanning the file, with return value
|
||||
EOS, ERROR, UNKNOWN_TYPE, or WRONG_TYPE from gst.extend.sources
|
||||
"""
|
||||
|
||||
gsignal('done', str)
|
||||
|
||||
def __init__(self, filename, threshold=-9.0):
|
||||
gst.Pipeline.__init__(self)
|
||||
|
||||
self._filename = filename
|
||||
|
||||
self._thresholddB = threshold
|
||||
self._threshold = math.pow(10, self._thresholddB / 10.0)
|
||||
|
||||
self._source = sources.AudioSource(filename)
|
||||
self._source.connect('done', self._done_cb)
|
||||
|
||||
self._level = gst.element_factory_make("level")
|
||||
|
||||
self._fakesink = gst.element_factory_make("fakesink")
|
||||
|
||||
self.add(self._source, self._level, self._fakesink)
|
||||
self._source.connect("pad-added", self._sourcePadAddedCb)
|
||||
self._level.link(self._fakesink)
|
||||
|
||||
# temporary values for each timepoint
|
||||
self._rmsdB = {} # hash of channel, rmsdB value
|
||||
self._peakdB = 0.0 # highest value over all channels for this time
|
||||
|
||||
# results over the whole file
|
||||
self._meansquaresums = [] # list of time -> mean square sum value
|
||||
self._peaksdB = [] # list of time -> peak value
|
||||
|
||||
self._lasttime = 0
|
||||
|
||||
# will be set when done
|
||||
self.mixin = 0
|
||||
self.mixout = 0
|
||||
self.length = 0
|
||||
self.rms = 0.0
|
||||
self.rmsdB = 0.0
|
||||
|
||||
def _sourcePadAddedCb(self, source, pad):
|
||||
self._source.link(self._level)
|
||||
|
||||
def do_handle_message(self, message):
|
||||
self.debug("got message %r" % message)
|
||||
if (message.type == gst.MESSAGE_ELEMENT) and (message.src == self._level):
|
||||
struc = message.structure
|
||||
endtime = struc["endtime"]
|
||||
rmss = struc["rms"]
|
||||
peaks = struc["peak"]
|
||||
decays = struc["decay"]
|
||||
infos = zip(rmss, peaks, decays)
|
||||
channid = 0
|
||||
for rms,peak,decay in infos:
|
||||
self._level_cb(message.src, endtime, channid, rms, peak, decay)
|
||||
channid += 1
|
||||
elif message.type == gst.MESSAGE_EOS:
|
||||
self._eos_cb(message.src)
|
||||
# chaining up
|
||||
gst.Pipeline.do_handle_message(self, message)
|
||||
|
||||
def _level_cb(self, element, time, channel, rmsdB, peakdB, decaydB):
|
||||
# rms is being signalled in dB
|
||||
# FIXME: maybe level should have a way of signalling actual values
|
||||
# signals are received in order, so I should get each channel one
|
||||
# by one
|
||||
if time > self._lasttime and self._lasttime > 0:
|
||||
# we have a new time point, so calculate stuff for the old block
|
||||
meansquaresum = 0.0
|
||||
for i in self._rmsdB.keys():
|
||||
meansquaresum += math.pow(10, self._rmsdB[i] / 10.0)
|
||||
# average over channels
|
||||
meansquaresum /= len(self._rmsdB.keys())
|
||||
try:
|
||||
rmsdBstr = str(10 * math.log10(meansquaresum))
|
||||
except OverflowError:
|
||||
rmsdBstr = "(-inf)"
|
||||
gst.log("meansquaresum %f (%s dB)" % (meansquaresum, rmsdBstr))
|
||||
|
||||
# update values
|
||||
self._peaksdB.append((self._lasttime, peakdB))
|
||||
self._meansquaresums.append((self._lasttime, meansquaresum))
|
||||
self._rmsdB = {}
|
||||
self._peakdB = 0.0
|
||||
|
||||
# store the current values for later processing
|
||||
gst.log("time %s, channel %d, rmsdB %f" % (gst.TIME_ARGS(time), channel, rmsdB))
|
||||
self._lasttime = time
|
||||
self._rmsdB[channel] = rmsdB
|
||||
if peakdB > self._peakdB:
|
||||
self._peakdB = peakdB
|
||||
|
||||
def _done_cb(self, source, reason):
|
||||
gst.debug("done, reason %s" % reason)
|
||||
# we ignore eos because we want the whole pipeline to eos
|
||||
if reason == EOS:
|
||||
return
|
||||
self.emit('done', reason)
|
||||
|
||||
def _eos_cb(self, source):
|
||||
gst.debug("eos, start calcing")
|
||||
|
||||
# get the highest peak RMS for this track
|
||||
highestdB = self._peaksdB[0][1]
|
||||
|
||||
for (time, peakdB) in self._peaksdB:
|
||||
if peakdB > highestdB:
|
||||
highestdB = peakdB
|
||||
gst.debug("highest peak(dB): %f" % highestdB)
|
||||
|
||||
# get the length
|
||||
(self.length, peakdB) = self._peaksdB[-1]
|
||||
|
||||
# find the mix in point
|
||||
for (time, peakdB) in self._peaksdB:
|
||||
gst.log("time %s, peakdB %f" % (gst.TIME_ARGS(time), peakdB))
|
||||
if peakdB > self._thresholddB + highestdB:
|
||||
gst.debug("found mix-in point of %f dB at %s" % (
|
||||
peakdB, gst.TIME_ARGS(time)))
|
||||
self.mixin = time
|
||||
break
|
||||
|
||||
# reverse and find out point
|
||||
self._peaksdB.reverse()
|
||||
found = None
|
||||
for (time, peakdB) in self._peaksdB:
|
||||
if found:
|
||||
self.mixout = time
|
||||
gst.debug("found mix-out point of %f dB right before %s" % (
|
||||
found, gst.TIME_ARGS(time)))
|
||||
break
|
||||
|
||||
if peakdB > self._thresholddB + highestdB:
|
||||
found = peakdB
|
||||
|
||||
# now calculate RMS between these two points
|
||||
weightedsquaresums = 0.0
|
||||
lasttime = self.mixin
|
||||
for (time, meansquaresum) in self._meansquaresums:
|
||||
if time <= self.mixin:
|
||||
continue
|
||||
|
||||
delta = time - lasttime
|
||||
weightedsquaresums += meansquaresum * delta
|
||||
gst.log("added MSS %f over time %s at time %s, now %f" % (
|
||||
meansquaresum, gst.TIME_ARGS(delta),
|
||||
gst.TIME_ARGS(time), weightedsquaresums))
|
||||
|
||||
lasttime = time
|
||||
|
||||
if time > self.mixout:
|
||||
break
|
||||
|
||||
# calculate
|
||||
try:
|
||||
ms = weightedsquaresums / (self.mixout - self.mixin)
|
||||
except ZeroDivisionError:
|
||||
# this is possible when, for example, the whole sound file is
|
||||
# empty
|
||||
gst.warning('ZeroDivisionError on %s, mixin %s, mixout %s' % (
|
||||
self._filename, gst.TIME_ARGS(self.mixin),
|
||||
gst.TIME_ARGS(self.mixout)))
|
||||
self.emit('done', WRONG_TYPE)
|
||||
return
|
||||
|
||||
self.rms = math.sqrt(ms)
|
||||
self.rmsdB = 10 * math.log10(ms)
|
||||
|
||||
self.emit('done', EOS)
|
||||
|
||||
def start(self):
|
||||
gst.debug("Setting to PLAYING")
|
||||
self.set_state(gst.STATE_PLAYING)
|
||||
gst.debug("Set to PLAYING")
|
||||
|
||||
# FIXME: we might want to do this ourselves automatically ?
|
||||
def stop(self):
|
||||
"""
|
||||
Stop the leveller, freeing all resources.
|
||||
Call after the leveller emitted 'done' to clean up.
|
||||
"""
|
||||
gst.debug("Setting to NULL")
|
||||
self.set_state(gst.STATE_NULL)
|
||||
gst.debug("Set to NULL")
|
||||
utils.gc_collect('Leveller.stop()')
|
||||
|
||||
def clean(self):
|
||||
# clean ourselves up completely
|
||||
self.stop()
|
||||
# let's be ghetto and clean out our bin manually
|
||||
self.remove(self._source)
|
||||
self.remove(self._level)
|
||||
self.remove(self._fakesink)
|
||||
gst.debug("Emptied myself")
|
||||
self._source.clean()
|
||||
utils.gc_collect('Leveller.clean() cleaned up source')
|
||||
self._source = None
|
||||
self._fakesink = None
|
||||
self._level = None
|
||||
utils.gc_collect('Leveller.clean() done')
|
||||
|
||||
gobject.type_register(Leveller)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main = gobject.MainLoop()
|
||||
|
||||
try:
|
||||
leveller = Leveller(sys.argv[1])
|
||||
except IndexError:
|
||||
sys.stderr.write("Please give a file to calculate level of\n")
|
||||
sys.exit(1)
|
||||
|
||||
print "Starting"
|
||||
bus = leveller.get_bus()
|
||||
bus.add_signal_watch()
|
||||
dontstop = True
|
||||
|
||||
leveller.set_state(gst.STATE_PLAYING)
|
||||
|
||||
while dontstop:
|
||||
message = bus.poll(gst.MESSAGE_ANY, gst.SECOND)
|
||||
if message:
|
||||
gst.debug("got message from poll:%s/%r" % (message.type, message))
|
||||
else:
|
||||
gst.debug("got NOTHING from poll")
|
||||
if message:
|
||||
if message.type == gst.MESSAGE_EOS:
|
||||
print "in: %s, out: %s, length: %s" % (gst.TIME_ARGS(leveller.mixin),
|
||||
gst.TIME_ARGS(leveller.mixout),
|
||||
gst.TIME_ARGS(leveller.length))
|
||||
print "rms: %f, %f dB" % (leveller.rms, leveller.rmsdB)
|
||||
dontstop = False
|
||||
elif message.type == gst.MESSAGE_ERROR:
|
||||
error,debug = message.parse_error()
|
||||
print "ERROR[%s] %s" % (error.domain, error.message)
|
||||
dontstop = False
|
||||
|
||||
leveller.stop()
|
||||
leveller.clean()
|
||||
|
||||
gst.debug('deleting leveller, verify objects are freed')
|
||||
utils.gc_collect('quit main loop')
|
||||
del leveller
|
||||
utils.gc_collect('deleted leveller')
|
||||
gst.debug('stopping forever')
|
|
@ -1,172 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
#
|
||||
# GStreamer python bindings
|
||||
# Copyright (C) 2004 Johan Dahlin <johan at gnome dot org>
|
||||
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
"""
|
||||
PyGTK helper functions
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
import gobject
|
||||
|
||||
def gobject_set_property(object, property, value):
|
||||
"""
|
||||
Set the given property to the given value on the given object.
|
||||
|
||||
@type object: L{gobject.GObject}
|
||||
@type property: string
|
||||
@param value: value to set property to
|
||||
"""
|
||||
for pspec in gobject.list_properties(object):
|
||||
if pspec.name == property:
|
||||
break
|
||||
else:
|
||||
raise errors.PropertyError(
|
||||
"Property '%s' in element '%s' does not exist" % (
|
||||
property, object.get_property('name')))
|
||||
|
||||
if pspec.value_type in (gobject.TYPE_INT, gobject.TYPE_UINT,
|
||||
gobject.TYPE_INT64, gobject.TYPE_UINT64):
|
||||
try:
|
||||
value = int(value)
|
||||
except ValueError:
|
||||
msg = "Invalid value given for property '%s' in element '%s'" % (
|
||||
property, object.get_property('name'))
|
||||
raise errors.PropertyError(msg)
|
||||
|
||||
elif pspec.value_type == gobject.TYPE_BOOLEAN:
|
||||
if value == 'False':
|
||||
value = False
|
||||
elif value == 'True':
|
||||
value = True
|
||||
else:
|
||||
value = bool(value)
|
||||
elif pspec.value_type in (gobject.TYPE_DOUBLE, gobject.TYPE_FLOAT):
|
||||
value = float(value)
|
||||
elif pspec.value_type == gobject.TYPE_STRING:
|
||||
value = str(value)
|
||||
# FIXME: this is superevil ! we really need to find a better way
|
||||
# of checking if this property is a param enum
|
||||
# also, we only allow int for now
|
||||
elif repr(pspec.__gtype__).startswith("<GType GParamEnum"):
|
||||
value = int(value)
|
||||
else:
|
||||
raise errors.PropertyError('Unknown property type: %s' %
|
||||
pspec.value_type)
|
||||
|
||||
object.set_property(property, value)
|
||||
|
||||
def gsignal(name, *args):
|
||||
"""
|
||||
Add a GObject signal to the current object.
|
||||
To be used from class definition scope.
|
||||
|
||||
@type name: string
|
||||
@type args: mixed
|
||||
"""
|
||||
frame = sys._getframe(1)
|
||||
_locals = frame.f_locals
|
||||
|
||||
if not '__gsignals__' in _locals:
|
||||
_dict = _locals['__gsignals__'] = {}
|
||||
else:
|
||||
_dict = _locals['__gsignals__']
|
||||
|
||||
_dict[name] = (gobject.SIGNAL_RUN_FIRST, None, args)
|
||||
|
||||
PARAM_CONSTRUCT = 1<<9
|
||||
|
||||
def with_construct_properties(__init__):
|
||||
"""
|
||||
Wrap a class' __init__ method in a procedure that will construct
|
||||
gobject properties. This is necessary because pygtk's object
|
||||
construction is a bit broken.
|
||||
|
||||
Usage::
|
||||
|
||||
class Foo(GObject):
|
||||
def __init__(self):
|
||||
GObject.__init(self)
|
||||
__init__ = with_construct_properties(__init__)
|
||||
"""
|
||||
frame = sys._getframe(1)
|
||||
_locals = frame.f_locals
|
||||
gproperties = _locals['__gproperties__']
|
||||
def hacked_init(self, *args, **kwargs):
|
||||
__init__(self, *args, **kwargs)
|
||||
self.__gproperty_values = {}
|
||||
for p, v in gproperties.items():
|
||||
if v[-1] & PARAM_CONSTRUCT:
|
||||
self.set_property(p, v[3])
|
||||
return hacked_init
|
||||
|
||||
def gproperty(type_, name, desc, *args, **kwargs):
|
||||
"""
|
||||
Add a GObject property to the current object.
|
||||
To be used from class definition scope.
|
||||
|
||||
@type type_: type object
|
||||
@type name: string
|
||||
@type desc: string
|
||||
@type args: mixed
|
||||
"""
|
||||
frame = sys._getframe(1)
|
||||
_locals = frame.f_locals
|
||||
flags = 0
|
||||
|
||||
def _do_get_property(self, prop):
|
||||
try:
|
||||
return self._gproperty_values[prop.name]
|
||||
except (AttributeError, KeyError):
|
||||
raise AttributeError('Property was never set', self, prop)
|
||||
|
||||
def _do_set_property(self, prop, value):
|
||||
if not getattr(self, '_gproperty_values', None):
|
||||
self._gproperty_values = {}
|
||||
self._gproperty_values[prop.name] = value
|
||||
|
||||
_locals['do_get_property'] = _do_get_property
|
||||
_locals['do_set_property'] = _do_set_property
|
||||
|
||||
if not '__gproperties__' in _locals:
|
||||
_dict = _locals['__gproperties__'] = {}
|
||||
else:
|
||||
_dict = _locals['__gproperties__']
|
||||
|
||||
for i in 'readable', 'writable':
|
||||
if not i in kwargs:
|
||||
kwargs[i] = True
|
||||
|
||||
for k, v in kwargs.items():
|
||||
if k == 'construct':
|
||||
flags |= PARAM_CONSTRUCT
|
||||
elif k == 'construct_only':
|
||||
flags |= gobject.PARAM_CONSTRUCT_ONLY
|
||||
elif k == 'readable':
|
||||
flags |= gobject.PARAM_READABLE
|
||||
elif k == 'writable':
|
||||
flags |= gobject.PARAM_WRITABLE
|
||||
elif k == 'lax_validation':
|
||||
flags |= gobject.PARAM_LAX_VALIDATION
|
||||
else:
|
||||
raise Exception('Invalid GObject property flag: %r=%r' % (k, v))
|
||||
|
||||
_dict[name] = (type_, name, desc) + args + tuple((flags,))
|
|
@ -1,165 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
#
|
||||
# GStreamer python bindings
|
||||
# Copyright (C) 2005 Edward Hervey <edward at fluendo dot com>
|
||||
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2.1 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import gobject
|
||||
import pygst
|
||||
pygst.require('0.10')
|
||||
import gst
|
||||
|
||||
from pygobject import gsignal
|
||||
|
||||
EOS = 'EOS'
|
||||
ERROR = 'ERROR'
|
||||
WRONG_TYPE = 'WRONG_TYPE'
|
||||
UNKNOWN_TYPE = 'UNKNOWN_TYPE'
|
||||
|
||||
class AudioSource(gst.Bin):
|
||||
"""A bin for audio sources with proper audio converters"""
|
||||
|
||||
gsignal('done', str)
|
||||
gsignal('prerolled')
|
||||
|
||||
def __init__(self, filename, caps="audio/x-raw-int,channels=2,rate=44100"):
|
||||
# with pygtk 2.4 this call is needed for the gsignal to work
|
||||
gst.Bin.__init__(self)
|
||||
|
||||
self.filename = filename
|
||||
self.outcaps = caps
|
||||
|
||||
self.filesrc = gst.element_factory_make("filesrc")
|
||||
self.filesrc.set_property("location", self.filename)
|
||||
self.dbin = gst.element_factory_make("decodebin")
|
||||
self.audioconvert = gst.element_factory_make("audioconvert")
|
||||
self.audioresample = gst.element_factory_make("audioresample")
|
||||
self.volume = gst.element_factory_make("volume")
|
||||
|
||||
self.add(self.filesrc, self.dbin,
|
||||
self.audioconvert, self.audioresample, self.volume)
|
||||
self.filesrc.link(self.dbin)
|
||||
self.audioconvert.link(self.audioresample)
|
||||
self.audioresample.link(self.volume, caps)
|
||||
|
||||
self.dbin.connect("new-decoded-pad", self._new_decoded_pad_cb)
|
||||
self.dbin.connect("unknown-type", self._unknown_type_cb)
|
||||
|
||||
self._srcpad = None
|
||||
|
||||
def __repr__(self):
|
||||
return "<AudioSource for %s>" % self.filename
|
||||
|
||||
def set_volume(self, volume):
|
||||
gst.debug("setting volume to %f" % volume)
|
||||
self.volume.set_property("volume", volume)
|
||||
|
||||
def _new_decoded_pad_cb(self, dbin, pad, is_last):
|
||||
gst.debug("new decoded pad: pad %r [%s]" % (pad, pad.get_caps().to_string()))
|
||||
if not "audio" in pad.get_caps().to_string() or self._srcpad:
|
||||
return
|
||||
|
||||
gst.debug("linking pad %r to audioconvert" % pad)
|
||||
pad.link(self.audioconvert.get_pad("sink"))
|
||||
|
||||
self._srcpad = gst.GhostPad("src", self.volume.get_pad("src"))
|
||||
self._srcpad.set_active(True)
|
||||
self.add_pad(self._srcpad)
|
||||
|
||||
def _unknown_type_cb(self, pad, caps):
|
||||
self.emit('done', UNKNOWN_TYPE)
|
||||
|
||||
def stop(self):
|
||||
self.set_state(gst.STATE_NULL)
|
||||
|
||||
def clean(self):
|
||||
self.stop()
|
||||
self.remove(self.filesrc)
|
||||
self.remove(self.dbin)
|
||||
self.remove(self.audioconvert)
|
||||
self.remove(self.audioresample)
|
||||
self.remove(self.volume)
|
||||
self.filesrc = None
|
||||
self.dbin = None
|
||||
self.audioconvert = None
|
||||
self.volume = None
|
||||
|
||||
gobject.type_register(AudioSource)
|
||||
|
||||
|
||||
# run us to test
|
||||
if __name__ == "__main__":
|
||||
main = gobject.MainLoop()
|
||||
|
||||
def _done_cb(source, reason):
|
||||
print "Done"
|
||||
sys.stdout.flush()
|
||||
if reason != EOS:
|
||||
print "Some error happened: %s" % reason
|
||||
main.quit()
|
||||
|
||||
def _error_cb(source, element, gerror, message):
|
||||
print "Error: %s" % gerror
|
||||
main.quit()
|
||||
|
||||
try:
|
||||
source = AudioSource(sys.argv[1])
|
||||
except IndexError:
|
||||
sys.stderr.write("Please give a filename to play\n")
|
||||
sys.exit(1)
|
||||
|
||||
pipeline = gst.Pipeline("playing")
|
||||
# connecting on the source also catches eos emit when
|
||||
# no audio pad
|
||||
source.connect('done', _done_cb)
|
||||
pipeline.connect('error', _error_cb)
|
||||
|
||||
p = "osssink"
|
||||
if len(sys.argv) > 2:
|
||||
p = " ".join(sys.argv[2:])
|
||||
|
||||
pipeline.add(source)
|
||||
sink = gst.parse_launch(p)
|
||||
pipeline.add(sink)
|
||||
source.link(sink)
|
||||
|
||||
# we schedule this as a timeout so that we are definately in the main
|
||||
# loop when it goes to PLAYING, and errors make main.quit() work correctly
|
||||
def _start(pipeline):
|
||||
print "setting pipeline to PLAYING"
|
||||
pipeline.set_state(gst.STATE_PLAYING)
|
||||
print "set pipeline to PLAYING"
|
||||
|
||||
gobject.timeout_add(0, _start, pipeline)
|
||||
gobject.idle_add(pipeline.iterate)
|
||||
|
||||
print "Going into main loop"
|
||||
main.run()
|
||||
print "Left main loop"
|
||||
|
||||
pipeline.set_state(gst.STATE_NULL)
|
||||
pipeline.remove(source)
|
||||
pipeline.remove(sink)
|
||||
utils.gc_collect('cleaned out pipeline')
|
||||
source.clean()
|
||||
utils.gc_collect('cleaned up source')
|
||||
source = None
|
||||
utils.gc_collect('set source to None')
|
|
@ -1,77 +0,0 @@
|
|||
import os
|
||||
|
||||
import gobject
|
||||
import gst
|
||||
|
||||
def gst_dump(bin):
|
||||
dump_element(bin, 0)
|
||||
|
||||
def dump_bin(bin, indent):
|
||||
# Iterate the children
|
||||
for child in bin.get_list():
|
||||
dump_element(child, indent + 2)
|
||||
|
||||
def dump_element(element, indent):
|
||||
states = { 1: 'NULL', 2: 'READY',
|
||||
4: 'PAUSED', 8: 'PLAYING' }
|
||||
|
||||
state = 'UNKNOWN'
|
||||
try:
|
||||
state = states[element.get_state()]
|
||||
except KeyError:
|
||||
state = 'UNKNOWN (%d)' % element.get_state()
|
||||
|
||||
c = element.get_clock()
|
||||
if c is None:
|
||||
clock_str = "clock - None"
|
||||
else:
|
||||
clock_str = "clock - %s" % (c.get_name())
|
||||
|
||||
out = "%s (%s): state %s, %s" % (element.get_name(),
|
||||
gobject.type_name(element.__gtype__), state, clock_str)
|
||||
|
||||
print out.rjust(len(out) + indent)
|
||||
|
||||
tmp = { True: 'active', False: 'inactive' }
|
||||
|
||||
for curpad in element.get_pad_list():
|
||||
if curpad.get_direction() == gst.PAD_SRC:
|
||||
if curpad.is_linked():
|
||||
peer = curpad.get_peer()
|
||||
out = " - %s:%s (%s) => %s:%s (%s)" % (
|
||||
curpad.get_parent().get_name(), curpad.get_name(),
|
||||
tmp[curpad.is_active()],
|
||||
peer.get_parent().get_name(), peer.get_name(),
|
||||
tmp[peer.is_active()])
|
||||
|
||||
print out.rjust(len(out) + indent)
|
||||
|
||||
if isinstance(element, gst.Bin):
|
||||
dump_bin(element, indent + 2)
|
||||
elif isinstance(element, gst.Queue):
|
||||
out = " - time_level: %ld" % (
|
||||
element.get_property('current-level-time'))
|
||||
print out.rjust(len(out) + indent)
|
||||
out = " - bytes_level: %ld" % (
|
||||
element.get_property('current-level-bytes'))
|
||||
print out.rjust(len(out) + indent)
|
||||
|
||||
def gc_collect(reason=None):
|
||||
"""
|
||||
Garbage-collect if GST_GC env var is set.
|
||||
This helps in debugging object refcounting.
|
||||
Sprinkle liberally around checkpoints.
|
||||
"""
|
||||
env = os.environ.get('GST_GC', None)
|
||||
if not env:
|
||||
return
|
||||
import gc
|
||||
if env == 'DEBUG_LEAK':
|
||||
gc.set_debug(gc.DEBUG_LEAK)
|
||||
|
||||
gst.debug('collecting garbage')
|
||||
if reason:
|
||||
gst.debug('because of %s' % reason)
|
||||
count = gc.collect()
|
||||
gst.debug('collected garbage, %d objects collected, %d left' % (
|
||||
count, len(gc.get_objects())))
|
|
@ -1,11 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_pad_set_iterate_internal_links_function
|
||||
gst_pad_iterate_internal_links
|
||||
gst_pad_iterate_internal_links_default
|
||||
gst_base_transform_suggest
|
||||
gst_base_transform_reconfigure
|
||||
%%
|
||||
ignore-type
|
||||
|
||||
%%
|
|
@ -1,18 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_bin_recalculate_latency
|
||||
gst_event_get_seqnum
|
||||
gst_event_set_seqnum
|
||||
gst_message_set_seqnum
|
||||
gst_message_new_structure_change
|
||||
gst_message_parse_structure_change
|
||||
gst_query_new_uri
|
||||
gst_query_parse_uri
|
||||
gst_query_set_uri
|
||||
gst_tag_setter_reset_tags
|
||||
gst_util_seqnum_next
|
||||
gst_util_seqnum_compare
|
||||
%%
|
||||
ignore-type
|
||||
GstStructureChangeType
|
||||
%%
|
|
@ -1,23 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_debug_construct_win_color
|
||||
gst_message_new_request_state
|
||||
gst_message_parse_request_state
|
||||
gst_util_array_binary_search
|
||||
gst_poll_new_timer
|
||||
gst_poll_write_control
|
||||
gst_poll_read_control
|
||||
gst_tag_list_get_buffer
|
||||
gst_tag_list_get_buffer_index
|
||||
gst_fixme
|
||||
gst_memdump
|
||||
gst_object_fixme
|
||||
gst_object_memdump
|
||||
gst_type_find_helper_for_extension
|
||||
GST_PARAM_MUTABLE_READY
|
||||
GST_PARAM_MUTABLE_PAUSED
|
||||
GST_PARAM_MUTABLE_PLAYING
|
||||
%%
|
||||
ignore-type
|
||||
GstSearchMode
|
||||
%%
|
|
@ -1,46 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_element_set_start_time
|
||||
gst_element_get_start_time
|
||||
gst_element_lost_state_full
|
||||
gst_event_new_step
|
||||
gst_event_parse_step
|
||||
gst_message_new_tag_full
|
||||
gst_message_parse_tag_full
|
||||
gst_message_new_step_done
|
||||
gst_message_parse_step_done
|
||||
gst_message_new_stream_status
|
||||
gst_message_parse_stream_status
|
||||
gst_message_set_stream_status_object
|
||||
gst_message_get_stream_status_object
|
||||
gst_message_new_step_start
|
||||
gst_message_parse_step_start
|
||||
gst_pad_set_chain_list_function
|
||||
gst_pad_push_list
|
||||
gst_pad_chain_list
|
||||
gst_plugin_get_cache_data
|
||||
gst_plugin_set_cache_data
|
||||
gst_segment_to_position
|
||||
gst_segment_set_running_time
|
||||
gst_structure_get_valist
|
||||
gst_structure_get
|
||||
gst_structure_id_get_valist
|
||||
gst_structure_id_get
|
||||
gst_tag_list_add_value
|
||||
gst_tag_setter_add_tag_value
|
||||
gst_task_set_priority
|
||||
gst_task_get_pool
|
||||
gst_task_set_pool
|
||||
gst_task_set_thread_callbacks
|
||||
gst_task_set_state
|
||||
gst_adapter_prev_timestamp
|
||||
gst_adapter_masked_scan_uint32
|
||||
%%
|
||||
ignore-type
|
||||
GstBufferList
|
||||
GstTaskPool
|
||||
GstBufferListItem
|
||||
GstStreamStatusType
|
||||
GstBufferList
|
||||
GstBufferListIterator
|
||||
%%
|
|
@ -1,4 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_caps_can_intersect
|
||||
%%
|
|
@ -1,20 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_caps_set_value
|
||||
gst_pad_get_caps_reffed
|
||||
gst_pad_peer_get_caps_reffed
|
||||
gst_util_greatest_common_divisor
|
||||
gst_util_fraction_to_double
|
||||
gst_util_double_to_fraction
|
||||
gst_util_fraction_multiply
|
||||
gst_util_fraction_add
|
||||
gst_event_new_sink_message
|
||||
gst_event_parse_sink_message
|
||||
gst_plugin_feature_list_copy
|
||||
gst_registry_get_feature_list_cookie
|
||||
gst_structure_id_has_field
|
||||
gst_structure_id_has_field_type
|
||||
gst_base_src_new_seamless_segment
|
||||
gst_collect_pads_set_clip_function
|
||||
gst_type_find_helper_get_range_ext
|
||||
%%
|
|
@ -1,9 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_message_new_qos
|
||||
gst_message_set_qos_values
|
||||
gst_message_set_qos_stats
|
||||
gst_message_parse_qos
|
||||
gst_message_parse_qos_values
|
||||
gst_message_parse_qos_stats
|
||||
%%
|
|
@ -1,14 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_caps_steal_structure
|
||||
gst_structure_fixate_field_boolean
|
||||
gst_tag_list_peek_string_index
|
||||
gst_pad_link_full
|
||||
gst_element_link_pads_full
|
||||
gst_adapter_masked_scan_uint32_peek
|
||||
gst_base_sink_set_last_buffer_enabled
|
||||
gst_base_sink_is_last_buffer_enabled
|
||||
%%
|
||||
ignore-type
|
||||
GstPadLinkCheck
|
||||
%%
|
|
@ -1,26 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_is_initialized
|
||||
gst_buffer_list_iterator_add_list
|
||||
gst_element_class_set_documentation_uri
|
||||
gst_element_class_set_icon_name
|
||||
gst_element_class_get_documentation_uri
|
||||
gst_element_class_get_icon_name
|
||||
gst_element_factory_list_is_type
|
||||
gst_element_factory_list_get_elements
|
||||
gst_element_factory_list_filter
|
||||
gst_element_factory_get_documentation_uri
|
||||
gst_element_factory_get_icon_name
|
||||
gst_plugin_Feature_rank_compare_func
|
||||
gst_query_add_buffering_range
|
||||
gst_query_get_n_buffering_ranges
|
||||
gst_query_parse_nth_buffering_range
|
||||
gst_util_fraction_compare
|
||||
gst_value_set_int64_range
|
||||
gst_value_get_int64_range_min
|
||||
gst_value_get_int64_range_max
|
||||
gst_adapter_take_list
|
||||
%%
|
||||
ignore-type
|
||||
GstDateTime
|
||||
%%
|
|
@ -1,8 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_clock_single_shot_id_reinit
|
||||
gst_read_gpollfd
|
||||
gst_value_list_merge
|
||||
gst_element_request_pad
|
||||
%%
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_preset_set_app_dir
|
||||
gst_preset_get_app_dir
|
||||
%%
|
|
@ -1,65 +0,0 @@
|
|||
/* gst-python
|
||||
* Copyright (C) 2004 Johan Dahlin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
|
||||
/* define this for all source files that don't run init_pygobject()
|
||||
* before including pygobject.h */
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
|
||||
#include "common.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
/* This function will return a copy, unless the following is all TRUE:
|
||||
* - The given PyObject contains a GstCaps already
|
||||
* - The copy parameter is non-NULL
|
||||
* - New years is the first of January
|
||||
* If copy is non-NULL, it is set to TRUE if a copy was made.
|
||||
* If the PyObject could not be converted to a caps, a TypeError is raised
|
||||
* and NULL is returned.
|
||||
*/
|
||||
GstCaps *
|
||||
pygst_caps_from_pyobject (PyObject * object, gboolean * copy)
|
||||
{
|
||||
if (pyg_boxed_check (object, GST_TYPE_CAPS)) {
|
||||
GstCaps *caps = pyg_boxed_get (object, GstCaps);
|
||||
if (copy) {
|
||||
*copy = FALSE;
|
||||
return caps;
|
||||
} else {
|
||||
return gst_caps_copy (caps);
|
||||
}
|
||||
} else if (pyg_boxed_check (object, GST_TYPE_STRUCTURE)) {
|
||||
GstStructure *structure = pyg_boxed_get (object, GstStructure);
|
||||
if (copy)
|
||||
*copy = TRUE;
|
||||
return gst_caps_new_full (gst_structure_copy (structure), NULL);
|
||||
} else if (PyString_Check (object)) {
|
||||
GstCaps *caps = gst_caps_from_string (PyString_AsString (object));
|
||||
if (!caps) {
|
||||
PyErr_SetString (PyExc_TypeError, "could not convert string to GstCaps");
|
||||
return NULL;
|
||||
}
|
||||
if (copy)
|
||||
*copy = TRUE;
|
||||
return caps;
|
||||
}
|
||||
PyErr_SetString (PyExc_TypeError, "could not convert to GstCaps");
|
||||
return NULL;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_element_save_thyself
|
||||
gst_element_restore_thyself
|
||||
gst_xml_get_topelements
|
||||
gst_xml_make_element
|
||||
gst_xml_new
|
||||
gst_xml_parse_memory
|
||||
gst_xml_write
|
||||
gst_xml_write_file
|
||||
%%
|
||||
ignore-type
|
||||
GstXML
|
||||
%%
|
|
@ -1,150 +0,0 @@
|
|||
; -*- scheme -*-
|
||||
|
||||
(define-method flags
|
||||
(of-object "GstElement")
|
||||
(c-name "GST_OBJECT_FLAGS")
|
||||
(return-type "GstElementFlags")
|
||||
)
|
||||
|
||||
(define-method set_flag
|
||||
(of-object "GstObject")
|
||||
(c-name "GST_OBJECT_FLAG_SET")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstObjectFlags" "flags")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method unset_flag
|
||||
(of-object "GstObject")
|
||||
(c-name "GST_OBJECT_FLAG_UNSET")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstObjectFlags" "flag")
|
||||
)
|
||||
)
|
||||
|
||||
;; DEBUGGING FUNCTIONS FROM PYTHON
|
||||
;; The c functions don't actually exist
|
||||
|
||||
(define-function log
|
||||
(c-name "gst_log")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function debug
|
||||
(c-name "gst_debug")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function info
|
||||
(c-name "gst_info")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function warning
|
||||
(c-name "gst_warning")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function error
|
||||
(c-name "gst_error")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function fixme
|
||||
(c-name "gst_fixme")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function memdump
|
||||
(c-name "gst_memdump")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
;; OBJECT DEBUGGING FUNCTIONS FROM PYTHON
|
||||
;; The c functions don't actually exist
|
||||
|
||||
(define-method log
|
||||
(of-object "GstObject")
|
||||
(c-name "gst_object_log")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method debug
|
||||
(of-object "GstObject")
|
||||
(c-name "gst_object_debug")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method info
|
||||
(of-object "GstObject")
|
||||
(c-name "gst_object_info")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method warning
|
||||
(of-object "GstObject")
|
||||
(c-name "gst_object_warning")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method error
|
||||
(of-object "GstObject")
|
||||
(c-name "gst_object_error")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method fixme
|
||||
(of-object "GstObject")
|
||||
(c-name "gst_object_fixme")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method memdump
|
||||
(of-object "GstObject")
|
||||
(c-name "gst_object_memdump")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar *" "msg")
|
||||
)
|
||||
)
|
|
@ -1,19 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_audio_clock_get_time
|
||||
gst_audio_clock_adjust
|
||||
gst_navigation_send_command
|
||||
gst_video_format_parse_caps_interlaced
|
||||
gst_video_format_new_caps_interlaced
|
||||
%%
|
||||
ignore-glob
|
||||
gst_navigation_query_*
|
||||
gst_navigation_message_*
|
||||
gst_navigation_event_*
|
||||
%%
|
||||
ignore-type
|
||||
GstNavigationCommand
|
||||
GstNavigationQueryType
|
||||
GstNavigationMessageType
|
||||
GstNavigationEventType
|
||||
%%
|
|
@ -1,9 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
%%
|
||||
ignore-glob
|
||||
gst_stream_volume_*
|
||||
%%
|
||||
ignore-type
|
||||
GstStreamVolumeFormat
|
||||
%%
|
|
@ -1,10 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_tag_get_language_code
|
||||
gst_tag_get_language_name
|
||||
gst_tag_get_language_code_iso_639_1
|
||||
gst_tag_get_language_code_iso_638_2B
|
||||
gst_tag_get_language_code_iso_638_2T
|
||||
gst_video_event_new_still_frame
|
||||
gst_video_event_parse_still_frame
|
||||
%%
|
|
@ -1,9 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_x_overlay_set_render_rectangle
|
||||
gst_tag_list_from_xmp_buffer
|
||||
gst_tag_list_to_xmp_buffer
|
||||
gst_video_format_is_gray
|
||||
gst_video_parse_caps_chroma_site
|
||||
gst_video_parse_caps_color_matrix
|
||||
%%
|
|
@ -1,7 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_tag_list_to_exif_buffer
|
||||
gst_tag_list_to_exif_buffer_with_tiff_header
|
||||
gst_tag_list_from_exif_buffer
|
||||
gst_tag_list_from_exif_buffer_with_tiff_header
|
||||
%%
|
|
@ -1,31 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_codec_utils_aac_get_sample_rate_from_index
|
||||
gst_codec_utils_aac_get_profile
|
||||
gst_codec_utils_aac_get_level
|
||||
gst_codec_utils_aac_caps_set_level_and_profile
|
||||
gst_codec_utils_h264_get_profile
|
||||
gst_codec_utils_h264_get_level
|
||||
gst_codec_utils_h264_caps_set_level_and_profile
|
||||
gst_codec_utils_mpeg4video_get_profile
|
||||
gst_codec_utils_mpeg4video_get_level
|
||||
gst_codec_utils_mpeg4video_caps_set_level_and_profile
|
||||
gst_plugins_base_version
|
||||
gst_plugins_base_version_string
|
||||
gst_audio_clock_invalidate
|
||||
gst_base_audio_sink_set_drift_tolerance
|
||||
gst_base_audio_sink_get_drift_tolerance
|
||||
gst_x_overlay_set_window_handle
|
||||
gst_x_overlay_got_window_handle
|
||||
gst_video_convert_frame
|
||||
gst_video_convert_frame_async
|
||||
%%
|
||||
ignore-type
|
||||
GstDiscoverer
|
||||
GstDiscovererResult
|
||||
GstDiscovererInfo
|
||||
GstDiscovererStreamInfo
|
||||
GstDiscovererContainerInfo
|
||||
GstDiscovererAudioInfo
|
||||
GstDiscovererVideoInfo
|
||||
%%
|
|
@ -1,50 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_encoding_profile_get_name
|
||||
gst_encoding_profile_get_description
|
||||
gst_encoding_profile_get_format
|
||||
gst_encoding_profile_get_preset
|
||||
gst_encoding_profile_get_presence
|
||||
gst_encoding_profile_get_restriction
|
||||
gst_encoding_profile_set_name
|
||||
gst_encoding_profile_set_description
|
||||
gst_encoding_profile_set_format
|
||||
gst_encoding_profile_set_preset
|
||||
gst_encoding_profile_set_presence
|
||||
gst_encoding_profile_set_restriction
|
||||
gst_encoding_profile_is_equal
|
||||
gst_encoding_profile_get_output_caps
|
||||
gst_encoding_profile_get_type_nick
|
||||
gst_encoding_profile_find
|
||||
gst_encoding_container_profile_add_profile
|
||||
gst_encoding_container_profile_contains_profile
|
||||
gst_encoding_container_profile_get_profiles
|
||||
gst_encoding_container_profile_new
|
||||
gst_encoding_audio_profile_new
|
||||
gst_encoding_video_profile_new
|
||||
gst_encoding_video_profile_get_pass
|
||||
gst_encoding_video_profile_set_pass
|
||||
gst_encoding_video_profile_get_variableframerate
|
||||
gst_encoding_video_profile_set_variableframerate
|
||||
gst_encoding_target_new
|
||||
gst_encoding_target_get_name
|
||||
gst_encoding_target_get_category
|
||||
gst_encoding_target_get_description
|
||||
gst_encoding_target_get_profiles
|
||||
gst_encoding_target_add_profile
|
||||
gst_encoding_target_save
|
||||
gst_encoding_target_save_to_file
|
||||
gst_encoding_target_load
|
||||
gst_encoding_target_load_from_file
|
||||
gst_encoding_list_available_categories
|
||||
gst_encoding_list_all_targets
|
||||
gst_discoverer_info_get_seekable
|
||||
gst_video_parse_caps_palette
|
||||
%%
|
||||
ignore-type
|
||||
GstEncodingProfile
|
||||
GstEncodingContainerProfile
|
||||
GstEncodingAudioProfile
|
||||
GstEncodingVideoProfile
|
||||
GstEncodingTarget
|
||||
%%
|
|
@ -1,8 +0,0 @@
|
|||
%%
|
||||
ignore
|
||||
gst_video_event_new_downstream_force_key_unit
|
||||
gst_video_event_parse_downstream_force_key_unit
|
||||
gst_video_event_new_upstream_force_key_unit
|
||||
gst_video_event_parse_upstream_force_key_unit
|
||||
gst_video_event_is_force_key_unit
|
||||
%%
|
1240
gst/gst-types.defs
1240
gst/gst-types.defs
File diff suppressed because it is too large
Load diff
9504
gst/gst.defs
9504
gst/gst.defs
File diff suppressed because it is too large
Load diff
1748
gst/gst.override
1748
gst/gst.override
File diff suppressed because it is too large
Load diff
|
@ -1,905 +0,0 @@
|
|||
/* -*- Mode: C; ; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2006 Edward Hervey
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
|
||||
%%
|
||||
override GstBaseSrc__proxy_do_create
|
||||
static GstFlowReturn
|
||||
_wrap_GstBaseSrc__proxy_do_create (GstBaseSrc * self,
|
||||
guint64 offset,
|
||||
guint size,
|
||||
GstBuffer ** buf)
|
||||
{
|
||||
PyGILState_STATE __py_state;
|
||||
PyObject *py_self;
|
||||
GstFlowReturn retval = GST_FLOW_ERROR;
|
||||
PyObject *py_ret;
|
||||
PyObject *py_flow;
|
||||
PyObject *py_buffer;
|
||||
PyObject *py_args;
|
||||
PyObject *py_method;
|
||||
|
||||
__py_state = pyg_gil_state_ensure();
|
||||
py_self = pygobject_new((GObject *) self);
|
||||
if (!py_self) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_args = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(py_args, 0, PyLong_FromUnsignedLongLong(offset));
|
||||
PyTuple_SET_ITEM(py_args, 1, PyInt_FromLong(size));
|
||||
|
||||
py_method = PyObject_GetAttrString(py_self, "do_create");
|
||||
|
||||
if (!py_method) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_ret = PyObject_CallObject(py_method, py_args);
|
||||
if (!py_ret) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
/* process the python return value */
|
||||
/* Should be a list containing the gst.FlowReturn and the gst.Buffer */
|
||||
if (PyTuple_Check(py_ret)) {
|
||||
/* gst.FlowReturn */
|
||||
py_flow = PyTuple_GetItem(py_ret, 0);
|
||||
|
||||
if (!py_flow) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_ret);
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
if (py_flow == Py_None) {
|
||||
GST_ERROR ("None return flow is not valid");
|
||||
goto beach;
|
||||
}
|
||||
|
||||
GST_DEBUG ("py_flow:%p", py_flow);
|
||||
|
||||
if (pyg_enum_get_value(GST_TYPE_FLOW_RETURN, py_flow, (gint*) &retval)) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_ret);
|
||||
Py_DECREF(py_flow);
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
retval = GST_FLOW_ERROR;
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_buffer = PyTuple_GetItem(py_ret, 1);
|
||||
if (!py_buffer) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_ret);
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
if (pygstminiobject_check(py_buffer, &PyGstBuffer_Type)) {
|
||||
*buf = GST_BUFFER (pygstminiobject_get (py_buffer));
|
||||
gst_buffer_ref (*buf);
|
||||
} else {
|
||||
*buf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Py_DECREF(py_ret);
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
|
||||
beach:
|
||||
pyg_gil_state_release(__py_state);
|
||||
|
||||
return retval;
|
||||
}
|
||||
%%
|
||||
override GstBaseSrc__do_create kwargs
|
||||
static PyObject *
|
||||
_wrap_GstBaseSrc__do_create (PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
gpointer klass;
|
||||
static char *kwlist[] = { "self", "offset", "size", NULL };
|
||||
PyGObject *self;
|
||||
guint64 offset;
|
||||
guint size;
|
||||
PyObject *py_ret;
|
||||
GstFlowReturn flow;
|
||||
GstBuffer *buffer = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!KI:GstBaseSrc.create",
|
||||
kwlist, &PyGstBaseSrc_Type, &self, &offset, &size))
|
||||
return NULL;
|
||||
|
||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
||||
if (GST_BASE_SRC_CLASS(klass)->create) {
|
||||
pyg_begin_allow_threads;
|
||||
flow = GST_BASE_SRC_CLASS(klass)->create(GST_BASE_SRC(self->obj), offset, size, &buffer);
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseSrc.set_caps not implemented");
|
||||
g_type_class_unref(klass);
|
||||
return NULL;
|
||||
}
|
||||
g_type_class_unref(klass);
|
||||
|
||||
/* We now need to return a tuple with (flow, buffer) */
|
||||
if (buffer)
|
||||
py_ret = PyTuple_New(2);
|
||||
else
|
||||
py_ret = PyTuple_New(1);
|
||||
|
||||
PyTuple_SET_ITEM(py_ret, 0, pyg_enum_from_gtype(GST_TYPE_FLOW_RETURN, flow));
|
||||
|
||||
if (buffer)
|
||||
PyTuple_SET_ITEM(py_ret, 1, pygstminiobject_new(GST_MINI_OBJECT (buffer)));
|
||||
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override GstBaseSrc__proxy_do_get_size
|
||||
static gboolean
|
||||
_wrap_GstBaseSrc__proxy_do_get_size (GstBaseSrc * self,
|
||||
guint64 * size)
|
||||
{
|
||||
PyGILState_STATE __py_state;
|
||||
PyObject *py_self;
|
||||
gboolean ret = FALSE;
|
||||
PyObject *py_method;
|
||||
PyObject *py_ret;
|
||||
|
||||
__py_state = pyg_gil_state_ensure();
|
||||
py_self = pygobject_new((GObject *) self);
|
||||
if (!py_self) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_method = PyObject_GetAttrString(py_self, "do_get_size");
|
||||
|
||||
if (!py_method) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_self);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_ret = PyObject_CallObject(py_method, NULL);
|
||||
if (!py_ret) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_self);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
/*
|
||||
If the method returned a numeric, the return value will be TRUE.
|
||||
For ANY other case, we don't set size and the return value is FALSE.
|
||||
*/
|
||||
|
||||
if (PyLong_Check(py_ret)) {
|
||||
*size = PyLong_AsUnsignedLongLongMask(py_ret);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_self);
|
||||
Py_DECREF(py_ret);
|
||||
|
||||
beach:
|
||||
pyg_gil_state_release(__py_state);
|
||||
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override GstBaseSrc__do_get_size kwargs
|
||||
static PyObject *
|
||||
_wrap_GstBaseSrc__do_get_size (PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
gpointer klass;
|
||||
static char *kwlist[] = { "self", NULL };
|
||||
PyGObject *self;
|
||||
gboolean ret;
|
||||
guint64 size = 0;
|
||||
PyObject *py_ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GstBaseSrc.get_size",
|
||||
kwlist, &PyGstBaseSrc_Type, &self))
|
||||
return NULL;
|
||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
||||
if (GST_BASE_SRC_CLASS(klass)->get_size) {
|
||||
pyg_begin_allow_threads;
|
||||
ret = GST_BASE_SRC_CLASS(klass)->get_size(GST_BASE_SRC(self->obj), &size);
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseSrc.get_size not implemented");
|
||||
g_type_class_unref(klass);
|
||||
return NULL;
|
||||
}
|
||||
g_type_class_unref(klass);
|
||||
|
||||
py_ret = PyLong_FromUnsignedLongLong(size);
|
||||
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override GstBaseSrc__proxy_do_get_times
|
||||
static void
|
||||
_wrap_GstBaseSrc__proxy_do_get_times (GstBaseSrc * self,
|
||||
GstBuffer *buffer,
|
||||
GstClockTime * start,
|
||||
GstClockTime * end)
|
||||
{
|
||||
PyGILState_STATE __py_state;
|
||||
PyObject *py_args;
|
||||
PyObject *py_self;
|
||||
PyObject *py_method;
|
||||
PyObject *py_ret;
|
||||
|
||||
__py_state = pyg_gil_state_ensure();
|
||||
|
||||
py_self = pygobject_new((GObject *) self);
|
||||
if (!py_self) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
return;
|
||||
}
|
||||
|
||||
py_args = Py_BuildValue ("(N)",
|
||||
pygstminiobject_new((GstMiniObject *)buffer));
|
||||
|
||||
py_method = PyObject_GetAttrString(py_self, "do_get_times");
|
||||
|
||||
Py_DECREF(py_self);
|
||||
|
||||
if (!py_method) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_ret = PyObject_CallObject(py_method, py_args);
|
||||
|
||||
Py_DECREF(py_method);
|
||||
|
||||
if (!py_ret) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
/*
|
||||
If the method returned a numeric, the return value will be TRUE.
|
||||
For ANY other case, we don't set size and the return value is FALSE.
|
||||
*/
|
||||
|
||||
if ((PyTuple_Check(py_ret)) && (PyTuple_Size (py_ret) == 2))
|
||||
PyArg_ParseTuple (py_ret, "KK", start, end);
|
||||
|
||||
Py_DECREF (py_ret);
|
||||
beach:
|
||||
Py_DECREF (py_args);
|
||||
pyg_gil_state_release(__py_state);
|
||||
return;
|
||||
}
|
||||
%%
|
||||
override GstBaseSrc__do_get_times kwargs
|
||||
static PyObject *
|
||||
_wrap_GstBaseSrc__do_get_times (PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
gpointer klass;
|
||||
static char *kwlist[] = { "self", "buffer", NULL };
|
||||
PyGObject *self;
|
||||
PyGstMiniObject *py_buffer;
|
||||
GstClockTime start = 0;
|
||||
GstClockTime end = 0;
|
||||
PyObject *py_ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GstBaseSrc.get_times",
|
||||
kwlist, &PyGstBaseSrc_Type, &self,
|
||||
&PyGstBuffer_Type, &py_buffer))
|
||||
return NULL;
|
||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
||||
if (GST_BASE_SRC_CLASS(klass)->get_times) {
|
||||
pyg_begin_allow_threads;
|
||||
GST_BASE_SRC_CLASS(klass)->get_times(GST_BASE_SRC(self->obj),
|
||||
GST_BUFFER(py_buffer->obj),
|
||||
&start, &end);
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseSrc.get_times not implemented");
|
||||
g_type_class_unref(klass);
|
||||
return NULL;
|
||||
}
|
||||
g_type_class_unref(klass);
|
||||
|
||||
py_ret = PyTuple_New(2);
|
||||
PyTuple_SetItem(py_ret, 0, PyLong_FromUnsignedLongLong(start));
|
||||
PyTuple_SetItem(py_ret, 1, PyLong_FromUnsignedLongLong(end));
|
||||
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override GstPushSrc__proxy_do_create
|
||||
static GstFlowReturn
|
||||
_wrap_GstPushSrc__proxy_do_create (GstPushSrc * self,
|
||||
GstBuffer **buffer)
|
||||
{
|
||||
PyGILState_STATE __py_state;
|
||||
PyObject *py_self;
|
||||
PyObject *py_method;
|
||||
PyObject *py_ret;
|
||||
PyGstMiniObject *py_buffer;
|
||||
PyObject *py_flow;
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
__py_state = pyg_gil_state_ensure();
|
||||
|
||||
py_self = pygobject_new((GObject *) self);
|
||||
if (!py_self) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_method = PyObject_GetAttrString(py_self, "do_create");
|
||||
|
||||
Py_DECREF(py_self);
|
||||
|
||||
if (!py_method) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_ret = PyObject_CallObject(py_method, NULL);
|
||||
|
||||
Py_DECREF(py_method);
|
||||
|
||||
if (!py_ret) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
/*
|
||||
If the method returned a numeric, the return value will be TRUE.
|
||||
For ANY other case, we don't set size and the return value is FALSE.
|
||||
*/
|
||||
|
||||
if ((PyTuple_Check(py_ret)) && (PyTuple_Size (py_ret) == 2)) {
|
||||
PyArg_ParseTuple (py_ret, "O!O!", &PyGEnum_Type, &py_flow,
|
||||
&PyGstBuffer_Type, &py_buffer);
|
||||
*buffer = GST_BUFFER (((PyGstMiniObject*) self)->obj);
|
||||
gst_buffer_ref (*buffer);
|
||||
pyg_enum_get_value(GST_TYPE_FLOW_RETURN, py_flow, (gint*)&ret);
|
||||
}
|
||||
|
||||
Py_DECREF (py_ret);
|
||||
beach:
|
||||
pyg_gil_state_release(__py_state);
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override GstPushSrc__do_create kwargs
|
||||
static PyObject *
|
||||
_wrap_GstPushSrc__do_create (PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
gpointer klass;
|
||||
static char *kwlist[] = { "self", NULL };
|
||||
PyGObject *self;
|
||||
GstBuffer *buffer;
|
||||
GstFlowReturn flow;
|
||||
PyObject *py_ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GstPushSrc.create",
|
||||
kwlist, &PyGstPushSrc_Type, &self))
|
||||
return NULL;
|
||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
||||
if (GST_PUSH_SRC_CLASS(klass)->create) {
|
||||
pyg_begin_allow_threads;
|
||||
flow = GST_PUSH_SRC_CLASS(klass)->create(GST_PUSH_SRC(self->obj),
|
||||
(GstBuffer**) &buffer);
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstPushSrc.create not implemented");
|
||||
g_type_class_unref(klass);
|
||||
return NULL;
|
||||
}
|
||||
g_type_class_unref(klass);
|
||||
|
||||
py_ret = PyTuple_New(2);
|
||||
PyList_SetItem(py_ret, 0, pyg_enum_from_gtype(GST_TYPE_FLOW_RETURN, flow));
|
||||
PyList_SetItem(py_ret, 1, pygstminiobject_new(GST_MINI_OBJECT(buffer)));
|
||||
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override GstBaseTransform__proxy_do_get_unit_size
|
||||
static gboolean
|
||||
_wrap_GstBaseTransform__proxy_do_get_unit_size (GstBaseTransform * self,
|
||||
GstCaps * caps,
|
||||
guint * size)
|
||||
{
|
||||
PyGILState_STATE __py_state;
|
||||
PyObject *py_self;
|
||||
PyObject *py_caps;
|
||||
gboolean ret = FALSE;
|
||||
PyObject *py_args;
|
||||
PyObject *py_method;
|
||||
PyObject *py_ret;
|
||||
|
||||
__py_state = pyg_gil_state_ensure();
|
||||
py_self = pygobject_new((GObject *) self);
|
||||
if (!py_self) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
if (caps)
|
||||
py_caps = pyg_boxed_new(GST_TYPE_CAPS, caps, FALSE, FALSE); // should copyval be TRUE instead?
|
||||
else {
|
||||
Py_INCREF (Py_None);
|
||||
py_caps = Py_None;
|
||||
}
|
||||
|
||||
py_args = PyTuple_New(1);
|
||||
PyTuple_SET_ITEM(py_args, 0, py_caps);
|
||||
|
||||
py_method = PyObject_GetAttrString(py_self, "do_get_unit_size");
|
||||
|
||||
if (!py_method) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_ret = PyObject_CallObject(py_method, py_args);
|
||||
if (!py_ret) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
goto beach;
|
||||
}
|
||||
|
||||
/*
|
||||
If the method returned a numeric, the return value will be TRUE.
|
||||
For ANY other case, we don't set size and the return value is FALSE.
|
||||
*/
|
||||
|
||||
if (PyInt_Check(py_ret)) {
|
||||
*size = PyInt_AsLong(py_ret);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
Py_DECREF(py_ret);
|
||||
|
||||
beach:
|
||||
pyg_gil_state_release(__py_state);
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override GstBaseTransform__do_get_unit_size kwargs
|
||||
static PyObject *
|
||||
_wrap_GstBaseTransform__do_get_unit_size (PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
gpointer klass;
|
||||
static char *kwlist[] = { "self", "caps", NULL };
|
||||
PyGObject *self;
|
||||
PyGObject *caps;
|
||||
gboolean ret;
|
||||
guint size = 0;
|
||||
PyObject *py_ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GstBaseTransform.get_unit_size",
|
||||
kwlist, &PyGstBaseTransform_Type, &self, &PyGstCaps_Type, &caps))
|
||||
return NULL;
|
||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
||||
if (GST_BASE_TRANSFORM_CLASS(klass)->get_unit_size) {
|
||||
pyg_begin_allow_threads;
|
||||
ret = GST_BASE_TRANSFORM_CLASS(klass)->get_unit_size(GST_BASE_TRANSFORM(self->obj), GST_CAPS(caps->obj), &size);
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseTransform.get_unit_size not implemented");
|
||||
g_type_class_unref(klass);
|
||||
return NULL;
|
||||
}
|
||||
g_type_class_unref(klass);
|
||||
|
||||
py_ret = PyLong_FromUnsignedLongLong(size);
|
||||
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override GstBaseTransform__proxy_do_transform_size
|
||||
static gboolean
|
||||
_wrap_GstBaseTransform__proxy_do_transform_size (GstBaseTransform * self,
|
||||
GstPadDirection direction,
|
||||
GstCaps * caps,
|
||||
guint size,
|
||||
GstCaps * othercaps,
|
||||
guint * othersize)
|
||||
{
|
||||
PyGILState_STATE __py_state;
|
||||
PyObject *py_self = NULL;
|
||||
PyObject *py_direction = NULL;
|
||||
PyObject *py_caps = NULL;
|
||||
PyObject *py_size = NULL;
|
||||
PyObject *py_othercaps = NULL;
|
||||
PyObject *py_args = NULL;
|
||||
PyObject *py_method = NULL;
|
||||
PyObject *py_ret = NULL;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
__py_state = pyg_gil_state_ensure();
|
||||
py_self = pygobject_new((GObject *) self);
|
||||
if (!py_self) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_direction = pyg_enum_from_gtype(GST_TYPE_PAD_DIRECTION, direction);
|
||||
|
||||
if (caps)
|
||||
py_caps = pyg_boxed_new(GST_TYPE_CAPS, caps, FALSE, FALSE); // should copyval be TRUE instead?
|
||||
else {
|
||||
Py_INCREF (Py_None);
|
||||
py_caps = Py_None;
|
||||
}
|
||||
|
||||
py_size = PyInt_FromLong(size);
|
||||
|
||||
if (othercaps)
|
||||
py_othercaps = pyg_boxed_new(GST_TYPE_CAPS, caps, FALSE, FALSE); // should copyval be TRUE instead?
|
||||
else {
|
||||
Py_INCREF (Py_None);
|
||||
py_othercaps = Py_None;
|
||||
}
|
||||
|
||||
py_args = PyTuple_New(4);
|
||||
PyTuple_SET_ITEM(py_args, 0, py_direction);
|
||||
PyTuple_SET_ITEM(py_args, 1, py_caps);
|
||||
PyTuple_SET_ITEM(py_args, 2, py_size);
|
||||
PyTuple_SET_ITEM(py_args, 3, py_othercaps);
|
||||
|
||||
py_method = PyObject_GetAttrString(py_self, "do_transform_size");
|
||||
if (!py_method) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_ret = PyObject_CallObject(py_method, py_args);
|
||||
if (!py_ret) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
if (PyInt_Check(py_ret)) {
|
||||
*othersize = PyInt_AsLong(py_ret);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
beach:
|
||||
Py_XDECREF(py_self);
|
||||
Py_XDECREF(py_args);
|
||||
Py_XDECREF(py_method);
|
||||
Py_XDECREF(py_ret);
|
||||
|
||||
pyg_gil_state_release(__py_state);
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override GstBaseTransform__do_transform_size kwargs
|
||||
static PyObject *
|
||||
_wrap_GstBaseTransform__do_transform_size (PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
gpointer klass;
|
||||
static char *kwlist[] = { "self", "direction", "caps", "size", "othercaps", NULL };
|
||||
PyGObject *self;
|
||||
PyGObject *py_direction;
|
||||
PyGObject *py_caps;
|
||||
PyGObject *py_othercaps;
|
||||
gboolean ret;
|
||||
GstPadDirection direction;
|
||||
guint size = 0;
|
||||
guint othersize = 0;
|
||||
PyObject *py_ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!iO!:GstBaseTransform.get_unit_size",
|
||||
kwlist, &PyGstBaseTransform_Type, &self, &PyGEnum_Type, &py_direction,
|
||||
&PyGstCaps_Type, &py_caps, &size, &PyGstCaps_Type, &py_othercaps))
|
||||
return NULL;
|
||||
|
||||
pyg_enum_get_value(GST_TYPE_PAD_DIRECTION,
|
||||
(PyObject *) py_direction, (gint *) &direction);
|
||||
|
||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
||||
if (GST_BASE_TRANSFORM_CLASS(klass)->transform_size) {
|
||||
pyg_begin_allow_threads;
|
||||
ret = GST_BASE_TRANSFORM_CLASS(klass)->transform_size(GST_BASE_TRANSFORM(self->obj),
|
||||
direction, GST_CAPS(py_caps->obj), size,
|
||||
GST_CAPS(py_othercaps->obj), &othersize);
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseTransform.transform_size not implemented");
|
||||
g_type_class_unref(klass);
|
||||
return NULL;
|
||||
}
|
||||
g_type_class_unref(klass);
|
||||
|
||||
py_ret = PyLong_FromUnsignedLongLong(othersize);
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override GstBaseSink__proxy_do_get_times
|
||||
static void
|
||||
_wrap_GstBaseSink__proxy_do_get_times (GstBaseSink * self,
|
||||
GstBuffer *buffer,
|
||||
GstClockTime * start,
|
||||
GstClockTime * end)
|
||||
{
|
||||
PyGILState_STATE __py_state;
|
||||
PyObject *py_args;
|
||||
PyObject *py_self;
|
||||
PyObject *py_method;
|
||||
PyObject *py_ret;
|
||||
|
||||
__py_state = pyg_gil_state_ensure();
|
||||
|
||||
py_self = pygobject_new((GObject *) self);
|
||||
if (!py_self) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
pyg_gil_state_release(__py_state);
|
||||
return;
|
||||
}
|
||||
|
||||
py_args = Py_BuildValue ("(N)",
|
||||
pygstminiobject_new((GstMiniObject *)buffer));
|
||||
|
||||
py_method = PyObject_GetAttrString(py_self, "do_get_times");
|
||||
|
||||
Py_DECREF(py_self);
|
||||
|
||||
if (!py_method) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
py_ret = PyObject_CallObject(py_method, py_args);
|
||||
|
||||
Py_DECREF(py_method);
|
||||
|
||||
if (!py_ret) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
goto beach;
|
||||
}
|
||||
|
||||
/*
|
||||
If the method returned a numeric, the return value will be TRUE.
|
||||
For ANY other case, we don't set size and the return value is FALSE.
|
||||
*/
|
||||
|
||||
if ((PyTuple_Check(py_ret)) && (PyTuple_Size (py_ret) == 2))
|
||||
PyArg_ParseTuple (py_ret, "KK", start, end);
|
||||
|
||||
Py_DECREF (py_ret);
|
||||
beach:
|
||||
Py_DECREF (py_args);
|
||||
pyg_gil_state_release(__py_state);
|
||||
return;
|
||||
}
|
||||
%%
|
||||
override GstBaseSink__do_get_times kwargs
|
||||
static PyObject *
|
||||
_wrap_GstBaseSink__do_get_times (PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
gpointer klass;
|
||||
static char *kwlist[] = { "self", "buffer", NULL };
|
||||
PyGObject *self;
|
||||
PyGstMiniObject *py_buffer;
|
||||
GstClockTime start = 0;
|
||||
GstClockTime end = 0;
|
||||
PyObject *py_ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GstBaseSink.get_times",
|
||||
kwlist, &PyGstBaseSink_Type, &self,
|
||||
&PyGstBuffer_Type, &py_buffer))
|
||||
return NULL;
|
||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
||||
if (GST_BASE_SINK_CLASS(klass)->get_times) {
|
||||
pyg_begin_allow_threads;
|
||||
GST_BASE_SINK_CLASS(klass)->get_times(GST_BASE_SINK(self->obj),
|
||||
GST_BUFFER(py_buffer->obj),
|
||||
&start, &end);
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseSink.get_times not implemented");
|
||||
g_type_class_unref(klass);
|
||||
return NULL;
|
||||
}
|
||||
g_type_class_unref(klass);
|
||||
|
||||
py_ret = PyTuple_New(2);
|
||||
PyTuple_SetItem(py_ret, 0, PyLong_FromUnsignedLongLong(start));
|
||||
PyTuple_SetItem(py_ret, 1, PyLong_FromUnsignedLongLong(end));
|
||||
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override gst_base_sink_query_latency noargs
|
||||
static PyObject *
|
||||
_wrap_gst_base_sink_query_latency (PyGObject *self)
|
||||
{
|
||||
gboolean res, live = FALSE, upstream_live = FALSE;
|
||||
GstClockTime minlat = GST_CLOCK_TIME_NONE, maxlat = GST_CLOCK_TIME_NONE;
|
||||
|
||||
res = gst_base_sink_query_latency (GST_BASE_SINK (self->obj), &live, &upstream_live,
|
||||
&minlat, &maxlat);
|
||||
return Py_BuildValue("(OOOKK)",
|
||||
PyBool_FromLong(res),
|
||||
PyBool_FromLong(live),
|
||||
PyBool_FromLong(upstream_live),
|
||||
minlat, maxlat);
|
||||
}
|
||||
%%
|
||||
override gst_base_src_query_latency noargs
|
||||
static PyObject *
|
||||
_wrap_gst_base_src_query_latency (PyGObject *self)
|
||||
{
|
||||
gboolean res, live = FALSE;
|
||||
GstClockTime minlat = GST_CLOCK_TIME_NONE, maxlat = GST_CLOCK_TIME_NONE;
|
||||
|
||||
res = gst_base_src_query_latency (GST_BASE_SRC (self->obj), &live,
|
||||
&minlat, &maxlat);
|
||||
return Py_BuildValue("(OOKK)",
|
||||
PyBool_FromLong(res),
|
||||
PyBool_FromLong(live),
|
||||
minlat, maxlat);
|
||||
}
|
||||
%%
|
||||
override GstBaseTransform__do_src_event kwargs
|
||||
static PyObject *
|
||||
_wrap_GstBaseTransform__do_src_event(PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
gpointer klass;
|
||||
static char *kwlist[] = { "self", "event", NULL };
|
||||
PyGObject *self;
|
||||
int ret;
|
||||
PyGstMiniObject *event;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!O!:GstBaseTransform.src_event", kwlist, &PyGstBaseTransform_Type, &self, &PyGstEvent_Type, &event))
|
||||
return NULL;
|
||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
||||
if (GST_BASE_TRANSFORM_CLASS(klass)->src_event) {
|
||||
pyg_begin_allow_threads;
|
||||
ret = GST_BASE_TRANSFORM_CLASS(klass)->src_event(GST_BASE_TRANSFORM(self->obj),
|
||||
gst_event_ref (GST_EVENT(event->obj)));
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBaseTransform.src_event not implemented");
|
||||
g_type_class_unref(klass);
|
||||
return NULL;
|
||||
}
|
||||
g_type_class_unref(klass);
|
||||
return PyBool_FromLong(ret);
|
||||
|
||||
}
|
||||
%%
|
||||
override gst_adapter_take kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_adapter_take(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "nbytes", NULL };
|
||||
PyObject *py_nbytes = NULL;
|
||||
guint nbytes = 0;
|
||||
guint8 *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:GstAdapter.take", kwlist, &py_nbytes))
|
||||
return NULL;
|
||||
if (py_nbytes) {
|
||||
if (PyLong_Check(py_nbytes))
|
||||
nbytes = PyLong_AsUnsignedLong(py_nbytes);
|
||||
else if (PyInt_Check(py_nbytes))
|
||||
nbytes = PyInt_AsLong(py_nbytes);
|
||||
else
|
||||
PyErr_SetString(PyExc_TypeError, "Parameter 'nbytes' must be an int or a long");
|
||||
if (PyErr_Occurred())
|
||||
return NULL;
|
||||
}
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_adapter_take(GST_ADAPTER(self->obj), nbytes);
|
||||
pyg_end_allow_threads;
|
||||
if (ret) {
|
||||
PyObject *py_ret = PyString_FromStringAndSize((gchar*) ret, nbytes);
|
||||
g_free(ret);
|
||||
return py_ret;
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_adapter_peek kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_adapter_peek(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "size", NULL };
|
||||
PyObject *py_size = NULL;
|
||||
const guint8 *ret;
|
||||
guint size = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:GstAdapter.peek", kwlist, &py_size))
|
||||
return NULL;
|
||||
if (py_size) {
|
||||
if (PyLong_Check(py_size))
|
||||
size = PyLong_AsUnsignedLong(py_size);
|
||||
else if (PyInt_Check(py_size))
|
||||
size = PyInt_AsLong(py_size);
|
||||
else
|
||||
PyErr_SetString(PyExc_TypeError, "Parameter 'size' must be an int or a long");
|
||||
if (PyErr_Occurred())
|
||||
return NULL;
|
||||
}
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_adapter_peek(GST_ADAPTER(self->obj), size);
|
||||
pyg_end_allow_threads;
|
||||
if (ret)
|
||||
return PyString_FromStringAndSize((gchar*) ret, size);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
|
@ -1,265 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2004 Johan Dahlin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
|
||||
%%
|
||||
ignore
|
||||
gst_bin_get_by_name_recurse_up
|
||||
%%
|
||||
override gst_bin_add args
|
||||
static PyObject *
|
||||
_wrap_gst_bin_add(PyGObject *self, PyObject *args)
|
||||
{
|
||||
PyGObject *element;
|
||||
int i, len;
|
||||
|
||||
len = PyTuple_Size(args);
|
||||
if (len == 0) {
|
||||
PyErr_SetString(PyExc_TypeError, "GstBin.add_many requires at least one argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
element = (PyGObject*)PyTuple_GetItem(args, i);
|
||||
if (!pygobject_check(element, &PyGstElement_Type))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "argument must be a GstElement");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
gboolean rest;
|
||||
|
||||
element = (PyGObject*)PyTuple_GetItem(args, i);
|
||||
pyg_begin_allow_threads;
|
||||
rest = gst_bin_add(GST_BIN(self->obj), GST_ELEMENT(element->obj));
|
||||
pyg_end_allow_threads;
|
||||
if (!rest) {
|
||||
PyErr_Format(PyGstExc_AddError, "Could not add element '%s'", GST_OBJECT_NAME(element->obj));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_bin_add_many kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_bin_add_many(PyGObject *self, PyObject *args)
|
||||
{
|
||||
if (PyErr_Warn(PyExc_DeprecationWarning, "gst.Bin.add_many() is deprecated, use gst.Bin.add()") < 0)
|
||||
return NULL;
|
||||
return _wrap_gst_bin_add (self, args);
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_bin_remove args
|
||||
static PyObject *
|
||||
_wrap_gst_bin_remove(PyGObject *self, PyObject *args)
|
||||
{
|
||||
PyGObject *element;
|
||||
int i, len;
|
||||
|
||||
len = PyTuple_Size(args);
|
||||
if (len == 0) {
|
||||
PyErr_SetString(PyExc_TypeError, "GstBin.remove_many requires at least one argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
element = (PyGObject*)PyTuple_GetItem(args, i);
|
||||
if (!pygobject_check(element, &PyGstElement_Type))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "argument must be a GstElement");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
gboolean rest;
|
||||
element = (PyGObject*)PyTuple_GetItem(args, i);
|
||||
pyg_begin_allow_threads;
|
||||
rest = gst_bin_remove(GST_BIN(self->obj), GST_ELEMENT(element->obj));
|
||||
pyg_end_allow_threads;
|
||||
if (!rest) {
|
||||
PyErr_Format(PyGstExc_RemoveError, "Could not remove element '%s'", GST_OBJECT_NAME(element->obj));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_bin_remove_many kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_bin_remove_many(PyGObject *self, PyObject *args)
|
||||
{
|
||||
if (PyErr_Warn(PyExc_DeprecationWarning, "gst.Bin.remove_many() is deprecated, use gst.Bin.remove()") < 0)
|
||||
return NULL;
|
||||
return _wrap_gst_bin_remove (self, args);
|
||||
}
|
||||
%%
|
||||
override gst_bin_get_by_name kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_bin_get_by_name(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "name", "recurse", NULL };
|
||||
char *name;
|
||||
gboolean recurse = FALSE;
|
||||
GstElement *el;
|
||||
PyObject *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|b:GstBin.get_by_name",
|
||||
kwlist, &name, &recurse))
|
||||
return NULL;
|
||||
|
||||
if (recurse)
|
||||
el = gst_bin_get_by_name_recurse_up(GST_BIN(self->obj), name);
|
||||
else
|
||||
el = gst_bin_get_by_name(GST_BIN(self->obj), name);
|
||||
|
||||
/* pygobject_new handles NULL checking */
|
||||
ret = pygobject_new((GObject *)el);
|
||||
if (el)
|
||||
gst_object_unref (el); /* from get_by_name */
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override-slot GstBin.tp_iter
|
||||
static PyObject *
|
||||
_wrap_gst_bin_tp_iter(PyGObject *self)
|
||||
{
|
||||
return _wrap_gst_bin_iterate_elements(self);
|
||||
}
|
||||
%%
|
||||
override GstBin__do_handle_message kwargs
|
||||
static PyObject *
|
||||
_wrap_GstBin__do_handle_message(PyObject *cls, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
gpointer klass;
|
||||
static char *kwlist[] = { "self", "message", NULL };
|
||||
PyGObject *self;
|
||||
PyGstMiniObject *message;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!O!:GstBin.handle_message", kwlist, &PyGstBin_Type, &self, &PyGstMessage_Type, &message))
|
||||
return NULL;
|
||||
klass = g_type_class_ref(pyg_type_from_object(cls));
|
||||
if (GST_BIN_CLASS(klass)->handle_message) {
|
||||
gst_mini_object_ref (message->obj);
|
||||
pyg_begin_allow_threads;
|
||||
GST_BIN_CLASS(klass)->handle_message(GST_BIN(self->obj), GST_MESSAGE(message->obj));
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_NotImplementedError, "virtual method GstBin.handle_message not implemented");
|
||||
g_type_class_unref(klass);
|
||||
return NULL;
|
||||
}
|
||||
g_type_class_unref(klass);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
%%
|
||||
override GstBin__proxy_do_handle_message
|
||||
static void
|
||||
_wrap_GstBin__proxy_do_handle_message(GstBin *self, GstMessage*message)
|
||||
{
|
||||
PyGILState_STATE __py_state;
|
||||
PyObject *py_self;
|
||||
PyObject *py_message = NULL;
|
||||
PyObject *py_retval;
|
||||
PyObject *py_args;
|
||||
PyObject *py_method;
|
||||
|
||||
__py_state = pyg_gil_state_ensure();
|
||||
py_self = pygobject_new((GObject *) self);
|
||||
if (!py_self) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
pyg_gil_state_release(__py_state);
|
||||
return;
|
||||
}
|
||||
if (message) {
|
||||
py_message = pygstminiobject_new((GstMiniObject *) message);
|
||||
gst_mini_object_unref ((GstMiniObject *) message);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
py_message = Py_None;
|
||||
}
|
||||
|
||||
py_args = PyTuple_New(1);
|
||||
Py_INCREF(py_message);
|
||||
PyTuple_SET_ITEM(py_args, 0, py_message);
|
||||
|
||||
py_method = PyObject_GetAttrString(py_self, "do_handle_message");
|
||||
if (!py_method) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_args);
|
||||
gst_mini_object_ref ((GstMiniObject *) message); Py_DECREF(py_message);
|
||||
Py_DECREF(py_self);
|
||||
pyg_gil_state_release(__py_state);
|
||||
return;
|
||||
}
|
||||
py_retval = PyObject_CallObject(py_method, py_args);
|
||||
if (!py_retval) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
gst_mini_object_ref ((GstMiniObject *) message); Py_DECREF(py_message);
|
||||
Py_DECREF(py_self);
|
||||
pyg_gil_state_release(__py_state);
|
||||
return;
|
||||
}
|
||||
if (py_retval != Py_None) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
PyErr_SetString(PyExc_TypeError, "retval should be None");
|
||||
Py_DECREF(py_retval);
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
gst_mini_object_ref ((GstMiniObject *) message); Py_DECREF(py_message);
|
||||
Py_DECREF(py_self);
|
||||
pyg_gil_state_release(__py_state);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Py_DECREF(py_retval);
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
gst_mini_object_ref ((GstMiniObject *) message); Py_DECREF(py_message);
|
||||
|
||||
/* #577735: since the bus handler will return BUS_DROP, we should unref.
|
||||
This is the only change from the generated code. */
|
||||
gst_mini_object_unref ((GstMiniObject *) message);
|
||||
|
||||
Py_DECREF(py_self);
|
||||
pyg_gil_state_release(__py_state);
|
||||
}
|
|
@ -1,611 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2002 David I. Lehn
|
||||
* Copyright (C) 2004 Johan Dahlin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
|
||||
static Py_ssize_t gst_buffer_getreadbuffer (PyObject *self,
|
||||
Py_ssize_t index, void **ptr);
|
||||
static Py_ssize_t gst_buffer_getwritebuf (PyObject *self,
|
||||
Py_ssize_t index, void **ptr);
|
||||
static Py_ssize_t gst_buffer_getsegcount (PyObject *self,
|
||||
Py_ssize_t *lenp);
|
||||
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
static Py_ssize_t gst_buffer_getcharbuf (PyObject *self,
|
||||
Py_ssize_t index, char **ptr);
|
||||
#else
|
||||
static Py_ssize_t gst_buffer_getcharbuf (PyObject *self,
|
||||
Py_ssize_t index, const char **ptr);
|
||||
#endif
|
||||
%%
|
||||
override gst_buffer_new kwargs
|
||||
static int
|
||||
_wrap_gst_buffer_new(PyGstMiniObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "data", "buffer_size", NULL };
|
||||
char *data = NULL;
|
||||
int size = 0;
|
||||
int buf_size = -1;
|
||||
|
||||
GST_INFO("self:%p", self);
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|z#i:GstBuffer.__init__", kwlist,
|
||||
&data, &size, &buf_size))
|
||||
return -1;
|
||||
|
||||
if (size < 0) {
|
||||
PyErr_SetString(PyExc_TypeError, "buffer size must be >= 0");
|
||||
return -1;
|
||||
}
|
||||
if (buf_size < 0)
|
||||
buf_size = size;
|
||||
if (buf_size < size) {
|
||||
PyErr_SetString(PyExc_TypeError, "buffer size must be >= data size");
|
||||
return -1;
|
||||
}
|
||||
|
||||
self->obj = GST_MINI_OBJECT(gst_buffer_new_and_alloc(buf_size));
|
||||
GST_INFO ("pyo:%p pyr:%"G_GSSIZE_FORMAT" minio:%p minir:%d",
|
||||
self, ((PyObject*)self)->ob_refcnt,
|
||||
self->obj, GST_MINI_OBJECT_REFCOUNT_VALUE(self->obj));
|
||||
if (!self->obj) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "could not create GstBuffer object");
|
||||
return -1;
|
||||
}
|
||||
pygstminiobject_register_wrapper((PyObject *) self);
|
||||
|
||||
if (data == NULL)
|
||||
return 0;
|
||||
|
||||
memcpy (GST_BUFFER_DATA (self->obj), data, size);
|
||||
GST_BUFFER_SIZE (self->obj) = size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-slot GstBuffer.tp_str
|
||||
static PyObject *
|
||||
_wrap_gst_buffer_tp_str (PyGstMiniObject *self)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
|
||||
g_assert (self);
|
||||
buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
g_assert (buf);
|
||||
|
||||
return PyString_FromStringAndSize((const gchar*) GST_BUFFER_DATA(buf),
|
||||
(gint) GST_BUFFER_SIZE(buf));
|
||||
}
|
||||
|
||||
%%
|
||||
override-slot GstBuffer.tp_repr
|
||||
static PyObject *
|
||||
_wrap_gst_buffer_tp_repr (PyGstMiniObject *self)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
guchar *data;
|
||||
gchar *repr;
|
||||
gint size = 0;
|
||||
PyObject *ret;
|
||||
|
||||
g_assert (self);
|
||||
buf = GST_BUFFER(self->obj);
|
||||
g_assert (buf);
|
||||
|
||||
size = GST_BUFFER_SIZE (buf);
|
||||
|
||||
if (size == 0) {
|
||||
repr = g_strdup_printf ("<gst.Buffer %p of size %d>", buf, size);
|
||||
} else {
|
||||
data = GST_BUFFER_DATA (buf);
|
||||
repr = g_strdup_printf (
|
||||
"<gst.Buffer %p of size %d and data 0x%02x%02x%02x%02x>", buf, size,
|
||||
*data,
|
||||
size > 0 ? *(data + 1) : 0,
|
||||
size > 1 ? *(data + 2) : 0,
|
||||
size > 2 ? *(data + 3) : 0
|
||||
);
|
||||
}
|
||||
ret = PyString_FromStringAndSize(repr, strlen (repr));
|
||||
g_free (repr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
%%
|
||||
override-slot GstBuffer.tp_as_buffer
|
||||
static PyBufferProcs _wrap_gst_buffer_tp_as_buffer = {
|
||||
gst_buffer_getreadbuffer, /* bf_getreadbuffer */
|
||||
gst_buffer_getwritebuf, /* bf_getwritebuffer */
|
||||
gst_buffer_getsegcount, /* bf_getsegcount */
|
||||
gst_buffer_getcharbuf, /* bf_getcharbuffer */
|
||||
};
|
||||
|
||||
static Py_ssize_t
|
||||
gst_buffer_getreadbuffer(PyObject *self, Py_ssize_t index,
|
||||
void **ptr)
|
||||
{
|
||||
GstBuffer *buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
|
||||
if ( index != 0 ) {
|
||||
PyErr_SetString(PyExc_SystemError,
|
||||
"accessing non-existent GstBuffer segment");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*ptr = GST_BUFFER_DATA(buf);
|
||||
return GST_BUFFER_SIZE(buf);
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
gst_buffer_getsegcount(PyObject *self, Py_ssize_t *lenp)
|
||||
{
|
||||
GstBuffer *buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
|
||||
if (lenp)
|
||||
*lenp = GST_BUFFER_SIZE(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Need a version that has const char ** for Python 2.4 */
|
||||
#if PY_VERSION_HEX >= 0x02050000
|
||||
static Py_ssize_t gst_buffer_getcharbuf (PyObject *self,
|
||||
Py_ssize_t index, char **ptr)
|
||||
#else
|
||||
static Py_ssize_t gst_buffer_getcharbuf (PyObject *self,
|
||||
Py_ssize_t index, const char **ptr)
|
||||
#endif
|
||||
{
|
||||
return gst_buffer_getreadbuffer (self, index, (void **) ptr);
|
||||
}
|
||||
|
||||
static Py_ssize_t
|
||||
gst_buffer_getwritebuf(PyObject *self, Py_ssize_t index, void **ptr)
|
||||
{
|
||||
GstBuffer *buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
|
||||
if ( index != 0 ) {
|
||||
PyErr_SetString(PyExc_SystemError,
|
||||
"accessing non-existent GstBuffer segment");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!gst_buffer_is_writable (buf)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"buffer is not writable");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*ptr = GST_BUFFER_DATA(buf);
|
||||
return GST_BUFFER_SIZE(buf);
|
||||
}
|
||||
|
||||
%%
|
||||
override-slot GstBuffer.tp_as_sequence
|
||||
/* FIXME: should buffer parts be buffers or strings? */
|
||||
|
||||
static Py_ssize_t
|
||||
pygst_buffer_length(PyObject *self)
|
||||
{
|
||||
return GST_BUFFER_SIZE(pygobject_get (self));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygst_buffer_slice(PyObject *self, Py_ssize_t start, Py_ssize_t end)
|
||||
{
|
||||
GstBuffer *buf = GST_BUFFER (pygobject_get (self));
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
if (end < 0)
|
||||
end = 0;
|
||||
if (end > GST_BUFFER_SIZE(buf))
|
||||
end = GST_BUFFER_SIZE(buf);
|
||||
|
||||
if (end <= start) {
|
||||
PyErr_SetString(PyExc_IndexError, "buffer index out of range");
|
||||
return NULL;
|
||||
}
|
||||
return PyString_FromStringAndSize((gchar *) GST_BUFFER_DATA (buf) + start, end - start);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygst_buffer_item(PyObject *self, Py_ssize_t index)
|
||||
{
|
||||
return pygst_buffer_slice (self, index, index + 1);
|
||||
}
|
||||
|
||||
static int
|
||||
pygst_buffer_ass_slice (PyObject *self, Py_ssize_t start,
|
||||
Py_ssize_t end, PyObject *val)
|
||||
{
|
||||
GstBuffer *buf = GST_BUFFER (pygobject_get (self));
|
||||
const void *data;
|
||||
Py_ssize_t len;
|
||||
|
||||
if (!gst_buffer_is_writable (buf)) {
|
||||
PyErr_SetString(PyExc_TypeError, "buffer is not writable");
|
||||
return -1;
|
||||
}
|
||||
/* FIXME: policy? */
|
||||
if (start < 0 || end <= start || end > GST_BUFFER_SIZE (buf)) {
|
||||
PyErr_SetString(PyExc_IndexError, "buffer index out of range");
|
||||
return -1;
|
||||
}
|
||||
end -= start;
|
||||
if (PyObject_AsReadBuffer(val, &data, &len))
|
||||
return -1;
|
||||
if (len > end)
|
||||
len = end;
|
||||
memcpy (GST_BUFFER_DATA (buf) + start, data, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
pygst_buffer_ass_item (PyObject *self, Py_ssize_t index, PyObject *val)
|
||||
{
|
||||
GstBuffer *buf = GST_BUFFER (pygobject_get (self));
|
||||
const void *data;
|
||||
Py_ssize_t len;
|
||||
|
||||
if (!gst_buffer_is_writable (buf)) {
|
||||
PyErr_SetString(PyExc_TypeError, "buffer is not writable");
|
||||
return -1;
|
||||
}
|
||||
if (index < 0 || index > GST_BUFFER_SIZE (buf)) {
|
||||
PyErr_SetString(PyExc_IndexError, "buffer index out of range");
|
||||
return -1;
|
||||
}
|
||||
if (PyObject_AsReadBuffer(val, &data, &len))
|
||||
return -1;
|
||||
/* FIXME: how do we handle this? */
|
||||
if (len > GST_BUFFER_SIZE (buf) - index)
|
||||
len = GST_BUFFER_SIZE (buf) - index;
|
||||
memcpy (GST_BUFFER_DATA (buf) + index, data, len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PySequenceMethods _wrap_gst_buffer_tp_as_sequence = {
|
||||
pygst_buffer_length, /* sq_length */
|
||||
NULL, /* sq_concat */
|
||||
NULL, /* sq_repeat */
|
||||
pygst_buffer_item, /* sq_item */
|
||||
pygst_buffer_slice, /* sq_slice */
|
||||
pygst_buffer_ass_item, /* sq_ass_item */
|
||||
pygst_buffer_ass_slice, /* sq_ass_slice */
|
||||
NULL, /* sq_contains */
|
||||
NULL, /* sq_inplace_concat */
|
||||
NULL, /* sq_inplace_repeat */
|
||||
};
|
||||
%%
|
||||
define GstBuffer.copy_on_write
|
||||
static PyObject *
|
||||
_wrap_gst_buffer_copy_on_write (PyObject *self)
|
||||
{
|
||||
GstBuffer *buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
|
||||
GST_INFO("INCREF");
|
||||
if (gst_buffer_is_writable (buf)) {
|
||||
Py_INCREF (self);
|
||||
return self;
|
||||
}
|
||||
buf = gst_buffer_copy (buf);
|
||||
self = pygstminiobject_new ((GstMiniObject *)(buf));
|
||||
gst_buffer_unref (buf);
|
||||
return self;
|
||||
}
|
||||
%%
|
||||
define GstBuffer.flag_is_set
|
||||
static PyObject *
|
||||
_wrap_gst_buffer_flag_is_set(PyObject *self, PyObject *args)
|
||||
{
|
||||
int flag;
|
||||
PyObject *retval;
|
||||
GstBuffer *buf;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i:GstBuffer.flag_is_set", &flag))
|
||||
return NULL;
|
||||
|
||||
buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
g_assert(GST_IS_BUFFER(buf));
|
||||
|
||||
retval = GST_BUFFER_FLAG_IS_SET(buf, flag) ? Py_True : Py_False;
|
||||
Py_INCREF(retval);
|
||||
return retval;
|
||||
}
|
||||
%%
|
||||
define GstBuffer.flag_set
|
||||
static PyObject *
|
||||
_wrap_gst_buffer_flag_set(PyObject *self, PyObject *args)
|
||||
{
|
||||
int flag;
|
||||
GstBuffer *buf;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i:GstBuffer.set", &flag))
|
||||
return NULL;
|
||||
|
||||
buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
g_assert(GST_IS_BUFFER(buf));
|
||||
GST_BUFFER_FLAG_SET(buf, flag);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
define GstBuffer.flag_unset
|
||||
static PyObject *
|
||||
_wrap_gst_buffer_flag_unset(PyObject *self, PyObject *args)
|
||||
{
|
||||
int flag;
|
||||
GstBuffer *buf;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i:GstBuffer.unset", &flag))
|
||||
return NULL;
|
||||
|
||||
buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
g_assert(GST_IS_BUFFER(buf));
|
||||
GST_BUFFER_FLAG_UNSET(buf, flag);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
%%
|
||||
override-attr GstBuffer.data
|
||||
static PyObject *
|
||||
_wrap_gst_buffer__get_data(PyObject *self, void *closure)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
|
||||
g_assert (self);
|
||||
buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
g_assert (buf);
|
||||
|
||||
return PyString_FromStringAndSize((const gchar*) GST_BUFFER_DATA(buf),
|
||||
(gint) GST_BUFFER_SIZE(buf));
|
||||
}
|
||||
|
||||
%%
|
||||
override-attr GstBuffer.size
|
||||
static PyObject *
|
||||
_wrap_gst_buffer__get_size(PyObject *self, void *closure)
|
||||
{
|
||||
return PyLong_FromUnsignedLongLong((guint) GST_BUFFER_SIZE(GST_BUFFER(pygstminiobject_get(self))));
|
||||
}
|
||||
static int
|
||||
_wrap_gst_buffer__set_size(PyGstMiniObject *self, PyObject *value, void *closure)
|
||||
{
|
||||
guint val;
|
||||
GstBuffer *buf;
|
||||
void* ptr;
|
||||
|
||||
if (PyInt_CheckExact(value))
|
||||
val = PyInt_AsUnsignedLongLongMask(value);
|
||||
else
|
||||
val = PyLong_AsUnsignedLongLong(value);
|
||||
if (PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
g_assert (self);
|
||||
buf = GST_BUFFER(pygstminiobject_get(self));
|
||||
g_assert (buf);
|
||||
|
||||
ptr = realloc( GST_BUFFER_DATA(buf), val );
|
||||
if (ptr)
|
||||
{
|
||||
GST_BUFFER_DATA(buf) = ptr;
|
||||
GST_BUFFER_SIZE(buf) = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Raise an error */
|
||||
PyErr_SetString( PyExc_RuntimeError, "Unable to realloc Buffer" );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr GstBuffer.timestamp
|
||||
static PyObject *
|
||||
_wrap_gst_buffer__get_timestamp(PyObject *self, void *closure)
|
||||
{
|
||||
guint64 ret;
|
||||
|
||||
ret = GST_BUFFER(pygstminiobject_get(self))->timestamp;
|
||||
return PyLong_FromUnsignedLongLong(ret);
|
||||
}
|
||||
static int
|
||||
_wrap_gst_buffer__set_timestamp(PyGstMiniObject *self, PyObject *value, void *closure)
|
||||
{
|
||||
guint64 val;
|
||||
|
||||
if (PyInt_CheckExact(value))
|
||||
val = PyInt_AsUnsignedLongLongMask(value);
|
||||
else
|
||||
val = PyLong_AsUnsignedLongLong(value);
|
||||
if (PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
GST_BUFFER(self->obj)->timestamp = val;
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override-attr GstBuffer.duration
|
||||
static PyObject *
|
||||
_wrap_gst_buffer__get_duration(PyObject *self, void *closure)
|
||||
{
|
||||
guint64 ret;
|
||||
|
||||
ret = GST_BUFFER(pygstminiobject_get(self))->duration;
|
||||
return PyLong_FromUnsignedLongLong(ret);
|
||||
}
|
||||
static int
|
||||
_wrap_gst_buffer__set_duration(PyGstMiniObject *self, PyObject *value, void *closure)
|
||||
{
|
||||
guint64 val;
|
||||
|
||||
if (PyInt_CheckExact(value))
|
||||
val = PyInt_AsUnsignedLongLongMask(value);
|
||||
else
|
||||
val = PyLong_AsUnsignedLongLong(value);
|
||||
if (PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
GST_BUFFER(self->obj)->duration = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
%%
|
||||
override-attr GstBuffer.offset
|
||||
static PyObject *
|
||||
_wrap_gst_buffer__get_offset (PyObject *self, void *closure)
|
||||
{
|
||||
guint64 ret;
|
||||
GstMiniObject *miniobject;
|
||||
g_assert (self);
|
||||
|
||||
miniobject = pygstminiobject_get (self);
|
||||
g_assert (miniobject);
|
||||
|
||||
ret = GST_BUFFER_OFFSET (GST_BUFFER (miniobject));
|
||||
return PyLong_FromUnsignedLongLong (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
_wrap_gst_buffer__set_offset (PyGstMiniObject *self, PyObject *value, void *closure)
|
||||
{
|
||||
guint64 val;
|
||||
g_assert (self);
|
||||
|
||||
if (PyInt_CheckExact (value))
|
||||
val = PyInt_AsUnsignedLongLongMask (value);
|
||||
else
|
||||
val = PyLong_AsUnsignedLongLong (value);
|
||||
if (PyErr_Occurred())
|
||||
return -1;
|
||||
|
||||
GST_BUFFER_OFFSET (GST_BUFFER (self->obj)) = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
%%
|
||||
override-attr GstBuffer.offset_end
|
||||
static PyObject *
|
||||
_wrap_gst_buffer__get_offset_end (PyObject *self, void *closure)
|
||||
{
|
||||
guint64 ret;
|
||||
GstMiniObject *miniobject;
|
||||
g_assert (self);
|
||||
|
||||
miniobject = pygstminiobject_get (self);
|
||||
g_assert (miniobject);
|
||||
|
||||
ret = GST_BUFFER_OFFSET_END (GST_BUFFER (miniobject));
|
||||
return PyLong_FromUnsignedLongLong (ret);
|
||||
}
|
||||
|
||||
static int
|
||||
_wrap_gst_buffer__set_offset_end (PyGstMiniObject *self, PyObject *value, void *closure)
|
||||
{
|
||||
guint64 val;
|
||||
g_assert (self);
|
||||
|
||||
if (PyInt_CheckExact (value))
|
||||
val = PyInt_AsUnsignedLongLongMask (value);
|
||||
else
|
||||
val = PyLong_AsUnsignedLongLong (value);
|
||||
if (PyErr_Occurred ())
|
||||
return -1;
|
||||
|
||||
GST_BUFFER_OFFSET_END (GST_BUFFER (self->obj)) = val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_buffer_stamp kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_buffer_stamp (PyGstMiniObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "src", NULL };
|
||||
PyGstMiniObject *srcobj;
|
||||
GstBuffer *dest, *src;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kwargs,
|
||||
"O:GstBuffer.stamp",
|
||||
kwlist, &srcobj))
|
||||
return NULL;
|
||||
dest = GST_BUFFER(pygstminiobject_get(self));
|
||||
src = GST_BUFFER(pygstminiobject_get(srcobj));
|
||||
gst_buffer_stamp (dest, (const GstBuffer*) src);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override-attr GstBuffer.caps
|
||||
static PyObject *
|
||||
_wrap_gst_buffer__get_caps (PyObject *self, void *closure)
|
||||
{
|
||||
GstMiniObject *miniobject;
|
||||
GstCaps *ret;
|
||||
|
||||
miniobject = pygstminiobject_get (self);
|
||||
g_assert (miniobject);
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_buffer_get_caps(GST_BUFFER(miniobject));
|
||||
pyg_end_allow_threads;
|
||||
return pyg_boxed_new (GST_TYPE_CAPS, ret, FALSE, TRUE);
|
||||
}
|
||||
static int
|
||||
_wrap_gst_buffer__set_caps (PyGstMiniObject *self, PyObject *value, void *closure)
|
||||
{
|
||||
GstCaps *caps;
|
||||
g_assert (self);
|
||||
|
||||
caps = pygst_caps_from_pyobject (value, NULL);
|
||||
if (PyErr_Occurred())
|
||||
return -1;
|
||||
pyg_begin_allow_threads;
|
||||
gst_buffer_set_caps(GST_BUFFER(self->obj), caps);
|
||||
gst_caps_unref (caps);
|
||||
pyg_end_allow_threads;
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override gst_buffer_set_caps kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_buffer_set_caps(PyGstMiniObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "caps", NULL };
|
||||
PyObject *py_caps;
|
||||
GstCaps *caps;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstBuffer.set_caps", kwlist, &py_caps))
|
||||
return NULL;
|
||||
caps = pygst_caps_from_pyobject (py_caps, NULL);
|
||||
if (PyErr_Occurred())
|
||||
return NULL;
|
||||
pyg_begin_allow_threads;
|
||||
gst_buffer_set_caps(GST_BUFFER(self->obj), caps);
|
||||
gst_caps_unref (caps);
|
||||
pyg_end_allow_threads;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
|
@ -1,272 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*-
|
||||
* vi:si:et:sw=4:sts=4:ts=4
|
||||
*
|
||||
* gst-python
|
||||
* Copyright (C) 2005 Edward Hervey
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Edward Hervey <edward@fluendo.com>
|
||||
*/
|
||||
%%
|
||||
ignore
|
||||
gst_bus_create_watch
|
||||
gst_bus_sync_signal_handler
|
||||
gst_bus_async_signal_func
|
||||
%%
|
||||
headers
|
||||
static GstBusSyncReply
|
||||
bus_sync_handler (GstBus *bus, GstMessage *message, gpointer user_data)
|
||||
{
|
||||
PyGILState_STATE state;
|
||||
GstBusSyncReply res;
|
||||
PyObject *py_userdata;
|
||||
PyObject *py_msg;
|
||||
PyObject *callback, *args;
|
||||
PyObject *ret;
|
||||
gint i, len;
|
||||
|
||||
g_return_val_if_fail (user_data != NULL, GST_BUS_PASS);
|
||||
|
||||
state = pyg_gil_state_ensure ();
|
||||
|
||||
py_userdata = (PyObject *) user_data;
|
||||
py_msg = pygstminiobject_new (GST_MINI_OBJECT (message));
|
||||
callback = PyTuple_GetItem (py_userdata, 0);
|
||||
|
||||
/* Using N we give away our references to the args tuple */
|
||||
args = Py_BuildValue ("(NN)",
|
||||
pygobject_new (G_OBJECT (bus)),
|
||||
py_msg);
|
||||
|
||||
/* add all *args to the args tuple object */
|
||||
len = PyTuple_Size (py_userdata);
|
||||
for (i = 1; i < len; ++i) {
|
||||
PyObject *tuple = args;
|
||||
args = PySequence_Concat (tuple, PyTuple_GetItem (py_userdata, i));
|
||||
Py_DECREF (tuple);
|
||||
}
|
||||
ret = PyObject_CallObject (callback, args);
|
||||
|
||||
if (!ret) {
|
||||
PyErr_Print ();
|
||||
res = GST_BUS_PASS;
|
||||
} else {
|
||||
if (ret == Py_None) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"callback should return a BusSyncReply");
|
||||
PyErr_Print ();
|
||||
res = GST_BUS_PASS;
|
||||
} else if (pyg_enum_get_value (GST_TYPE_BUS_SYNC_REPLY, ret,
|
||||
(gint *) &res))
|
||||
res = GST_BUS_PASS;
|
||||
|
||||
Py_DECREF (ret);
|
||||
}
|
||||
Py_DECREF (args);
|
||||
|
||||
pyg_gil_state_release (state);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
bus_func (GstBus *bus, GstMessage *message, gpointer user_data)
|
||||
{
|
||||
PyGILState_STATE state;
|
||||
gboolean res;
|
||||
PyObject *py_userdata;
|
||||
PyObject *py_msg;
|
||||
PyObject *callback, *args;
|
||||
PyObject *ret;
|
||||
gint i, len;
|
||||
|
||||
g_return_val_if_fail (user_data != NULL, TRUE);
|
||||
|
||||
GST_DEBUG_OBJECT (bus, "dispatching message %p", message);
|
||||
|
||||
state = pyg_gil_state_ensure ();
|
||||
|
||||
py_userdata = (PyObject *) user_data;
|
||||
g_assert (PyTuple_Check (py_userdata));
|
||||
|
||||
py_msg = pygstminiobject_new (GST_MINI_OBJECT (message));
|
||||
callback = PyTuple_GetItem (py_userdata, 0);
|
||||
|
||||
/* Using N we give away our references to the args tuple */
|
||||
args = Py_BuildValue ("(NN)",
|
||||
pygobject_new (G_OBJECT (bus)),
|
||||
py_msg);
|
||||
g_assert (args);
|
||||
|
||||
/* add all *args to the args tuple object */
|
||||
len = PyTuple_Size (py_userdata);
|
||||
for (i = 1; i < len; ++i) {
|
||||
PyObject *item;
|
||||
PyObject *tuple = args;
|
||||
|
||||
item = PyTuple_GetItem (py_userdata, i);
|
||||
g_assert (item);
|
||||
|
||||
args = PySequence_Concat (tuple, item);
|
||||
g_assert (args);
|
||||
|
||||
Py_DECREF (tuple);
|
||||
}
|
||||
ret = PyObject_CallObject(callback, args);
|
||||
|
||||
if (!ret) {
|
||||
PyErr_Print ();
|
||||
res = TRUE;
|
||||
} else {
|
||||
if (ret == Py_None) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"callback should return True or False");
|
||||
PyErr_Print ();
|
||||
res = TRUE;
|
||||
} else
|
||||
res = PyObject_IsTrue (ret);
|
||||
Py_DECREF (ret);
|
||||
}
|
||||
Py_DECREF (args);
|
||||
|
||||
pyg_gil_state_release (state);
|
||||
|
||||
GST_DEBUG_OBJECT (bus, "dispatched message %p", message);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_bus_set_sync_handler args
|
||||
static PyObject *
|
||||
_wrap_gst_bus_set_sync_handler (PyGObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *callback = NULL;
|
||||
PyObject *cbargs = NULL;
|
||||
PyObject *data = NULL;
|
||||
PyObject *old_data = NULL;
|
||||
gint len;
|
||||
static GQuark sync_handler_data_quark = 0;
|
||||
|
||||
len = PyTuple_Size(args);
|
||||
|
||||
if (len < 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "Bus requires at least 1 arg");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sync_handler_data_quark == 0)
|
||||
sync_handler_data_quark = \
|
||||
g_quark_from_static_string("PyGst::BusSyncHandlerData");
|
||||
|
||||
callback = PySequence_GetItem(args, 0);
|
||||
if (callback != Py_None) {
|
||||
if (!PyCallable_Check(callback)) {
|
||||
Py_DECREF (callback);
|
||||
PyErr_SetString(PyExc_TypeError, "callback is not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cbargs = PySequence_GetSlice(args, 1, len);
|
||||
if (cbargs == NULL) {
|
||||
Py_DECREF (callback);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = Py_BuildValue("(ON)", callback, cbargs);
|
||||
Py_DECREF (cbargs);
|
||||
if (data == NULL) {
|
||||
Py_DECREF (callback);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
old_data = g_object_get_qdata (self->obj, sync_handler_data_quark);
|
||||
if (old_data != NULL) {
|
||||
Py_DECREF (old_data);
|
||||
}
|
||||
|
||||
g_object_set_qdata (self->obj, sync_handler_data_quark, data);
|
||||
|
||||
gst_bus_set_sync_handler (GST_BUS (self->obj),
|
||||
(GstBusSyncHandler) bus_sync_handler,
|
||||
data);
|
||||
} else {
|
||||
old_data = g_object_get_qdata (self->obj, sync_handler_data_quark);
|
||||
if (old_data != NULL) {
|
||||
Py_DECREF (old_data);
|
||||
}
|
||||
|
||||
g_object_set_qdata (self->obj, sync_handler_data_quark, NULL);
|
||||
|
||||
gst_bus_set_sync_handler (GST_BUS (self->obj), NULL, NULL);
|
||||
}
|
||||
|
||||
Py_DECREF (callback);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_bus_add_watch args
|
||||
static PyObject *
|
||||
_wrap_gst_bus_add_watch (PyGObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *callback, *cbargs = NULL, *data;
|
||||
guint sigid;
|
||||
guint len;
|
||||
|
||||
len = PyTuple_Size(args);
|
||||
|
||||
if (len < 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "Bus.add_watch requires at least 1 argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
callback = PySequence_GetItem(args, 0);
|
||||
if (!PyCallable_Check(callback)) {
|
||||
PyErr_SetString(PyExc_TypeError, "callback is not callable");
|
||||
return NULL;
|
||||
}
|
||||
cbargs = PySequence_GetSlice(args, 1, len);
|
||||
if (cbargs == NULL)
|
||||
return NULL;
|
||||
/* FIXME: thomas: I'm pretty sure the second N needs to be O */
|
||||
data = Py_BuildValue("(ON)", callback, cbargs);
|
||||
if (data == NULL)
|
||||
return NULL;
|
||||
|
||||
sigid = gst_bus_add_watch_full (GST_BUS (self->obj), G_PRIORITY_DEFAULT,
|
||||
(GstBusFunc) bus_func, data, (GDestroyNotify)pyg_destroy_notify);
|
||||
|
||||
return PyInt_FromLong(sigid);
|
||||
}
|
||||
%%
|
||||
override gst_bus_add_signal_watch kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_bus_add_signal_watch(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "priority", NULL };
|
||||
int priority = G_PRIORITY_DEFAULT;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|i:GstBus.add_signal_watch", kwlist, &priority))
|
||||
return NULL;
|
||||
pyg_begin_allow_threads;
|
||||
gst_bus_add_signal_watch_full(GST_BUS(self->obj), priority);
|
||||
pyg_end_allow_threads;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
|
@ -1,474 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Johan Dahlin
|
||||
* 2005 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
* Benjamin Otte <otte@gnome.org>
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
/* This is a (hopefully) smart hack to allow access to a caps'
|
||||
* structures without falling into traps when the caps get destroyed
|
||||
* before the structures get.
|
||||
* This Hash Table uses the structure PyObjects as keys and the caps
|
||||
* PyObjects as values. No clue if this is a fast data structure but it
|
||||
* probably doesn't matter anyway.
|
||||
*/
|
||||
static GHashTable *structure_caps_map = NULL;
|
||||
|
||||
static void
|
||||
pygst_caps_map_add (PyObject *structure, PyObject *caps)
|
||||
{
|
||||
/* we can't have free_on_dealloc stuff in here */
|
||||
g_assert (((PyGBoxed *)structure)->free_on_dealloc == FALSE);
|
||||
g_hash_table_insert (structure_caps_map, structure, caps);
|
||||
}
|
||||
|
||||
static void
|
||||
pygst_caps_map_remove_structure (PyObject *structure)
|
||||
{
|
||||
g_hash_table_remove (structure_caps_map, structure);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
pygst_caps_map_foreach (gpointer structure, gpointer caps, gpointer match)
|
||||
{
|
||||
PyGBoxed *boxed = structure;
|
||||
|
||||
if (match != caps)
|
||||
return FALSE;
|
||||
|
||||
/* we can't have free_on_dealloc stuff in here */
|
||||
g_assert (boxed->free_on_dealloc == FALSE);
|
||||
boxed->boxed = gst_structure_copy (boxed->boxed);
|
||||
boxed->free_on_dealloc = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
pygst_caps_map_modified (PyObject *caps)
|
||||
{
|
||||
g_hash_table_foreach_remove (structure_caps_map, pygst_caps_map_foreach, caps);
|
||||
}
|
||||
|
||||
%%
|
||||
init
|
||||
structure_caps_map = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
%%
|
||||
ignore
|
||||
gst_caps_new_simple
|
||||
gst_caps_new_full
|
||||
gst_caps_set_simple
|
||||
%%
|
||||
override gst_caps_get_structure kwargs
|
||||
static PyObject *pygst_caps_sq_item(PyObject *self, Py_ssize_t i);
|
||||
static PyObject *
|
||||
_wrap_gst_caps_get_structure(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "index", NULL };
|
||||
int index;
|
||||
|
||||
if (PyErr_Warn(PyExc_DeprecationWarning, "caps.get_structure(i) is deprecated, use caps[i]") < 0)
|
||||
return NULL;
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GstCaps.get_structure", kwlist, &index))
|
||||
return NULL;
|
||||
return pygst_caps_sq_item (self, index);
|
||||
}
|
||||
%%
|
||||
override gst_caps_new_empty kwargs
|
||||
static int
|
||||
_wrap_gst_caps_new_empty(PyGBoxed *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
PyObject* item;
|
||||
int len, i;
|
||||
|
||||
/* we wrap caps_new, caps_from_string and caps_new_full */
|
||||
len = PyTuple_Size(args);
|
||||
self->gtype = GST_TYPE_CAPS;
|
||||
self->free_on_dealloc = TRUE;
|
||||
|
||||
if (len == 0) {
|
||||
/* 0 length creates a new empty caps */
|
||||
self->boxed = gst_caps_new_empty();
|
||||
} else if (len == 1) {
|
||||
item = PyTuple_GetItem(args, 0);
|
||||
/* 1 length is either a string or a structure */
|
||||
self->boxed = pygst_caps_from_pyobject (item, NULL);
|
||||
} else {
|
||||
/* it's multiple arguments that can all be made to caps */
|
||||
GstCaps *append;
|
||||
self->boxed = gst_caps_new_empty();
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
item = PyTuple_GetItem(args, i);
|
||||
append = pygst_caps_from_pyobject (item, NULL);
|
||||
if (!append) {
|
||||
gst_caps_unref (self->boxed);
|
||||
self->boxed = NULL;
|
||||
break;
|
||||
}
|
||||
gst_caps_append (self->boxed, append);
|
||||
}
|
||||
}
|
||||
if (!self->boxed) {
|
||||
PyErr_SetString(PyExc_TypeError, "wrong arguments when creating GstCaps object");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
%%
|
||||
override-slot GstCaps.tp_richcompare
|
||||
|
||||
static gboolean
|
||||
pygst_caps_is_true_subset (GstCaps *caps1, GstCaps *caps2)
|
||||
{
|
||||
GstCaps *tmp;
|
||||
gboolean ret;
|
||||
|
||||
/* order is important here */
|
||||
if (gst_caps_is_any (caps1))
|
||||
return FALSE;
|
||||
if (gst_caps_is_any (caps2))
|
||||
return TRUE;
|
||||
if (gst_caps_is_empty (caps2))
|
||||
return FALSE;
|
||||
if (gst_caps_is_empty (caps1))
|
||||
return TRUE;
|
||||
|
||||
tmp = gst_caps_subtract (caps1, caps2);
|
||||
ret = gst_caps_is_empty (tmp);
|
||||
gst_caps_unref (tmp);
|
||||
if (!ret)
|
||||
return FALSE;
|
||||
tmp = gst_caps_subtract (caps2, caps1);
|
||||
ret = gst_caps_is_empty (tmp);
|
||||
gst_caps_unref (tmp);
|
||||
return !ret;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_caps_tp_richcompare (PyObject *py_caps1, PyObject *py_caps2, int comparison)
|
||||
{
|
||||
GstCaps *caps1, *caps2;
|
||||
gboolean caps2_is_copy;
|
||||
PyObject *ret;
|
||||
|
||||
caps1 = pyg_boxed_get (py_caps1, GstCaps);
|
||||
caps2 = pygst_caps_from_pyobject (py_caps2, &caps2_is_copy);
|
||||
if (PyErr_Occurred()) {
|
||||
/* the second arg is not a caps */
|
||||
switch (comparison) {
|
||||
case Py_EQ:
|
||||
PyErr_Clear();
|
||||
ret = Py_False;
|
||||
Py_INCREF (ret);
|
||||
return ret;
|
||||
case Py_NE:
|
||||
PyErr_Clear();
|
||||
ret = Py_True;
|
||||
Py_INCREF (ret);
|
||||
return ret;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
switch (comparison) {
|
||||
case Py_LT:
|
||||
ret = pygst_caps_is_true_subset (caps1, caps2) ? Py_True : Py_False;
|
||||
break;
|
||||
case Py_LE:
|
||||
ret = gst_caps_is_subset (caps1, caps2) ? Py_True : Py_False;
|
||||
break;
|
||||
case Py_NE:
|
||||
ret = gst_caps_is_equal (caps1, caps2) ? Py_False : Py_True;
|
||||
break;
|
||||
case Py_EQ:
|
||||
ret = gst_caps_is_equal (caps1, caps2) ? Py_True : Py_False;
|
||||
break;
|
||||
case Py_GE:
|
||||
ret = gst_caps_is_subset (caps2, caps1) ? Py_True : Py_False;
|
||||
break;
|
||||
case Py_GT:
|
||||
ret = pygst_caps_is_true_subset (caps2, caps1) ? Py_True : Py_False;
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString (PyExc_RuntimeError, "invalid comparison operation");
|
||||
if (caps2 && caps2_is_copy)
|
||||
gst_caps_unref (caps2);
|
||||
return NULL;
|
||||
}
|
||||
if (caps2 && caps2_is_copy)
|
||||
gst_caps_unref (caps2);
|
||||
|
||||
Py_INCREF (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
%%
|
||||
override-slot GstCaps.tp_as_number
|
||||
|
||||
/* In this number code, we mimic the Python set.Set datatype.
|
||||
* The same operations are supported. If you want to have an operation
|
||||
* supported for caps, add it to Python's Set type first.
|
||||
*/
|
||||
#define BINARY_FUNC(name,func) \
|
||||
static PyObject * \
|
||||
name (PyObject *py_caps1, PyObject *py_caps2) \
|
||||
{ \
|
||||
GstCaps *caps1, *caps2, *ret; \
|
||||
gboolean caps2_is_copy; \
|
||||
\
|
||||
caps1 = pyg_boxed_get (py_caps1, GstCaps); \
|
||||
caps2 = pygst_caps_from_pyobject (py_caps2, &caps2_is_copy); \
|
||||
if (PyErr_Occurred()) \
|
||||
return NULL; \
|
||||
ret = func (caps1, caps2); \
|
||||
if (caps2 && caps2_is_copy) \
|
||||
gst_caps_unref (caps2); \
|
||||
return pyg_boxed_new (GST_TYPE_CAPS, ret, FALSE, TRUE); \
|
||||
}
|
||||
|
||||
BINARY_FUNC (pygst_caps_nb_subtract, gst_caps_subtract)
|
||||
BINARY_FUNC (pygst_caps_nb_and, gst_caps_intersect)
|
||||
BINARY_FUNC (pygst_caps_nb_or, gst_caps_union)
|
||||
static GstCaps *
|
||||
pygst_caps_xor (const GstCaps *caps1, const GstCaps *caps2)
|
||||
{
|
||||
GstCaps *intersect, *_union, *ret;
|
||||
intersect = gst_caps_intersect (caps1, caps2);
|
||||
_union = gst_caps_union (caps1, caps2);
|
||||
ret = gst_caps_subtract (_union, intersect);
|
||||
gst_caps_unref (_union);
|
||||
gst_caps_unref (intersect);
|
||||
gst_caps_do_simplify (ret);
|
||||
return ret;
|
||||
}
|
||||
BINARY_FUNC (pygst_caps_nb_xor, pygst_caps_xor)
|
||||
|
||||
static int
|
||||
pygst_caps_nb_nonzero (PyObject *py_caps)
|
||||
{
|
||||
GstCaps *caps = pyg_boxed_get (py_caps, GstCaps);
|
||||
|
||||
if (gst_caps_is_empty (caps))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
pygst_caps_nb_coerce (PyObject **py_caps1, PyObject **py_caps2)
|
||||
{
|
||||
GstCaps *caps1, *caps2 = NULL;
|
||||
gboolean caps1_is_copy, caps2_is_copy;
|
||||
|
||||
caps1 = pygst_caps_from_pyobject (*py_caps1, &caps1_is_copy);
|
||||
if (!caps1)
|
||||
goto error;
|
||||
caps2 = pygst_caps_from_pyobject (*py_caps2, &caps2_is_copy);
|
||||
if (!caps2)
|
||||
goto error;
|
||||
/* if they're not copies, they're caps already */
|
||||
if (caps1_is_copy)
|
||||
*py_caps1 = pyg_boxed_new (GST_TYPE_CAPS, caps1, FALSE, TRUE);
|
||||
else
|
||||
Py_INCREF (*py_caps1);
|
||||
if (caps2_is_copy)
|
||||
*py_caps2 = pyg_boxed_new (GST_TYPE_CAPS, caps2, FALSE, TRUE);
|
||||
else
|
||||
Py_INCREF (*py_caps2);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
g_assert (PyErr_Occurred ());
|
||||
PyErr_Clear ();
|
||||
if (caps1 && !caps1_is_copy)
|
||||
gst_caps_unref (caps1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static PyNumberMethods _wrap_gst_caps_tp_as_number = {
|
||||
0, /* nb_add */
|
||||
pygst_caps_nb_subtract, /* nb_subtract */
|
||||
0, /* nb_multiply */
|
||||
0, /* nb_divide */
|
||||
0, /* nb_remainder */
|
||||
0, /* nb_divmod */
|
||||
0, /* nb_power */
|
||||
0, /* nb_negative */
|
||||
0, /* nb_positive */
|
||||
0, /* nb_absolute */
|
||||
pygst_caps_nb_nonzero, /* nb_nonzero */
|
||||
0, /* nb_invert */
|
||||
0, /* nb_lshift */
|
||||
0, /* nb_rshift */
|
||||
pygst_caps_nb_and, /* nb_and */
|
||||
pygst_caps_nb_xor, /* nb_xor */
|
||||
pygst_caps_nb_or, /* nb_or */
|
||||
pygst_caps_nb_coerce, /* nb_coerce */
|
||||
0, /* nb_int */
|
||||
0, /* nb_long */
|
||||
0, /* nb_float */
|
||||
0, /* nb_oct */
|
||||
0, /* nb_hex */
|
||||
0, /* nb_inplace_add */
|
||||
0, /* nb_inplace_subtract */
|
||||
0, /* nb_inplace_multiply */
|
||||
0, /* nb_inplace_divide */
|
||||
0, /* nb_inplace_remainder */
|
||||
0, /* nb_inplace_power */
|
||||
0, /* nb_inplace_lshift */
|
||||
0, /* nb_inplace_rshift */
|
||||
0, /* nb_inplace_and */
|
||||
0, /* nb_inplace_xor */
|
||||
0, /* nb_inplace_or */
|
||||
0, /* nb_floor_divide */
|
||||
0, /* nb_true_divide */
|
||||
0, /* nb_inplace_floor_divide */
|
||||
0, /* nb_inplace_true_divide */
|
||||
};
|
||||
%%
|
||||
override-slot GstCaps.tp_as_sequence
|
||||
static Py_ssize_t
|
||||
pygst_caps_sq_length(PyObject *self)
|
||||
{
|
||||
GstCaps *caps = pyg_boxed_get (self, GstCaps);
|
||||
return gst_caps_get_size(caps);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygst_caps_sq_item(PyObject *self, Py_ssize_t i)
|
||||
{
|
||||
GstCaps *caps = pyg_boxed_get (self, GstCaps);
|
||||
GstStructure *structure;
|
||||
PyObject *ret;
|
||||
|
||||
if (i < 0 || i >= gst_caps_get_size(caps)) {
|
||||
PyErr_SetString(PyExc_IndexError, "list index out of range");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
structure = gst_caps_get_structure(caps, i);
|
||||
|
||||
/* pyg_boxed_new handles NULL checking */
|
||||
ret = pyg_boxed_new(GST_TYPE_STRUCTURE,
|
||||
structure,
|
||||
FALSE, FALSE);
|
||||
if (ret)
|
||||
pygst_caps_map_add (ret, self);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* FIXME: This syntax sucks */
|
||||
static PyObject *
|
||||
pygst_caps_sq_slice(PyObject *self, Py_ssize_t start, Py_ssize_t end)
|
||||
{
|
||||
GstCaps *caps = pyg_boxed_get (self, GstCaps);
|
||||
GstCaps *ret = gst_caps_new_empty ();
|
||||
int i;
|
||||
|
||||
if (start < 0)
|
||||
start = 0;
|
||||
if (end > gst_caps_get_size (caps))
|
||||
end = gst_caps_get_size (caps);
|
||||
|
||||
for (i = start; i < end; i++)
|
||||
gst_caps_append_structure (ret, gst_structure_copy (gst_caps_get_structure (caps, i)));
|
||||
|
||||
return pyg_boxed_new(GST_TYPE_CAPS, ret, FALSE, TRUE);
|
||||
}
|
||||
|
||||
static PySequenceMethods _wrap_gst_caps_tp_as_sequence = {
|
||||
pygst_caps_sq_length,
|
||||
NULL, /* not allowed for sets, use | instead of + */
|
||||
NULL, /* doesn't make sense, because it'd still be the same */
|
||||
pygst_caps_sq_item,
|
||||
pygst_caps_sq_slice,
|
||||
NULL, /* doesn't make sense, you can only append */
|
||||
NULL, /* doesn't make sense, you can only append */
|
||||
NULL, /* doesn't make sense really, unless you use is_subset */
|
||||
NULL, /* not allowed for sets, use | instead of + */
|
||||
NULL /* doesn't make sense, because it'd still be the same */
|
||||
};
|
||||
%%
|
||||
override-slot GstCaps.tp_dealloc
|
||||
static void
|
||||
_wrap_gst_caps_tp_dealloc (PyObject *self)
|
||||
{
|
||||
PyGBoxed *boxed = (PyGBoxed *) self;
|
||||
|
||||
if (boxed->free_on_dealloc && boxed->boxed) {
|
||||
pygst_caps_map_modified (self);
|
||||
GST_DEBUG ("unreffing caps %" GST_PTR_FORMAT " at %p with refcount %d",
|
||||
boxed->boxed, boxed->boxed, GST_CAPS_REFCOUNT (boxed->boxed));
|
||||
gst_caps_unref (boxed->boxed);
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
%%
|
||||
override-slot GstCaps.tp_str
|
||||
static PyObject *
|
||||
_wrap_gst_caps_tp_str(PyGObject *self)
|
||||
{
|
||||
gchar *tmp;
|
||||
PyObject *retval;
|
||||
|
||||
tmp = gst_caps_to_string((GstCaps*)self->obj);
|
||||
retval = PyString_FromString(tmp);
|
||||
g_free(tmp);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
%%
|
||||
override-attr GstCaps.__refcount__
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_caps__get___refcount__(PyGObject *self, void *closure)
|
||||
{
|
||||
return PyInt_FromLong(GST_CAPS_REFCOUNT(self->obj));
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_caps_append_structure kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_caps_append_structure(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "structure", NULL };
|
||||
PyObject *py_structure;
|
||||
GstStructure *structure = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:GstCaps.append_structure", kwlist, &py_structure))
|
||||
return NULL;
|
||||
if (pyg_boxed_check(py_structure, GST_TYPE_STRUCTURE))
|
||||
structure = gst_structure_copy(pyg_boxed_get(py_structure, GstStructure));
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "structure should be a GstStructure");
|
||||
return NULL;
|
||||
}
|
||||
pyg_begin_allow_threads;
|
||||
gst_caps_append_structure(pyg_boxed_get(self, GstCaps), structure);
|
||||
pyg_end_allow_threads;
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
|
@ -1,637 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 8 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Johan Dahlin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
%%
|
||||
ignore
|
||||
gst_element_get
|
||||
gst_element_set
|
||||
gst_element_get_property
|
||||
gst_element_set_property
|
||||
%%
|
||||
override gst_element_get_pad_template args
|
||||
static PyObject *
|
||||
_wrap_gst_element_get_pad_template(PyGObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *ret;
|
||||
gchar *name;
|
||||
GstPadTemplate *tmpl;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:GstElement.get_pad_template", &name))
|
||||
return NULL;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
tmpl = gst_element_class_get_pad_template
|
||||
(GST_ELEMENT_GET_CLASS (self->obj), name);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (tmpl) {
|
||||
ret = pygobject_new (G_OBJECT (tmpl));
|
||||
} else {
|
||||
ret = Py_None;
|
||||
Py_INCREF (ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override gst_element_set_state kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_set_state(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "state", NULL };
|
||||
PyObject *py_state = NULL;
|
||||
GstState state;
|
||||
gint ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstElement.set_state", kwlist, &py_state))
|
||||
return NULL;
|
||||
if (pyg_enum_get_value(GST_TYPE_STATE, py_state, (gint *)&state))
|
||||
return NULL;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
|
||||
ret = gst_element_set_state(GST_ELEMENT(self->obj), state);
|
||||
|
||||
pyg_end_allow_threads;
|
||||
|
||||
return pyg_enum_from_gtype(GST_TYPE_STATE_CHANGE_RETURN, ret);
|
||||
}
|
||||
%%
|
||||
override gst_element_get_state kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_get_state(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "timeout", NULL };
|
||||
GstState state;
|
||||
GstState pending;
|
||||
GstStateChangeReturn ret;
|
||||
GstClockTime timeout = GST_CLOCK_TIME_NONE;
|
||||
PyObject *tuple;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"|K:GstElement.get_state", kwlist,
|
||||
&timeout)) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Timeout not specified correctly");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
|
||||
ret = gst_element_get_state(GST_ELEMENT (self->obj), &state, &pending,
|
||||
timeout);
|
||||
|
||||
pyg_end_allow_threads;
|
||||
|
||||
tuple = Py_BuildValue("(OOO)",
|
||||
pyg_enum_from_gtype (GST_TYPE_STATE_CHANGE_RETURN, ret),
|
||||
pyg_enum_from_gtype (GST_TYPE_STATE, state),
|
||||
pyg_enum_from_gtype (GST_TYPE_STATE, pending));
|
||||
|
||||
return tuple;
|
||||
}
|
||||
%%
|
||||
override gst_element_link_many args
|
||||
static PyObject *
|
||||
_wrap_gst_element_link_many(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyGObject *element, *element2;
|
||||
int i, len;
|
||||
|
||||
len = PyTuple_Size(args);
|
||||
if (len < 2)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "gst.element_link_many requires at least two argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
element = (PyGObject*)PyTuple_GetItem(args, i);
|
||||
if (!pygobject_check(element, &PyGstElement_Type))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "argument must be a GstElement");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Mimic the real gst_element_link_many */
|
||||
element = (PyGObject*)PyTuple_GetItem(args, 0);
|
||||
element2 = (PyGObject*)PyTuple_GetItem(args, 1);
|
||||
|
||||
i = 2;
|
||||
while (1) {
|
||||
gboolean res;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
res = gst_element_link(GST_ELEMENT(element->obj),
|
||||
GST_ELEMENT(element2->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (!res)
|
||||
{
|
||||
PyErr_Format(PyGstExc_LinkError,
|
||||
"failed to link %s with %s",
|
||||
GST_ELEMENT_NAME(element->obj),
|
||||
GST_ELEMENT_NAME(element2->obj));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (i >= len)
|
||||
break;
|
||||
|
||||
element = element2;
|
||||
element2 = (PyGObject*)PyTuple_GetItem(args, i);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_True);
|
||||
return Py_True;
|
||||
}
|
||||
|
||||
|
||||
%%
|
||||
override gst_element_link kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_link(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "dest", "filtercaps", NULL };
|
||||
PyGObject *dest;
|
||||
PyObject *py_caps = NULL;
|
||||
int ret;
|
||||
GstCaps *caps = NULL;
|
||||
gboolean caps_is_copy;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|O:GstElement.link",
|
||||
kwlist, &PyGstElement_Type, &dest, &py_caps))
|
||||
return NULL;
|
||||
if (py_caps == NULL)
|
||||
caps = NULL;
|
||||
else {
|
||||
caps = pygst_caps_from_pyobject (py_caps, &caps_is_copy);
|
||||
if (caps == NULL)
|
||||
/* an error happened, propagate up */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_element_link_filtered(GST_ELEMENT(self->obj), GST_ELEMENT(dest->obj), caps);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (caps && caps_is_copy)
|
||||
gst_caps_unref (caps);
|
||||
if (!ret) {
|
||||
PyErr_Format(PyGstExc_LinkError,
|
||||
"failed to link %s with %s",
|
||||
GST_ELEMENT_NAME(self->obj),
|
||||
GST_ELEMENT_NAME(dest->obj));
|
||||
return NULL;
|
||||
}
|
||||
return PyBool_FromLong(ret);
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_element_link_filtered kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_link_filtered(PyGObject *self, PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
if (PyErr_Warn(PyExc_DeprecationWarning, "element.link_filtered is deprecated, use element.link") < 0)
|
||||
return NULL;
|
||||
return _wrap_gst_element_link (self, args, kwargs);
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_element_link_pads kwargs
|
||||
static gboolean
|
||||
pad_name_from_object (PyObject *object, const gchar **name)
|
||||
{
|
||||
if (object == Py_None) {
|
||||
*name = NULL;
|
||||
return TRUE;
|
||||
} else if (PyString_Check (object)) {
|
||||
*name = PyString_AsString (object);
|
||||
return TRUE;
|
||||
} else if (pygobject_check (object, &PyGstPad_Type)) {
|
||||
GstObject *obj = GST_OBJECT (pygobject_get (object));
|
||||
pyg_begin_allow_threads;
|
||||
*name = gst_object_get_name (obj);
|
||||
pyg_end_allow_threads;
|
||||
return TRUE;
|
||||
}
|
||||
PyErr_SetString(PyExc_TypeError, "argument could not be converted to a pad");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_element_link_pads(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "srcpadname", "dest", "destpadname", NULL };
|
||||
const char *srcpadname, *destpadname;
|
||||
PyGObject *dest;
|
||||
PyObject *srcpad, *destpad;
|
||||
int ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"OO!O:GstElement.link_pads", kwlist,
|
||||
&srcpad, &PyGstElement_Type, &dest,
|
||||
&destpad))
|
||||
return NULL;
|
||||
if (!pad_name_from_object (srcpad, &srcpadname) ||
|
||||
!pad_name_from_object (destpad, &destpadname))
|
||||
return NULL;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_element_link_pads(GST_ELEMENT(self->obj), srcpadname,
|
||||
GST_ELEMENT(dest->obj), destpadname);
|
||||
pyg_end_allow_threads;
|
||||
if (!ret) {
|
||||
PyErr_SetString(PyGstExc_LinkError, "link failed");
|
||||
return NULL;
|
||||
}
|
||||
return PyBool_FromLong(ret);
|
||||
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_element_link_pads_filtered kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_link_pads_filtered(PyGObject *self, PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "srcpadname", "dest", "destpadname",
|
||||
"filtercaps", NULL };
|
||||
char *srcpadname, *destpadname;
|
||||
PyGObject *dest;
|
||||
int ret;
|
||||
PyObject *py_filtercaps;
|
||||
GstCaps *filtercaps = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"sO!sO:GstElement.link_pads_filtered",
|
||||
kwlist, &srcpadname, &PyGstElement_Type,
|
||||
&dest, &destpadname, &py_filtercaps))
|
||||
return NULL;
|
||||
if (pyg_boxed_check(py_filtercaps, GST_TYPE_CAPS))
|
||||
filtercaps = pyg_boxed_get(py_filtercaps, GstCaps);
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "filtercaps should be a GstCaps");
|
||||
return NULL;
|
||||
}
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_element_link_pads_filtered(GST_ELEMENT(self->obj), srcpadname,
|
||||
GST_ELEMENT(dest->obj), destpadname,
|
||||
filtercaps);
|
||||
pyg_end_allow_threads;
|
||||
if (!ret) {
|
||||
PyErr_SetString(PyGstExc_LinkError, "link failed");
|
||||
return NULL;
|
||||
}
|
||||
return PyBool_FromLong(ret);
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_element_unlink_many args
|
||||
static PyObject *
|
||||
_wrap_gst_element_unlink_many(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyGObject *element, *element2;
|
||||
int i, len;
|
||||
|
||||
len = PyTuple_Size(args);
|
||||
if (len < 2)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "gst.element_unlink_many requires at least two arguments");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
element = (PyGObject*)PyTuple_GetItem(args, i);
|
||||
if (!pygobject_check(element, &PyGstElement_Type))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "argument must be a GstElement");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Mimic the real gst_element_unlink_many */
|
||||
element = (PyGObject*)PyTuple_GetItem(args, 0);
|
||||
element2 = (PyGObject*)PyTuple_GetItem(args, 1);
|
||||
|
||||
i = 2;
|
||||
while (1) {
|
||||
pyg_begin_allow_threads;
|
||||
gst_element_unlink(GST_ELEMENT(element->obj), GST_ELEMENT(element2->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (i >= len)
|
||||
break;
|
||||
|
||||
element = element2;
|
||||
element2 = (PyGObject*)PyTuple_GetItem(args, i);
|
||||
|
||||
i++;
|
||||
}
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_element_send_event kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_send_event(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "event", NULL };
|
||||
PyObject *py_event;
|
||||
int ret;
|
||||
GstEvent *event = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstElement.send_event", kwlist, &py_event))
|
||||
return NULL;
|
||||
if (pygstminiobject_check (py_event, &PyGstEvent_Type)) {
|
||||
event = GST_EVENT (pygstminiobject_get (py_event));
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError, "event should be a GstEvent");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The pipeline unrefs the event, but we want to keep the ownership */
|
||||
gst_event_ref(event);
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_element_send_event(GST_ELEMENT(self->obj), event);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
return PyBool_FromLong(ret);
|
||||
}
|
||||
%%
|
||||
override gst_element_query_position args
|
||||
static PyObject *
|
||||
_wrap_gst_element_query_position (PyGObject *self, PyObject *args)
|
||||
{
|
||||
gint64 cur;
|
||||
gint format;
|
||||
PyObject *pformat;
|
||||
gboolean res;
|
||||
|
||||
pformat = (PyObject*)PyTuple_GetItem(args, 0);
|
||||
if (pyg_enum_get_value (GST_TYPE_FORMAT, pformat, &format)) {
|
||||
PyErr_SetString(PyExc_TypeError, "argument should be a GstFormat");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
res = gst_element_query_position(GST_ELEMENT (self->obj), (GstFormat*) &format, &cur);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (!res) {
|
||||
PyErr_Format(PyGstExc_QueryError,
|
||||
"query failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Py_BuildValue("(LO)", cur,
|
||||
pyg_enum_from_gtype(GST_TYPE_FORMAT, format));
|
||||
}
|
||||
%%
|
||||
override gst_element_query_duration args
|
||||
static PyObject *
|
||||
_wrap_gst_element_query_duration (PyGObject *self, PyObject *args)
|
||||
{
|
||||
gint64 cur;
|
||||
gint format;
|
||||
PyObject *pformat;
|
||||
gboolean res;
|
||||
|
||||
pformat = (PyObject*)PyTuple_GetItem(args, 0);
|
||||
if (pyg_enum_get_value (GST_TYPE_FORMAT, pformat, &format)) {
|
||||
PyErr_SetString(PyExc_TypeError, "argument should be a GstFormat");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
res = gst_element_query_duration(GST_ELEMENT (self->obj), (GstFormat*) &format, &cur);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (!res) {
|
||||
PyErr_Format(PyGstExc_QueryError,
|
||||
"query failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Py_BuildValue("(LO)", cur,
|
||||
pyg_enum_from_gtype(GST_TYPE_FORMAT, format));
|
||||
}
|
||||
%%
|
||||
override gst_element_query_convert kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_query_convert (PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "fromformat", "fromvalue", "destformat", NULL };
|
||||
PyObject *pfromformat, *pdestformat;
|
||||
GstFormat srcformat, destformat;
|
||||
gint64 fromval, dstval;
|
||||
gboolean res;
|
||||
|
||||
/* Input : src_format, src_val, dst_format */
|
||||
/* Returns : dst_format, dst_val OR None */
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"OLO:GstElement.query_convert",
|
||||
kwlist, &pfromformat, &fromval, &pdestformat))
|
||||
return NULL;
|
||||
|
||||
if (pyg_enum_get_value(GST_TYPE_FORMAT, pfromformat, (gint *) &srcformat)) {
|
||||
PyErr_SetString(PyExc_TypeError, "argument should be a GstFormat");
|
||||
return NULL;
|
||||
}
|
||||
if (pyg_enum_get_value(GST_TYPE_FORMAT, pdestformat, (gint *) &destformat)) {
|
||||
PyErr_SetString(PyExc_TypeError, "argument should be a GstFormat");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
res = gst_element_query_convert (GST_ELEMENT(self->obj),
|
||||
srcformat, fromval,
|
||||
&destformat, &dstval);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (!res) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
return Py_BuildValue("(OL)",
|
||||
pyg_enum_from_gtype(GST_TYPE_FORMAT, destformat),
|
||||
dstval);
|
||||
}
|
||||
%%
|
||||
override gst_element_get_query_types noargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_get_query_types (PyGObject *self)
|
||||
{
|
||||
PyObject *ret;
|
||||
PyObject *item;
|
||||
int i;
|
||||
GstQueryType *tab;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
tab = (GstQueryType*) gst_element_get_query_types(GST_ELEMENT(self->obj));
|
||||
pyg_end_allow_threads;
|
||||
if (tab == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
ret = PyList_New(0);
|
||||
for (i = 0; tab[i] != 0; i++) {
|
||||
item = pyg_enum_from_gtype (GST_TYPE_QUERY_TYPE, tab[i]);
|
||||
PyList_Append(ret, item);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override-slot GstElement.tp_iter
|
||||
static PyObject *
|
||||
_wrap_gst_element_tp_iter(PyGObject *self)
|
||||
{
|
||||
return _wrap_gst_element_iterate_pads(self);
|
||||
}
|
||||
%%
|
||||
override gst_element_get_pad_template_list noargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_get_pad_template_list(PyGObject *self)
|
||||
{
|
||||
PyObject *ret;
|
||||
GList *res = NULL;
|
||||
guint i;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
res = gst_element_class_get_pad_template_list
|
||||
(GST_ELEMENT_GET_CLASS (self->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (res) {
|
||||
i = g_list_length (res);
|
||||
ret = PyList_New (i);
|
||||
for (i = 0 ; res ; res = g_list_next (res), i++) {
|
||||
GstPadTemplate * tmpl = (GstPadTemplate *) res->data;
|
||||
PyList_SetItem (ret, i, pygobject_new (G_OBJECT (tmpl)));
|
||||
}
|
||||
} else {
|
||||
ret = Py_None;
|
||||
Py_INCREF (ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override GstElement__proxy_do_request_new_pad
|
||||
static GstPad*
|
||||
_wrap_GstElement__proxy_do_request_new_pad(GstElement *self, GstPadTemplate*templ, const gchar*name)
|
||||
{
|
||||
PyGILState_STATE __py_state;
|
||||
PyObject *py_self;
|
||||
PyObject *py_templ = NULL;
|
||||
PyObject *py_name;
|
||||
GstPad* retval;
|
||||
PyObject *py_retval;
|
||||
PyObject *py_args;
|
||||
PyObject *py_method;
|
||||
|
||||
__py_state = pyg_gil_state_ensure();
|
||||
py_self = pygobject_new((GObject *) self);
|
||||
if (!py_self) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
pyg_gil_state_release(__py_state);
|
||||
return NULL;
|
||||
}
|
||||
if (templ)
|
||||
py_templ = pygobject_new((GObject *) templ);
|
||||
else {
|
||||
Py_INCREF(Py_None);
|
||||
py_templ = Py_None;
|
||||
}
|
||||
|
||||
if (name == NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
py_name = Py_None;
|
||||
} else {
|
||||
py_name = PyString_FromString(name);
|
||||
if (!py_name) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_templ);
|
||||
Py_DECREF(py_self);
|
||||
pyg_gil_state_release(__py_state);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
py_args = PyTuple_New(2);
|
||||
PyTuple_SET_ITEM(py_args, 0, py_templ);
|
||||
PyTuple_SET_ITEM(py_args, 1, py_name);
|
||||
|
||||
py_method = PyObject_GetAttrString(py_self, "do_request_new_pad");
|
||||
if (!py_method) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
pyg_gil_state_release(__py_state);
|
||||
return NULL;
|
||||
}
|
||||
py_retval = PyObject_CallObject(py_method, py_args);
|
||||
if (!py_retval) {
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
pyg_gil_state_release(__py_state);
|
||||
return NULL;
|
||||
}
|
||||
if (!PyObject_TypeCheck(py_retval, &PyGObject_Type)) {
|
||||
PyErr_SetString(PyExc_TypeError, "retval should be a GObject");
|
||||
PyErr_Print();
|
||||
Py_DECREF(py_retval);
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
pyg_gil_state_release(__py_state);
|
||||
return NULL;
|
||||
}
|
||||
retval = (GstPad*) pygobject_get(py_retval);
|
||||
g_object_ref((GObject *) retval);
|
||||
|
||||
|
||||
Py_DECREF(py_retval);
|
||||
Py_DECREF(py_method);
|
||||
Py_DECREF(py_args);
|
||||
Py_DECREF(py_self);
|
||||
pyg_gil_state_release(__py_state);
|
||||
|
||||
return retval;
|
||||
}
|
|
@ -1,153 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* gstelementfactory.override - gstreamer element factory override
|
||||
* Copyright (C) 2005 Alessandro Decina
|
||||
*
|
||||
* Authors:
|
||||
* Alessandro Decina <alessandro@nnva.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
%%
|
||||
override gst_element_factory_make kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_factory_make(PyObject *self, PyObject *args, PyObject *kwargs){
|
||||
static char *kwlist[] = { "factoryname", "name", NULL };
|
||||
char *factoryname, *name = NULL;
|
||||
PyObject *py_ret;
|
||||
GstElement *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z:element_factory_make", kwlist, &factoryname, &name))
|
||||
return NULL;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_element_factory_make(factoryname, name);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (ret == NULL) {
|
||||
PyErr_SetString(PyGstExc_ElementNotFoundError, factoryname);
|
||||
return NULL;
|
||||
}
|
||||
py_ret = pygobject_new((GObject *)ret);
|
||||
g_object_unref((GObject *)ret);
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override gst_element_factory_get_static_pad_templates noargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_factory_get_static_pad_templates(PyGObject *self)
|
||||
{
|
||||
const GList *list;
|
||||
GList *l;
|
||||
PyObject *py_list;
|
||||
int i = 0;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
list = gst_element_factory_get_static_pad_templates (GST_ELEMENT_FACTORY (self->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
py_list = PyList_New(g_list_length ((GList*) list));
|
||||
|
||||
for (l = (GList*) list; l ; l = g_list_next(l), i++) {
|
||||
GstStaticPadTemplate *templ = (GstStaticPadTemplate*) l->data;
|
||||
PyList_SetItem(py_list, i, pyg_pointer_new(GST_TYPE_STATIC_PAD_TEMPLATE, (gpointer) templ));
|
||||
}
|
||||
return py_list;
|
||||
}
|
||||
%%
|
||||
override gst_element_factory_list_get_elements kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_factory_list_get_elements(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "type", "minrank", NULL };
|
||||
PyObject *py_minrank;
|
||||
GstRank minrank;
|
||||
GstElementFactoryListType listype;
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"KO:element_factory_list_get_elements", kwlist,
|
||||
&listype, &py_minrank))
|
||||
return NULL;
|
||||
if (pyg_enum_get_value(GST_TYPE_RANK, py_minrank, (gint *)&minrank))
|
||||
return NULL;
|
||||
pyg_begin_allow_threads;
|
||||
res = gst_element_factory_list_get_elements(listype, minrank);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
GstElementFactory *fact = (GstElementFactory*) tmp->data;
|
||||
PyObject *ltmp = pygobject_new (G_OBJECT (fact));
|
||||
|
||||
PyList_Append(pyres, ltmp);
|
||||
}
|
||||
gst_plugin_feature_list_free (res);
|
||||
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_element_factory_list_filter kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_element_factory_list_filter(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "list", "caps", "direction", "subsetonly", NULL };
|
||||
PyObject *py_list, *py_caps, *py_direction;
|
||||
GList *inlist = NULL;
|
||||
GList *res, *tmp;
|
||||
GstCaps *caps;
|
||||
GstPadDirection direction;
|
||||
gboolean subsetonly, caps_is_copy;
|
||||
PyObject *pyres;
|
||||
guint i, n;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OOOi:element_factory_list_filter", kwlist,
|
||||
&py_list, &py_caps, &py_direction, &subsetonly))
|
||||
return NULL;
|
||||
if (!PyList_Check (py_list))
|
||||
return NULL;
|
||||
if (pyg_enum_get_value(GST_TYPE_PAD_DIRECTION, py_direction, (gint *)&direction))
|
||||
return NULL;
|
||||
caps = pygst_caps_from_pyobject(py_caps, &caps_is_copy);
|
||||
n = PyList_GET_SIZE(py_list);
|
||||
for (i = 0; i < n; i++) {
|
||||
/* Get Object */
|
||||
inlist = g_list_append(inlist, pygobject_get (PyList_GET_ITEM (py_list, i)));
|
||||
}
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
res = gst_element_factory_list_filter(inlist, caps, direction, subsetonly);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
GstElementFactory *fact = (GstElementFactory*) tmp->data;
|
||||
PyObject *ltmp = pygobject_new (G_OBJECT (fact));
|
||||
|
||||
PyList_Append(pyres, ltmp);
|
||||
}
|
||||
|
||||
gst_plugin_feature_list_free (res);
|
||||
if (caps && caps_is_copy)
|
||||
gst_caps_unref (caps);
|
||||
if (inlist)
|
||||
g_list_free (inlist);
|
||||
|
||||
return pyres;
|
||||
}
|
||||
|
||||
|
|
@ -1,331 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "k&r"; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Edward Hervey
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
%%
|
||||
override gst_event_get_structure noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_get_structure(PyGstMiniObject *self)
|
||||
{
|
||||
GstStructure *ret;
|
||||
|
||||
ret = (GstStructure *) gst_event_get_structure(GST_EVENT(self->obj));
|
||||
/* pyg_boxed_new handles NULL checking */
|
||||
return pyg_boxed_new(GST_TYPE_STRUCTURE, ret, TRUE, TRUE);
|
||||
}
|
||||
|
||||
%%
|
||||
override-slot GstEvent.tp_repr
|
||||
static PyObject *
|
||||
_wrap_gst_event_tp_repr (PyGObject *self)
|
||||
{
|
||||
char *buf;
|
||||
PyObject *retval;
|
||||
GstEvent *event;
|
||||
|
||||
event = GST_EVENT(self->obj);
|
||||
|
||||
buf = g_strdup_printf ("<GstEvent (%s) at %lx>",
|
||||
gst_event_type_get_name (event->type), (long) self->obj);
|
||||
|
||||
retval = PyString_FromString(buf);
|
||||
g_free(buf);
|
||||
return retval;
|
||||
}
|
||||
%%
|
||||
override gst_event_parse_new_segment noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_parse_new_segment (PyGstMiniObject *self)
|
||||
{
|
||||
gboolean update;
|
||||
gdouble rate;
|
||||
GstFormat format;
|
||||
gint64 start_value, stop_value, base;
|
||||
|
||||
if (GST_EVENT_TYPE(self->obj) != GST_EVENT_NEWSEGMENT) {
|
||||
PyErr_SetString(PyExc_TypeError, "Event is not a 'NewSegment' event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_event_parse_new_segment (GST_EVENT(self->obj), &update, &rate, &format,
|
||||
&start_value, &stop_value, &base);
|
||||
|
||||
return Py_BuildValue("(OdOLLL)",
|
||||
PyBool_FromLong(update),
|
||||
rate, pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
start_value, stop_value, base);
|
||||
}
|
||||
%%
|
||||
override gst_event_parse_tag noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_parse_tag (PyGstMiniObject *self)
|
||||
{
|
||||
PyObject *ret;
|
||||
GstTagList *taglist;
|
||||
|
||||
if (GST_EVENT_TYPE(self->obj) != GST_EVENT_TAG) {
|
||||
PyErr_SetString(PyExc_TypeError, "Event is not an 'Tag' event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_event_parse_tag (GST_EVENT(self->obj), &taglist);
|
||||
|
||||
ret = pyg_boxed_new (GST_TYPE_TAG_LIST, taglist, TRUE, TRUE);
|
||||
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override gst_event_parse_qos noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_parse_qos (PyGstMiniObject *self)
|
||||
{
|
||||
gdouble proportion;
|
||||
GstClockTimeDiff diff;
|
||||
GstClockTime timestamp;
|
||||
|
||||
if (GST_EVENT_TYPE(self->obj) != GST_EVENT_QOS) {
|
||||
PyErr_SetString(PyExc_TypeError, "Event is not an 'Qos' event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_event_parse_qos (GST_EVENT(self->obj), &proportion,
|
||||
&diff, ×tamp);
|
||||
|
||||
return Py_BuildValue("(dLK)", proportion, diff, timestamp);
|
||||
}
|
||||
%%
|
||||
override gst_event_parse_seek noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_parse_seek (PyGstMiniObject *self)
|
||||
{
|
||||
gdouble rate;
|
||||
GstFormat format;
|
||||
GstSeekFlags flags;
|
||||
GstSeekType cur_type;
|
||||
gint64 cur;
|
||||
GstSeekType stop_type;
|
||||
gint64 stop;
|
||||
|
||||
if (GST_EVENT_TYPE(self->obj) != GST_EVENT_SEEK) {
|
||||
PyErr_SetString(PyExc_TypeError, "Event is not an 'Seek' event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_event_parse_seek (GST_EVENT(self->obj), &rate, &format, &flags,
|
||||
&cur_type, &cur, &stop_type, &stop);
|
||||
|
||||
return Py_BuildValue("(dOOOLOL)",
|
||||
rate,
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
pyg_flags_from_gtype (GST_TYPE_SEEK_FLAGS, flags),
|
||||
pyg_enum_from_gtype (GST_TYPE_SEEK_TYPE, cur_type),
|
||||
cur,
|
||||
pyg_enum_from_gtype (GST_TYPE_SEEK_TYPE, stop_type),
|
||||
stop);
|
||||
}
|
||||
%%
|
||||
override gst_event_parse_buffer_size noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_parse_buffer_size (PyGstMiniObject *self)
|
||||
{
|
||||
GstFormat format;
|
||||
gint64 minsize;
|
||||
gint64 maxsize;
|
||||
gboolean async;
|
||||
|
||||
if (GST_EVENT_TYPE (self->obj) != GST_EVENT_BUFFERSIZE) {
|
||||
PyErr_SetString(PyExc_TypeError, "Event is not an 'BufferSize' event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_event_parse_buffer_size (GST_EVENT (self->obj),
|
||||
&format, &minsize,
|
||||
&maxsize, &async);
|
||||
|
||||
return Py_BuildValue("(OLLO)",
|
||||
pyg_enum_from_gtype(GST_TYPE_FORMAT, format),
|
||||
minsize, maxsize,
|
||||
PyBool_FromLong(async));
|
||||
}
|
||||
%%
|
||||
override gst_event_parse_latency noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_parse_latency (PyGstMiniObject * self)
|
||||
{
|
||||
GstClockTime ctime = GST_CLOCK_TIME_NONE;
|
||||
|
||||
if (GST_EVENT_TYPE (self->obj) != GST_EVENT_LATENCY) {
|
||||
PyErr_SetString(PyExc_TypeError, "Event is not a 'latency' event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_event_parse_latency (GST_EVENT (self->obj), &ctime);
|
||||
|
||||
return PyLong_FromUnsignedLongLong(ctime);
|
||||
}
|
||||
%%
|
||||
override gst_event_new_navigation kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_new_navigation(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "structure", NULL };
|
||||
PyObject *py_structure, *py_ret;
|
||||
GstEvent *ret;
|
||||
GstStructure *structure = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:event_new_navigation", kwlist, &py_structure))
|
||||
return NULL;
|
||||
if (pyg_boxed_check(py_structure, GST_TYPE_STRUCTURE))
|
||||
structure = pyg_boxed_get(py_structure, GstStructure);
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "structure should be a GstStructure");
|
||||
return NULL;
|
||||
}
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_event_new_navigation(gst_structure_copy(structure));
|
||||
pyg_end_allow_threads;
|
||||
py_ret = pygstminiobject_new((GstMiniObject *)ret);
|
||||
if (ret != NULL)
|
||||
gst_mini_object_unref((GstMiniObject *)ret);
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override gst_event_new_custom kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_new_custom(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "type", "structure", NULL };
|
||||
PyObject *py_type = NULL, *py_structure, *py_ret;
|
||||
GstEvent *ret;
|
||||
GstStructure *structure = NULL;
|
||||
GstEventType type;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OO:event_new_custom", kwlist, &py_type, &py_structure))
|
||||
return NULL;
|
||||
if (pyg_enum_get_value(GST_TYPE_EVENT_TYPE, py_type, (gint *)&type))
|
||||
return NULL;
|
||||
if (pyg_boxed_check(py_structure, GST_TYPE_STRUCTURE))
|
||||
structure = pyg_boxed_get(py_structure, GstStructure);
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "structure should be a GstStructure");
|
||||
return NULL;
|
||||
}
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_event_new_custom(type, gst_structure_copy(structure));
|
||||
pyg_end_allow_threads;
|
||||
py_ret = pygstminiobject_new((GstMiniObject *)ret);
|
||||
if (ret != NULL)
|
||||
gst_mini_object_unref((GstMiniObject *)ret);
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override gst_event_new_tag kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_new_tag(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "taglist", NULL };
|
||||
GstTagList *taglist = NULL;
|
||||
PyObject *py_taglist, *py_ret;
|
||||
GstEvent *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:event_new_tag", kwlist, &py_taglist))
|
||||
return NULL;
|
||||
if (pyg_boxed_check(py_taglist, GST_TYPE_TAG_LIST))
|
||||
taglist = pyg_boxed_get(py_taglist, GstTagList);
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "taglist should be a GstTagList");
|
||||
return NULL;
|
||||
}
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_event_new_tag(gst_tag_list_copy(taglist));
|
||||
pyg_end_allow_threads;
|
||||
py_ret = pygstminiobject_new((GstMiniObject *)ret);
|
||||
if (ret != NULL)
|
||||
gst_mini_object_unref((GstMiniObject *)ret);
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override gst_event_parse_step noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_parse_step (PyGstMiniObject * self)
|
||||
{
|
||||
GstFormat format;
|
||||
guint64 amount;
|
||||
gdouble rate;
|
||||
gboolean flush, intermediate;
|
||||
|
||||
if (GST_EVENT_TYPE (self->obj) != GST_EVENT_STEP) {
|
||||
PyErr_SetString(PyExc_TypeError, "Event is not a 'step' event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_event_parse_step (GST_EVENT (self->obj), &format, &amount, &rate,
|
||||
&flush, &intermediate);
|
||||
|
||||
return Py_BuildValue("OKdOO",
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
amount, rate,
|
||||
PyBool_FromLong(flush),
|
||||
PyBool_FromLong(intermediate));
|
||||
}
|
||||
%%
|
||||
override gst_event_parse_new_segment_full noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_parse_new_segment_full (PyGstMiniObject *self)
|
||||
{
|
||||
gboolean update;
|
||||
gdouble rate, applied_rate;
|
||||
GstFormat format;
|
||||
gint64 start_value, stop_value, base;
|
||||
|
||||
if (GST_EVENT_TYPE(self->obj) != GST_EVENT_NEWSEGMENT) {
|
||||
PyErr_SetString(PyExc_TypeError, "Event is not a 'NewSegment' event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_event_parse_new_segment_full (GST_EVENT(self->obj), &update, &rate,
|
||||
&applied_rate, &format,
|
||||
&start_value, &stop_value, &base);
|
||||
|
||||
return Py_BuildValue("(OddOLLL)",
|
||||
PyBool_FromLong(update),
|
||||
rate, applied_rate, pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
start_value, stop_value, base);
|
||||
}
|
||||
%%
|
||||
override gst_event_parse_sink_message noargs
|
||||
static PyObject *
|
||||
_wrap_gst_event_parse_sink_message (PyGstMiniObject *self)
|
||||
{
|
||||
GstMessage *message;
|
||||
|
||||
if (GST_EVENT_TYPE(self->obj) != GST_EVENT_SINK_MESSAGE) {
|
||||
PyErr_SetString(PyExc_TypeError, "Event is not a 'SinkMessage' event");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_event_parse_sink_message (GST_EVENT(self->obj), &message);
|
||||
|
||||
if (message)
|
||||
return pygstminiobject_new (GST_MINI_OBJECT (message));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
|
@ -1,402 +0,0 @@
|
|||
/* -*- Mode: C; ; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Edward Hervey
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
%%
|
||||
ignore
|
||||
gst_controller_new
|
||||
gst_controller_*_valist
|
||||
gst_controller_remove_properties_list
|
||||
|
||||
%%
|
||||
override gst_controller_set args
|
||||
static PyObject *
|
||||
_wrap_gst_controller_set (PyGObject *self, PyObject *args)
|
||||
{
|
||||
GstController *controller = (GstController *) self->obj;
|
||||
gchar *param_name;
|
||||
GParamSpec *pspec = NULL;
|
||||
GstClockTime timestamp;
|
||||
GValue value = { 0, };
|
||||
PyObject *pvalue;
|
||||
gboolean res;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sLO:GstController.set",
|
||||
¶m_name, ×tamp, &pvalue))
|
||||
return NULL;
|
||||
|
||||
if (!(pspec = g_object_class_find_property(G_OBJECT_GET_CLASS (controller->object),
|
||||
(const gchar*) param_name))) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"The controlled object doesn't have the given property");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
g_value_init (&value, pspec->value_type);
|
||||
|
||||
if (pyg_value_from_pyobject (&value, pvalue)) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"Couldn't convert the given value to the good type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res = gst_controller_set (controller, param_name, timestamp, &value);
|
||||
if (res) {
|
||||
Py_INCREF (Py_True);
|
||||
return Py_True;
|
||||
}
|
||||
Py_INCREF (Py_False);
|
||||
return Py_False;
|
||||
}
|
||||
%%
|
||||
override gst_controller_get kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_controller_get (PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
GstController *controller = (GstController *) self->obj;
|
||||
static char *kwlist[] = { "propertyname", "timestamp", NULL };
|
||||
gchar *propertyname;
|
||||
GstClockTime timestamp;
|
||||
GValue *value = NULL;
|
||||
PyObject *pyvalue;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kwargs,
|
||||
"sL:GstController.get",
|
||||
kwlist, &propertyname, ×tamp))
|
||||
return NULL;
|
||||
|
||||
value = gst_controller_get (controller, propertyname, timestamp);
|
||||
if (value) {
|
||||
pyvalue = pyg_value_as_pyobject (value, FALSE);
|
||||
return pyvalue;
|
||||
}
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_controller_new_list args
|
||||
static int
|
||||
_wrap_gst_controller_new_list(PyGObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *target_pyobj;
|
||||
PyGObject *target;
|
||||
gint len;
|
||||
GList *list = NULL;
|
||||
|
||||
if ((len = PyTuple_Size(args)) < 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "Controller requires at least a target object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
target_pyobj = PyTuple_GetItem(args, 0);
|
||||
if (!PyObject_TypeCheck(target_pyobj, &PyGObject_Type)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"argument 1 must be %s, not %s",
|
||||
PyGObject_Type.tp_name,
|
||||
target_pyobj == Py_None ? "None" : target_pyobj->ob_type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
target = (PyGObject *) target_pyobj;
|
||||
|
||||
if (len > 1)
|
||||
while (len-- > 1) {
|
||||
PyObject *temp;
|
||||
gchar *str;
|
||||
|
||||
temp = PyTuple_GetItem(args, len);
|
||||
str = PyString_AsString(temp);
|
||||
if (str == NULL) {
|
||||
g_list_free (list);
|
||||
return -1;
|
||||
}
|
||||
GST_INFO("prepending %s [%d]", str, len);
|
||||
list = g_list_prepend(list, str);
|
||||
}
|
||||
|
||||
self->obj = (GObject *) gst_controller_new_list(target->obj, list);
|
||||
g_list_free (list);
|
||||
|
||||
if (!self->obj) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "could not create GstController object");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pygobject_register_wrapper((PyObject *) self);
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override gst_controller_remove_properties args
|
||||
static PyObject *
|
||||
_wrap_gst_controller_remove_properties (PyGObject *self, PyObject *args)
|
||||
{
|
||||
GstController *controller = (GstController *) self->obj;
|
||||
gint len;
|
||||
GList *list = NULL;
|
||||
gboolean res = FALSE;
|
||||
PyObject *pret;
|
||||
|
||||
if ((len = PyTuple_Size(args)) < 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "Please give at least one property name to remove");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (len--) {
|
||||
PyObject *temp;
|
||||
gchar *str;
|
||||
|
||||
temp = PyTuple_GetItem(args, len);
|
||||
str = PyString_AsString(temp);
|
||||
if (str == NULL) {
|
||||
g_list_free (list);
|
||||
return NULL;
|
||||
}
|
||||
GST_INFO("prepending %s [%d]", str, len);
|
||||
list = g_list_prepend(list, str);
|
||||
}
|
||||
|
||||
res = gst_controller_remove_properties_list(controller, list);
|
||||
g_list_free (list);
|
||||
|
||||
if (res)
|
||||
pret = Py_True;
|
||||
else
|
||||
pret = Py_False;
|
||||
|
||||
Py_INCREF (pret);
|
||||
|
||||
return pret;
|
||||
}
|
||||
%%
|
||||
override gst_controller_set_from_list args
|
||||
static PyObject *
|
||||
_wrap_gst_controller_set_from_list (PyGObject *self, PyObject *args)
|
||||
{
|
||||
GstController *controller = (GstController *) self->obj;
|
||||
PyObject *temp;
|
||||
gint len;
|
||||
gchar *pname;
|
||||
GSList *list = NULL;
|
||||
GParamSpec *pspec = NULL;
|
||||
gboolean res = FALSE;
|
||||
PyObject *pret;
|
||||
|
||||
if ((len = PyTuple_Size(args)) < 2) {
|
||||
PyErr_SetString(PyExc_TypeError, "Please give a property name and a tuple of (time,value)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
temp = PyTuple_GetItem(args, 0);
|
||||
if (!PyString_Check (temp)) {
|
||||
PyErr_SetString(PyExc_TypeError, "First argument must be a string");
|
||||
return NULL;
|
||||
}
|
||||
pname = PyString_AsString(temp);
|
||||
|
||||
if (!(pspec = g_object_class_find_property(G_OBJECT_GET_CLASS (controller->object),
|
||||
(const gchar*) pname)))
|
||||
goto error;
|
||||
|
||||
while (len-- > 1) {
|
||||
PyObject *temp2;
|
||||
GstTimedValue *tval;
|
||||
|
||||
temp2 = PyTuple_GetItem(args, len);
|
||||
if (!PyTuple_Check (temp2)) {
|
||||
PyErr_SetString (PyExc_TypeError, "Tuple doesn't contain tuples !");
|
||||
goto error;
|
||||
}
|
||||
tval = g_new0(GstTimedValue, 1);
|
||||
tval->timestamp = PyLong_AsUnsignedLongLong(PyTuple_GetItem(temp2, 0));
|
||||
g_value_init (&tval->value, pspec->value_type);
|
||||
if ((pyg_value_from_pyobject (&tval->value, PyTuple_GetItem (temp2, 1))) < 0) {
|
||||
PyErr_SetString (PyExc_TypeError, "Couldn't convert value to correct type");
|
||||
goto error;
|
||||
};
|
||||
|
||||
list = g_slist_prepend(list, tval);
|
||||
}
|
||||
|
||||
res = gst_controller_set_from_list(controller, pname, list);
|
||||
g_slist_free (list);
|
||||
|
||||
if (res)
|
||||
pret = Py_True;
|
||||
else
|
||||
pret = Py_False;
|
||||
|
||||
Py_INCREF (pret);
|
||||
|
||||
return pret;
|
||||
|
||||
error:
|
||||
while (list) {
|
||||
g_free(list->data);
|
||||
list = g_slist_next(list);
|
||||
}
|
||||
g_slist_free (list);
|
||||
return NULL;
|
||||
}
|
||||
%%
|
||||
override gst_dp_header_payload_length kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_dp_header_payload_length(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "header", NULL };
|
||||
char *header;
|
||||
gulong ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:dp_header_payload_length", kwlist, &header))
|
||||
return NULL;
|
||||
ret = gst_dp_header_payload_length((guint8*)header);
|
||||
return PyLong_FromUnsignedLong(ret);
|
||||
}
|
||||
%%
|
||||
overrid gst_dp_header_payload_type kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_dp_header_payload_type(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "header", NULL };
|
||||
char *header;
|
||||
gint ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:dp_header_payload_type", kwlist, &header))
|
||||
return NULL;
|
||||
ret = gst_dp_header_payload_type((guint8*)header);
|
||||
return pyg_enum_from_gtype(G_TYPE_NONE, ret);
|
||||
}
|
||||
%%
|
||||
override gst_dp_buffer_from_header kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_dp_buffer_from_header(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "header_length", "header", NULL };
|
||||
char *header;
|
||||
GstBuffer *ret;
|
||||
guint header_length;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Is:dp_buffer_from_header", kwlist, &header_length, &header))
|
||||
return NULL;
|
||||
ret = gst_dp_buffer_from_header(header_length, (guint8*)header);
|
||||
/* pygobject_new handles NULL checking */
|
||||
return pygstminiobject_new((GstMiniObject *)ret);
|
||||
}
|
||||
%%
|
||||
override gst_dp_caps_from_packet kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_dp_caps_from_packet(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "header_length", "header", "payload", NULL };
|
||||
char *header, *payload;
|
||||
GstCaps *ret;
|
||||
guint header_length;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Iss:dp_caps_from_packet", kwlist, &header_length, &header, &payload))
|
||||
return NULL;
|
||||
ret = gst_dp_caps_from_packet(header_length,
|
||||
(guint8*) header,
|
||||
(guint8*) payload);
|
||||
return pyg_boxed_new (GST_TYPE_CAPS, ret, FALSE, TRUE);
|
||||
}
|
||||
%%
|
||||
override gst_dp_event_from_packet kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_dp_event_from_packet(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "header_length", "header", "payload", NULL };
|
||||
char *header, *payload;
|
||||
GstEvent *ret;
|
||||
guint header_length;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Iss:dp_event_from_packet", kwlist, &header_length, &header, &payload))
|
||||
return NULL;
|
||||
ret = gst_dp_event_from_packet(header_length,
|
||||
(guint8*) header,
|
||||
(guint8*) payload);
|
||||
/* pygobject_new handles NULL checking */
|
||||
return pygstminiobject_new((GstMiniObject *)ret);
|
||||
}
|
||||
%%
|
||||
override gst_dp_validate_header kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_dp_validate_header(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "header_length", "header", NULL };
|
||||
char *header;
|
||||
int ret;
|
||||
guint header_length;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Is:dp_validate_header", kwlist, &header_length, &header))
|
||||
return NULL;
|
||||
ret = gst_dp_validate_header(header_length, (guint8*) header);
|
||||
return PyBool_FromLong(ret);
|
||||
|
||||
}
|
||||
%%
|
||||
override gst_dp_validate_payload kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_dp_validate_payload(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "header_length", "header", "payload", NULL };
|
||||
char *header, *payload;
|
||||
int ret;
|
||||
guint header_length;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Iss:dp_validate_payload", kwlist, &header_length, &header, &payload))
|
||||
return NULL;
|
||||
ret = gst_dp_validate_payload(header_length,
|
||||
(guint8*) header,
|
||||
(guint8*) payload);
|
||||
return PyBool_FromLong(ret);
|
||||
|
||||
}
|
||||
%%
|
||||
override gst_dp_validate_packet kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_dp_validate_packet(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "header_length", "header", "payload", NULL };
|
||||
char *header, *payload;
|
||||
int ret;
|
||||
guint header_length;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Iss:dp_validate_packet", kwlist, &header_length, &header, &payload))
|
||||
return NULL;
|
||||
ret = gst_dp_validate_packet(header_length,
|
||||
(guint8*) header,
|
||||
(guint8*) payload);
|
||||
return PyBool_FromLong(ret);
|
||||
|
||||
}
|
||||
%%
|
||||
override gst_dp_header_payload_type kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_dp_header_payload_type(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "header", NULL };
|
||||
char *header;
|
||||
gint ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:dp_header_payload_type", kwlist, &header))
|
||||
return NULL;
|
||||
ret = gst_dp_header_payload_type((guint8*) header);
|
||||
return pyg_enum_from_gtype(G_TYPE_NONE, ret);
|
||||
}
|
||||
|
|
@ -1,540 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Edward Hervey
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
|
||||
%%
|
||||
override-slot GstMessage.tp_repr
|
||||
static PyObject *
|
||||
_wrap_gst_message_tp_repr (PyGstMiniObject *self)
|
||||
{
|
||||
GstMessage *msg;
|
||||
gchar *repr, *structure_str, *src_str;
|
||||
PyObject *ret;
|
||||
|
||||
g_assert (self);
|
||||
msg = GST_MESSAGE (self->obj);
|
||||
g_assert (msg);
|
||||
|
||||
structure_str = msg->structure ? gst_structure_to_string (msg->structure)
|
||||
: g_strdup ("(none)");
|
||||
if (msg->src) {
|
||||
pyg_begin_allow_threads;
|
||||
src_str = gst_object_get_name (msg->src);
|
||||
pyg_end_allow_threads;
|
||||
} else {
|
||||
src_str = g_strdup ("(no src)");
|
||||
}
|
||||
|
||||
repr = g_strdup_printf ("<gst.Message %s from %s at %p>",
|
||||
structure_str, src_str, msg);
|
||||
g_free (src_str);
|
||||
g_free (structure_str);
|
||||
|
||||
ret = PyString_FromStringAndSize(repr, strlen (repr));
|
||||
g_free (repr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_message_parse_state_changed noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_state_changed (PyGstMiniObject *self)
|
||||
{
|
||||
GstState old;
|
||||
GstState new;
|
||||
GstState pen;
|
||||
|
||||
/* Should raise an exception if it's not a state-changed message */
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_STATE_CHANGED) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a state-changed message");
|
||||
return NULL;
|
||||
}
|
||||
gst_message_parse_state_changed (GST_MESSAGE(self->obj), &old, &new, &pen);
|
||||
|
||||
return Py_BuildValue("[OOO]",
|
||||
pyg_enum_from_gtype(GST_TYPE_STATE, old),
|
||||
pyg_enum_from_gtype(GST_TYPE_STATE, new),
|
||||
pyg_enum_from_gtype(GST_TYPE_STATE, pen));
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_segment_start noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_segment_start (PyGstMiniObject *self)
|
||||
{
|
||||
gint64 position;
|
||||
GstFormat format;
|
||||
|
||||
/* Should raise an exception if it's not a segment start message */
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_SEGMENT_START) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a segment start message");
|
||||
return NULL;
|
||||
}
|
||||
gst_message_parse_segment_start (GST_MESSAGE(self->obj), &format, &position);
|
||||
|
||||
return Py_BuildValue("(OL)",
|
||||
pyg_enum_from_gtype(GST_TYPE_FORMAT, format),
|
||||
position);
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_message_parse_segment_done noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_segment_done (PyGstMiniObject *self)
|
||||
{
|
||||
gint64 position;
|
||||
GstFormat format;
|
||||
|
||||
/* Should raise an exception if it's not a segment done message */
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_SEGMENT_DONE) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a segment done message");
|
||||
return NULL;
|
||||
}
|
||||
gst_message_parse_segment_done (GST_MESSAGE(self->obj), &format, &position);
|
||||
|
||||
return Py_BuildValue("(OL)",
|
||||
pyg_enum_from_gtype(GST_TYPE_FORMAT, format),
|
||||
position);
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_message_parse_error noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_error (PyGstMiniObject *self)
|
||||
{
|
||||
PyObject *ret;
|
||||
GError *error = NULL;
|
||||
gchar *debug;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_ERROR) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an error message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_error (GST_MESSAGE(self->obj), &error, &debug);
|
||||
|
||||
ret = PyList_New(2);
|
||||
PyList_SetItem(ret, 0, pyg_boxed_new (GST_TYPE_G_ERROR, error, TRUE, TRUE));
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
if (debug != NULL) {
|
||||
PyList_SetItem(ret, 1, PyString_FromString(debug));
|
||||
} else {
|
||||
Py_INCREF (Py_None);
|
||||
PyList_SetItem(ret, 1, Py_None);
|
||||
}
|
||||
g_free(debug);
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_warning noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_warning (PyGstMiniObject *self)
|
||||
{
|
||||
PyObject *ret;
|
||||
GError *warning = NULL;
|
||||
gchar *debug;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_WARNING) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an warning message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_warning (GST_MESSAGE(self->obj), &warning, &debug);
|
||||
|
||||
ret = PyList_New(2);
|
||||
PyList_SetItem(ret, 0, pyg_boxed_new (GST_TYPE_G_ERROR, warning, TRUE, TRUE));
|
||||
if (warning)
|
||||
g_error_free (warning);
|
||||
if (debug != NULL) {
|
||||
PyList_SetItem(ret, 1, PyString_FromString(debug));
|
||||
} else {
|
||||
Py_INCREF (Py_None);
|
||||
PyList_SetItem(ret, 1, Py_None);
|
||||
}
|
||||
g_free(debug);
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_info noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_info (PyGstMiniObject *self)
|
||||
{
|
||||
PyObject *ret;
|
||||
GError *info = NULL;
|
||||
gchar *debug;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_INFO) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an info message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_info (GST_MESSAGE(self->obj), &info, &debug);
|
||||
|
||||
ret = PyList_New(2);
|
||||
PyList_SetItem(ret, 0, pyg_boxed_new (GST_TYPE_G_ERROR, info, TRUE, TRUE));
|
||||
if (info)
|
||||
g_error_free (info);
|
||||
if (debug != NULL) {
|
||||
PyList_SetItem(ret, 1, PyString_FromString(debug));
|
||||
} else {
|
||||
Py_INCREF (Py_None);
|
||||
PyList_SetItem(ret, 1, Py_None);
|
||||
}
|
||||
g_free(debug);
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_tag noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_tag (PyGstMiniObject *self)
|
||||
{
|
||||
PyObject *ret;
|
||||
GstTagList *taglist;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_TAG) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an Tag message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_tag (GST_MESSAGE(self->obj), &taglist);
|
||||
|
||||
ret = pyg_boxed_new (GST_TYPE_TAG_LIST, taglist, TRUE, TRUE);
|
||||
gst_tag_list_free (taglist);
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_clock_provide noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_clock_provide (PyGstMiniObject *self)
|
||||
{
|
||||
GstClock *clock;
|
||||
gboolean ready;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_CLOCK_PROVIDE) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a 'clock provide' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_clock_provide (GST_MESSAGE(self->obj), &clock, &ready);
|
||||
|
||||
return Py_BuildValue("(OO)",
|
||||
pygobject_new(G_OBJECT (clock)),
|
||||
PyBool_FromLong(ready));
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_clock_lost noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_clock_lost (PyGstMiniObject *self)
|
||||
{
|
||||
GstClock *clock;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_CLOCK_LOST) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a 'clock lost' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_clock_lost (GST_MESSAGE(self->obj), &clock);
|
||||
|
||||
return pygobject_new(G_OBJECT(clock));
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_new_clock noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_new_clock (PyGstMiniObject *self)
|
||||
{
|
||||
GstClock *clock;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_NEW_CLOCK) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a 'new clock' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_new_clock (GST_MESSAGE(self->obj), &clock);
|
||||
|
||||
return pygobject_new(G_OBJECT(clock));
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_duration noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_duration (PyGstMiniObject *self)
|
||||
{
|
||||
GstFormat format;
|
||||
gint64 duration;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_DURATION) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a 'duration' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_duration (GST_MESSAGE(self->obj), &format, &duration);
|
||||
|
||||
return Py_BuildValue("(OL)",
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
duration);
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_async_start noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_async_start (PyGstMiniObject *self)
|
||||
{
|
||||
gboolean res = FALSE;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_ASYNC_START) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'async-start' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_async_start (GST_MESSAGE(self->obj), &res);
|
||||
|
||||
return PyBool_FromLong (res);
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_buffering noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_buffering (PyGstMiniObject *self)
|
||||
{
|
||||
gint percent;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_BUFFERING) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a 'buffering' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_buffering (GST_MESSAGE(self->obj), &percent);
|
||||
|
||||
return Py_BuildValue("i", percent);
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_tag_full noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_tag_full (PyGstMiniObject *self)
|
||||
{
|
||||
GstPad *pad;
|
||||
GstTagList *taglist;
|
||||
PyObject *ptlist;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_TAG) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an Tag message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_tag_full (GST_MESSAGE (self->obj), &pad, &taglist);
|
||||
ptlist = pyg_boxed_new (GST_TYPE_TAG_LIST, taglist, TRUE, TRUE);
|
||||
gst_tag_list_free (taglist);
|
||||
|
||||
return Py_BuildValue("(OO)",
|
||||
pygobject_new((GObject*) pad),
|
||||
ptlist);
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_step_done noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_step_done (PyGstMiniObject *self)
|
||||
{
|
||||
GstFormat format;
|
||||
guint64 amount, duration;
|
||||
gdouble rate;
|
||||
gboolean flush, intermediate, eos;
|
||||
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_STEP_DONE) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'step-done' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_step_done (GST_MESSAGE (self->obj), &format, &amount, &rate,
|
||||
&flush, &intermediate, &duration, &eos);
|
||||
|
||||
return Py_BuildValue("OKdOOKO",
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
amount, rate,
|
||||
PyBool_FromLong(flush),
|
||||
PyBool_FromLong(intermediate),
|
||||
duration,
|
||||
PyBool_FromLong(eos));
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_step_start noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_step_start (PyGstMiniObject *self)
|
||||
{
|
||||
GstFormat format;
|
||||
guint64 amount;
|
||||
gdouble rate;
|
||||
gboolean active, flush, intermediate;
|
||||
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_STEP_START) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'step-start' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_step_start (GST_MESSAGE (self->obj), &active, &format,
|
||||
&amount, &rate, &flush, &intermediate);
|
||||
|
||||
return Py_BuildValue("OOKdOO",
|
||||
PyBool_FromLong(active),
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
amount, rate,
|
||||
PyBool_FromLong(flush),
|
||||
PyBool_FromLong(intermediate));
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_stream_status noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_stream_status (PyGstMiniObject *self)
|
||||
{
|
||||
GstStreamStatusType type;
|
||||
GstElement *owner;
|
||||
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_STREAM_STATUS) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'stream-status' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_stream_status (GST_MESSAGE (self->obj), &type, &owner);
|
||||
|
||||
return Py_BuildValue("OO",
|
||||
pyg_enum_from_gtype (GST_TYPE_STREAM_STATUS_TYPE, type),
|
||||
pygobject_new((GObject*) owner));
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_structure_change noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_structure_change (PyGstMiniObject *self)
|
||||
{
|
||||
GstStructureChangeType type;
|
||||
GstElement *owner;
|
||||
gboolean busy;
|
||||
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_STRUCTURE_CHANGE) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'structure_change' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_structure_change (GST_MESSAGE (self->obj), &type, &owner, &busy);
|
||||
|
||||
return Py_BuildValue("OOO",
|
||||
pyg_enum_from_gtype (GST_TYPE_STRUCTURE_CHANGE_TYPE, type),
|
||||
pygobject_new((GObject*) owner),
|
||||
PyBool_FromLong(busy));
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_request_state noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_request_state (PyGstMiniObject *self)
|
||||
{
|
||||
GstState state;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_REQUEST_STATE) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'request_state' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_request_state (GST_MESSAGE (self->obj), &state);
|
||||
|
||||
return pyg_enum_from_gtype(GST_TYPE_STATE, state);
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_buffering_stats noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_buffering_stats (PyGstMiniObject *self)
|
||||
{
|
||||
GstBufferingMode mode;
|
||||
gint avg_in, avg_out;
|
||||
gint64 buffering_left;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_BUFFERING) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'buffering' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_buffering_stats (GST_MESSAGE (self->obj), &mode, &avg_in, &avg_out,
|
||||
&buffering_left);
|
||||
|
||||
return Py_BuildValue("OiiL",
|
||||
pyg_enum_from_gtype (GST_TYPE_BUFFERING_MODE, mode),
|
||||
avg_in, avg_out, buffering_left);
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_qos noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_qos (PyGstMiniObject *self)
|
||||
{
|
||||
gboolean live;
|
||||
guint64 running_time, stream_time, timestamp, duration;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_QOS) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'qos' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_qos (GST_MESSAGE (self->obj), &live, &running_time, &stream_time,
|
||||
×tamp, &duration);
|
||||
|
||||
return Py_BuildValue("OKKKK",
|
||||
PyBool_FromLong(live), running_time, stream_time,
|
||||
timestamp, duration);
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_qos_values noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_qos_values (PyGstMiniObject *self)
|
||||
{
|
||||
gint64 jitter;
|
||||
gdouble proportion;
|
||||
gint quality;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_QOS) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'qos' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_qos_values (GST_MESSAGE (self->obj), &jitter,
|
||||
&proportion, &quality);
|
||||
|
||||
return Py_BuildValue("Ldi",
|
||||
jitter, proportion, quality);
|
||||
}
|
||||
%%
|
||||
override gst_message_parse_qos_stats noargs
|
||||
static PyObject *
|
||||
_wrap_gst_message_parse_qos_stats (PyGstMiniObject *self)
|
||||
{
|
||||
GstFormat format;
|
||||
guint64 processed;
|
||||
guint64 dropped;
|
||||
|
||||
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_QOS) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not an 'qos' message");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_message_parse_qos_stats (GST_MESSAGE (self->obj), &format,
|
||||
&processed, &dropped);
|
||||
|
||||
return Py_BuildValue("OKK",
|
||||
pyg_enum_from_gtype(GST_TYPE_FORMAT, format),
|
||||
processed, dropped);
|
||||
}
|
395
gst/gstmodule.c
395
gst/gstmodule.c
|
@ -1,395 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "k&r"; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2002 David I. Lehn
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: David I. Lehn <dlehn@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
||||
#include <pygobject.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/gstversion.h>
|
||||
#include "pygst-private.h"
|
||||
#include "pygstexception.h"
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
|
||||
void pygst_register_classes (PyObject * d);
|
||||
void pygst_add_constants (PyObject * module, const gchar * strip_prefix);
|
||||
void _pygst_register_boxed_types (PyObject * moddict);
|
||||
|
||||
extern PyMethodDef pygst_functions[];
|
||||
|
||||
GST_DEBUG_CATEGORY (pygst_debug); /* for bindings code */
|
||||
GST_DEBUG_CATEGORY (python_debug); /* for python code */
|
||||
|
||||
/* copied from pygtk to register GType */
|
||||
#define REGISTER_TYPE(d, type, name) \
|
||||
type.ob_type = &PyType_Type; \
|
||||
type.tp_alloc = PyType_GenericAlloc; \
|
||||
type.tp_new = PyType_GenericNew; \
|
||||
if (PyType_Ready(&type)) \
|
||||
return; \
|
||||
PyDict_SetItemString(d, name, (PyObject *)&type);
|
||||
|
||||
#define REGISTER_GTYPE(d, type, name, gtype) \
|
||||
REGISTER_TYPE(d, type, name); \
|
||||
PyDict_SetItemString(type.tp_dict, "__gtype__", \
|
||||
o=pyg_type_wrapper_new(gtype)); \
|
||||
Py_DECREF(o);
|
||||
|
||||
static PyObject *
|
||||
pygstminiobject_from_gvalue (const GValue * value)
|
||||
{
|
||||
GstMiniObject *miniobj;
|
||||
|
||||
if ((miniobj = gst_value_get_mini_object (value)) == NULL) {
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
return pygstminiobject_new (miniobj);
|
||||
}
|
||||
|
||||
static int
|
||||
pygstminiobject_to_gvalue (GValue * value, PyObject * obj)
|
||||
{
|
||||
PyGstMiniObject *self = (PyGstMiniObject *) obj;
|
||||
|
||||
gst_value_set_mini_object (value, obj == Py_None ? NULL : self->obj);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sink_gstobject (GObject * object)
|
||||
{
|
||||
if (GST_OBJECT_IS_FLOATING (object)) {
|
||||
g_object_ref (object);
|
||||
gst_object_sink (GST_OBJECT (object));
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygst_fraction_from_value (const GValue * value)
|
||||
{
|
||||
PyObject *module, *dict, *fraction_type, *args, *fraction;
|
||||
gint numerator, denominator;
|
||||
|
||||
numerator = gst_value_get_fraction_numerator (value);
|
||||
denominator = gst_value_get_fraction_denominator (value);
|
||||
|
||||
module = PyImport_ImportModule ("gst");
|
||||
dict = PyModule_GetDict (module);
|
||||
fraction_type = PyMapping_GetItemString (dict, "Fraction");
|
||||
|
||||
args = Py_BuildValue ("(ii)", numerator, denominator);
|
||||
fraction = PyObject_Call (fraction_type, args, NULL);
|
||||
Py_DECREF (args);
|
||||
Py_DECREF (fraction_type);
|
||||
Py_DECREF (module);
|
||||
|
||||
return fraction;
|
||||
}
|
||||
|
||||
static int
|
||||
pygst_fraction_to_value (GValue * value, PyObject * object)
|
||||
{
|
||||
PyObject *numerator, *denominator;
|
||||
|
||||
numerator = PyObject_GetAttrString (object, "num");
|
||||
if (numerator == NULL)
|
||||
goto fail;
|
||||
|
||||
denominator = PyObject_GetAttrString (object, "denom");
|
||||
if (denominator == NULL)
|
||||
goto fail;
|
||||
|
||||
gst_value_set_fraction (value,
|
||||
PyLong_AsLong (numerator), PyLong_AsLong (denominator));
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct _PyGst_Functions pygst_api_functions = {
|
||||
pygst_caps_from_pyobject,
|
||||
pygst_iterator_new,
|
||||
pygstminiobject_new
|
||||
};
|
||||
|
||||
/* for addon libraries ... */
|
||||
static void
|
||||
pygst_register_api (PyObject * d)
|
||||
{
|
||||
PyObject *api;
|
||||
|
||||
api = PyCObject_FromVoidPtr (&pygst_api_functions, NULL);
|
||||
PyDict_SetItemString (d, "_PyGst_API", api);
|
||||
Py_DECREF (api);
|
||||
}
|
||||
|
||||
DL_EXPORT (void)
|
||||
init_gst (void)
|
||||
{
|
||||
PyObject *m, *d;
|
||||
PyObject *av, *tuple;
|
||||
int argc, i;
|
||||
guint major, minor, micro, nano;
|
||||
char **argv;
|
||||
GError *error = NULL;
|
||||
|
||||
init_pygobject ();
|
||||
|
||||
/* pull in arguments */
|
||||
av = PySys_GetObject ("argv");
|
||||
if (av != NULL) {
|
||||
argc = PyList_Size (av);
|
||||
argv = g_new (char *, argc);
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] = g_strdup (PyString_AsString (PyList_GetItem (av, i)));
|
||||
} else {
|
||||
/* gst_init_check does not like argc == 0 */
|
||||
argc = 1;
|
||||
argv = g_new (char *, argc);
|
||||
argv[0] = g_strdup ("");
|
||||
}
|
||||
if (!gst_init_check (&argc, &argv, &error)) {
|
||||
gchar *errstr;
|
||||
|
||||
if (argv != NULL) {
|
||||
for (i = 0; i < argc; i++)
|
||||
g_free (argv[i]);
|
||||
g_free (argv);
|
||||
}
|
||||
errstr = g_strdup_printf ("can't initialize module gst: %s",
|
||||
error ? GST_STR_NULL (error->message) : "no error given");
|
||||
PyErr_SetString (PyExc_RuntimeError, errstr);
|
||||
g_free (errstr);
|
||||
g_error_free (error);
|
||||
setlocale (LC_NUMERIC, "C");
|
||||
return;
|
||||
}
|
||||
|
||||
setlocale (LC_NUMERIC, "C");
|
||||
if (argv != NULL) {
|
||||
PySys_SetArgv (argc, argv);
|
||||
for (i = 0; i < argc; i++)
|
||||
g_free (argv[i]);
|
||||
g_free (argv);
|
||||
}
|
||||
|
||||
/* Initialize debugging category */
|
||||
GST_DEBUG_CATEGORY_INIT (pygst_debug, "pygst", 0,
|
||||
"GStreamer python bindings");
|
||||
GST_DEBUG_CATEGORY_INIT (python_debug, "python", GST_DEBUG_FG_GREEN,
|
||||
"python code using gst-python");
|
||||
|
||||
pygobject_register_sinkfunc (GST_TYPE_OBJECT, sink_gstobject);
|
||||
|
||||
m = Py_InitModule ("_gst", pygst_functions);
|
||||
d = PyModule_GetDict (m);
|
||||
pygst_register_api (d);
|
||||
|
||||
/* gst version */
|
||||
gst_version (&major, &minor, µ, &nano);
|
||||
tuple = Py_BuildValue ("(iii)", major, minor, micro);
|
||||
PyDict_SetItemString (d, "gst_version", tuple);
|
||||
Py_DECREF (tuple);
|
||||
|
||||
/* gst-python version */
|
||||
tuple = Py_BuildValue ("(iii)", PYGST_MAJOR_VERSION, PYGST_MINOR_VERSION,
|
||||
PYGST_MICRO_VERSION);
|
||||
PyDict_SetItemString (d, "pygst_version", tuple);
|
||||
Py_DECREF (tuple);
|
||||
|
||||
/* clock stuff */
|
||||
PyModule_AddIntConstant (m, "SECOND", GST_SECOND);
|
||||
PyModule_AddIntConstant (m, "MSECOND", GST_MSECOND);
|
||||
PyModule_AddIntConstant (m, "NSECOND", GST_NSECOND);
|
||||
|
||||
PyModule_AddObject (m, "CLOCK_TIME_NONE",
|
||||
PyLong_FromUnsignedLongLong (GST_CLOCK_TIME_NONE));
|
||||
PyModule_AddObject (m, "BUFFER_OFFSET_NONE",
|
||||
PyLong_FromUnsignedLongLong (GST_BUFFER_OFFSET_NONE));
|
||||
|
||||
pygst_exceptions_register_classes (d);
|
||||
|
||||
REGISTER_TYPE (d, PyGstIterator_Type, "Iterator");
|
||||
|
||||
|
||||
pygstminiobject_register_class (d, "GstMiniObject", GST_TYPE_MINI_OBJECT,
|
||||
&PyGstMiniObject_Type, NULL);
|
||||
pyg_register_boxed_custom (GST_TYPE_MINI_OBJECT,
|
||||
pygstminiobject_from_gvalue, pygstminiobject_to_gvalue);
|
||||
|
||||
pygst_register_classes (d);
|
||||
pygst_add_constants (m, "GST_");
|
||||
|
||||
/* make our types available */
|
||||
PyModule_AddObject (m, "TYPE_ELEMENT_FACTORY",
|
||||
pyg_type_wrapper_new (GST_TYPE_ELEMENT_FACTORY));
|
||||
PyModule_AddObject (m, "TYPE_INDEX_FACTORY",
|
||||
pyg_type_wrapper_new (GST_TYPE_INDEX_FACTORY));
|
||||
PyModule_AddObject (m, "TYPE_TYPE_FIND_FACTORY",
|
||||
pyg_type_wrapper_new (GST_TYPE_TYPE_FIND_FACTORY));
|
||||
|
||||
#define ADD_GST_TAG(a) PyModule_AddStringConstant(m, "TAG_" #a, GST_TAG_##a)
|
||||
/* GStreamer core tags */
|
||||
ADD_GST_TAG (TITLE);
|
||||
ADD_GST_TAG (ARTIST);
|
||||
ADD_GST_TAG (ALBUM);
|
||||
ADD_GST_TAG (DATE);
|
||||
ADD_GST_TAG (GENRE);
|
||||
ADD_GST_TAG (COMMENT);
|
||||
ADD_GST_TAG (TRACK_NUMBER);
|
||||
ADD_GST_TAG (TRACK_COUNT);
|
||||
ADD_GST_TAG (ALBUM_VOLUME_NUMBER);
|
||||
ADD_GST_TAG (ALBUM_VOLUME_COUNT);
|
||||
ADD_GST_TAG (LOCATION);
|
||||
ADD_GST_TAG (DESCRIPTION);
|
||||
ADD_GST_TAG (VERSION);
|
||||
ADD_GST_TAG (ISRC);
|
||||
ADD_GST_TAG (ORGANIZATION);
|
||||
ADD_GST_TAG (COPYRIGHT);
|
||||
ADD_GST_TAG (CONTACT);
|
||||
ADD_GST_TAG (LICENSE);
|
||||
ADD_GST_TAG (PERFORMER);
|
||||
ADD_GST_TAG (DURATION);
|
||||
ADD_GST_TAG (CODEC);
|
||||
ADD_GST_TAG (VIDEO_CODEC);
|
||||
ADD_GST_TAG (AUDIO_CODEC);
|
||||
ADD_GST_TAG (BITRATE);
|
||||
ADD_GST_TAG (NOMINAL_BITRATE);
|
||||
ADD_GST_TAG (MINIMUM_BITRATE);
|
||||
ADD_GST_TAG (MAXIMUM_BITRATE);
|
||||
ADD_GST_TAG (SERIAL);
|
||||
ADD_GST_TAG (ENCODER);
|
||||
ADD_GST_TAG (ENCODER_VERSION);
|
||||
ADD_GST_TAG (TRACK_GAIN);
|
||||
ADD_GST_TAG (TRACK_PEAK);
|
||||
ADD_GST_TAG (ALBUM_GAIN);
|
||||
ADD_GST_TAG (ALBUM_PEAK);
|
||||
ADD_GST_TAG (LANGUAGE_CODE);
|
||||
ADD_GST_TAG (IMAGE);
|
||||
ADD_GST_TAG (PREVIEW_IMAGE);
|
||||
ADD_GST_TAG (EXTENDED_COMMENT);
|
||||
ADD_GST_TAG (REFERENCE_LEVEL);
|
||||
ADD_GST_TAG (BEATS_PER_MINUTE);
|
||||
ADD_GST_TAG (LICENSE_URI);
|
||||
ADD_GST_TAG (COPYRIGHT_URI);
|
||||
ADD_GST_TAG (COMPOSER);
|
||||
ADD_GST_TAG (ARTIST_SORTNAME);
|
||||
ADD_GST_TAG (ALBUM_SORTNAME);
|
||||
ADD_GST_TAG (TITLE_SORTNAME);
|
||||
#if ((GST_VERSION_MICRO >= 21) || (GST_VERSION_MICRO == 20 && GST_VERSION_NANO > 0))
|
||||
ADD_GST_TAG (ATTACHMENT);
|
||||
ADD_GST_TAG (KEYWORDS);
|
||||
ADD_GST_TAG (GEO_LOCATION_NAME);
|
||||
ADD_GST_TAG (GEO_LOCATION_LATITUDE);
|
||||
ADD_GST_TAG (GEO_LOCATION_LONGITUDE);
|
||||
ADD_GST_TAG (GEO_LOCATION_ELEVATION);
|
||||
#if ((GST_VERSION_MICRO >= 23) || (GST_VERSION_MICRO == 22 && GST_VERSION_NANO > 0))
|
||||
ADD_GST_TAG (SUBTITLE_CODEC);
|
||||
ADD_GST_TAG (HOMEPAGE);
|
||||
#if ((GST_VERSION_MICRO >= 24) || (GST_VERSION_MICRO == 23 && GST_VERSION_NANO > 0))
|
||||
ADD_GST_TAG (CONTAINER_FORMAT);
|
||||
#if ((GST_VERSION_MICRO >= 25) || (GST_VERSION_MICRO == 24 && GST_VERSION_NANO > 0))
|
||||
ADD_GST_TAG (ALBUM_ARTIST);
|
||||
ADD_GST_TAG (ALBUM_ARTIST_SORTNAME);
|
||||
#if ((GST_VERSION_MICRO >= 26) || (GST_VERSION_MICRO == 25 && GST_VERSION_NANO > 0))
|
||||
ADD_GST_TAG (SHOW_NAME);
|
||||
ADD_GST_TAG (SHOW_SORTNAME);
|
||||
ADD_GST_TAG (SHOW_EPISODE_NUMBER);
|
||||
ADD_GST_TAG (SHOW_SEASON_NUMBER);
|
||||
ADD_GST_TAG (LYRICS);
|
||||
ADD_GST_TAG (COMPOSER_SORTNAME);
|
||||
ADD_GST_TAG (GROUPING);
|
||||
#if ((GST_VERSION_MICRO >= 29) || (GST_VERSION_MICRO == 28 && GST_VERSION_NANO > 0))
|
||||
ADD_GST_TAG (GEO_LOCATION_COUNTRY);
|
||||
ADD_GST_TAG (GEO_LOCATION_CITY);
|
||||
ADD_GST_TAG (GEO_LOCATION_SUBLOCATION);
|
||||
ADD_GST_TAG (USER_RATING);
|
||||
#if ((GST_VERSION_MICRO >= 30) || (GST_VERSION_MICRO == 29 && GST_VERSION_NANO > 0))
|
||||
ADD_GST_TAG (DEVICE_MANUFACTURER);
|
||||
ADD_GST_TAG (IMAGE_ORIENTATION);
|
||||
ADD_GST_TAG (DEVICE_MODEL);
|
||||
ADD_GST_TAG (GEO_LOCATION_MOVEMENT_SPEED);
|
||||
ADD_GST_TAG (GEO_LOCATION_MOVEMENT_DIRECTION);
|
||||
ADD_GST_TAG (GEO_LOCATION_CAPTURE_DIRECTION);
|
||||
ADD_GST_TAG (IMAGE_ORIENTATION);
|
||||
#if ((GST_VERSION_MICRO >= 31) || (GST_VERSION_MICRO == 30 && GST_VERSION_NANO > 0))
|
||||
#define ADD_FACTORY_TYPE(a) PyModule_AddObject(m, "ELEMENT_FACTORY_TYPE_" #a,\
|
||||
PyLong_FromUnsignedLongLong(GST_ELEMENT_FACTORY_TYPE_##a))
|
||||
ADD_FACTORY_TYPE (DECODER);
|
||||
ADD_FACTORY_TYPE (ENCODER);
|
||||
ADD_FACTORY_TYPE (SINK);
|
||||
ADD_FACTORY_TYPE (SRC);
|
||||
ADD_FACTORY_TYPE (MUXER);
|
||||
ADD_FACTORY_TYPE (DEMUXER);
|
||||
ADD_FACTORY_TYPE (PARSER);
|
||||
ADD_FACTORY_TYPE (PAYLOADER);
|
||||
ADD_FACTORY_TYPE (DEPAYLOADER);
|
||||
ADD_FACTORY_TYPE (FORMATTER);
|
||||
ADD_FACTORY_TYPE (MAX_ELEMENTS);
|
||||
ADD_FACTORY_TYPE (MEDIA_VIDEO);
|
||||
ADD_FACTORY_TYPE (MEDIA_AUDIO);
|
||||
ADD_FACTORY_TYPE (MEDIA_IMAGE);
|
||||
ADD_FACTORY_TYPE (MEDIA_SUBTITLE);
|
||||
ADD_FACTORY_TYPE (MEDIA_METADATA);
|
||||
ADD_FACTORY_TYPE (ANY);
|
||||
ADD_FACTORY_TYPE (MEDIA_ANY);
|
||||
ADD_FACTORY_TYPE (VIDEO_ENCODER);
|
||||
ADD_FACTORY_TYPE (AUDIO_ENCODER);
|
||||
ADD_FACTORY_TYPE (AUDIOVIDEO_SINKS);
|
||||
ADD_FACTORY_TYPE (DECODABLE);
|
||||
ADD_GST_TAG (DATE_TIME);
|
||||
ADD_GST_TAG (APPLICATION_NAME);
|
||||
ADD_GST_TAG (APPLICATION_DATA);
|
||||
ADD_GST_TAG (GEO_LOCATION_HORIZONTAL_ERROR);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
PyModule_AddStringConstant (m, "LIBRARY_ERROR",
|
||||
(gchar *) g_quark_to_string (GST_LIBRARY_ERROR));
|
||||
PyModule_AddStringConstant (m, "RESOURCE_ERROR",
|
||||
(gchar *) g_quark_to_string (GST_RESOURCE_ERROR));
|
||||
PyModule_AddStringConstant (m, "CORE_ERROR",
|
||||
(gchar *) g_quark_to_string (GST_CORE_ERROR));
|
||||
PyModule_AddStringConstant (m, "STREAM_ERROR",
|
||||
(gchar *) g_quark_to_string (GST_STREAM_ERROR));
|
||||
|
||||
pyg_register_gtype_custom (GST_TYPE_FRACTION,
|
||||
pygst_fraction_from_value, pygst_fraction_to_value);
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
Py_FatalError ("can't initialize module gst");
|
||||
}
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
/* -*- Mode: C -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Edward Hervey
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Edward Hervey <edward@fluendo.com>
|
||||
*/
|
||||
|
||||
%%
|
||||
ignore
|
||||
gst_object_default_deep_notify
|
||||
gst_object_check_uniqueness
|
||||
gst_object_replace
|
||||
|
||||
%%
|
||||
override-attr GstObject.__gstrefcount__
|
||||
|
||||
/* keep this attribute around even after 2.8 for compatibility reasons */
|
||||
static PyObject *
|
||||
_wrap_gst_object__get___gstrefcount__ (PyGObject * self, void *closure)
|
||||
{
|
||||
return PyInt_FromLong (GST_OBJECT_REFCOUNT_VALUE (self->obj));
|
||||
}
|
||||
|
||||
%%
|
||||
override-slot GstObject.tp_repr
|
||||
static PyObject *
|
||||
_wrap_gst_object_tp_repr (PyObject * self)
|
||||
{
|
||||
gchar *repr;
|
||||
PyObject *ret;
|
||||
GstObject *object = GST_OBJECT (pygobject_get (self));
|
||||
|
||||
repr = g_strdup_printf ("<%s object (%s) at 0x%lx>",
|
||||
self->ob_type->tp_name,
|
||||
object ? (
|
||||
GST_OBJECT_NAME (object) ? GST_OBJECT_NAME (object) : "unnamed"
|
||||
) : "(null)",
|
||||
(long) self);
|
||||
ret = PyString_FromString (repr);
|
||||
g_free (repr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
%%
|
||||
override-slot GstObject.tp_str
|
||||
static PyObject *
|
||||
_wrap_gst_object_tp_str (PyObject * self)
|
||||
{
|
||||
gchar *repr, *path;
|
||||
PyObject *ret;
|
||||
GstObject *object = GST_OBJECT (pygobject_get (self));
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
path = gst_object_get_path_string (object);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
repr = g_strdup_printf ("%s (%s)", path, self->ob_type->tp_name);
|
||||
ret = PyString_FromString (repr);
|
||||
g_free (repr);
|
||||
g_free (path);
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override gst_object_set_property args
|
||||
|
||||
/*
|
||||
* REMOVE THE FOLLOWING CODE, once pygobject has fixed the issue of not
|
||||
* releasing the GIL when calling g_object_set_property.
|
||||
*
|
||||
* See bug #395048 : set_property() doesn't release the GIL
|
||||
**/
|
||||
|
||||
static gboolean
|
||||
set_property_from_pspec(GObject *obj,
|
||||
char *attr_name,
|
||||
GParamSpec *pspec,
|
||||
PyObject *pvalue)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
|
||||
if (pspec->flags & G_PARAM_CONSTRUCT_ONLY) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"property '%s' can only be set in constructor",
|
||||
attr_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!(pspec->flags & G_PARAM_WRITABLE)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"property '%s' is not writable", attr_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
|
||||
/* FIXME: bug in pygtk 2.8 series; see
|
||||
http://svn.gnome.org/viewcvs/pygobject/trunk/gobject/pygobject.h?rev=566&r1=564&r2=566 */
|
||||
|
||||
#ifndef PYGOBJECT_2_12
|
||||
#undef pyg_param_gvalue_from_pyobject
|
||||
#define pyg_param_gvalue_from_pyobject (_PyGObject_API->gvalue_from_param_pyobject)
|
||||
#endif
|
||||
|
||||
if (pyg_param_gvalue_from_pyobject(&value, pvalue, pspec) < 0) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"could not convert argument to correct param type");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
g_object_set_property(obj, attr_name, &value);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
g_value_unset(&value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_object_set_property(PyGObject *self, PyObject *args)
|
||||
{
|
||||
gchar *param_name;
|
||||
GParamSpec *pspec;
|
||||
PyObject *pvalue;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO:gst.Object.set_property", ¶m_name,
|
||||
&pvalue))
|
||||
return NULL;
|
||||
|
||||
if (!GST_IS_OBJECT (self->obj)) {
|
||||
PyErr_Format (PyExc_TypeError,
|
||||
"object at %p of type %s is not initialized",
|
||||
self, self->ob_type->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(self->obj),
|
||||
param_name);
|
||||
if (!pspec) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"object of type `%s' does not have property `%s'",
|
||||
g_type_name(G_OBJECT_TYPE(self->obj)), param_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!set_property_from_pspec(self->obj, param_name, pspec, pvalue))
|
||||
return NULL;
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
1690
gst/gstpad.override
1690
gst/gstpad.override
File diff suppressed because it is too large
Load diff
|
@ -1,324 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Edward Hervey
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
%%
|
||||
ignore
|
||||
gst_query_set_formatsv
|
||||
%%
|
||||
override gst_query_parse_position noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_position (PyGstMiniObject *self)
|
||||
{
|
||||
GstFormat format;
|
||||
gint64 cur;
|
||||
|
||||
if (GST_QUERY_TYPE(self->obj) != GST_QUERY_POSITION) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'Position' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_position (GST_QUERY(self->obj), &format, &cur);
|
||||
|
||||
return Py_BuildValue("(OL)",
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
cur);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_duration noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_duration (PyGstMiniObject *self)
|
||||
{
|
||||
GstFormat format;
|
||||
gint64 cur;
|
||||
|
||||
if (GST_QUERY_TYPE(self->obj) != GST_QUERY_DURATION) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'Duration' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_duration (GST_QUERY(self->obj), &format, &cur);
|
||||
|
||||
return Py_BuildValue("(OL)",
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
cur);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_convert noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_convert (PyGstMiniObject *self)
|
||||
{
|
||||
GstFormat srcformat, destformat;
|
||||
gint64 srcvalue, destvalue;
|
||||
|
||||
if (GST_QUERY_TYPE(self->obj) != GST_QUERY_CONVERT) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'Convert' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_convert (GST_QUERY(self->obj),
|
||||
&srcformat, &srcvalue,
|
||||
&destformat, &destvalue);
|
||||
|
||||
return Py_BuildValue("(OLOL)",
|
||||
pyg_enum_from_gtype(GST_TYPE_FORMAT, srcformat),
|
||||
srcvalue,
|
||||
pyg_enum_from_gtype(GST_TYPE_FORMAT, destformat),
|
||||
destvalue);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_segment noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_segment (PyGstMiniObject *self)
|
||||
{
|
||||
gdouble rate;
|
||||
GstFormat format;
|
||||
gint64 start_value;
|
||||
gint64 stop_value;
|
||||
|
||||
if (GST_QUERY_TYPE(self->obj) != GST_QUERY_SEGMENT) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'Segment' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_segment (GST_QUERY(self->obj),
|
||||
&rate, &format,
|
||||
&start_value, &stop_value);
|
||||
|
||||
return Py_BuildValue("(dOLL)",
|
||||
rate,
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
start_value, stop_value);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_seeking noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_seeking (PyGstMiniObject *self)
|
||||
{
|
||||
GstFormat format;
|
||||
gboolean seekable;
|
||||
gint64 segment_start, segment_end;
|
||||
|
||||
if (GST_QUERY_TYPE(self->obj) != GST_QUERY_SEEKING) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'Seeking' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_seeking (GST_QUERY(self->obj),
|
||||
&format, &seekable,
|
||||
&segment_start, &segment_end);
|
||||
|
||||
return Py_BuildValue("(OOLL)",
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
PyBool_FromLong(seekable),
|
||||
segment_start,
|
||||
segment_end);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_formats_length noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_formats_length (PyGstMiniObject *self)
|
||||
{
|
||||
PyObject *ret;
|
||||
guint n_formats;
|
||||
|
||||
if (GST_QUERY_TYPE(self->obj) != GST_QUERY_FORMATS) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'Formats' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_formats_length (GST_QUERY (self->obj),
|
||||
&n_formats);
|
||||
|
||||
ret = PyInt_FromLong(n_formats);
|
||||
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_formats_nth kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_formats_nth (PyGstMiniObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = {"nth", NULL};
|
||||
guint nth;
|
||||
GstFormat format;
|
||||
|
||||
if (GST_QUERY_TYPE (self->obj) != GST_QUERY_FORMATS) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'Formats' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "I:GstQuery.parse_formats_nth", kwlist, &nth))
|
||||
return NULL;
|
||||
|
||||
gst_query_parse_formats_nth (GST_QUERY (self->obj),
|
||||
nth, &format);
|
||||
|
||||
return pyg_enum_from_gtype (GST_TYPE_FORMAT, format);
|
||||
}
|
||||
%%
|
||||
override gst_query_set_formats args
|
||||
static PyObject *
|
||||
_wrap_gst_query_set_formats (PyGstMiniObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *ret = NULL;
|
||||
gint len, i;
|
||||
GstFormat *formats;
|
||||
|
||||
if (GST_QUERY_TYPE (self->obj) != GST_QUERY_FORMATS) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'Formats' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((len = PyTuple_Size(args)) < 1) {
|
||||
PyErr_SetString(PyExc_TypeError, "You need to supply at least one gst.Format");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
formats = g_new0(GstFormat, len);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (pyg_enum_get_value(GST_TYPE_FORMAT,
|
||||
PyTuple_GetItem(args, i),
|
||||
(gint *) &formats[i]))
|
||||
goto beach;
|
||||
}
|
||||
|
||||
gst_query_set_formatsv (GST_QUERY(self->obj), len, formats);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
ret = Py_None;
|
||||
|
||||
beach:
|
||||
g_free(formats);
|
||||
return ret;
|
||||
}
|
||||
%%
|
||||
override gst_query_get_structure noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_get_structure(PyGstMiniObject *self)
|
||||
{
|
||||
GstStructure *ret;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_query_get_structure(GST_QUERY(self->obj));
|
||||
pyg_end_allow_threads;
|
||||
/* pyg_boxed_new handles NULL checking */
|
||||
return pyg_boxed_new(GST_TYPE_STRUCTURE, ret, FALSE, FALSE);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_latency noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_latency (PyGstMiniObject * self)
|
||||
{
|
||||
gboolean islive;
|
||||
GstClockTime minlat, maxlat;
|
||||
|
||||
if (GST_QUERY_TYPE (self->obj) != GST_QUERY_LATENCY) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'latency' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_latency (GST_QUERY (self->obj), &islive, &minlat, &maxlat);
|
||||
|
||||
return Py_BuildValue("(OKK)",
|
||||
PyBool_FromLong(islive),
|
||||
minlat, maxlat);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_buffering_percent noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_buffering_percent (PyGstMiniObject * self)
|
||||
{
|
||||
gboolean busy;
|
||||
gint percent;
|
||||
|
||||
if (GST_QUERY_TYPE (self->obj) != GST_QUERY_BUFFERING) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'buffering' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_buffering_percent (GST_QUERY (self->obj), &busy, &percent);
|
||||
|
||||
return Py_BuildValue("(Od)", PyBool_FromLong(busy), percent);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_buffering_stats noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_buffering_stats (PyGstMiniObject * self)
|
||||
{
|
||||
GstBufferingMode mode;
|
||||
gint avg_in, avg_out;
|
||||
gint64 buffering_left;
|
||||
|
||||
if (GST_QUERY_TYPE (self->obj) != GST_QUERY_BUFFERING) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'buffering' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_buffering_stats (GST_QUERY (self->obj), &mode,
|
||||
&avg_in, &avg_out,
|
||||
&buffering_left);
|
||||
return Py_BuildValue("OiiL",
|
||||
pyg_enum_from_gtype (GST_TYPE_BUFFERING_MODE, mode),
|
||||
avg_in, avg_out, buffering_left);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_buffering_range noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_buffering_range (PyGstMiniObject * self)
|
||||
{
|
||||
GstFormat format;
|
||||
gint64 start, stop, estimated_total;
|
||||
|
||||
if (GST_QUERY_TYPE (self->obj) != GST_QUERY_BUFFERING) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'buffering' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_buffering_range (GST_QUERY (self->obj), &format,
|
||||
&start, &stop, &estimated_total);
|
||||
return Py_BuildValue("OLLL",
|
||||
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
||||
start, stop, estimated_total);
|
||||
}
|
||||
%%
|
||||
override gst_query_parse_uri noargs
|
||||
static PyObject *
|
||||
_wrap_gst_query_parse_uri (PyGstMiniObject * self)
|
||||
{
|
||||
gchar *uri = NULL;
|
||||
PyObject *ret;
|
||||
|
||||
if (GST_QUERY_TYPE (self->obj) != GST_QUERY_URI) {
|
||||
PyErr_SetString(PyExc_TypeError, "Query is not a 'uri' query");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gst_query_parse_uri (GST_QUERY (self->obj), &uri);
|
||||
if (uri) {
|
||||
ret = PyString_FromStringAndSize(uri, strlen (uri));
|
||||
g_free(uri);
|
||||
} else {
|
||||
Py_INCREF(Py_None);
|
||||
ret = Py_None;
|
||||
}
|
||||
return ret;
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# Author: David I. Lehn <dlehn@users.sourceforge.net>
|
||||
|
||||
from gst import *
|
|
@ -1,348 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Johan Dahlin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
%%
|
||||
ignore
|
||||
gst_structure_get_boolean
|
||||
gst_structure_get_int
|
||||
gst_structure_get_fourcc
|
||||
gst_structure_get_double
|
||||
gst_structure_get_date
|
||||
gst_structure_get_clock_time
|
||||
gst_structure_get_string
|
||||
gst_structure_get_value
|
||||
gst_structure_get_enum
|
||||
gst_structure_get_fraction
|
||||
gst_structure_set
|
||||
gst_structure_get_name_id
|
||||
gst_structure_id_get_value
|
||||
gst_structure_id_set_value
|
||||
gst_structure_set_parent_refcount
|
||||
gst_structure_remove_fields
|
||||
gst_structure_map_in_place
|
||||
gst_structure_fixate_field_nearest_fraction
|
||||
%%
|
||||
override gst_structure_new kwargs
|
||||
static int
|
||||
_wrap_gst_structure_new(PyGBoxed *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "name", NULL };
|
||||
char *name;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:GstStructure.__init__", kwlist, &name))
|
||||
return -1;
|
||||
|
||||
self->gtype = GST_TYPE_STRUCTURE;
|
||||
self->free_on_dealloc = FALSE;
|
||||
|
||||
self->boxed = gst_structure_new(name, NULL);
|
||||
|
||||
if (!self->boxed) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "could not create GstStructure object");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override gst_structure_set_value kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_structure_set_value(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "field", "value", "type_name", NULL };
|
||||
char *field;
|
||||
PyObject *py_value = NULL;
|
||||
char *type_name = NULL;
|
||||
GType type;
|
||||
GValue value = { 0 };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"sO|s:GstStructure.set_value",
|
||||
kwlist, &field, &py_value,
|
||||
&type_name)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (type_name) {
|
||||
if (strcmp (type_name, "char") == 0) {
|
||||
type = G_TYPE_CHAR;
|
||||
} else if (strcmp (type_name, "uchar") == 0) {
|
||||
type = G_TYPE_UCHAR;
|
||||
} else if (strcmp (type_name, "boolean") == 0) {
|
||||
type = G_TYPE_BOOLEAN;
|
||||
} else if (strcmp (type_name, "int") == 0) {
|
||||
type = G_TYPE_INT;
|
||||
} else if (strcmp (type_name, "uint") == 0) {
|
||||
type = G_TYPE_UINT;
|
||||
} else if (strcmp (type_name, "long") == 0) {
|
||||
type = G_TYPE_LONG;
|
||||
} else if (strcmp (type_name, "ulong") == 0) {
|
||||
type = G_TYPE_ULONG;
|
||||
} else if (strcmp (type_name, "int64") == 0) {
|
||||
type = G_TYPE_INT64;
|
||||
} else if (strcmp (type_name, "uint64") == 0) {
|
||||
type = G_TYPE_UINT64;
|
||||
} else if (strcmp (type_name, "float") == 0) {
|
||||
type = G_TYPE_FLOAT;
|
||||
} else if (strcmp (type_name, "double") == 0) {
|
||||
type = G_TYPE_DOUBLE;
|
||||
} else if (strcmp (type_name, "string") == 0) {
|
||||
type = G_TYPE_STRING;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"invalid type name");
|
||||
return NULL;
|
||||
}
|
||||
} else if (py_value == Py_None) {
|
||||
PyErr_SetString(PyExc_TypeError, "value can't be None");
|
||||
return NULL;
|
||||
} else {
|
||||
type = pyg_type_from_object((PyObject *) py_value->ob_type);
|
||||
}
|
||||
|
||||
if (type != G_TYPE_INVALID) {
|
||||
g_value_init(&value, type);
|
||||
} else if (!pygst_value_init_for_pyobject(&value, py_value)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pygst_value_from_pyobject(&value, py_value) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
gst_structure_set_value(pyg_boxed_get(self, GstStructure), field,
|
||||
&value);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
define GstStructure.has_key args
|
||||
static PyObject*
|
||||
_wrap_gst_structure_has_key(PyGObject *self, PyObject *args)
|
||||
{
|
||||
gchar *key;
|
||||
gboolean has_field;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:GstStructure.has_key", &key))
|
||||
return NULL;
|
||||
|
||||
has_field = gst_structure_has_field((GstStructure*)self->obj, key);
|
||||
|
||||
return PyBool_FromLong(has_field);
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_structure_keys noargs
|
||||
static PyObject *
|
||||
_wrap_gst_structure_keys (PyObject *self)
|
||||
{
|
||||
GstStructure *s;
|
||||
int i, n;
|
||||
PyObject *ret;
|
||||
|
||||
s = pyg_boxed_get(self, GstStructure);
|
||||
n = gst_structure_n_fields(s);
|
||||
ret = PyList_New(n);
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
const gchar *name = gst_structure_nth_field_name (s, i);
|
||||
PyList_SetItem(ret, i, PyString_FromString(name));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
%%
|
||||
override-slot GstStructure.tp_as_mapping
|
||||
static Py_ssize_t
|
||||
_wrap_gst_structure_length(PyObject *self)
|
||||
{
|
||||
PyGObject *gself = (PyGObject *)self;
|
||||
return gst_structure_n_fields((GstStructure*)gself->obj);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_structure_subscript(PyGObject *self, PyObject *py_key)
|
||||
{
|
||||
PyObject *v = NULL;
|
||||
const char *field = PyString_AsString(py_key);
|
||||
|
||||
if (gst_structure_has_field((GstStructure*)self->obj, field)) {
|
||||
const GValue *gvalue;
|
||||
gvalue = gst_structure_get_value((GstStructure*)self->obj, field);
|
||||
g_assert(gvalue != NULL);
|
||||
v = pygst_value_as_pyobject(gvalue, TRUE);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_KeyError, field);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static int
|
||||
_wrap_gst_structure_ass_subscript(PyGObject *self,
|
||||
PyObject *py_key,
|
||||
PyObject *py_value)
|
||||
{
|
||||
const char *key;
|
||||
GstStructure* structure;
|
||||
|
||||
structure = (GstStructure*)self->obj;
|
||||
key = PyString_AsString(py_key);
|
||||
if (py_value != NULL) {
|
||||
GValue v = { 0, };
|
||||
if (!pygst_value_init_for_pyobject (&v, py_value))
|
||||
return -1;
|
||||
if (pygst_value_from_pyobject(&v, py_value))
|
||||
return -1;
|
||||
gst_structure_set_value(structure, key, &v);
|
||||
g_value_unset(&v);
|
||||
} else {
|
||||
gst_structure_remove_field(structure, key);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyMappingMethods _wrap_gst_structure_tp_as_mapping = {
|
||||
_wrap_gst_structure_length, /* mp_length */
|
||||
(binaryfunc)_wrap_gst_structure_subscript, /* mp_subscript */
|
||||
(objobjargproc)_wrap_gst_structure_ass_subscript /* mp_ass_subscript */
|
||||
};
|
||||
|
||||
%%
|
||||
override gst_structure_foreach kwargs
|
||||
static gboolean
|
||||
pygst_structure_foreach_marshal(GQuark field_id,
|
||||
const GValue *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
PyGstCustomNotify *cunote = user_data;
|
||||
PyObject *py_field, *py_value, *retobj;
|
||||
gboolean retval = TRUE;
|
||||
PyGILState_STATE state;
|
||||
|
||||
g_assert(cunote->func);
|
||||
|
||||
state = pyg_gil_state_ensure();
|
||||
|
||||
py_field = Py_BuildValue("s", g_quark_to_string(field_id));
|
||||
py_value = pygst_value_as_pyobject(value, FALSE);
|
||||
if (cunote->data)
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NNO)",
|
||||
py_field, py_value,
|
||||
cunote->data);
|
||||
else
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NN)",
|
||||
py_field, py_value);
|
||||
|
||||
if (PyErr_Occurred () || (retobj == NULL) || (retobj == Py_None)) {
|
||||
PyErr_Print ();
|
||||
retval = FALSE;
|
||||
} else if (retobj != Py_None) {
|
||||
retval = PyInt_AsLong(retobj);
|
||||
}
|
||||
|
||||
Py_XDECREF(retobj);
|
||||
|
||||
pyg_gil_state_release(state);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_structure_foreach (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "foreach_function", "args", NULL };
|
||||
PyObject *pyfunc, *pyarg = NULL;
|
||||
PyGstCustomNotify cunote;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O|O:GstStructure.foreach",
|
||||
kwlist,
|
||||
&pyfunc, &pyarg)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(pyfunc)) {
|
||||
PyErr_SetString(PyExc_TypeError, "foreach_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cunote.func = pyfunc;
|
||||
cunote.data = pyarg;
|
||||
gst_structure_foreach(pyg_boxed_get(self, GstStructure),
|
||||
pygst_structure_foreach_marshal,
|
||||
&cunote);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override-slot GstStructure.tp_repr
|
||||
static PyObject *
|
||||
_wrap_gst_structure_tp_repr (PyGObject *self)
|
||||
{
|
||||
char *buf;
|
||||
PyObject *retval;
|
||||
|
||||
buf = g_strdup_printf("<GstStructure (%s) at %lx>",
|
||||
gst_structure_get_name((GstStructure*)self->obj),
|
||||
(long)self->obj);
|
||||
|
||||
retval = PyString_FromString(buf);
|
||||
g_free(buf);
|
||||
return retval;
|
||||
}
|
||||
%%
|
||||
override gst_structure_from_string kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_structure_from_string(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "string", NULL };
|
||||
char *string;
|
||||
GstStructure *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:structure_from_string", kwlist, &string))
|
||||
return NULL;
|
||||
|
||||
ret = gst_structure_from_string(string, NULL);
|
||||
|
||||
/* pyg_boxed_new handles NULL checking */
|
||||
return pyg_boxed_new(GST_TYPE_STRUCTURE, ret, FALSE, TRUE);
|
||||
}
|
||||
%%
|
||||
override-slot GstStructure.tp_dealloc
|
||||
static void
|
||||
_wrap_gst_structure_tp_dealloc (PyObject *self)
|
||||
{
|
||||
PyGBoxed *boxed = (PyGBoxed *) self;
|
||||
|
||||
if (boxed->free_on_dealloc && boxed->boxed) {
|
||||
gst_structure_free (boxed->boxed);
|
||||
} else if (boxed->boxed) {
|
||||
pygst_caps_map_remove_structure (self);
|
||||
}
|
||||
|
||||
self->ob_type->tp_free((PyObject *)self);
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Edward Hervey
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Edward Hervey <edward@fluendo.com>
|
||||
*/
|
||||
|
||||
%%
|
||||
ignore-glob
|
||||
gst_tag_list_get_*
|
||||
%%
|
||||
ignore
|
||||
gst_tag_list_add
|
||||
gst_tag_list_add_values
|
||||
gst_tag_list_add_valist_values
|
||||
gst_tag_list_copy_value
|
||||
gst_tag_list_get
|
||||
gst_tag_list_remove_tag
|
||||
gst_tag_list_foreach
|
||||
gst_is_tag_list
|
||||
%%
|
||||
define GstTagList.keys noargs
|
||||
static void
|
||||
tag_foreach_func_list (const GstTagList *list,
|
||||
const gchar *tag,
|
||||
PyObject *py_list)
|
||||
{
|
||||
int count;
|
||||
|
||||
count = gst_tag_list_get_tag_size(GST_TAG_LIST(list), tag);
|
||||
if (count == 0)
|
||||
PyErr_SetString(PyExc_KeyError, tag);
|
||||
else if (count > 0)
|
||||
PyList_Append(py_list, PyString_FromString(tag));
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_tag_list_keys(PyGObject *self)
|
||||
{
|
||||
PyObject *dict;
|
||||
|
||||
dict = PyList_New(0);
|
||||
|
||||
gst_tag_list_foreach(GST_TAG_LIST(self->obj),
|
||||
(GstTagForeachFunc)tag_foreach_func_list,
|
||||
(gpointer)dict);
|
||||
return dict;
|
||||
}
|
||||
%%
|
||||
override-slot GstTagList.tp_as_mapping
|
||||
static Py_ssize_t
|
||||
_wrap_gst_tag_list_length(PyObject *self)
|
||||
{
|
||||
PyGObject *gself = (PyGObject *)self;
|
||||
return gst_structure_n_fields((GstStructure*)gself->obj);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_tag_list_subscript(PyGObject *self, PyObject *py_key)
|
||||
{
|
||||
PyObject *v = NULL;
|
||||
const char *field = PyString_AsString(py_key);
|
||||
|
||||
if (gst_structure_has_field((GstStructure*)self->obj, field)) {
|
||||
const GValue *gvalue;
|
||||
gvalue = gst_structure_get_value((GstStructure*)self->obj, field);
|
||||
g_assert(gvalue != NULL);
|
||||
v = pygst_value_as_pyobject(gvalue, TRUE);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_KeyError, field);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
static int
|
||||
_wrap_gst_tag_list_ass_subscript(PyGObject *self,
|
||||
PyObject *py_key,
|
||||
PyObject *py_value)
|
||||
{
|
||||
const char *key;
|
||||
GstStructure* structure;
|
||||
GType tagtype;
|
||||
|
||||
structure = (GstStructure*)self->obj;
|
||||
key = PyString_AsString(py_key);
|
||||
if (py_value != NULL) {
|
||||
GValue v = { 0, };
|
||||
|
||||
if (!pygst_value_init_for_pyobject (&v, py_value))
|
||||
return -1;
|
||||
if (pygst_value_from_pyobject(&v, py_value))
|
||||
return -1;
|
||||
|
||||
/* some tags are supposed to be uint, but there is no unsigned
|
||||
* int python type, so convert here if needed */
|
||||
if (gst_tag_exists (key)) {
|
||||
tagtype = gst_tag_get_type (key);
|
||||
|
||||
if (tagtype && tagtype != G_VALUE_TYPE (&v)) {
|
||||
GValue w = { 0, };
|
||||
|
||||
g_value_init (&w, tagtype);
|
||||
g_value_transform (&v, &w);
|
||||
g_value_unset (&v);
|
||||
g_value_init (&v, tagtype);
|
||||
g_value_copy (&w, &v);
|
||||
}
|
||||
}
|
||||
gst_structure_set_value(structure, key, &v);
|
||||
g_value_unset(&v);
|
||||
} else {
|
||||
gst_structure_remove_field(structure, key);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyMappingMethods _wrap_gst_tag_list_tp_as_mapping = {
|
||||
_wrap_gst_tag_list_length, /* mp_length */
|
||||
(binaryfunc)_wrap_gst_tag_list_subscript, /* mp_subscript */
|
||||
(objobjargproc)_wrap_gst_tag_list_ass_subscript /* mp_ass_subscript */
|
||||
};
|
||||
%%
|
||||
override-slot GstTagList.tp_as_sequence
|
||||
static int
|
||||
_wrap_gst_tag_list_contains(PyGObject *self, PyObject *py_key)
|
||||
{
|
||||
return gst_structure_has_field((GstStructure*)self->obj,
|
||||
PyString_AsString(py_key));
|
||||
}
|
||||
|
||||
static PySequenceMethods _wrap_gst_tag_list_tp_as_sequence = {
|
||||
(lenfunc)NULL,
|
||||
(binaryfunc)NULL,
|
||||
(ssizeargfunc)NULL,
|
||||
(ssizeargfunc)NULL,
|
||||
(ssizessizeargfunc)NULL,
|
||||
(ssizeobjargproc)NULL,
|
||||
(ssizessizeobjargproc)NULL,
|
||||
(objobjproc)_wrap_gst_tag_list_contains,
|
||||
(binaryfunc)NULL,
|
||||
(ssizeargfunc)NULL,
|
||||
};
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
%%
|
||||
include
|
||||
@IGNORE_GST_0_10_21@
|
||||
@IGNORE_GST_0_10_22@
|
||||
@IGNORE_GST_0_10_23@
|
||||
@IGNORE_GST_PB_0_10_23@
|
||||
@IGNORE_GST_0_10_24@
|
||||
@IGNORE_GST_0_10_25@
|
||||
@IGNORE_GST_PB_0_10_25@
|
||||
@IGNORE_GST_0_10_26@
|
||||
@IGNORE_GST_PB_0_10_26@
|
||||
@IGNORE_GST_LOADSAVE@
|
||||
@IGNORE_GST_0_10_29@
|
||||
@IGNORE_GST_PB_0_10_29@
|
||||
@IGNORE_GST_0_10_30@
|
||||
@IGNORE_GST_PB_0_10_30@
|
||||
@IGNORE_GST_0_10_31@
|
||||
@IGNORE_GST_PB_0_10_31@
|
||||
@IGNORE_GST_0_10_32@
|
||||
@IGNORE_GST_PB_0_10_32@
|
||||
@IGNORE_GST_0_10_36@
|
||||
@IGNORE_GST_PB_0_10_36@
|
||||
%%
|
1255
gst/interfaces.defs
1255
gst/interfaces.defs
File diff suppressed because it is too large
Load diff
|
@ -1,486 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2004 David I. Lehn
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: David I. Lehn <dlehn@users.sourceforge.net>
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
#include "common.h"
|
||||
#include "pygst.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <gst/interfaces/colorbalance.h>
|
||||
#include <gst/interfaces/navigation.h>
|
||||
#include <gst/interfaces/propertyprobe.h>
|
||||
#include <gst/interfaces/tuner.h>
|
||||
#include <gst/interfaces/mixer.h>
|
||||
#include <gst/interfaces/videoorientation.h>
|
||||
#ifdef HAVE_STREAM_VOLUME_INTERFACE
|
||||
#include <gst/interfaces/streamvolume.h>
|
||||
#endif
|
||||
|
||||
%%
|
||||
modulename gst.interfaces
|
||||
%%
|
||||
import gobject.GObject as PyGObject_Type
|
||||
import gst.Object as PyGstObject_Type
|
||||
import gst.Structure as PyGstStructure_Type
|
||||
import gst.Element as PyGstElement_Type
|
||||
import gst.Query as PyGstQuery_Type
|
||||
%%
|
||||
include
|
||||
xoverlay.override
|
||||
gstversion.override
|
||||
%%
|
||||
ignore-glob
|
||||
_*
|
||||
gstinterfaces_*init
|
||||
*_get_type
|
||||
%%
|
||||
override gst_tuner_list_channels noargs
|
||||
static PyObject *
|
||||
_wrap_gst_tuner_list_channels(PyGObject *self)
|
||||
{
|
||||
const GList *l, *list;
|
||||
PyObject *py_list;
|
||||
|
||||
g_return_val_if_fail (GST_IS_TUNER (self->obj), PyList_New(0));
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
list = gst_tuner_list_channels(GST_TUNER(self->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
py_list = PyList_New(0);
|
||||
for (l = list; l; l = l->next) {
|
||||
GstTunerChannel *channel = (GstTunerChannel*)l->data;
|
||||
PyObject *py_channel = pygobject_new(G_OBJECT(channel));
|
||||
PyList_Append(py_list, py_channel);
|
||||
Py_DECREF(py_channel);
|
||||
}
|
||||
|
||||
return py_list;
|
||||
}
|
||||
%%
|
||||
override gst_tuner_list_norms noargs
|
||||
static PyObject *
|
||||
_wrap_gst_tuner_list_norms(PyGObject *self)
|
||||
{
|
||||
const GList *l, *list;
|
||||
PyObject *py_list;
|
||||
|
||||
g_return_val_if_fail (GST_IS_TUNER (self->obj), PyList_New(0));
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
list = gst_tuner_list_norms(GST_TUNER(self->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
py_list = PyList_New(0);
|
||||
for (l = list; l; l = l->next) {
|
||||
GstTunerNorm *norm = (GstTunerNorm*)l->data;
|
||||
PyObject *py_norm = pygobject_new(G_OBJECT(norm));
|
||||
PyList_Append(py_list, py_norm);
|
||||
Py_DECREF(py_norm);
|
||||
}
|
||||
|
||||
return py_list;
|
||||
}
|
||||
%%
|
||||
override gst_mixer_list_tracks noargs
|
||||
static PyObject *
|
||||
_wrap_gst_mixer_list_tracks(PyGObject *self)
|
||||
{
|
||||
const GList *l, *list;
|
||||
PyObject *py_list;
|
||||
|
||||
g_return_val_if_fail (GST_IS_MIXER (self->obj), PyList_New(0));
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
list = gst_mixer_list_tracks(GST_MIXER(self->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
py_list = PyList_New(0);
|
||||
for (l = list; l; l = l->next) {
|
||||
GstMixerTrack *track = (GstMixerTrack*)l->data;
|
||||
PyObject *py_track = pygobject_new(G_OBJECT(track));
|
||||
PyList_Append(py_list, py_track);
|
||||
Py_DECREF(py_track);
|
||||
}
|
||||
|
||||
return py_list;
|
||||
}
|
||||
%%
|
||||
override gst_color_balance_list_channels noargs
|
||||
static PyObject *
|
||||
_wrap_gst_color_balance_list_channels(PyGObject *self)
|
||||
{
|
||||
const GList *l, *list;
|
||||
PyObject *py_list;
|
||||
|
||||
g_return_val_if_fail (GST_IS_COLOR_BALANCE (self->obj), PyList_New(0));
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
list = gst_color_balance_list_channels(GST_COLOR_BALANCE(self->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
py_list = PyList_New(0);
|
||||
for (l = list; l; l = l->next) {
|
||||
GstColorBalanceChannel *channel = (GstColorBalanceChannel*)l->data;
|
||||
PyObject *py_channel = pygobject_new(G_OBJECT(channel));
|
||||
PyList_Append(py_list, py_channel);
|
||||
Py_DECREF(py_channel);
|
||||
}
|
||||
|
||||
return py_list;
|
||||
}
|
||||
%%
|
||||
override gst_mixer_options_get_values noargs
|
||||
static PyObject *
|
||||
_wrap_gst_mixer_options_get_values (PyGObject *self)
|
||||
{
|
||||
GList *l, *list;
|
||||
PyObject *py_list;
|
||||
|
||||
g_return_val_if_fail (GST_IS_MIXER_OPTIONS (self->obj), PyList_New(0));
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
list = gst_mixer_options_get_values (GST_MIXER_OPTIONS (self->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
py_list = PyList_New(0);
|
||||
for (l = list; l; l = l->next) {
|
||||
gchar *value = (gchar *) l->data;
|
||||
PyObject *py_string = PyString_FromString(g_strdup(value));
|
||||
PyList_Append(py_list, py_string);
|
||||
Py_DECREF (py_string);
|
||||
}
|
||||
|
||||
return py_list;
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_mixer_set_volume kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_mixer_set_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "track", "volumes", NULL };
|
||||
PyGObject *track;
|
||||
PyObject *py_tuple;
|
||||
gint *volumes = NULL;
|
||||
gint channels;
|
||||
int i;
|
||||
PyObject *ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!O:GstMixer.set_volume",
|
||||
kwlist, &PyGstMixerTrack_Type, &track, &py_tuple))
|
||||
return NULL;
|
||||
|
||||
g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
|
||||
NULL);
|
||||
|
||||
if (channels != PyTuple_Size (py_tuple)) {
|
||||
PyErr_Format (PyExc_TypeError,
|
||||
"Track channel count %d != volume tuple size %d",
|
||||
channels, (gint) PyTuple_Size (py_tuple));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
ret = Py_None;
|
||||
|
||||
if (channels == 0)
|
||||
return ret;
|
||||
|
||||
volumes = g_malloc (channels * sizeof (gint));
|
||||
for (i = 0; i < channels; ++i) {
|
||||
volumes[i] = PyInt_AsLong (PyTuple_GET_ITEM (py_tuple, i));
|
||||
}
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
gst_mixer_set_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
|
||||
volumes);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
g_free (volumes);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_mixer_get_volume kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_mixer_get_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "track", NULL };
|
||||
PyGObject *track;
|
||||
PyObject *py_tuple;
|
||||
gint *volumes = NULL;
|
||||
gint channels;
|
||||
int i;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!:GstMixer.get_volume",
|
||||
kwlist, &PyGstMixerTrack_Type, &track))
|
||||
return NULL;
|
||||
|
||||
g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
|
||||
NULL);
|
||||
|
||||
volumes = g_malloc (channels * sizeof (gint));
|
||||
/* 0 channels will cause volume to be a NULL pointer, but we still want
|
||||
* our (empty) tuple */
|
||||
if (channels) {
|
||||
pyg_begin_allow_threads;
|
||||
gst_mixer_get_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
|
||||
volumes);
|
||||
pyg_end_allow_threads;
|
||||
}
|
||||
|
||||
py_tuple = PyTuple_New (channels);
|
||||
|
||||
for (i = 0; i < channels; ++i) {
|
||||
PyTuple_SET_ITEM (py_tuple, i, PyInt_FromLong (volumes[i]));
|
||||
}
|
||||
g_free (volumes);
|
||||
|
||||
return py_tuple;
|
||||
}
|
||||
|
||||
%%
|
||||
override gst_property_probe_get_property args
|
||||
static PyObject *
|
||||
_wrap_gst_property_probe_get_property (PyGObject *self, PyObject *args)
|
||||
{
|
||||
const char *name;
|
||||
const GParamSpec *spec;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_property", &name))
|
||||
return NULL;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
spec = gst_property_probe_get_property (GST_PROPERTY_PROBE (self->obj),
|
||||
name);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
if (!spec) {
|
||||
PyErr_Format(PyExc_ValueError, "unknown property: %s", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pyg_param_spec_new((GParamSpec*)spec);
|
||||
}
|
||||
%%
|
||||
override gst_property_probe_get_properties noargs
|
||||
static PyObject *
|
||||
_wrap_gst_property_probe_get_properties (PyGObject *self)
|
||||
{
|
||||
const GList *l, *list;
|
||||
PyObject *py_list;
|
||||
|
||||
g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
list = gst_property_probe_get_properties (GST_PROPERTY_PROBE (self->obj));
|
||||
pyg_end_allow_threads;
|
||||
|
||||
py_list = PyList_New(0);
|
||||
for (l = list; l; l = l->next) {
|
||||
GParamSpec *spec = (GParamSpec*)l->data;
|
||||
PyObject *py_gspec = pyg_param_spec_new((GParamSpec*)spec);
|
||||
PyList_Append(py_list, py_gspec);
|
||||
Py_DECREF(py_gspec);
|
||||
}
|
||||
|
||||
return py_list;
|
||||
}
|
||||
%%
|
||||
override gst_property_probe_get_values_name args
|
||||
static PyObject *
|
||||
_wrap_gst_property_probe_get_values_name (PyGObject *self, PyObject *args)
|
||||
{
|
||||
const char *name;
|
||||
GValueArray *array;
|
||||
PyObject *py_list;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_values_name", &name))
|
||||
return NULL;
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
array = gst_property_probe_get_values_name (GST_PROPERTY_PROBE (self->obj),
|
||||
name);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
py_list = PyList_New(0);
|
||||
|
||||
if (array) {
|
||||
for (i = 0; i < array->n_values; i++) {
|
||||
GValue *value = g_value_array_get_nth(array, i);
|
||||
PyObject *py_value = pyg_value_as_pyobject(value, TRUE);
|
||||
PyList_Append(py_list, py_value);
|
||||
Py_DECREF(py_value);
|
||||
|
||||
}
|
||||
g_value_array_free(array);
|
||||
}
|
||||
|
||||
return py_list;
|
||||
}
|
||||
%%
|
||||
override gst_mixer_message_parse_mute_toggled noargs
|
||||
static PyObject *
|
||||
_wrap_gst_mixer_message_parse_mute_toggled (PyGstMiniObject * self)
|
||||
{
|
||||
GstMixerTrack *track;
|
||||
gboolean mute;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_MUTE_TOGGLED) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a mute-toggled message");
|
||||
return NULL;
|
||||
}
|
||||
gst_mixer_message_parse_mute_toggled (GST_MESSAGE(self->obj), &track, &mute);
|
||||
|
||||
return Py_BuildValue("(OO)",
|
||||
pygobject_new(G_OBJECT (track)),
|
||||
PyBool_FromLong(mute));
|
||||
}
|
||||
%%
|
||||
override gst_mixer_message_parse_record_toggled noargs
|
||||
static PyObject *
|
||||
_wrap_gst_mixer_message_parse_record_toggled (PyGstMiniObject * self)
|
||||
{
|
||||
GstMixerTrack *track;
|
||||
gboolean record;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_RECORD_TOGGLED) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a record-toggled message");
|
||||
return NULL;
|
||||
}
|
||||
gst_mixer_message_parse_record_toggled (GST_MESSAGE(self->obj), &track, &record);
|
||||
|
||||
return Py_BuildValue("(OO)",
|
||||
pygobject_new(G_OBJECT (track)),
|
||||
PyBool_FromLong(record));
|
||||
}
|
||||
%%
|
||||
override gst_mixer_message_parse_volume_changed noargs
|
||||
static PyObject *
|
||||
_wrap_gst_mixer_message_parse_volume_changed (PyGstMiniObject * self)
|
||||
{
|
||||
GstMixerTrack *track;
|
||||
gint *volumes;
|
||||
gint num_channels;
|
||||
PyObject *pvolumes;
|
||||
int i;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_VOLUME_CHANGED) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a volume-changed message");
|
||||
return NULL;
|
||||
}
|
||||
gst_mixer_message_parse_volume_changed (GST_MESSAGE(self->obj), &track, &volumes, &num_channels);
|
||||
|
||||
pvolumes = PyList_New (num_channels);
|
||||
|
||||
for (i = 0; i < num_channels; ++i) {
|
||||
PyList_SET_ITEM (pvolumes, i, PyInt_FromLong (volumes[i]));
|
||||
}
|
||||
g_free (volumes);
|
||||
|
||||
return Py_BuildValue("(OOi)",
|
||||
pygobject_new(G_OBJECT (track)),
|
||||
pvolumes, num_channels);
|
||||
}
|
||||
%%
|
||||
override gst_mixer_message_parse_option_changed noargs
|
||||
static PyObject *
|
||||
_wrap_gst_mixer_message_parse_option_changed (PyGstMiniObject * self)
|
||||
{
|
||||
GstMixerOptions *options;
|
||||
const gchar *value = NULL;
|
||||
|
||||
if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_OPTION_CHANGED) {
|
||||
PyErr_SetString(PyExc_TypeError, "Message is not a option-changed message");
|
||||
return NULL;
|
||||
}
|
||||
gst_mixer_message_parse_option_changed (GST_MESSAGE(self->obj), &options, &value);
|
||||
|
||||
return Py_BuildValue("(Os)",
|
||||
pygobject_new(G_OBJECT (options)),
|
||||
value);
|
||||
}
|
||||
%%
|
||||
override gst_video_orientation_get_hflip noargs
|
||||
static PyObject *
|
||||
_wrap_gst_video_orientation_get_hflip (PyGObject * self)
|
||||
{
|
||||
gboolean flip, res;
|
||||
|
||||
res = gst_video_orientation_get_hflip (GST_VIDEO_ORIENTATION (self->obj), &flip);
|
||||
|
||||
return Py_BuildValue("(OO)",
|
||||
PyBool_FromLong(res),
|
||||
PyBool_FromLong(flip));
|
||||
}
|
||||
%%
|
||||
override gst_video_orientation_get_vflip noargs
|
||||
static PyObject *
|
||||
_wrap_gst_video_orientation_get_vflip (PyGObject * self)
|
||||
{
|
||||
gboolean flip, res;
|
||||
|
||||
res = gst_video_orientation_get_vflip (GST_VIDEO_ORIENTATION (self->obj), &flip);
|
||||
|
||||
return Py_BuildValue("(OO)",
|
||||
PyBool_FromLong(res),
|
||||
PyBool_FromLong(flip));
|
||||
}
|
||||
%%
|
||||
override gst_video_orientation_get_hcenter noargs
|
||||
static PyObject *
|
||||
_wrap_gst_video_orientation_get_hcenter (PyGObject * self)
|
||||
{
|
||||
gboolean res;
|
||||
gint center;
|
||||
|
||||
res = gst_video_orientation_get_hcenter (GST_VIDEO_ORIENTATION (self->obj), ¢er);
|
||||
|
||||
return Py_BuildValue("(Oi)",
|
||||
PyBool_FromLong(res),
|
||||
center);
|
||||
}
|
||||
%%
|
||||
override gst_video_orientation_get_vcenter noargs
|
||||
static PyObject *
|
||||
_wrap_gst_video_orientation_get_vcenter (PyGObject * self)
|
||||
{
|
||||
gboolean res;
|
||||
gint center;
|
||||
|
||||
res = gst_video_orientation_get_vcenter (GST_VIDEO_ORIENTATION (self->obj), ¢er);
|
||||
|
||||
return Py_BuildValue("(Oi)",
|
||||
PyBool_FromLong(res),
|
||||
center);
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2004 David I. Lehn
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: David I. Lehn <dlehn@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
||||
#include <pygobject.h>
|
||||
#include <gst/gst.h>
|
||||
#include "pygst.h"
|
||||
|
||||
void pyinterfaces_register_classes (PyObject * d);
|
||||
void pyinterfaces_add_constants (PyObject * module, const gchar * strip_prefix);
|
||||
|
||||
extern PyMethodDef pyinterfaces_functions[];
|
||||
|
||||
DL_EXPORT (void)
|
||||
initinterfaces (void)
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
init_pygobject ();
|
||||
pygst_init ();
|
||||
|
||||
m = Py_InitModule ("interfaces", pyinterfaces_functions);
|
||||
d = PyModule_GetDict (m);
|
||||
|
||||
pyinterfaces_register_classes (d);
|
||||
pyinterfaces_add_constants (m, "GST_");
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
Py_FatalError ("can't initialize module gst.interfaces");
|
||||
}
|
||||
}
|
684
gst/libs.defs
684
gst/libs.defs
|
@ -1,684 +0,0 @@
|
|||
;; -*- scheme -*-
|
||||
; object definitions ...
|
||||
|
||||
(define-object ControlSource
|
||||
(in-module "Gst")
|
||||
(parent "GObject")
|
||||
(c-name "GstControlSource")
|
||||
(gtype-id "GST_TYPE_CONTROL_SOURCE")
|
||||
)
|
||||
|
||||
(define-object Controller
|
||||
(in-module "Gst")
|
||||
(parent "GObject")
|
||||
(c-name "GstController")
|
||||
(gtype-id "GST_TYPE_CONTROLLER")
|
||||
)
|
||||
|
||||
(define-object InterpolationControlSource
|
||||
(in-module "Gst")
|
||||
(parent "GstControlSource")
|
||||
(c-name "GstInterpolationControlSource")
|
||||
(gtype-id "GST_TYPE_INTERPOLATION_CONTROL_SOURCE")
|
||||
)
|
||||
|
||||
(define-object LFOControlSource
|
||||
(in-module "Gst")
|
||||
(parent "GstControlSource")
|
||||
(c-name "GstLFOControlSource")
|
||||
(gtype-id "GST_TYPE_LFO_CONTROL_SOURCE")
|
||||
)
|
||||
|
||||
|
||||
;; Enumerations and flags ...
|
||||
|
||||
(define-enum InterpolateMode
|
||||
(in-module "Gst")
|
||||
(c-name "GstInterpolateMode")
|
||||
(values
|
||||
'("none" "GST_INTERPOLATE_NONE")
|
||||
'("trigger" "GST_INTERPOLATE_TRIGGER")
|
||||
'("linear" "GST_INTERPOLATE_LINEAR")
|
||||
'("quadratic" "GST_INTERPOLATE_QUADRATIC")
|
||||
'("cubic" "GST_INTERPOLATE_CUBIC")
|
||||
'("user" "GST_INTERPOLATE_USER")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum LFOWaveform
|
||||
(in-module "Gst")
|
||||
(c-name "GstLFOWaveform")
|
||||
(gtype-id "GST_TYPE_LFO_WAVEFORM")
|
||||
(values
|
||||
'("sine" "GST_LFO_WAVEFORM_SINE")
|
||||
'("square" "GST_LFO_WAVEFORM_SQUARE")
|
||||
'("saw" "GST_LFO_WAVEFORM_SAW")
|
||||
'("reverse-saw" "GST_LFO_WAVEFORM_REVERSE_SAW")
|
||||
'("triangle" "GST_LFO_WAVEFORM_TRIANGLE")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum DPVersion
|
||||
(in-module "Gst")
|
||||
(c-name "GstDPVersion")
|
||||
(gtype-id "GST_TYPE_DP_VERSION")
|
||||
(values
|
||||
'("0-2" "GST_DP_VERSION_0_2")
|
||||
'("1-0" "GST_DP_VERSION_1_0")
|
||||
)
|
||||
)
|
||||
|
||||
(define-flags DPHeaderFlag
|
||||
(in-module "Gst")
|
||||
(c-name "GstDPHeaderFlag")
|
||||
(values
|
||||
'("none" "GST_DP_HEADER_FLAG_NONE")
|
||||
'("crc-header" "GST_DP_HEADER_FLAG_CRC_HEADER")
|
||||
'("crc-payload" "GST_DP_HEADER_FLAG_CRC_PAYLOAD")
|
||||
'("crc" "GST_DP_HEADER_FLAG_CRC")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum DPPayloadType
|
||||
(in-module "Gst")
|
||||
(c-name "GstDPPayloadType")
|
||||
(values
|
||||
'("none" "GST_DP_PAYLOAD_NONE")
|
||||
'("buffer" "GST_DP_PAYLOAD_BUFFER")
|
||||
'("caps" "GST_DP_PAYLOAD_CAPS")
|
||||
'("event-none" "GST_DP_PAYLOAD_EVENT_NONE")
|
||||
)
|
||||
)
|
||||
|
||||
;; From ../gstreamer/libs/gst/controller/gst-controller.h
|
||||
|
||||
(define-function gst_controller_get_type
|
||||
(c-name "gst_controller_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function gst_controller_new_valist
|
||||
(c-name "gst_controller_new_valist")
|
||||
(return-type "GstController*")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
'("va_list" "var_args")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_controller_new_list
|
||||
(c-name "gst_controller_new_list")
|
||||
(is-constructor-of "GstController")
|
||||
(return-type "GstController*")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
'("GList*" "list")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_controller_new
|
||||
(c-name "gst_controller_new")
|
||||
(return-type "GstController*")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
)
|
||||
(varargs #t)
|
||||
)
|
||||
|
||||
(define-method remove_properties_valist
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_remove_properties_valist")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("va_list" "var_args")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method remove_properties
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_remove_properties")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
)
|
||||
(varargs #t)
|
||||
)
|
||||
|
||||
(define-method remove_properties_list
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_remove_properties_list")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GList*" "list")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_disabled
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_set_disabled")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gboolean" "disabled")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_property_disabled
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_set_property_disabled")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
'("gboolean" "disabled")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_control_source
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_set_control_source")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
'("GstControlSource*" "csource")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_control_source
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_get_control_source")
|
||||
(return-type "GstControlSource*")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
)
|
||||
)
|
||||
(define-method set
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_set")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GValue*" "value")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_from_list
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_set_from_list")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
'("GSList*" "timedvalues")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method unset
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_unset")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
'("GstClockTime" "timestamp")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method unset_all
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_unset_all")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_get")
|
||||
(return-type "GValue*")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
'("GstClockTime" "timestamp")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_all
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_get_all")
|
||||
(return-type "const-GList*")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method suggest_next_sync
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_suggest_next_sync")
|
||||
(return-type "GstClockTime")
|
||||
)
|
||||
|
||||
(define-method sync_values
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_sync_values")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstClockTime" "timestamp")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_value_arrays
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_get_value_arrays")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GSList*" "value_arrays")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_value_array
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_get_value_array")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GstValueArray*" "value_array")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_interpolation_mode
|
||||
(of-object "GstController")
|
||||
(c-name "gst_controller_set_interpolation_mode")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("gchar*" "property_name")
|
||||
'("GstInterpolateMode" "mode")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function object_control_properties
|
||||
(c-name "gst_object_control_properties")
|
||||
(return-type "GstController*")
|
||||
(parameters
|
||||
'("GObject*" "object"))
|
||||
(varargs #t)
|
||||
)
|
||||
|
||||
(define-function object_uncontrol_properties
|
||||
(c-name "gst_object_uncontrol_properties")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
)
|
||||
(varargs #t)
|
||||
)
|
||||
|
||||
(define-function object_get_controller
|
||||
(c-name "gst_object_get_controller")
|
||||
(return-type "GstController*")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function object_set_controller
|
||||
(c-name "gst_object_set_controller")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
'("GstController*" "controller")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function object_suggest_next_sync
|
||||
(c-name "gst_object_suggest_next_sync")
|
||||
(return-type "GstClockTime")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function object_sync_values
|
||||
(c-name "gst_object_sync_values")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
'("GstClockTime" "timestamp")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_object_set_control_source
|
||||
(c-name "gst_object_set_control_source")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
'("gchar*" "property_name")
|
||||
'("GstControlSource*" "csource")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_object_get_control_source
|
||||
(c-name "gst_object_get_control_source")
|
||||
(return-type "GstControlSource*")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
'("gchar*" "property_name")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function object_get_value_arrays
|
||||
(c-name "gst_object_get_value_arrays")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GSList*" "value_arrays")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function object_get_value_array
|
||||
(c-name "gst_object_get_value_array")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GstValueArray*" "value_array")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function object_get_control_rate
|
||||
(c-name "gst_object_get_control_rate")
|
||||
(return-type "GstClockTime")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function object_set_control_rate
|
||||
(c-name "gst_object_set_control_rate")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GObject*" "object")
|
||||
'("GstClockTime" "control_rate")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_controller_init
|
||||
(c-name "gst_controller_init")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("int*" "argc")
|
||||
'("char***" "argv")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From gstcontrolsource.h
|
||||
|
||||
(define-function gst_control_source_get_type
|
||||
(c-name "gst_control_source_get_type")
|
||||
(return-type "GType")
|
||||
(parameters
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_value
|
||||
(of-object "GstControlSource")
|
||||
(c-name "gst_control_source_get_value")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GValue*" "value")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_value_array
|
||||
(of-object "GstControlSource")
|
||||
(c-name "gst_control_source_get_value_array")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GstValueArray*" "value_array")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method bind
|
||||
(of-object "GstControlSource")
|
||||
(c-name "gst_control_source_bind")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GParamSpec*" "pspec")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From gstinterpolationcontrolsource.h
|
||||
|
||||
(define-function gst_interpolation_control_source_get_type
|
||||
(c-name "gst_interpolation_control_source_get_type")
|
||||
(return-type "GType")
|
||||
(parameters
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_interpolation_control_source_new
|
||||
(c-name "gst_interpolation_control_source_new")
|
||||
(is-constructor-of "GstInterpolationControlSource")
|
||||
(return-type "GstInterpolationControlSource*")
|
||||
(parameters
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_interpolation_mode
|
||||
(of-object "GstInterpolationControlSource")
|
||||
(c-name "gst_interpolation_control_source_set_interpolation_mode")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstInterpolateMode" "mode")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set
|
||||
(of-object "GstInterpolationControlSource")
|
||||
(c-name "gst_interpolation_control_source_set")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GValue*" "value")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_from_list
|
||||
(of-object "GstInterpolationControlSource")
|
||||
(c-name "gst_interpolation_control_source_set_from_list")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GSList*" "timedvalues")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method unset
|
||||
(of-object "GstInterpolationControlSource")
|
||||
(c-name "gst_interpolation_control_source_unset")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstClockTime" "timestamp")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method unset_all
|
||||
(of-object "GstInterpolationControlSource")
|
||||
(c-name "gst_interpolation_control_source_unset_all")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-method get_all
|
||||
(of-object "GstInterpolationControlSource")
|
||||
(c-name "gst_interpolation_control_source_get_all")
|
||||
(return-type "GList*")
|
||||
)
|
||||
|
||||
(define-method get_count
|
||||
(of-object "GstInterpolationControlSource")
|
||||
(c-name "gst_interpolation_control_source_get_count")
|
||||
(return-type "gint")
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From gstlfocontrolsource.h
|
||||
|
||||
(define-function gst_lfo_control_source_get_type
|
||||
(c-name "gst_lfo_control_source_get_type")
|
||||
(return-type "GType")
|
||||
(parameters
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_lfo_waveform_get_type
|
||||
(c-name "gst_lfo_waveform_get_type")
|
||||
(return-type "GType")
|
||||
(parameters
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_lfo_control_source_new
|
||||
(c-name "gst_lfo_control_source_new")
|
||||
(is-constructor-of "GstLfoControlSource")
|
||||
(return-type "GstLFOControlSource*")
|
||||
(parameters
|
||||
)
|
||||
)
|
||||
|
||||
;; From ../gstreamer/libs/gst/dataprotocol/dataprotocol.h
|
||||
|
||||
(define-function dp_init
|
||||
(c-name "gst_dp_init")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-function dp_packetizer_new
|
||||
(c-name "gst_dp_packetizer_new")
|
||||
(is-constructor-of "GstDpPacketizer")
|
||||
(return-type "GstDPPacketizer*")
|
||||
(parameters
|
||||
'("GstDPVersion" "version")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_dp_crc
|
||||
(c-name "gst_dp_crc")
|
||||
(return-type "guint16")
|
||||
(parameters
|
||||
'("const-guint8*" "buffer")
|
||||
'("guint" "length")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_header_payload_length
|
||||
(c-name "gst_dp_header_payload_length")
|
||||
(return-type "guint32")
|
||||
(parameters
|
||||
'("const-gchar*" "header")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_header_payload_type
|
||||
(c-name "gst_dp_header_payload_type")
|
||||
(return-type "GstDPPayloadType")
|
||||
(parameters
|
||||
'("const-gchar*" "header")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_header_from_buffer
|
||||
(c-name "gst_dp_header_from_buffer")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("const-GstBuffer*" "buffer")
|
||||
'("GstDPHeaderFlag" "flags")
|
||||
'("guint*" "length")
|
||||
'("guint8**" "header")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_packet_from_caps
|
||||
(c-name "gst_dp_packet_from_caps")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("const-GstCaps*" "caps")
|
||||
'("GstDPHeaderFlag" "flags")
|
||||
'("guint*" "length")
|
||||
'("guint8**" "header")
|
||||
'("guint8**" "payload")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_packet_from_event
|
||||
(c-name "gst_dp_packet_from_event")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("const-GstEvent*" "event")
|
||||
'("GstDPHeaderFlag" "flags")
|
||||
'("guint*" "length")
|
||||
'("guint8**" "header")
|
||||
'("guint8**" "payload")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_buffer_from_header
|
||||
(c-name "gst_dp_buffer_from_header")
|
||||
(return-type "GstBuffer*")
|
||||
(parameters
|
||||
'("guint" "header_length")
|
||||
'("const-guint8*" "header")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_caps_from_packet
|
||||
(c-name "gst_dp_caps_from_packet")
|
||||
(return-type "GstCaps*")
|
||||
(parameters
|
||||
'("guint" "header_length")
|
||||
'("const-guint8*" "header")
|
||||
'("const-guint8*" "payload")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_event_from_packet
|
||||
(c-name "gst_dp_event_from_packet")
|
||||
(return-type "GstEvent*")
|
||||
(parameters
|
||||
'("guint" "header_length")
|
||||
'("const-guint8*" "header")
|
||||
'("const-guint8*" "payload")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_validate_header
|
||||
(c-name "gst_dp_validate_header")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("guint" "header_length")
|
||||
'("const-guint8*" "header")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_validate_payload
|
||||
(c-name "gst_dp_validate_payload")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("guint" "header_length")
|
||||
'("const-guint8*" "header")
|
||||
'("const-guint8*" "payload")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function dp_validate_packet
|
||||
(c-name "gst_dp_validate_packet")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("guint" "header_length")
|
||||
'("const-guint8*" "header")
|
||||
'("const-guint8*" "payload")
|
||||
)
|
||||
)
|
1056
gst/pbutils.defs
1056
gst/pbutils.defs
File diff suppressed because it is too large
Load diff
|
@ -1,486 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2008 <edward.hervey@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
#include "common.h"
|
||||
#include "pygst.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <gst/pbutils/pbutils.h>
|
||||
#include "pygstminiobject.h"
|
||||
GST_DEBUG_CATEGORY_EXTERN (pygst_debug);
|
||||
#define GST_CAT_DEFAULT pygst_debug
|
||||
|
||||
/* Boonky define that allows for backwards compatibility with Python 2.4 */
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
#define Py_ssize_t int
|
||||
#endif
|
||||
|
||||
static void
|
||||
install_plugins_result_handler(GstInstallPluginsReturn result, gpointer user_data)
|
||||
{
|
||||
PyGILState_STATE state;
|
||||
PyObject *callback, *args;
|
||||
PyObject *py_user_data;
|
||||
PyObject *py_result;
|
||||
PyObject *ret;
|
||||
gint i, len;
|
||||
|
||||
if (user_data == NULL)
|
||||
return;
|
||||
|
||||
state = pyg_gil_state_ensure();
|
||||
|
||||
py_user_data = (PyObject*) user_data;
|
||||
py_result = pyg_enum_from_gtype(GST_TYPE_INSTALL_PLUGINS_RETURN, result);
|
||||
|
||||
callback = PyTuple_GetItem(py_user_data, 0);
|
||||
args = Py_BuildValue("(N)", py_result);
|
||||
|
||||
len = PyTuple_Size(py_user_data);
|
||||
for (i = 1; i < len; ++i) {
|
||||
PyObject *tuple = args;
|
||||
args = PySequence_Concat(tuple, PyTuple_GetItem(py_user_data, i));
|
||||
Py_DECREF(tuple);
|
||||
}
|
||||
|
||||
ret = PyObject_CallObject(callback, args);
|
||||
|
||||
if (PyErr_Occurred())
|
||||
PyErr_Print();
|
||||
|
||||
Py_DECREF(args);
|
||||
pyg_gil_state_release(state);
|
||||
|
||||
}
|
||||
%%
|
||||
modulename gst.pbutils
|
||||
%%
|
||||
import gobject.GObject as PyGObject_Type
|
||||
import gst.Object as PyGstObject_Type
|
||||
import gst.Structure as PyGstStructure_Type
|
||||
import gst.Element as PyGstElement_Type
|
||||
import gst.Message as PyGstMessage_Type
|
||||
import gst.MiniObject as PyGstMiniObject_Type
|
||||
%%
|
||||
include
|
||||
gstversion.override
|
||||
%%
|
||||
ignore-glob
|
||||
_*
|
||||
*init
|
||||
*_free
|
||||
*_get_type
|
||||
%%
|
||||
override gst_install_plugins_sync kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_install_plugins_sync(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "details", "context", NULL };
|
||||
PyObject *py_ctx;
|
||||
GstInstallPluginsContext *ctx;
|
||||
GstInstallPluginsReturn ret;
|
||||
gchar **details;
|
||||
gint len;
|
||||
PyObject *py_ret;
|
||||
PyObject *py_details;
|
||||
Py_ssize_t i;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:install_plugins_sync",
|
||||
kwlist, &py_details, &py_ctx))
|
||||
return NULL;
|
||||
|
||||
if (!pyg_boxed_check(py_ctx, GST_TYPE_INSTALL_PLUGINS_CONTEXT)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Argument 2 must be a gst.pbutils.InstallPluginsContext");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = PySequence_Size(py_details);
|
||||
if ((!PySequence_Check(py_details)) || (len < 1)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Details need to be a non-empty list or tuple of strings");
|
||||
Py_DECREF(py_details);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
details = g_new0(gchar*, len+1);
|
||||
|
||||
/* Check all items in py_details are strings */
|
||||
for (i = 0; i < len; i++) {
|
||||
PyObject *py_str = PySequence_GetItem(py_details, i);
|
||||
gchar *str;
|
||||
|
||||
if (!PyString_Check(py_str)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Details need to be a non-empty list or tuple of strings");
|
||||
Py_DECREF(py_str);
|
||||
Py_DECREF(py_details);
|
||||
g_strfreev(details);
|
||||
return NULL;
|
||||
}
|
||||
if (!(str = PyString_AsString(py_str))) {
|
||||
Py_DECREF(py_str);
|
||||
Py_DECREF(py_details);
|
||||
g_strfreev(details);
|
||||
return NULL;
|
||||
}
|
||||
details[i] = g_strdup(str);
|
||||
Py_DECREF(py_str);
|
||||
}
|
||||
|
||||
ctx = (GstInstallPluginsContext *) pyg_boxed_get(py_ctx, GstInstallPluginsContext);
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_install_plugins_sync(details, ctx);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
g_strfreev(details);
|
||||
|
||||
py_ret = pyg_enum_from_gtype(GST_TYPE_INSTALL_PLUGINS_RETURN, ret);
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override gst_install_plugins_async args
|
||||
static PyObject *
|
||||
_wrap_gst_install_plugins_async(PyGObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *py_ctx, *py_ret, *py_details, *callback, *cbargs, *data;
|
||||
GstInstallPluginsContext *ctx;
|
||||
GstInstallPluginsReturn ret;
|
||||
gchar **details;
|
||||
gint len;
|
||||
Py_ssize_t i;
|
||||
|
||||
if (PyTuple_Size(args) < 3) {
|
||||
PyErr_SetString(PyExc_TypeError, "install_plugins_async requires at least 3 arguments");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
py_ctx = PySequence_GetItem(args, 1);
|
||||
|
||||
if (!pyg_boxed_check(py_ctx, GST_TYPE_INSTALL_PLUGINS_CONTEXT)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Argument 2 must be a gst.pbutils.InstallPluginsContext");
|
||||
Py_DECREF(py_ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
py_details = PySequence_GetItem(args, 0);
|
||||
if ((!PySequence_Check(py_details)) || (PySequence_Size(py_details) < 1)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Details need to be a non-empty list or tuple of strings");
|
||||
Py_DECREF(py_ctx);
|
||||
Py_DECREF(py_details);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = PySequence_Size(py_details);
|
||||
details = g_new0(gchar*, len+1);
|
||||
|
||||
/* Check all items in py_details are strings */
|
||||
for (i = 0; i < len; i++) {
|
||||
PyObject *py_str = PySequence_GetItem(py_details, i);
|
||||
gchar *str;
|
||||
|
||||
if (!PyString_Check(py_str)) {
|
||||
PyErr_SetString(PyExc_TypeError, "Details need to be a non-empty list or tuple of strings");
|
||||
Py_DECREF(py_str);
|
||||
Py_DECREF(py_ctx);
|
||||
Py_DECREF(py_details);
|
||||
g_strfreev(details);
|
||||
return NULL;
|
||||
}
|
||||
if (!(str = PyString_AsString(py_str))) {
|
||||
Py_DECREF(py_str);
|
||||
Py_DECREF(py_ctx);
|
||||
Py_DECREF(py_details);
|
||||
g_strfreev(details);
|
||||
return NULL;
|
||||
}
|
||||
details[i] = g_strdup(str);
|
||||
Py_DECREF(py_str);
|
||||
}
|
||||
|
||||
callback = PySequence_GetItem(args, 2);
|
||||
if (!PyCallable_Check(callback)) {
|
||||
PyErr_SetString(PyExc_TypeError, "callback is not callable");
|
||||
Py_DECREF(callback);
|
||||
Py_DECREF(py_ctx);
|
||||
Py_DECREF(py_details);
|
||||
g_strfreev(details);
|
||||
}
|
||||
|
||||
if (!(cbargs = PySequence_GetSlice(args, 3, PyTuple_Size(args)))) {
|
||||
Py_DECREF(callback);
|
||||
Py_DECREF(py_ctx);
|
||||
Py_DECREF(py_details);
|
||||
g_strfreev(details);
|
||||
return NULL;
|
||||
}
|
||||
if (!(data = Py_BuildValue("(ON)", callback, cbargs))) {
|
||||
Py_DECREF(py_details);
|
||||
Py_DECREF(py_ctx);
|
||||
Py_DECREF(callback);
|
||||
Py_DECREF(cbargs);
|
||||
}
|
||||
|
||||
ctx = (GstInstallPluginsContext *) pyg_boxed_get(py_ctx, GstInstallPluginsContext);
|
||||
pyg_begin_allow_threads;
|
||||
ret = gst_install_plugins_async(details, ctx,
|
||||
(GstInstallPluginsResultFunc) install_plugins_result_handler,
|
||||
data);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
g_strfreev(details);
|
||||
|
||||
py_ret = pyg_enum_from_gtype(GST_TYPE_INSTALL_PLUGINS_RETURN, ret);
|
||||
return py_ret;
|
||||
}
|
||||
%%
|
||||
override gst_plugins_base_version noargs
|
||||
static PyObject *
|
||||
_wrap_gst_plugins_base_version (PyObject *self)
|
||||
{
|
||||
guint major, minor, micro, nano;
|
||||
PyObject *py_tuple;
|
||||
|
||||
gst_plugins_base_version (&major, &minor, µ, &nano);
|
||||
py_tuple = PyTuple_New(4);
|
||||
PyTuple_SetItem(py_tuple, 0, PyInt_FromLong(major));
|
||||
PyTuple_SetItem(py_tuple, 1, PyInt_FromLong(minor));
|
||||
PyTuple_SetItem(py_tuple, 2, PyInt_FromLong(micro));
|
||||
PyTuple_SetItem(py_tuple, 3, PyInt_FromLong(nano));
|
||||
|
||||
return py_tuple;
|
||||
}
|
||||
%%
|
||||
override gst_discoverer_info_get_stream_list noargs
|
||||
static PyObject *
|
||||
_wrap_gst_discoverer_info_get_stream_list(PyGstMiniObject * self)
|
||||
{
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres;
|
||||
|
||||
res = gst_discoverer_info_get_stream_list(GST_DISCOVERER_INFO (self->obj));
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
||||
}
|
||||
if (res)
|
||||
gst_discoverer_stream_info_list_free(res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_discoverer_info_get_streams kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_discoverer_info_get_streams(PyGstMiniObject * self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "type", NULL };
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres, *py_type;
|
||||
GType ftype;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O:GstDiscovererInfo.get_streams", kwlist, &py_type))
|
||||
return NULL;
|
||||
if ((ftype = pyg_type_from_object(py_type)) == 0)
|
||||
return NULL;
|
||||
res = gst_discoverer_info_get_streams(GST_DISCOVERER_INFO (self->obj), ftype);
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
||||
}
|
||||
if (res)
|
||||
gst_discoverer_stream_info_list_free(res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_discoverer_info_get_audio_streams noargs
|
||||
static PyObject *
|
||||
_wrap_gst_discoverer_info_get_audio_streams(PyGstMiniObject * self)
|
||||
{
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres;
|
||||
|
||||
res = gst_discoverer_info_get_audio_streams(GST_DISCOVERER_INFO (self->obj));
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
||||
}
|
||||
if (res)
|
||||
gst_discoverer_stream_info_list_free(res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_discoverer_info_get_video_streams noargs
|
||||
static PyObject *
|
||||
_wrap_gst_discoverer_info_get_video_streams(PyGstMiniObject * self)
|
||||
{
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres;
|
||||
|
||||
res = gst_discoverer_info_get_video_streams(GST_DISCOVERER_INFO (self->obj));
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
||||
}
|
||||
if (res)
|
||||
gst_discoverer_stream_info_list_free(res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_discoverer_info_get_container_streams noargs
|
||||
static PyObject *
|
||||
_wrap_gst_discoverer_info_get_container_streams(PyGstMiniObject * self)
|
||||
{
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres;
|
||||
|
||||
res = gst_discoverer_info_get_container_streams(GST_DISCOVERER_INFO (self->obj));
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
||||
}
|
||||
if (res)
|
||||
gst_discoverer_stream_info_list_free(res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_discoverer_container_info_get_streams noargs
|
||||
static PyObject *
|
||||
_wrap_gst_discoverer_container_info_get_streams(PyGstMiniObject * self)
|
||||
{
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres;
|
||||
|
||||
res = gst_discoverer_container_info_get_streams(GST_DISCOVERER_CONTAINER_INFO (self->obj));
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
||||
}
|
||||
if (res)
|
||||
gst_discoverer_stream_info_list_free(res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_encoding_container_profile_get_profiles noargs
|
||||
static PyObject *
|
||||
_wrap_gst_encoding_container_profile_get_profiles(PyGstMiniObject * self)
|
||||
{
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres;
|
||||
|
||||
res = (GList*) gst_encoding_container_profile_get_profiles(GST_ENCODING_CONTAINER_PROFILE (self->obj));
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
||||
}
|
||||
if (res)
|
||||
g_list_free (res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_encoding_target_get_profiles noargs
|
||||
static PyObject *
|
||||
_wrap_gst_encoding_target_get_profiles(PyGstMiniObject * self)
|
||||
{
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres;
|
||||
|
||||
res = (GList*) gst_encoding_target_get_profiles(GST_ENCODING_TARGET (self->obj));
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
||||
}
|
||||
if (res)
|
||||
g_list_free (res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_encoding_list_all_targets kwargs
|
||||
static PyObject *
|
||||
_wrap_gst_encoding_list_all_targets(PyGstMiniObject * self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "categoryname", NULL };
|
||||
GList *res, *tmp;
|
||||
const gchar *categoryname = NULL;
|
||||
PyObject *pyres;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"s:GstEncoding.list_all_targets", kwlist, &categoryname))
|
||||
return NULL;
|
||||
res = (GList*) gst_encoding_list_all_targets(categoryname);
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, pygstminiobject_new((GstMiniObject*) tmp->data));
|
||||
}
|
||||
if (res)
|
||||
g_list_free (res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_encoding_list_available_categories noargs
|
||||
static PyObject *
|
||||
_wrap_gst_encoding_list_available_categories(PyGstMiniObject * self)
|
||||
{
|
||||
GList *res, *tmp;
|
||||
PyObject *pyres;
|
||||
|
||||
res = (GList*) gst_encoding_list_available_categories();
|
||||
|
||||
pyres = PyList_New(0);
|
||||
for (tmp = res; tmp; tmp = tmp->next) {
|
||||
PyList_Append(pyres, PyString_FromString((const gchar*) tmp->data));
|
||||
g_free (tmp->data);
|
||||
}
|
||||
if (res)
|
||||
g_list_free (res);
|
||||
return pyres;
|
||||
}
|
||||
%%
|
||||
override gst_encoding_target_new kwargs
|
||||
static int
|
||||
_wrap_gst_encoding_target_new(PyGstMiniObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "name", "category", "description", NULL };
|
||||
char *name, *description, *category;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"sss:GstEncodingContainerProfile.__init__", kwlist, &name, &category, &description))
|
||||
return -1;
|
||||
|
||||
self->obj = (GstMiniObject *)gst_encoding_target_new(name, category, description, NULL);
|
||||
|
||||
if (!self->obj) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "could not create GstEncodingTarget miniobject");
|
||||
return -1;
|
||||
}
|
||||
pygstminiobject_register_wrapper((PyObject *)self);
|
||||
return 0;
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2008 Edward Hervey <edward.hervey@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
||||
#include <pygobject.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/pbutils/pbutils.h>
|
||||
#include "pygst.h"
|
||||
|
||||
void pypbutils_register_classes (PyObject * d);
|
||||
void pypbutils_add_constants (PyObject * module, const gchar * strip_prefix);
|
||||
|
||||
extern PyMethodDef pypbutils_functions[];
|
||||
|
||||
GST_DEBUG_CATEGORY (pygst_debug); /* for python code */
|
||||
|
||||
DL_EXPORT (void)
|
||||
initpbutils (void)
|
||||
{
|
||||
PyObject *m, *d;
|
||||
PyObject *gst G_GNUC_UNUSED;
|
||||
|
||||
init_pygobject ();
|
||||
|
||||
/* Make sure gst module is loaded and ready */
|
||||
gst = pygst_init ();
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
Py_FatalError ("can't initialize module gst.pbutils");
|
||||
}
|
||||
|
||||
gst_pb_utils_init ();
|
||||
|
||||
m = Py_InitModule ("pbutils", pypbutils_functions);
|
||||
d = PyModule_GetDict (m);
|
||||
|
||||
pypbutils_register_classes (d);
|
||||
pypbutils_add_constants (m, "GST_");
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
Py_FatalError ("can't initialize module gst.pbutils");
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2010 Edward Hervey <bilboed@bilboed.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _PYGST_PRIVATE_H_
|
||||
#define _PYGST_PRIVATE_H_
|
||||
|
||||
#ifdef _PYGST_H_
|
||||
# error "include pygst.h or pygst-private.h but not both"
|
||||
#endif
|
||||
|
||||
#define _INSIDE_PYGST_
|
||||
#include "pygst.h"
|
||||
#include "common.h"
|
||||
|
||||
extern PyTypeObject PyGstMiniObject_Type;
|
||||
|
||||
/* from gst-types.c */
|
||||
GstCaps *pygst_caps_from_pyobject (PyObject *object, gboolean *copy);
|
||||
PyObject* pygst_iterator_new(GstIterator *iter);
|
||||
|
||||
/* from pygstminiobject.c */
|
||||
PyObject *
|
||||
pygstminiobject_new(GstMiniObject *obj);
|
||||
|
||||
|
||||
|
||||
#endif /* _PYGST_PRIVATE_H_ */
|
102
gst/pygst.h
102
gst/pygst.h
|
@ -1,102 +0,0 @@
|
|||
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2010 Edward Hervey <bilboed@bilboed.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _PYGST_H_
|
||||
#define _PYGST_H_
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct _PyGst_Functions {
|
||||
GstCaps* (*caps_from_pyobject) (PyObject *object, gboolean *copy);
|
||||
PyObject* (*iterator_new) (GstIterator *iter);
|
||||
PyObject* (*miniobject_new) (GstMiniObject *obj);
|
||||
};
|
||||
|
||||
#define pygstminiobject_get(v) (((PyGstMiniObject *)(v))->obj)
|
||||
#define pygstminiobject_check(v,base) (PyObject_TypeCheck(v,base))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
GstMiniObject *obj;
|
||||
PyObject *inst_dict; /* the instance dictionary -- must be last */
|
||||
PyObject *weakreflist; /* list of weak references */
|
||||
} PyGstMiniObject;
|
||||
|
||||
#ifndef _INSIDE_PYGST_
|
||||
|
||||
#if defined(NO_IMPORT_PYGOBJECT)
|
||||
extern struct _PyGst_Functions *_PyGst_API;
|
||||
#else
|
||||
struct _PyGst_Functions *_PyGst_API;
|
||||
#endif
|
||||
|
||||
#define pygst_caps_from_pyobject (_PyGst_API->caps_from_pyobject)
|
||||
#define pygst_iterator_new (_PyGst_API->iterator_new)
|
||||
#define pygstminiobject_new (_PyGst_API->miniobject_new)
|
||||
|
||||
static inline PyObject *
|
||||
pygst_init(void)
|
||||
{
|
||||
PyObject *gstobject, *cobject;
|
||||
|
||||
gstobject = PyImport_ImportModule("gst._gst");
|
||||
if (!gstobject) {
|
||||
if (PyErr_Occurred())
|
||||
{
|
||||
PyObject *type, *value, *traceback;
|
||||
PyObject *py_orig_exc;
|
||||
PyErr_Fetch(&type, &value, &traceback);
|
||||
py_orig_exc = PyObject_Repr(value);
|
||||
Py_XDECREF(type);
|
||||
Py_XDECREF(value);
|
||||
Py_XDECREF(traceback);
|
||||
PyErr_Format(PyExc_ImportError,
|
||||
"could not import gst (error was: %s)",
|
||||
PyString_AsString(py_orig_exc));
|
||||
Py_DECREF(py_orig_exc);
|
||||
} else {
|
||||
PyErr_SetString(PyExc_ImportError,
|
||||
"could not import gst (no error given)");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cobject = PyObject_GetAttrString(gstobject, "_PyGst_API");
|
||||
if (!cobject) {
|
||||
PyErr_SetString(PyExc_ImportError,
|
||||
"could not import gst (getting _PyGst_API)");
|
||||
return NULL;
|
||||
}
|
||||
_PyGst_API = (struct _PyGst_Functions *) PyCObject_AsVoidPtr(cobject);
|
||||
|
||||
return gstobject;
|
||||
}
|
||||
|
||||
#endif /* _INSIDE_PYGST_ */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* !_PYGST_H_ */
|
|
@ -1,269 +0,0 @@
|
|||
/*
|
||||
* pygstexception.c - gst-python exceptions
|
||||
* Copyright (C) 2005 Alessandro Decina
|
||||
*
|
||||
* Authors:
|
||||
* Alessandro Decina <alessandro@nnva.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
#include "structmember.h"
|
||||
|
||||
PyObject *PyGstExc_LinkError = NULL;
|
||||
PyObject *PyGstExc_AddError = NULL;
|
||||
PyObject *PyGstExc_QueryError = NULL;
|
||||
PyObject *PyGstExc_RemoveError = NULL;
|
||||
PyObject *PyGstExc_PluginNotFoundError = NULL;
|
||||
PyObject *PyGstExc_ElementNotFoundError = NULL;
|
||||
|
||||
|
||||
static PyObject *
|
||||
call_exception_init (PyObject * args)
|
||||
{
|
||||
PyObject *parent_init = NULL;
|
||||
PyObject *res = NULL;
|
||||
|
||||
/* get Exception.__init__ */
|
||||
parent_init = PyObject_GetAttrString (PyExc_Exception, "__init__");
|
||||
if (parent_init == NULL)
|
||||
goto exception;
|
||||
|
||||
/* call Exception.__init__. This will set self.args */
|
||||
res = PyObject_CallObject (parent_init, args);
|
||||
if (res == NULL)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (parent_init);
|
||||
|
||||
return res;
|
||||
|
||||
exception:
|
||||
Py_XDECREF (parent_init);
|
||||
Py_XDECREF (res);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
add_method (PyObject * klass, PyObject * dict, PyMethodDef * method)
|
||||
{
|
||||
PyObject *module = NULL;
|
||||
PyObject *func = NULL;
|
||||
PyObject *meth = NULL;
|
||||
|
||||
module = PyString_FromString ("gst");
|
||||
if (module == NULL)
|
||||
goto exception;
|
||||
|
||||
func = PyCFunction_NewEx (method, NULL, module);
|
||||
if (func == NULL)
|
||||
goto exception;
|
||||
Py_DECREF (module);
|
||||
|
||||
meth = PyMethod_New (func, NULL, klass);
|
||||
if (meth == NULL)
|
||||
goto exception;
|
||||
Py_DECREF (func);
|
||||
|
||||
if (PyDict_SetItemString (dict, method->ml_name, meth) < 0)
|
||||
goto exception;
|
||||
Py_DECREF (meth);
|
||||
|
||||
return 0;
|
||||
|
||||
exception:
|
||||
Py_XDECREF (module);
|
||||
Py_XDECREF (func);
|
||||
Py_XDECREF (meth);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
link_error_init (PyObject * self, PyObject * args)
|
||||
{
|
||||
PyObject *err_type = NULL;
|
||||
int status;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "O|O:__init__", &self, &err_type))
|
||||
return NULL;
|
||||
|
||||
if (err_type == NULL)
|
||||
err_type = Py_None;
|
||||
Py_INCREF (err_type);
|
||||
|
||||
/* set self.error */
|
||||
status = PyObject_SetAttrString (self, "error", err_type);
|
||||
Py_DECREF (err_type);
|
||||
if (status < 0)
|
||||
return NULL;
|
||||
|
||||
return call_exception_init (args);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
element_not_found_error_init (PyObject * self, PyObject * args)
|
||||
{
|
||||
PyObject *element_name = NULL;
|
||||
int status;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "O|O:__init__", &self, &element_name))
|
||||
return NULL;
|
||||
|
||||
if (element_name == NULL)
|
||||
element_name = Py_None;
|
||||
Py_INCREF (element_name);
|
||||
|
||||
/* set self.name */
|
||||
status = PyObject_SetAttrString (self, "name", element_name);
|
||||
Py_DECREF (element_name);
|
||||
if (status < 0)
|
||||
return NULL;
|
||||
|
||||
return call_exception_init (args);
|
||||
}
|
||||
|
||||
static PyMethodDef link_error_init_method = { "__init__",
|
||||
link_error_init, METH_VARARGS
|
||||
};
|
||||
|
||||
static PyMethodDef element_not_found_error_init_method = { "__init__",
|
||||
element_not_found_error_init, METH_VARARGS
|
||||
};
|
||||
|
||||
void
|
||||
pygst_exceptions_register_classes (PyObject * d)
|
||||
{
|
||||
PyObject *dict = NULL;
|
||||
|
||||
/* register gst.LinkError */
|
||||
dict = PyDict_New ();
|
||||
if (dict == NULL)
|
||||
goto exception;
|
||||
|
||||
PyGstExc_LinkError = PyErr_NewException ("gst.LinkError",
|
||||
PyExc_Exception, dict);
|
||||
if (PyGstExc_LinkError == NULL)
|
||||
goto exception;
|
||||
|
||||
if (add_method (PyGstExc_LinkError, dict, &link_error_init_method) < 0)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (dict);
|
||||
|
||||
if (PyDict_SetItemString (d, "LinkError", PyGstExc_LinkError) < 0)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (PyGstExc_LinkError);
|
||||
|
||||
/* register gst.AddError */
|
||||
PyGstExc_AddError = PyErr_NewException ("gst.AddError",
|
||||
PyExc_Exception, NULL);
|
||||
if (PyGstExc_AddError == NULL)
|
||||
goto exception;
|
||||
|
||||
if (PyDict_SetItemString (d, "AddError", PyGstExc_AddError) < 0)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (PyGstExc_AddError);
|
||||
|
||||
/* register gst.RemoveError */
|
||||
PyGstExc_RemoveError = PyErr_NewException ("gst.RemoveError",
|
||||
PyExc_Exception, NULL);
|
||||
if (PyGstExc_RemoveError == NULL)
|
||||
goto exception;
|
||||
|
||||
if (PyDict_SetItemString (d, "RemoveError", PyGstExc_RemoveError) < 0)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (PyGstExc_RemoveError);
|
||||
|
||||
/* register gst.QueryError */
|
||||
PyGstExc_QueryError = PyErr_NewException ("gst.QueryError",
|
||||
PyExc_Exception, NULL);
|
||||
if (PyGstExc_QueryError == NULL)
|
||||
goto exception;
|
||||
|
||||
if (PyDict_SetItemString (d, "QueryError", PyGstExc_QueryError) < 0)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (PyGstExc_QueryError);
|
||||
|
||||
/* FIXME: remove this method in 0.11; element_factory_make deals with element
|
||||
factories, not plug-ins */
|
||||
|
||||
/* register gst.PluginNotFoundError */
|
||||
dict = PyDict_New ();
|
||||
if (dict == NULL)
|
||||
goto exception;
|
||||
|
||||
PyGstExc_PluginNotFoundError =
|
||||
PyErr_NewException ("gst.PluginNotFoundError", PyExc_Exception, dict);
|
||||
if (PyGstExc_PluginNotFoundError == NULL)
|
||||
goto exception;
|
||||
|
||||
if (add_method (PyGstExc_PluginNotFoundError,
|
||||
dict, &element_not_found_error_init_method) < 0)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (dict);
|
||||
|
||||
if (PyDict_SetItemString (d, "PluginNotFoundError",
|
||||
PyGstExc_PluginNotFoundError) < 0)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (PyGstExc_PluginNotFoundError);
|
||||
|
||||
/* register gst.ElementNotFoundError */
|
||||
dict = PyDict_New ();
|
||||
if (dict == NULL)
|
||||
goto exception;
|
||||
|
||||
PyGstExc_ElementNotFoundError =
|
||||
PyErr_NewException ("gst.ElementNotFoundError",
|
||||
PyGstExc_PluginNotFoundError, dict);
|
||||
if (PyGstExc_ElementNotFoundError == NULL)
|
||||
goto exception;
|
||||
|
||||
if (add_method (PyGstExc_ElementNotFoundError,
|
||||
dict, &element_not_found_error_init_method) < 0)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (dict);
|
||||
|
||||
if (PyDict_SetItemString (d, "ElementNotFoundError",
|
||||
PyGstExc_ElementNotFoundError) < 0)
|
||||
goto exception;
|
||||
|
||||
Py_DECREF (PyGstExc_ElementNotFoundError);
|
||||
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
exception:
|
||||
Py_XDECREF (dict);
|
||||
Py_XDECREF (PyGstExc_LinkError);
|
||||
Py_XDECREF (PyGstExc_AddError);
|
||||
Py_XDECREF (PyGstExc_RemoveError);
|
||||
Py_XDECREF (PyGstExc_QueryError);
|
||||
Py_XDECREF (PyGstExc_PluginNotFoundError);
|
||||
Py_XDECREF (PyGstExc_ElementNotFoundError);
|
||||
|
||||
return;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* pygstexception.h - gst-python exceptions
|
||||
* Copyright (C) 2005 Alessandro Decina
|
||||
*
|
||||
* Authors:
|
||||
* Alessandro Decina <alessandro@nnva.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _PYGSTEXCEPTION_H_
|
||||
#define _PYGSTEXCEPTION_H_
|
||||
|
||||
extern PyObject *PyGstExc_LinkError;
|
||||
extern PyObject *PyGstExc_AddError;
|
||||
extern PyObject *PyGstExc_RemoveError;
|
||||
extern PyObject *PyGstExc_QueryError;
|
||||
extern PyObject *PyGstExc_PluginNotFoundError;
|
||||
extern PyObject *PyGstExc_ElementNotFoundError;
|
||||
|
||||
void pygst_exceptions_register_classes(PyObject *d);
|
||||
|
||||
#endif /* _PYGSTEXCEPTION_H_ */
|
|
@ -1,160 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2005 Johan Dahlin
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Johan Dahlin <johan@gnome.org>
|
||||
*/
|
||||
/* define this for all source files that don't run init_pygobject()
|
||||
* before including pygobject.h */
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
|
||||
#include "pygst-private.h"
|
||||
|
||||
static void
|
||||
pygst_iterator_dealloc (PyGstIterator * self)
|
||||
{
|
||||
gst_iterator_free (self->iter);
|
||||
PyObject_Del ((PyObject *) self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygst_iterator_iter_next (PyGstIterator * self)
|
||||
{
|
||||
gpointer element;
|
||||
PyObject *retval = NULL;
|
||||
GstIteratorResult result;
|
||||
|
||||
result = gst_iterator_next (self->iter, &element);
|
||||
switch (result) {
|
||||
case GST_ITERATOR_DONE:
|
||||
PyErr_SetNone (PyExc_StopIteration);
|
||||
break;
|
||||
case GST_ITERATOR_OK:
|
||||
if (g_type_is_a (self->iter->type, G_TYPE_OBJECT)) {
|
||||
retval = pygobject_new (G_OBJECT (element));
|
||||
g_object_unref (element);
|
||||
} else if (g_type_is_a (self->iter->type, GST_TYPE_MINI_OBJECT)) {
|
||||
retval = pygstminiobject_new (GST_MINI_OBJECT (element));
|
||||
gst_mini_object_unref (element);
|
||||
} else {
|
||||
const gchar *type_name;
|
||||
|
||||
type_name = g_type_name (self->iter->type);
|
||||
PyErr_Format (PyExc_TypeError, "Unsupported child type: %s",
|
||||
type_name ? type_name : "unknown");
|
||||
}
|
||||
break;
|
||||
case GST_ITERATOR_RESYNC:
|
||||
/* XXX: add/raise gst.IteratorResync */
|
||||
PyErr_SetString (PyExc_TypeError, "Resync");
|
||||
break;
|
||||
case GST_ITERATOR_ERROR:
|
||||
PyErr_SetString (PyExc_TypeError, "Error");
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygst_iterator_next (PyGstIterator * self)
|
||||
{
|
||||
/* Be compatible with Pythons API rather than GStreamers */
|
||||
return pygst_iterator_iter_next (self);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygst_iterator_push (PyGstIterator * self, PyObject * args)
|
||||
{
|
||||
PyGstIterator *other;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "O!:push", &PyGstIterator_Type, &other))
|
||||
return NULL;
|
||||
|
||||
gst_iterator_push (self->iter, other->iter);
|
||||
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygst_iterator_resync (PyGstIterator * self)
|
||||
{
|
||||
gst_iterator_resync (self->iter);
|
||||
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyMethodDef _PyGstIterator_methods[] = {
|
||||
{"next", (PyCFunction) pygst_iterator_next, METH_NOARGS},
|
||||
{"push", (PyCFunction) pygst_iterator_push, METH_VARARGS},
|
||||
{"resync", (PyCFunction) pygst_iterator_resync, METH_NOARGS},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
PyTypeObject PyGstIterator_Type = {
|
||||
PyObject_HEAD_INIT (NULL)
|
||||
0, /* ob_size */
|
||||
"gst.Iterator", /* tp_name */
|
||||
sizeof (PyGstIterator), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
(destructor) pygst_iterator_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
0, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
0, /* tp_call */
|
||||
0, /* tp_str */
|
||||
0, /* tp_getattro */
|
||||
0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT, /* tp_flags */
|
||||
"GstIterator wrapper", /* tp_doc */
|
||||
0, /* tp_traverse */
|
||||
0, /* tp_clear */
|
||||
0, /* tp_richcompare */
|
||||
0, /* tp_weaklistoffset */
|
||||
PyObject_SelfIter, /* tp_iter */
|
||||
(iternextfunc) pygst_iterator_iter_next, /* tp_iternext */
|
||||
_PyGstIterator_methods, /* tp_methods */
|
||||
};
|
||||
|
||||
PyObject *
|
||||
pygst_iterator_new (GstIterator * iter)
|
||||
{
|
||||
PyGstIterator *self;
|
||||
|
||||
if (iter == NULL) {
|
||||
PyErr_SetString (PyExc_TypeError, "Invalid GstIterator (NULL)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
self = PyObject_NEW (PyGstIterator, &PyGstIterator_Type);
|
||||
self->iter = iter;
|
||||
GST_DEBUG ("self:%p , iterator:%p, type:%lu",
|
||||
self, self->iter, self->iter->type);
|
||||
return (PyObject *) self;
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
#ifndef _PYGOBJECT_PRIVATE_H_
|
||||
#define _PYGOBJECT_PRIVATE_H_
|
||||
|
||||
#ifdef _PYGOBJECT_H_
|
||||
# error "include pygobject.h or pygobject-private.h, but not both"
|
||||
#endif
|
||||
|
||||
#define _INSIDE_PYGOBJECT_
|
||||
#include "pygobject.h"
|
||||
|
||||
/* from gobjectmodule.c */
|
||||
extern struct _PyGObject_Functions pygobject_api_functions;
|
||||
#define pyg_block_threads() G_STMT_START { \
|
||||
if (pygobject_api_functions.block_threads != NULL) \
|
||||
(* pygobject_api_functions.block_threads)(); \
|
||||
} G_STMT_END
|
||||
#define pyg_unblock_threads() G_STMT_START { \
|
||||
if (pygobject_api_functions.unblock_threads != NULL) \
|
||||
(* pygobject_api_functions.unblock_threads)(); \
|
||||
} G_STMT_END
|
||||
|
||||
#define pyg_threads_enabled (pygobject_api_functions.threads_enabled)
|
||||
|
||||
|
||||
#define pyg_gil_state_ensure() (pygobject_api_functions.threads_enabled? (pygobject_api_functions.gil_state_ensure()) : 0)
|
||||
#define pyg_gil_state_release(state) G_STMT_START { \
|
||||
if (pygobject_api_functions.threads_enabled) \
|
||||
pygobject_api_functions.gil_state_release(state); \
|
||||
} G_STMT_END
|
||||
|
||||
#define pyg_begin_allow_threads \
|
||||
G_STMT_START { \
|
||||
PyThreadState *_save = NULL; \
|
||||
if (pygobject_api_functions.threads_enabled) \
|
||||
_save = PyEval_SaveThread();
|
||||
#define pyg_end_allow_threads \
|
||||
if (pygobject_api_functions.threads_enabled) \
|
||||
PyEval_RestoreThread(_save); \
|
||||
} G_STMT_END
|
||||
|
||||
|
||||
extern GType PY_TYPE_OBJECT;
|
||||
|
||||
void pyg_destroy_notify (gpointer user_data);
|
||||
|
||||
/* from pygtype.h */
|
||||
extern PyTypeObject PyGTypeWrapper_Type;
|
||||
|
||||
PyObject *pyg_type_wrapper_new (GType type);
|
||||
GType pyg_type_from_object (PyObject *obj);
|
||||
|
||||
gint pyg_enum_get_value (GType enum_type, PyObject *obj, gint *val);
|
||||
gint pyg_flags_get_value (GType flag_type, PyObject *obj, gint *val);
|
||||
int pyg_pyobj_to_unichar_conv (PyObject* py_obj, void* ptr);
|
||||
|
||||
typedef PyObject *(* fromvaluefunc)(const GValue *value);
|
||||
typedef int (*tovaluefunc)(GValue *value, PyObject *obj);
|
||||
|
||||
void pyg_register_boxed_custom(GType boxed_type,
|
||||
fromvaluefunc from_func,
|
||||
tovaluefunc to_func);
|
||||
int pyg_value_from_pyobject(GValue *value, PyObject *obj);
|
||||
PyObject *pyg_value_as_pyobject(const GValue *value, gboolean copy_boxed);
|
||||
int pyg_param_gvalue_from_pyobject(GValue* value,
|
||||
PyObject* py_obj,
|
||||
const GParamSpec* pspec);
|
||||
PyObject *pyg_param_gvalue_as_pyobject(const GValue* gvalue,
|
||||
gboolean copy_boxed,
|
||||
const GParamSpec* pspec);
|
||||
|
||||
GClosure *pyg_closure_new(PyObject *callback, PyObject *extra_args, PyObject *swap_data);
|
||||
GClosure *pyg_signal_class_closure_get(void);
|
||||
|
||||
PyObject *pyg_object_descr_doc_get(void);
|
||||
|
||||
|
||||
/* from pygobject.h */
|
||||
extern PyTypeObject PyGObject_Type;
|
||||
extern PyTypeObject PyGInterface_Type;
|
||||
extern GQuark pyginterface_type_key;
|
||||
|
||||
void pygobject_register_class (PyObject *dict,
|
||||
const gchar *type_name,
|
||||
GType gtype, PyTypeObject *type,
|
||||
PyObject *bases);
|
||||
void pygobject_register_wrapper (PyObject *self);
|
||||
PyObject * pygobject_new (GObject *obj);
|
||||
PyTypeObject *pygobject_lookup_class (GType gtype);
|
||||
void pygobject_watch_closure (PyObject *self, GClosure *closure);
|
||||
void pygobject_register_sinkfunc(GType type,
|
||||
void (* sinkfunc)(GObject *object));
|
||||
|
||||
/* from pygboxed.c */
|
||||
extern PyTypeObject PyGBoxed_Type;
|
||||
|
||||
void pyg_register_boxed (PyObject *dict, const gchar *class_name,
|
||||
GType boxed_type, PyTypeObject *type);
|
||||
PyObject * pyg_boxed_new (GType boxed_type, gpointer boxed,
|
||||
gboolean copy_boxed, gboolean own_ref);
|
||||
|
||||
extern PyTypeObject PyGPointer_Type;
|
||||
|
||||
void pyg_register_pointer (PyObject *dict, const gchar *class_name,
|
||||
GType pointer_type, PyTypeObject *type);
|
||||
PyObject * pyg_pointer_new (GType pointer_type, gpointer pointer);
|
||||
|
||||
extern char * pyg_constant_strip_prefix(gchar *name, const gchar *strip_prefix);
|
||||
|
||||
/* pygflags */
|
||||
typedef struct {
|
||||
PyIntObject parent;
|
||||
GType gtype;
|
||||
} PyGFlags;
|
||||
|
||||
extern PyTypeObject PyGFlags_Type;
|
||||
|
||||
#define PyGFlags_Check(x) (g_type_is_a(((PyGFlags*)x)->gtype, G_TYPE_FLAGS))
|
||||
|
||||
extern PyObject * pyg_flags_add (PyObject * module,
|
||||
const char * typename,
|
||||
const char * strip_prefix,
|
||||
GType gtype);
|
||||
extern PyObject * pyg_flags_from_gtype (GType gtype,
|
||||
int value);
|
||||
|
||||
/* pygenum */
|
||||
#define PyGEnum_Check(x) (g_type_is_a(((PyGFlags*)x)->gtype, G_TYPE_ENUM))
|
||||
|
||||
typedef struct {
|
||||
PyIntObject parent;
|
||||
GType gtype;
|
||||
} PyGEnum;
|
||||
|
||||
extern PyTypeObject PyGEnum_Type;
|
||||
|
||||
extern PyObject * pyg_enum_add (PyObject * module,
|
||||
const char * typename,
|
||||
const char * strip_prefix,
|
||||
GType gtype);
|
||||
extern PyObject * pyg_enum_from_gtype (GType gtype,
|
||||
int value);
|
||||
|
||||
/* pygmainloop */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
GMainLoop *loop;
|
||||
GSource *signal_source;
|
||||
} PyGMainLoop;
|
||||
|
||||
extern PyTypeObject PyGMainLoop_Type;
|
||||
|
||||
/* pygmaincontext */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
GMainContext *context;
|
||||
} PyGMainContext;
|
||||
|
||||
extern PyTypeObject PyGMainContext_Type;
|
||||
|
||||
/* pygparamspec */
|
||||
|
||||
extern PyTypeObject PyGParamSpec_Type;
|
||||
PyObject * pyg_param_spec_new (GParamSpec *pspec);
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -1,381 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*-
|
||||
* pygtk- Python bindings for the GTK toolkit.
|
||||
* Copyright (C) 1998-2003 James Henstridge
|
||||
*
|
||||
* pygobject.c: wrapper for the GObject type.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA
|
||||
*/
|
||||
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
#define _INSIDE_PYGST_
|
||||
#include "common.h"
|
||||
#include "pygstminiobject.h"
|
||||
#include "pygst.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
static const gchar pygstminiobject_class_id[] = "PyGstMiniObject::class";
|
||||
static GQuark pygstminiobject_class_key = 0;
|
||||
/* static const gchar pygstminiobject_wrapper_id[] = "PyGstMiniObject::wrapper"; */
|
||||
/* static GQuark pygstminiobject_wrapper_key = 0; */
|
||||
|
||||
static void pygstminiobject_dealloc (PyGstMiniObject * self);
|
||||
/* static int pygstminiobject_traverse(PyGstMiniObject *self, visitproc visit, void *arg); */
|
||||
/* static int pygstminiobject_clear(PyGstMiniObject *self); */
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (pygst_debug);
|
||||
#define GST_CAT_DEFAULT pygst_debug
|
||||
|
||||
/**
|
||||
* pygstminiobject_lookup_class:
|
||||
* @gtype: the GType of the GstMiniObject subclass.
|
||||
*
|
||||
* This function looks up the wrapper class used to represent
|
||||
* instances of a GstMiniObject represented by @gtype. If no wrapper class
|
||||
* or interface has been registered for the given GType, then a new
|
||||
* type will be created.
|
||||
*
|
||||
* Returns: The wrapper class for the GstMiniObject or NULL if the
|
||||
* GType has no registered type and a new type couldn't be created
|
||||
*/
|
||||
PyTypeObject *
|
||||
pygstminiobject_lookup_class (GType gtype)
|
||||
{
|
||||
PyTypeObject *py_type = NULL;
|
||||
GType ctype = gtype;
|
||||
|
||||
while (!py_type && ctype) {
|
||||
py_type = g_type_get_qdata (ctype, pygstminiobject_class_key);
|
||||
ctype = g_type_parent (ctype);
|
||||
}
|
||||
if (!ctype)
|
||||
g_error ("Couldn't find a good base type!!");
|
||||
|
||||
return py_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* pygstminiobject_register_class:
|
||||
* @dict: the module dictionary. A reference to the type will be stored here.
|
||||
* @type_name: not used ?
|
||||
* @gtype: the GType of the Gstminiobject subclass.
|
||||
* @type: the Python type object for this wrapper.
|
||||
* @bases: a tuple of Python type objects that are the bases of this type.
|
||||
*
|
||||
* This function is used to register a Python type as the wrapper for
|
||||
* a particular Gstminiobject subclass. It will also insert a reference to
|
||||
* the wrapper class into the module dictionary passed as a reference,
|
||||
* which simplifies initialisation.
|
||||
*/
|
||||
void
|
||||
pygstminiobject_register_class (PyObject * dict, const gchar * type_name,
|
||||
GType gtype, PyTypeObject * type, PyObject * bases)
|
||||
{
|
||||
PyObject *o;
|
||||
const char *class_name, *s;
|
||||
|
||||
if (!pygstminiobject_class_key)
|
||||
pygstminiobject_class_key =
|
||||
g_quark_from_static_string (pygstminiobject_class_id);
|
||||
|
||||
class_name = type->tp_name;
|
||||
s = strrchr (class_name, '.');
|
||||
if (s != NULL)
|
||||
class_name = s + 1;
|
||||
|
||||
type->ob_type = &PyType_Type;
|
||||
type->tp_alloc = PyType_GenericAlloc;
|
||||
type->tp_new = PyType_GenericNew;
|
||||
if (bases) {
|
||||
type->tp_bases = bases;
|
||||
type->tp_base = (PyTypeObject *) PyTuple_GetItem (bases, 0);
|
||||
}
|
||||
|
||||
if (PyType_Ready (type) < 0) {
|
||||
g_warning ("couldn't make the type `%s' ready", type->tp_name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gtype) {
|
||||
o = pyg_type_wrapper_new (gtype);
|
||||
PyDict_SetItemString (type->tp_dict, "__gtype__", o);
|
||||
Py_DECREF (o);
|
||||
|
||||
/* stash a pointer to the python class with the GType */
|
||||
Py_INCREF (type);
|
||||
g_type_set_qdata (gtype, pygstminiobject_class_key, type);
|
||||
}
|
||||
|
||||
PyDict_SetItemString (dict, (char *) class_name, (PyObject *) type);
|
||||
}
|
||||
|
||||
void
|
||||
pygstminiobject_register_wrapper (PyObject * self)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* pygstminiobject_new:
|
||||
* @obj: a GstMiniObject instance.
|
||||
*
|
||||
* This function gets a reference to a wrapper for the given GstMiniObject
|
||||
* instance. A new wrapper will always be created.
|
||||
*
|
||||
* Returns: a reference to the wrapper for the GstMiniObject.
|
||||
*/
|
||||
PyObject *
|
||||
pygstminiobject_new (GstMiniObject * obj)
|
||||
{
|
||||
PyGstMiniObject *self = NULL;
|
||||
PyGILState_STATE state;
|
||||
PyTypeObject *tp = NULL;
|
||||
|
||||
if (obj == NULL) {
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
/* since mini objects cannot notify us when they get destroyed, we
|
||||
* can't use a global hash to map GMO to PyO, and have to create a new
|
||||
* Python object every time we see it */
|
||||
tp = pygstminiobject_lookup_class (G_OBJECT_TYPE (obj));
|
||||
GST_DEBUG ("have to create wrapper for object %p", obj);
|
||||
if (!tp)
|
||||
g_warning ("Couldn't get class for type object : %p", obj);
|
||||
if (tp->tp_flags & Py_TPFLAGS_HEAPTYPE) {
|
||||
GST_INFO ("Increment refcount %p", tp);
|
||||
Py_INCREF (tp);
|
||||
}
|
||||
state = pyg_gil_state_ensure ();
|
||||
self = PyObject_New (PyGstMiniObject, tp);
|
||||
pyg_gil_state_release (state);
|
||||
|
||||
if (self == NULL)
|
||||
return NULL;
|
||||
self->obj = gst_mini_object_ref (obj);
|
||||
|
||||
self->inst_dict = NULL;
|
||||
self->weakreflist = NULL;
|
||||
|
||||
GST_DEBUG ("created Python object %p for GstMiniObject %p [ref:%d]",
|
||||
self, obj, GST_MINI_OBJECT_REFCOUNT_VALUE (obj));
|
||||
return (PyObject *) self;
|
||||
}
|
||||
|
||||
static void
|
||||
pygstminiobject_dealloc (PyGstMiniObject * self)
|
||||
{
|
||||
PyGILState_STATE state;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
GST_DEBUG ("At the beginning %p", self);
|
||||
state = pyg_gil_state_ensure ();
|
||||
|
||||
if (self->obj) {
|
||||
GST_DEBUG ("PyO %p unreffing GstMiniObject %p [ref:%d]", self,
|
||||
self->obj, GST_MINI_OBJECT_REFCOUNT_VALUE (self->obj));
|
||||
gst_mini_object_unref (self->obj);
|
||||
GST_DEBUG ("setting self %p -> obj to NULL", self);
|
||||
self->obj = NULL;
|
||||
}
|
||||
|
||||
if (self->inst_dict) {
|
||||
Py_DECREF (self->inst_dict);
|
||||
self->inst_dict = NULL;
|
||||
}
|
||||
|
||||
self->ob_type->tp_free ((PyObject *) self);
|
||||
pyg_gil_state_release (state);
|
||||
GST_DEBUG ("At the end %p", self);
|
||||
}
|
||||
|
||||
static int
|
||||
pygstminiobject_compare (PyGstMiniObject * self, PyGstMiniObject * v)
|
||||
{
|
||||
if (self->obj == v->obj)
|
||||
return 0;
|
||||
if (self->obj > v->obj)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static long
|
||||
pygstminiobject_hash (PyGstMiniObject * self)
|
||||
{
|
||||
return (long) self->obj;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygstminiobject_repr (PyGstMiniObject * self)
|
||||
{
|
||||
gchar buf[256];
|
||||
|
||||
g_snprintf (buf, sizeof (buf),
|
||||
"<%s mini-object (%s) at 0x%lx>",
|
||||
self->ob_type->tp_name,
|
||||
self->obj ? G_OBJECT_TYPE_NAME (self->obj) : "uninitialized",
|
||||
(long) self);
|
||||
return PyString_FromString (buf);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
pygstminiobject_free (PyObject * op)
|
||||
{
|
||||
PyObject_FREE (op);
|
||||
}
|
||||
|
||||
|
||||
/* ---------------- PyGstMiniObject methods ----------------- */
|
||||
|
||||
static int
|
||||
pygstminiobject_init (PyGstMiniObject * self, PyObject * args,
|
||||
PyObject * kwargs)
|
||||
{
|
||||
GType object_type;
|
||||
GstMiniObjectClass *class;
|
||||
|
||||
if (!PyArg_ParseTuple (args, ":GstMiniObject.__init__", &object_type))
|
||||
return -1;
|
||||
|
||||
object_type = pyg_type_from_object ((PyObject *) self);
|
||||
if (!object_type)
|
||||
return -1;
|
||||
|
||||
if (G_TYPE_IS_ABSTRACT (object_type)) {
|
||||
PyErr_Format (PyExc_TypeError, "cannot create instance of abstract "
|
||||
"(non-instantiable) type `%s'", g_type_name (object_type));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((class = g_type_class_ref (object_type)) == NULL) {
|
||||
PyErr_SetString (PyExc_TypeError,
|
||||
"could not get a reference to type class");
|
||||
return -1;
|
||||
}
|
||||
|
||||
self->obj = gst_mini_object_new (object_type);
|
||||
if (self->obj == NULL)
|
||||
PyErr_SetString (PyExc_RuntimeError, "could not create object");
|
||||
|
||||
g_type_class_unref (class);
|
||||
|
||||
return (self->obj) ? 0 : -1;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygstminiobject__gstminiobject_init__ (PyGstMiniObject * self, PyObject * args,
|
||||
PyObject * kwargs)
|
||||
{
|
||||
if (pygstminiobject_init (self, args, kwargs) < 0)
|
||||
return NULL;
|
||||
Py_INCREF (Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygstminiobject_copy (PyGstMiniObject * self, PyObject * args)
|
||||
{
|
||||
return pygstminiobject_new (gst_mini_object_copy (self->obj));
|
||||
}
|
||||
|
||||
static PyMethodDef pygstminiobject_methods[] = {
|
||||
{"__gstminiobject_init__",
|
||||
(PyCFunction) pygstminiobject__gstminiobject_init__,
|
||||
METH_VARARGS | METH_KEYWORDS},
|
||||
{"copy", (PyCFunction) pygstminiobject_copy, METH_VARARGS,
|
||||
"Copies the miniobject"},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
static PyObject *
|
||||
pygstminiobject_get_dict (PyGstMiniObject * self, void *closure)
|
||||
{
|
||||
if (self->inst_dict == NULL) {
|
||||
self->inst_dict = PyDict_New ();
|
||||
if (self->inst_dict == NULL)
|
||||
return NULL;
|
||||
}
|
||||
Py_INCREF (self->inst_dict);
|
||||
return self->inst_dict;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygstminiobject_get_refcount (PyGstMiniObject * self, void *closure)
|
||||
{
|
||||
return PyInt_FromLong (GST_MINI_OBJECT_REFCOUNT_VALUE (self->obj));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pygstminiobject_get_flags (PyGstMiniObject * self, void *closure)
|
||||
{
|
||||
return PyInt_FromLong (GST_MINI_OBJECT_FLAGS (self->obj));
|
||||
}
|
||||
|
||||
static PyGetSetDef pygstminiobject_getsets[] = {
|
||||
{"__dict__", (getter) pygstminiobject_get_dict, (setter) 0},
|
||||
{"__grefcount__", (getter) pygstminiobject_get_refcount, (setter) 0,},
|
||||
{"flags", (getter) pygstminiobject_get_flags, (setter) 0,},
|
||||
{NULL, 0, 0}
|
||||
};
|
||||
|
||||
PyTypeObject PyGstMiniObject_Type = {
|
||||
PyObject_HEAD_INIT (NULL)
|
||||
0, /* ob_size */
|
||||
"gst.MiniObject", /* tp_name */
|
||||
sizeof (PyGstMiniObject), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor) pygstminiobject_dealloc, /* tp_dealloc */
|
||||
(printfunc) 0, /* tp_print */
|
||||
(getattrfunc) 0, /* tp_getattr */
|
||||
(setattrfunc) 0, /* tp_setattr */
|
||||
(cmpfunc) pygstminiobject_compare, /* tp_compare */
|
||||
(reprfunc) pygstminiobject_repr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
(hashfunc) pygstminiobject_hash, /* tp_hash */
|
||||
(ternaryfunc) 0, /* tp_call */
|
||||
(reprfunc) 0, /* tp_str */
|
||||
(getattrofunc) 0, /* tp_getattro */
|
||||
(setattrofunc) 0, /* tp_setattro */
|
||||
0, /* tp_as_buffer */
|
||||
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
|
||||
NULL, /* Documentation string */
|
||||
(traverseproc) 0, /* tp_traverse */
|
||||
(inquiry) 0, /* tp_clear */
|
||||
(richcmpfunc) 0, /* tp_richcompare */
|
||||
offsetof (PyGstMiniObject, weakreflist), /* tp_weaklistoffset */
|
||||
(getiterfunc) 0, /* tp_iter */
|
||||
(iternextfunc) 0, /* tp_iternext */
|
||||
pygstminiobject_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
pygstminiobject_getsets, /* tp_getset */
|
||||
(PyTypeObject *) 0, /* tp_base */
|
||||
(PyObject *) 0, /* tp_dict */
|
||||
0, /* tp_descr_get */
|
||||
0, /* tp_descr_set */
|
||||
offsetof (PyGstMiniObject, inst_dict), /* tp_dictoffset */
|
||||
(initproc) pygstminiobject_init, /* tp_init */
|
||||
(allocfunc) 0, /* tp_alloc */
|
||||
(newfunc) 0, /* tp_new */
|
||||
(freefunc) pygstminiobject_free, /* tp_free */
|
||||
(inquiry) 0, /* tp_is_gc */
|
||||
(PyObject *) 0, /* tp_bases */
|
||||
};
|
|
@ -1,39 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
|
||||
#ifndef _PYGSTMINIOBJECT_H_
|
||||
#define _PYGSTMINIOBJECT_H_
|
||||
|
||||
#include <Python.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Work around bugs in PyGILState api fixed in 2.4.0a4 */
|
||||
#undef PYGIL_API_IS_BUGGY
|
||||
#if PY_VERSION_HEX < 0x020400A4
|
||||
#define PYGIL_API_IS_BUGGY TRUE
|
||||
#else
|
||||
#define PYGIL_API_IS_BUGGY FALSE
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
pygstminiobject_register_class(PyObject *dict, const gchar *type_name,
|
||||
GType gtype, PyTypeObject *type,
|
||||
PyObject *bases);
|
||||
void
|
||||
pygstminiobject_register_wrapper(PyObject *self);
|
||||
|
||||
void
|
||||
pygst_miniobject_init();
|
||||
|
||||
#ifndef _INSIDE_PYGSTMINIOBJECT_
|
||||
|
||||
|
||||
#endif /* !_INSIDE_PYGSTMINIOBJECT_ */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* !_PYGSTMINIOBJECT_H_ */
|
414
gst/pygstvalue.c
414
gst/pygstvalue.c
|
@ -1,414 +0,0 @@
|
|||
/* gst-python
|
||||
* Copyright (C) 2004 Andy Wingo
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Andy Wingo <wingo@pobox.com>
|
||||
*/
|
||||
|
||||
/* define this for all source files that don't run init_pygobject()
|
||||
* before including pygobject.h */
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
|
||||
#include "pygst-private.h"
|
||||
#include "pygstvalue.h"
|
||||
|
||||
static PyObject *gstvalue_class = NULL;
|
||||
static PyObject *gstfourcc_class = NULL;
|
||||
static PyObject *gstintrange_class = NULL;
|
||||
static PyObject *gstdoublerange_class = NULL;
|
||||
static PyObject *gstfraction_class = NULL;
|
||||
static PyObject *gstfractionrange_class = NULL;
|
||||
|
||||
/* helper function */
|
||||
|
||||
/* Finds the greatest common divisor.
|
||||
* Returns 1 if none other found.
|
||||
* This is Euclid's algorithm. */
|
||||
static long
|
||||
my_gcd (long num, long denom)
|
||||
{
|
||||
while (denom != 0) {
|
||||
long temp = num;
|
||||
|
||||
num = denom;
|
||||
denom = temp % denom;
|
||||
}
|
||||
|
||||
return ABS (num);
|
||||
}
|
||||
|
||||
/**
|
||||
* pygst_value_as_pyobject:
|
||||
* @value: the GValue object.
|
||||
* @copy_boxed: true if boxed values should be copied.
|
||||
*
|
||||
* This function creates/returns a Python wrapper object that
|
||||
* represents the GValue passed as an argument.
|
||||
*
|
||||
* Returns: a PyObject representing the value.
|
||||
*/
|
||||
PyObject *
|
||||
pygst_value_as_pyobject (const GValue * value, gboolean copy_boxed)
|
||||
{
|
||||
PyObject *ret = pyg_value_as_pyobject (value, copy_boxed);
|
||||
if (!ret) {
|
||||
PyErr_Clear ();
|
||||
if (GST_VALUE_HOLDS_FOURCC (value)) {
|
||||
gchar str[5];
|
||||
g_snprintf (str, 5, "%" GST_FOURCC_FORMAT,
|
||||
GST_FOURCC_ARGS (gst_value_get_fourcc (value)));
|
||||
ret = PyObject_Call (gstfourcc_class, Py_BuildValue ("(s)", str), NULL);
|
||||
} else if (GST_VALUE_HOLDS_INT_RANGE (value)) {
|
||||
ret = PyObject_Call
|
||||
(gstintrange_class,
|
||||
Py_BuildValue ("ii",
|
||||
gst_value_get_int_range_min (value),
|
||||
gst_value_get_int_range_max (value)), NULL);
|
||||
} else if (GST_VALUE_HOLDS_DOUBLE_RANGE (value)) {
|
||||
ret = PyObject_Call
|
||||
(gstdoublerange_class,
|
||||
Py_BuildValue ("dd",
|
||||
gst_value_get_double_range_min (value),
|
||||
gst_value_get_double_range_max (value)), NULL);
|
||||
} else if (GST_VALUE_HOLDS_LIST (value)) {
|
||||
int i, len;
|
||||
len = gst_value_list_get_size (value);
|
||||
ret = PyList_New (len);
|
||||
for (i = 0; i < len; i++) {
|
||||
PyList_SetItem (ret, i,
|
||||
pygst_value_as_pyobject
|
||||
(gst_value_list_get_value (value, i), copy_boxed));
|
||||
}
|
||||
} else if (GST_VALUE_HOLDS_ARRAY (value)) {
|
||||
int i, len;
|
||||
len = gst_value_array_get_size (value);
|
||||
ret = PyTuple_New (len);
|
||||
for (i = 0; i < len; i++) {
|
||||
PyTuple_SetItem (ret, i,
|
||||
pygst_value_as_pyobject
|
||||
(gst_value_array_get_value (value, i), copy_boxed));
|
||||
}
|
||||
} else if (GST_VALUE_HOLDS_FRACTION (value)) {
|
||||
ret = PyObject_Call
|
||||
(gstfraction_class,
|
||||
Py_BuildValue ("ii",
|
||||
gst_value_get_fraction_numerator (value),
|
||||
gst_value_get_fraction_denominator (value)), NULL);
|
||||
} else if (GST_VALUE_HOLDS_FRACTION_RANGE (value)) {
|
||||
const GValue *min, *max;
|
||||
min = gst_value_get_fraction_range_min (value);
|
||||
max = gst_value_get_fraction_range_max (value);
|
||||
ret = PyObject_Call
|
||||
(gstfractionrange_class,
|
||||
Py_BuildValue ("OO",
|
||||
pygst_value_as_pyobject (min, copy_boxed),
|
||||
pygst_value_as_pyobject (max, copy_boxed)), NULL);
|
||||
} else if (GST_VALUE_HOLDS_BUFFER (value)) {
|
||||
return pygstminiobject_new (gst_value_get_mini_object (value));
|
||||
} else {
|
||||
gchar buf[256];
|
||||
g_snprintf (buf, 256, "unknown type: %s",
|
||||
g_type_name (G_VALUE_TYPE (value)));
|
||||
PyErr_SetString (PyExc_TypeError, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (G_VALUE_TYPE (value) == G_TYPE_STRING) {
|
||||
PyObject *u = NULL;
|
||||
|
||||
/* FIXME: docs are not clear on whether this sets a python
|
||||
exception when it fails */
|
||||
u = PyUnicode_FromEncodedObject (ret, "utf-8", NULL);
|
||||
Py_DECREF (ret);
|
||||
ret = u;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define VALUE_TYPE_CHECK(v, t) \
|
||||
G_STMT_START{\
|
||||
if (!G_VALUE_HOLDS (v, t)) {\
|
||||
gchar errbuf[256];\
|
||||
g_snprintf (errbuf, 256, "Could not convert %s to %s",\
|
||||
g_type_name (t), g_type_name (G_VALUE_TYPE (v)));\
|
||||
PyErr_SetString (PyExc_TypeError, errbuf);\
|
||||
return -1;\
|
||||
}}G_STMT_END
|
||||
|
||||
gboolean
|
||||
pygst_value_init_for_pyobject (GValue * value, PyObject * obj)
|
||||
{
|
||||
GType t;
|
||||
|
||||
if (obj == Py_None) {
|
||||
PyErr_SetString (PyExc_TypeError, "value can't be None");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!(t = pyg_type_from_object ((PyObject *) obj->ob_type))) {
|
||||
if (PyObject_IsInstance (obj, gstvalue_class)) {
|
||||
PyErr_Clear ();
|
||||
if (PyObject_IsInstance (obj, gstfourcc_class))
|
||||
t = GST_TYPE_FOURCC;
|
||||
else if (PyObject_IsInstance (obj, gstintrange_class))
|
||||
t = GST_TYPE_INT_RANGE;
|
||||
else if (PyObject_IsInstance (obj, gstdoublerange_class))
|
||||
t = GST_TYPE_DOUBLE_RANGE;
|
||||
else if (PyObject_IsInstance (obj, gstfraction_class))
|
||||
t = GST_TYPE_FRACTION;
|
||||
else if (PyObject_IsInstance (obj, gstfractionrange_class))
|
||||
t = GST_TYPE_FRACTION_RANGE;
|
||||
else {
|
||||
PyErr_SetString (PyExc_TypeError, "Unexpected gst.Value instance");
|
||||
return FALSE;
|
||||
}
|
||||
} else if (PyObject_IsInstance (obj, (PyObject *) & PyGstMiniObject_Type)) {
|
||||
PyErr_Clear ();
|
||||
t = GST_TYPE_MINI_OBJECT;
|
||||
} else if (PyTuple_Check (obj)) {
|
||||
PyErr_Clear ();
|
||||
t = GST_TYPE_ARRAY;
|
||||
} else if (PyList_Check (obj)) {
|
||||
PyErr_Clear ();
|
||||
t = GST_TYPE_LIST;
|
||||
} else if (PyUnicode_Check (obj)) {
|
||||
/* unicode strings should be converted to UTF-8 */
|
||||
PyErr_Clear ();
|
||||
t = G_TYPE_STRING;
|
||||
} else {
|
||||
/* pyg_type_from_object already set the error */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
g_value_init (value, t);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
pygst_value_from_pyobject_internal (GValue * value, PyObject * obj)
|
||||
{
|
||||
GType f = g_type_fundamental (G_VALUE_TYPE (value));
|
||||
|
||||
/* work around a bug in pygtk whereby pyg_value_from_pyobject claims success
|
||||
for unknown fundamental types without actually doing anything */
|
||||
if (f < G_TYPE_MAKE_FUNDAMENTAL (G_TYPE_RESERVED_USER_FIRST)
|
||||
&& pyg_value_from_pyobject (value, obj) == 0) {
|
||||
return 0;
|
||||
} else if (PyObject_IsInstance (obj, gstvalue_class)) {
|
||||
PyErr_Clear ();
|
||||
|
||||
if (PyObject_IsInstance (obj, gstfourcc_class)) {
|
||||
PyObject *pystr;
|
||||
gchar *str;
|
||||
VALUE_TYPE_CHECK (value, GST_TYPE_FOURCC);
|
||||
if (!(pystr = PyObject_GetAttrString (obj, "fourcc")))
|
||||
return -1;
|
||||
if (!(str = PyString_AsString (pystr)))
|
||||
return -1;
|
||||
g_assert (strlen (str) == 4);
|
||||
gst_value_set_fourcc (value, GST_STR_FOURCC (str));
|
||||
} else if (PyObject_IsInstance (obj, gstintrange_class)) {
|
||||
PyObject *pyval;
|
||||
long low, high;
|
||||
VALUE_TYPE_CHECK (value, GST_TYPE_INT_RANGE);
|
||||
if (!(pyval = PyObject_GetAttrString (obj, "low")))
|
||||
return -1;
|
||||
low = PyInt_AsLong (pyval);
|
||||
g_assert (G_MININT <= low && low <= G_MAXINT);
|
||||
if (!(pyval = PyObject_GetAttrString (obj, "high")))
|
||||
return -1;
|
||||
high = PyInt_AsLong (pyval);
|
||||
g_assert (G_MININT <= high && high <= G_MAXINT);
|
||||
gst_value_set_int_range (value, (int) low, (int) high);
|
||||
} else if (PyObject_IsInstance (obj, gstdoublerange_class)) {
|
||||
PyObject *pyval;
|
||||
double low, high;
|
||||
VALUE_TYPE_CHECK (value, GST_TYPE_DOUBLE_RANGE);
|
||||
if (!(pyval = PyObject_GetAttrString (obj, "low")))
|
||||
return -1;
|
||||
low = PyFloat_AsDouble (pyval);
|
||||
if (!(pyval = PyObject_GetAttrString (obj, "high")))
|
||||
return -1;
|
||||
high = PyFloat_AsDouble (pyval);
|
||||
gst_value_set_double_range (value, low, high);
|
||||
} else if (PyObject_IsInstance (obj, gstfraction_class)) {
|
||||
PyObject *pyval;
|
||||
long num, denom;
|
||||
long gcd = 0;
|
||||
VALUE_TYPE_CHECK (value, GST_TYPE_FRACTION);
|
||||
if (!(pyval = PyObject_GetAttrString (obj, "num")))
|
||||
return -1;
|
||||
num = PyInt_AsLong (pyval);
|
||||
if ((num == -1) && PyErr_Occurred ())
|
||||
return -1;
|
||||
g_assert (G_MININT <= num && num <= G_MAXINT);
|
||||
if (!(pyval = PyObject_GetAttrString (obj, "denom")))
|
||||
return -1;
|
||||
denom = PyInt_AsLong (pyval);
|
||||
if ((denom == -1) && PyErr_Occurred ())
|
||||
return -1;
|
||||
/* we need to reduce the values to be smaller than MAXINT */
|
||||
if ((gcd = my_gcd (num, denom))) {
|
||||
num /= gcd;
|
||||
denom /= gcd;
|
||||
}
|
||||
g_assert (G_MININT <= denom && denom <= G_MAXINT);
|
||||
gst_value_set_fraction (value, (int) num, (int) denom);
|
||||
} else if (PyObject_IsInstance (obj, gstfractionrange_class)) {
|
||||
GValue low = { 0, };
|
||||
GValue high = { 0, };
|
||||
PyObject *pylow, *pyhigh;
|
||||
|
||||
VALUE_TYPE_CHECK (value, GST_TYPE_FRACTION_RANGE);
|
||||
if (!(pylow = PyObject_GetAttrString (obj, "low")))
|
||||
return -1;
|
||||
if (!pygst_value_init_for_pyobject (&low, pylow))
|
||||
return -1;
|
||||
if (pygst_value_from_pyobject (&low, pylow) != 0)
|
||||
return -1;
|
||||
|
||||
if (!(pyhigh = PyObject_GetAttrString (obj, "high")))
|
||||
return -1;
|
||||
if (!pygst_value_init_for_pyobject (&high, pyhigh))
|
||||
return -1;
|
||||
if (pygst_value_from_pyobject (&high, pyhigh) != 0)
|
||||
return -1;
|
||||
|
||||
gst_value_set_fraction_range (value, &low, &high);
|
||||
} else {
|
||||
gchar buf[256];
|
||||
gchar *str = PyString_AsString (PyObject_Repr (obj));
|
||||
g_snprintf (buf, 256, "Unknown gst.Value type: %s", str);
|
||||
PyErr_SetString (PyExc_TypeError, buf);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
} else if (PyObject_IsInstance (obj, (PyObject *) & PyGstMiniObject_Type)) {
|
||||
VALUE_TYPE_CHECK (value, GST_TYPE_MINI_OBJECT);
|
||||
gst_value_set_mini_object (value, pygstminiobject_get (obj));
|
||||
return 0;
|
||||
} else if (PyTuple_Check (obj)) {
|
||||
gint i, len;
|
||||
PyErr_Clear ();
|
||||
VALUE_TYPE_CHECK (value, GST_TYPE_ARRAY);
|
||||
len = PyTuple_Size (obj);
|
||||
for (i = 0; i < len; i++) {
|
||||
PyObject *o;
|
||||
GValue new = { 0, };
|
||||
o = PyTuple_GetItem (obj, i);
|
||||
if (!pygst_value_init_for_pyobject (&new, o))
|
||||
return -1;
|
||||
if (pygst_value_from_pyobject (&new, o) != 0) {
|
||||
g_value_unset (&new);
|
||||
return -1;
|
||||
}
|
||||
gst_value_array_append_value (value, &new);
|
||||
g_value_unset (&new);
|
||||
}
|
||||
return 0;
|
||||
} else if (PyList_Check (obj)) {
|
||||
gint i, len;
|
||||
PyErr_Clear ();
|
||||
VALUE_TYPE_CHECK (value, GST_TYPE_LIST);
|
||||
len = PyList_Size (obj);
|
||||
for (i = 0; i < len; i++) {
|
||||
PyObject *o;
|
||||
GValue new = { 0, };
|
||||
o = PyList_GetItem (obj, i);
|
||||
if (!pygst_value_init_for_pyobject (&new, o))
|
||||
return -1;
|
||||
if (pygst_value_from_pyobject (&new, o) != 0) {
|
||||
g_value_unset (&new);
|
||||
return -1;
|
||||
}
|
||||
gst_value_list_append_value (value, &new);
|
||||
g_value_unset (&new);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pygst_value_from_pyobject:
|
||||
* @value: the GValue object to store the converted value in.
|
||||
* @obj: the Python object to convert.
|
||||
*
|
||||
* This function converts a Python object and stores the result in a
|
||||
* GValue. The GValue must be initialised in advance with
|
||||
* g_value_init(). If the Python object can't be converted to the
|
||||
* type of the GValue, then an error is returned.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error.
|
||||
*/
|
||||
int
|
||||
pygst_value_from_pyobject (GValue * value, PyObject * obj)
|
||||
{
|
||||
PyObject *v = NULL;
|
||||
int res;
|
||||
|
||||
/* Unicode objects should be converted to utf-8 strings */
|
||||
if (PyObject_TypeCheck (obj, &PyUnicode_Type)) {
|
||||
|
||||
v = PyUnicode_AsUTF8String (obj);
|
||||
obj = v;
|
||||
}
|
||||
|
||||
res = pygst_value_from_pyobject_internal (value, obj);
|
||||
|
||||
if (v) {
|
||||
Py_DECREF (obj);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#define NULL_CHECK(o) if (!o) goto err
|
||||
|
||||
gboolean
|
||||
pygst_value_init (void)
|
||||
{
|
||||
PyObject *module, *dict;
|
||||
|
||||
if ((module = PyImport_ImportModule ("gst")) == NULL)
|
||||
return FALSE;
|
||||
|
||||
dict = PyModule_GetDict (module);
|
||||
|
||||
gstvalue_class = (PyObject *) PyDict_GetItemString (dict, "Value");
|
||||
NULL_CHECK (gstvalue_class);
|
||||
gstfourcc_class = (PyObject *) PyDict_GetItemString (dict, "Fourcc");
|
||||
NULL_CHECK (gstfourcc_class);
|
||||
gstintrange_class = (PyObject *) PyDict_GetItemString (dict, "IntRange");
|
||||
NULL_CHECK (gstintrange_class);
|
||||
gstdoublerange_class =
|
||||
(PyObject *) PyDict_GetItemString (dict, "DoubleRange");
|
||||
NULL_CHECK (gstdoublerange_class);
|
||||
gstfraction_class = (PyObject *) PyDict_GetItemString (dict, "Fraction");
|
||||
NULL_CHECK (gstfraction_class);
|
||||
gstfractionrange_class =
|
||||
(PyObject *) PyDict_GetItemString (dict, "FractionRange");
|
||||
NULL_CHECK (gstfractionrange_class);
|
||||
return TRUE;
|
||||
|
||||
err:
|
||||
PyErr_SetString (PyExc_ImportError,
|
||||
"Failed to get GstValue classes from gst module");
|
||||
return FALSE;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/* gst-python
|
||||
* Copyright (C) 2004 Andy Wingo
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* Author: Andy Wingo <wingo@pobox.com>
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
|
||||
PyObject *pygst_value_as_pyobject(const GValue *value, gboolean copy_boxed);
|
||||
gboolean pygst_value_init_for_pyobject (GValue *value, PyObject *obj);
|
||||
int pygst_value_from_pyobject(GValue *value, PyObject *obj);
|
||||
gboolean pygst_value_init(void);
|
306
gst/tag.defs
306
gst/tag.defs
|
@ -1,306 +0,0 @@
|
|||
;; -*- scheme -*-
|
||||
; object definitions ...
|
||||
(define-object TagDemux
|
||||
(in-module "Gst")
|
||||
(parent "GstElement")
|
||||
(c-name "GstTagDemux")
|
||||
(gtype-id "GST_TYPE_TAG_DEMUX")
|
||||
)
|
||||
|
||||
;; Enumerations and flags ...
|
||||
|
||||
(define-enum TagDemuxResult
|
||||
(in-module "Gst")
|
||||
(c-name "GstTagDemuxResult")
|
||||
(gtype-id "GST_TYPE_TAG_DEMUX_RESULT")
|
||||
(values
|
||||
'("broken-tag" "GST_TAG_DEMUX_RESULT_BROKEN_TAG")
|
||||
'("again" "GST_TAG_DEMUX_RESULT_AGAIN")
|
||||
'("ok" "GST_TAG_DEMUX_RESULT_OK")
|
||||
)
|
||||
)
|
||||
|
||||
(define-enum TagImageType
|
||||
(in-module "Gst")
|
||||
(c-name "GstTagImageType")
|
||||
(gtype-id "GST_TYPE_TAG_IMAGE_TYPE")
|
||||
(values
|
||||
'("none" "GST_TAG_IMAGE_TYPE_NONE")
|
||||
'("undefined" "GST_TAG_IMAGE_TYPE_UNDEFINED")
|
||||
'("front-cover" "GST_TAG_IMAGE_TYPE_FRONT_COVER")
|
||||
'("back-cover" "GST_TAG_IMAGE_TYPE_BACK_COVER")
|
||||
'("leaflet-page" "GST_TAG_IMAGE_TYPE_LEAFLET_PAGE")
|
||||
'("medium" "GST_TAG_IMAGE_TYPE_MEDIUM")
|
||||
'("lead-artist" "GST_TAG_IMAGE_TYPE_LEAD_ARTIST")
|
||||
'("artist" "GST_TAG_IMAGE_TYPE_ARTIST")
|
||||
'("conductor" "GST_TAG_IMAGE_TYPE_CONDUCTOR")
|
||||
'("band-orchestra" "GST_TAG_IMAGE_TYPE_BAND_ORCHESTRA")
|
||||
'("composer" "GST_TAG_IMAGE_TYPE_COMPOSER")
|
||||
'("lyricist" "GST_TAG_IMAGE_TYPE_LYRICIST")
|
||||
'("recording-location" "GST_TAG_IMAGE_TYPE_RECORDING_LOCATION")
|
||||
'("during-recording" "GST_TAG_IMAGE_TYPE_DURING_RECORDING")
|
||||
'("during-performance" "GST_TAG_IMAGE_TYPE_DURING_PERFORMANCE")
|
||||
'("video-capture" "GST_TAG_IMAGE_TYPE_VIDEO_CAPTURE")
|
||||
'("fish" "GST_TAG_IMAGE_TYPE_FISH")
|
||||
'("illustration" "GST_TAG_IMAGE_TYPE_ILLUSTRATION")
|
||||
'("band-artist-logo" "GST_TAG_IMAGE_TYPE_BAND_ARTIST_LOGO")
|
||||
'("publisher-studio-logo" "GST_TAG_IMAGE_TYPE_PUBLISHER_STUDIO_LOGO")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; From gsttagdemux.h
|
||||
|
||||
(define-function demux_get_type
|
||||
(c-name "gst_tag_demux_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From tag.h
|
||||
|
||||
(define-function image_type_get_type
|
||||
(c-name "gst_tag_image_type_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function from_vorbis_tag
|
||||
(c-name "gst_tag_from_vorbis_tag")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "vorbis_tag")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function to_vorbis_tag
|
||||
(c-name "gst_tag_to_vorbis_tag")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "gst_tag")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function gst_vorbis_tag_add
|
||||
(c-name "gst_vorbis_tag_add")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstTagList*" "list")
|
||||
'("const-gchar*" "tag")
|
||||
'("const-gchar*" "value")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function to_vorbis_comments
|
||||
(c-name "gst_tag_to_vorbis_comments")
|
||||
(return-type "GList*")
|
||||
(parameters
|
||||
'("const-GstTagList*" "list")
|
||||
'("const-gchar*" "tag")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function list_from_vorbiscomment_buffer
|
||||
(c-name "gst_tag_list_from_vorbiscomment_buffer")
|
||||
(return-type "GstTagList*")
|
||||
(parameters
|
||||
'("const-GstBuffer*" "buffer")
|
||||
'("const-guint8*" "id_data")
|
||||
'("const-guint" "id_data_length")
|
||||
'("gchar**" "vendor_string")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method to_vorbiscomment_buffer
|
||||
(of-object "GstTagList")
|
||||
(c-name "gst_tag_list_to_vorbiscomment_buffer")
|
||||
(return-type "GstBuffer*")
|
||||
(parameters
|
||||
'("const-guint8*" "id_data")
|
||||
'("const-guint" "id_data_length")
|
||||
'("const-gchar*" "vendor_string")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function id3_genre_count
|
||||
(c-name "gst_tag_id3_genre_count")
|
||||
(return-type "guint")
|
||||
)
|
||||
|
||||
(define-function id3_genre_get
|
||||
(c-name "gst_tag_id3_genre_get")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-guint" "id")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function list_new_from_id3v1
|
||||
(c-name "gst_tag_list_new_from_id3v1")
|
||||
(return-type "GstTagList*")
|
||||
(parameters
|
||||
'("const-guint8*" "data")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function from_id3_tag
|
||||
(c-name "gst_tag_from_id3_tag")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "id3_tag")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function from_id3_user_tag
|
||||
(c-name "gst_tag_from_id3_user_tag")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "type")
|
||||
'("const-gchar*" "id3_user_tag")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function to_id3_tag
|
||||
(c-name "gst_tag_to_id3_tag")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "gst_tag")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method add_id3_image
|
||||
(of-object "GstTagList")
|
||||
(c-name "gst_tag_list_add_id3_image")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("const-guint8*" "image_data")
|
||||
'("guint" "image_data_len")
|
||||
'("guint" "id3_picture_type")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method to_exif_buffer
|
||||
(of-object "GstTagList")
|
||||
(c-name "gst_tag_list_to_exif_buffer")
|
||||
(return-type "GstBuffer*")
|
||||
(parameters
|
||||
'("gint" "byte_order")
|
||||
'("guint32" "base_offset")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method to_exif_buffer_with_tiff_header
|
||||
(of-object "GstTagList")
|
||||
(c-name "gst_tag_list_to_exif_buffer_with_tiff_header")
|
||||
(return-type "GstBuffer*")
|
||||
)
|
||||
|
||||
(define-function tag_list_from_exif_buffer
|
||||
(c-name "gst_tag_list_from_exif_buffer")
|
||||
(return-type "GstTagList*")
|
||||
(parameters
|
||||
'("const-GstBuffer*" "buffer")
|
||||
'("gint" "byte_order")
|
||||
'("guint32" "base_offset")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function tag_list_from_exif_buffer_with_tiff_header
|
||||
(c-name "gst_tag_list_from_exif_buffer_with_tiff_header")
|
||||
(return-type "GstTagList*")
|
||||
(parameters
|
||||
'("const-GstBuffer*" "buffer")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function parse_extended_comment
|
||||
(c-name "gst_tag_parse_extended_comment")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("const-gchar*" "ext_comment")
|
||||
'("gchar**" "key")
|
||||
'("gchar**" "lang")
|
||||
'("gchar**" "value")
|
||||
'("gboolean" "fail_if_no_key")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function freeform_string_to_utf8
|
||||
(c-name "gst_tag_freeform_string_to_utf8")
|
||||
(return-type "gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "data")
|
||||
'("gint" "size")
|
||||
'("const-gchar**" "env_vars")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function image_data_to_image_buffer
|
||||
(c-name "gst_tag_image_data_to_image_buffer")
|
||||
(return-type "GstBuffer*")
|
||||
(parameters
|
||||
'("const-guint8*" "image_data")
|
||||
'("guint" "image_data_len")
|
||||
'("GstTagImageType" "image_type")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function register_musicbrainz_tags
|
||||
(c-name "gst_tag_register_musicbrainz_tags")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-function get_language_codes
|
||||
(c-name "gst_tag_get_language_codes")
|
||||
(return-type "gchar**")
|
||||
)
|
||||
|
||||
(define-function get_language_name
|
||||
(c-name "gst_tag_get_language_name")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "language_code")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function get_language_code_iso_639_1
|
||||
(c-name "gst_tag_get_language_code_iso_639_1")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "lang_code")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function get_language_code_iso_639_2B
|
||||
(c-name "gst_tag_get_language_code_iso_639_2B")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "lang_code")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function get_language_code_iso_639_2T
|
||||
(c-name "gst_tag_get_language_code_iso_639_2T")
|
||||
(return-type "const-gchar*")
|
||||
(parameters
|
||||
'("const-gchar*" "lang_code")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function tag_list_from_xmp_buffer
|
||||
(c-name "gst_tag_list_from_xmp_buffer")
|
||||
(return-type "GstTagList*")
|
||||
(parameters
|
||||
'("const-GstBuffer*" "buffer")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function tag_list_to_xmp_buffer
|
||||
(c-name "gst_tag_list_to_xmp_buffer")
|
||||
(return-type "GstBuffer*")
|
||||
(parameters
|
||||
'("const-GstTagList*" "taglist")
|
||||
'("gboolean" "readonly")
|
||||
)
|
||||
)
|
||||
|
105
gst/tag.override
105
gst/tag.override
|
@ -1,105 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2008 <edward.hervey@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#define NO_IMPORT_PYGOBJECT
|
||||
#include "common.h"
|
||||
#include "pygst.h"
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <gst/tag/tag.h>
|
||||
#include <gst/tag/gsttagdemux.h>
|
||||
#include "pygstminiobject.h"
|
||||
GST_DEBUG_CATEGORY_EXTERN (pygst_debug);
|
||||
#define GST_CAT_DEFAULT pygst_debug
|
||||
|
||||
/* Boonky define that allows for backwards compatibility with Python 2.4 */
|
||||
#if PY_VERSION_HEX < 0x02050000
|
||||
#define Py_ssize_t int
|
||||
#endif
|
||||
|
||||
%%
|
||||
modulename gst.tag
|
||||
%%
|
||||
import gobject.GObject as PyGObject_Type
|
||||
import gst.Object as PyGstObject_Type
|
||||
import gst.Structure as PyGstStructure_Type
|
||||
import gst.Element as PyGstElement_Type
|
||||
import gst.Pad as PyGstPad_Type
|
||||
import gst.Buffer as PyGstBuffer_Type
|
||||
import gst.Message as PyGstMessage_Type
|
||||
import gst.SystemClock as PyGstSystemClock_Type
|
||||
import gst.BaseTransform as PyGstBaseTransform_Type
|
||||
import gst.BaseSink as PyGstBaseSink_Type
|
||||
%%
|
||||
include
|
||||
gstversion.override
|
||||
%%
|
||||
ignore-glob
|
||||
_*
|
||||
*init
|
||||
*_free
|
||||
*_get_type
|
||||
|
||||
%%
|
||||
override gst_tag_to_vorbis_comments
|
||||
static PyObject *
|
||||
_wrap_gst_tag_to_vorbis_comments(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
PyObject *py_taglist;
|
||||
const GstTagList *taglist;
|
||||
const gchar *tag;
|
||||
|
||||
const GList *list;
|
||||
const GList *l;
|
||||
PyObject *py_list;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Os", &py_taglist, &tag))
|
||||
return NULL;
|
||||
|
||||
if (pyg_boxed_check(py_taglist, GST_TYPE_TAG_LIST))
|
||||
taglist = pyg_boxed_get(py_taglist, GstTagList);
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "list should be a GstTagList");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
pyg_begin_allow_threads;
|
||||
list = gst_tag_to_vorbis_comments (taglist, tag);
|
||||
pyg_end_allow_threads;
|
||||
|
||||
py_list = PyList_New(0);
|
||||
|
||||
for (l = list; l; l = l->next) {
|
||||
gchar *pair = (gchar *)l->data;
|
||||
PyObject *py_pair = PyString_FromString(pair);
|
||||
PyList_Append(py_list, py_pair);
|
||||
Py_DECREF(py_pair);
|
||||
}
|
||||
return py_list;
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* gst-python
|
||||
* Copyright (C) 2008 Edward Hervey <edward.hervey@collabora.co.uk>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* include this first, before NO_IMPORT_PYGOBJECT is defined */
|
||||
#include <pygobject.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/tag/tag.h>
|
||||
#include "pygst.h"
|
||||
|
||||
void pytag_register_classes (PyObject * d);
|
||||
void pytag_add_constants (PyObject * module, const gchar * strip_prefix);
|
||||
|
||||
extern PyMethodDef pytag_functions[];
|
||||
|
||||
GST_DEBUG_CATEGORY (pygst_debug); /* for python code */
|
||||
|
||||
DL_EXPORT (void)
|
||||
inittag (void)
|
||||
{
|
||||
PyObject *m, *d;
|
||||
|
||||
init_pygobject ();
|
||||
pygst_init ();
|
||||
/* Initialize tag library */
|
||||
gst_tag_register_musicbrainz_tags ();
|
||||
|
||||
m = Py_InitModule ("tag", pytag_functions);
|
||||
d = PyModule_GetDict (m);
|
||||
|
||||
pytag_register_classes (d);
|
||||
pytag_add_constants (m, "GST_");
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
Py_FatalError ("can't initialize module gst.tag");
|
||||
}
|
||||
}
|
425
gst/video.defs
425
gst/video.defs
|
@ -1,425 +0,0 @@
|
|||
;; -*- scheme -*-
|
||||
; object definitions ...
|
||||
(define-object VideoFilter
|
||||
(in-module "Gst")
|
||||
(parent "GstBaseTransform")
|
||||
(c-name "GstVideoFilter")
|
||||
(gtype-id "GST_TYPE_VIDEO_FILTER")
|
||||
)
|
||||
|
||||
(define-object VideoSink
|
||||
(in-module "Gst")
|
||||
(parent "GstBaseSink")
|
||||
(c-name "GstVideoSink")
|
||||
(gtype-id "GST_TYPE_VIDEO_SINK")
|
||||
)
|
||||
|
||||
;; Enumerations and flags ...
|
||||
|
||||
(define-enum VideoFormat
|
||||
(in-module "Gst")
|
||||
(c-name "GstVideoFormat")
|
||||
(gtype-id "GST_TYPE_VIDEO_FORMAT")
|
||||
(values
|
||||
'("unknown" "GST_VIDEO_FORMAT_UNKNOWN")
|
||||
'("i420" "GST_VIDEO_FORMAT_I420")
|
||||
'("yv12" "GST_VIDEO_FORMAT_YV12")
|
||||
'("yuy2" "GST_VIDEO_FORMAT_YUY2")
|
||||
'("uyvy" "GST_VIDEO_FORMAT_UYVY")
|
||||
'("ayuv" "GST_VIDEO_FORMAT_AYUV")
|
||||
'("rgbx" "GST_VIDEO_FORMAT_RGBx")
|
||||
'("bgrx" "GST_VIDEO_FORMAT_BGRx")
|
||||
'("xrgb" "GST_VIDEO_FORMAT_xRGB")
|
||||
'("xbgr" "GST_VIDEO_FORMAT_xBGR")
|
||||
'("rgba" "GST_VIDEO_FORMAT_RGBA")
|
||||
'("bgra" "GST_VIDEO_FORMAT_BGRA")
|
||||
'("argb" "GST_VIDEO_FORMAT_ARGB")
|
||||
'("abgr" "GST_VIDEO_FORMAT_ABGR")
|
||||
'("rgb" "GST_VIDEO_FORMAT_RGB")
|
||||
'("bgr" "GST_VIDEO_FORMAT_BGR")
|
||||
'("y41b" "GST_VIDEO_FORMAT_Y41B")
|
||||
'("y42b" "GST_VIDEO_FORMAT_Y42B")
|
||||
'("yvyu" "GST_VIDEO_FORMAT_YVYU")
|
||||
'("y444" "GST_VIDEO_FORMAT_Y444")
|
||||
'("v210" "GST_VIDEO_FORMAT_v210")
|
||||
'("v216" "GST_VIDEO_FORMAT_v216")
|
||||
'("nv12" "GST_VIDEO_FORMAT_NV12")
|
||||
'("nv21" "GST_VIDEO_FORMAT_NV21")
|
||||
'("gray8" "GST_VIDEO_FORMAT_GRAY8")
|
||||
'("gray16-be" "GST_VIDEO_FORMAT_GRAY16_BE")
|
||||
'("gray16-le" "GST_VIDEO_FORMAT_GRAY16_LE")
|
||||
'("v308" "GST_VIDEO_FORMAT_v308")
|
||||
'("y800" "GST_VIDEO_FORMAT_Y800")
|
||||
'("y16" "GST_VIDEO_FORMAT_Y16")
|
||||
'("rgb16" "GST_VIDEO_FORMAT_RGB16")
|
||||
'("bgr16" "GST_VIDEO_FORMAT_BGR16")
|
||||
'("rgb15" "GST_VIDEO_FORMAT_RGB15")
|
||||
'("bgr15" "GST_VIDEO_FORMAT_BGR15")
|
||||
'("uyvp" "GST_VIDEO_FORMAT_UYVP")
|
||||
'("a420" "GST_VIDEO_FORMAT_A420")
|
||||
'("rgb8-paletted" "GST_VIDEO_FORMAT_RGB8_PALETTED")
|
||||
'("yuv9" "GST_VIDEO_FORMAT_YUV9")
|
||||
'("yvu9" "GST_VIDEO_FORMAT_YVU9")
|
||||
'("iyu1" "GST_VIDEO_FORMAT_IYU1")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; From gstvideofilter.h
|
||||
|
||||
(define-function gst_video_filter_get_type
|
||||
(c-name "gst_video_filter_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From gstvideosink.h
|
||||
|
||||
(define-function gst_video_sink_get_type
|
||||
(c-name "gst_video_sink_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function video_sink_center_rect
|
||||
(c-name "gst_video_sink_center_rect")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstVideoRectangle" "src")
|
||||
'("GstVideoRectangle" "dst")
|
||||
'("GstVideoRectangle*" "result")
|
||||
'("gboolean" "scaling")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From video.h
|
||||
|
||||
(define-function get_size
|
||||
(c-name "gst_video_get_size")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstPad*" "pad")
|
||||
'("gint*" "width")
|
||||
'("gint*" "height")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function calculate_display_ratio
|
||||
(c-name "gst_video_calculate_display_ratio")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("guint*" "dar_n")
|
||||
'("guint*" "dar_d")
|
||||
'("guint" "video_width")
|
||||
'("guint" "video_height")
|
||||
'("guint" "video_par_n")
|
||||
'("guint" "video_par_d")
|
||||
'("guint" "display_par_n")
|
||||
'("guint" "display_par_d")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function format_parse_caps
|
||||
(c-name "gst_video_format_parse_caps")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstCaps*" "caps")
|
||||
'("GstVideoFormat*" "format")
|
||||
'("int*" "width")
|
||||
'("int*" "height")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function format_parse_caps_interlaced
|
||||
(c-name "gst_video_format_parse_caps_interlaced")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstCaps*" "caps")
|
||||
'("gboolean*" "interlaced")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function parse_caps_framerate
|
||||
(c-name "gst_video_parse_caps_framerate")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstCaps*" "caps")
|
||||
'("int*" "fps_n")
|
||||
'("int*" "fps_d")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function parse_caps_pixel_aspect_ratio
|
||||
(c-name "gst_video_parse_caps_pixel_aspect_ratio")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstCaps*" "caps")
|
||||
'("int*" "par_n")
|
||||
'("int*" "par_d")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function parse_caps_color_matrix
|
||||
(c-name "gst_video_parse_caps_color_matrix")
|
||||
(return-type "const-char*")
|
||||
(parameters
|
||||
'("GstCaps*" "caps")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function parse_caps_chroma_site
|
||||
(c-name "gst_video_parse_caps_chroma_site")
|
||||
(return-type "const-char*")
|
||||
(parameters
|
||||
'("GstCaps*" "caps")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function video_parse_caps_palette
|
||||
(c-name "gst_video_parse_caps_palette")
|
||||
(return-type "GstBuffer*")
|
||||
(parameters
|
||||
'("GstCaps*" "caps")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method new_caps
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_new_caps")
|
||||
(caller-owns-return #t)
|
||||
(return-type "GstCaps*")
|
||||
(parameters
|
||||
'("int" "width")
|
||||
'("int" "height")
|
||||
'("int" "framerate_n")
|
||||
'("int" "framerate_d")
|
||||
'("int" "par_n")
|
||||
'("int" "par_d")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method new_caps_interlaced
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_new_caps_interlaced")
|
||||
(caller-owns-return #t)
|
||||
(return-type "GstCaps*")
|
||||
(parameters
|
||||
'("int" "width")
|
||||
'("int" "height")
|
||||
'("int" "framerate_n")
|
||||
'("int" "framerate_d")
|
||||
'("int" "par_n")
|
||||
'("int" "par_d")
|
||||
'("gboolean" "interlaced")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function format_from_fourcc
|
||||
(c-name "gst_video_format_from_fourcc")
|
||||
(return-type "GstVideoFormat")
|
||||
(parameters
|
||||
'("guint32" "fourcc")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method to_fourcc
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_to_fourcc")
|
||||
(return-type "guint32")
|
||||
)
|
||||
|
||||
(define-method is_rgb
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_is_rgb")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method is_yuv
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_is_yuv")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method is_gray
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_is_gray")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method has_alpha
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_has_alpha")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method get_row_stride
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_get_row_stride")
|
||||
(return-type "int")
|
||||
(parameters
|
||||
'("int" "component")
|
||||
'("int" "width")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_pixel_stride
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_get_pixel_stride")
|
||||
(return-type "int")
|
||||
(parameters
|
||||
'("int" "component")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_component_width
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_get_component_width")
|
||||
(return-type "int")
|
||||
(parameters
|
||||
'("int" "component")
|
||||
'("int" "width")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_component_height
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_get_component_height")
|
||||
(return-type "int")
|
||||
(parameters
|
||||
'("int" "component")
|
||||
'("int" "height")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_component_offset
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_get_component_offset")
|
||||
(return-type "int")
|
||||
(parameters
|
||||
'("int" "component")
|
||||
'("int" "width")
|
||||
'("int" "height")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_size
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_get_size")
|
||||
(return-type "int")
|
||||
(parameters
|
||||
'("int" "width")
|
||||
'("int" "height")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method convert
|
||||
(of-object "GstVideoFormat")
|
||||
(c-name "gst_video_format_convert")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("int" "width")
|
||||
'("int" "height")
|
||||
'("int" "fps_n")
|
||||
'("int" "fps_d")
|
||||
'("GstFormat" "src_format")
|
||||
'("gint64" "src_value")
|
||||
'("GstFormat" "dest_format")
|
||||
'("gint64*" "dest_value")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function event_new_still_frame
|
||||
(c-name "gst_video_event_new_still_frame")
|
||||
(return-type "GstEvent*")
|
||||
(parameters
|
||||
'("gboolean" "in_still")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function event_parse_still_frame
|
||||
(c-name "gst_video_event_parse_still_frame")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstEvent*" "event")
|
||||
'("gboolean*" "in_still")
|
||||
)
|
||||
)
|
||||
(define-function video_convert_frame
|
||||
(c-name "gst_video_convert_frame")
|
||||
(return-type "GstBuffer*")
|
||||
(parameters
|
||||
'("GstBuffer*" "buf")
|
||||
'("const-GstCaps*" "to_caps")
|
||||
'("GstClockTime" "timeout")
|
||||
'("GError**" "error")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function video_convert_frame_async
|
||||
(c-name "gst_video_convert_frame_async")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstBuffer*" "buf")
|
||||
'("const-GstCaps*" "to_caps")
|
||||
'("GstClockTime" "timeout")
|
||||
'("GstVideoConvertFrameCallback" "callback")
|
||||
'("gpointer" "user_data")
|
||||
'("GDestroyNotify" "destroy_notify")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function event_new_downstream_force_key_unit
|
||||
(c-name "gst_video_event_new_downstream_force_key_unit")
|
||||
(return-type "GstEvent*")
|
||||
(parameters
|
||||
'("GstClockTime" "timestamp")
|
||||
'("GstClockTime" "streamtime")
|
||||
'("GstClockTime" "runningtime")
|
||||
'("gboolean" "all_headers")
|
||||
'("guint" "count")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function event_parse_downstream_force_key_unit
|
||||
(c-name "gst_video_event_parse_downstream_force_key_unit")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstEvent*" "event")
|
||||
'("GstClockTime*" "timestamp")
|
||||
'("GstClockTime*" "streamtime")
|
||||
'("GstClockTime*" "runningtime")
|
||||
'("gboolean*" "all_headers")
|
||||
'("guint*" "count")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function event_new_upstream_force_key_unit
|
||||
(c-name "gst_video_event_new_upstream_force_key_unit")
|
||||
(return-type "GstEvent*")
|
||||
(parameters
|
||||
'("GstClockTime" "running_time")
|
||||
'("gboolean" "all_headers")
|
||||
'("guint" "count")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function event_parse_upstream_force_key_unit
|
||||
(c-name "gst_video_event_parse_upstream_force_key_unit")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstEvent*" "event")
|
||||
'("GstClockTime*" "running_time")
|
||||
'("gboolean*" "all_headers")
|
||||
'("guint*" "count")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function event_is_force_key_unit
|
||||
(c-name "gst_video_event_is_force_key_unit")
|
||||
(return-type "gboolean")
|
||||
(parameters
|
||||
'("GstEvent*" "event")
|
||||
)
|
||||
)
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue