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

« back to all changes in this revision

Viewing changes to gst/gstmessage.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
%%
 
24
override-slot GstMessage.tp_repr
 
25
static PyObject *
 
26
_wrap_gst_message_tp_repr (PyGstMiniObject *self)
 
27
{
 
28
    GstMessage *msg;
 
29
    gchar *repr, *structure_str, *src_str;
 
30
    PyObject *ret;
 
31
 
 
32
    g_assert (self);
 
33
    msg = GST_MESSAGE (self->obj);
 
34
    g_assert (msg);
 
35
 
 
36
    structure_str = msg->structure ? gst_structure_to_string (msg->structure)
 
37
        : g_strdup ("(none)");
 
38
    src_str = msg->src ? gst_object_get_name (msg->src) : g_strdup ("(no src)");
 
39
 
 
40
    repr = g_strdup_printf ("<gst.Message %s from %s at %p>",
 
41
        structure_str, src_str, msg);
 
42
    g_free (src_str);
 
43
    g_free (structure_str);
 
44
 
 
45
    ret = PyString_FromStringAndSize(repr, strlen (repr));
 
46
    g_free (repr);
 
47
 
 
48
    return ret;
 
49
}
 
50
 
 
51
%%
 
52
override gst_message_parse_state_changed noargs
 
53
static PyObject *
 
54
_wrap_gst_message_parse_state_changed (PyGstMiniObject *self)
 
55
{
 
56
  GstState      old;
 
57
  GstState      new;
 
58
  GstState      pen;
 
59
  PyObject      *ret;
 
60
 
 
61
  /* Should raise an exception if it's not a state-changed message */
 
62
  if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_STATE_CHANGED) {
 
63
          PyErr_SetString(PyExc_TypeError, "Message is not a state-changed message");
 
64
          return NULL;
 
65
  }
 
66
  gst_message_parse_state_changed (GST_MESSAGE(self->obj), &old, &new, &pen);
 
67
  /* Return this as a tuple */
 
68
  ret = PyList_New(3);
 
69
  PyList_SET_ITEM(ret, 0, pyg_enum_from_gtype(GST_TYPE_STATE, old));
 
70
  PyList_SET_ITEM(ret, 1, pyg_enum_from_gtype(GST_TYPE_STATE, new));
 
71
  PyList_SET_ITEM(ret, 2, pyg_enum_from_gtype(GST_TYPE_STATE, pen));
 
72
  return ret;
 
73
}
 
74
%%
 
75
override gst_message_parse_segment_start noargs
 
76
static PyObject *
 
77
_wrap_gst_message_parse_segment_start (PyGstMiniObject *self)
 
78
{
 
79
  gint64                position;
 
80
  GstFormat             format;
 
81
  PyObject              *ret;
 
82
 
 
83
  /* Should raise an exception if it's not a segment start message */
 
84
  if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_SEGMENT_START) {
 
85
          PyErr_SetString(PyExc_TypeError, "Message is not a segment start message");
 
86
          return NULL;
 
87
  }
 
88
  gst_message_parse_segment_start (GST_MESSAGE(self->obj), &format, &position);
 
89
 
 
90
  /* Return this as a tuple */
 
91
  ret = PyList_New(2);
 
92
  PyList_SET_ITEM(ret, 0, pyg_enum_from_gtype(GST_TYPE_FORMAT, format));
 
93
  PyList_SET_ITEM(ret, 1, PyLong_FromLongLong(position));
 
94
 
 
95
  return ret;
 
96
}
 
97
 
 
98
%%
 
99
override gst_message_parse_segment_done noargs
 
100
static PyObject *
 
101
_wrap_gst_message_parse_segment_done (PyGstMiniObject *self)
 
102
{
 
103
  gint64                position;
 
104
  GstFormat             format;
 
105
  PyObject              *ret;
 
106
 
 
107
  /* Should raise an exception if it's not a segment done message */
 
108
  if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_SEGMENT_DONE) {
 
109
          PyErr_SetString(PyExc_TypeError, "Message is not a segment done message");
 
110
          return NULL;
 
111
  }
 
112
  gst_message_parse_segment_done (GST_MESSAGE(self->obj), &format, &position);
 
113
 
 
114
  /* Return this as a tuple */
 
115
  ret = PyList_New(2);
 
116
  PyList_SET_ITEM(ret, 0, pyg_enum_from_gtype(GST_TYPE_FORMAT, format));
 
117
  PyList_SET_ITEM(ret, 1, PyLong_FromLongLong(position));
 
118
 
 
119
  return ret;
 
120
}
 
121
 
 
122
%%
 
123
override gst_message_parse_error noargs
 
124
static PyObject *
 
125
_wrap_gst_message_parse_error (PyGstMiniObject *self)
 
126
{
 
127
        PyObject        *ret;
 
128
        GError  *error = NULL;
 
129
        gchar   *debug;
 
130
        
 
131
        if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_ERROR) {
 
132
                PyErr_SetString(PyExc_TypeError, "Message is not an error message");
 
133
                return NULL;
 
134
        }
 
135
 
 
136
        gst_message_parse_error (GST_MESSAGE(self->obj), &error, &debug);
 
137
 
 
138
        ret = PyList_New(2);
 
139
        PyList_SetItem(ret, 0, pyg_boxed_new (GST_TYPE_G_ERROR, error, TRUE, TRUE));
 
