Commit 1c454fda authored by Antonio Ospite's avatar Antonio Ospite

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.
parent f4b054d3
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment