Initial import to Tizen
[profile/ivi/gstreamer-python.git] / gst / gstelementfactory.override
1 /* -*- Mode: C; c-basic-offset: 4 -*- */
2 /*
3  * gstelementfactory.override - gstreamer element factory override
4  * Copyright (C) 2005 Alessandro Decina
5  * 
6  * Authors:
7  *   Alessandro Decina <alessandro@nnva.org>
8  *
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.
13  *
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.
18  *
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.
23  */
24
25 %%
26 override gst_element_factory_make kwargs
27 static PyObject *
28 _wrap_gst_element_factory_make(PyObject *self, PyObject *args, PyObject *kwargs){
29     static char *kwlist[] = { "factoryname", "name", NULL };
30     char *factoryname, *name = NULL;
31     PyObject *py_ret;
32     GstElement *ret;
33
34     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|z:element_factory_make", kwlist, &factoryname, &name))
35         return NULL;
36
37     pyg_begin_allow_threads;
38     ret = gst_element_factory_make(factoryname, name);
39     pyg_end_allow_threads;
40
41     if (ret == NULL) {
42         PyErr_SetString(PyGstExc_ElementNotFoundError, factoryname);
43         return NULL;
44     }
45     py_ret = pygobject_new((GObject *)ret);
46     g_object_unref((GObject *)ret);
47     return py_ret;
48 }
49 %%
50 override gst_element_factory_get_static_pad_templates noargs
51 static PyObject *
52 _wrap_gst_element_factory_get_static_pad_templates(PyGObject *self)
53 {
54   const GList *list;
55   GList *l;
56   PyObject *py_list;
57   int i = 0;
58
59   pyg_begin_allow_threads;
60   list = gst_element_factory_get_static_pad_templates (GST_ELEMENT_FACTORY (self->obj));
61   pyg_end_allow_threads;
62
63   py_list = PyList_New(g_list_length ((GList*) list));
64
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));
68   }
69   return py_list;
70 }
71 %%
72 override gst_element_factory_list_get_elements kwargs
73 static PyObject *
74 _wrap_gst_element_factory_list_get_elements(PyObject *self, PyObject *args, PyObject *kwargs)
75 {
76     static char *kwlist[] = { "type", "minrank", NULL };
77     PyObject *py_minrank;
78     GstRank minrank;
79     GstElementFactoryListType listype;
80     GList *res, *tmp;
81     PyObject *pyres;
82
83     if (!PyArg_ParseTupleAndKeywords(args, kwargs,"KO:element_factory_list_get_elements", kwlist,
84                                      &listype, &py_minrank))
85         return NULL;
86     if (pyg_enum_get_value(GST_TYPE_RANK, py_minrank, (gint *)&minrank))
87         return NULL;
88     pyg_begin_allow_threads;
89     res = gst_element_factory_list_get_elements(listype, minrank);
90     pyg_end_allow_threads;
91
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));
96
97         PyList_Append(pyres, ltmp);
98     }
99     gst_plugin_feature_list_free (res);
100
101     return pyres;
102 }
103 %%
104 override gst_element_factory_list_filter kwargs
105 static PyObject *
106 _wrap_gst_element_factory_list_filter(PyObject *self, PyObject *args, PyObject *kwargs)
107 {
108     static char *kwlist[] = { "list", "caps", "direction", "subsetonly", NULL };
109     PyObject *py_list, *py_caps, *py_direction;
110     GList *inlist = NULL;
111     GList *res, *tmp;
112     GstCaps *caps;
113     GstPadDirection direction;
114     gboolean subsetonly, caps_is_copy;
115     PyObject *pyres;
116     guint i, n;
117
118     if (!PyArg_ParseTupleAndKeywords(args, kwargs,"OOOi:element_factory_list_filter", kwlist,
119                                      &py_list, &py_caps, &py_direction, &subsetonly))
120         return NULL;
121     if (!PyList_Check (py_list))
122         return NULL;
123     if (pyg_enum_get_value(GST_TYPE_PAD_DIRECTION, py_direction, (gint *)&direction))
124         return NULL;
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++) {
128         /* Get Object */
129         inlist = g_list_append(inlist, pygobject_get (PyList_GET_ITEM (py_list, i)));
130     }
131
132     pyg_begin_allow_threads;
133     res = gst_element_factory_list_filter(inlist, caps, direction, subsetonly);
134     pyg_end_allow_threads;
135
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));
140
141         PyList_Append(pyres, ltmp);
142     }
143
144     gst_plugin_feature_list_free (res);
145     if (caps && caps_is_copy)
146         gst_caps_unref (caps);
147     if (inlist)
148         g_list_free (inlist);
149
150     return pyres;
151 }
152     
153