gstreamer/gst/gstelementfactory.override

153 lines
4.8 KiB
C

/* -*- Mode: C; c-basic-offset: 4 -*- */
/*
* gstelementfactory.override - gstreamer element factory override
* Copyright (C) 2005 Alessandro Decina
*
* Authors:
* Alessandro Decina <alessandro@nnva.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
%%
override gst_element_factory_make kwargs
static PyObject *
_wrap_gst_element_factory_make(PyObject *self, PyObject *args, PyObject *kwargs){
static char *kwlist[] = { "factoryname", "name", NULL };
char *factoryname, *name = NULL;
PyObject *py_ret;
GstElement *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z:element_factory_make", kwlist, &factoryname, &name))
return NULL;
pyg_begin_allow_threads;
ret = gst_element_factory_make(factoryname, name);
pyg_end_allow_threads;
if (ret == NULL) {
PyErr_SetString(PyGstExc_ElementNotFoundError, factoryname);
return NULL;
}
py_ret = pygobject_new((GObject *)ret);
g_object_unref((GObject *)ret);
return py_ret;
}
%%
override gst_element_factory_get_static_pad_templates noargs
static PyObject *
_wrap_gst_element_factory_get_static_pad_templates(PyGObject *self)
{
const GList *list;
GList *l;
PyObject *py_list;
int i = 0;
pyg_begin_allow_threads;
list = gst_element_factory_get_static_pad_templates (GST_ELEMENT_FACTORY (self->obj));
pyg_end_allow_threads;
py_list = PyList_New(g_list_length ((GList*) list));
for (l = (GList*) list; l ; l = g_list_next(l), i++) {
GstStaticPadTemplate *templ = (GstStaticPadTemplate*) l->data;
PyList_SetItem(py_list, i, pyg_pointer_new(GST_TYPE_STATIC_PAD_TEMPLATE, (gpointer) templ));
}
return py_list;
}
%%
override gst_element_factory_list_get_elements kwargs
static PyObject *
_wrap_gst_element_factory_list_get_elements(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "type", "minrank", NULL };
PyObject *py_minrank;
GstRank minrank;
GstElementFactoryListType listype;
GList *res, *tmp;
PyObject *pyres;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"KO:element_factory_list_get_elements", kwlist,
&listype, &py_minrank))
return NULL;
if (pyg_enum_get_value(GST_TYPE_RANK, py_minrank, (gint *)&minrank))
return NULL;
pyg_begin_allow_threads;
res = gst_element_factory_list_get_elements(listype, minrank);
pyg_end_allow_threads;
pyres = PyList_New(0);
for (tmp = res; tmp; tmp = tmp->next) {
GstElementFactory *fact = (GstElementFactory*) tmp->data;
PyObject *ltmp = pygobject_new (G_OBJECT (fact));
PyList_Append(pyres, ltmp);
}
gst_plugin_feature_list_free (res);
return pyres;
}
%%
override gst_element_factory_list_filter kwargs
static PyObject *
_wrap_gst_element_factory_list_filter(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "list", "caps", "direction", "subsetonly", NULL };
PyObject *py_list, *py_caps, *py_direction;
GList *inlist = NULL;
GList *res, *tmp;
GstCaps *caps;
GstPadDirection direction;
gboolean subsetonly, caps_is_copy;
PyObject *pyres;
guint i, n;
if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OOOi:element_factory_list_filter", kwlist,
&py_list, &py_caps, &py_direction, &subsetonly))
return NULL;
if (!PyList_Check (py_list))
return NULL;
if (pyg_enum_get_value(GST_TYPE_PAD_DIRECTION, py_direction, (gint *)&direction))
return NULL;
caps = pygst_caps_from_pyobject(py_caps, &caps_is_copy);
n = PyList_GET_SIZE(py_list);
for (i = 0; i < n; i++) {
/* Get Object */
inlist = g_list_append(inlist, pygobject_get (PyList_GET_ITEM (py_list, i)));
}
pyg_begin_allow_threads;
res = gst_element_factory_list_filter(inlist, caps, direction, subsetonly);
pyg_end_allow_threads;
pyres = PyList_New(0);
for (tmp = res; tmp; tmp = tmp->next) {
GstElementFactory *fact = (GstElementFactory*) tmp->data;
PyObject *ltmp = pygobject_new (G_OBJECT (fact));
PyList_Append(pyres, ltmp);
}
gst_plugin_feature_list_free (res);
if (caps && caps_is_copy)
gst_caps_unref (caps);
if (inlist)
g_list_free (inlist);
return pyres;
}