mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
examples/gstreamer/filesrc.py,player.py: New examples
Original commit message from CVS: * examples/gstreamer/filesrc.py,player.py: New examples * gstreamer/gstreamer.override: Add a dict like interface to GstTagList * gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override * gstreamer/gst-types.defs: Don't use gst_buffer_free/gst_data_free, use gst_data_unref instead. * gstreamer/gst-types.c (PyGstData_to_value): Don't send address here. * gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the address to stuff, since we really want to avoid segfaults :) * gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7 * gstreamer/0.7.[c,defs,h,override]: Remove, merge with gstreamer.* * gstreamer/Makefile.am: Clean up, remove versioning support.
This commit is contained in:
parent
b27c464e5e
commit
a37dede09c
51 changed files with 1130 additions and 2455 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2004-02-27 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
* examples/gstreamer/filesrc.py,player.py: New examples
|
||||
|
||||
* gstreamer/gstreamer.override: Add a dict like interface to GstTagList
|
||||
|
||||
* gstreamer/gstpad-handlers.override: New file, split out from gstreamer.override
|
||||
|
||||
* gstreamer/gst-types.defs: Don't use
|
||||
gst_buffer_free/gst_data_free, use gst_data_unref instead.
|
||||
|
||||
* gstreamer/gst-types.c (PyGstData_to_value): Don't send address here.
|
||||
|
||||
* gstreamer/arg-types.py (GstDataPtrArg.write_param): Send the
|
||||
address to stuff, since we really want to avoid segfaults :)
|
||||
|
||||
* gstreamer/0.6.[c,defs,h,override]: Remove, we're focusing on 0.7
|
||||
|
||||
* gstreamer/0.7.[c,defs,h,override]: Remove, merge with
|
||||
gstreamer.*
|
||||
|
||||
* gstreamer/Makefile.am: Clean up, remove versioning support.
|
||||
|
||||
2004-02-25 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
* gstreamer/gstreamer.override:
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 0945c85c4c9139e2e5b8e04d0fc841b8aa1e6e9b
|
||||
Subproject commit 874dab5c3461ad7487f1ae029256b6da82dddf6d
|
54
examples/gst/filesrc.py
Executable file
54
examples/gst/filesrc.py
Executable file
|
@ -0,0 +1,54 @@
|
|||
import sys
|
||||
import gobject
|
||||
import gst
|
||||
|
||||
class FileSource(gst.Element):
|
||||
blocksize = 4096
|
||||
fd = None
|
||||
def __init__(self, name):
|
||||
self.__gobject_init__()
|
||||
self.set_name(name)
|
||||
self.srcpad = gst.Pad('src', gst.PAD_SRC)
|
||||
self.srcpad.set_get_function(self.srcpad_get)
|
||||
self.add_pad(self.srcpad)
|
||||
|
||||
def set_property(self, name, value):
|
||||
if name == 'location':
|
||||
self.fd = open(value, 'r')
|
||||
|
||||
def srcpad_get(self, pad):
|
||||
data = self.fd.read(self.blocksize)
|
||||
if data:
|
||||
return gst.Buffer(data)
|
||||
else:
|
||||
self.set_eos()
|
||||
return gst.Event(gst.EVENT_EOS)
|
||||
gobject.type_register(FileSource)
|
||||
|
||||
def main(args):
|
||||
if len(args) != 3:
|
||||
print 'Usage: %s input output' % (args[0])
|
||||
return -1
|
||||
|
||||
bin = gst.Pipeline('pipeline')
|
||||
|
||||
filesrc = FileSource('filesource')
|
||||
#filesrc = gst.Element('filesrc', 'src')
|
||||
filesrc.set_property('location', args[1])
|
||||
|
||||
filesink = gst.Element('filesink', 'sink')
|
||||
filesink.set_property('location', args[2])
|
||||
|
||||
bin.add_many(filesrc, filesink)
|
||||
gst.element_link_many(filesrc, filesink)
|
||||
|
||||
bin.set_state(gst.STATE_PLAYING);
|
||||
|
||||
while bin.iterate():
|
||||
pass
|
||||
|
||||
bin.set_state(gst.STATE_NULL)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# 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
|
||||
|
@ -57,8 +58,13 @@ def filter(element):
|
|||
filesrc = gst.Element('sinesrc', 'source');
|
||||
filesink = gst.Element('fakesink', 'sink')
|
||||
|
||||
bin.add_many(filesrc, element, filesink)
|
||||
gst.element_link_many(filesrc, element, filesink)
|
||||
stats = gst.Element('statistics', 'stats');
|
||||
stats.set_property('silent', False)
|
||||
stats.set_property('buffer_update_freq', True)
|
||||
stats.set_property('update_on_eos', True)
|
||||
|
||||
bin.add_many(filesrc, element, stats, filesink)
|
||||
gst.element_link_many(filesrc, element, stats, filesink)
|
||||
|
||||
# start playing
|
||||
bin.set_state(gst.STATE_PLAYING);
|
||||
|
|
41
examples/gst/player.py
Executable file
41
examples/gst/player.py
Executable file
|
@ -0,0 +1,41 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
import gst
|
||||
|
||||
def found_tags(element, source, tags):
|
||||
print 'Artist:', tags.get('artist')
|
||||
print 'Title: ', tags.get('title')
|
||||
print 'Album: ', tags.get('album')
|
||||
|
||||
def playfile(filename):
|
||||
bin = gst.Pipeline('player')
|
||||
|
||||
source = gst.Element('filesrc', 'src')
|
||||
source.set_property('location', filename)
|
||||
|
||||
spider = gst.Element('spider', 'spider')
|
||||
spider.connect('found-tag', found_tags)
|
||||
|
||||
sink = gst.Element('osssink', 'sink')
|
||||
|
||||
bin.add_many(source, spider, sink)
|
||||
gst.element_link_many(source, spider, sink)
|
||||
|
||||
print 'Playing:', os.path.basename(filename)
|
||||
bin.set_state(gst.STATE_PLAYING)
|
||||
|
||||
try:
|
||||
while bin.iterate():
|
||||
pass
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
bin.set_state(gst.STATE_NULL)
|
||||
|
||||
def main(args):
|
||||
map(playfile, args[1:])
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
|
54
examples/gstreamer/filesrc.py
Normal file
54
examples/gstreamer/filesrc.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
import sys
|
||||
import gobject
|
||||
import gst
|
||||
|
||||
class FileSource(gst.Element):
|
||||
blocksize = 4096
|
||||
fd = None
|
||||
def __init__(self, name):
|
||||
self.__gobject_init__()
|
||||
self.set_name(name)
|
||||
self.srcpad = gst.Pad('src', gst.PAD_SRC)
|
||||
self.srcpad.set_get_function(self.srcpad_get)
|
||||
self.add_pad(self.srcpad)
|
||||
|
||||
def set_property(self, name, value):
|
||||
if name == 'location':
|
||||
self.fd = open(value, 'r')
|
||||
|
||||
def srcpad_get(self, pad):
|
||||
data = self.fd.read(self.blocksize)
|
||||
if data:
|
||||
return gst.Buffer(data)
|
||||
else:
|
||||
self.set_eos()
|
||||
return gst.Event(gst.EVENT_EOS)
|
||||
gobject.type_register(FileSource)
|
||||
|
||||
def main(args):
|
||||
if len(args) != 3:
|
||||
print 'Usage: %s input output' % (args[0])
|
||||
return -1
|
||||
|
||||
bin = gst.Pipeline('pipeline')
|
||||
|
||||
filesrc = FileSource('filesource')
|
||||
#filesrc = gst.Element('filesrc', 'src')
|
||||
filesrc.set_property('location', args[1])
|
||||
|
||||
filesink = gst.Element('filesink', 'sink')
|
||||
filesink.set_property('location', args[2])
|
||||
|
||||
bin.add_many(filesrc, filesink)
|
||||
gst.element_link_many(filesrc, filesink)
|
||||
|
||||
bin.set_state(gst.STATE_PLAYING);
|
||||
|
||||
while bin.iterate():
|
||||
pass
|
||||
|
||||
bin.set_state(gst.STATE_NULL)
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# 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
|
||||
|
@ -57,8 +58,13 @@ def filter(element):
|
|||
filesrc = gst.Element('sinesrc', 'source');
|
||||
filesink = gst.Element('fakesink', 'sink')
|
||||
|
||||
bin.add_many(filesrc, element, filesink)
|
||||
gst.element_link_many(filesrc, element, filesink)
|
||||
stats = gst.Element('statistics', 'stats');
|
||||
stats.set_property('silent', False)
|
||||
stats.set_property('buffer_update_freq', True)
|
||||
stats.set_property('update_on_eos', True)
|
||||
|
||||
bin.add_many(filesrc, element, stats, filesink)
|
||||
gst.element_link_many(filesrc, element, stats, filesink)
|
||||
|
||||
# start playing
|
||||
bin.set_state(gst.STATE_PLAYING);
|
||||
|
|
41
examples/gstreamer/player.py
Normal file
41
examples/gstreamer/player.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
import gst
|
||||
|
||||
def found_tags(element, source, tags):
|
||||
print 'Artist:', tags.get('artist')
|
||||
print 'Title: ', tags.get('title')
|
||||
print 'Album: ', tags.get('album')
|
||||
|
||||
def playfile(filename):
|
||||
bin = gst.Pipeline('player')
|
||||
|
||||
source = gst.Element('filesrc', 'src')
|
||||
source.set_property('location', filename)
|
||||
|
||||
spider = gst.Element('spider', 'spider')
|
||||
spider.connect('found-tag', found_tags)
|
||||
|
||||
sink = gst.Element('osssink', 'sink')
|
||||
|
||||
bin.add_many(source, spider, sink)
|
||||
gst.element_link_many(source, spider, sink)
|
||||
|
||||
print 'Playing:', os.path.basename(filename)
|
||||
bin.set_state(gst.STATE_PLAYING)
|
||||
|
||||
try:
|
||||
while bin.iterate():
|
||||
pass
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
bin.set_state(gst.STATE_NULL)
|
||||
|
||||
def main(args):
|
||||
map(playfile, args[1:])
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
|
30
gst/0.6.c
30
gst/0.6.c
|
@ -1,30 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "0.6.h"
|
||||
|
||||
GstPropsType gst_props_entry_get_props_type(GstPropsEntry *entry)
|
||||
{
|
||||
return gst_props_entry_get_type(entry);
|
||||
}
|
42
gst/0.6.defs
42
gst/0.6.defs
|
@ -1,42 +0,0 @@
|
|||
;;
|
||||
;; Override normal *_get_type handling via rename
|
||||
;;
|
||||
|
||||
(define-method get_props_type
|
||||
(of-object "GstPropsEntry")
|
||||
(c-name "gst_props_entry_get_props_type")
|
||||
(return-type "GstPropsType")
|
||||
)
|
||||
|
||||
;;
|
||||
;; Access GstProps properties list
|
||||
;;
|
||||
|
||||
(define-method get_list
|
||||
(of-object "GstProps")
|
||||
(c-name "gst_props_get_list")
|
||||
(return-type "const-GList*")
|
||||
)
|
||||
|
||||
;;
|
||||
;; 0.6 Boxed types
|
||||
;;
|
||||
|
||||
(define-boxed BufferPool
|
||||
(in-module "Gst")
|
||||
(c-name "GstBufferPool")
|
||||
(gtype-id "GST_TYPE_BUFFER_POOL")
|
||||
)
|
||||
|
||||
(define-boxed Props
|
||||
(in-module "Gst")
|
||||
(c-name "GstProps")
|
||||
(gtype-id "GST_TYPE_PROPS")
|
||||
)
|
||||
|
||||
(define-boxed PropsEntry
|
||||
(in-module "Gst")
|
||||
(c-name "GstPropsEntry")
|
||||
(gtype-id "GST_TYPE_PROPS_ENTRY")
|
||||
)
|
||||
|
24
gst/0.6.h
24
gst/0.6.h
|
@ -1,24 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
GstPropsType gst_props_entry_get_props_type(GstPropsEntry *entry);
|
188
gst/0.6.override
188
gst/0.6.override
|
@ -1,188 +0,0 @@
|
|||
/* -*- Mode: C; 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>
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
#include <Python.h>
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "0.6.h"
|
||||
%%
|
||||
override gst_props_entry_get_int
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_int(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gint val;
|
||||
|
||||
val = 0;
|
||||
ret = gst_props_entry_get_int(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
return Py_BuildValue("(bi)", ret, val);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_float
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_float(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gfloat val;
|
||||
|
||||
val = 0.0f;
|
||||
ret = gst_props_entry_get_float(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
return Py_BuildValue("(bf)", ret, val);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_fourcc_int
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_fourcc_int(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gint32 val;
|
||||
|
||||
val = 0;
|
||||
ret = gst_props_entry_get_fourcc_int(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
return Py_BuildValue("(bi)", ret, val);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_boolean
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_boolean(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gboolean val;
|
||||
PyObject *py_val;
|
||||
|
||||
val = FALSE;
|
||||
ret = gst_props_entry_get_boolean(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
|
||||
py_val = val ? Py_True : Py_False;
|
||||
return Py_BuildValue("(bO)", ret, py_val);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_string
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_string(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
const gchar *val;
|
||||
|
||||
val = NULL;
|
||||
ret = gst_props_entry_get_string(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
if (ret) {
|
||||
return Py_BuildValue("(bs)", ret, val);
|
||||
} else {
|
||||
return Py_BuildValue("(bO)", ret, Py_None);
|
||||
}
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_int_range
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_int_range(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gint min, max;
|
||||
|
||||
min = max = 0;
|
||||
ret = gst_props_entry_get_int_range(pyg_boxed_get(self, GstPropsEntry), &min, &max);
|
||||
return Py_BuildValue("(bii)", ret, min, max);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_float_range
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_float_range(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gfloat min, max;
|
||||
|
||||
min = max = 0.0f;
|
||||
ret = gst_props_entry_get_float_range(pyg_boxed_get(self, GstPropsEntry), &min, &max);
|
||||
return Py_BuildValue("(bff)", ret, min, max);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_list
|
||||
|
||||
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_list(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
const GList *list;
|
||||
PyObject *tuple, *obj;
|
||||
int i;
|
||||
|
||||
list = NULL;
|
||||
ret = gst_props_entry_get_list(pyg_boxed_get(self, GstPropsEntry), &list);
|
||||
if (ret == TRUE) {
|
||||
tuple = PyTuple_New(g_list_length((GList *) list));
|
||||
for (i = 0; list != NULL; i++, list = g_list_next(list)) {
|
||||
obj = pyg_boxed_new(GST_TYPE_PROPS_ENTRY, list->data, TRUE, TRUE);
|
||||
PyTuple_SET_ITEM(tuple, i, obj);
|
||||
}
|
||||
} else {
|
||||
tuple = Py_None;
|
||||
Py_INCREF(tuple);
|
||||
}
|
||||
return Py_BuildValue("(bO)", ret, tuple);
|
||||
}
|
||||
%%
|
||||
override gst_props_get_list
|
||||
|
||||
static gboolean
|
||||
gst_props_get_list(GstProps *props, GList **list)
|
||||
{
|
||||
*list = GST_PROPS_PROPERTIES(props);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_get_list(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
GList *list;
|
||||
PyObject *tuple, *obj;
|
||||
int i;
|
||||
|
||||
list = NULL;
|
||||
ret = gst_props_get_list(pyg_boxed_get(self, GstProps), &list);
|
||||
if (ret == TRUE) {
|
||||
tuple = PyTuple_New(g_list_length(list));
|
||||
for (i = 0; list != NULL; i++, list = g_list_next(list)) {
|
||||
obj = pyg_boxed_new(GST_TYPE_PROPS_ENTRY, list->data, TRUE, TRUE);
|
||||
PyTuple_SET_ITEM(tuple, i, obj);
|
||||
}
|
||||
} else {
|
||||
tuple = Py_None;
|
||||
Py_INCREF(tuple);
|
||||
}
|
||||
return Py_BuildValue("(bO)", ret, tuple);
|
||||
}
|
||||
|
||||
|
25
gst/0.7.c
25
gst/0.7.c
|
@ -1,25 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "0.7.h"
|
15
gst/0.7.defs
15
gst/0.7.defs
|
@ -1,15 +0,0 @@
|
|||
;;
|
||||
;; 0.7 Boxed types
|
||||
;;
|
||||
|
||||
(define-boxed Structure
|
||||
(in-module "Gst")
|
||||
(c-name "GstStructure")
|
||||
(gtype-id "GST_TYPE_STRUCTURE")
|
||||
)
|
||||
|
||||
(define-boxed TagList
|
||||
(in-module "Gst")
|
||||
(c-name "GstTagList")
|
||||
(gtype-id "GST_TYPE_TAG_LIST")
|
||||
)
|
20
gst/0.7.h
20
gst/0.7.h
|
@ -1,20 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
245
gst/0.7.override
245
gst/0.7.override
|
@ -1,245 +0,0 @@
|
|||
/* -*- Mode: C; 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>
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
#include <Python.h>
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "0.7.h"
|
||||
%%
|
||||
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;
|
||||
}
|
||||
self->free_on_dealloc = TRUE;
|
||||
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", NULL };
|
||||
char *field;
|
||||
PyObject *py_value = NULL;
|
||||
GValue value = { 0 };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO:GstStructure.set_value", kwlist, &field, &py_value))
|
||||
return NULL;
|
||||
g_value_init(&value, G_TYPE_STRING);
|
||||
if (pyg_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;
|
||||
}
|
||||
%%
|
||||
override gst_structure_foreach kwargs
|
||||
|
||||
static gboolean
|
||||
pygst_structure_foreach_marshal(GQuark field_id,
|
||||
GValue *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
PyGstCustomNotify *cunote = user_data;
|
||||
PyObject *py_field, *py_value, *retobj;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
g_assert(cunote->func);
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
//py_model = pygobject_new((GObject *)model);
|
||||
//py_path = pygtk_tree_path_to_pyobject(path);
|
||||
//py_iter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE);
|
||||
py_field = Py_BuildValue("s", g_quark_to_string(field_id));
|
||||
py_value = pyg_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_unblock_threads();
|
||||
|
||||
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 gst_tag_list_foreach kwargs
|
||||
|
||||
static gboolean
|
||||
pygst_tag_list_foreach_marshal(GstTagList *list,
|
||||
const gchar *tag,
|
||||
gpointer user_data)
|
||||
{
|
||||
PyGstCustomNotify *cunote = user_data;
|
||||
PyGObject *py_list;
|
||||
PyObject *py_key, *retobj;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
g_assert(cunote->func);
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
py_list = pyg_boxed_new(GST_TYPE_TAG_LIST, list, TRUE, TRUE);
|
||||
py_key = Py_BuildValue("s", tag);
|
||||
if (cunote->data)
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NNO)",
|
||||
py_list,
|
||||
py_key,
|
||||
cunote->data);
|
||||
else
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NN)",
|
||||
py_list,
|
||||
py_key);
|
||||
|
||||
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_unblock_threads();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_tag_list_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:GstTagList.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_tag_list_foreach(pyg_boxed_get(self, GstTagList),
|
||||
pygst_tag_list_foreach_marshal,
|
||||
&cunote);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_tag_list_get_value_index kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_tag_list_get_value_index (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "tag", "index", NULL };
|
||||
char *tag;
|
||||
int index;
|
||||
GValue *gvalue;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"si:GstTagList.get_value_index",
|
||||
kwlist,
|
||||
&tag, &index)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gvalue = gst_tag_list_get_value_index(pyg_boxed_get(self, GstTagList),
|
||||
tag,
|
||||
index);
|
||||
|
||||
return pyg_value_as_pyobject(gvalue, FALSE);
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
MODULE = gstreamer
|
||||
|
||||
INCLUDES = $(PYTHON_INCLUDES) $(PYGTK_CFLAGS)
|
||||
PYGTK_DEFSDIR = @PYGTK_DEFSDIR@
|
||||
|
||||
|
@ -15,50 +13,31 @@ pygstreamer_PYTHON = gstreamer.py
|
|||
|
||||
pygstexecdir = $(pkgpyexecdir)
|
||||
|
||||
GST_OVERRIDES = common.override \
|
||||
0.6.override \
|
||||
0.7.override
|
||||
GST_DEFS = common.defs \
|
||||
0.6.defs \
|
||||
0.7.defs
|
||||
GST_CODE = common.c common.h \
|
||||
0.6.c 0.6.h \
|
||||
0.7.c 0.7.h
|
||||
|
||||
# Ugly hack to pick the proper version code.
|
||||
# Just setting to $(GST_MAJORMINOR).{ch} will not work
|
||||
if GST_0_6
|
||||
VERSOURCES = 0.6.c 0.6.h
|
||||
endif
|
||||
if GST_0_7
|
||||
VERSOURCES = 0.7.c 0.7.h
|
||||
endif
|
||||
GST_OVERRIDES = \
|
||||
gstreamer.override \
|
||||
gstpad-handlers.override
|
||||
|
||||
pygstexec_LTLIBRARIES = _gstmodule.la
|
||||
_gstmodule_la_SOURCES = \
|
||||
gstreamermodule.c \
|
||||
gst-types.c \
|
||||
common.c \
|
||||
common.h \
|
||||
gstreamermodule.c \
|
||||
gst-types.c \
|
||||
$(VERSOURCES)
|
||||
|
||||
_gstmodule_la_CFLAGS = $(GST_CFLAGS) -fno-strict-aliasing
|
||||
_gstmodule_la_LIBADD = $(GST_LIBS)
|
||||
_gstmodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_gst
|
||||
nodist__gstmodule_la_SOURCES = $(MODULE).c
|
||||
nodist__gstmodule_la_SOURCES = gstreamer.c
|
||||
|
||||
CLEANFILES = $(MODULE).c
|
||||
EXTRA_DIST = $(MODULE).defs $(GST_OVERRIDES) $(GST_DEFS) $(GST_CODE) arg-types.py
|
||||
CLEANFILES = gstreamer.c
|
||||
EXTRA_DIST = gstreamer.defs $(GST_OVERRIDES) arg-types.py
|
||||
|
||||
GST_EXCLUDE_INCLUDES=\
|
||||
$(GST_INCLUDEDIR)/gst/gstatomic_impl.h \
|
||||
$(GST_INCLUDEDIR)/gst/gstcompat.h
|
||||
GST_INCLUDES=$(filter-out $(GST_EXCLUDE_INCLUDES),$(wildcard $(GST_INCLUDEDIR)/gst/*.h))
|
||||
|
||||
gstreamer.c: $(srcdir)/$(MODULE).defs $(srcdir)/arg-types.py $(srcdir)/$(MODULE).override
|
||||
gstreamer.c: $(srcdir)/gstreamer.defs $(srcdir)/arg-types.py $(GST_OVERRIDES)
|
||||
$(PYGTK_CODEGEN) \
|
||||
--load-types $(srcdir)/arg-types.py \
|
||||
--register $(srcdir)/gst-types.defs \
|
||||
--override $(srcdir)/$(MODULE).override \
|
||||
--prefix pygst $(MODULE).defs > gen-$(MODULE).c \
|
||||
&& cp gen-$(MODULE).c $(MODULE).c \
|
||||
&& rm -f gen-$(MODULE).c
|
||||
--override $(srcdir)/gstreamer.override \
|
||||
--prefix pygst gstreamer.defs > gen-gstreamer.c \
|
||||
&& rm -fr gtreamer.c \
|
||||
&& echo '/* GENERATED FILE - DO NOT EDIT */' >> gstreamer.c \
|
||||
&& cat gen-gstreamer.c >> gstreamer.c \
|
||||
&& rm -f gen-gstreamer.c
|
||||
|
|
|
@ -28,7 +28,7 @@ class GstDataPtrArg(ArgType):
|
|||
' return NULL;\n')
|
||||
null = (' if (py_%(name)s == Py_None)\n'
|
||||
' %(name)s = NULL;\n'
|
||||
' else if (pyst_data_from_pyobject(py_%(name)s, &%(name)s_rect))\n'
|
||||
' else if (pyst_data_from_pyobject(py_%(name)s, %(name)s_rect))\n'
|
||||
' %(name)s = &%(name)s_rect;\n'
|
||||
' else\n'
|
||||
' return NULL;\n')
|
||||
|
@ -41,10 +41,10 @@ class GstDataPtrArg(ArgType):
|
|||
info.arglist.append(pname)
|
||||
info.codebefore.append(self.null % {'name': pname})
|
||||
else:
|
||||
info.varlist.add('GstData', pname)
|
||||
info.varlist.add('GstData*', pname)
|
||||
info.varlist.add('PyObject', '*py_' + pname)
|
||||
info.add_parselist('O', ['&py_' + pname], [pname])
|
||||
info.arglist.append('&' + pname)
|
||||
info.arglist.append(pname)
|
||||
info.codebefore.append(self.normal % {'name': pname})
|
||||
|
||||
arg = GstDataPtrArg()
|
||||
|
|
64
gst/common.c
64
gst/common.c
|
@ -1,64 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
void iterate_bin_all(GstBin *bin) {
|
||||
g_return_if_fail(bin != NULL);
|
||||
g_return_if_fail(GST_IS_BIN(bin));
|
||||
|
||||
pyg_unblock_threads();
|
||||
while (gst_bin_iterate(bin));
|
||||
pyg_block_threads();
|
||||
}
|
||||
|
||||
static gboolean iterate_bin(gpointer data) {
|
||||
GstBin *bin;
|
||||
|
||||
bin = GST_BIN(data);
|
||||
return gst_bin_iterate(bin);
|
||||
}
|
||||
|
||||
static void iterate_bin_destroy(gpointer data) {
|
||||
GstBin *bin;
|
||||
|
||||
bin = GST_BIN(data);
|
||||
gst_object_unref(GST_OBJECT(bin));
|
||||
}
|
||||
|
||||
guint add_iterate_bin(GstBin *bin) {
|
||||
g_return_val_if_fail(bin != NULL, FALSE);
|
||||
g_return_val_if_fail(GST_IS_BIN(bin), FALSE);
|
||||
|
||||
gst_object_ref(GST_OBJECT(bin));
|
||||
return g_idle_add_full(
|
||||
G_PRIORITY_DEFAULT_IDLE,
|
||||
iterate_bin,
|
||||
bin,
|
||||
iterate_bin_destroy);
|
||||
}
|
||||
|
||||
void remove_iterate_bin(guint id) {
|
||||
g_source_remove(id);
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
;; -*- scheme -*-
|
||||
;;
|
||||
;; Boxed types
|
||||
;;
|
||||
|
||||
(define-boxed Buffer
|
||||
(in-module "Gst")
|
||||
(c-name "GstBuffer")
|
||||
(gtype-id "GST_TYPE_BUFFER")
|
||||
)
|
||||
|
||||
(define-boxed Caps
|
||||
(in-module "Gst")
|
||||
(c-name "GstCaps")
|
||||
(gtype-id "GST_TYPE_CAPS")
|
||||
)
|
||||
|
||||
(define-boxed Event
|
||||
(in-module "Gst")
|
||||
(c-name "GstEvent")
|
||||
(gtype-id "GST_TYPE_EVENT")
|
||||
)
|
||||
|
||||
;;
|
||||
;; Accelerate common GstBin iterate loop
|
||||
;;
|
||||
|
||||
(define-function iterate_bin_all
|
||||
(c-name "iterate_bin_all")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstBin*" "bin")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function add_iterate_bin
|
||||
(c-name "add_iterate_bin")
|
||||
(return-type "guint")
|
||||
(parameters
|
||||
'("GstBin*" "bin")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function remove_iterate_bin
|
||||
(c-name "remove_iterate_bin")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint" "id")
|
||||
)
|
||||
)
|
||||
|
||||
;;
|
||||
;; HACK
|
||||
;;
|
||||
|
||||
(define-method get_data
|
||||
(of-object "GstBuffer")
|
||||
(c-name "gst_buffer_get_data")
|
||||
(return-type "char*")
|
||||
)
|
||||
|
||||
(define-method set_data
|
||||
(of-object "GstBuffer")
|
||||
(c-name "gst_buffer_set_data")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("char*" "data")
|
||||
)
|
||||
)
|
||||
|
||||
|
34
gst/common.h
34
gst/common.h
|
@ -1,34 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <gst/gstqueue.h>
|
||||
#include <gst/gsttypefind.h>
|
||||
|
||||
typedef struct {
|
||||
PyObject *func, *data;
|
||||
} PyGstCustomNotify;
|
||||
|
||||
void iterate_bin_all(GstBin *bin);
|
||||
guint add_iterate_bin(GstBin *bin);
|
||||
void remove_iterate_bin(guint id);
|
|
@ -1,414 +0,0 @@
|
|||
/* -*- Mode: C; 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>
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
#include <Python.h>
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct {
|
||||
PyGObject *pad;
|
||||
PyObject *link_function;
|
||||
PyObject *chain_function;
|
||||
} PyGstPadPrivate;
|
||||
|
||||
static PyGstPadPrivate*
|
||||
pad_private(GstPad *pad)
|
||||
{
|
||||
return (PyGstPadPrivate*)gst_pad_get_element_private(pad);
|
||||
}
|
||||
|
||||
static PyGstPadPrivate*
|
||||
py_pad_private(PyGObject *pad)
|
||||
{
|
||||
PyGstPadPrivate *private;
|
||||
GstPad *gpad;
|
||||
|
||||
gpad = (GstPad*)pygobject_get(pad);
|
||||
private = (PyGstPadPrivate*)gst_pad_get_element_private(gpad);
|
||||
if (private == NULL) {
|
||||
/* FIXME need to free this somewhere */
|
||||
private = g_new0(PyGstPadPrivate, 1);
|
||||
Py_INCREF(pad);
|
||||
private->pad = pad;
|
||||
gst_pad_set_element_private(gpad, private);
|
||||
}
|
||||
return private;
|
||||
}
|
||||
|
||||
%%
|
||||
modulename gstreamer
|
||||
%%
|
||||
import gobject.GObject as PyGObject_Type
|
||||
%%
|
||||
ignore-glob
|
||||
_*
|
||||
gstreamer_*init
|
||||
*_get_type
|
||||
%%
|
||||
override gst_pad_set_link_function kwargs
|
||||
|
||||
static GstPadLinkReturn
|
||||
call_link_function (GstPad *pad, GstCaps *caps)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
GstPadLinkReturn ret;
|
||||
|
||||
function = pad_private(pad)->link_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = (PyObject*)PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_CAPS, caps, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
}
|
||||
|
||||
ret = PyInt_AsLong(retval);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_link_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "link_function", NULL };
|
||||
PyObject *link_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_link_funcion",
|
||||
kwlist,
|
||||
&link_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(link_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "link_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(link_function);
|
||||
py_pad_private(self)->link_function = link_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_link_function(pad, call_link_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_chain_function kwargs
|
||||
|
||||
static void
|
||||
call_chain_function(GstPad *pad, GstData *data)
|
||||
{
|
||||
PyObject *function;
|
||||
|
||||
function = pad_private(pad)->chain_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
if (GST_IS_BUFFER(data)) {
|
||||
PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_BUFFER, data, TRUE, TRUE));
|
||||
} else if (GST_IS_EVENT(data)) {
|
||||
PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_EVENT, data, TRUE, TRUE));
|
||||
}
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return;
|
||||
}
|
||||
|
||||
pyg_unblock_threads();
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_chain_function(PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "chain_function", NULL };
|
||||
PyObject *chain_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_chain_funcion",
|
||||
kwlist,
|
||||
&chain_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(chain_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "chain_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(chain_function);
|
||||
py_pad_private(self)->chain_function = chain_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_chain_function(pad, call_chain_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_buffer_get_data
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_buffer_get_data(PyObject *self)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
|
||||
buf = pyg_boxed_get(self, GstBuffer);
|
||||
|
||||
return PyString_FromStringAndSize(
|
||||
GST_BUFFER_DATA(buf),
|
||||
GST_BUFFER_SIZE(buf));
|
||||
}
|
||||
%%
|
||||
override gst_buffer_set_data kwargs
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_buffer_set_data(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = {"data", NULL};
|
||||
PyObject *data;
|
||||
GstBuffer *buf;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstBuffer:set_data", kwlist, &data)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!PyString_Check(data)) {
|
||||
PyErr_SetString(PyExc_TypeError, "data should be a string");
|
||||
return NULL;
|
||||
}
|
||||
buf = pyg_boxed_get(self, GstBuffer);
|
||||
if (GST_BUFFER_FLAGS(buf) & GST_BUFFER_READONLY) {
|
||||
PyErr_SetString(PyExc_TypeError, "set_data can't use a READONLY buffer");
|
||||
return NULL;
|
||||
}
|
||||
GST_BUFFER_SIZE(buf) = PyString_Size(data);
|
||||
GST_BUFFER_DATA(buf) = g_new0(char, GST_BUFFER_SIZE(buf));
|
||||
|
||||
memcpy(GST_BUFFER_DATA(buf),
|
||||
PyString_AsString(data),
|
||||
PyString_Size(data));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_bin_iterate
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_bin_iterate(PyGObject *self)
|
||||
{
|
||||
int ret;
|
||||
|
||||
pyg_unblock_threads();
|
||||
ret = gst_bin_iterate(GST_BIN(self->obj));
|
||||
pyg_block_threads();
|
||||
return PyInt_FromLong(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;
|
||||
GstElementState state;
|
||||
gint ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstElement.set_state", kwlist, &py_state))
|
||||
return NULL;
|
||||
if (pyg_flags_get_value(GST_TYPE_ELEMENT_STATE, py_state, (gint *)&state))
|
||||
return NULL;
|
||||
pyg_unblock_threads();
|
||||
ret = gst_element_set_state(GST_ELEMENT(self->obj), state);
|
||||
pyg_block_threads();
|
||||
return PyInt_FromLong(ret);
|
||||
}
|
||||
%%
|
||||
override gst_pad_query kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_pad_query(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "type", "format", NULL };
|
||||
GstQueryType type;
|
||||
GstFormat format;
|
||||
gint64 value;
|
||||
gboolean ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GstPad.query", kwlist, &type, &format))
|
||||
return NULL;
|
||||
value = 0;
|
||||
ret = gst_pad_query(GST_PAD(self->obj), type, &format, &value);
|
||||
return Py_BuildValue("(bL)", ret, value);
|
||||
}
|
||||
%%
|
||||
override gst_element_query kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_element_query(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "type", "format", NULL };
|
||||
GstQueryType type;
|
||||
GstFormat format;
|
||||
gint64 value;
|
||||
gboolean ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GstElement.query", kwlist, &type, &format))
|
||||
return NULL;
|
||||
value = 0;
|
||||
ret = gst_element_query(GST_ELEMENT(self->obj), type, &format, &value);
|
||||
return Py_BuildValue("(bL)", ret, value);
|
||||
}
|
||||
%%
|
||||
override gst_pad_convert kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_pad_convert(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "src_format", "src_value", "dest_format", NULL };
|
||||
GstFormat src_format, dest_format;
|
||||
PyObject *src_value_obj;
|
||||
gint64 src_value, dest_value;
|
||||
gboolean ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iOi:GstPad.convert", kwlist, &src_format, &src_value_obj, &dest_format))
|
||||
return NULL;
|
||||
src_value = PyLong_AsLongLong(src_value_obj);
|
||||
dest_value = 0;
|
||||
ret = gst_pad_convert(GST_PAD(self->obj), src_format, src_value, &dest_format, &dest_value);
|
||||
return Py_BuildValue("(bL)", ret, dest_value);
|
||||
}
|
||||
%%
|
||||
override gst_element_convert kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_element_convert(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "src_format", "src_value", "dest_format", NULL };
|
||||
GstFormat src_format, dest_format;
|
||||
PyObject *src_value_obj;
|
||||
gint64 src_value, dest_value;
|
||||
gboolean ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iOi:GstElement.convert", kwlist, &src_format, &src_value_obj, &dest_format))
|
||||
return NULL;
|
||||
src_value = PyLong_AsLongLong(src_value_obj);
|
||||
dest_value = 0;
|
||||
ret = gst_element_convert(GST_ELEMENT(self->obj), src_format, src_value, &dest_format, &dest_value);
|
||||
return Py_BuildValue("(bL)", ret, dest_value);
|
||||
}
|
||||
%%
|
||||
override gst_element_factory_make_element
|
||||
|
||||
/* we create this function to serve as a constructor for Element */
|
||||
static int
|
||||
_wrap_gst_element_factory_make_element(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "factoryname", "name", NULL };
|
||||
char *factoryname, *name = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|s:GstElement.__init__", kwlist, &factoryname, &name))
|
||||
return -1;
|
||||
self->obj = (GObject *)gst_element_factory_make(factoryname, name);
|
||||
|
||||
if (!self->obj) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "could not create GstElement object");
|
||||
return -1;
|
||||
}
|
||||
pygobject_register_wrapper((PyObject *)self);
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override gst_version noargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_version(void)
|
||||
{
|
||||
guint major, minor, micro;
|
||||
|
||||
gst_version(&major, &minor, µ);
|
||||
|
||||
return Py_BuildValue("(iii)", major, minor, micro);
|
||||
}
|
||||
%%
|
||||
override gst_bin_add_many args
|
||||
static PyObject *
|
||||
_wrap_gst_bin_add_many(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
PyGObject *element;
|
||||
int i;
|
||||
int len;
|
||||
|
||||
len = PyList_Size(args);
|
||||
if (len == 0)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "GstBin.add requires at least one argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
element = (PyGObject*)PyList_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++)
|
||||
{
|
||||
element = (PyGObject*)PyList_GetItem(args, i);
|
||||
gst_bin_add(GST_BIN(self->obj), GST_ELEMENT(element->obj));
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
|
@ -26,7 +26,7 @@ gboolean
|
|||
pygst_data_from_pyobject(PyObject *object, GstData **data)
|
||||
{
|
||||
g_return_val_if_fail(*data != NULL, FALSE);
|
||||
|
||||
|
||||
if (pyg_boxed_check(object, GST_TYPE_DATA)) {
|
||||
*data = pyg_boxed_get(object, GstData);
|
||||
return TRUE;
|
||||
|
@ -58,14 +58,11 @@ PyGstData_to_value(GValue *value, PyObject *object)
|
|||
|
||||
if (!pygst_data_from_pyobject(object, &data))
|
||||
return -1;
|
||||
|
||||
g_value_set_boxed(value, &data);
|
||||
|
||||
g_value_set_boxed(value, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We have to set ob_type here because stupid win32 does not allow you
|
||||
* to use variables from another dll in a global variable initialisation.
|
||||
*/
|
||||
void
|
||||
_pygst_register_boxed_types(PyObject *moddict)
|
||||
{
|
||||
|
|
|
@ -156,8 +156,8 @@
|
|||
(in-module "Gst")
|
||||
(c-name "GstBuffer")
|
||||
(gtype-id "GST_TYPE_BUFFER")
|
||||
(copy-func "gst_buffer_copy")
|
||||
(release-func "gst_buffer_free")
|
||||
(copy-func "gst_data_copy")
|
||||
(release-func "gst_data_unref")
|
||||
)
|
||||
|
||||
(define-boxed Caps
|
||||
|
@ -179,7 +179,7 @@
|
|||
(c-name "GstEvent")
|
||||
(gtype-id "GST_TYPE_EVENT")
|
||||
(copy-func "gst_event_copy")
|
||||
(release-func "gst_event_free")
|
||||
(release-func "gst_data_unref")
|
||||
)
|
||||
|
||||
|
||||
|
|
19
gst/gst.defs
19
gst/gst.defs
|
@ -1,6 +1,7 @@
|
|||
;; -*- scheme -*-
|
||||
|
||||
(include "gst-types.defs")
|
||||
;;(include "0.7.defs")
|
||||
|
||||
;; From /opt/gnome/include/gstreamer-0.7/gst/gstatomic.h
|
||||
|
||||
|
@ -1559,7 +1560,7 @@
|
|||
(return-type "GstElement*")
|
||||
(parameters
|
||||
'("const-gchar*" "factoryname")
|
||||
'("const-gchar*" "name")
|
||||
'("const-gchar*" "name" (null-ok) (default "NULL"))
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -5265,7 +5266,23 @@
|
|||
(return-type "GstTagList*")
|
||||
)
|
||||
|
||||
;; Added python method
|
||||
(define-method keys
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_keys")
|
||||
)
|
||||
|
||||
(define-method has_key
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_has_key")
|
||||
(parameters '("gchar*" "key"))
|
||||
)
|
||||
|
||||
(define-method get
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_get")
|
||||
(parameters '("gchar*" "key"))
|
||||
)
|
||||
|
||||
;; From /opt/gnome/include/gstreamer-0.7/gst/gsttaginterface.h
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ init_gst (void)
|
|||
char **argv;
|
||||
|
||||
init_pygobject ();
|
||||
|
||||
|
||||
/* pull in arguments */
|
||||
av = PySys_GetObject ("argv");
|
||||
if (av != NULL) {
|
||||
|
|
258
gst/gstpad-handlers.override
Normal file
258
gst/gstpad-handlers.override
Normal file
|
@ -0,0 +1,258 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* 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
|
||||
*/
|
||||
|
||||
%%
|
||||
override gst_pad_set_link_function kwargs
|
||||
|
||||
static GstPadLinkReturn
|
||||
call_link_function (GstPad *pad, GstCaps *caps)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
GstPadLinkReturn ret;
|
||||
|
||||
function = pad_private(pad)->link_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = (PyObject*)PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_CAPS, caps, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
}
|
||||
|
||||
ret = PyInt_AsLong(retval);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_link_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "link_function", NULL };
|
||||
PyObject *link_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_link_funcion",
|
||||
kwlist,
|
||||
&link_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(link_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "link_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(link_function);
|
||||
py_pad_private(self)->link_function = link_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_link_function(pad, (GstPadLinkFunction)call_link_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_chain_function kwargs
|
||||
|
||||
static void
|
||||
call_chain_function(GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
PyObject *function;
|
||||
|
||||
function = pad_private(pad)->chain_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_BUFFER, buf, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return;
|
||||
}
|
||||
|
||||
pyg_unblock_threads();
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_chain_function(PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "chain_function", NULL };
|
||||
PyObject *chain_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_chain_funcion",
|
||||
kwlist,
|
||||
&chain_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(chain_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "chain_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(chain_function);
|
||||
py_pad_private(self)->chain_function = chain_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_chain_function(pad, (GstPadChainFunction)call_chain_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_event_function kwargs
|
||||
|
||||
static gboolean
|
||||
call_event_function (GstPad *pad, GstEvent *event)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
gboolean ret;
|
||||
|
||||
function = pad_private(pad)->event_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_EVENT, event, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = PyInt_AsLong(retval);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_event_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "event_function", NULL };
|
||||
PyObject *event_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_event_funcion",
|
||||
kwlist,
|
||||
&event_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(event_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "event_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(event_function);
|
||||
py_pad_private(self)->event_function = event_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_event_function(pad, (GstPadEventFunction)call_event_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_get_function kwargs
|
||||
|
||||
static GstData*
|
||||
call_get_function (GstPad *pad)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
GstData *data = NULL;
|
||||
|
||||
function = pad_private(pad)->get_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = PyObject_CallFunction(function, "O", pad_private(pad)->pad);
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
goto bail;
|
||||
} else if (retval == Py_None) {
|
||||
goto bail;
|
||||
}
|
||||
|
||||
pygst_data_from_pyobject(retval, &data);
|
||||
|
||||
bail:
|
||||
pyg_unblock_threads();
|
||||
return data;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_get_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "get_function", NULL };
|
||||
PyObject *get_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_get_funcion",
|
||||
kwlist,
|
||||
&get_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(get_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "get_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(get_function);
|
||||
py_pad_private(self)->get_function = get_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_get_function(pad, (GstPadGetFunction)call_get_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
258
gst/gstpad.override
Normal file
258
gst/gstpad.override
Normal file
|
@ -0,0 +1,258 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* 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
|
||||
*/
|
||||
|
||||
%%
|
||||
override gst_pad_set_link_function kwargs
|
||||
|
||||
static GstPadLinkReturn
|
||||
call_link_function (GstPad *pad, GstCaps *caps)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
GstPadLinkReturn ret;
|
||||
|
||||
function = pad_private(pad)->link_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = (PyObject*)PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_CAPS, caps, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
}
|
||||
|
||||
ret = PyInt_AsLong(retval);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_link_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "link_function", NULL };
|
||||
PyObject *link_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_link_funcion",
|
||||
kwlist,
|
||||
&link_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(link_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "link_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(link_function);
|
||||
py_pad_private(self)->link_function = link_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_link_function(pad, (GstPadLinkFunction)call_link_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_chain_function kwargs
|
||||
|
||||
static void
|
||||
call_chain_function(GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
PyObject *function;
|
||||
|
||||
function = pad_private(pad)->chain_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_BUFFER, buf, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return;
|
||||
}
|
||||
|
||||
pyg_unblock_threads();
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_chain_function(PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "chain_function", NULL };
|
||||
PyObject *chain_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_chain_funcion",
|
||||
kwlist,
|
||||
&chain_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(chain_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "chain_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(chain_function);
|
||||
py_pad_private(self)->chain_function = chain_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_chain_function(pad, (GstPadChainFunction)call_chain_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_event_function kwargs
|
||||
|
||||
static gboolean
|
||||
call_event_function (GstPad *pad, GstEvent *event)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
gboolean ret;
|
||||
|
||||
function = pad_private(pad)->event_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_EVENT, event, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = PyInt_AsLong(retval);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_event_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "event_function", NULL };
|
||||
PyObject *event_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_event_funcion",
|
||||
kwlist,
|
||||
&event_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(event_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "event_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(event_function);
|
||||
py_pad_private(self)->event_function = event_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_event_function(pad, (GstPadEventFunction)call_event_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_get_function kwargs
|
||||
|
||||
static GstData*
|
||||
call_get_function (GstPad *pad)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
GstData *data = NULL;
|
||||
|
||||
function = pad_private(pad)->get_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = PyObject_CallFunction(function, "O", pad_private(pad)->pad);
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
goto bail;
|
||||
} else if (retval == Py_None) {
|
||||
goto bail;
|
||||
}
|
||||
|
||||
pygst_data_from_pyobject(retval, &data);
|
||||
|
||||
bail:
|
||||
pyg_unblock_threads();
|
||||
return data;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_get_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "get_function", NULL };
|
||||
PyObject *get_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_get_funcion",
|
||||
kwlist,
|
||||
&get_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(get_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "get_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(get_function);
|
||||
py_pad_private(self)->get_function = get_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_get_function(pad, (GstPadGetFunction)call_get_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
;; -*- scheme -*-
|
||||
|
||||
(include "gst-types.defs")
|
||||
;;(include "0.7.defs")
|
||||
|
||||
;; From /opt/gnome/include/gstreamer-0.7/gst/gstatomic.h
|
||||
|
||||
|
@ -1559,7 +1560,7 @@
|
|||
(return-type "GstElement*")
|
||||
(parameters
|
||||
'("const-gchar*" "factoryname")
|
||||
'("const-gchar*" "name")
|
||||
'("const-gchar*" "name" (null-ok) (default "NULL"))
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -5265,7 +5266,23 @@
|
|||
(return-type "GstTagList*")
|
||||
)
|
||||
|
||||
;; Added python method
|
||||
(define-method keys
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_keys")
|
||||
)
|
||||
|
||||
(define-method has_key
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_has_key")
|
||||
(parameters '("gchar*" "key"))
|
||||
)
|
||||
|
||||
(define-method get
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_get")
|
||||
(parameters '("gchar*" "key"))
|
||||
)
|
||||
|
||||
;; From /opt/gnome/include/gstreamer-0.7/gst/gsttaginterface.h
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ init_gst (void)
|
|||
char **argv;
|
||||
|
||||
init_pygobject ();
|
||||
|
||||
|
||||
/* pull in arguments */
|
||||
av = PySys_GetObject ("argv");
|
||||
if (av != NULL) {
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "0.6.h"
|
||||
|
||||
GstPropsType gst_props_entry_get_props_type(GstPropsEntry *entry)
|
||||
{
|
||||
return gst_props_entry_get_type(entry);
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
;;
|
||||
;; Override normal *_get_type handling via rename
|
||||
;;
|
||||
|
||||
(define-method get_props_type
|
||||
(of-object "GstPropsEntry")
|
||||
(c-name "gst_props_entry_get_props_type")
|
||||
(return-type "GstPropsType")
|
||||
)
|
||||
|
||||
;;
|
||||
;; Access GstProps properties list
|
||||
;;
|
||||
|
||||
(define-method get_list
|
||||
(of-object "GstProps")
|
||||
(c-name "gst_props_get_list")
|
||||
(return-type "const-GList*")
|
||||
)
|
||||
|
||||
;;
|
||||
;; 0.6 Boxed types
|
||||
;;
|
||||
|
||||
(define-boxed BufferPool
|
||||
(in-module "Gst")
|
||||
(c-name "GstBufferPool")
|
||||
(gtype-id "GST_TYPE_BUFFER_POOL")
|
||||
)
|
||||
|
||||
(define-boxed Props
|
||||
(in-module "Gst")
|
||||
(c-name "GstProps")
|
||||
(gtype-id "GST_TYPE_PROPS")
|
||||
)
|
||||
|
||||
(define-boxed PropsEntry
|
||||
(in-module "Gst")
|
||||
(c-name "GstPropsEntry")
|
||||
(gtype-id "GST_TYPE_PROPS_ENTRY")
|
||||
)
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
GstPropsType gst_props_entry_get_props_type(GstPropsEntry *entry);
|
|
@ -1,188 +0,0 @@
|
|||
/* -*- Mode: C; 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>
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
#include <Python.h>
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "0.6.h"
|
||||
%%
|
||||
override gst_props_entry_get_int
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_int(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gint val;
|
||||
|
||||
val = 0;
|
||||
ret = gst_props_entry_get_int(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
return Py_BuildValue("(bi)", ret, val);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_float
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_float(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gfloat val;
|
||||
|
||||
val = 0.0f;
|
||||
ret = gst_props_entry_get_float(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
return Py_BuildValue("(bf)", ret, val);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_fourcc_int
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_fourcc_int(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gint32 val;
|
||||
|
||||
val = 0;
|
||||
ret = gst_props_entry_get_fourcc_int(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
return Py_BuildValue("(bi)", ret, val);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_boolean
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_boolean(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gboolean val;
|
||||
PyObject *py_val;
|
||||
|
||||
val = FALSE;
|
||||
ret = gst_props_entry_get_boolean(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
|
||||
py_val = val ? Py_True : Py_False;
|
||||
return Py_BuildValue("(bO)", ret, py_val);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_string
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_string(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
const gchar *val;
|
||||
|
||||
val = NULL;
|
||||
ret = gst_props_entry_get_string(pyg_boxed_get(self, GstPropsEntry), &val);
|
||||
if (ret) {
|
||||
return Py_BuildValue("(bs)", ret, val);
|
||||
} else {
|
||||
return Py_BuildValue("(bO)", ret, Py_None);
|
||||
}
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_int_range
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_int_range(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gint min, max;
|
||||
|
||||
min = max = 0;
|
||||
ret = gst_props_entry_get_int_range(pyg_boxed_get(self, GstPropsEntry), &min, &max);
|
||||
return Py_BuildValue("(bii)", ret, min, max);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_float_range
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_float_range(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
gfloat min, max;
|
||||
|
||||
min = max = 0.0f;
|
||||
ret = gst_props_entry_get_float_range(pyg_boxed_get(self, GstPropsEntry), &min, &max);
|
||||
return Py_BuildValue("(bff)", ret, min, max);
|
||||
}
|
||||
%%
|
||||
override gst_props_entry_get_list
|
||||
|
||||
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_entry_get_list(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
const GList *list;
|
||||
PyObject *tuple, *obj;
|
||||
int i;
|
||||
|
||||
list = NULL;
|
||||
ret = gst_props_entry_get_list(pyg_boxed_get(self, GstPropsEntry), &list);
|
||||
if (ret == TRUE) {
|
||||
tuple = PyTuple_New(g_list_length((GList *) list));
|
||||
for (i = 0; list != NULL; i++, list = g_list_next(list)) {
|
||||
obj = pyg_boxed_new(GST_TYPE_PROPS_ENTRY, list->data, TRUE, TRUE);
|
||||
PyTuple_SET_ITEM(tuple, i, obj);
|
||||
}
|
||||
} else {
|
||||
tuple = Py_None;
|
||||
Py_INCREF(tuple);
|
||||
}
|
||||
return Py_BuildValue("(bO)", ret, tuple);
|
||||
}
|
||||
%%
|
||||
override gst_props_get_list
|
||||
|
||||
static gboolean
|
||||
gst_props_get_list(GstProps *props, GList **list)
|
||||
{
|
||||
*list = GST_PROPS_PROPERTIES(props);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_props_get_list(PyObject *self)
|
||||
{
|
||||
gboolean ret;
|
||||
GList *list;
|
||||
PyObject *tuple, *obj;
|
||||
int i;
|
||||
|
||||
list = NULL;
|
||||
ret = gst_props_get_list(pyg_boxed_get(self, GstProps), &list);
|
||||
if (ret == TRUE) {
|
||||
tuple = PyTuple_New(g_list_length(list));
|
||||
for (i = 0; list != NULL; i++, list = g_list_next(list)) {
|
||||
obj = pyg_boxed_new(GST_TYPE_PROPS_ENTRY, list->data, TRUE, TRUE);
|
||||
PyTuple_SET_ITEM(tuple, i, obj);
|
||||
}
|
||||
} else {
|
||||
tuple = Py_None;
|
||||
Py_INCREF(tuple);
|
||||
}
|
||||
return Py_BuildValue("(bO)", ret, tuple);
|
||||
}
|
||||
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "0.7.h"
|
|
@ -1,15 +0,0 @@
|
|||
;;
|
||||
;; 0.7 Boxed types
|
||||
;;
|
||||
|
||||
(define-boxed Structure
|
||||
(in-module "Gst")
|
||||
(c-name "GstStructure")
|
||||
(gtype-id "GST_TYPE_STRUCTURE")
|
||||
)
|
||||
|
||||
(define-boxed TagList
|
||||
(in-module "Gst")
|
||||
(c-name "GstTagList")
|
||||
(gtype-id "GST_TYPE_TAG_LIST")
|
||||
)
|
|
@ -1,20 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
|
@ -1,245 +0,0 @@
|
|||
/* -*- Mode: C; 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>
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
#include <Python.h>
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "0.7.h"
|
||||
%%
|
||||
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;
|
||||
}
|
||||
self->free_on_dealloc = TRUE;
|
||||
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", NULL };
|
||||
char *field;
|
||||
PyObject *py_value = NULL;
|
||||
GValue value = { 0 };
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO:GstStructure.set_value", kwlist, &field, &py_value))
|
||||
return NULL;
|
||||
g_value_init(&value, G_TYPE_STRING);
|
||||
if (pyg_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;
|
||||
}
|
||||
%%
|
||||
override gst_structure_foreach kwargs
|
||||
|
||||
static gboolean
|
||||
pygst_structure_foreach_marshal(GQuark field_id,
|
||||
GValue *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
PyGstCustomNotify *cunote = user_data;
|
||||
PyObject *py_field, *py_value, *retobj;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
g_assert(cunote->func);
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
//py_model = pygobject_new((GObject *)model);
|
||||
//py_path = pygtk_tree_path_to_pyobject(path);
|
||||
//py_iter = pyg_boxed_new(GTK_TYPE_TREE_ITER, iter, TRUE, TRUE);
|
||||
py_field = Py_BuildValue("s", g_quark_to_string(field_id));
|
||||
py_value = pyg_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_unblock_threads();
|
||||
|
||||
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 gst_tag_list_foreach kwargs
|
||||
|
||||
static gboolean
|
||||
pygst_tag_list_foreach_marshal(GstTagList *list,
|
||||
const gchar *tag,
|
||||
gpointer user_data)
|
||||
{
|
||||
PyGstCustomNotify *cunote = user_data;
|
||||
PyGObject *py_list;
|
||||
PyObject *py_key, *retobj;
|
||||
gboolean retval = TRUE;
|
||||
|
||||
g_assert(cunote->func);
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
py_list = pyg_boxed_new(GST_TYPE_TAG_LIST, list, TRUE, TRUE);
|
||||
py_key = Py_BuildValue("s", tag);
|
||||
if (cunote->data)
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NNO)",
|
||||
py_list,
|
||||
py_key,
|
||||
cunote->data);
|
||||
else
|
||||
retobj = PyEval_CallFunction(cunote->func, "(NN)",
|
||||
py_list,
|
||||
py_key);
|
||||
|
||||
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_unblock_threads();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_tag_list_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:GstTagList.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_tag_list_foreach(pyg_boxed_get(self, GstTagList),
|
||||
pygst_tag_list_foreach_marshal,
|
||||
&cunote);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_tag_list_get_value_index kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_tag_list_get_value_index (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "tag", "index", NULL };
|
||||
char *tag;
|
||||
int index;
|
||||
GValue *gvalue;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"si:GstTagList.get_value_index",
|
||||
kwlist,
|
||||
&tag, &index)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gvalue = gst_tag_list_get_value_index(pyg_boxed_get(self, GstTagList),
|
||||
tag,
|
||||
index);
|
||||
|
||||
return pyg_value_as_pyobject(gvalue, FALSE);
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
MODULE = gstreamer
|
||||
|
||||
INCLUDES = $(PYTHON_INCLUDES) $(PYGTK_CFLAGS)
|
||||
PYGTK_DEFSDIR = @PYGTK_DEFSDIR@
|
||||
|
||||
|
@ -15,50 +13,31 @@ pygstreamer_PYTHON = gstreamer.py
|
|||
|
||||
pygstexecdir = $(pkgpyexecdir)
|
||||
|
||||
GST_OVERRIDES = common.override \
|
||||
0.6.override \
|
||||
0.7.override
|
||||
GST_DEFS = common.defs \
|
||||
0.6.defs \
|
||||
0.7.defs
|
||||
GST_CODE = common.c common.h \
|
||||
0.6.c 0.6.h \
|
||||
0.7.c 0.7.h
|
||||
|
||||
# Ugly hack to pick the proper version code.
|
||||
# Just setting to $(GST_MAJORMINOR).{ch} will not work
|
||||
if GST_0_6
|
||||
VERSOURCES = 0.6.c 0.6.h
|
||||
endif
|
||||
if GST_0_7
|
||||
VERSOURCES = 0.7.c 0.7.h
|
||||
endif
|
||||
GST_OVERRIDES = \
|
||||
gstreamer.override \
|
||||
gstpad-handlers.override
|
||||
|
||||
pygstexec_LTLIBRARIES = _gstmodule.la
|
||||
_gstmodule_la_SOURCES = \
|
||||
gstreamermodule.c \
|
||||
gst-types.c \
|
||||
common.c \
|
||||
common.h \
|
||||
gstreamermodule.c \
|
||||
gst-types.c \
|
||||
$(VERSOURCES)
|
||||
|
||||
_gstmodule_la_CFLAGS = $(GST_CFLAGS) -fno-strict-aliasing
|
||||
_gstmodule_la_LIBADD = $(GST_LIBS)
|
||||
_gstmodule_la_LDFLAGS = -module -avoid-version -export-symbols-regex init_gst
|
||||
nodist__gstmodule_la_SOURCES = $(MODULE).c
|
||||
nodist__gstmodule_la_SOURCES = gstreamer.c
|
||||
|
||||
CLEANFILES = $(MODULE).c
|
||||
EXTRA_DIST = $(MODULE).defs $(GST_OVERRIDES) $(GST_DEFS) $(GST_CODE) arg-types.py
|
||||
CLEANFILES = gstreamer.c
|
||||
EXTRA_DIST = gstreamer.defs $(GST_OVERRIDES) arg-types.py
|
||||
|
||||
GST_EXCLUDE_INCLUDES=\
|
||||
$(GST_INCLUDEDIR)/gst/gstatomic_impl.h \
|
||||
$(GST_INCLUDEDIR)/gst/gstcompat.h
|
||||
GST_INCLUDES=$(filter-out $(GST_EXCLUDE_INCLUDES),$(wildcard $(GST_INCLUDEDIR)/gst/*.h))
|
||||
|
||||
gstreamer.c: $(srcdir)/$(MODULE).defs $(srcdir)/arg-types.py $(srcdir)/$(MODULE).override
|
||||
gstreamer.c: $(srcdir)/gstreamer.defs $(srcdir)/arg-types.py $(GST_OVERRIDES)
|
||||
$(PYGTK_CODEGEN) \
|
||||
--load-types $(srcdir)/arg-types.py \
|
||||
--register $(srcdir)/gst-types.defs \
|
||||
--override $(srcdir)/$(MODULE).override \
|
||||
--prefix pygst $(MODULE).defs > gen-$(MODULE).c \
|
||||
&& cp gen-$(MODULE).c $(MODULE).c \
|
||||
&& rm -f gen-$(MODULE).c
|
||||
--override $(srcdir)/gstreamer.override \
|
||||
--prefix pygst gstreamer.defs > gen-gstreamer.c \
|
||||
&& rm -fr gtreamer.c \
|
||||
&& echo '/* GENERATED FILE - DO NOT EDIT */' >> gstreamer.c \
|
||||
&& cat gen-gstreamer.c >> gstreamer.c \
|
||||
&& rm -f gen-gstreamer.c
|
||||
|
|
|
@ -28,7 +28,7 @@ class GstDataPtrArg(ArgType):
|
|||
' return NULL;\n')
|
||||
null = (' if (py_%(name)s == Py_None)\n'
|
||||
' %(name)s = NULL;\n'
|
||||
' else if (pyst_data_from_pyobject(py_%(name)s, &%(name)s_rect))\n'
|
||||
' else if (pyst_data_from_pyobject(py_%(name)s, %(name)s_rect))\n'
|
||||
' %(name)s = &%(name)s_rect;\n'
|
||||
' else\n'
|
||||
' return NULL;\n')
|
||||
|
@ -41,10 +41,10 @@ class GstDataPtrArg(ArgType):
|
|||
info.arglist.append(pname)
|
||||
info.codebefore.append(self.null % {'name': pname})
|
||||
else:
|
||||
info.varlist.add('GstData', pname)
|
||||
info.varlist.add('GstData*', pname)
|
||||
info.varlist.add('PyObject', '*py_' + pname)
|
||||
info.add_parselist('O', ['&py_' + pname], [pname])
|
||||
info.arglist.append('&' + pname)
|
||||
info.arglist.append(pname)
|
||||
info.codebefore.append(self.normal % {'name': pname})
|
||||
|
||||
arg = GstDataPtrArg()
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
void iterate_bin_all(GstBin *bin) {
|
||||
g_return_if_fail(bin != NULL);
|
||||
g_return_if_fail(GST_IS_BIN(bin));
|
||||
|
||||
pyg_unblock_threads();
|
||||
while (gst_bin_iterate(bin));
|
||||
pyg_block_threads();
|
||||
}
|
||||
|
||||
static gboolean iterate_bin(gpointer data) {
|
||||
GstBin *bin;
|
||||
|
||||
bin = GST_BIN(data);
|
||||
return gst_bin_iterate(bin);
|
||||
}
|
||||
|
||||
static void iterate_bin_destroy(gpointer data) {
|
||||
GstBin *bin;
|
||||
|
||||
bin = GST_BIN(data);
|
||||
gst_object_unref(GST_OBJECT(bin));
|
||||
}
|
||||
|
||||
guint add_iterate_bin(GstBin *bin) {
|
||||
g_return_val_if_fail(bin != NULL, FALSE);
|
||||
g_return_val_if_fail(GST_IS_BIN(bin), FALSE);
|
||||
|
||||
gst_object_ref(GST_OBJECT(bin));
|
||||
return g_idle_add_full(
|
||||
G_PRIORITY_DEFAULT_IDLE,
|
||||
iterate_bin,
|
||||
bin,
|
||||
iterate_bin_destroy);
|
||||
}
|
||||
|
||||
void remove_iterate_bin(guint id) {
|
||||
g_source_remove(id);
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
;; -*- scheme -*-
|
||||
;;
|
||||
;; Boxed types
|
||||
;;
|
||||
|
||||
(define-boxed Buffer
|
||||
(in-module "Gst")
|
||||
(c-name "GstBuffer")
|
||||
(gtype-id "GST_TYPE_BUFFER")
|
||||
)
|
||||
|
||||
(define-boxed Caps
|
||||
(in-module "Gst")
|
||||
(c-name "GstCaps")
|
||||
(gtype-id "GST_TYPE_CAPS")
|
||||
)
|
||||
|
||||
(define-boxed Event
|
||||
(in-module "Gst")
|
||||
(c-name "GstEvent")
|
||||
(gtype-id "GST_TYPE_EVENT")
|
||||
)
|
||||
|
||||
;;
|
||||
;; Accelerate common GstBin iterate loop
|
||||
;;
|
||||
|
||||
(define-function iterate_bin_all
|
||||
(c-name "iterate_bin_all")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("GstBin*" "bin")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function add_iterate_bin
|
||||
(c-name "add_iterate_bin")
|
||||
(return-type "guint")
|
||||
(parameters
|
||||
'("GstBin*" "bin")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function remove_iterate_bin
|
||||
(c-name "remove_iterate_bin")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("guint" "id")
|
||||
)
|
||||
)
|
||||
|
||||
;;
|
||||
;; HACK
|
||||
;;
|
||||
|
||||
(define-method get_data
|
||||
(of-object "GstBuffer")
|
||||
(c-name "gst_buffer_get_data")
|
||||
(return-type "char*")
|
||||
)
|
||||
|
||||
(define-method set_data
|
||||
(of-object "GstBuffer")
|
||||
(c-name "gst_buffer_set_data")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("char*" "data")
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/* 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>
|
||||
*/
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include <gst/gstqueue.h>
|
||||
#include <gst/gsttypefind.h>
|
||||
|
||||
typedef struct {
|
||||
PyObject *func, *data;
|
||||
} PyGstCustomNotify;
|
||||
|
||||
void iterate_bin_all(GstBin *bin);
|
||||
guint add_iterate_bin(GstBin *bin);
|
||||
void remove_iterate_bin(guint id);
|
|
@ -1,414 +0,0 @@
|
|||
/* -*- Mode: C; 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>
|
||||
*/
|
||||
%%
|
||||
headers
|
||||
#include <Python.h>
|
||||
|
||||
#include "pygobject.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
typedef struct {
|
||||
PyGObject *pad;
|
||||
PyObject *link_function;
|
||||
PyObject *chain_function;
|
||||
} PyGstPadPrivate;
|
||||
|
||||
static PyGstPadPrivate*
|
||||
pad_private(GstPad *pad)
|
||||
{
|
||||
return (PyGstPadPrivate*)gst_pad_get_element_private(pad);
|
||||
}
|
||||
|
||||
static PyGstPadPrivate*
|
||||
py_pad_private(PyGObject *pad)
|
||||
{
|
||||
PyGstPadPrivate *private;
|
||||
GstPad *gpad;
|
||||
|
||||
gpad = (GstPad*)pygobject_get(pad);
|
||||
private = (PyGstPadPrivate*)gst_pad_get_element_private(gpad);
|
||||
if (private == NULL) {
|
||||
/* FIXME need to free this somewhere */
|
||||
private = g_new0(PyGstPadPrivate, 1);
|
||||
Py_INCREF(pad);
|
||||
private->pad = pad;
|
||||
gst_pad_set_element_private(gpad, private);
|
||||
}
|
||||
return private;
|
||||
}
|
||||
|
||||
%%
|
||||
modulename gstreamer
|
||||
%%
|
||||
import gobject.GObject as PyGObject_Type
|
||||
%%
|
||||
ignore-glob
|
||||
_*
|
||||
gstreamer_*init
|
||||
*_get_type
|
||||
%%
|
||||
override gst_pad_set_link_function kwargs
|
||||
|
||||
static GstPadLinkReturn
|
||||
call_link_function (GstPad *pad, GstCaps *caps)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
GstPadLinkReturn ret;
|
||||
|
||||
function = pad_private(pad)->link_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = (PyObject*)PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_CAPS, caps, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
}
|
||||
|
||||
ret = PyInt_AsLong(retval);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_link_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "link_function", NULL };
|
||||
PyObject *link_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_link_funcion",
|
||||
kwlist,
|
||||
&link_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(link_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "link_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(link_function);
|
||||
py_pad_private(self)->link_function = link_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_link_function(pad, call_link_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_chain_function kwargs
|
||||
|
||||
static void
|
||||
call_chain_function(GstPad *pad, GstData *data)
|
||||
{
|
||||
PyObject *function;
|
||||
|
||||
function = pad_private(pad)->chain_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
if (GST_IS_BUFFER(data)) {
|
||||
PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_BUFFER, data, TRUE, TRUE));
|
||||
} else if (GST_IS_EVENT(data)) {
|
||||
PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_EVENT, data, TRUE, TRUE));
|
||||
}
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return;
|
||||
}
|
||||
|
||||
pyg_unblock_threads();
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_chain_function(PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "chain_function", NULL };
|
||||
PyObject *chain_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_chain_funcion",
|
||||
kwlist,
|
||||
&chain_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(chain_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "chain_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(chain_function);
|
||||
py_pad_private(self)->chain_function = chain_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_chain_function(pad, call_chain_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_buffer_get_data
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_buffer_get_data(PyObject *self)
|
||||
{
|
||||
GstBuffer *buf;
|
||||
|
||||
buf = pyg_boxed_get(self, GstBuffer);
|
||||
|
||||
return PyString_FromStringAndSize(
|
||||
GST_BUFFER_DATA(buf),
|
||||
GST_BUFFER_SIZE(buf));
|
||||
}
|
||||
%%
|
||||
override gst_buffer_set_data kwargs
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_buffer_set_data(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = {"data", NULL};
|
||||
PyObject *data;
|
||||
GstBuffer *buf;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstBuffer:set_data", kwlist, &data)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!PyString_Check(data)) {
|
||||
PyErr_SetString(PyExc_TypeError, "data should be a string");
|
||||
return NULL;
|
||||
}
|
||||
buf = pyg_boxed_get(self, GstBuffer);
|
||||
if (GST_BUFFER_FLAGS(buf) & GST_BUFFER_READONLY) {
|
||||
PyErr_SetString(PyExc_TypeError, "set_data can't use a READONLY buffer");
|
||||
return NULL;
|
||||
}
|
||||
GST_BUFFER_SIZE(buf) = PyString_Size(data);
|
||||
GST_BUFFER_DATA(buf) = g_new0(char, GST_BUFFER_SIZE(buf));
|
||||
|
||||
memcpy(GST_BUFFER_DATA(buf),
|
||||
PyString_AsString(data),
|
||||
PyString_Size(data));
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_bin_iterate
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_bin_iterate(PyGObject *self)
|
||||
{
|
||||
int ret;
|
||||
|
||||
pyg_unblock_threads();
|
||||
ret = gst_bin_iterate(GST_BIN(self->obj));
|
||||
pyg_block_threads();
|
||||
return PyInt_FromLong(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;
|
||||
GstElementState state;
|
||||
gint ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstElement.set_state", kwlist, &py_state))
|
||||
return NULL;
|
||||
if (pyg_flags_get_value(GST_TYPE_ELEMENT_STATE, py_state, (gint *)&state))
|
||||
return NULL;
|
||||
pyg_unblock_threads();
|
||||
ret = gst_element_set_state(GST_ELEMENT(self->obj), state);
|
||||
pyg_block_threads();
|
||||
return PyInt_FromLong(ret);
|
||||
}
|
||||
%%
|
||||
override gst_pad_query kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_pad_query(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "type", "format", NULL };
|
||||
GstQueryType type;
|
||||
GstFormat format;
|
||||
gint64 value;
|
||||
gboolean ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GstPad.query", kwlist, &type, &format))
|
||||
return NULL;
|
||||
value = 0;
|
||||
ret = gst_pad_query(GST_PAD(self->obj), type, &format, &value);
|
||||
return Py_BuildValue("(bL)", ret, value);
|
||||
}
|
||||
%%
|
||||
override gst_element_query kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_element_query(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "type", "format", NULL };
|
||||
GstQueryType type;
|
||||
GstFormat format;
|
||||
gint64 value;
|
||||
gboolean ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:GstElement.query", kwlist, &type, &format))
|
||||
return NULL;
|
||||
value = 0;
|
||||
ret = gst_element_query(GST_ELEMENT(self->obj), type, &format, &value);
|
||||
return Py_BuildValue("(bL)", ret, value);
|
||||
}
|
||||
%%
|
||||
override gst_pad_convert kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_pad_convert(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "src_format", "src_value", "dest_format", NULL };
|
||||
GstFormat src_format, dest_format;
|
||||
PyObject *src_value_obj;
|
||||
gint64 src_value, dest_value;
|
||||
gboolean ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iOi:GstPad.convert", kwlist, &src_format, &src_value_obj, &dest_format))
|
||||
return NULL;
|
||||
src_value = PyLong_AsLongLong(src_value_obj);
|
||||
dest_value = 0;
|
||||
ret = gst_pad_convert(GST_PAD(self->obj), src_format, src_value, &dest_format, &dest_value);
|
||||
return Py_BuildValue("(bL)", ret, dest_value);
|
||||
}
|
||||
%%
|
||||
override gst_element_convert kwargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_element_convert(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "src_format", "src_value", "dest_format", NULL };
|
||||
GstFormat src_format, dest_format;
|
||||
PyObject *src_value_obj;
|
||||
gint64 src_value, dest_value;
|
||||
gboolean ret;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iOi:GstElement.convert", kwlist, &src_format, &src_value_obj, &dest_format))
|
||||
return NULL;
|
||||
src_value = PyLong_AsLongLong(src_value_obj);
|
||||
dest_value = 0;
|
||||
ret = gst_element_convert(GST_ELEMENT(self->obj), src_format, src_value, &dest_format, &dest_value);
|
||||
return Py_BuildValue("(bL)", ret, dest_value);
|
||||
}
|
||||
%%
|
||||
override gst_element_factory_make_element
|
||||
|
||||
/* we create this function to serve as a constructor for Element */
|
||||
static int
|
||||
_wrap_gst_element_factory_make_element(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "factoryname", "name", NULL };
|
||||
char *factoryname, *name = NULL;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|s:GstElement.__init__", kwlist, &factoryname, &name))
|
||||
return -1;
|
||||
self->obj = (GObject *)gst_element_factory_make(factoryname, name);
|
||||
|
||||
if (!self->obj) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "could not create GstElement object");
|
||||
return -1;
|
||||
}
|
||||
pygobject_register_wrapper((PyObject *)self);
|
||||
return 0;
|
||||
}
|
||||
%%
|
||||
override gst_version noargs
|
||||
|
||||
static PyObject *
|
||||
_wrap_gst_version(void)
|
||||
{
|
||||
guint major, minor, micro;
|
||||
|
||||
gst_version(&major, &minor, µ);
|
||||
|
||||
return Py_BuildValue("(iii)", major, minor, micro);
|
||||
}
|
||||
%%
|
||||
override gst_bin_add_many args
|
||||
static PyObject *
|
||||
_wrap_gst_bin_add_many(PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
PyGObject *element;
|
||||
int i;
|
||||
int len;
|
||||
|
||||
len = PyList_Size(args);
|
||||
if (len == 0)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "GstBin.add requires at least one argument");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
element = (PyGObject*)PyList_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++)
|
||||
{
|
||||
element = (PyGObject*)PyList_GetItem(args, i);
|
||||
gst_bin_add(GST_BIN(self->obj), GST_ELEMENT(element->obj));
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
|
@ -26,7 +26,7 @@ gboolean
|
|||
pygst_data_from_pyobject(PyObject *object, GstData **data)
|
||||
{
|
||||
g_return_val_if_fail(*data != NULL, FALSE);
|
||||
|
||||
|
||||
if (pyg_boxed_check(object, GST_TYPE_DATA)) {
|
||||
*data = pyg_boxed_get(object, GstData);
|
||||
return TRUE;
|
||||
|
@ -58,14 +58,11 @@ PyGstData_to_value(GValue *value, PyObject *object)
|
|||
|
||||
if (!pygst_data_from_pyobject(object, &data))
|
||||
return -1;
|
||||
|
||||
g_value_set_boxed(value, &data);
|
||||
|
||||
g_value_set_boxed(value, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* We have to set ob_type here because stupid win32 does not allow you
|
||||
* to use variables from another dll in a global variable initialisation.
|
||||
*/
|
||||
void
|
||||
_pygst_register_boxed_types(PyObject *moddict)
|
||||
{
|
||||
|
|
|
@ -156,8 +156,8 @@
|
|||
(in-module "Gst")
|
||||
(c-name "GstBuffer")
|
||||
(gtype-id "GST_TYPE_BUFFER")
|
||||
(copy-func "gst_buffer_copy")
|
||||
(release-func "gst_buffer_free")
|
||||
(copy-func "gst_data_copy")
|
||||
(release-func "gst_data_unref")
|
||||
)
|
||||
|
||||
(define-boxed Caps
|
||||
|
@ -179,7 +179,7 @@
|
|||
(c-name "GstEvent")
|
||||
(gtype-id "GST_TYPE_EVENT")
|
||||
(copy-func "gst_event_copy")
|
||||
(release-func "gst_event_free")
|
||||
(release-func "gst_data_unref")
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
;; -*- scheme -*-
|
||||
|
||||
(include "gst-types.defs")
|
||||
;;(include "0.7.defs")
|
||||
|
||||
;; From /opt/gnome/include/gstreamer-0.7/gst/gstatomic.h
|
||||
|
||||
|
@ -1559,7 +1560,7 @@
|
|||
(return-type "GstElement*")
|
||||
(parameters
|
||||
'("const-gchar*" "factoryname")
|
||||
'("const-gchar*" "name")
|
||||
'("const-gchar*" "name" (null-ok) (default "NULL"))
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -5265,7 +5266,23 @@
|
|||
(return-type "GstTagList*")
|
||||
)
|
||||
|
||||
;; Added python method
|
||||
(define-method keys
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_keys")
|
||||
)
|
||||
|
||||
(define-method has_key
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_has_key")
|
||||
(parameters '("gchar*" "key"))
|
||||
)
|
||||
|
||||
(define-method get
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_get")
|
||||
(parameters '("gchar*" "key"))
|
||||
)
|
||||
|
||||
;; From /opt/gnome/include/gstreamer-0.7/gst/gsttaginterface.h
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ init_gst (void)
|
|||
char **argv;
|
||||
|
||||
init_pygobject ();
|
||||
|
||||
|
||||
/* pull in arguments */
|
||||
av = PySys_GetObject ("argv");
|
||||
if (av != NULL) {
|
||||
|
|
258
gstreamer/gstpad-handlers.override
Normal file
258
gstreamer/gstpad-handlers.override
Normal file
|
@ -0,0 +1,258 @@
|
|||
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
||||
/* 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
|
||||
*/
|
||||
|
||||
%%
|
||||
override gst_pad_set_link_function kwargs
|
||||
|
||||
static GstPadLinkReturn
|
||||
call_link_function (GstPad *pad, GstCaps *caps)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
GstPadLinkReturn ret;
|
||||
|
||||
function = pad_private(pad)->link_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = (PyObject*)PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_CAPS, caps, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
}
|
||||
|
||||
ret = PyInt_AsLong(retval);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_link_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "link_function", NULL };
|
||||
PyObject *link_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_link_funcion",
|
||||
kwlist,
|
||||
&link_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(link_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "link_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(link_function);
|
||||
py_pad_private(self)->link_function = link_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_link_function(pad, (GstPadLinkFunction)call_link_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_chain_function kwargs
|
||||
|
||||
static void
|
||||
call_chain_function(GstPad *pad, GstBuffer *buf)
|
||||
{
|
||||
PyObject *function;
|
||||
|
||||
function = pad_private(pad)->chain_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_BUFFER, buf, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return;
|
||||
}
|
||||
|
||||
pyg_unblock_threads();
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_chain_function(PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "chain_function", NULL };
|
||||
PyObject *chain_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_chain_funcion",
|
||||
kwlist,
|
||||
&chain_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(chain_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "chain_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(chain_function);
|
||||
py_pad_private(self)->chain_function = chain_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_chain_function(pad, (GstPadChainFunction)call_chain_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_event_function kwargs
|
||||
|
||||
static gboolean
|
||||
call_event_function (GstPad *pad, GstEvent *event)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
gboolean ret;
|
||||
|
||||
function = pad_private(pad)->event_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = PyObject_CallFunction (function,
|
||||
"OO",
|
||||
pad_private(pad)->pad,
|
||||
pyg_boxed_new(GST_TYPE_EVENT, event, TRUE, TRUE));
|
||||
|
||||
if (PyErr_Occurred ()) {
|
||||
PyErr_Print ();
|
||||
pyg_unblock_threads();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ret = PyInt_AsLong(retval);
|
||||
|
||||
pyg_unblock_threads();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_event_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "event_function", NULL };
|
||||
PyObject *event_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_event_funcion",
|
||||
kwlist,
|
||||
&event_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(event_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "event_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(event_function);
|
||||
py_pad_private(self)->event_function = event_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_event_function(pad, (GstPadEventFunction)call_event_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
%%
|
||||
override gst_pad_set_get_function kwargs
|
||||
|
||||
static GstData*
|
||||
call_get_function (GstPad *pad)
|
||||
{
|
||||
PyObject *function;
|
||||
PyObject *retval;
|
||||
GstData *data = NULL;
|
||||
|
||||
function = pad_private(pad)->get_function;
|
||||
|
||||
pyg_block_threads();
|
||||
|
||||
retval = PyObject_CallFunction(function, "O", pad_private(pad)->pad);
|
||||
|
||||
if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
goto bail;
|
||||
} else if (retval == Py_None) {
|
||||
goto bail;
|
||||
}
|
||||
|
||||
pygst_data_from_pyobject(retval, &data);
|
||||
|
||||
bail:
|
||||
pyg_unblock_threads();
|
||||
return data;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
_wrap_gst_pad_set_get_function (PyGObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwargs)
|
||||
{
|
||||
static char *kwlist[] = { "get_function", NULL };
|
||||
PyObject *get_function;
|
||||
GstPad *pad;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
||||
"O:GstPad.set_get_funcion",
|
||||
kwlist,
|
||||
&get_function)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyCallable_Check(get_function)) {
|
||||
PyErr_SetString(PyExc_TypeError, "get_function not callable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_INCREF(get_function);
|
||||
py_pad_private(self)->get_function = get_function;
|
||||
pad = (GstPad*)pygobject_get(self);
|
||||
gst_pad_set_get_function(pad, (GstPadGetFunction)call_get_function);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
;; -*- scheme -*-
|
||||
|
||||
(include "gst-types.defs")
|
||||
;;(include "0.7.defs")
|
||||
|
||||
;; From /opt/gnome/include/gstreamer-0.7/gst/gstatomic.h
|
||||
|
||||
|
@ -1559,7 +1560,7 @@
|
|||
(return-type "GstElement*")
|
||||
(parameters
|
||||
'("const-gchar*" "factoryname")
|
||||
'("const-gchar*" "name")
|
||||
'("const-gchar*" "name" (null-ok) (default "NULL"))
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -5265,7 +5266,23 @@
|
|||
(return-type "GstTagList*")
|
||||
)
|
||||
|
||||
;; Added python method
|
||||
(define-method keys
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_keys")
|
||||
)
|
||||
|
||||
(define-method has_key
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_has_key")
|
||||
(parameters '("gchar*" "key"))
|
||||
)
|
||||
|
||||
(define-method get
|
||||
(of-object "GstTagList")
|
||||
(c-name "pygst_tag_list_get")
|
||||
(parameters '("gchar*" "key"))
|
||||
)
|
||||
|
||||
;; From /opt/gnome/include/gstreamer-0.7/gst/gsttaginterface.h
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ init_gst (void)
|
|||
char **argv;
|
||||
|
||||
init_pygobject ();
|
||||
|
||||
|
||||
/* pull in arguments */
|
||||
av = PySys_GetObject ("argv");
|
||||
if (av != NULL) {
|
||||
|
|
Loading…
Reference in a new issue