From a85991eeb8eaf15b9d01f3e2013ba1f3dfef38ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 10 Sep 2012 21:39:32 +0100 Subject: [PATCH] baseparse, typefind: only activate in pull mode if upstream is seekable Upstream might support pull mode, but only sequential pulls, which isn't gonna do much for us. https://bugzilla.gnome.org/show_bug.cgi?id=634927 --- gst/gstquery.c | 10 ++++++++++ libs/gst/base/gstbaseparse.c | 7 ++++++- plugins/elements/gsttypefindelement.c | 7 ++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/gst/gstquery.c b/gst/gstquery.c index 021c527650..d29ddab8ae 100644 --- a/gst/gstquery.c +++ b/gst/gstquery.c @@ -2096,6 +2096,16 @@ gst_query_parse_nth_scheduling_mode (GstQuery * query, guint index) * * Check if @query has scheduling mode set. * + * + * + * When checking if upstream supports pull mode, it is usually not + * enough to just check for GST_PAD_MODE_PULL with this function, you + * also want to check whether the scheduling flags returned by + * gst_query_parse_scheduling() have the seeking flag set (meaning + * random access is supported, not only sequential pulls). + * + * + * * Returns: TRUE when @mode is in the list of scheduling modes. */ gboolean diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 5ce638a870..6d2f24a028 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -2966,6 +2966,7 @@ pause: static gboolean gst_base_parse_sink_activate (GstPad * sinkpad, GstObject * parent) { + GstSchedulingFlags sched_flags; GstBaseParse *parse; GstQuery *query; gboolean pull_mode; @@ -2980,7 +2981,11 @@ gst_base_parse_sink_activate (GstPad * sinkpad, GstObject * parent) goto baseparse_push; } - pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL); + gst_query_parse_scheduling (query, &sched_flags, NULL, NULL, NULL); + + pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL) + && ((sched_flags & GST_SCHEDULING_FLAG_SEEKABLE) != 0); + gst_query_unref (query); if (!pull_mode) diff --git a/plugins/elements/gsttypefindelement.c b/plugins/elements/gsttypefindelement.c index d2990261d7..33e2376ba7 100644 --- a/plugins/elements/gsttypefindelement.c +++ b/plugins/elements/gsttypefindelement.c @@ -1165,6 +1165,7 @@ gst_type_find_element_activate_sink (GstPad * pad, GstObject * parent) gboolean pull_mode; GstCaps *found_caps = NULL; GstTypeFindProbability probability = GST_TYPE_FIND_NONE; + GstSchedulingFlags sched_flags; typefind = GST_TYPE_FIND_ELEMENT (parent); @@ -1196,7 +1197,11 @@ gst_type_find_element_activate_sink (GstPad * pad, GstObject * parent) goto typefind_push; } - pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL); + gst_query_parse_scheduling (query, &sched_flags, NULL, NULL, NULL); + + pull_mode = gst_query_has_scheduling_mode (query, GST_PAD_MODE_PULL) + && ((sched_flags & GST_SCHEDULING_FLAG_SEEKABLE) != 0); + gst_query_unref (query); if (!pull_mode)