From 1c454fdafc54935f45ddcb9d758a634d152ff026 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 6 May 2019 12:48:49 +0200 Subject: [PATCH] subparse: fix pushing WebVTT cue when last is not an empty line 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 | 3 ++- tests/check/elements/subparse.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index c3912ad2d4..425415874b 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -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); diff --git a/tests/check/elements/subparse.c b/tests/check/elements/subparse.c index 9b94a24381..a414a2a1c8 100644 --- a/tests/check/elements/subparse.c +++ b/tests/check/elements/subparse.c @@ -476,7 +476,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;