Merge the tizen patch based on 1.12.2
[platform/upstream/gstreamer.git] / plugins / elements / gsttypefindelement.c
index 2426051..0d8f092 100644 (file)
@@ -20,6 +20,7 @@
  */
 /**
  * SECTION:element-typefind
+ * @title: typefind
  *
  * Determines the media-type of a stream. It applies typefind functions in the
  * order of their rank. Once the type has been detected it sets its src pad caps
@@ -97,7 +98,14 @@ GST_STATIC_PAD_TEMPLATE ("src",
 
 /* Require at least 2kB of data before we attempt typefinding in chain-mode.
  * 128kB is massive overkill for the maximum, but doesn't do any harm */
+#ifdef TIZEN_PROFILE_TV
+/* TV demuxer needs 4*1024 as min size to match demuxer, if not
+ * sometimes can't find correct demuxer
+ */
+#define TYPE_FIND_MIN_SIZE   (4*1024)
+#else
 #define TYPE_FIND_MIN_SIZE   (2*1024)
+#endif
 #define TYPE_FIND_MAX_SIZE (128*1024)
 
 /* TypeFind signals and args */
@@ -558,6 +566,7 @@ gst_type_find_element_src_event (GstPad * pad, GstObject * parent,
 
   if (typefind->mode != MODE_NORMAL) {
     /* need to do more? */
+    GST_LOG_OBJECT (typefind, "Still typefinding. Not passing event upstream");
     gst_event_unref (event);
     return FALSE;
   }
@@ -783,6 +792,8 @@ gst_type_find_element_setcaps (GstTypeFindElement * typefind, GstCaps * caps)
   if (gst_caps_is_any (caps))
     return TRUE;
 
+  /* Set to MODE_NORMAL before emitting have-type, in case it triggers a seek */
+  typefind->mode = MODE_NORMAL;
   gst_type_find_element_emit_have_type (typefind, GST_TYPE_FIND_MAXIMUM, caps);
 
   /* Shortcircuit typefinding if we get caps */
@@ -967,6 +978,8 @@ gst_type_find_element_chain_do_typefinding (GstTypeFindElement * typefind,
 
   /* probability is good enough too, so let's make it known ... emiting this
    * signal calls our object handler which sets the caps. */
+  /* Set to MODE_NORMAL before emitting have-type, in case it triggers a seek */
+  typefind->mode = MODE_NORMAL;
   gst_type_find_element_emit_have_type (typefind, probability, caps);
 
   /* .. and send out the accumulated data */
@@ -1158,8 +1171,9 @@ gst_type_find_element_loop (GstPad * pad)
     }
 
     GST_DEBUG ("Emiting found caps %" GST_PTR_FORMAT, found_caps);
-    gst_type_find_element_emit_have_type (typefind, probability, found_caps);
+    /* Set to MODE_NORMAL before emitting have-type, in case it triggers a seek */
     typefind->mode = MODE_NORMAL;
+    gst_type_find_element_emit_have_type (typefind, probability, found_caps);
     gst_caps_unref (found_caps);
   } else if (typefind->mode == MODE_NORMAL) {
     GstBuffer *outbuf = NULL;