Merge branch 'upstream/1.16' into tizen_gst_1.16.2
[platform/upstream/gst-plugins-base.git] / gst / subparse / gstsubparse.c
index 5008e98..6d806de 100644 (file)
@@ -320,6 +320,9 @@ gst_sub_parse_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
         GST_DEBUG_OBJECT (self, "segment after seek: %" GST_SEGMENT_FORMAT,
             &self->segment);
 
+        /* will mark need_segment when receiving segment from upstream,
+         * after FLUSH and all that has happened,
+         * rather than racing with chain */
       } else {
         GST_WARNING_OBJECT (self, "seek to 0 bytes failed");
       }
@@ -948,7 +951,13 @@ parse_subrip_time (const gchar * ts_string, GstClockTime * t)
 
   /* make sure we have exactly three digits after he comma */
   p = strchr (s, ',');
-  g_assert (p != NULL);
+  if (p == NULL) {
+    /* If there isn't a ',' the timestamp is broken */
+    /* https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/532#note_100179 */
+    GST_WARNING ("failed to parse subrip timestamp string '%s'", s);
+    return FALSE;
+  }
+
   ++p;
   len = strlen (p);
   if (len > 3) {
@@ -1930,20 +1939,24 @@ gst_sub_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
   GstSubParse *self = GST_SUBPARSE (parent);
   gboolean ret = FALSE;
 
-  GST_DEBUG ("Handling %s event", GST_EVENT_TYPE_NAME (event));
+  GST_LOG_OBJECT (self, "%s event", GST_EVENT_TYPE_NAME (event));
 
   switch (GST_EVENT_TYPE (event)) {
+    case GST_EVENT_STREAM_GROUP_DONE:
     case GST_EVENT_EOS:{
       /* Make sure the last subrip chunk is pushed out even
        * if the file does not have an empty line at the end */
       if (self->parser_type == GST_SUB_PARSE_FORMAT_SUBRIP ||
           self->parser_type == GST_SUB_PARSE_FORMAT_TMPLAYER ||
           self->parser_type == GST_SUB_PARSE_FORMAT_MPL2 ||
-          self->parser_type == GST_SUB_PARSE_FORMAT_QTTEXT) {
+          self->parser_type == GST_SUB_PARSE_FORMAT_QTTEXT ||
+          self->parser_type == GST_SUB_PARSE_FORMAT_VTT) {
         gchar term_chars[] = { '\n', '\n', '\0' };
         GstBuffer *buf = gst_buffer_new_and_alloc (2 + 1);
 
-        GST_DEBUG ("EOS. Pushing remaining text (if any)");
+        GST_DEBUG_OBJECT (self, "%s: force pushing of any remaining text",
+            GST_EVENT_TYPE_NAME (event));
+
         gst_buffer_fill (buf, 0, term_chars, 3);
         gst_buffer_set_size (buf, 2);
 
@@ -1990,13 +2003,12 @@ gst_sub_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
       /* in either case, let's not simply discard this event;
        * trigger sending of the saved requested seek segment
        * or the one taken here from upstream */
-
-      self->need_segment = TRUE; /* upstream */
+      self->need_segment = TRUE;
 
 #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
       SUBPARSE_SEEK_UNLOCK (self);
 #endif
-
+         
       break;
     }
     case GST_EVENT_FLUSH_START: