gst.Message: Add overrides for new 0.10.24 messages

This commit is contained in:
Edward Hervey 2009-07-01 12:29:22 +02:00
parent f1bbb486ae
commit eb2aedc523
2 changed files with 155 additions and 0 deletions

View file

@ -323,3 +323,98 @@ _wrap_gst_message_parse_buffering (PyGstMiniObject *self)
return Py_BuildValue("i", percent);
}
%%
override gst_message_parse_tag_full noargs
static PyObject *
_wrap_gst_message_parse_tag_full (PyGstMiniObject *self)
{
GstPad *pad;
GstTagList *taglist;
PyObject *ptlist;
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_full (GST_MESSAGE (self->obj), &pad, &taglist);
ptlist = pyg_boxed_new (GST_TYPE_TAG_LIST, taglist, TRUE, TRUE);
gst_tag_list_free (taglist);
return Py_BuildValue("(OO)",
pygobject_new((GObject*) pad),
ptlist);
}
%%
override gst_message_parse_step_done noargs
static PyObject *
_wrap_gst_message_parse_step_done (PyGstMiniObject *self)
{
GstFormat format;
guint64 amount, duration;
gdouble rate;
gboolean flush, intermediate, eos;
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_STEP_DONE) {
PyErr_SetString(PyExc_TypeError, "Message is not an 'step-done' message");
return NULL;
}
gst_message_parse_step_done (GST_MESSAGE (self->obj), &format, &amount, &rate,
&flush, &intermediate, &duration, &eos);
return Py_BuildValue("OKdOOKO",
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
amount, rate,
PyBool_FromLong(flush),
PyBool_FromLong(intermediate),
duration,
PyBool_FromLong(eos));
}
%%
override gst_message_parse_step_start noargs
static PyObject *
_wrap_gst_message_parse_step_start (PyGstMiniObject *self)
{
GstFormat format;
guint64 amount;
gdouble rate;
gboolean active, flush, intermediate;
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_STEP_START) {
PyErr_SetString(PyExc_TypeError, "Message is not an 'step-start' message");
return NULL;
}
gst_message_parse_step_start (GST_MESSAGE (self->obj), &active, &format,
&amount, &rate, &flush, &intermediate);
return Py_BuildValue("OOKdOO",
PyBool_FromLong(active),
pyg_enum_from_gtype (GST_TYPE_FORMAT, format),
amount, rate,
PyBool_FromLong(flush),
PyBool_FromLong(intermediate));
}
%%
override gst_message_parse_stream_status noargs
static PyObject *
_wrap_gst_message_parse_stream_status (PyGstMiniObject *self)
{
GstStreamStatusType type;
GstElement *owner;
if (GST_MESSAGE_TYPE(self->obj) != GST_MESSAGE_STREAM_STATUS) {
PyErr_SetString(PyExc_TypeError, "Message is not an 'stream-status' message");
return NULL;
}
gst_message_parse_stream_status (GST_MESSAGE (self->obj), &type, &owner);
return Py_BuildValue("OO",
pyg_enum_from_gtype (GST_TYPE_STREAM_STATUS_TYPE, type),
pygobject_new((GObject*) owner));
}

View file

@ -105,6 +105,66 @@ class TestCreateMessages(TestCase):
self.assertEquals(t2['something'], "else")
self.assertEquals(t2['another'], 42)
def testTagFullMessage(self):
if hasattr(gst.Message, 'parse_tag_full'):
p = gst.Pad("blahblah", gst.PAD_SRC)
# Create a taglist
t = gst.TagList()
t['something'] = "else"
t['another'] = 42
# Create two messages using that same taglist
m1 = gst.message_new_tag_full(self.element, p, t)
assert m1
m2 = gst.message_new_tag_full(self.element, p, t)
assert m2
# make sure the two messages have the same taglist
p1, t1 = m1.parse_tag_full()
assert t1
keys = t1.keys()
keys.sort()
self.assertEquals(p1, p)
self.assertEquals(keys, ['another', 'something'])
self.assertEquals(t1['something'], "else")
self.assertEquals(t1['another'], 42)
p2, t2 = m2.parse_tag_full()
assert t2
keys = t2.keys()
keys.sort()
self.assertEquals(p2, p)
self.assertEquals(keys, ['another', 'something'])
self.assertEquals(t2['something'], "else")
self.assertEquals(t2['another'], 42)
def testStepStartMessage(self):
if hasattr(gst, 'message_new_step_start'):
m = gst.message_new_step_start(self.element, True,
gst.FORMAT_TIME, 42, 1.0,
True, True)
self.assertEquals(m.type, gst.MESSAGE_STEP_START)
active, format, amount, rate, flush, intermediate = m.parse_step_start()
self.assertEquals(active, True)
self.assertEquals(format, gst.FORMAT_TIME)
self.assertEquals(amount, 42)
self.assertEquals(rate, 1.0)
self.assertEquals(flush, True)
self.assertEquals(intermediate, True)
def testStepDoneMessage(self):
if hasattr(gst, 'message_new_step_done'):
m = gst.message_new_step_done(self.element, gst.FORMAT_TIME, 42,
1.0, True, True, 54, True)
self.assertEquals(m.type, gst.MESSAGE_STEP_DONE)
fmt, am, rat, flu, inter, dur, eos = m.parse_step_done()
self.assertEquals(fmt, gst.FORMAT_TIME)
self.assertEquals(am, 42)
self.assertEquals(rat, 1.0)
self.assertEquals(flu, True)
self.assertEquals(inter, True)
self.assertEquals(dur, 54)
self.assertEquals(eos, True)
if __name__ == "__main__":
unittest.main()