mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-14 13:21:28 +00:00
ae75cbd54b
Original commit message from CVS: * gst/gst-types.defs: * gst/gst.defs: Added GError wrapping, Removed data field from Buffer, Added virtual methods to object Updated to latest API * gst/gst.override: wrapped gst_plugin_get_feature_list(), gst_uri_handler_get_protocols(), gst_registry_pool_list() * gst/gstbuffer.override: gst.Buffer() works get/setters fixed wrapped gst_buffer_stamp() * gst/gstbus.override: wrapped gst_bus_set_sync_handler() and gst_bus_add_watch() * gst/gstelement.override: wrapped gst_element_send_event(), gst_element_factory_get_pad_templates() gst_element_query_convert(), gst_element_get_query_types() * gst/gstevent.override: wrapped gst_event_discont_get_value() * gst/gstmessage.override: wrapped gst_message_parse_state_changed(), gst_message_parse_error(), gst_message_parse_warning(), gst_message_parse_tag() * gst/gstmodule.c: Added registration of new fundamental type with pygtk * gst/gstpad.override: wrapped gst_pad_query(), gst_pad_[add|remove]_[data|event|buffer]_probe(), gst_pad_query_position(), gst_pad_query_convert() * gst/gstquery.override: wrapped gst_query_parse_position(), gst_query_parse_convert(), gst_query_parse_seeking_query(), gst_query_parse_seeking_reponse() * gst/pygstminiobject.c: fixes * gst/Makefile.am: added gstbus.override, gstmessage.override, gstquery.override * testsuite/test_buffer.py: * testsuite/test_element.py: * testsuite/test_event.py: * testsuite/test_pipeline.py: Updating testsuites
175 lines
4.4 KiB
C
175 lines
4.4 KiB
C
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
|
/* gst-python
|
|
* Copyright (C) 2005 Edward Hervey
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*
|
|
* Author: Edward Hervey <edward@fluendo.com>
|
|
*/
|
|
%%
|
|
headers
|
|
static GstBusSyncReply
|
|
bus_sync_handler (GstBus *bus, GstMessage *message, gpointer user_data)
|
|
{
|
|
PyGILState_STATE state;
|
|
GstBusSyncReply res;
|
|
PyObject *py_userdata;
|
|
PyObject *py_msg;
|
|
PyObject *callback, *args;
|
|
PyObject *ret;
|
|
gint i,len;
|
|
|
|
g_return_val_if_fail (user_data != NULL, GST_BUS_PASS);
|
|
|
|
state = pyg_gil_state_ensure();
|
|
|
|
py_userdata = (PyObject *) user_data;
|
|
py_msg = pygstminiobject_new(GST_MINI_OBJECT(message));
|
|
callback = PyTuple_GetItem(py_userdata, 0);
|
|
args = Py_BuildValue("(NN)",
|
|
pygobject_new(G_OBJECT(bus)),
|
|
py_msg);
|
|
|
|
len = PyTuple_Size(py_userdata);
|
|
for (i = 1; i < len; ++i) {
|
|
PyObject *tuple = args;
|
|
args = PySequence_Concat(tuple, PyTuple_GetItem(py_userdata, i));
|
|
Py_DECREF(tuple);
|
|
}
|
|
ret = PyObject_CallObject(callback, args);
|
|
|
|
if (!ret) {
|
|
PyErr_Print();
|
|
res = GST_BUS_PASS;
|
|
} else {
|
|
if (pyg_enum_get_value(GST_TYPE_BUS_SYNC_REPLY, ret, (gint *) &res))
|
|
res = GST_BUS_PASS;
|
|
Py_DECREF (ret);
|
|
}
|
|
|
|
Py_DECREF(args);
|
|
|
|
pyg_gil_state_release(state);
|
|
|
|
return res;
|
|
}
|
|
|
|
static gboolean
|
|
bus_handler (GstBus *bus, GstMessage *message, gpointer user_data)
|
|
{
|
|
PyGILState_STATE state;
|
|
gboolean res;
|
|
PyObject *py_userdata;
|
|
PyObject *py_msg;
|
|
PyObject *callback, *args;
|
|
PyObject *ret;
|
|
gint i,len;
|
|
|
|
g_return_val_if_fail (user_data != NULL, TRUE);
|
|
|
|
state = pyg_gil_state_ensure();
|
|
|
|
py_userdata = (PyObject *) user_data;
|
|
py_msg = pygstminiobject_new(GST_MINI_OBJECT(message));
|
|
callback = PyTuple_GetItem(py_userdata, 0);
|
|
args = Py_BuildValue("(NN)",
|
|
pygobject_new(G_OBJECT(bus)),
|
|
py_msg);
|
|
|
|
len = PyTuple_Size(py_userdata);
|
|
for (i = 1; i < len; ++i) {
|
|
PyObject *tuple = args;
|
|
args = PySequence_Concat(tuple, PyTuple_GetItem(py_userdata, i));
|
|
Py_DECREF(tuple);
|
|
}
|
|
ret = PyObject_CallObject(callback, args);
|
|
|
|
if (!ret) {
|
|
PyErr_Print();
|
|
res = TRUE;
|
|
} else {
|
|
res = PyObject_IsTrue(ret);
|
|
Py_DECREF(ret);
|
|
}
|
|
Py_DECREF(args);
|
|
|
|
pyg_gil_state_release(state);
|
|
|
|
return res;
|
|
}
|
|
|
|
%%
|
|
override gst_bus_set_sync_handler args
|
|
static PyObject *
|
|
_wrap_gst_bus_set_sync_handler (PyGObject *self, PyObject *args)
|
|
{
|
|
PyObject *callback, *cbargs = NULL, *data;
|
|
gint len;
|
|
|
|
len = PyTuple_Size(args);
|
|
|
|
if (len < 1) {
|
|
PyErr_SetString(PyExc_TypeError, "Bus requires at least 1 arg");
|
|
return NULL;
|
|
}
|
|
callback = PySequence_GetItem(args, 0);
|
|
if (!PyCallable_Check(callback)) {
|
|
PyErr_SetString(PyExc_TypeError, "callback is not callable");
|
|
return NULL;
|
|
}
|
|
cbargs = PySequence_GetSlice(args, 1, len);
|
|
if (cbargs == NULL)
|
|
return NULL;
|
|
data = Py_BuildValue("(ON)", callback, cbargs);
|
|
if (data == NULL)
|
|
return NULL;
|
|
gst_bus_set_sync_handler (GST_BUS (self->obj),
|
|
(GstBusSyncHandler) bus_sync_handler,
|
|
data);
|
|
|
|
return (PyObject*) self;
|
|
|
|
}
|
|
%%
|
|
override gst_bus_add_watch args
|
|
static PyObject *
|
|
_wrap_gst_bus_add_watch (PyGObject *self, PyObject *args)
|
|
{
|
|
PyObject *callback, *cbargs = NULL, *data;
|
|
guint sigid;
|
|
guint len;
|
|
|
|
len = PyTuple_Size(args);
|
|
|
|
if (len < 1) {
|
|
PyErr_SetString(PyExc_TypeError, "Bus requires at least 1 arg");
|
|
return NULL;
|
|
}
|
|
callback = PySequence_GetItem(args, 0);
|
|
if (!PyCallable_Check(callback)) {
|
|
PyErr_SetString(PyExc_TypeError, "callback is not callable");
|
|
return NULL;
|
|
}
|
|
cbargs = PySequence_GetSlice(args, 1, len);
|
|
if (cbargs == NULL)
|
|
return NULL;
|
|
data = Py_BuildValue("(ON)", callback, cbargs);
|
|
if (data == NULL)
|
|
return NULL;
|
|
sigid = gst_bus_add_watch (GST_BUS (self->obj), (GstBusHandler) bus_handler, data);
|
|
|
|
return PyInt_FromLong(sigid);
|
|
}
|