From f1bbb486aedfd449e5f52edc1cf25ed3b6008007 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 1 Jul 2009 12:28:52 +0200 Subject: [PATCH] gst.Event: Add override for step event --- gst/gstevent.override | 24 ++++++++++++++++++++++++ testsuite/test_event.py | 15 +++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/gst/gstevent.override b/gst/gstevent.override index b2eb455..97ba7cb 100644 --- a/gst/gstevent.override +++ b/gst/gstevent.override @@ -261,3 +261,27 @@ _wrap_gst_event_new_tag(PyObject *self, PyObject *args, PyObject *kwargs) gst_mini_object_unref((GstMiniObject *)ret); return py_ret; } +%% +override gst_event_parse_step noargs +static PyObject * +_wrap_gst_event_parse_step (PyGstMiniObject * self) +{ + GstFormat format; + guint64 amount; + gdouble rate; + gboolean flush, intermediate; + + if (GST_EVENT_TYPE (self->obj) != GST_EVENT_STEP) { + PyErr_SetString(PyExc_TypeError, "Event is not a 'step' event"); + return NULL; + } + + gst_event_parse_step (GST_EVENT (self->obj), &format, &amount, &rate, + &flush, &intermediate); + + return Py_BuildValue("OKdOO", + pyg_enum_from_gtype (GST_TYPE_FORMAT, format), + amount, rate, + PyBool_FromLong(flush), + PyBool_FromLong(intermediate)); +} diff --git a/testsuite/test_event.py b/testsuite/test_event.py index 4b46dc6..6a4860d 100644 --- a/testsuite/test_event.py +++ b/testsuite/test_event.py @@ -225,5 +225,20 @@ class TestDelayedEventProbe(TestCase): # now let the buffer through return True +class TestEventCreationParsing(TestCase): + + def testEventStep(self): + if hasattr(gst.Event, "parse_step"): + e = gst.event_new_step(gst.FORMAT_TIME, 42, 1.0, True, True) + + self.assertEquals(e.type, gst.EVENT_STEP) + + fmt, amount, rate, flush, intermediate = e.parse_step() + self.assertEquals(fmt, gst.FORMAT_TIME) + self.assertEquals(amount, 42) + self.assertEquals(rate, 1.0) + self.assertEquals(flush, True) + self.assertEquals(intermediate, True) + if __name__ == "__main__": unittest.main() -- 2.7.4