[WebVTT] support cues without payload
WebVTT cues without payload may not carry meaningful information, but it is allowed by WebVTT specification [1]. It could also be useful sometimes, e.g. to signal the time progression in live case. Fixes #433. [1] https://www.w3.org/TR/webvtt1/#types-of-webvtt-cue-payload Change-Id: I9e31f4a3789cbdafb7667b64f4019834190ecfc0
This commit is contained in:
parent
83f29ff964
commit
308b92d16e
|
@ -163,15 +163,14 @@ bool WebVttParser::Parse() {
|
|||
}
|
||||
|
||||
// CUE with ID
|
||||
if (block.size() > 2 && MaybeCueId(block[0]) &&
|
||||
if (block.size() >= 2 && MaybeCueId(block[0]) &&
|
||||
IsLikelyCueTiming(block[1]) && ParseCueWithId(block)) {
|
||||
saw_cue = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// CUE with no ID
|
||||
if (block.size() > 1 && IsLikelyCueTiming(block[0]) &&
|
||||
ParseCueWithNoId(block)) {
|
||||
if (IsLikelyCueTiming(block[0]) && ParseCueWithNoId(block)) {
|
||||
saw_cue = true;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -214,6 +214,28 @@ TEST_F(WebVttParserTest, ParseOneCue) {
|
|||
ASSERT_OK(parser_->Run());
|
||||
}
|
||||
|
||||
TEST_F(WebVttParserTest, ParseOneEmptyCue) {
|
||||
const char* text =
|
||||
"WEBVTT\n"
|
||||
"\n"
|
||||
"00:01:00.000 --> 01:00:00.000\n"
|
||||
"\n";
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(SetUpAndInitializeGraph(text));
|
||||
|
||||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(
|
||||
*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(_, kNoId, 60000u, 3600000u, kNoSettings, "")));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
}
|
||||
|
||||
TEST_F(WebVttParserTest, FailToParseCueWithArrowInId) {
|
||||
const char* text =
|
||||
"WEBVTT\n"
|
||||
|
@ -250,6 +272,29 @@ TEST_F(WebVttParserTest, ParseOneCueWithId) {
|
|||
ASSERT_OK(parser_->Run());
|
||||
}
|
||||
|
||||
TEST_F(WebVttParserTest, ParseOneEmptyCueWithId) {
|
||||
const char* text =
|
||||
"WEBVTT\n"
|
||||
"\n"
|
||||
"id\n"
|
||||
"00:01:00.000 --> 01:00:00.000\n"
|
||||
"\n";
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(SetUpAndInitializeGraph(text));
|
||||
|
||||
{
|
||||
testing::InSequence s;
|
||||
EXPECT_CALL(*Output(kOutputIndex),
|
||||
OnProcess(IsStreamInfo(_, kTimeScale, !kEncrypted, _)));
|
||||
EXPECT_CALL(
|
||||
*Output(kOutputIndex),
|
||||
OnProcess(IsTextSample(_, "id", 60000u, 3600000u, kNoSettings, "")));
|
||||
EXPECT_CALL(*Output(kOutputIndex), OnFlush(_));
|
||||
}
|
||||
|
||||
ASSERT_OK(parser_->Run());
|
||||
}
|
||||
|
||||
TEST_F(WebVttParserTest, ParseOneCueWithSettings) {
|
||||
const char* text =
|
||||
"WEBVTT\n"
|
||||
|
|
Loading…
Reference in New Issue