gst.Message: Wrap remaining parse_*() methods.

This commit is contained in:
Edward Hervey 2009-07-01 13:54:57 +02:00
parent 13d2cb2145
commit 7ad1b84f50
2 changed files with 91 additions and 0 deletions

View file

@ -418,3 +418,62 @@ _wrap_gst_message_parse_stream_status (PyGstMiniObject *self)
pyg_enum_from_gtype (GST_TYPE_STREAM_STATUS_TYPE, type),
pygobject_new((GObject*) owner));
}
%%
override gst_message_parse_structure_change noargs
static PyObject *
_wrap_gst_message_parse_structure_change (PyGstMiniObject *self)
{
GstStructureChangeType type;
GstElement *owner;
gboolean busy;
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_STRUCTURE_CHANGE) {
PyErr_SetString(PyExc_TypeError, "Message is not an 'structure_change' message");
return NULL;
}
gst_message_parse_structure_change (GST_MESSAGE (self->obj), &type, &owner, &busy);
return Py_BuildValue("OOO",
pyg_enum_from_gtype (GST_TYPE_STRUCTURE_CHANGE_TYPE, type),
pygobject_new((GObject*) owner),
PyBool_FromLong(busy));
}
%%
override gst_message_parse_request_state noargs
static PyObject *
_wrap_gst_message_parse_request_state (PyGstMiniObject *self)
{
GstState state;
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_REQUEST_STATE) {
PyErr_SetString(PyExc_TypeError, "Message is not an 'request_state' message");
return NULL;
}
gst_message_parse_request_state (GST_MESSAGE (self->obj), &state);
return pyg_enum_from_gtype(GST_TYPE_STATE, state);
}
%%
override gst_message_parse_buffering_stats noargs
static PyObject *
_wrap_gst_message_parse_buffering_stats (PyGstMiniObject *self)
{
GstBufferingMode mode;
gint avg_in, avg_out;
gint64 buffering_left;
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_BUFFERING) {
PyErr_SetString(PyExc_TypeError, "Message is not an 'buffering' message");
return NULL;
}
gst_message_parse_buffering_stats (GST_MESSAGE (self->obj), &mode, &avg_in, &avg_out,
&buffering_left);
return Py_BuildValue("OiiL",
pyg_enum_from_gtype (GST_TYPE_BUFFERING_MODE, mode),
avg_in, avg_out, buffering_left);
}

View file

@ -166,5 +166,37 @@ class TestCreateMessages(TestCase):
self.assertEquals(dur, 54)
self.assertEquals(eos, True)
def testStructureChangeMessage(self):
if hasattr(gst, 'message_new_structure_change'):
p = gst.Pad("blah", gst.PAD_SRC)
m = gst.message_new_structure_change(p,
gst.STRUCTURE_CHANGE_TYPE_PAD_LINK,
self.element, True)
self.assertEquals(m.type, gst.MESSAGE_STRUCTURE_CHANGE)
sct, owner, busy = m.parse_structure_change()
self.assertEquals(sct, gst.STRUCTURE_CHANGE_TYPE_PAD_LINK)
self.assertEquals(owner, self.element)
self.assertEquals(busy, True)
def testRequestStateMessage(self):
if hasattr(gst, 'message_new_request_state'):
m = gst.message_new_request_state(self.element, gst.STATE_NULL)
self.assertEquals(m.type, gst.MESSAGE_REQUEST_STATE)
self.assertEquals(m.parse_request_state(), gst.STATE_NULL)
def testBufferingStatsMessage(self):
if hasattr(gst.Message, 'set_buffering_stats'):
gst.debug("Creating buffering message")
m = gst.message_new_buffering(self.element, 50)
gst.debug("Setting stats")
m.set_buffering_stats(gst.BUFFERING_LIVE, 30, 1024, 123456)
self.assertEquals(m.type, gst.MESSAGE_BUFFERING)
mode, ain, aout, left = m.parse_buffering_stats()
self.assertEquals(mode, gst.BUFFERING_LIVE)
self.assertEquals(ain, 30)
self.assertEquals(aout, 1024)
self.assertEquals(left, 123456)
if __name__ == "__main__":
unittest.main()