plugins/elements/gsttypefindelement.c: When we get an EOS event and have not found...
authorTim-Philipp Müller <tim@centricular.net>
Mon, 27 Feb 2006 20:01:53 +0000 (20:01 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Mon, 27 Feb 2006 20:01:53 +0000 (20:01 +0000)
Original commit message from CVS:
* plugins/elements/gsttypefindelement.c:
(gst_type_find_element_handle_event):
When we get an EOS event and have not found a type yet
(most likely because we had not yet accumulated
TYPE_FIND_MIN_SIZE of data yet), try to determine the
type given the data we have so far. Fixes typefinding
for very short streams again, most notably quicktime
redirections as used on Apple's trailer site (#331701).

ChangeLog
plugins/elements/gsttypefindelement.c

index 8d06cb5..a7f7c2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2006-02-27  Tim-Philipp Müller  <tim at centricular dot net>
 
+       * plugins/elements/gsttypefindelement.c:
+       (gst_type_find_element_handle_event):
+         When we get an EOS event and have not found a type yet
+         (most likely because we had not yet accumulated
+         TYPE_FIND_MIN_SIZE of data yet), try to determine the
+         type given the data we have so far. Fixes typefinding
+         for very short streams again, most notably quicktime
+         redirections as used on Apple's trailer site (#331701).
+
+2006-02-27  Tim-Philipp Müller  <tim at centricular dot net>
+
        * libs/gst/base/gsttypefindhelper.c: (type_find_factory_rank_cmp),
        (gst_type_find_helper):
          Try typefinding factories with the highest rank first.
index d55dfe8..f120326 100644 (file)
@@ -559,20 +559,24 @@ gst_type_find_element_handle_event (GstPad * pad, GstEvent * event)
     case MODE_TYPEFIND:
       switch (GST_EVENT_TYPE (event)) {
         case GST_EVENT_EOS:{
-          TypeFindEntry *entry;
+          GstTypeFindProbability prob;
+          GstCaps *caps;
 
-          entry = gst_type_find_element_get_best_possibility (typefind);
+          GST_INFO_OBJECT (typefind, "Got EOS and no type found yet");
 
-          if (entry && entry->probability >= typefind->min_probability) {
-            GST_INFO_OBJECT (typefind,
-                "'%s' is the best typefind left after we got all data, using it now (probability %u)",
-                GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability);
+          /* we might not have started typefinding yet because there was not
+           * enough data so far; just give it a shot now and see what we get */
+          caps = gst_type_find_helper_for_buffer (GST_OBJECT (typefind),
+              typefind->store, &prob);
+
+          if (caps && prob >= typefind->min_probability) {
             g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE],
-                0, entry->probability, entry->caps);
+                0, prob, caps);
           } else {
-            GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL),
-                (NULL));
+            GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND,
+                (NULL), (NULL));
           }
+          gst_caps_replace (&caps, NULL);
           stop_typefinding (typefind);
           res = gst_pad_event_default (pad, event);
           break;