From 08a6671ff6d31e5a170808fab830fcd82f70416c Mon Sep 17 00:00:00 2001 From: David Chen Date: Mon, 15 Jan 2024 17:18:55 -0800 Subject: [PATCH] Diable pssh generation in output. Add tests --- packager/live_packager.cc | 3 ++ packager/live_packager_test.cc | 52 ++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/packager/live_packager.cc b/packager/live_packager.cc index 410169cecdd..276f4781f4a 100644 --- a/packager/live_packager.cc +++ b/packager/live_packager.cc @@ -250,6 +250,8 @@ Status LivePackager::PackageInit(const Segment& init_segment, packaging_params.chunking_params.segment_duration_in_seconds = config_.segment_duration_sec; + packaging_params.mp4_output_params.include_pssh_in_stream = false; + // in order to enable init packaging as a separate execution. packaging_params.init_segment_only = true; @@ -310,6 +312,7 @@ Status LivePackager::Package(const Segment& init_segment, config_.segment_duration_sec; packaging_params.mp4_output_params.sequence_number = config_.segment_number; + packaging_params.mp4_output_params.include_pssh_in_stream = false; EncryptionParams& encryption_params = packaging_params.encryption_params; // As a side effect of InitializeEncryption, encryption_params will be diff --git a/packager/live_packager_test.cc b/packager/live_packager_test.cc index 6bf8d391b55..0cc024021b4 100644 --- a/packager/live_packager_test.cc +++ b/packager/live_packager_test.cc @@ -124,6 +124,8 @@ struct MovieBoxChecker { media::mp4::Movie moov; CHECK(ParseAndCheckType(moov, reader)); + EXPECT_EQ(0, moov.pssh.size()); + EXPECT_EQ(moov_.tracks.size(), moov.tracks.size()); for (unsigned i(0); i < moov_.tracks.size(); ++i) { @@ -227,7 +229,7 @@ class MP4MediaParserTest { std::vector> samples_; }; -void CheckVideoInitSegment(const FullSegmentBuffer& buffer) { +void CheckVideoInitSegment(const FullSegmentBuffer& buffer, media::FourCC format) { bool err(true); size_t bytes_to_read(buffer.InitSegmentSize()); const uint8_t* data(buffer.InitSegmentData()); @@ -250,7 +252,7 @@ void CheckVideoInitSegment(const FullSegmentBuffer& buffer) { EXPECT_FALSE(err); media::mp4::VideoSampleEntry entry; - entry.format = media::FOURCC_avc1; + entry.format = format; entry.width = 1024; entry.height = 576; @@ -366,7 +368,51 @@ TEST_F(LivePackagerBaseTest, InitSegmentOnly) { ASSERT_GT(out.InitSegmentSize(), 0); ASSERT_EQ(out.SegmentSize(), 0); - CheckVideoInitSegment(out); + CheckVideoInitSegment(out, media::FourCC::FOURCC_avc1); +} + +TEST_F(LivePackagerBaseTest, InitSegmentOnlyWithCBCS) { + std::vector init_segment_buffer = ReadTestDataFile("input/init.mp4"); + ASSERT_FALSE(init_segment_buffer.empty()); + + FullSegmentBuffer in; + in.SetInitSegment(init_segment_buffer.data(), init_segment_buffer.size()); + + FullSegmentBuffer out; + + LiveConfig live_config; + live_config.format = LiveConfig::OutputFormat::FMP4; + live_config.track_type = LiveConfig::TrackType::VIDEO; + live_config.protection_scheme = LiveConfig::EncryptionScheme::CBCS; + SetupLivePackagerConfig(live_config); + + ASSERT_EQ(Status::OK, live_packager_->PackageInit(in, out)); + ASSERT_GT(out.InitSegmentSize(), 0); + ASSERT_EQ(out.SegmentSize(), 0); + + CheckVideoInitSegment(out, media::FourCC::FOURCC_encv); +} + +TEST_F(LivePackagerBaseTest, InitSegmentOnlyWithCENC) { + std::vector init_segment_buffer = ReadTestDataFile("input/init.mp4"); + ASSERT_FALSE(init_segment_buffer.empty()); + + FullSegmentBuffer in; + in.SetInitSegment(init_segment_buffer.data(), init_segment_buffer.size()); + + FullSegmentBuffer out; + + LiveConfig live_config; + live_config.format = LiveConfig::OutputFormat::FMP4; + live_config.track_type = LiveConfig::TrackType::VIDEO; + live_config.protection_scheme = LiveConfig::EncryptionScheme::CENC; + SetupLivePackagerConfig(live_config); + + ASSERT_EQ(Status::OK, live_packager_->PackageInit(in, out)); + ASSERT_GT(out.InitSegmentSize(), 0); + ASSERT_EQ(out.SegmentSize(), 0); + + CheckVideoInitSegment(out, media::FourCC::FOURCC_encv); } TEST_F(LivePackagerBaseTest, VerifyAes128WithDecryption) {