Skip to content

Commit

Permalink
fix: retain mehd box after re-encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
lee.fordyce committed May 13, 2024
1 parent 1696776 commit 921a7a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions packager/live_packager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -915,12 +915,18 @@ TEST_F(LivePackagerBaseTest, MehdBoxIncluded) {
live_config.decryption_key_id = HexStringToVector(kKeyIdHex);
SetupLivePackagerConfig(live_config);

SegmentData init_seg(init_segment_buffer.data(),
init_segment_buffer.size());
SegmentData init_seg(init_segment_buffer.data(), init_segment_buffer.size());
SegmentBuffer actual_buf;
const auto status = live_packager_->PackageInit(init_seg, actual_buf);
ASSERT_EQ(Status::OK, status);
ASSERT_GT(actual_buf.Size(), 0);

media::mp4::Movie exp_moov;
ASSERT_TRUE(GetBox(init_seg, exp_moov));
media::mp4::Movie act_moov;
ASSERT_TRUE(GetBox(actual_buf, act_moov));

ASSERT_EQ(exp_moov.extends.header, act_moov.extends.header);
}

TEST_F(LivePackagerBaseTest, EncryptionFailure) {
Expand Down
3 changes: 1 addition & 2 deletions packager/media/formats/mp4/mp4_muxer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ Status MP4Muxer::DelayInitializeMuxer() {
if (codec_fourcc != FOURCC_avc3 && codec_fourcc != FOURCC_hev1)
ftyp->compatible_brands.push_back(FOURCC_cmfc);

// Carry over movie extends header duration from init segment.
moov->extends.header.fragment_duration = streams()[0].get()->duration();
}

Expand All @@ -256,8 +257,6 @@ Status MP4Muxer::DelayInitializeMuxer() {

moov->tracks.resize(streams().size());
moov->extends.tracks.resize(streams().size());
// const StreamInfo* stream_info = streams()[0].get();
// moov->extends.header.fragment_duration = stream_info->duration();

// Initialize tracks.
for (uint32_t i = 0; i < streams().size(); ++i) {
Expand Down

0 comments on commit 921a7a7

Please sign in to comment.