diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2014-07-10 12:51:22 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2014-07-21 09:35:36 +0200 |
commit | 57999c28fd7720f5f3e9b3adf55528ddad21cc9c (patch) | |
tree | bae9ea858044d594915ee16f62529b4d76a436f6 /gst/playback/gstdecodebin2.c | |
parent | 994680b04eb390a116a9b5bda2abd647df233be3 (diff) |
decodebin: Send sticky events to the new element after setting it to PAUSED
... and if this fails for whatever reason we skip the element and instead
try with the next element. This allows us to handle elements that fail
when setting caps on them by just skipping to the next alternative element.
Diffstat (limited to 'gst/playback/gstdecodebin2.c')
-rw-r--r-- | gst/playback/gstdecodebin2.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 882ef54d7..aa4be8a4d 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -1889,6 +1889,40 @@ remove_error_filter (GstDecodeBin * dbin, GstElement * element) GST_OBJECT_UNLOCK (dbin); } +typedef struct +{ + gboolean ret; + GstPad *peer; +} SendStickyEventsData; + +static gboolean +send_sticky_event (GstPad * pad, GstEvent ** event, gpointer user_data) +{ + SendStickyEventsData *data = user_data; + gboolean ret; + + ret = gst_pad_send_event (data->peer, gst_event_ref (*event)); + if (!ret) + data->ret = FALSE; + + return data->ret; +} + +static gboolean +send_sticky_events (GstDecodeBin * dbin, GstPad * pad) +{ + SendStickyEventsData data; + + data.ret = TRUE; + data.peer = gst_pad_get_peer (pad); + + gst_pad_sticky_events_foreach (pad, send_sticky_event, &data); + + gst_object_unref (data.peer); + + return data.ret; +} + /* connect_pad: * * Try to connect the given pad to an element created from one of the factories, @@ -2220,7 +2254,8 @@ connect_pad (GstDecodeBin * dbin, GstElement * src, GstDecodePad * dpad, /* Bring the element to the state of the parent */ if ((gst_element_set_state (element, - GST_STATE_PAUSED)) == GST_STATE_CHANGE_FAILURE) { + GST_STATE_PAUSED)) == GST_STATE_CHANGE_FAILURE || + !send_sticky_events (dbin, pad)) { GstDecodeElement *dtmp = NULL; GstElement *tmp = NULL; |