mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-06 01:19:38 +00:00
ebed604ed8
Original commit message from CVS: * gst/gstelement.override: * gst/gstevent.override: * gst/gstmessage.override: * gst/gstquery.override: Repeat 100 times : "I shouldn't commit patches without checking them thoroughly, especially if they come from someone I trust". Fix the broken Py_BuildValue.
252 lines
7 KiB
C
252 lines
7 KiB
C
/* -*- Mode: C; ; c-file-style: "python" -*- */
|
|
/* gst-python
|
|
* Copyright (C) 2005 Edward Hervey
|
|
*
|
|
* 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: Johan Dahlin <johan@gnome.org>
|
|
*/
|
|
|
|
%%
|
|
override-slot GstMessage.tp_repr
|
|
static PyObject *
|
|
_wrap_gst_message_tp_repr (PyGstMiniObject *self)
|
|
{
|
|
GstMessage *msg;
|
|
gchar *repr, *structure_str, *src_str;
|
|
PyObject *ret;
|
|
|
|
g_assert (self);
|
|
msg = GST_MESSAGE (self->obj);
|
|
g_assert (msg);
|
|
|
|
structure_str = msg->structure ? gst_structure_to_string (msg->structure)
|
|
: g_strdup ("(none)");
|
|
src_str = msg->src ? gst_object_get_name (msg->src) : g_strdup ("(no src)");
|
|
|
|
repr = g_strdup_printf ("<gst.Message %s from %s at %p>",
|
|
structure_str, src_str, msg);
|
|
g_free (src_str);
|
|
g_free (structure_str);
|
|
|
|
ret = PyString_FromStringAndSize(repr, strlen (repr));
|
|
g_free (repr);
|
|
|
|
return ret;
|
|
}
|
|
|
|
%%
|
|
override gst_message_parse_state_changed noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_state_changed (PyGstMiniObject *self)
|
|
{
|
|
GstState old;
|
|
GstState new;
|
|
GstState pen;
|
|
|
|
/* Should raise an exception if it's not a state-changed message */
|
|
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_STATE_CHANGED) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not a state-changed message");
|
|
return NULL;
|
|
}
|
|
gst_message_parse_state_changed (GST_MESSAGE(self->obj), &old, &new, &pen);
|
|
|
|
return Py_BuildValue("[OOO]",
|
|
pyg_enum_from_gtype(GST_TYPE_STATE, old),
|
|
pyg_enum_from_gtype(GST_TYPE_STATE, new),
|
|
pyg_enum_from_gtype(GST_TYPE_STATE, pen));
|
|
}
|
|
%%
|
|
override gst_message_parse_segment_start noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_segment_start (PyGstMiniObject *self)
|
|
{
|
|
gint64 position;
|
|
GstFormat format;
|
|
|
|
/* Should raise an exception if it's not a segment start message */
|
|
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_SEGMENT_START) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not a segment start message");
|
|
return NULL;
|
|
}
|
|
gst_message_parse_segment_start (GST_MESSAGE(self->obj), &format, &position);
|
|
|
|
return Py_BuildValue("(OL)",
|
|
pyg_enum_from_gtype(GST_TYPE_FORMAT, format),
|
|
position);
|
|
}
|
|
|
|
%%
|
|
override gst_message_parse_segment_done noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_segment_done (PyGstMiniObject *self)
|
|
{
|
|
gint64 position;
|
|
GstFormat format;
|
|
|
|
/* Should raise an exception if it's not a segment done message */
|
|
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_SEGMENT_DONE) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not a segment done message");
|
|
return NULL;
|
|
}
|
|
gst_message_parse_segment_done (GST_MESSAGE(self->obj), &format, &position);
|
|
|
|
return Py_BuildValue("(OL)",
|
|
pyg_enum_from_gtype(GST_TYPE_FORMAT, format),
|
|
position);
|
|
}
|
|
|
|
%%
|
|
override gst_message_parse_error noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_error (PyGstMiniObject *self)
|
|
{
|
|
PyObject *ret;
|
|
GError *error = NULL;
|
|
gchar *debug;
|
|
|
|
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_ERROR) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not an error message");
|
|
return NULL;
|
|
}
|
|
|
|
gst_message_parse_error (GST_MESSAGE(self->obj), &error, &debug);
|
|
|
|
ret = PyList_New(2);
|
|
PyList_SetItem(ret, 0, pyg_boxed_new (GST_TYPE_G_ERROR, error, TRUE, TRUE));
|
|
if (error)
|
|
g_error_free (error);
|
|
if (debug != NULL) {
|
|
PyList_SetItem(ret, 1, PyString_FromString(debug));
|
|
} else {
|
|
Py_INCREF (Py_None);
|
|
PyList_SetItem(ret, 1, Py_None);
|
|
}
|
|
g_free(debug);
|
|
return ret;
|
|
}
|
|
%%
|
|
override gst_message_parse_warning noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_warning (PyGstMiniObject *self)
|
|
{
|
|
PyObject *ret;
|
|
GError *warning;
|
|
gchar *debug;
|
|
|
|
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_WARNING) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not an warning message");
|
|
return NULL;
|
|
}
|
|
|
|
gst_message_parse_warning (GST_MESSAGE(self->obj), &warning, &debug);
|
|
|
|
ret = PyList_New(1);
|
|
PyList_SetItem(ret, 0, pyg_boxed_new (GST_TYPE_G_ERROR, warning, TRUE, TRUE));
|
|
if (debug != NULL)
|
|
PyList_Append(ret, PyString_FromString(debug));
|
|
|
|
return ret;
|
|
}
|
|
%%
|
|
override gst_message_parse_tag noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_tag (PyGstMiniObject *self)
|
|
{
|
|
PyObject *ret;
|
|
GstTagList *taglist;
|
|
|
|
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_TAG) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not an Tag message");
|
|
return NULL;
|
|
}
|
|
|
|
gst_message_parse_tag (GST_MESSAGE(self->obj), &taglist);
|
|
|
|
ret = pyg_boxed_new (GST_TYPE_TAG_LIST, taglist, TRUE, TRUE);
|
|
gst_tag_list_free (taglist);
|
|
return ret;
|
|
}
|
|
%%
|
|
override gst_message_parse_clock_provide noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_clock_provide (PyGstMiniObject *self)
|
|
{
|
|
GstClock *clock;
|
|
gboolean ready;
|
|
|
|
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_CLOCK_PROVIDE) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not a 'clock provide' message");
|
|
return NULL;
|
|
}
|
|
|
|
gst_message_parse_clock_provide (GST_MESSAGE(self->obj), &clock, &ready);
|
|
|
|
return Py_BuildValue("(OO)",
|
|
pygobject_new(G_OBJECT (clock)),
|
|
PyBool_FromLong(ready));
|
|
}
|
|
%%
|
|
override gst_message_parse_clock_lost noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_clock_lost (PyGstMiniObject *self)
|
|
{
|
|
GstClock *clock;
|
|
|
|
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_CLOCK_LOST) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not a 'clock lost' message");
|
|
return NULL;
|
|
}
|
|
|
|
gst_message_parse_clock_lost (GST_MESSAGE(self->obj), &clock);
|
|
|
|
return pygobject_new(G_OBJECT(clock));
|
|
}
|
|
%%
|
|
override gst_message_parse_new_clock noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_new_clock (PyGstMiniObject *self)
|
|
{
|
|
GstClock *clock;
|
|
|
|
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_NEW_CLOCK) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not a 'new clock' message");
|
|
return NULL;
|
|
}
|
|
|
|
gst_message_parse_new_clock (GST_MESSAGE(self->obj), &clock);
|
|
|
|
return pygobject_new(G_OBJECT(clock));
|
|
}
|
|
%%
|
|
override gst_message_parse_duration noargs
|
|
static PyObject *
|
|
_wrap_gst_message_parse_duration (PyGstMiniObject *self)
|
|
{
|
|
GstFormat format;
|
|
gint64 duration;
|
|
|
|
if (GST_MESSAGE(self->obj)->type != GST_MESSAGE_DURATION) {
|
|
PyErr_SetString(PyExc_TypeError, "Message is not a 'duration' message");
|
|
return NULL;
|
|
}
|
|
|
|
gst_message_parse_duration (GST_MESSAGE(self->obj), &format, &duration);
|
|
|
|
return Py_BuildValue("(OL)",
|
|
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
|
|
duration);
|
|
}
|