Skip to content

Commit

Permalink
Diable pssh generation in output. Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chenda6 committed Jan 16, 2024
1 parent 09cc3c6 commit 08a6671
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packager/live_packager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
52 changes: 49 additions & 3 deletions packager/live_packager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -227,7 +229,7 @@ class MP4MediaParserTest {
std::vector<std::shared_ptr<media::MediaSample>> 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());
Expand All @@ -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;

Expand Down Expand Up @@ -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<uint8_t> 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<uint8_t> 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) {
Expand Down

0 comments on commit 08a6671

Please sign in to comment.