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.

https://bugzilla.gnome.org/show_bug.cgi?id=640323
This commit is contained in:
Vincent Penquerc'h 2011-01-23 15:56:49 +00:00 committed by Sebastian Dröge
parent b99f4be3db
commit 38b596337f
2 changed files with 31 additions and 0 deletions

View file

@ -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));
if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
GST_DEBUG_OBJECT (overlay,
"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)
{

View file

@ -48,6 +48,7 @@ struct _GstCairoTextOverlay {
GstCollectPads *collect;
GstCollectData *video_collect_data;
GstCollectData *text_collect_data;
GstPadEventFunction collect_event;
gint width;
gint height;