subparse: accept WebVTT timestamps without an hour component
authorMathieu Duponchelle <mathieu@centricular.com>
Wed, 11 Mar 2020 00:01:34 +0000 (01:01 +0100)
committerGilbok Lee <gilbok.lee@samsung.com>
Fri, 16 Jul 2021 01:33:26 +0000 (10:33 +0900)
https://www.w3.org/TR/webvtt1/#webvtt-timestamp

Change-Id: I5e87fdcda7f150c12fc08857ce04c378001321bd
mm:ss,000 is a valid WebVTT timestamp

gst/subparse/gstsubparse.c

index 2115da8..c702a33 100644 (file)
@@ -999,8 +999,23 @@ parse_subrip_time (const gchar * ts_string, GstClockTime * t)
 
   GST_LOG ("parsing timestamp '%s'", s);
   if (sscanf (s, "%u:%u:%u,%u", &hour, &min, &sec, &msec) != 4) {
+#ifdef TIZEN_FEATURE_UPSTREAM
+    /* https://www.w3.org/TR/webvtt1/#webvtt-timestamp
+     *
+     * The hours component is optional with webVTT, for example
+     * mm:ss,500 is a valid webVTT timestamp. When not present,
+     * hours is 0.
+     */
+    hour = 0;
+
+    if (sscanf (s, "%u:%u,%u", &min, &sec, &msec) != 3) {
+      GST_WARNING ("failed to parse subrip timestamp string '%s'", s);
+      return FALSE;
+    }
+#else
     GST_WARNING ("failed to parse subrip timestamp string '%s'", s);
     return FALSE;
+#endif
   }
 
   *t = ((hour * 3600) + (min * 60) + sec) * GST_SECOND + msec * GST_MSECOND;