140
        if (error)
 
141
                g_error_free (error);
 
142
        if (debug != NULL) {
 
143
                PyList_SetItem(ret, 1, PyString_FromString(debug));
 
144
        } else {
 
145
                Py_INCREF (Py_None);
 
146
                PyList_SetItem(ret, 1, Py_None);
 
147
        }
 
148
        g_free(debug);
 
149
        return ret;
 
150
}
 
151
%%
 
152
override gst_message_parse_warning noargs
 
153
static PyObject *
 
154
_wrap_gst_message_parse_warning (PyGstMiniObject *self)
 
155
{
 
156
        PyObject        *ret;
 
157
        GError          *warning;
 
158
        gchar   *debug;
 
159
        
 
160
        if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_WARNING) {
 
161
                PyErr_SetString(PyExc_TypeError, "Message is not an warning message");
 
162
                return NULL;
 
163
        }
 
164
 
 
165
        gst_message_parse_warning (GST_MESSAGE(self->obj), &warning, &debug);
 
166
 
 
167
        ret = PyList_New(1);
 
168
        PyList_SetItem(ret, 0, pyg_boxed_new (GST_TYPE_G_ERROR, warning, TRUE, TRUE));
 
169
        if (debug != NULL)
 
170
                PyList_Append(ret, PyString_FromString(debug));
 
171
 
 
172
        return ret;
 
173
}
 
174
%%
 
175
override gst_message_parse_tag noargs
 
176
static PyObject *
 
177
_wrap_gst_message_parse_tag (PyGstMiniObject *self)
 
178
{
 
179
        PyObject        *ret;
 
180
        GstTagList      *taglist;
 
181
        
 
182
        if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_TAG) {
 
183
                PyErr_SetString(PyExc_TypeError, "Message is not an Tag message");
 
184
                return NULL;
 
185
        }
 
186
 
 
187
        gst_message_parse_tag (GST_MESSAGE(self->obj), &taglist);
 
188
 
 
189
        ret = pyg_boxed_new (GST_TYPE_TAG_LIST, taglist, TRUE, TRUE);
 
190
        gst_tag_list_free (taglist);
 
191
        return ret;
 
192
}
 
193
%%
 
194
override gst_message_parse_clock_provide noargs
 
195
static PyObject *
 
196
_wrap_gst_message_parse_clock_provide (PyGstMiniObject *self)
 
197
{
 
198
  GstClock      *clock;
 
199
  gboolean      ready;
 
200
  PyObject      *ret;
 
201
 
 
202
  if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_CLOCK_PROVIDE) {
 
203
          PyErr_SetString(PyExc_TypeError, "Message is not a 'clock provide' message");
 
204
          return NULL;
 
205
  }
 
206
 
 
207
  gst_message_parse_clock_provide (GST_MESSAGE(self->obj), &clock, &ready);
 
208
 
 
209
  ret = PyList_New(2);
 
210
  PyList_SET_ITEM(ret, 0, pygstobject_new(G_OBJECT (clock)));
 
211
  PyList_SET_ITEM(ret, 1, PyBool_FromLong(ready));
 
212
 
 
213
  return ret;
 
214
}
 
215
%%
 
216
override gst_message_parse_clock_lost noargs
 
217
static PyObject *
 
218
_wrap_gst_message_parse_clock_lost (PyGstMiniObject *self)
 
219
{
 
220
  GstClock      *clock;
 
221
 
 
222
  if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_CLOCK_LOST) {
 
223
          PyErr_SetString(PyExc_TypeError, "Message is not a 'clock lost' message");
 
224
          return NULL;
 
225
  }
 
226
 
 
227
  gst_message_parse_clock_lost (GST_MESSAGE(self->obj), &clock);
 
228
 
 
229
  return pygstobject_new(G_OBJECT(clock));
 
230
}
 
231
%%
 
232
override gst_message_parse_new_clock noargs
 
233
static PyObject *
 
234
_wrap_gst_message_parse_new_clock (PyGstMiniObject *self)
 
235
{
 
236
  GstClock      *clock;
 
237
 
 
238
  if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_NEW_CLOCK) {
 
239
          PyErr_SetString(PyExc_TypeError, "Message is not a 'new clock' message");
 
240
          return NULL;
 
241
  }
 
242
 
 
243
  gst_message_parse_new_clock (GST_MESSAGE(self->obj), &clock);
 
244
 
 
245
  return pygstobject_new(G_OBJECT(clock));
 
246
}
 
247
%%
 
248
override gst_message_parse_duration noargs
 
249
static PyObject *
 
250
_wrap_gst_message_parse_duration (PyGstMiniObject *self)
 
251
{
 
252
  GstFormat     format;
 
253
  gint64        duration;
 
254
  PyObject      *ret;
 
255
 
 
256
  if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_DURATION) {
 
257
          PyErr_SetString(PyExc_TypeError, "Message is not a 'duration' message");
 
258
          return NULL;
 
259
  }
 
260
 
 
261
  gst_message_parse_duration (GST_MESSAGE(self->obj), &format, &duration);
 
262
 
 
263
  ret = PyList_New(2);
 
264
  PyList_SET_ITEM(ret, 0, pyg_enum_from_gtype (GST_TYPE_FORMAT, format));
 
265
  PyList_SET_ITEM(ret, 1, PyLong_FromLongLong(duration));
 
266
 
 
267
  return ret;
 
268
}