gstreamer/gst/interfaces.override
Tim-Philipp Müller b769a83fb4 Don't install common.h and remove from public headers
Doesn't seem to be needed anyway. Also remove duplicate
pygobject.h include in common.h while at it.

https://bugzilla.gnome.org/show_bug.cgi?id=657435
2011-10-11 23:33:21 +01:00

486 lines
13 KiB
C

/* -*- Mode: C; c-basic-offset: 4 -*- */
/* gst-python
* Copyright (C) 2004 David I. Lehn
*
* 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.
*
* Author: David I. Lehn <dlehn@users.sourceforge.net>
*/
%%
headers
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#define NO_IMPORT_PYGOBJECT
#include "common.h"
#include "pygst.h"
#include <gst/gst.h>
#include <gst/interfaces/colorbalance.h>
#include <gst/interfaces/navigation.h>
#include <gst/interfaces/propertyprobe.h>
#include <gst/interfaces/tuner.h>
#include <gst/interfaces/mixer.h>
#include <gst/interfaces/videoorientation.h>
#ifdef HAVE_STREAM_VOLUME_INTERFACE
#include <gst/interfaces/streamvolume.h>
#endif
%%
modulename gst.interfaces
%%
import gobject.GObject as PyGObject_Type
import gst.Object as PyGstObject_Type
import gst.Structure as PyGstStructure_Type
import gst.Element as PyGstElement_Type
import gst.Query as PyGstQuery_Type
%%
include
xoverlay.override
gstversion.override
%%
ignore-glob
_*
gstinterfaces_*init
*_get_type
%%
override gst_tuner_list_channels noargs
static PyObject *
_wrap_gst_tuner_list_channels(PyGObject *self)
{
const GList *l, *list;
PyObject *py_list;
g_return_val_if_fail (GST_IS_TUNER (self->obj), PyList_New(0));
pyg_begin_allow_threads;
list = gst_tuner_list_channels(GST_TUNER(self->obj));
pyg_end_allow_threads;
py_list = PyList_New(0);
for (l = list; l; l = l->next) {
GstTunerChannel *channel = (GstTunerChannel*)l->data;
PyObject *py_channel = pygobject_new(G_OBJECT(channel));
PyList_Append(py_list, py_channel);
Py_DECREF(py_channel);
}
return py_list;
}
%%
override gst_tuner_list_norms noargs
static PyObject *
_wrap_gst_tuner_list_norms(PyGObject *self)
{
const GList *l, *list;
PyObject *py_list;
g_return_val_if_fail (GST_IS_TUNER (self->obj), PyList_New(0));
pyg_begin_allow_threads;
list = gst_tuner_list_norms(GST_TUNER(self->obj));
pyg_end_allow_threads;
py_list = PyList_New(0);
for (l = list; l; l = l->next) {
GstTunerNorm *norm = (GstTunerNorm*)l->data;
PyObject *py_norm = pygobject_new(G_OBJECT(norm));
PyList_Append(py_list, py_norm);
Py_DECREF(py_norm);
}
return py_list;
}
%%
override gst_mixer_list_tracks noargs
static PyObject *
_wrap_gst_mixer_list_tracks(PyGObject *self)
{
const GList *l, *list;
PyObject *py_list;
g_return_val_if_fail (GST_IS_MIXER (self->obj), PyList_New(0));
pyg_begin_allow_threads;
list = gst_mixer_list_tracks(GST_MIXER(self->obj));
pyg_end_allow_threads;
py_list = PyList_New(0);
for (l = list; l; l = l->next) {
GstMixerTrack *track = (GstMixerTrack*)l->data;
PyObject *py_track = pygobject_new(G_OBJECT(track));
PyList_Append(py_list, py_track);
Py_DECREF(py_track);
}
return py_list;
}
%%
override gst_color_balance_list_channels noargs
static PyObject *
_wrap_gst_color_balance_list_channels(PyGObject *self)
{
const GList *l, *list;
PyObject *py_list;
g_return_val_if_fail (GST_IS_COLOR_BALANCE (self->obj), PyList_New(0));
pyg_begin_allow_threads;
list = gst_color_balance_list_channels(GST_COLOR_BALANCE(self->obj));
pyg_end_allow_threads;
py_list = PyList_New(0);
for (l = list; l; l = l->next) {
GstColorBalanceChannel *channel = (GstColorBalanceChannel*)l->data;
PyObject *py_channel = pygobject_new(G_OBJECT(channel));
PyList_Append(py_list, py_channel);
Py_DECREF(py_channel);
}
return py_list;
}
%%
override gst_mixer_options_get_values noargs
static PyObject *
_wrap_gst_mixer_options_get_values (PyGObject *self)
{
GList *l, *list;
PyObject *py_list;
g_return_val_if_fail (GST_IS_MIXER_OPTIONS (self->obj), PyList_New(0));
pyg_begin_allow_threads;
list = gst_mixer_options_get_values (GST_MIXER_OPTIONS (self->obj));
pyg_end_allow_threads;
py_list = PyList_New(0);
for (l = list; l; l = l->next) {
gchar *value = (gchar *) l->data;
PyObject *py_string = PyString_FromString(g_strdup(value));
PyList_Append(py_list, py_string);
Py_DECREF (py_string);
}
return py_list;
}
%%
override gst_mixer_set_volume kwargs
static PyObject *
_wrap_gst_mixer_set_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "track", "volumes", NULL };
PyGObject *track;
PyObject *py_tuple;
gint *volumes = NULL;
gint channels;
int i;
PyObject *ret;
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!O:GstMixer.set_volume",
kwlist, &PyGstMixerTrack_Type, &track, &py_tuple))
return NULL;
g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
NULL);
if (channels != PyTuple_Size (py_tuple)) {
PyErr_Format (PyExc_TypeError,
"Track channel count %d != volume tuple size %d",
channels, (gint) PyTuple_Size (py_tuple));
return NULL;
}
Py_INCREF(Py_None);
ret = Py_None;
if (channels == 0)
return ret;
volumes = g_malloc (channels * sizeof (gint));
for (i = 0; i < channels; ++i) {
volumes[i] = PyInt_AsLong (PyTuple_GET_ITEM (py_tuple, i));
}
pyg_begin_allow_threads;
gst_mixer_set_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
volumes);
pyg_end_allow_threads;
g_free (volumes);
return ret;
}
%%
override gst_mixer_get_volume kwargs
static PyObject *
_wrap_gst_mixer_get_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "track", NULL };
PyGObject *track;
PyObject *py_tuple;
gint *volumes = NULL;
gint channels;
int i;
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!:GstMixer.get_volume",
kwlist, &PyGstMixerTrack_Type, &track))
return NULL;
g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
NULL);
volumes = g_malloc (channels * sizeof (gint));
/* 0 channels will cause volume to be a NULL pointer, but we still want
* our (empty) tuple */
if (channels) {
pyg_begin_allow_threads;
gst_mixer_get_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
volumes);
pyg_end_allow_threads;
}
py_tuple = PyTuple_New (channels);
for (i = 0; i < channels; ++i) {
PyTuple_SET_ITEM (py_tuple, i, PyInt_FromLong (volumes[i]));
}
g_free (volumes);
return py_tuple;
}
%%
override gst_property_probe_get_property args
static PyObject *
_wrap_gst_property_probe_get_property (PyGObject *self, PyObject *args)
{
const char *name;
const GParamSpec *spec;
if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_property", &name))
return NULL;
pyg_begin_allow_threads;
spec = gst_property_probe_get_property (GST_PROPERTY_PROBE (self->obj),
name);
pyg_end_allow_threads;
if (!spec) {
PyErr_Format(PyExc_ValueError, "unknown property: %s", name);
return NULL;
}
return pyg_param_spec_new((GParamSpec*)spec);
}
%%
override gst_property_probe_get_properties noargs
static PyObject *
_wrap_gst_property_probe_get_properties (PyGObject *self)
{
const GList *l, *list;
PyObject *py_list;
g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
pyg_begin_allow_threads;
list = gst_property_probe_get_properties (GST_PROPERTY_PROBE (self->obj));
pyg_end_allow_threads;
py_list = PyList_New(0);
for (l = list; l; l = l->next) {
GParamSpec *spec = (GParamSpec*)l->data;
PyObject *py_gspec = pyg_param_spec_new((GParamSpec*)spec);
PyList_Append(py_list, py_gspec);
Py_DECREF(py_gspec);
}
return py_list;
}
%%
override gst_property_probe_get_values_name args
static PyObject *
_wrap_gst_property_probe_get_values_name (PyGObject *self, PyObject *args)
{
const char *name;
GValueArray *array;
PyObject *py_list;
int i;
g_return_val_if_fail (GST_IS_PROPERTY_PROBE (self->obj), PyList_New(0));
if (!PyArg_ParseTuple(args, "s:ProbeProperty.get_values_name", &name))
return NULL;
pyg_begin_allow_threads;
array = gst_property_probe_get_values_name (GST_PROPERTY_PROBE (self->obj),
name);
pyg_end_allow_threads;
py_list = PyList_New(0);
if (array) {
for (i = 0; i < array->n_values; i++) {
GValue *value = g_value_array_get_nth(array, i);
PyObject *py_value = pyg_value_as_pyobject(value, TRUE);
PyList_Append(py_list, py_value);
Py_DECREF(py_value);
}
g_value_array_free(array);
}
return py_list;
}
%%
override gst_mixer_message_parse_mute_toggled noargs
static PyObject *
_wrap_gst_mixer_message_parse_mute_toggled (PyGstMiniObject * self)
{
GstMixerTrack *track;
gboolean mute;
if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_MUTE_TOGGLED) {
PyErr_SetString(PyExc_TypeError, "Message is not a mute-toggled message");
return NULL;
}
gst_mixer_message_parse_mute_toggled (GST_MESSAGE(self->obj), &track, &mute);
return Py_BuildValue("(OO)",
pygobject_new(G_OBJECT (track)),
PyBool_FromLong(mute));
}
%%
override gst_mixer_message_parse_record_toggled noargs
static PyObject *
_wrap_gst_mixer_message_parse_record_toggled (PyGstMiniObject * self)
{
GstMixerTrack *track;
gboolean record;
if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_RECORD_TOGGLED) {
PyErr_SetString(PyExc_TypeError, "Message is not a record-toggled message");
return NULL;
}
gst_mixer_message_parse_record_toggled (GST_MESSAGE(self->obj), &track, &record);
return Py_BuildValue("(OO)",
pygobject_new(G_OBJECT (track)),
PyBool_FromLong(record));
}
%%
override gst_mixer_message_parse_volume_changed noargs
static PyObject *
_wrap_gst_mixer_message_parse_volume_changed (PyGstMiniObject * self)
{
GstMixerTrack *track;
gint *volumes;
gint num_channels;
PyObject *pvolumes;
int i;
if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_VOLUME_CHANGED) {
PyErr_SetString(PyExc_TypeError, "Message is not a volume-changed message");
return NULL;
}
gst_mixer_message_parse_volume_changed (GST_MESSAGE(self->obj), &track, &volumes, &num_channels);
pvolumes = PyList_New (num_channels);
for (i = 0; i < num_channels; ++i) {
PyList_SET_ITEM (pvolumes, i, PyInt_FromLong (volumes[i]));
}
g_free (volumes);
return Py_BuildValue("(OOi)",
pygobject_new(G_OBJECT (track)),
pvolumes, num_channels);
}
%%
override gst_mixer_message_parse_option_changed noargs
static PyObject *
_wrap_gst_mixer_message_parse_option_changed (PyGstMiniObject * self)
{
GstMixerOptions *options;
const gchar *value = NULL;
if (GST_MESSAGE(self->obj)->type != GST_MIXER_MESSAGE_OPTION_CHANGED) {
PyErr_SetString(PyExc_TypeError, "Message is not a option-changed message");
return NULL;
}
gst_mixer_message_parse_option_changed (GST_MESSAGE(self->obj), &options, &value);
return Py_BuildValue("(Os)",
pygobject_new(G_OBJECT (options)),
value);
}
%%
override gst_video_orientation_get_hflip noargs
static PyObject *
_wrap_gst_video_orientation_get_hflip (PyGObject * self)
{
gboolean flip, res;
res = gst_video_orientation_get_hflip (GST_VIDEO_ORIENTATION (self->obj), &flip);
return Py_BuildValue("(OO)",
PyBool_FromLong(res),
PyBool_FromLong(flip));
}
%%
override gst_video_orientation_get_vflip noargs
static PyObject *
_wrap_gst_video_orientation_get_vflip (PyGObject * self)
{
gboolean flip, res;
res = gst_video_orientation_get_vflip (GST_VIDEO_ORIENTATION (self->obj), &flip);
return Py_BuildValue("(OO)",
PyBool_FromLong(res),
PyBool_FromLong(flip));
}
%%
override gst_video_orientation_get_hcenter noargs
static PyObject *
_wrap_gst_video_orientation_get_hcenter (PyGObject * self)
{
gboolean res;
gint center;
res = gst_video_orientation_get_hcenter (GST_VIDEO_ORIENTATION (self->obj), &center);
return Py_BuildValue("(Oi)",
PyBool_FromLong(res),
center);
}
%%
override gst_video_orientation_get_vcenter noargs
static PyObject *
_wrap_gst_video_orientation_get_vcenter (PyGObject * self)
{
gboolean res;
gint center;
res = gst_video_orientation_get_vcenter (GST_VIDEO_ORIENTATION (self->obj), &center);
return Py_BuildValue("(Oi)",
PyBool_FromLong(res),
center);
}