GNOME Bugzilla – Bug 726856
cairo is unusable from unbound 'draw' signal (in gstreamer)
Last modified: 2015-02-07 16:46:33 UTC
Here's an example program: from gi.repository import cairo from gi.repository import Gst print Gst.version() def draw_overlay(overlay, cr, timestamp, duration): cr.move_to(0,0) Gst.init([]) pl = Gst.parse_launch('filesrc location=test.png ! pngdec ! videoconvert ! cairooverlay name=overlay ! videoconvert ! pngenc ! filesink location=out.png') overlay = pl.get_by_name('overlay') overlay.connect('draw', draw_overlay) pl.set_state(Gst.State.PLAYING) pl.get_bus().timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.EOS | Gst.MessageType.ERROR) pl.set_state(Gst.State.NULL) When you run it, this happens: (1L, 3L, 0L, 1L) Traceback (most recent call last):
+ Trace 233382
cr.move_to(0,0)
If you remove the "import cairo" at the top then it says: AttributeError: 'gobject.GBoxed' object has no attribute 'move_to' Printing out the 'cr' from the callback shows this: <CairoContext at 0x7fa65c019400> whereas a similar Gtk program (with the 'draw' signal on a GtkWindow) shows this: <cairo.Context object at 0x7ffda9629310> GStreamer doesn't install header files for its various elements and therefore there is no corresponding .gir verbiage for the GstCairoOverlay object, which might be the source of this problem. Gtk's .gir file has this bit, meanwhile: <glib:signal name="draw" when="last" version="3.0"> <doc xml:space="preserve"> --snip-- </doc> <return-value transfer-ownership="none"> <doc xml:space="preserve">%TRUE to stop other handlers from being invoked for the event. % %FALSE to propagate the event further.</doc> <type name="gboolean" c:type="gboolean"/> </return-value> <parameters> <parameter name="cr" transfer-ownership="none"> <doc xml:space="preserve">the cairo context to draw to</doc> <type name="cairo.Context"/> </parameter> </parameters> </glib:signal> Both objects define their signals in similar ways in C: GtkWidget: widget_signals[DRAW] = g_signal_new (I_("draw"), G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GtkWidgetClass, draw), _gtk_boolean_handled_accumulator, NULL, gtk_widget_draw_marshaller, G_TYPE_BOOLEAN, 1, CAIRO_GOBJECT_TYPE_CONTEXT); gstreamer cairo overlay (part of gst-plugins-good): gst_cairo_overlay_signals[SIGNAL_DRAW] = g_signal_new ("draw", G_TYPE_FROM_CLASS (klass), 0, 0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 3, CAIRO_GOBJECT_TYPE_CONTEXT, G_TYPE_UINT64, G_TYPE_UINT64); ie: they are both using CAIRO_GOBJECT_TYPE_CONTEXT -- not a boxed type. I'm really not sure what's going on here but given the similar signal declarations, it seems that it is surely an issue in either gobject-introspection or pygobject -- possibly related to the lack of an explicit .gir description of the GstCairoOverlay object.
*** This bug has been marked as a duplicate of bug 694604 ***
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]