1 /* -*- Mode: C; c-basic-offset: 4 -*- */
3 * Copyright (C) 2004 David I. Lehn
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.
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.
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.
20 * Author: David I. Lehn <dlehn@users.sourceforge.net>
28 #define NO_IMPORT_PYGOBJECT
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>
45 modulename gst.interfaces
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
62 override gst_tuner_list_channels noargs
64 _wrap_gst_tuner_list_channels(PyGObject *self)
66 const GList *l, *list;
69 g_return_val_if_fail (GST_IS_TUNER (self->obj), PyList_New(0));
71 pyg_begin_allow_threads;
72 list = gst_tuner_list_channels(GST_TUNER(self->obj));
73 pyg_end_allow_threads;
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);
86 override gst_tuner_list_norms noargs
88 _wrap_gst_tuner_list_norms(PyGObject *self)
90 const GList *l, *list;
93 g_return_val_if_fail (GST_IS_TUNER (self->obj), PyList_New(0));
95 pyg_begin_allow_threads;
96 list = gst_tuner_list_norms(GST_TUNER(self->obj));
97 pyg_end_allow_threads;
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);
110 override gst_mixer_list_tracks noargs
112 _wrap_gst_mixer_list_tracks(PyGObject *self)
114 const GList *l, *list;
117 g_return_val_if_fail (GST_IS_MIXER (self->obj), PyList_New(0));
119 pyg_begin_allow_threads;
120 list = gst_mixer_list_tracks(GST_MIXER(self->obj));
121 pyg_end_allow_threads;
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);
134 override gst_color_balance_list_channels noargs
136 _wrap_gst_color_balance_list_channels(PyGObject *self)
138 const GList *l, *list;
141 g_return_val_if_fail (GST_IS_COLOR_BALANCE (self->obj), PyList_New(0));
143 pyg_begin_allow_threads;
144 list = gst_color_balance_list_channels(GST_COLOR_BALANCE(self->obj));
145 pyg_end_allow_threads;
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);
158 override gst_mixer_options_get_values noargs
160 _wrap_gst_mixer_options_get_values (PyGObject *self)
165 g_return_val_if_fail (GST_IS_MIXER_OPTIONS (self->obj), PyList_New(0));
167 pyg_begin_allow_threads;
168 list = gst_mixer_options_get_values (GST_MIXER_OPTIONS (self->obj));
169 pyg_end_allow_threads;
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);
183 override gst_mixer_set_volume kwargs
185 _wrap_gst_mixer_set_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
187 static char *kwlist[] = { "track", "volumes", NULL };
190 gint *volumes = NULL;
195 if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!O:GstMixer.set_volume",
196 kwlist, &PyGstMixerTrack_Type, &track, &py_tuple))
199 g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
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));
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));
220 pyg_begin_allow_threads;
221 gst_mixer_set_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
223 pyg_end_allow_threads;
231 override gst_mixer_get_volume kwargs
233 _wrap_gst_mixer_get_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
235 static char *kwlist[] = { "track", NULL };
238 gint *volumes = NULL;
242 if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!:GstMixer.get_volume",
243 kwlist, &PyGstMixerTrack_Type, &track))
246 g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
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 */
253 pyg_begin_allow_threads;
254 gst_mixer_get_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
256 pyg_end_allow_threads;
259 py_tuple = PyTuple_New (channels);
261 for (i = 0; i < channels; ++i) {
262 PyTuple_SET_ITEM (py_tuple, i, PyInt_FromLong (volumes[i]));
270 override gst_property_probe_get_property args
272 _wrap_gst_property_probe_get_property (PyGObject *self, PyObject *args)
275 const GParamSpec *spec;
277 if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_property", &name))
280 pyg_begin_allow_threads;
281 spec = gst_property_probe_get_property (GST_PROPERTY_PROBE (self->obj),
283 pyg_end_allow_threads;
286 PyErr_Format(PyExc_ValueError, "unknown property: %s", name);
290 return pyg_param_spec_new((GParamSpec*)spec);
293 override gst_property_probe_get_properties noargs
295 _wrap_gst_property_probe_get_properties (PyGObject *self)
297 const GList *l, *list;
300 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
302 pyg_begin_allow_threads;
303 list = gst_property_probe_get_properties (GST_PROPERTY_PROBE (self->obj));
304 pyg_end_allow_threads;
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);
317 override gst_property_probe_get_values_name args
319 _wrap_gst_property_probe_get_values_name (PyGObject *self, PyObject *args)
326 g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
328 if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_values_name", &name))
331 pyg_begin_allow_threads;
332 array = gst_property_probe_get_values_name (GST_PROPERTY_PROBE (self->obj),
334 pyg_end_allow_threads;
336 py_list = PyList_New(0);
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);
346 g_value_array_free(array);
352 override gst_mixer_message_parse_mute_toggled noargs
354 _wrap_gst_mixer_message_parse_mute_toggled (PyGstMiniObject * self)
356 GstMixerTrack *track;
359 if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_MUTE_TOGGLED) {
360 PyErr_SetString(PyExc_TypeError, "Message is not a mute-toggled message");
363 gst_mixer_message_parse_mute_toggled (GST_MESSAGE(self->obj), &track, &mute);
365 return Py_BuildValue("(OO)",
366 pygobject_new(G_OBJECT (track)),
367 PyBool_FromLong(mute));
370 override gst_mixer_message_parse_record_toggled noargs
372 _wrap_gst_mixer_message_parse_record_toggled (PyGstMiniObject * self)
374 GstMixerTrack *track;
377 if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_RECORD_TOGGLED) {
378 PyErr_SetString(PyExc_TypeError, "Message is not a record-toggled message");
381 gst_mixer_message_parse_record_toggled (GST_MESSAGE(self->obj), &track, &record);
383 return Py_BuildValue("(OO)",
384 pygobject_new(G_OBJECT (track)),
385 PyBool_FromLong(record));
388 override gst_mixer_message_parse_volume_changed noargs
390 _wrap_gst_mixer_message_parse_volume_changed (PyGstMiniObject * self)
392 GstMixerTrack *track;
398 if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_VOLUME_CHANGED) {
399 PyErr_SetString(PyExc_TypeError, "Message is not a volume-changed message");
402 gst_mixer_message_parse_volume_changed (GST_MESSAGE(self->obj), &track, &volumes, &num_channels);
404 pvolumes = PyList_New (num_channels);
406 for (i = 0; i < num_channels; ++i) {
407 PyList_SET_ITEM (pvolumes, i, PyInt_FromLong (volumes[i]));
411 return Py_BuildValue("(OOi)",
412 pygobject_new(G_OBJECT (track)),
413 pvolumes, num_channels);
416 override gst_mixer_message_parse_option_changed noargs
418 _wrap_gst_mixer_message_parse_option_changed (PyGstMiniObject * self)
420 GstMixerOptions *options;
421 const gchar *value = NULL;
423 if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_OPTION_CHANGED) {
424 PyErr_SetString(PyExc_TypeError, "Message is not a option-changed message");
427 gst_mixer_message_parse_option_changed (GST_MESSAGE(self->obj), &options, &value);
429 return Py_BuildValue("(Os)",
430 pygobject_new(G_OBJECT (options)),
434 override gst_video_orientation_get_hflip noargs
436 _wrap_gst_video_orientation_get_hflip (PyGObject * self)
440 res = gst_video_orientation_get_hflip (GST_VIDEO_ORIENTATION (self->obj), &flip);
442 return Py_BuildValue("(OO)",
443 PyBool_FromLong(res),
444 PyBool_FromLong(flip));
447 override gst_video_orientation_get_vflip noargs
449 _wrap_gst_video_orientation_get_vflip (PyGObject * self)
453 res = gst_video_orientation_get_vflip (GST_VIDEO_ORIENTATION (self->obj), &flip);
455 return Py_BuildValue("(OO)",
456 PyBool_FromLong(res),
457 PyBool_FromLong(flip));
460 override gst_video_orientation_get_hcenter noargs
462 _wrap_gst_video_orientation_get_hcenter (PyGObject * self)
467 res = gst_video_orientation_get_hcenter (GST_VIDEO_ORIENTATION (self->obj), ¢er);
469 return Py_BuildValue("(Oi)",
470 PyBool_FromLong(res),
474 override gst_video_orientation_get_vcenter noargs
476 _wrap_gst_video_orientation_get_vcenter (PyGObject * self)
481 res = gst_video_orientation_get_vcenter (GST_VIDEO_ORIENTATION (self->obj), ¢er);
483 return Py_BuildValue("(Oi)",
484 PyBool_FromLong(res),