2004-08-03 17:07:38 +00:00
|
|
|
/* -*- Mode: C; c-basic-offset: 4 -*- */
|
2004-08-30 10:42:36 +00:00
|
|
|
/* gst-python
|
2004-02-27 18:32:20 +00:00
|
|
|
* Copyright (C) 2002 David I. Lehn
|
|
|
|
* Copyright (C) 2004 Johan Dahlin
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Author: David I. Lehn <dlehn@users.sourceforge.net>
|
|
|
|
*/
|
|
|
|
%%
|
|
|
|
headers
|
2004-03-08 13:51:02 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2004-05-03 09:10:26 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
#include <gst/gst.h>
|
2004-03-09 14:54:57 +00:00
|
|
|
#include <gst/gsterror.h>
|
2004-02-27 18:32:20 +00:00
|
|
|
#include <gst/gstqueue.h>
|
|
|
|
#include <gst/gsttypefind.h>
|
2004-03-15 14:25:10 +00:00
|
|
|
#include <gst/gsttag.h>
|
2004-11-04 15:31:11 +00:00
|
|
|
#include <gst/gsttaginterface.h>
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
extern gboolean pygst_data_from_pyobject (PyObject *object, GstData **data);
|
2004-11-29 12:14:27 +00:00
|
|
|
PyObject *PyGstExc_LinkError = NULL;
|
2004-03-09 14:54:57 +00:00
|
|
|
|
2004-08-03 17:07:38 +00:00
|
|
|
GSList *mainloops = NULL;
|
|
|
|
void
|
|
|
|
_pygst_main_quit(void)
|
|
|
|
{
|
|
|
|
if (!mainloops)
|
2004-10-11 09:01:23 +00:00
|
|
|
g_error ("Quit more loops than there are");
|
2004-08-03 17:07:38 +00:00
|
|
|
else {
|
2004-10-11 09:01:23 +00:00
|
|
|
GMainLoop *loop = mainloops->data;
|
2004-08-03 17:07:38 +00:00
|
|
|
|
2004-10-11 09:01:23 +00:00
|
|
|
mainloops = g_slist_delete_link (mainloops, mainloops);
|
|
|
|
g_main_loop_quit (loop);
|
|
|
|
g_main_loop_unref (loop);
|
2004-08-03 17:07:38 +00:00
|
|
|
}
|
2004-10-11 09:01:23 +00:00
|
|
|
}
|
2004-08-03 17:07:38 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
_pygst_main(void)
|
|
|
|
{
|
|
|
|
GMainLoop *loop;
|
|
|
|
|
|
|
|
loop = g_main_loop_new (NULL, FALSE);
|
|
|
|
mainloops = g_slist_prepend (mainloops, loop);
|
|
|
|
|
|
|
|
g_main_loop_run (loop);
|
|
|
|
}
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
%%
|
|
|
|
include
|
2004-05-24 10:30:05 +00:00
|
|
|
gstbin.override
|
2004-05-04 14:20:28 +00:00
|
|
|
gstbuffer.override
|
2004-02-27 18:32:20 +00:00
|
|
|
gstpad-handlers.override
|
|
|
|
%%
|
2004-04-16 16:53:29 +00:00
|
|
|
init
|
|
|
|
%%
|
2004-02-27 18:32:20 +00:00
|
|
|
modulename gst
|
|
|
|
%%
|
|
|
|
import gobject.GObject as PyGObject_Type
|
|
|
|
%%
|
|
|
|
ignore-glob
|
2004-03-08 13:51:02 +00:00
|
|
|
_*
|
|
|
|
*_copy
|
2004-03-16 17:57:18 +00:00
|
|
|
*_error_quark
|
2004-03-08 13:51:02 +00:00
|
|
|
*_free
|
2004-03-16 17:57:18 +00:00
|
|
|
*_get_type
|
2004-03-08 13:51:02 +00:00
|
|
|
*_private
|
2004-03-16 17:57:18 +00:00
|
|
|
*_thyself
|
|
|
|
*_valist
|
|
|
|
gst_class_*
|
|
|
|
gst_init*
|
|
|
|
gst_interface_*
|
2004-03-08 13:51:02 +00:00
|
|
|
gst_tag_list_get_*
|
2004-03-16 17:57:18 +00:00
|
|
|
gst_value_*
|
|
|
|
%%
|
|
|
|
ignore
|
|
|
|
gst_alloc_trace_list
|
|
|
|
gst_alloc_trace_get
|
|
|
|
gst_caps_new_simple
|
|
|
|
gst_caps_new_full
|
|
|
|
gst_caps_set_simple
|
|
|
|
gst_element_get
|
|
|
|
gst_element_set
|
|
|
|
gst_element_get_property
|
|
|
|
gst_element_set_property
|
|
|
|
gst_error_get_message
|
|
|
|
gst_object_default_deep_notify
|
|
|
|
gst_object_check_uniqueness
|
|
|
|
gst_object_replace
|
|
|
|
gst_pad_select
|
|
|
|
gst_pad_selectv
|
|
|
|
gst_pad_load_and_link
|
|
|
|
gst_parse_launchv
|
|
|
|
gst_tag_list_add
|
|
|
|
gst_tag_list_add_values
|
|
|
|
gst_tag_list_add_valist_values
|
|
|
|
gst_tag_list_copy_value
|
|
|
|
gst_trace_read_tsc
|
2004-02-27 18:32:20 +00:00
|
|
|
%%
|
2004-03-16 17:57:18 +00:00
|
|
|
override gst_element_get_pad_list noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_element_get_pad_list(PyGObject *self)
|
|
|
|
{
|
|
|
|
GList *l, *pads;
|
|
|
|
PyObject *list;
|
|
|
|
|
|
|
|
pads = GST_ELEMENT_PADS(GST_ELEMENT(self->obj));
|
|
|
|
|
|
|
|
list = PyList_New(0);
|
|
|
|
for (l = pads; l; l = l->next) {
|
|
|
|
GstPad *pad = (GstPad*)l->data;
|
|
|
|
PyList_Append(list, pygobject_new(G_OBJECT(pad)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
%%
|
2004-05-03 09:10:26 +00:00
|
|
|
override gst_element_get_pad_template_list noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_element_get_pad_template_list(PyGObject *self)
|
|
|
|
{
|
|
|
|
GList *l, *pads;
|
|
|
|
PyObject *list;
|
|
|
|
|
|
|
|
pads = (GList*)gst_element_get_pad_template_list(GST_ELEMENT(self->obj));
|
|
|
|
|
|
|
|
list = PyList_New(0);
|
|
|
|
for (l = pads; l; l = l->next) {
|
|
|
|
GstPad *pad = (GstPad*)l->data;
|
|
|
|
PyList_Append(list, pygobject_new(G_OBJECT(pad)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
%%
|
2004-02-27 18:32:20 +00:00
|
|
|
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;
|
2004-08-06 14:18:28 +00:00
|
|
|
|
2004-09-22 16:34:08 +00:00
|
|
|
pyg_begin_allow_threads;
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
ret = gst_element_set_state(GST_ELEMENT(self->obj), state);
|
2004-09-22 16:34:08 +00:00
|
|
|
|
|
|
|
pyg_end_allow_threads;
|
2004-08-06 14:18:28 +00:00
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
return PyInt_FromLong(ret);
|
|
|
|
}
|
|
|
|
%%
|
2004-03-24 10:31:35 +00:00
|
|
|
override-slot GstPad.tp_repr
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_pad_tp_repr (PyGObject *self)
|
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
PyObject *retval;
|
2004-09-13 07:31:31 +00:00
|
|
|
GstPad *pad;
|
|
|
|
GstElement *parent;
|
2004-10-11 09:01:23 +00:00
|
|
|
|
|
|
|
pad = GST_PAD(self->obj);
|
|
|
|
parent = gst_pad_get_parent (pad);
|
|
|
|
|
2004-09-13 07:31:31 +00:00
|
|
|
buf = g_strdup_printf ("<GstPad (%s:%s) at %lx>",
|
|
|
|
gst_element_get_name (parent),
|
|
|
|
gst_pad_get_name (pad), (long) self->obj);
|
2004-03-24 10:31:35 +00:00
|
|
|
|
|
|
|
retval = PyString_FromString(buf);
|
|
|
|
g_free(buf);
|
|
|
|
return retval;
|
|
|
|
}
|
2004-09-13 07:31:31 +00:00
|
|
|
|
2004-03-24 10:31:35 +00:00
|
|
|
%%
|
2004-02-27 18:32:20 +00:00
|
|
|
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;
|
2004-07-13 10:08:45 +00:00
|
|
|
gint64 value = 0;
|
2004-02-27 18:32:20 +00:00
|
|
|
gboolean ret;
|
|
|
|
|
2004-07-13 10:08:45 +00:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"ii:GstPad.query", kwlist,
|
|
|
|
&type, &format))
|
2004-02-27 18:32:20 +00:00
|
|
|
return NULL;
|
2004-07-13 09:00:07 +00:00
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
ret = gst_pad_query(GST_PAD(self->obj), type, &format, &value);
|
2004-07-13 10:08:45 +00:00
|
|
|
return PyLong_FromLongLong(value);
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
%%
|
|
|
|
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;
|
2004-07-13 10:08:45 +00:00
|
|
|
gint64 value = 0;
|
2004-02-27 18:32:20 +00:00
|
|
|
gboolean ret;
|
|
|
|
|
2004-07-13 10:08:45 +00:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"ii:GstElement.query", kwlist,
|
|
|
|
&type, &format))
|
2004-02-27 18:32:20 +00:00
|
|
|
return NULL;
|
2004-07-13 09:08:32 +00:00
|
|
|
|
2004-07-13 10:08:45 +00:00
|
|
|
ret = gst_element_query(GST_ELEMENT(self->obj), type, &format, &value);
|
|
|
|
return PyLong_FromLongLong(value);
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_pad_convert kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_pad_convert(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
2004-07-13 10:08:45 +00:00
|
|
|
static char *kwlist[] = { "src_format", "src_value",
|
|
|
|
"dest_format", NULL };
|
2004-02-27 18:32:20 +00:00
|
|
|
GstFormat src_format, dest_format;
|
|
|
|
PyObject *src_value_obj;
|
2004-07-13 10:08:45 +00:00
|
|
|
gint64 src_value, dest_value = 0;
|
2004-02-27 18:32:20 +00:00
|
|
|
gboolean ret;
|
|
|
|
|
2004-07-13 10:08:45 +00:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"iOi:GstPad.convert", kwlist,
|
|
|
|
&src_format, &src_value_obj,
|
|
|
|
&dest_format))
|
2004-02-27 18:32:20 +00:00
|
|
|
return NULL;
|
2004-07-13 10:08:45 +00:00
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
src_value = PyLong_AsLongLong(src_value_obj);
|
2004-07-13 09:08:32 +00:00
|
|
|
|
2004-07-13 10:08:45 +00:00
|
|
|
ret = gst_pad_convert(GST_PAD(self->obj), src_format, src_value,
|
|
|
|
&dest_format, &dest_value);
|
|
|
|
return PyLong_FromLongLong(dest_value);
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
%%
|
|
|
|
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);
|
2004-07-13 09:08:32 +00:00
|
|
|
if (!ret) {
|
|
|
|
PyErr_SetString(PyExc_RuntimeError, "conversion could not be performed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PyInt_FromLong(dest_value);
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_element_link_many args
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_element_link_many(PyObject *self, PyObject *args)
|
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
PyGObject *element, *element2;
|
|
|
|
int i, len;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
len = PyTuple_Size(args);
|
|
|
|
if (len < 2)
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "gst.element_link_many requires at least two argument");
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-02-27 18:32:20 +00:00
|
|
|
|
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
for (i = 0; i < len; i++)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
element = (PyGObject*)PyTuple_GetItem(args, i);
|
|
|
|
if (!pygobject_check(element, &PyGstElement_Type))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "argument must be a GstElement");
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
/* Mimic the real gst_element_link_many */
|
|
|
|
element = (PyGObject*)PyTuple_GetItem(args, 0);
|
|
|
|
element2 = (PyGObject*)PyTuple_GetItem(args, 1);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
i = 2;
|
|
|
|
while (1) {
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-11-29 12:14:27 +00:00
|
|
|
if (!gst_element_link(GST_ELEMENT(element->obj),
|
|
|
|
GST_ELEMENT(element2->obj)))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyGstExc_LinkError, "link failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
if (i >= len)
|
|
|
|
break;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
element = element2;
|
|
|
|
element2 = (PyGObject*)PyTuple_GetItem(args, i);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
i++;
|
|
|
|
}
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
return PyInt_FromLong(1);
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
2004-11-29 12:14:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
override gst_element_link kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_element_link(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "dest", NULL };
|
|
|
|
PyGObject *dest;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GstElement.link",
|
|
|
|
kwlist, &PyGstElement_Type, &dest))
|
|
|
|
return NULL;
|
|
|
|
ret = gst_element_link(GST_ELEMENT(self->obj), GST_ELEMENT(dest->obj));
|
|
|
|
if (!ret) {
|
|
|
|
PyErr_SetString(PyGstExc_LinkError, "link failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return PyBool_FromLong(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
%%
|
|
|
|
override gst_element_link_filtered kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_element_link_filtered(PyGObject *self, PyObject *args,
|
|
|
|
PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "dest", "filtercaps", NULL };
|
|
|
|
PyGObject *dest;
|
|
|
|
PyObject *py_filtercaps;
|
|
|
|
int ret;
|
|
|
|
GstCaps *filtercaps = NULL;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"O!O:GstElement.link_filtered",
|
|
|
|
kwlist, &PyGstElement_Type,
|
|
|
|
&dest, &py_filtercaps))
|
|
|
|
return NULL;
|
|
|
|
if (pyg_boxed_check(py_filtercaps, GST_TYPE_CAPS))
|
|
|
|
filtercaps = pyg_boxed_get(py_filtercaps, GstCaps);
|
|
|
|
else {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "filtercaps should be a GstCaps");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ret = gst_element_link_filtered(GST_ELEMENT(self->obj),
|
|
|
|
GST_ELEMENT(dest->obj),
|
|
|
|
filtercaps);
|
|
|
|
if (!ret) {
|
|
|
|
PyErr_SetString(PyGstExc_LinkError, "link failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return PyBool_FromLong(ret);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
%%
|
|
|
|
override gst_element_link_pads kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_element_link_pads(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "srcpadname", "dest", "destpadname", NULL };
|
|
|
|
char *srcpadname, *destpadname;
|
|
|
|
PyGObject *dest;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"sO!s:GstElement.link_pads", kwlist,
|
|
|
|
&srcpadname, &PyGstElement_Type, &dest,
|
|
|
|
&destpadname))
|
|
|
|
return NULL;
|
|
|
|
ret = gst_element_link_pads(GST_ELEMENT(self->obj), srcpadname,
|
|
|
|
GST_ELEMENT(dest->obj), destpadname);
|
|
|
|
if (!ret) {
|
|
|
|
PyErr_SetString(PyGstExc_LinkError, "link failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return PyBool_FromLong(ret);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
%%
|
|
|
|
override gst_element_link_pads_filtered kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_element_link_pads_filtered(PyGObject *self, PyObject *args,
|
|
|
|
PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "srcpadname", "dest", "destpadname",
|
|
|
|
"filtercaps", NULL };
|
|
|
|
char *srcpadname, *destpadname;
|
|
|
|
PyGObject *dest;
|
|
|
|
int ret;
|
|
|
|
PyObject *py_filtercaps;
|
|
|
|
GstCaps *filtercaps = NULL;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"sO!sO:GstElement.link_pads_filtered",
|
|
|
|
kwlist, &srcpadname, &PyGstElement_Type,
|
|
|
|
&dest, &destpadname, &py_filtercaps))
|
|
|
|
return NULL;
|
|
|
|
if (pyg_boxed_check(py_filtercaps, GST_TYPE_CAPS))
|
|
|
|
filtercaps = pyg_boxed_get(py_filtercaps, GstCaps);
|
|
|
|
else {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "filtercaps should be a GstCaps");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ret = gst_element_link_pads_filtered(GST_ELEMENT(self->obj), srcpadname,
|
|
|
|
GST_ELEMENT(dest->obj), destpadname,
|
|
|
|
filtercaps);
|
|
|
|
if (!ret) {
|
|
|
|
PyErr_SetString(PyGstExc_LinkError, "link failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return PyBool_FromLong(ret);
|
|
|
|
}
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
%%
|
2004-03-16 17:57:18 +00:00
|
|
|
override gst_element_unlink_many args
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_element_unlink_many(PyObject *self, PyObject *args)
|
|
|
|
{
|
|
|
|
PyGObject *element, *element2;
|
|
|
|
int i, len;
|
|
|
|
|
|
|
|
len = PyTuple_Size(args);
|
|
|
|
if (len < 2)
|
|
|
|
{
|
2004-10-11 09:45:40 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "gst.element_unlink_many requires at least two arguments");
|
2004-03-16 17:57:18 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
element = (PyGObject*)PyTuple_GetItem(args, i);
|
|
|
|
if (!pygobject_check(element, &PyGstElement_Type))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "argument must be a GstElement");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mimic the real gst_element_unlink_many */
|
|
|
|
element = (PyGObject*)PyTuple_GetItem(args, 0);
|
|
|
|
element2 = (PyGObject*)PyTuple_GetItem(args, 1);
|
|
|
|
|
|
|
|
i = 2;
|
|
|
|
while (1) {
|
|
|
|
gst_element_unlink(GST_ELEMENT(element->obj), GST_ELEMENT(element2->obj));
|
|
|
|
|
|
|
|
if (i >= len)
|
|
|
|
break;
|
|
|
|
|
|
|
|
element = element2;
|
|
|
|
element2 = (PyGObject*)PyTuple_GetItem(args, i);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
2004-10-11 09:45:40 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2004-03-16 17:57:18 +00:00
|
|
|
}
|
2004-11-29 12:14:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
%%
|
|
|
|
override gst_pad_link kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_pad_link(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "sinkpad", NULL };
|
|
|
|
PyGObject *sinkpad;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:GstPad.link", kwlist,
|
|
|
|
&PyGstPad_Type, &sinkpad))
|
|
|
|
return NULL;
|
|
|
|
ret = gst_pad_link(GST_PAD(self->obj), GST_PAD(sinkpad->obj));
|
|
|
|
if (!ret) {
|
|
|
|
PyErr_SetString(PyGstExc_LinkError, "link failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return PyBool_FromLong(ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
%%
|
|
|
|
override gst_pad_link_filtered kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_pad_link_filtered(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "sinkpad", "filtercaps", NULL };
|
|
|
|
PyGObject *sinkpad;
|
|
|
|
PyObject *py_filtercaps;
|
|
|
|
int ret;
|
|
|
|
GstCaps *filtercaps = NULL;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O:GstPad.link_filtered",
|
|
|
|
kwlist, &PyGstPad_Type, &sinkpad,
|
|
|
|
&py_filtercaps))
|
|
|
|
return NULL;
|
|
|
|
if (pyg_boxed_check(py_filtercaps, GST_TYPE_CAPS))
|
|
|
|
filtercaps = pyg_boxed_get(py_filtercaps, GstCaps);
|
|
|
|
else {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "filtercaps should be a GstCaps");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
ret = gst_pad_link_filtered(GST_PAD(self->obj),
|
|
|
|
GST_PAD(sinkpad->obj),
|
|
|
|
filtercaps);
|
|
|
|
if (!ret) {
|
|
|
|
PyErr_SetString(PyGstExc_LinkError, "link failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return PyBool_FromLong(ret);
|
|
|
|
}
|
|
|
|
|
2004-03-16 17:57:18 +00:00
|
|
|
%%
|
2004-11-29 12:14:27 +00:00
|
|
|
override gst_pad_get_negotiated_caps
|
2004-02-27 18:32:20 +00:00
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_pad_get_negotiated_caps(PyGObject *self)
|
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
const GstCaps *ret;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
ret = gst_pad_get_negotiated_caps(GST_PAD(self->obj));
|
|
|
|
/* pyg_boxed_new handles NULL checking */
|
|
|
|
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
%%
|
2004-08-06 18:49:53 +00:00
|
|
|
override gst_caps_new_empty kwargs
|
|
|
|
static int
|
|
|
|
_wrap_gst_caps_new_empty(PyGBoxed *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
PyObject* item;
|
|
|
|
int len, i;
|
|
|
|
|
|
|
|
/* we wrap caps_new, caps_from_string and caps_new_full */
|
|
|
|
len = PyTuple_Size(args);
|
|
|
|
self->gtype = GST_TYPE_CAPS;
|
|
|
|
self->free_on_dealloc = FALSE;
|
2004-08-06 19:03:08 +00:00
|
|
|
|
2004-08-06 18:49:53 +00:00
|
|
|
if (len == 0) {
|
2004-08-06 19:03:50 +00:00
|
|
|
/* 0 length creates a new empty caps */
|
2004-08-06 18:49:53 +00:00
|
|
|
self->boxed = gst_caps_new_empty();
|
2004-08-06 19:03:50 +00:00
|
|
|
goto beach;
|
2004-08-06 18:49:53 +00:00
|
|
|
} else if (len == 1) {
|
2004-08-06 19:03:50 +00:00
|
|
|
/* 1 length is either a string or a structure */
|
2004-08-06 18:49:53 +00:00
|
|
|
item = PyTuple_GetItem(args, 0);
|
2004-08-06 19:03:50 +00:00
|
|
|
if (PyString_Check(item)) {
|
|
|
|
self->boxed = gst_caps_from_string(PyString_AsString(item));
|
|
|
|
goto beach;
|
|
|
|
} else if (!pyg_boxed_check(item, GST_TYPE_STRUCTURE)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "argument must be a string or a GstStructure");
|
2004-08-06 18:49:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2004-08-06 19:03:50 +00:00
|
|
|
}
|
|
|
|
/* it's either one GstStructure or several whatevers */
|
|
|
|
self->boxed = gst_caps_new_empty();
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
item = PyTuple_GetItem(args, i);
|
|
|
|
if (!pyg_boxed_check(item, GST_TYPE_STRUCTURE))
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_TypeError, "argument must be a GstStructure");
|
|
|
|
gst_caps_free(self->boxed);
|
|
|
|
return -1;
|
2004-08-06 18:49:53 +00:00
|
|
|
}
|
2004-08-06 19:03:50 +00:00
|
|
|
gst_caps_append_structure(self->boxed, pyg_boxed_get(item, GstStructure));
|
2004-08-06 18:49:53 +00:00
|
|
|
}
|
|
|
|
|
2004-08-06 19:03:50 +00:00
|
|
|
beach:
|
2004-08-06 18:49:53 +00:00
|
|
|
if (!self->boxed) {
|
|
|
|
PyErr_SetString(PyExc_RuntimeError, "could not create GstCaps object");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
%%
|
2004-08-06 18:14:30 +00:00
|
|
|
override gst_caps_get_structure kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_caps_get_structure(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "index", NULL };
|
|
|
|
int index;
|
|
|
|
GstStructure *ret;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i:GstCaps.get_structure", kwlist, &index))
|
|
|
|
return NULL;
|
|
|
|
ret = gst_caps_get_structure(pyg_boxed_get(self, GstCaps), index);
|
|
|
|
|
|
|
|
/* pyg_boxed_new handles NULL checking */
|
|
|
|
return pyg_boxed_new(GST_TYPE_STRUCTURE, ret, FALSE, FALSE);
|
|
|
|
}
|
|
|
|
%%
|
2004-03-24 10:31:35 +00:00
|
|
|
override-slot GstCaps.tp_as_sequence
|
|
|
|
static int
|
|
|
|
caps_length(PyGObject *self)
|
|
|
|
{
|
|
|
|
return gst_caps_get_size((GstCaps*)self->obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
caps_item(PyGObject *self, int i)
|
|
|
|
|
|
|
|
{
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
if (i < 0 || i >= gst_caps_get_size((GstCaps*)self->obj)) {
|
|
|
|
PyErr_SetString(PyExc_IndexError, "list index out of range");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure((GstCaps*)self->obj, i);
|
|
|
|
return pyg_boxed_new(GST_TYPE_STRUCTURE, structure, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PySequenceMethods _wrap_gst_caps_tp_as_sequence = {
|
|
|
|
(inquiry)caps_length, /* mp_length */
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(intargfunc)caps_item,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
%%
|
2004-04-16 16:53:29 +00:00
|
|
|
override-slot GstCaps.tp_str
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_caps_tp_str(PyGObject *self)
|
|
|
|
{
|
2004-08-30 10:42:36 +00:00
|
|
|
gchar *tmp;
|
|
|
|
PyObject *retval;
|
|
|
|
|
|
|
|
tmp = gst_caps_to_string((GstCaps*)self->obj);
|
|
|
|
retval = PyString_FromString(tmp);
|
|
|
|
g_free(tmp);
|
|
|
|
|
|
|
|
return retval;
|
2004-04-16 16:53:29 +00:00
|
|
|
}
|
|
|
|
%%
|
2004-03-08 13:51:02 +00:00
|
|
|
define GstTagList.keys noargs
|
2004-02-27 18:32:20 +00:00
|
|
|
void
|
|
|
|
tag_foreach_func_dict (const GstTagList *list,
|
|
|
|
const gchar *tag,
|
|
|
|
PyObject *dict)
|
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
int count;
|
|
|
|
guint i;
|
|
|
|
const GValue *gvalue;
|
|
|
|
PyObject *value;
|
|
|
|
gchar *key;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
count = gst_tag_list_get_tag_size(GST_TAG_LIST(list), tag);
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(list), tag, i);
|
|
|
|
value = pyg_value_as_pyobject(gvalue, TRUE);
|
|
|
|
key = g_strdup (tag);
|
|
|
|
PyDict_SetItemString(dict, key, value);
|
|
|
|
g_free (key);
|
|
|
|
Py_DECREF(value);
|
|
|
|
}
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
void
|
|
|
|
tag_foreach_func_list (const GstTagList *list,
|
|
|
|
const gchar *tag,
|
|
|
|
PyObject *py_list)
|
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
int count;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
count = gst_tag_list_get_tag_size(GST_TAG_LIST(list), tag);
|
|
|
|
if (count == 0)
|
|
|
|
PyErr_SetString(PyExc_KeyError, tag);
|
|
|
|
else if (count == 1)
|
|
|
|
PyList_Append(py_list, PyString_FromString(tag));
|
2004-11-04 15:31:11 +00:00
|
|
|
#if 0
|
2004-03-08 13:51:02 +00:00
|
|
|
else if (count > 1)
|
|
|
|
PyErr_SetString(PyExc_TypeError, "lists are currently unspported");
|
2004-11-04 15:31:11 +00:00
|
|
|
#endif
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject*
|
2004-03-08 13:51:02 +00:00
|
|
|
_wrap_gst_tag_list_keys(PyGObject *self)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
PyObject *dict;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
dict = PyList_New(0);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
gst_tag_list_foreach(GST_TAG_LIST(self->obj),
|
|
|
|
(GstTagForeachFunc)tag_foreach_func_list,
|
|
|
|
(gpointer)dict);
|
|
|
|
return dict;
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
%%
|
|
|
|
override-slot GstTagList.tp_as_mapping
|
|
|
|
static int
|
2004-03-08 13:51:02 +00:00
|
|
|
_wrap_gst_tag_list_length(PyGObject *self)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
return gst_structure_n_fields((GstStructure*)self->obj);
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2004-03-08 13:51:02 +00:00
|
|
|
_wrap_gst_tag_list_subscript(PyGObject *self, PyObject *py_key)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
PyObject *v = NULL;
|
2004-02-27 18:32:20 +00:00
|
|
|
char *key = PyString_AsString(py_key);
|
|
|
|
|
|
|
|
int count = gst_tag_list_get_tag_size(GST_TAG_LIST(self->obj), key);
|
|
|
|
if (count == 0) {
|
2004-03-08 13:51:02 +00:00
|
|
|
PyErr_SetObject(PyExc_KeyError, py_key);
|
2004-02-27 18:32:20 +00:00
|
|
|
} else if (count == 1) {
|
2004-03-08 13:51:02 +00:00
|
|
|
const GValue *gvalue;
|
|
|
|
gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(self->obj), key, 0);
|
|
|
|
v = pyg_value_as_pyobject(gvalue, TRUE);
|
2004-02-27 18:32:20 +00:00
|
|
|
} else {
|
2004-03-08 13:51:02 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "lists are currently unspported");
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
if (v != NULL)
|
|
|
|
Py_INCREF(v);
|
|
|
|
return v;
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PySequenceMethods _wrap_gst_tag_list_tp_as_mapping = {
|
2004-03-08 13:51:02 +00:00
|
|
|
(inquiry)_wrap_gst_tag_list_length, /* mp_length */
|
|
|
|
(binaryfunc)_wrap_gst_tag_list_subscript, /* mp_subscript */
|
|
|
|
NULL,
|
2004-02-27 18:32:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
%%
|
2004-03-08 13:51:02 +00:00
|
|
|
define GstTagList.has_key args
|
2004-02-27 18:32:20 +00:00
|
|
|
static PyObject*
|
2004-03-08 13:51:02 +00:00
|
|
|
_wrap_gst_tag_list_has_key(PyGObject *self, PyObject *args)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
gchar *key;
|
|
|
|
const GValue *gvalue;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-08-06 18:14:30 +00:00
|
|
|
if (!PyArg_ParseTuple(args, "s:GstTagList.has_key", &key))
|
2004-03-08 13:51:02 +00:00
|
|
|
return NULL;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(self->obj), key, 0);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
return PyInt_FromLong(gvalue != NULL);
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
%%
|
2004-03-08 13:51:02 +00:00
|
|
|
define GstTagList.get
|
2004-02-27 18:32:20 +00:00
|
|
|
static PyObject *
|
2004-03-08 13:51:02 +00:00
|
|
|
_wrap_gst_tag_list_get(PyGObject *self, PyObject *args)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
|
|
|
char *key;
|
|
|
|
PyObject *failobj = Py_None;
|
|
|
|
PyObject *val = NULL;
|
|
|
|
const GValue *gvalue;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s|O:GstTagList.get", &key, &failobj))
|
2004-03-08 13:51:02 +00:00
|
|
|
return NULL;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
|
|
|
gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(self->obj), key, 0);
|
|
|
|
if (gvalue != NULL) {
|
2004-03-08 13:51:02 +00:00
|
|
|
int count = gst_tag_list_get_tag_size(GST_TAG_LIST(self->obj), key);
|
|
|
|
if (count == 0) {
|
|
|
|
PyErr_SetString(PyExc_KeyError, key);
|
|
|
|
} else if (count == 1) {
|
|
|
|
gvalue = gst_tag_list_get_value_index(GST_TAG_LIST(self->obj), key, 0);
|
|
|
|
val = pyg_value_as_pyobject(gvalue, TRUE);
|
|
|
|
} else {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "lists are currently unspported");
|
|
|
|
}
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (val == NULL)
|
|
|
|
val = failobj;
|
|
|
|
Py_INCREF(val);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_structure_new kwargs
|
|
|
|
static int
|
|
|
|
_wrap_gst_structure_new(PyGBoxed *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
2004-03-08 13:51:02 +00:00
|
|
|
static char *kwlist[] = { "name", NULL };
|
|
|
|
char *name;
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:GstStructure.__init__", kwlist, &name))
|
|
|
|
return -1;
|
2004-08-06 18:14:30 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
self->gtype = GST_TYPE_STRUCTURE;
|
|
|
|
self->free_on_dealloc = FALSE;
|
2004-08-06 18:14:30 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
self->boxed = gst_structure_new(name, NULL);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
if (!self->boxed) {
|
|
|
|
PyErr_SetString(PyExc_RuntimeError, "could not create GstStructure object");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
self->free_on_dealloc = TRUE;
|
|
|
|
return 0;
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_structure_set_value kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_structure_set_value(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
2004-11-27 09:41:17 +00:00
|
|
|
static char *kwlist[] = { "field", "value", "type_name", NULL };
|
2004-03-08 13:51:02 +00:00
|
|
|
char *field;
|
|
|
|
PyObject *py_value = NULL;
|
2004-11-27 09:41:17 +00:00
|
|
|
char *type_name = NULL;
|
|
|
|
GType type;
|
2004-03-08 13:51:02 +00:00
|
|
|
GValue value = { 0 };
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
2004-11-27 09:41:17 +00:00
|
|
|
"sO|s:GstStructure.set_value",
|
|
|
|
kwlist, &field, &py_value,
|
|
|
|
&type_name)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type_name) {
|
|
|
|
if (strcmp (type_name, "char") == 0) {
|
|
|
|
type = G_TYPE_CHAR;
|
|
|
|
} else if (strcmp (type_name, "uchar") == 0) {
|
|
|
|
type = G_TYPE_UCHAR;
|
|
|
|
} else if (strcmp (type_name, "boolean") == 0) {
|
|
|
|
type = G_TYPE_BOOLEAN;
|
|
|
|
} else if (strcmp (type_name, "int") == 0) {
|
|
|
|
type = G_TYPE_INT;
|
|
|
|
} else if (strcmp (type_name, "uint") == 0) {
|
|
|
|
type = G_TYPE_UINT;
|
|
|
|
} else if (strcmp (type_name, "long") == 0) {
|
|
|
|
type = G_TYPE_LONG;
|
|
|
|
} else if (strcmp (type_name, "ulong") == 0) {
|
|
|
|
type = G_TYPE_ULONG;
|
|
|
|
} else if (strcmp (type_name, "int64") == 0) {
|
|
|
|
type = G_TYPE_INT64;
|
|
|
|
} else if (strcmp (type_name, "uint64") == 0) {
|
|
|
|
type = G_TYPE_UINT64;
|
|
|
|
} else if (strcmp (type_name, "float") == 0) {
|
|
|
|
type = G_TYPE_FLOAT;
|
|
|
|
} else if (strcmp (type_name, "double") == 0) {
|
|
|
|
type = G_TYPE_DOUBLE;
|
|
|
|
} else if (strcmp (type_name, "string") == 0) {
|
|
|
|
type = G_TYPE_STRING;
|
|
|
|
} else {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"invalid type name");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Let PyGTK guess a GType for the object. */
|
|
|
|
type = pyg_type_from_object((PyObject *) py_value->ob_type);
|
|
|
|
if (type == 0) {
|
2004-03-08 13:51:02 +00:00
|
|
|
return NULL;
|
2004-11-27 09:41:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init(&value, type);
|
2004-03-08 13:51:02 +00:00
|
|
|
if (pyg_value_from_pyobject(&value, py_value) != 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-11-27 09:41:17 +00:00
|
|
|
gst_structure_set_value(pyg_boxed_get(self, GstStructure), field,
|
|
|
|
&value);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-08 13:51:02 +00:00
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
2004-02-27 18:32:20 +00:00
|
|
|
}
|
2004-03-24 10:31:35 +00:00
|
|
|
%%
|
2004-08-03 17:07:38 +00:00
|
|
|
override gst_structure_get_int kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_structure_get_int(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "fieldname", NULL };
|
|
|
|
char *fieldname;
|
|
|
|
int value;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"s:GstStructure.get_int",
|
|
|
|
kwlist, &fieldname))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (gst_structure_get_int(pyg_boxed_get(self, GstStructure), fieldname, &value))
|
|
|
|
return PyInt_FromLong(value);
|
|
|
|
|
|
|
|
/* XXX: Raise exception? */
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
%%
|
2004-08-06 18:14:30 +00:00
|
|
|
define GstStructure.has_key args
|
|
|
|
static PyObject*
|
|
|
|
_wrap_gst_structure_has_key(PyGObject *self, PyObject *args)
|
|
|
|
{
|
|
|
|
gchar *key;
|
|
|
|
gboolean has_field;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s:GstStructure.has_key", &key))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
has_field = gst_structure_has_field((GstStructure*)self->obj, key);
|
|
|
|
|
|
|
|
return PyBool_FromLong(has_field);
|
|
|
|
}
|
|
|
|
%%
|
2004-03-24 10:31:35 +00:00
|
|
|
override-slot GstStructure.tp_as_mapping
|
|
|
|
static int
|
|
|
|
_wrap_gst_structure_length(PyGObject *self)
|
|
|
|
{
|
|
|
|
return gst_structure_n_fields((GstStructure*)self->obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_structure_subscript(PyGObject *self, PyObject *py_key)
|
|
|
|
{
|
|
|
|
PyObject *v = NULL;
|
|
|
|
const char *field = PyString_AsString(py_key);
|
|
|
|
|
|
|
|
if (gst_structure_has_field((GstStructure*)self->obj, field)) {
|
|
|
|
const GValue *gvalue;
|
|
|
|
gvalue = gst_structure_get_value((GstStructure*)self->obj, field);
|
|
|
|
g_assert(gvalue != NULL);
|
|
|
|
v = pyg_value_as_pyobject(gvalue, TRUE);
|
|
|
|
} else {
|
|
|
|
PyErr_SetString(PyExc_KeyError, field);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v != NULL)
|
|
|
|
Py_INCREF(v);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2004-08-06 14:18:28 +00:00
|
|
|
static int
|
|
|
|
_wrap_gst_structure_ass_subscript(PyGObject *self,
|
|
|
|
PyObject *py_key,
|
|
|
|
PyObject *py_value)
|
|
|
|
{
|
|
|
|
const char *key;
|
2004-08-06 18:14:30 +00:00
|
|
|
GstStructure* structure;
|
|
|
|
|
|
|
|
structure = (GstStructure*)self->obj;
|
|
|
|
key = PyString_AsString(py_key);
|
|
|
|
if (py_value != NULL) {
|
2004-08-30 10:42:36 +00:00
|
|
|
if (PyString_Check(py_value)) {
|
|
|
|
#if 0
|
|
|
|
GValue *value = NULL;
|
|
|
|
gst_structure_field_from_string(PyString_AsString(py_value), value);
|
|
|
|
g_print ("gvalue: %s %s %s\n",
|
|
|
|
PyString_AsString(py_value),
|
|
|
|
gst_value_serialize(value),
|
|
|
|
G_VALUE_TYPE_NAME(value));
|
|
|
|
gst_structure_set_value(structure, key, value);
|
|
|
|
#else
|
|
|
|
GValue value = { 0, };
|
|
|
|
g_value_init (&value, G_TYPE_STRING);
|
|
|
|
gst_value_deserialize(&value, PyString_AsString(py_value));
|
|
|
|
gst_structure_set_value(structure, key, &value);
|
|
|
|
g_value_unset(&value);
|
|
|
|
#endif
|
|
|
|
// gst_structure_set(structure, key, G_TYPE_STRING, PyString_AsString(py_value), NULL);
|
|
|
|
} else if (PyInt_Check(py_value))
|
2004-08-06 19:19:41 +00:00
|
|
|
gst_structure_set(structure, key, G_TYPE_INT, PyInt_AsLong(py_value), NULL);
|
|
|
|
else if (PyFloat_Check(py_value))
|
|
|
|
gst_structure_set(structure, key, G_TYPE_DOUBLE, PyFloat_AsDouble(py_value), NULL);
|
|
|
|
#if 0
|
2004-08-06 18:14:30 +00:00
|
|
|
g_value_init(&value, g_type_from_name("PyObject"));
|
2004-08-06 14:18:28 +00:00
|
|
|
if (pyg_value_from_pyobject(&value, py_value)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "can't convert value");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-08-06 18:14:30 +00:00
|
|
|
gst_structure_set_value(structure, key, &value);
|
2004-08-06 14:18:28 +00:00
|
|
|
g_value_unset(&value);
|
2004-08-06 19:19:41 +00:00
|
|
|
#endif
|
2004-08-06 18:14:30 +00:00
|
|
|
} else {
|
|
|
|
gst_structure_remove_field(structure, key);
|
2004-08-06 14:18:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMappingMethods _wrap_gst_structure_tp_as_mapping = {
|
2004-03-24 10:31:35 +00:00
|
|
|
(inquiry)_wrap_gst_structure_length, /* mp_length */
|
|
|
|
(binaryfunc)_wrap_gst_structure_subscript, /* mp_subscript */
|
2004-08-06 14:18:28 +00:00
|
|
|
(objobjargproc)_wrap_gst_structure_ass_subscript /* mp_ass_subscript */
|
2004-03-24 10:31:35 +00:00
|
|
|
};
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
%%
|
|
|
|
override gst_structure_foreach kwargs
|
|
|
|
static gboolean
|
|
|
|
pygst_structure_foreach_marshal(GQuark field_id,
|
2004-03-08 13:51:02 +00:00
|
|
|
GValue *value,
|
|
|
|
gpointer user_data)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
|
|
|
PyGstCustomNotify *cunote = user_data;
|
|
|
|
PyObject *py_field, *py_value, *retobj;
|
|
|
|
gboolean retval = TRUE;
|
2004-09-22 16:34:08 +00:00
|
|
|
PyGILState_STATE state;
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
g_assert(cunote->func);
|
|
|
|
|
2004-09-22 16:34:08 +00:00
|
|
|
state = pyg_gil_state_ensure();
|
2004-02-27 18:32:20 +00:00
|
|
|
|
|
|
|
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)",
|
2004-03-08 13:51:02 +00:00
|
|
|
py_field, py_value,
|
|
|
|
cunote->data);
|
2004-02-27 18:32:20 +00:00
|
|
|
else
|
|
|
|
retobj = PyEval_CallFunction(cunote->func, "(NN)",
|
2004-03-08 13:51:02 +00:00
|
|
|
py_field, py_value);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
|
|
|
if (PyErr_Occurred () || (retobj == NULL) || (retobj == Py_None)) {
|
|
|
|
PyErr_Print ();
|
|
|
|
retval = FALSE;
|
|
|
|
} else if (retobj != Py_None) {
|
|
|
|
retval = PyInt_AsLong(retobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_XDECREF(retobj);
|
|
|
|
|
2004-09-22 16:34:08 +00:00
|
|
|
pyg_gil_state_release(state);
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_structure_foreach (PyGObject *self,
|
2004-03-08 13:51:02 +00:00
|
|
|
PyObject *args,
|
|
|
|
PyObject *kwargs)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
|
|
|
static char *kwlist[] = { "foreach_function", "args", NULL };
|
|
|
|
PyObject *pyfunc, *pyarg = NULL;
|
|
|
|
PyGstCustomNotify cunote;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
2004-03-08 13:51:02 +00:00
|
|
|
"O|O:GstStructure.foreach",
|
|
|
|
kwlist,
|
|
|
|
&pyfunc, &pyarg)) {
|
2004-02-27 18:32:20 +00:00
|
|
|
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),
|
2004-03-08 13:51:02 +00:00
|
|
|
pygst_structure_foreach_marshal,
|
|
|
|
&cunote);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
%%
|
2004-03-24 10:31:35 +00:00
|
|
|
override-slot GstStructure.tp_repr
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_structure_tp_repr (PyGObject *self)
|
|
|
|
{
|
|
|
|
char *buf;
|
|
|
|
PyObject *retval;
|
|
|
|
|
|
|
|
buf = g_strdup_printf("<GstStructure (%s) at %lx>",
|
|
|
|
gst_structure_get_name((GstStructure*)self->obj),
|
|
|
|
(long)self->obj);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
2004-03-24 10:31:35 +00:00
|
|
|
retval = PyString_FromString(buf);
|
|
|
|
g_free(buf);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
%%
|
2004-08-06 18:14:30 +00:00
|
|
|
override gst_structure_from_string kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_structure_from_string(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "string", NULL };
|
|
|
|
char *string;
|
|
|
|
GstStructure *ret;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:structure_from_string", kwlist, &string))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = gst_structure_from_string(string, NULL);
|
|
|
|
|
|
|
|
/* pyg_boxed_new handles NULL checking */
|
|
|
|
return pyg_boxed_new(GST_TYPE_STRUCTURE, ret, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
%%
|
2004-03-24 10:31:35 +00:00
|
|
|
override gst_tag_list_foreach kwargs
|
2004-02-27 18:32:20 +00:00
|
|
|
static gboolean
|
|
|
|
pygst_tag_list_foreach_marshal(GstTagList *list,
|
2004-03-08 13:51:02 +00:00
|
|
|
const gchar *tag,
|
|
|
|
gpointer user_data)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
|
|
|
PyGstCustomNotify *cunote = user_data;
|
|
|
|
PyObject *py_list;
|
|
|
|
PyObject *py_key, *retobj;
|
|
|
|
gboolean retval = TRUE;
|
2004-09-22 16:34:08 +00:00
|
|
|
PyGILState_STATE state;
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
g_assert(cunote->func);
|
|
|
|
|
2004-09-22 16:34:08 +00:00
|
|
|
state = pyg_gil_state_ensure();
|
2004-02-27 18:32:20 +00:00
|
|
|
|
|
|
|
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)",
|
2004-03-08 13:51:02 +00:00
|
|
|
py_list,
|
|
|
|
py_key,
|
|
|
|
cunote->data);
|
2004-02-27 18:32:20 +00:00
|
|
|
else
|
|
|
|
retobj = PyEval_CallFunction(cunote->func, "(NN)",
|
2004-03-08 13:51:02 +00:00
|
|
|
py_list,
|
|
|
|
py_key);
|
2004-02-27 18:32:20 +00:00
|
|
|
|
|
|
|
if (PyErr_Occurred () || (retobj == NULL) || (retobj == Py_None)) {
|
|
|
|
PyErr_Print ();
|
|
|
|
retval = FALSE;
|
|
|
|
} else if (retobj != Py_None) {
|
|
|
|
retval = PyInt_AsLong(retobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
Py_XDECREF(retobj);
|
|
|
|
|
2004-09-22 16:34:08 +00:00
|
|
|
pyg_gil_state_release(state);
|
|
|
|
|
2004-02-27 18:32:20 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_tag_list_foreach (PyGObject *self,
|
2004-03-08 13:51:02 +00:00
|
|
|
PyObject *args,
|
|
|
|
PyObject *kwargs)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
|
|
|
static char *kwlist[] = { "foreach_function", "args", NULL };
|
|
|
|
PyObject *pyfunc, *pyarg = NULL;
|
|
|
|
PyGstCustomNotify cunote;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
2004-03-08 13:51:02 +00:00
|
|
|
"O|O:GstTagList.foreach",
|
|
|
|
kwlist, &pyfunc, &pyarg))
|
2004-02-27 18:32:20 +00:00
|
|
|
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),
|
|
|
|
(GstTagForeachFunc)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,
|
2004-03-08 13:51:02 +00:00
|
|
|
PyObject *args,
|
|
|
|
PyObject *kwargs)
|
2004-02-27 18:32:20 +00:00
|
|
|
{
|
|
|
|
static char *kwlist[] = { "tag", "index", NULL };
|
|
|
|
char *tag;
|
|
|
|
int index;
|
|
|
|
const GValue *gvalue;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
2004-03-08 13:51:02 +00:00
|
|
|
"si:GstTagList.get_value_index",
|
|
|
|
kwlist, &tag, &index))
|
2004-02-27 18:32:20 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
gvalue = gst_tag_list_get_value_index(pyg_boxed_get(self, GstTagList),
|
|
|
|
tag,
|
|
|
|
index);
|
|
|
|
|
|
|
|
return pyg_value_as_pyobject(gvalue, FALSE);
|
|
|
|
}
|
2004-03-08 13:51:02 +00:00
|
|
|
%%
|
|
|
|
override gst_pad_get_negotiated_caps noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_pad_get_negotiated_caps(PyGObject *self)
|
|
|
|
{
|
|
|
|
GstCaps *ret = (GstCaps*)gst_pad_get_negotiated_caps(GST_PAD(self->obj));
|
|
|
|
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_pad_get_pad_template_caps noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_pad_get_pad_template_caps(PyGObject *self)
|
|
|
|
{
|
|
|
|
GstCaps *ret = (GstCaps*)gst_pad_get_pad_template_caps(GST_PAD(self->obj));
|
|
|
|
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_pad_template_get_caps noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_pad_template_get_caps(PyGObject *self)
|
|
|
|
{
|
|
|
|
GstCaps *ret = (GstCaps*)gst_pad_template_get_caps(GST_PAD_TEMPLATE(self->obj));
|
|
|
|
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
%%
|
2004-05-03 09:10:26 +00:00
|
|
|
override gst_type_find_factory_get_caps noargs
|
2004-03-08 13:51:02 +00:00
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_type_find_factory_get_caps(PyGObject *self)
|
|
|
|
{
|
|
|
|
GstCaps *ret = (GstCaps*)gst_type_find_factory_get_caps(GST_TYPE_FIND_FACTORY(self->obj));
|
|
|
|
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
%%
|
2004-05-03 09:10:26 +00:00
|
|
|
override gst_pad_template_get_caps_by_name kwargs
|
2004-03-08 13:51:02 +00:00
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_pad_template_get_caps_by_name(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
2004-05-03 09:10:26 +00:00
|
|
|
static char *kwlist[] = { "name", NULL };
|
|
|
|
char *name;
|
|
|
|
GstCaps *ret;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:GstPadTemplate.get_caps_by_name", kwlist, &name))
|
|
|
|
return NULL;
|
|
|
|
ret = (GstCaps*)gst_pad_template_get_caps_by_name(GST_PAD_TEMPLATE(self->obj), name);
|
|
|
|
/* pyg_boxed_new handles NULL checking */
|
|
|
|
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
|
2004-03-08 13:51:02 +00:00
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_type_find_factory_get_caps noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_type_find_factory_get_caps(PyGObject *self)
|
|
|
|
{
|
|
|
|
GstCaps *ret = (GstCaps*)gst_type_find_factory_get_caps(GST_TYPE_FIND_FACTORY(self->obj));
|
|
|
|
return pyg_boxed_new(GST_TYPE_CAPS, ret, TRUE, TRUE);
|
|
|
|
}
|
2004-03-09 14:54:57 +00:00
|
|
|
%%
|
|
|
|
override-attr GError.domain
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_g_error__get_domain(PyGObject *self, void *closure)
|
|
|
|
{
|
|
|
|
return PyString_FromString(g_quark_to_string(((GError*)self->obj)->domain));
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override-slot GError.tp_str
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_g_error_tp_str(PyGObject *self)
|
|
|
|
{
|
|
|
|
GError *error = (GError*)self->obj;
|
|
|
|
return PyString_FromString(gst_error_get_message (error->domain,
|
|
|
|
error->code));
|
|
|
|
}
|
2004-03-24 10:31:35 +00:00
|
|
|
%%
|
|
|
|
override gst_main noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_main(PyObject *self)
|
|
|
|
{
|
2004-09-22 16:34:08 +00:00
|
|
|
pyg_begin_allow_threads;
|
2004-08-03 17:07:38 +00:00
|
|
|
|
|
|
|
_pygst_main();
|
|
|
|
|
2004-09-22 16:34:08 +00:00
|
|
|
pyg_end_allow_threads;
|
2004-03-24 10:31:35 +00:00
|
|
|
|
|
|
|
if (PyErr_Occurred())
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
|
|
|
|
}
|
2004-08-03 17:07:38 +00:00
|
|
|
%%
|
|
|
|
override gst_main_quit args
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_main_quit(PyObject *self)
|
|
|
|
{
|
|
|
|
|
|
|
|
_pygst_main_quit();
|
|
|
|
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
2004-07-15 10:15:18 +00:00
|
|
|
%%
|
2004-11-27 09:41:17 +00:00
|
|
|
override gst_event_new_any kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_event_new_any(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "structure", NULL };
|
|
|
|
PyObject *py_structure;
|
|
|
|
GstStructure *structure = NULL;
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"O:event_new_any", kwlist, &py_structure))
|
|
|
|
return NULL;
|
|
|
|
if (pyg_boxed_check(py_structure, GST_TYPE_STRUCTURE))
|
|
|
|
structure = pyg_boxed_get(py_structure, GstStructure);
|
|
|
|
else {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"structure should be a GstStructure");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
event = gst_event_new (GST_EVENT_ANY);
|
|
|
|
if (!event) {
|
|
|
|
PyErr_SetString(PyExc_RuntimeError,
|
|
|
|
"could not create GstEvent object");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
event->event_data.structure.structure = gst_structure_copy(structure);
|
|
|
|
|
|
|
|
/* pyg_boxed_new handles NULL checking */
|
|
|
|
return pyg_boxed_new(GST_TYPE_EVENT, event, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_event_any_get_structure noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_event_any_get_structure(PyObject *self)
|
|
|
|
{
|
|
|
|
GstStructure *ret;
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
event = pyg_pointer_get(self, GstEvent);
|
|
|
|
if (GST_EVENT_TYPE(event) == GST_EVENT_ANY) {
|
|
|
|
ret = event->event_data.structure.structure;
|
|
|
|
/* pyg_boxed_new handles NULL checking */
|
|
|
|
return pyg_boxed_new(GST_TYPE_STRUCTURE, ret, TRUE, TRUE);
|
|
|
|
} else {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_event_new_discontinuous kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_event_new_discontinuous(PyObject *self, PyObject *args,
|
|
|
|
PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "new_media", "format", "value", NULL };
|
|
|
|
int new_media = FALSE;
|
|
|
|
PyObject *py_format = NULL;
|
|
|
|
gint64 value = 0;
|
|
|
|
GstFormat format;
|
|
|
|
GstEvent *event;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"iOL:event_new_discontinuous", kwlist, &new_media, &py_format,
|
|
|
|
&value)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (pyg_enum_get_value(GST_TYPE_FORMAT, py_format, (gint *) &format)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
event = gst_event_new_discontinuous (new_media, format, value,
|
|
|
|
GST_FORMAT_UNDEFINED);
|
|
|
|
|
|
|
|
return pyg_boxed_new(GST_TYPE_EVENT, event, TRUE, TRUE);
|
|
|
|
}
|
|
|
|
%%
|
2004-07-15 10:15:18 +00:00
|
|
|
override gst_registry_pool_plugin_list noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_registry_pool_plugin_list(PyGObject *self)
|
|
|
|
{
|
|
|
|
GList *l, *plugins;
|
|
|
|
PyObject *list;
|
|
|
|
|
|
|
|
plugins = gst_registry_pool_plugin_list();
|
|
|
|
|
|
|
|
list = PyList_New(0);
|
|
|
|
for (l = plugins; l; l = l->next) {
|
|
|
|
GstPlugin *plugin = (GstPlugin*)l->data;
|
|
|
|
PyList_Append(list,
|
|
|
|
pyg_boxed_new(GST_TYPE_PLUGIN, plugin, TRUE, TRUE));
|
|
|
|
}
|
|
|
|
g_list_free(plugins);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_registry_pool_feature_list
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_registry_pool_feature_list(PyGObject *self, PyObject *args)
|
|
|
|
{
|
|
|
|
GList *l, *features;
|
|
|
|
PyObject *pygtype, *list;
|
|
|
|
GType gtype;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O:registry_pool_feature_list",
|
|
|
|
&pygtype))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
gtype = pyg_type_from_object (pygtype);
|
|
|
|
if (!gtype)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
features = gst_registry_pool_feature_list(gtype);
|
|
|
|
|
|
|
|
list = PyList_New(0);
|
|
|
|
for (l = features; l; l = l->next) {
|
|
|
|
GstPluginFeature *feature = (GstPluginFeature*)l->data;
|
|
|
|
PyList_Append(list, pygobject_new (G_OBJECT (feature)));
|
|
|
|
|
|
|
|
}
|
|
|
|
g_list_free(features);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
2004-10-11 09:24:15 +00:00
|
|
|
%%
|
|
|
|
override gst_xml_new noargs
|
|
|
|
|
2004-10-11 13:43:26 +00:00
|
|
|
extern PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
|
|
|
|
extern PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node);
|
|
|
|
|
2004-10-11 09:24:15 +00:00
|
|
|
/* libxml2 available check */
|
|
|
|
static PyObject *
|
|
|
|
_gst_get_libxml2_module(void)
|
|
|
|
{
|
|
|
|
PyObject *xml = NULL;
|
|
|
|
|
|
|
|
xml = PyImport_ImportModule("libxml2");
|
|
|
|
if (!xml) {
|
|
|
|
PyErr_Clear();
|
|
|
|
PyErr_SetString(PyExc_RuntimeError,"libxml2 bindings required");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_wrap_gst_xml_new(PyGObject *self)
|
|
|
|
{
|
|
|
|
PyObject *xml = _gst_get_libxml2_module();
|
|
|
|
|
|
|
|
if(!xml)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
self->obj = (GObject *)gst_xml_new();
|
|
|
|
|
|
|
|
if (!self->obj) {
|
|
|
|
PyErr_SetString(PyExc_RuntimeError, "could not create GstXML object");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pygobject_register_wrapper((PyObject *)self);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_xml_get_topelements noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_xml_get_topelements(PyGObject *self)
|
|
|
|
{
|
|
|
|
GList *l, *xml_elements;
|
|
|
|
PyObject *py_list;
|
|
|
|
|
|
|
|
py_list = PyList_New(0);
|
|
|
|
|
|
|
|
xml_elements = gst_xml_get_topelements(GST_XML(self->obj));
|
|
|
|
for (l = xml_elements; l; l = l->next) {
|
|
|
|
GstElement *element = (GstElement*)l->data;
|
|
|
|
|
|
|
|
PyList_Append(py_list, pygobject_new(G_OBJECT(element)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return py_list;
|
|
|
|
}
|
|
|
|
%%
|
|
|
|
override gst_xml_parse_memory kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_xml_parse_memory(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "buffer", "root", NULL };
|
|
|
|
int buffer_len, ret;
|
|
|
|
char *root = NULL;
|
|
|
|
guchar *buffer;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
|
|
|
|
"s#|s:GstXML.parse_memory",
|
|
|
|
kwlist, &buffer, &buffer_len, &root))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = gst_xml_parse_memory(GST_XML(self->obj),
|
|
|
|
buffer, buffer_len, root);
|
|
|
|
|
|
|
|
return PyBool_FromLong(ret);
|
|
|
|
}
|
2004-11-15 12:13:57 +00:00
|
|
|
%%
|
|
|
|
override gst_tag_setter_get_list noargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_tag_setter_get_list(PyGObject *self)
|
|
|
|
{
|
|
|
|
GstTagList *ret;
|
|
|
|
|
|
|
|
ret = (GstTagList*)gst_tag_setter_get_list(GST_TAG_SETTER(self->obj));
|
|
|
|
/* pyg_boxed_new handles NULL checking */
|
|
|
|
return pyg_boxed_new(GST_TYPE_TAG_LIST, ret, TRUE, TRUE);
|
|
|
|
}
|
2004-11-23 10:16:58 +00:00
|
|
|
%%
|
|
|
|
override gst_element_send_event kwargs
|
|
|
|
static PyObject *
|
|
|
|
_wrap_gst_element_send_event(PyGObject *self, PyObject *args, PyObject *kwargs)
|
|
|
|
{
|
|
|
|
static char *kwlist[] = { "event", NULL };
|
|
|
|
PyObject *py_event;
|
|
|
|
int ret;
|
|
|
|
GstEvent *event = NULL;
|
|
|
|
|
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:GstElement.send_event", kwlist, &py_event))
|
|
|
|
return NULL;
|
|
|
|
if (pyg_boxed_check(py_event, GST_TYPE_EVENT))
|
|
|
|
event = pyg_boxed_get(py_event, GstEvent);
|
|
|
|
else {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "event should be a GstEvent");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The pipeline unrefs the event, but we want to keep the ownership */
|
|
|
|
gst_event_ref(event);
|
|
|
|
|
|
|
|
ret = gst_element_send_event(GST_ELEMENT(self->obj), event);
|
|
|
|
return PyBool_FromLong(ret);
|
|
|
|
|
|
|
|
}
|