Initial import to Tizen
[profile/ivi/gstreamer-python.git] / gst / interfaces.override
1 /* -*- Mode: C; c-basic-offset: 4 -*- */
2 /* gst-python
3  * Copyright (C) 2004 David I. Lehn
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  * 
20  * Author: David I. Lehn <dlehn@users.sourceforge.net>
21  */
22 %%
23 headers
24 #ifdef HAVE_CONFIG_H
25 # include <config.h>
26 #endif
27
28 #define NO_IMPORT_PYGOBJECT
29 #include "common.h"
30 #include "pygst.h"
31
32 #include <gst/gst.h>
33
34 #include <gst/interfaces/colorbalance.h>
35 #include <gst/interfaces/navigation.h>
36 #include <gst/interfaces/propertyprobe.h>
37 #include <gst/interfaces/tuner.h>
38 #include <gst/interfaces/mixer.h>
39 #include <gst/interfaces/videoorientation.h>
40 #ifdef HAVE_STREAM_VOLUME_INTERFACE
41 #include <gst/interfaces/streamvolume.h>
42 #endif
43
44 %%
45 modulename gst.interfaces
46 %%
47 import gobject.GObject as PyGObject_Type
48 import gst.Object as PyGstObject_Type
49 import gst.Structure as PyGstStructure_Type
50 import gst.Element as PyGstElement_Type
51 import gst.Query as PyGstQuery_Type
52 %%
53 include
54   xoverlay.override
55   gstversion.override
56 %%
57 ignore-glob
58  _*
59  gstinterfaces_*init
60  *_get_type
61 %%
62 override gst_tuner_list_channels noargs
63 static PyObject *
64 _wrap_gst_tuner_list_channels(PyGObject *self)
65 {
66     const GList *l, *list;
67     PyObject *py_list;
68         
69     g_return_val_if_fail (GST_IS_TUNER (self->obj), PyList_New(0));
70
71     pyg_begin_allow_threads;
72     list = gst_tuner_list_channels(GST_TUNER(self->obj));
73     pyg_end_allow_threads;
74     
75     py_list = PyList_New(0);
76     for (l = list; l; l = l->next) {
77         GstTunerChannel *channel = (GstTunerChannel*)l->data;
78         PyObject *py_channel = pygobject_new(G_OBJECT(channel));
79         PyList_Append(py_list, py_channel);
80         Py_DECREF(py_channel);
81     }
82                 
83     return py_list;
84 }
85 %%
86 override gst_tuner_list_norms noargs
87 static PyObject *
88 _wrap_gst_tuner_list_norms(PyGObject *self)
89 {
90     const GList *l, *list;
91     PyObject *py_list;
92         
93     g_return_val_if_fail (GST_IS_TUNER (self->obj), PyList_New(0));
94
95     pyg_begin_allow_threads;
96     list = gst_tuner_list_norms(GST_TUNER(self->obj));
97     pyg_end_allow_threads;
98     
99     py_list = PyList_New(0);
100     for (l = list; l; l = l->next) {
101         GstTunerNorm *norm = (GstTunerNorm*)l->data;
102         PyObject *py_norm = pygobject_new(G_OBJECT(norm));
103         PyList_Append(py_list, py_norm);
104         Py_DECREF(py_norm);
105     }
106                 
107     return py_list;
108 }
109 %%
110 override gst_mixer_list_tracks noargs
111 static PyObject *
112 _wrap_gst_mixer_list_tracks(PyGObject *self)
113 {
114     const GList *l, *list;
115     PyObject *py_list;
116         
117     g_return_val_if_fail (GST_IS_MIXER (self->obj), PyList_New(0));
118
119     pyg_begin_allow_threads;
120     list = gst_mixer_list_tracks(GST_MIXER(self->obj));
121     pyg_end_allow_threads;
122     
123     py_list = PyList_New(0);
124     for (l = list; l; l = l->next) {
125         GstMixerTrack *track = (GstMixerTrack*)l->data;
126         PyObject *py_track = pygobject_new(G_OBJECT(track));
127         PyList_Append(py_list, py_track);
128         Py_DECREF(py_track);
129     }
130                 
131     return py_list;
132 }
133 %%
134 override gst_color_balance_list_channels noargs
135 static PyObject *
136 _wrap_gst_color_balance_list_channels(PyGObject *self)
137 {
138     const GList *l, *list;
139     PyObject *py_list;
140
141     g_return_val_if_fail (GST_IS_COLOR_BALANCE (self->obj), PyList_New(0));
142
143     pyg_begin_allow_threads;
144     list = gst_color_balance_list_channels(GST_COLOR_BALANCE(self->obj));
145     pyg_end_allow_threads;
146
147     py_list = PyList_New(0);
148     for (l = list; l; l = l->next) {
149         GstColorBalanceChannel *channel = (GstColorBalanceChannel*)l->data;
150         PyObject *py_channel = pygobject_new(G_OBJECT(channel));
151         PyList_Append(py_list, py_channel);
152         Py_DECREF(py_channel);
153     }
154
155     return py_list;
156 }
157 %%
158 override gst_mixer_options_get_values noargs
159 static PyObject *
160 _wrap_gst_mixer_options_get_values (PyGObject *self)
161 {
162     GList       *l, *list;
163     PyObject    *py_list;
164
165     g_return_val_if_fail (GST_IS_MIXER_OPTIONS (self->obj), PyList_New(0));
166
167     pyg_begin_allow_threads;
168     list = gst_mixer_options_get_values (GST_MIXER_OPTIONS (self->obj));
169     pyg_end_allow_threads;
170
171     py_list = PyList_New(0);
172     for (l = list; l; l = l->next) {
173         gchar *value = (gchar *) l->data;
174         PyObject *py_string = PyString_FromString(g_strdup(value));
175         PyList_Append(py_list, py_string);
176         Py_DECREF (py_string);
177     }
178
179     return py_list;
180 }
181
182 %%
183 override gst_mixer_set_volume kwargs
184 static PyObject *
185 _wrap_gst_mixer_set_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
186 {
187     static char *kwlist[] = { "track", "volumes", NULL };
188     PyGObject *track;
189     PyObject *py_tuple;
190     gint *volumes = NULL;
191     gint channels;
192     int i;
193     PyObject *ret;
194
195     if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!O:GstMixer.set_volume",
196         kwlist, &PyGstMixerTrack_Type, &track, &py_tuple))
197       return NULL;
198
199     g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
200       NULL);
201
202     if (channels != PyTuple_Size (py_tuple)) {
203       PyErr_Format (PyExc_TypeError,
204           "Track channel count %d != volume tuple size %d",
205           channels, (gint) PyTuple_Size (py_tuple));
206       return NULL;
207     }
208
209     Py_INCREF(Py_None);
210     ret = Py_None;
211
212     if (channels == 0)
213       return ret;
214
215     volumes = g_malloc (channels * sizeof (gint));
216     for (i = 0; i < channels; ++i) {
217       volumes[i] = PyInt_AsLong (PyTuple_GET_ITEM (py_tuple, i));
218     }
219     
220     pyg_begin_allow_threads;
221     gst_mixer_set_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
222           volumes);
223     pyg_end_allow_threads;
224
225     g_free (volumes);
226
227     return ret;
228 }
229
230 %%
231 override gst_mixer_get_volume kwargs
232 static PyObject *
233 _wrap_gst_mixer_get_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
234 {
235     static char *kwlist[] = { "track", NULL };
236     PyGObject *track;
237     PyObject *py_tuple;
238     gint *volumes = NULL;
239     gint channels;
240     int i;
241
242     if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!:GstMixer.get_volume",
243         kwlist, &PyGstMixerTrack_Type, &track))
244       return NULL;
245
246     g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
247       NULL);
248
249     volumes = g_malloc (channels * sizeof (gint));
250     /* 0 channels will cause volume to be a NULL pointer, but we still want
251      * our (empty) tuple */
252     if (channels) {
253         pyg_begin_allow_threads;
254         gst_mixer_get_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
255                               volumes);
256         pyg_end_allow_threads;
257     }
258
259     py_tuple = PyTuple_New (channels);
260
261     for (i = 0; i < channels; ++i) {
262       PyTuple_SET_ITEM (py_tuple, i, PyInt_FromLong (volumes[i]));
263     }
264     g_free (volumes);
265
266     return py_tuple;
267 }
268
269 %%
270 override gst_property_probe_get_property args
271 static PyObject *
272 _wrap_gst_property_probe_get_property (PyGObject *self, PyObject *args)
273 {
274     const char *name;
275     const GParamSpec *spec;
276     
277     if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_property", &name))
278         return NULL;
279     
280     pyg_begin_allow_threads;
281     spec = gst_property_probe_get_property (GST_PROPERTY_PROBE (self->obj),
282                                             name);
283     pyg_end_allow_threads;
284
285     if (!spec) {
286         PyErr_Format(PyExc_ValueError, "unknown property: %s", name);
287         return NULL;
288     }
289
290     return pyg_param_spec_new((GParamSpec*)spec);
291 }
292 %%
293 override gst_property_probe_get_properties noargs
294 static PyObject *
295 _wrap_gst_property_probe_get_properties (PyGObject *self)
296 {
297     const GList *l, *list;
298     PyObject *py_list;
299
300     g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
301
302     pyg_begin_allow_threads;
303     list = gst_property_probe_get_properties (GST_PROPERTY_PROBE (self->obj));
304     pyg_end_allow_threads;
305
306     py_list = PyList_New(0);
307     for (l = list; l; l = l->next) {
308         GParamSpec *spec = (GParamSpec*)l->data;
309         PyObject *py_gspec = pyg_param_spec_new((GParamSpec*)spec);
310         PyList_Append(py_list, py_gspec);
311         Py_DECREF(py_gspec);
312     }
313
314     return py_list;
315 }
316 %%
317 override gst_property_probe_get_values_name args
318 static PyObject *
319 _wrap_gst_property_probe_get_values_name (PyGObject *self, PyObject *args)
320 {
321     const char *name;
322     GValueArray *array;
323     PyObject *py_list;
324     int i;
325     
326     g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
327
328     if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_values_name", &name))
329         return NULL;
330
331     pyg_begin_allow_threads;
332     array = gst_property_probe_get_values_name (GST_PROPERTY_PROBE (self->obj),
333                                                 name);
334     pyg_end_allow_threads;
335
336     py_list = PyList_New(0);
337
338     if (array) {
339         for (i = 0; i < array->n_values; i++) {
340             GValue *value = g_value_array_get_nth(array, i);
341             PyObject *py_value = pyg_value_as_pyobject(value, TRUE);
342             PyList_Append(py_list, py_value);
343             Py_DECREF(py_value);
344             
345         }
346         g_value_array_free(array);
347     }
348     
349     return py_list;
350 }
351 %%
352 override gst_mixer_message_parse_mute_toggled noargs
353 static PyObject *
354 _wrap_gst_mixer_message_parse_mute_toggled (PyGstMiniObject * self)
355 {
356     GstMixerTrack *track;
357     gboolean mute;
358
359     if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_MUTE_TOGGLED) {
360         PyErr_SetString(PyExc_TypeError, "Message is not a mute-toggled message");
361         return NULL;
362     }
363     gst_mixer_message_parse_mute_toggled (GST_MESSAGE(self->obj), &track, &mute);
364
365     return Py_BuildValue("(OO)",
366                          pygobject_new(G_OBJECT (track)),
367                          PyBool_FromLong(mute));
368 }
369 %%
370 override gst_mixer_message_parse_record_toggled noargs
371 static PyObject *
372 _wrap_gst_mixer_message_parse_record_toggled (PyGstMiniObject * self)
373 {
374     GstMixerTrack *track;
375     gboolean record;
376
377     if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_RECORD_TOGGLED) {
378         PyErr_SetString(PyExc_TypeError, "Message is not a record-toggled message");
379         return NULL;
380     }
381     gst_mixer_message_parse_record_toggled (GST_MESSAGE(self->obj), &track, &record);
382
383     return Py_BuildValue("(OO)",
384                          pygobject_new(G_OBJECT (track)),
385                          PyBool_FromLong(record));
386 }
387 %%
388 override gst_mixer_message_parse_volume_changed noargs
389 static PyObject *
390 _wrap_gst_mixer_message_parse_volume_changed (PyGstMiniObject * self)
391 {
392     GstMixerTrack *track;
393     gint *volumes;
394     gint num_channels;
395     PyObject *pvolumes;
396     int i;
397
398     if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_VOLUME_CHANGED) {
399         PyErr_SetString(PyExc_TypeError, "Message is not a volume-changed message");
400         return NULL;
401     }
402     gst_mixer_message_parse_volume_changed (GST_MESSAGE(self->obj), &track, &volumes, &num_channels);
403
404     pvolumes = PyList_New (num_channels);
405
406     for (i = 0; i < num_channels; ++i) {
407         PyList_SET_ITEM (pvolumes, i, PyInt_FromLong (volumes[i]));
408     }
409     g_free (volumes);
410
411     return Py_BuildValue("(OOi)",
412                          pygobject_new(G_OBJECT (track)),
413                          pvolumes, num_channels);
414 }
415 %%
416 override gst_mixer_message_parse_option_changed noargs
417 static PyObject *
418 _wrap_gst_mixer_message_parse_option_changed (PyGstMiniObject * self)
419 {
420     GstMixerOptions *options;
421     const gchar *value = NULL;
422
423     if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_OPTION_CHANGED) {
424         PyErr_SetString(PyExc_TypeError, "Message is not a option-changed message");
425         return NULL;
426     }
427     gst_mixer_message_parse_option_changed (GST_MESSAGE(self->obj), &options, &value);
428
429     return Py_BuildValue("(Os)",
430                          pygobject_new(G_OBJECT (options)),
431                          value);
432 }
433 %%
434 override gst_video_orientation_get_hflip noargs
435 static PyObject *
436 _wrap_gst_video_orientation_get_hflip (PyGObject * self)
437 {
438     gboolean flip, res;
439
440     res = gst_video_orientation_get_hflip (GST_VIDEO_ORIENTATION (self->obj), &flip);
441
442     return Py_BuildValue("(OO)",
443                          PyBool_FromLong(res),
444                          PyBool_FromLong(flip));
445 }
446 %%
447 override gst_video_orientation_get_vflip noargs
448 static PyObject *
449 _wrap_gst_video_orientation_get_vflip (PyGObject * self)
450 {
451     gboolean flip, res;
452
453     res = gst_video_orientation_get_vflip (GST_VIDEO_ORIENTATION (self->obj), &flip);
454
455     return Py_BuildValue("(OO)",
456                          PyBool_FromLong(res),
457                          PyBool_FromLong(flip));
458 }
459 %%
460 override gst_video_orientation_get_hcenter noargs
461 static PyObject *
462 _wrap_gst_video_orientation_get_hcenter (PyGObject * self)
463 {
464     gboolean res;
465     gint center;
466
467     res = gst_video_orientation_get_hcenter (GST_VIDEO_ORIENTATION (self->obj), &center);
468
469     return Py_BuildValue("(Oi)",
470                          PyBool_FromLong(res),
471                          center);
472 }
473 %%
474 override gst_video_orientation_get_vcenter noargs
475 static PyObject *
476 _wrap_gst_video_orientation_get_vcenter (PyGObject * self)
477 {
478     gboolean res;
479     gint center;
480
481     res = gst_video_orientation_get_vcenter (GST_VIDEO_ORIENTATION (self->obj), &center);
482
483     return Py_BuildValue("(Oi)",
484                          PyBool_FromLong(res),
485                          center);
486 }