Commit 38b59633 authored by Vincent Penquerc'h's avatar Vincent Penquerc'h Committed by Sebastian Dröge

cairotextoverlay: forward new segment events from the sink to the source

Not doing so will cause buffers to be received by downstream without
a time base set.
We use the same method avimux uses to get access to the event when
collectpads got the sink event function.
parent b99f4be3
......@@ -109,6 +109,7 @@ static GstFlowReturn gst_text_overlay_collected (GstCollectPads * pads,
static void gst_text_overlay_finalize (GObject * object);
static void gst_text_overlay_font_init (GstCairoTextOverlay * overlay);
static gboolean gst_text_overlay_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_text_overlay_video_event (GstPad * pad, GstEvent * event);
/* These macros are adapted from videotestsrc.c */
#define I420_Y_ROWSTRIDE(width) (GST_ROUND_UP_4(width))
......@@ -277,6 +278,14 @@ gst_text_overlay_init (GstCairoTextOverlay * overlay,
overlay->video_collect_data = gst_collect_pads_add_pad (overlay->collect,
overlay->video_sinkpad, sizeof (GstCollectData));
/* FIXME: hacked way to override/extend the event function of
* GstCollectPads; because it sets its own event function giving the
* element no access to events. Nicked from avimux. */
overlay->collect_event =
(GstPadEventFunction) GST_PAD_EVENTFUNC (overlay->video_sinkpad);
gst_pad_set_event_function (overlay->video_sinkpad,
GST_DEBUG_FUNCPTR (gst_text_overlay_video_event));
/* text pad will be added when it is linked */
overlay->text_collect_data = NULL;
......@@ -963,6 +972,27 @@ gst_text_overlay_src_event (GstPad * pad, GstEvent * event)
return ret;
static gboolean
gst_text_overlay_video_event (GstPad * pad, GstEvent * event)
gboolean ret = FALSE;
GstCairoTextOverlay *overlay = NULL;
overlay = GST_CAIRO_TEXT_OVERLAY (gst_pad_get_parent (pad));
"received new segment on video sink pad, forwarding");
gst_event_ref (event);
gst_pad_push_event (overlay->srcpad, event);
/* now GstCollectPads can take care of the rest, e.g. EOS */
ret = overlay->collect_event (pad, event);
gst_object_unref (overlay);
return ret;
static GstStateChangeReturn
gst_text_overlay_change_state (GstElement * element, GstStateChange transition)
......@@ -48,6 +48,7 @@ struct _GstCairoTextOverlay {
GstCollectPads *collect;
GstCollectData *video_collect_data;
GstCollectData *text_collect_data;
GstPadEventFunction collect_event;
gint width;
gint height;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment