diff --git a/packager/live_packager_test.cc b/packager/live_packager_test.cc index 08c51a66326..43cb1e34836 100644 --- a/packager/live_packager_test.cc +++ b/packager/live_packager_test.cc @@ -1075,6 +1075,8 @@ struct LivePackagerTestCase { LiveConfig::TrackType track_type; const char* media_segment_format; bool compare_samples; + std::string exp_init; + const char* exp_media_seg; }; class LivePackagerEncryptionTest @@ -1094,13 +1096,14 @@ class LivePackagerEncryptionTest protected: static std::vector ReadExpectedData() { // TODO: make this more generic to handle mp2t as well - std::vector buf = ReadTestDataFile("expected/fmp4/init.mp4"); + std::vector buf = ReadTestDataFile(GetParam().exp_init); for (unsigned int i = 0; i < GetParam().num_segments; i++) { - auto seg_buf = - ReadTestDataFile(absl::StrFormat("expected/fmp4/%04d.m4s", i + 1)); - buf.insert(buf.end(), seg_buf.begin(), seg_buf.end()); + std::string input_fname; + if (FormatWithIndex(GetParam().exp_media_seg, i, input_fname)) { + auto seg_buf = ReadTestDataFile(input_fname); + buf.insert(buf.end(), seg_buf.begin(), seg_buf.end()); + } } - return buf; } @@ -1176,32 +1179,62 @@ INSTANTIATE_TEST_CASE_P( LivePackagerTestCase{ 10, "input/init.mp4", LiveConfig::EncryptionScheme::SAMPLE_AES, LiveConfig::OutputFormat::TS, LiveConfig::TrackType::VIDEO, - "input/%04d.m4s", false}, + "input/%04d.m4s", false, "expected/fmp4/init.mp4", + "expected/fmp4/%04d.m4s"}, // Verify FMP4 to TS with AES-128 encryption. LivePackagerTestCase{ 10, "input/init.mp4", LiveConfig::EncryptionScheme::AES_128, LiveConfig::OutputFormat::TS, LiveConfig::TrackType::VIDEO, - "input/%04d.m4s", false}, + "input/%04d.m4s", false, "expected/fmp4/init.mp4", + "expected/fmp4/%04d.m4s"}, // Verify FMP4 to FMP4 with Sample AES encryption. LivePackagerTestCase{ 10, "input/init.mp4", LiveConfig::EncryptionScheme::SAMPLE_AES, LiveConfig::OutputFormat::FMP4, LiveConfig::TrackType::VIDEO, - "input/%04d.m4s", true}, + "input/%04d.m4s", true, "expected/fmp4/init.mp4", + "expected/fmp4/%04d.m4s"}, // Verify FMP4 to FMP4 with CENC encryption. LivePackagerTestCase{ 10, "input/init.mp4", LiveConfig::EncryptionScheme::CENC, LiveConfig::OutputFormat::FMP4, LiveConfig::TrackType::VIDEO, - "input/%04d.m4s", true}, + "input/%04d.m4s", true, "expected/fmp4/init.mp4", + "expected/fmp4/%04d.m4s"}, // Verify FMP4 to FMP4 with CBCS encryption. LivePackagerTestCase{ 10, "input/init.mp4", LiveConfig::EncryptionScheme::CBCS, LiveConfig::OutputFormat::FMP4, LiveConfig::TrackType::VIDEO, - "input/%04d.m4s", true}, + "input/%04d.m4s", true, "expected/fmp4/init.mp4", + "expected/fmp4/%04d.m4s"}, // Verify AUDIO segments only to TS with Sample AES encryption. LivePackagerTestCase{ 5, "audio/en/init.mp4", LiveConfig::EncryptionScheme::SAMPLE_AES, LiveConfig::OutputFormat::TS, LiveConfig::TrackType::AUDIO, - "audio/en/%05d.m4s", false})); + "audio/en/%05d.m4s", false, "expected/fmp4/init.mp4", + "expected/fmp4/%04d.m4s"}, + // Verify packaging of CMAF Video segments, no encryption + LivePackagerTestCase{ + 10, "cmaf/video/init.mp4", LiveConfig::EncryptionScheme::NONE, + LiveConfig::OutputFormat::FMP4, LiveConfig::TrackType::VIDEO, + "cmaf/video/seg_34313817%01d.m4s", true, "cmaf/video/init.mp4", + "cmaf/video/seg_34313817%01d.m4s"}, + // Verify packaging of CMAF Audio segments + LivePackagerTestCase{ + 10, "cmaf/audio/init.mp4", LiveConfig::EncryptionScheme::NONE, + LiveConfig::OutputFormat::FMP4, LiveConfig::TrackType::AUDIO, + "cmaf/audio/seg_34313817%01d.m4s", true, "cmaf/audio/init.mp4", + "cmaf/audio/seg_34313817%01d.m4s"}, + // Verify packaging of CMAF audio segments, with encryption + LivePackagerTestCase{ + 10, "cmaf/audio/init.mp4", LiveConfig::EncryptionScheme::CENC, + LiveConfig::OutputFormat::FMP4, LiveConfig::TrackType::AUDIO, + "cmaf/audio/seg_34313817%01d.m4s", true, "cmaf/audio/init.mp4", + "cmaf/audio/seg_34313817%01d.m4s"}, + // Verify packaging of CMAF video segments, with encryption + LivePackagerTestCase{ + 10, "cmaf/video/init.mp4", LiveConfig::EncryptionScheme::CENC, + LiveConfig::OutputFormat::FMP4, LiveConfig::TrackType::VIDEO, + "cmaf/video/seg_34313817%01d.m4s", true, "cmaf/video/init.mp4", + "cmaf/video/seg_34313817%01d.m4s"})); struct LivePackagerReEncryptCase { unsigned int num_segments; @@ -1499,4 +1532,36 @@ INSTANTIATE_TEST_CASE_P( Status(error::INVALID_ARGUMENT, "Stream not available"), 0, })); + +// Exercise edge case found in webvtt_to_mp4_handler for large decode times. +// Issue was a narrow conversion from int64_t to int (32 bit) for segment_start. +// Valid decode times can be int64_t. +TEST_F(LivePackagerBaseTest, TestCmafTimedText) { + std::vector segment_buffer = + ReadTestDataFile("timed_text/cmaf/text_cmaf_fragment_343138171.vtt"); + ASSERT_FALSE(segment_buffer.empty()); + + SegmentData media_seg(segment_buffer.data(), segment_buffer.size()); + + FullSegmentBuffer out; + + LiveConfig live_config; + live_config.format = LiveConfig::OutputFormat::VTTMP4; + live_config.track_type = LiveConfig::TrackType::TEXT; + live_config.protection_scheme = LiveConfig::EncryptionScheme::NONE; + live_config.segment_number = 343138171; + live_config.timed_text_decode_time = (154412176500000 / 90000) * 1000; + + SetupLivePackagerConfig(live_config); + ASSERT_EQ(Status::OK, live_packager_->PackageTimedText(media_seg, out)); + ASSERT_GT(out.SegmentSize(), 0); + + CheckTextInitSegment(out, media::FourCC::FOURCC_text, + media::FourCC::FOURCC_wvtt); + + SegmentBuffer seg; + seg.AppendData(out.SegmentData(), out.SegmentSize()); + CheckSegment(live_config, seg, 1000, true); +} + } // namespace shaka diff --git a/packager/media/formats/webvtt/webvtt_to_mp4_handler.cc b/packager/media/formats/webvtt/webvtt_to_mp4_handler.cc index 3eeabaec1b3..7dbbaed3415 100644 --- a/packager/media/formats/webvtt/webvtt_to_mp4_handler.cc +++ b/packager/media/formats/webvtt/webvtt_to_mp4_handler.cc @@ -191,7 +191,7 @@ Status WebVttToMp4Handler::DispatchCurrentSegment(int64_t segment_start, // Move through the segment, jumping between each change to the current state. // A change is defined as a group of one or more DisplayActions. - int section_start = segment_start; + int64_t section_start = segment_start; // |actions| is a map of [time] -> [action]. auto actions = CreateActionList(segment_start, segment_end, current_segment_); diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/init.mp4 b/packager/media/test/data/live_packager_tests/cmaf/audio/init.mp4 new file mode 100644 index 00000000000..2e6320970a0 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/init.mp4 differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138170.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138170.m4s new file mode 100644 index 00000000000..2c4aa00c104 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138170.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138171.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138171.m4s new file mode 100644 index 00000000000..ee334470f1c Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138171.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138172.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138172.m4s new file mode 100644 index 00000000000..647bff67d08 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138172.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138173.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138173.m4s new file mode 100644 index 00000000000..238af962544 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138173.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138174.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138174.m4s new file mode 100644 index 00000000000..7b68c7210c2 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138174.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138175.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138175.m4s new file mode 100644 index 00000000000..7cbb68bf2ca Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138175.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138176.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138176.m4s new file mode 100644 index 00000000000..16b671aac77 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138176.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138177.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138177.m4s new file mode 100644 index 00000000000..4274cb3a00d Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138177.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138178.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138178.m4s new file mode 100644 index 00000000000..16be8715ae4 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138178.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138179.m4s b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138179.m4s new file mode 100644 index 00000000000..bb9b9df300a Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/audio/seg_343138179.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/init.mp4 b/packager/media/test/data/live_packager_tests/cmaf/video/init.mp4 new file mode 100644 index 00000000000..034b05519e8 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/init.mp4 differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138170.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138170.m4s new file mode 100644 index 00000000000..64b68bd869d Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138170.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138171.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138171.m4s new file mode 100644 index 00000000000..c8cab942bc2 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138171.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138172.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138172.m4s new file mode 100644 index 00000000000..8f374e11103 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138172.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138173.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138173.m4s new file mode 100644 index 00000000000..4bd9cc63295 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138173.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138174.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138174.m4s new file mode 100644 index 00000000000..516c8674777 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138174.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138175.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138175.m4s new file mode 100644 index 00000000000..767ff0d9440 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138175.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138176.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138176.m4s new file mode 100644 index 00000000000..a5036937e16 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138176.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138177.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138177.m4s new file mode 100644 index 00000000000..520acfe13b7 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138177.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138178.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138178.m4s new file mode 100644 index 00000000000..0aaaa6e4da7 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138178.m4s differ diff --git a/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138179.m4s b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138179.m4s new file mode 100644 index 00000000000..f4e1fb657b6 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/cmaf/video/seg_343138179.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0000.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0000.m4s new file mode 100644 index 00000000000..e312303ee97 Binary files /dev/null and b/packager/media/test/data/live_packager_tests/expected/fmp4/0000.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0001.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0001.m4s index e312303ee97..7558b959388 100644 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0001.m4s and b/packager/media/test/data/live_packager_tests/expected/fmp4/0001.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0002.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0002.m4s index 7558b959388..e64b6017f61 100644 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0002.m4s and b/packager/media/test/data/live_packager_tests/expected/fmp4/0002.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0003.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0003.m4s index e64b6017f61..090c699938c 100644 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0003.m4s and b/packager/media/test/data/live_packager_tests/expected/fmp4/0003.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0004.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0004.m4s index 090c699938c..b0429557c15 100644 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0004.m4s and b/packager/media/test/data/live_packager_tests/expected/fmp4/0004.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0005.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0005.m4s index b0429557c15..651b2ae923b 100644 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0005.m4s and b/packager/media/test/data/live_packager_tests/expected/fmp4/0005.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0006.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0006.m4s index 651b2ae923b..1ab7b3c5b51 100644 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0006.m4s and b/packager/media/test/data/live_packager_tests/expected/fmp4/0006.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0007.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0007.m4s index 1ab7b3c5b51..8eadbca0bdd 100644 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0007.m4s and b/packager/media/test/data/live_packager_tests/expected/fmp4/0007.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0008.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0008.m4s index 8eadbca0bdd..150c81c13b2 100644 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0008.m4s and b/packager/media/test/data/live_packager_tests/expected/fmp4/0008.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0009.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0009.m4s index 150c81c13b2..e1c2a40a32f 100644 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0009.m4s and b/packager/media/test/data/live_packager_tests/expected/fmp4/0009.m4s differ diff --git a/packager/media/test/data/live_packager_tests/expected/fmp4/0010.m4s b/packager/media/test/data/live_packager_tests/expected/fmp4/0010.m4s deleted file mode 100644 index e1c2a40a32f..00000000000 Binary files a/packager/media/test/data/live_packager_tests/expected/fmp4/0010.m4s and /dev/null differ diff --git a/packager/media/test/data/live_packager_tests/timed_text/cmaf/text_cmaf_fragment_343138171.vtt b/packager/media/test/data/live_packager_tests/timed_text/cmaf/text_cmaf_fragment_343138171.vtt new file mode 100644 index 00000000000..b2de25d7412 --- /dev/null +++ b/packager/media/test/data/live_packager_tests/timed_text/cmaf/text_cmaf_fragment_343138171.vtt @@ -0,0 +1,9 @@ +WEBVTT + +1 +476580:47:31.733 --> 476580:47:34.600 align:center +was three boxes downat number 22. + +2 +476580:47:34.666 --> 476580:47:35.000 align:center +And now that prizeis in position here. \ No newline at end of file