diff --git a/gst/gstpad.c b/gst/gstpad.c index 8b0242f4ee..5938744c1a 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -4875,6 +4875,39 @@ gst_pad_get_element_private (GstPad * pad) return pad->element_private; } +/** + * gst_pad_get_sticky_event: + * @pad: the #GstPad to get the event from. + * @event_type: the #GstEventType that should be retrieved. + * @active: If only active events should be retrieved + * + * Returns a new reference of the sticky event of type @event_type + * from the event. If @active is #TRUE only active events that + * were accepted downstream are returned. + * + * Returns: (transfer full): a #GstEvent of type @event_type. Unref after usage. + */ +GstEvent * +gst_pad_get_sticky_event (GstPad * pad, GstEventType event_type, + gboolean active) +{ + GstEvent *event = NULL; + guint idx; + + g_return_val_if_fail (GST_IS_PAD (pad), NULL); + g_return_val_if_fail ((event_type & GST_EVENT_TYPE_STICKY) != 0, NULL); + + idx = GST_EVENT_STICKY_IDX_TYPE (event_type); + + if (!active || pad->priv->events[idx].active) { + if ((event = pad->priv->events[idx].event)) { + gst_event_ref (event); + } + } + + return event; +} + static void do_stream_status (GstPad * pad, GstStreamStatusType type, GThread * thread, GstTask * task) diff --git a/gst/gstpad.h b/gst/gstpad.h index 966b5c8260..18b7776d6f 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -818,6 +818,8 @@ gpointer gst_pad_get_element_private (GstPad *pad); GstPadTemplate* gst_pad_get_pad_template (GstPad *pad); +GstEvent* gst_pad_get_sticky_event (GstPad *pad, GstEventType event_type, gboolean active); + /* data passing setup functions */ void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate); void gst_pad_set_activatepull_function (GstPad *pad, GstPadActivateModeFunction activatepull);