tsdemux: ignore sparse stream when checking for initial timestamp

Unless we only have sparse streams. In this case we will consider them.
It fixes a bug happening when first observed timestamp comes from a
sparse stream and other streams don't have a valid timestamp, yet. Thus
leading the timestamp from sparse stream to be the start of the
following segment. In this case, if the timestamp is really bigger than
non-sparse stream (audio/video), it will lead the pipeline to clip
samples from the non-parse stream.

https://bugzilla.gnome.org/show_bug.cgi?id=744469
diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c
index b0ff238..40f06e3 100644
--- a/gst/mpegtsdemux/tsdemux.c
+++ b/gst/mpegtsdemux/tsdemux.c
@@ -2119,15 +2119,28 @@
   /* The biggest offset */
   guint64 offset = 0;
   GList *tmp;
+  gboolean have_only_sparse = TRUE;
+
+  /* 0. Do we only have sparse stream */
+  for (tmp = demux->program->stream_list; tmp; tmp = tmp->next) {
+    TSDemuxStream *tmpstream = (TSDemuxStream *) tmp->data;
+
+    if (!tmpstream->sparse) {
+      have_only_sparse = FALSE;
+      break;
+    }
+  }
 
   /* 1. Go over all streams */
   for (tmp = demux->program->stream_list; tmp; tmp = tmp->next) {
     TSDemuxStream *tmpstream = (TSDemuxStream *) tmp->data;
     /* 1.1 check if at least one stream got a valid DTS */
-    if ((tmpstream->raw_dts != -1 && tmpstream->dts != GST_CLOCK_TIME_NONE) ||
-        (tmpstream->raw_pts != -1 && tmpstream->pts != GST_CLOCK_TIME_NONE)) {
-      have_observation = TRUE;
-      break;
+    if (have_only_sparse || !tmpstream->sparse) {
+      if ((tmpstream->raw_dts != -1 && tmpstream->dts != GST_CLOCK_TIME_NONE) ||
+          (tmpstream->raw_pts != -1 && tmpstream->pts != GST_CLOCK_TIME_NONE)) {
+        have_observation = TRUE;
+        break;
+      }
     }
   }