~ubuntu-branches/ubuntu/precise/gst0.10-python/precise

« back to all changes in this revision

Viewing changes to gst/gstquery.override

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier
  • Date: 2006-06-25 19:37:45 UTC
  • Revision ID: james.westby@ubuntu.com-20060625193745-9yeg0wq56r24n57x
Tags: upstream-0.10.4
ImportĀ upstreamĀ versionĀ 0.10.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; ; c-file-style: "python" -*- */
 
2
/* gst-python
 
3
 * Copyright (C) 2005 Edward Hervey
 
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: Johan Dahlin <johan@gnome.org>
 
21
 */
 
22
%%
 
23
ignore
 
24
  gst_query_set_formatsv
 
25
%%
 
26
override gst_query_parse_position noargs
 
27
static PyObject *
 
28
_wrap_gst_query_parse_position (PyGstMiniObject *self)
 
29
{
 
30
        GstFormat       format;
 
31
        gint64          cur;
 
32
        PyObject        *ret;
 
33
 
 
34
        if (GST_QUERY_TYPE(self->obj) != GST_QUERY_POSITION) {
 
35
                PyErr_SetString(PyExc_TypeError, "Query is not a 'Position' query");
 
36
                return NULL;
 
37
        }
 
38
        
 
39
        gst_query_parse_position (GST_QUERY(self->obj), &format, &cur);
 
40
        
 
41
        ret = PyList_New(2);
 
42
        PyList_SetItem(ret, 0, pyg_enum_from_gtype(GST_TYPE_FORMAT, format));
 
43
        PyList_SetItem(ret, 1, PyLong_FromLongLong(cur));
 
44
 
 
45
        return ret;
 
46
}
 
47
%%
 
48
override gst_query_parse_duration noargs
 
49
static PyObject *
 
50
_wrap_gst_query_parse_duration (PyGstMiniObject *self)
 
51
{
 
52
        GstFormat       format;
 
53
        gint64          cur;
 
54
        PyObject        *ret;
 
55
 
 
56
        if (GST_QUERY_TYPE(self->obj) != GST_QUERY_DURATION) {
 
57
                PyErr_SetString(PyExc_TypeError, "Query is not a 'Duration' query");
 
58
                return NULL;
 
59
        }
 
60
        
 
61
        gst_query_parse_duration (GST_QUERY(self->obj), &format, &cur);
 
62
        
 
63
        ret = PyList_New(2);
 
64
        PyList_SetItem(ret, 0, pyg_enum_from_gtype(GST_TYPE_FORMAT, format));
 
65
        PyList_SetItem(ret, 1, PyLong_FromLongLong(cur));
 
66
 
 
67
        return ret;
 
68
}
 
69
%%
 
70
override gst_query_parse_convert noargs
 
71
static PyObject *
 
72
_wrap_gst_query_parse_convert (PyGstMiniObject *self)
 
73
{
 
74
        GstFormat       srcformat, destformat;
 
75
        gint64          srcvalue, destvalue;
 
76
        PyObject        *ret;
 
77
 
 
78
        if (GST_QUERY_TYPE(self->obj) != GST_QUERY_CONVERT) {
 
79
                PyErr_SetString(PyExc_TypeError, "Query is not a 'Convert' query");
 
80
                return NULL;
 
81
        }
 
82
 
 
83
        gst_query_parse_convert (GST_QUERY(self->obj), 
 
84
                                 &srcformat, &srcvalue,
 
85
                                 &destformat, &destvalue);
 
86
        
 
87
        ret = PyList_New(4);
 
88
        PyList_SetItem(ret, 0, pyg_enum_from_gtype(GST_TYPE_FORMAT, srcformat));
 
89
        PyList_SetItem(ret, 1, PyLong_FromLongLong(srcvalue));
 
90
        PyList_SetItem(ret, 2, pyg_enum_from_gtype(GST_TYPE_FORMAT, destformat));
 
91
        PyList_SetItem(ret, 3, PyLong_FromLongLong(destvalue));
 
92
 
 
93
        return ret;
 
94
}
 
95
%%
 
96
override gst_query_parse_segment noargs
 
97
static PyObject *
 
98
_wrap_gst_query_parse_segment (PyGstMiniObject *self)
 
99
{
 
100
        PyObject        *ret;
 
101
        gdouble         rate;
 
102
        GstFormat       format;
 
103
        gint64          start_value;
 
104
        gint64          stop_value;
 
105
 
 
106
        if (GST_QUERY_TYPE(self->obj) != GST_QUERY_SEGMENT) {
 
107
                PyErr_SetString(PyExc_TypeError, "Query is not a 'Segment' query");
 
108
                return NULL;
 
109
        }
 
110
 
 
111
        gst_query_parse_segment (GST_QUERY(self->obj),
 
112
                                 &rate, &format,
 
113
                                 &start_value, &stop_value);
 
114
        
 
115
        ret = PyList_New(4);
 
116
        PyList_SetItem (ret, 0, PyFloat_FromDouble(rate));
 
117
        PyList_SetItem (ret, 1, pyg_enum_from_gtype (GST_TYPE_FORMAT, format));
 
118
        PyList_SetItem (ret, 2, PyLong_FromUnsignedLongLong(start_value));
 
119
        PyList_SetItem (ret, 3, PyLong_FromUnsignedLongLong(stop_value));
 
120
 
 
121
        return ret;
 
122
}
 
