mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
pad: add gst_pad_store_sticky_event()
Rewire some internal functions and expose a new gst_pad_store_sticky_event() function. API: gst_pad_store_sticky_event()
This commit is contained in:
parent
1457c9c499
commit
3e1a430c22
3 changed files with 67 additions and 26 deletions
91
gst/gstpad.c
91
gst/gstpad.c
|
@ -4375,8 +4375,8 @@ probe_stopped_unref:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* must be called with pad object lock */
|
/* must be called with pad object lock */
|
||||||
static gboolean
|
static GstFlowReturn
|
||||||
gst_pad_store_sticky_event (GstPad * pad, GstEvent * event)
|
store_sticky_event (GstPad * pad, GstEvent * event)
|
||||||
{
|
{
|
||||||
guint i, len;
|
guint i, len;
|
||||||
GstEventType type;
|
GstEventType type;
|
||||||
|
@ -4384,6 +4384,12 @@ gst_pad_store_sticky_event (GstPad * pad, GstEvent * event)
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
const gchar *name = NULL;
|
const gchar *name = NULL;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
|
||||||
|
goto flushed;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (GST_PAD_IS_EOS (pad)))
|
||||||
|
goto eos;
|
||||||
|
|
||||||
type = GST_EVENT_TYPE (event);
|
type = GST_EVENT_TYPE (event);
|
||||||
if (type & GST_EVENT_TYPE_STICKY_MULTI)
|
if (type & GST_EVENT_TYPE_STICKY_MULTI)
|
||||||
name = gst_structure_get_name (gst_event_get_structure (event));
|
name = gst_structure_get_name (gst_event_get_structure (event));
|
||||||
|
@ -4435,7 +4441,49 @@ gst_pad_store_sticky_event (GstPad * pad, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
if (type == GST_EVENT_EOS)
|
||||||
|
GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_EOS);
|
||||||
|
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
flushed:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (pad, "pad is flushing");
|
||||||
|
return GST_FLOW_FLUSHING;
|
||||||
|
}
|
||||||
|
eos:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (pad, "pad is EOS");
|
||||||
|
return GST_FLOW_EOS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_pad_store_sticky_event:
|
||||||
|
* @pad: a #GstPad
|
||||||
|
* @event: a #GstEvent
|
||||||
|
*
|
||||||
|
* Store the sticky @event on @pad
|
||||||
|
*
|
||||||
|
* Returns: #GST_FLOW_OK on success, #GST_FLOW_FLUSHING when the pad
|
||||||
|
* was flushing or #GST_FLOW_EOS when the pad was EOS.
|
||||||
|
*
|
||||||
|
* Since: 1.2
|
||||||
|
*/
|
||||||
|
GstFlowReturn
|
||||||
|
gst_pad_store_sticky_event (GstPad * pad, GstEvent * event)
|
||||||
|
{
|
||||||
|
GstFlowReturn ret;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
|
||||||
|
g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (pad);
|
||||||
|
ret = store_sticky_event (pad, event);
|
||||||
|
GST_OBJECT_UNLOCK (pad);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* should be called with pad LOCK */
|
/* should be called with pad LOCK */
|
||||||
|
@ -4615,21 +4663,17 @@ gst_pad_push_event (GstPad * pad, GstEvent * event)
|
||||||
serialized = GST_EVENT_IS_SERIALIZED (event);
|
serialized = GST_EVENT_IS_SERIALIZED (event);
|
||||||
|
|
||||||
if (sticky) {
|
if (sticky) {
|
||||||
/* can't store on flushing pads */
|
|
||||||
if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
|
|
||||||
goto flushed;
|
|
||||||
|
|
||||||
if (G_UNLIKELY (GST_PAD_IS_EOS (pad)))
|
|
||||||
goto eos;
|
|
||||||
|
|
||||||
/* srcpad sticky events are stored immediately, the received flag is set
|
/* srcpad sticky events are stored immediately, the received flag is set
|
||||||
* to FALSE and will be set to TRUE when we can successfully push the
|
* to FALSE and will be set to TRUE when we can successfully push the
|
||||||
* event to the peer pad */
|
* event to the peer pad */
|
||||||
if (gst_pad_store_sticky_event (pad, event)) {
|
switch (store_sticky_event (pad, event)) {
|
||||||
GST_DEBUG_OBJECT (pad, "event %s updated", GST_EVENT_TYPE_NAME (event));
|
case GST_FLOW_FLUSHING:
|
||||||
|
goto flushed;
|
||||||
|
case GST_FLOW_EOS:
|
||||||
|
goto eos;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS)
|
|
||||||
GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_EOS);
|
|
||||||
}
|
}
|
||||||
if (GST_PAD_IS_SRC (pad) && (serialized || sticky)) {
|
if (GST_PAD_IS_SRC (pad) && (serialized || sticky)) {
|
||||||
/* all serialized or sticky events on the srcpad trigger push of
|
/* all serialized or sticky events on the srcpad trigger push of
|
||||||
|
@ -4841,21 +4885,16 @@ gst_pad_send_event_unchecked (GstPad * pad, GstEvent * event,
|
||||||
if (sticky) {
|
if (sticky) {
|
||||||
if (ret == GST_FLOW_OK) {
|
if (ret == GST_FLOW_OK) {
|
||||||
GST_OBJECT_LOCK (pad);
|
GST_OBJECT_LOCK (pad);
|
||||||
/* can't store on flushing pads */
|
|
||||||
if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
|
|
||||||
goto flushing;
|
|
||||||
|
|
||||||
if (G_UNLIKELY (GST_PAD_IS_EOS (pad)))
|
|
||||||
goto eos;
|
|
||||||
|
|
||||||
/* after the event function accepted the event, we can store the sticky
|
/* after the event function accepted the event, we can store the sticky
|
||||||
* event on the pad */
|
* event on the pad */
|
||||||
if (gst_pad_store_sticky_event (pad, event)) {
|
switch (store_sticky_event (pad, event)) {
|
||||||
GST_DEBUG_OBJECT (pad, "event %s updated", GST_EVENT_TYPE_NAME (event));
|
case GST_FLOW_FLUSHING:
|
||||||
|
goto flushing;
|
||||||
|
case GST_FLOW_EOS:
|
||||||
|
goto eos;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (event_type == GST_EVENT_EOS)
|
|
||||||
GST_OBJECT_FLAG_SET (pad, GST_PAD_FLAG_EOS);
|
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (pad);
|
GST_OBJECT_UNLOCK (pad);
|
||||||
}
|
}
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
|
|
|
@ -880,6 +880,7 @@ gpointer gst_pad_get_element_private (GstPad *pad);
|
||||||
|
|
||||||
GstPadTemplate* gst_pad_get_pad_template (GstPad *pad);
|
GstPadTemplate* gst_pad_get_pad_template (GstPad *pad);
|
||||||
|
|
||||||
|
GstFlowReturn gst_pad_store_sticky_event (GstPad *pad, GstEvent *event);
|
||||||
GstEvent* gst_pad_get_sticky_event (GstPad *pad, GstEventType event_type,
|
GstEvent* gst_pad_get_sticky_event (GstPad *pad, GstEventType event_type,
|
||||||
guint idx);
|
guint idx);
|
||||||
void gst_pad_sticky_events_foreach (GstPad *pad, GstPadStickyEventsForeachFunction foreach_func, gpointer user_data);
|
void gst_pad_sticky_events_foreach (GstPad *pad, GstPadStickyEventsForeachFunction foreach_func, gpointer user_data);
|
||||||
|
|
|
@ -795,6 +795,7 @@ EXPORTS
|
||||||
gst_pad_start_task
|
gst_pad_start_task
|
||||||
gst_pad_sticky_events_foreach
|
gst_pad_sticky_events_foreach
|
||||||
gst_pad_stop_task
|
gst_pad_stop_task
|
||||||
|
gst_pad_store_sticky_event
|
||||||
gst_pad_template_flags_get_type
|
gst_pad_template_flags_get_type
|
||||||
gst_pad_template_get_caps
|
gst_pad_template_get_caps
|
||||||
gst_pad_template_get_type
|
gst_pad_template_get_type
|
||||||
|
|
Loading…
Reference in a new issue