tizen 2.3.1 release
[framework/multimedia/gst-plugins-base0.10.git] / gst / playback / gstdecodebin2.c
old mode 100644 (file)
new mode 100755 (executable)
index 8bcadde..55a092f
@@ -405,6 +405,7 @@ struct _GstDecodeChain
 
   GstPad *pad;                  /* srcpad that caused creation of this chain */
 
+  gboolean drained;             /* TRUE if the all children are drained */
   gboolean demuxer;             /* TRUE if elements->data is a demuxer */
   gboolean seekable;            /* TRUE if this chain ends on a demuxer and is seekable */
   GList *elements;              /* All elements in this group, first
@@ -2266,6 +2267,14 @@ type_found (GstElement * typefind, guint probability,
     goto exit;
   }
 
+#ifdef GST_EXT_DECODEBIN2_QUEUESIZE
+  if (gst_structure_has_name (gst_caps_get_structure (caps, 0), "application/x-hls") ||
+     gst_structure_has_name (gst_caps_get_structure (caps, 0), "application/x-ss")) {
+    GST_DEBUG_OBJECT (decode_bin, "decodebin2 got hls/ss caps.. set queue max-size-time to 1 sec");
+    decode_bin->max_size_time = 1 * GST_SECOND;
+  }
+#endif
+
   /* FIXME: we can only deal with one type, we don't yet support dynamically changing
    * caps from the typefind element */
   if (decode_bin->have_type || decode_bin->decode_chain)
@@ -2915,6 +2924,9 @@ gst_decode_group_new (GstDecodeBin * dbin, GstDecodeChain * parent)
   GstDecodeGroup *group = g_slice_new0 (GstDecodeGroup);
   GstElement *mq;
   gboolean seekable;
+#ifdef GST_EXT_DECODEBIN2_MODIFICATION
+  gboolean smooth_stream_demuxer_last = FALSE;
+#endif
 
   GST_DEBUG_OBJECT (dbin, "Creating new group %p with parent chain %p", group,
       parent);
@@ -2926,8 +2938,25 @@ gst_decode_group_new (GstDecodeBin * dbin, GstDecodeChain * parent)
   if (G_UNLIKELY (!group->multiqueue))
     goto missing_multiqueue;
 
+#ifdef GST_EXT_DECODEBIN2_MODIFICATION
+  /*Check if last parent elment is smooth streaming demuxer.*/
+  if (parent && parent->demuxer)
+  {
+    GstElement *element =
+        ((GstDecodeElement *) parent->elements->data)->element;
+    if(g_strrstr(GST_ELEMENT_NAME(element), "dashdemux"))
+      smooth_stream_demuxer_last = TRUE;
+  }
+
+  /* default is for use-buffering is FALSE
+    We should disable buffering in multiqueue after smooth streaming
+    demuxers like dashdemux because they are fake demuxers.*/
+  if (dbin->use_buffering && !smooth_stream_demuxer_last)
+#else
   /* default is for use-buffering is FALSE */
-  if (dbin->use_buffering) {
+  if (dbin->use_buffering)
+#endif
+  {
     g_object_set (mq,
         "use-buffering", TRUE,
         "low-percent", dbin->low_percent,
@@ -3120,7 +3149,6 @@ drain_and_switch_group (GstDecodeGroup * group, GstDecodePad * drainpad,
     gboolean * last_group, gboolean * drained, gboolean * switched)
 {
   gboolean handled = FALSE;
-  gboolean alldrained = TRUE;
   GList *tmp;
 
   GST_DEBUG ("Checking group %p (target pad %s:%s)",
@@ -3133,6 +3161,7 @@ drain_and_switch_group (GstDecodeGroup * group, GstDecodePad * drainpad,
 
   /* Figure out if all our chains are drained with the
    * new information */
+  group->drained = TRUE;
   for (tmp = group->children; tmp; tmp = tmp->next) {
     GstDecodeChain *chain = (GstDecodeChain *) tmp->data;
     gboolean subdrained = FALSE;
@@ -3141,13 +3170,13 @@ drain_and_switch_group (GstDecodeGroup * group, GstDecodePad * drainpad,
         drain_and_switch_chains (chain, drainpad, last_group, &subdrained,
         switched);
     if (!subdrained)
-      alldrained = FALSE;
+      group->drained = FALSE;
   }
 
 beach:
   GST_DEBUG ("group %p (last_group:%d, drained:%d, switched:%d, handled:%d)",
-      group, *last_group, alldrained, *switched, handled);
-  *drained = alldrained;
+      group, *last_group, group->drained, *switched, handled);
+  *drained = group->drained;
   return handled;
 }
 
@@ -3163,6 +3192,11 @@ drain_and_switch_chains (GstDecodeChain * chain, GstDecodePad * drainpad,
 
   CHAIN_MUTEX_LOCK (chain);
 
+  /* Definitely can't be in drained chains */
+  if (G_UNLIKELY (chain->drained)) {
+    goto beach;
+  }
+  
   if (chain->endpad) {
     /* Check if we're reached the target endchain */
     if (chain == drainpad->chain) {
@@ -3171,7 +3205,7 @@ drain_and_switch_chains (GstDecodeChain * chain, GstDecodePad * drainpad,
       handled = TRUE;
     }
 
-    *drained = chain->endpad->drained;
+    chain->drained = chain->endpad->drained;
     goto beach;
   }
 
@@ -3199,11 +3233,11 @@ drain_and_switch_chains (GstDecodeChain * chain, GstDecodePad * drainpad,
         chain->next_groups =
             g_list_delete_link (chain->next_groups, chain->next_groups);
         *switched = TRUE;
-        *drained = FALSE;
+        chain->drained = FALSE;
       } else {
         GST_DEBUG ("Group %p was the last in chain %p", chain->active_group,
             chain);
-        *drained = TRUE;
+        chain->drained = TRUE; 
         /* We're drained ! */
       }
     }
@@ -3213,7 +3247,9 @@ beach:
   CHAIN_MUTEX_UNLOCK (chain);
 
   GST_DEBUG ("Chain %p (handled:%d, last_group:%d, drained:%d, switched:%d)",
-      chain, handled, *last_group, *drained, *switched);
+      chain, handled, *last_group, chain->drained, *switched);
+
+  *drained = chain->drained;
 
   if (*drained)
     g_signal_emit (dbin, gst_decode_bin_signals[SIGNAL_DRAINED], 0, NULL);