1
/* -*- Mode: C; ; c-file-style: "python" -*- */
3
* Copyright (C) 2005 Edward Hervey
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: Johan Dahlin <johan@gnome.org>
24
override-slot GstMessage.tp_repr
26
_wrap_gst_message_tp_repr (PyGstMiniObject *self)
29
gchar *repr, *structure_str, *src_str;
33
msg = GST_MESSAGE (self->obj);
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)");
40
repr = g_strdup_printf ("<gst.Message %s from %s at %p>",
41
structure_str, src_str, msg);
43
g_free (structure_str);
45
ret = PyString_FromStringAndSize(repr, strlen (repr));
52
override gst_message_parse_state_changed noargs
54
_wrap_gst_message_parse_state_changed (PyGstMiniObject *self)
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");
66
gst_message_parse_state_changed (GST_MESSAGE(self->obj), &old, &new, &pen);
67
/* Return this as a tuple */
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));
75
override gst_message_parse_segment_start noargs
77
_wrap_gst_message_parse_segment_start (PyGstMiniObject *self)
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");
88
gst_message_parse_segment_start (GST_MESSAGE(self->obj), &format, &position);
90
/* Return this as a tuple */
92
PyList_SET_ITEM(ret, 0, pyg_enum_from_gtype(GST_TYPE_FORMAT, format));
93
PyList_SET_ITEM(ret, 1, PyLong_FromLongLong(position));
99
override gst_message_parse_segment_done noargs
101
_wrap_gst_message_parse_segment_done (PyGstMiniObject *self)
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");
112
gst_message_parse_segment_done (GST_MESSAGE(self->obj), &format, &position);
114
/* Return this as a tuple */
116
PyList_SET_ITEM(ret, 0, pyg_enum_from_gtype(GST_TYPE_FORMAT, format));
117
PyList_SET_ITEM(ret, 1, PyLong_FromLongLong(position));
123
override gst_message_parse_error noargs
125
_wrap_gst_message_parse_error (PyGstMiniObject *self)
128
GError *error = NULL;
131
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_ERROR) {
132
PyErr_SetString(PyExc_TypeError, "Message is not an error message");
136
gst_message_parse_error (GST_MESSAGE(self->obj), &error, &debug);
139
PyList_SetItem(ret, 0, pyg_boxed_new (GST_TYPE_G_ERROR, error, TRUE, TRUE));
141
g_error_free (error);
143
PyList_SetItem(ret, 1, PyString_FromString(debug));
146
PyList_SetItem(ret, 1, Py_None);
152
override gst_message_parse_warning noargs
154
_wrap_gst_message_parse_warning (PyGstMiniObject *self)
160
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_WARNING) {
161
PyErr_SetString(PyExc_TypeError, "Message is not an warning message");
165
gst_message_parse_warning (GST_MESSAGE(self->obj), &warning, &debug);
168
PyList_SetItem(ret, 0, pyg_boxed_new (GST_TYPE_G_ERROR, warning, TRUE, TRUE));
170
PyList_Append(ret, PyString_FromString(debug));
175
override gst_message_parse_tag noargs
177
_wrap_gst_message_parse_tag (PyGstMiniObject *self)
182
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_TAG) {
183
PyErr_SetString(PyExc_TypeError, "Message is not an Tag message");
187
gst_message_parse_tag (GST_MESSAGE(self->obj), &taglist);
189
ret = pyg_boxed_new (GST_TYPE_TAG_LIST, taglist, TRUE, TRUE);
190
gst_tag_list_free (taglist);
194
override gst_message_parse_clock_provide noargs
196
_wrap_gst_message_parse_clock_provide (PyGstMiniObject *self)
202
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_CLOCK_PROVIDE) {
203
PyErr_SetString(PyExc_TypeError, "Message is not a 'clock provide' message");
207
gst_message_parse_clock_provide (GST_MESSAGE(self->obj), &clock, &ready);
210
PyList_SET_ITEM(ret, 0, pygstobject_new(G_OBJECT (clock)));
211
PyList_SET_ITEM(ret, 1, PyBool_FromLong(ready));
216
override gst_message_parse_clock_lost noargs
218
_wrap_gst_message_parse_clock_lost (PyGstMiniObject *self)
222
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_CLOCK_LOST) {
223
PyErr_SetString(PyExc_TypeError, "Message is not a 'clock lost' message");
227
gst_message_parse_clock_lost (GST_MESSAGE(self->obj), &clock);
229
return pygstobject_new(G_OBJECT(clock));
232
override gst_message_parse_new_clock noargs
234
_wrap_gst_message_parse_new_clock (PyGstMiniObject *self)
238
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_NEW_CLOCK) {
239
PyErr_SetString(PyExc_TypeError, "Message is not a 'new clock' message");
243
gst_message_parse_new_clock (GST_MESSAGE(self->obj), &clock);
245
return pygstobject_new(G_OBJECT(clock));
248
override gst_message_parse_duration noargs
250
_wrap_gst_message_parse_duration (PyGstMiniObject *self)
256
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_DURATION) {
257
PyErr_SetString(PyExc_TypeError, "Message is not a 'duration' message");
261
gst_message_parse_duration (GST_MESSAGE(self->obj), &format, &duration);
264
PyList_SET_ITEM(ret, 0, pyg_enum_from_gtype (GST_TYPE_FORMAT, format));
265
PyList_SET_ITEM(ret, 1, PyLong_FromLongLong(duration));