summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2016-07-04 10:00:38 +0200
committerSebastian Dröge <sebastian@centricular.com>2016-07-25 13:12:31 +0300
commit5aba7d8bb78333cb16905df5f62dd00d3eed0805 (patch)
tree13951ca380dae9cf9ae8cec58198ed804358f2c7
parentaee7ab344450c151990f1f1f5946136124202a77 (diff)
downloadgstreamer-5aba7d8bb78333cb16905df5f62dd00d3eed0805.tar.gz
baseparse: Make sure to not create an invalid event order when generating the default CAPS event because of a GAP event
There must be a SEGMENT event before the GAP event, and SEGMENT events must come after any CAPS event. We however did not produce any CAPS yet, so we need to ensure to insert the CAPS event before the SEGMENT event into the pending events list. https://bugzilla.gnome.org/show_bug.cgi?id=766970
-rw-r--r--libs/gst/base/gstbaseparse.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
index 50499a4b14..45bc869ffc 100644
--- a/libs/gst/base/gstbaseparse.c
+++ b/libs/gst/base/gstbaseparse.c
@@ -1405,11 +1405,32 @@ gst_base_parse_sink_event_default (GstBaseParse * parse, GstEvent * event)
if (!gst_pad_has_current_caps (GST_BASE_PARSE_SRC_PAD (parse))) {
GstCaps *default_caps = NULL;
if ((default_caps = gst_base_parse_negotiate_default_caps (parse))) {
+ GList *l;
+ GstEvent *caps_event = gst_event_new_caps (default_caps);
+
GST_DEBUG_OBJECT (parse,
"Store caps event to pending list for initial pre-rolling");
- parse->priv->pending_events =
- g_list_prepend (parse->priv->pending_events,
- gst_event_new_caps (default_caps));
+
+ /* Events are in decreasing order. Go down the list until we
+ * find the first pre-CAPS event and insert our CAPS event there.
+ *
+ * There should be a SEGMENT event already, which is > CAPS */
+ for (l = parse->priv->pending_events; l; l = l->next) {
+ GstEvent *e = l->data;
+
+ if (GST_EVENT_TYPE (e) < GST_EVENT_CAPS) {
+ parse->priv->pending_events =
+ g_list_insert_before (parse->priv->pending_events, l,
+ caps_event);
+ break;
+ }
+ }
+ /* No pending event that is < CAPS, so we have to add it at the very
+ * end of the list */
+ if (!l) {
+ parse->priv->pending_events =
+ g_list_append (parse->priv->pending_events, caps_event);
+ }
gst_caps_unref (default_caps);
} else {
gst_event_unref (event);