subparse: fix pushing WebVTT cue when last is not an empty line
authorAntonio Ospite <antonio.ospite@collabora.com>
Mon, 6 May 2019 10:48:49 +0000 (12:48 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 8 Aug 2019 08:52:55 +0000 (09:52 +0100)
If the last WebVTT cue does not have an empty line after it, or if it
does not end with a newline at all, it does not get pushed out and it
won't be displayed.

gst_sub_parse_sink_event() already handles the issue for other subtitle
formats, enable handling it for GST_SUB_PARSE_FORMAT_VTT too.

While at it also add a test for this case.

gst/subparse/gstsubparse.c
tests/check/elements/subparse.c

index c3912ad..4254158 100644 (file)
@@ -1861,7 +1861,8 @@ gst_sub_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
       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);
 
index 4d88e17..e6c75e0 100644 (file)
@@ -487,7 +487,17 @@ GST_START_TEST (test_webvtt)
         2 * GST_SECOND, 3 * GST_SECOND, "Hello\nWorld"}
     ,
   };
+
+  /* Test with no newline at the end */
+  SubParseInputChunk webvtt_input2[] = {
+    {
+          "1\n00:00:01,000 --> 00:00:02,000\nLast cue, no newline at the end",
+        1 * GST_SECOND, 2 * GST_SECOND, "Last cue, no newline at the end"}
+    ,
+  };
+
   test_vtt_do_test (webvtt_input, 0, G_N_ELEMENTS (webvtt_input));
+  test_vtt_do_test (webvtt_input2, 0, G_N_ELEMENTS (webvtt_input2));
 }
 
 GST_END_TEST;