From e7ec08ad5deb915d9219be3449ac69afbafea289 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 3 Mar 2006 11:27:02 +0000 Subject: [PATCH] plugins/elements/gsttypefindelement.c: Use gst_type_find_helper_get_range() here, so we can honour the min-probabilit... Original commit message from CVS: * plugins/elements/gsttypefindelement.c: (gst_type_find_element_activate): Use gst_type_find_helper_get_range() here, so we can honour the min-probability property and also emit the signal with the correct probability of the found caps. --- ChangeLog | 8 ++++++++ plugins/elements/gsttypefindelement.c | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9173440..16acbe8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-03-03 Tim-Philipp Müller + + * plugins/elements/gsttypefindelement.c: + (gst_type_find_element_activate): + Use gst_type_find_helper_get_range() here, so we + can honour the min-probability property and also emit + the signal with the correct probability of the found caps. + 2006-03-02 Tim-Philipp Müller * docs/libs/gstreamer-libs-sections.txt: diff --git a/plugins/elements/gsttypefindelement.c b/plugins/elements/gsttypefindelement.c index f120326..99876cc 100644 --- a/plugins/elements/gsttypefindelement.c +++ b/plugins/elements/gsttypefindelement.c @@ -862,6 +862,7 @@ gst_type_find_element_activate_src_pull (GstPad * pad, gboolean active) static gboolean gst_type_find_element_activate (GstPad * pad) { + GstTypeFindProbability probability = 0; GstCaps *found_caps = NULL; GstTypeFindElement *typefind; @@ -892,8 +893,15 @@ gst_type_find_element_activate (GstPad * pad) gint64 size; GstFormat format = GST_FORMAT_BYTES; - gst_pad_query_duration (peer, &format, &size); - found_caps = gst_type_find_helper (peer, (guint64) size); + if (!gst_pad_query_duration (peer, &format, &size)) { + GST_WARNING_OBJECT (typefind, "Could not query upstream length!"); + return FALSE; + } + + found_caps = gst_type_find_helper_get_range (GST_OBJECT (peer), + (GstTypeFindHelperGetRangeFunction) (GST_PAD_GETRANGEFUNC (peer)), + (guint64) size, &probability); + gst_object_unref (peer); } } @@ -905,14 +913,15 @@ gst_type_find_element_activate (GstPad * pad) gst_pad_activate_push (typefind->src, FALSE); /* 5 */ - if (!found_caps) { + if (!found_caps || probability < typefind->min_probability) { GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL)); + gst_caps_replace (&found_caps, NULL); return FALSE; } /* 6 */ g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], - 0, 100, found_caps); + 0, probability, found_caps); gst_caps_unref (found_caps); typefind->mode = MODE_NORMAL; -- 2.7.4