1 /* -*- Mode: C; c-basic-offset: 4 -*- */
3 * gstelementfactory.override - gstreamer element factory override
4 * Copyright (C) 2005 Alessandro Decina
7 * Alessandro Decina <alessandro@nnva.org>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
26 override gst_element_factory_make kwargs
28 _wrap_gst_element_factory_make(PyObject *self, PyObject *args, PyObject *kwargs){
29 static char *kwlist[] = { "factoryname", "name", NULL };
30 char *factoryname, *name = NULL;
34 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z:element_factory_make", kwlist, &factoryname, &name))
37 pyg_begin_allow_threads;
38 ret = gst_element_factory_make(factoryname, name);
39 pyg_end_allow_threads;
42 PyErr_SetString(PyGstExc_ElementNotFoundError, factoryname);
45 py_ret = pygobject_new((GObject *)ret);
46 g_object_unref((GObject *)ret);
50 override gst_element_factory_get_static_pad_templates noargs
52 _wrap_gst_element_factory_get_static_pad_templates(PyGObject *self)
59 pyg_begin_allow_threads;
60 list = gst_element_factory_get_static_pad_templates (GST_ELEMENT_FACTORY (self->obj));
61 pyg_end_allow_threads;
63 py_list = PyList_New(g_list_length ((GList*) list));
65 for (l = (GList*) list; l ; l = g_list_next(l), i++) {
66 GstStaticPadTemplate *templ = (GstStaticPadTemplate*) l->data;
67 PyList_SetItem(py_list, i, pyg_pointer_new(GST_TYPE_STATIC_PAD_TEMPLATE, (gpointer) templ));
72 override gst_element_factory_list_get_elements kwargs
74 _wrap_gst_element_factory_list_get_elements(PyObject *self, PyObject *args, PyObject *kwargs)
76 static char *kwlist[] = { "type", "minrank", NULL };
79 GstElementFactoryListType listype;
83 if (!PyArg_ParseTupleAndKeywords(args, kwargs,"KO:element_factory_list_get_elements", kwlist,
84 &listype, &py_minrank))
86 if (pyg_enum_get_value(GST_TYPE_RANK, py_minrank, (gint *)&minrank))
88 pyg_begin_allow_threads;
89 res = gst_element_factory_list_get_elements(listype, minrank);
90 pyg_end_allow_threads;
92 pyres = PyList_New(0);
93 for (tmp = res; tmp; tmp = tmp->next) {
94 GstElementFactory *fact = (GstElementFactory*) tmp->data;
95 PyObject *ltmp = pygobject_new (G_OBJECT (fact));
97 PyList_Append(pyres, ltmp);
99 gst_plugin_feature_list_free (res);
104 override gst_element_factory_list_filter kwargs
106 _wrap_gst_element_factory_list_filter(PyObject *self, PyObject *args, PyObject *kwargs)
108 static char *kwlist[] = { "list", "caps", "direction", "subsetonly", NULL };
109 PyObject *py_list, *py_caps, *py_direction;
110 GList *inlist = NULL;
113 GstPadDirection direction;
114 gboolean subsetonly, caps_is_copy;
118 if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OOOi:element_factory_list_filter", kwlist,
119 &py_list, &py_caps, &py_direction, &subsetonly))
121 if (!PyList_Check (py_list))
123 if (pyg_enum_get_value(GST_TYPE_PAD_DIRECTION, py_direction, (gint *)&direction))
125 caps = pygst_caps_from_pyobject(py_caps, &caps_is_copy);
126 n = PyList_GET_SIZE(py_list);
127 for (i = 0; i < n; i++) {
129 inlist = g_list_append(inlist, pygobject_get (PyList_GET_ITEM (py_list, i)));
132 pyg_begin_allow_threads;
133 res = gst_element_factory_list_filter(inlist, caps, direction, subsetonly);
134 pyg_end_allow_threads;
136 pyres = PyList_New(0);
137 for (tmp = res; tmp; tmp = tmp->next) {
138 GstElementFactory *fact = (GstElementFactory*) tmp->data;
139 PyObject *ltmp = pygobject_new (G_OBJECT (fact));
141 PyList_Append(pyres, ltmp);
144 gst_plugin_feature_list_free (res);
145 if (caps && caps_is_copy)
146 gst_caps_unref (caps);
148 g_list_free (inlist);