123
%%
 
124
override gst_query_parse_seeking noargs
 
125
static PyObject *
 
126
_wrap_gst_query_parse_seeking (PyGstMiniObject *self)
 
127
{
 
128
        PyObject        *ret;
 
129
        GstFormat       format;
 
130
        gboolean        seekable;
 
131
        gint64          segment_start, segment_end;
 
132
 
 
133
        if (GST_QUERY_TYPE(self->obj) != GST_QUERY_SEEKING) {
 
134
                PyErr_SetString(PyExc_TypeError, "Query is not a 'Seeking' query");
 
135
                return NULL;
 
136
        }
 
137
 
 
138
        gst_query_parse_seeking (GST_QUERY(self->obj),
 
139
                                 &format, &seekable,
 
140
                                 &segment_start, &segment_end);
 
141
        
 
142
        ret = PyList_New(4);
 
143
        PyList_SetItem (ret, 0, pyg_enum_from_gtype (GST_TYPE_FORMAT, format));
 
144
        PyList_SetItem (ret, 1, PyBool_FromLong (seekable));
 
145
        PyList_SetItem (ret, 2, PyLong_FromLongLong(segment_start));
 
146
        PyList_SetItem (ret, 3, PyLong_FromLongLong(segment_end));
 
147
 
 
148
        return ret;
 
149
}
 
150
%%
 
151
override gst_query_parse_formats_length noargs
 
152
static PyObject *
 
153
_wrap_gst_query_parse_formats_length (PyGstMiniObject *self)
 
154
{
 
155
        PyObject        *ret;
 
156
        guint           n_formats;
 
157
        
 
158
        if (GST_QUERY_TYPE(self->obj) != GST_QUERY_FORMATS) {
 
159
                PyErr_SetString(PyExc_TypeError, "Query is not a 'Formats' query");
 
160
                return NULL;
 
161
        }
 
162
 
 
163
        gst_query_parse_formats_length (GST_QUERY (self->obj),
 
164
                                        &n_formats);
 
165
 
 
166
        ret = PyInt_FromLong(n_formats);
 
167
        
 
168
        return ret;
 
169
}
 
170
%%
 
171
override gst_query_parse_formats_nth kwargs
 
172
static PyObject *
 
173
_wrap_gst_query_parse_formats_nth (PyGstMiniObject *self, PyObject *args, PyObject *kwargs)
 
174
{
 
175
        static char *kwlist[] = {"nth", NULL};
 
176
        guint           nth;
 
177
        GstFormat       format;
 
178
 
 
179
        if (GST_QUERY_TYPE (self->obj) != GST_QUERY_FORMATS) {
 
180
                PyErr_SetString(PyExc_TypeError, "Query is not a 'Formats' query");
 
181
                return NULL;
 
182
        }
 
183
 
 
184
        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "I:GstQuery.parse_formats_nth", kwlist, &nth))
 
185
                return NULL;
 
186
 
 
187
        gst_query_parse_formats_nth (GST_QUERY (self->obj),
 
188
                                     nth, &format);
 
189
 
 
190
        return pyg_enum_from_gtype (GST_TYPE_FORMAT, format);
 
191
}
 
192
%%
 
193
override gst_query_set_formats args
 
194
static PyObject *
 
195
_wrap_gst_query_set_formats (PyGstMiniObject *self, PyObject *args)
 
196
{
 
197
        PyObject        *ret = NULL;
 
198
        gint    len, i;
 
199
        GstFormat *formats;
 
200
 
 
201
        if (GST_QUERY_TYPE (self->obj) != GST_QUERY_FORMATS) {
 
202
                PyErr_SetString(PyExc_TypeError, "Query is not a 'Formats' query");
 
203
                return NULL;
 
204
        }
 
205
 
 
206
        if ((len = PyTuple_Size(args)) < 1) {
 
207
                PyErr_SetString(PyExc_TypeError, "You need to supply at least one gst.Format");
 
208
                return NULL;
 
209
        }
 
210
 
 
211
        formats = g_new0(GstFormat, len);
 
212
 
 
213
        for (i = 0; i < len; i++) {
 
214
                if (pyg_enum_get_value(GST_TYPE_FORMAT, 
 
215
                                       PyTuple_GetItem(args, i), 
 
216
                                       (gint *) &formats[i]))
 
217
                        goto beach;
 
218
        }
 
219
 
 
220
        gst_query_set_formatsv (GST_QUERY(self->obj), len, formats);
 
221
 
 
222
        Py_INCREF(Py_None);
 
223
        ret = Py_None;
 
224
 
 
225
  beach:
 
226
        g_free(formats);
 
227
        return ret;
 
228
}