From 028931d4c37981cfe8caf5ca6426aba59ebc963f Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Fri, 25 May 2018 17:23:40 -0700 Subject: [PATCH] Fix MPD@duration not set with MpdGenerator Fixes: #401. Change-Id: I5cd7c691d9cf4f187d12e5de60bf641e753f800c --- packager/mpd/base/period.cc | 5 +++++ .../mpd/test/data/audio_media_info1_expected_mpd_output.txt | 2 +- ...dio_media_info1_video_media_info1_expected_mpd_output.txt | 2 +- .../mpd/test/data/video_media_info1_expected_mpd_output.txt | 2 +- .../test/data/video_media_info1and2_expected_mpd_output.txt | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packager/mpd/base/period.cc b/packager/mpd/base/period.cc index 51e2d548d5..08952ac690 100644 --- a/packager/mpd/base/period.cc +++ b/packager/mpd/base/period.cc @@ -46,6 +46,11 @@ Period::Period(uint32_t period_id, AdaptationSet* Period::GetOrCreateAdaptationSet( const MediaInfo& media_info, bool content_protection_in_adaptation_set) { + // Set duration if it is not set. It may be updated later from duration + // calculated from segments. + if (duration_seconds_ == 0) + duration_seconds_ = media_info.media_duration_seconds(); + // AdaptationSets with the same key should only differ in ContentProtection, // which also means that if |content_protection_in_adaptation_set| is false, // there should be at most one entry in |adaptation_sets|. diff --git a/packager/mpd/test/data/audio_media_info1_expected_mpd_output.txt b/packager/mpd/test/data/audio_media_info1_expected_mpd_output.txt index b9b235f466..3a645f6505 100644 --- a/packager/mpd/test/data/audio_media_info1_expected_mpd_output.txt +++ b/packager/mpd/test/data/audio_media_info1_expected_mpd_output.txt @@ -1,5 +1,5 @@ - + diff --git a/packager/mpd/test/data/audio_media_info1_video_media_info1_expected_mpd_output.txt b/packager/mpd/test/data/audio_media_info1_video_media_info1_expected_mpd_output.txt index 88f9eebb34..0da72fba08 100644 --- a/packager/mpd/test/data/audio_media_info1_video_media_info1_expected_mpd_output.txt +++ b/packager/mpd/test/data/audio_media_info1_video_media_info1_expected_mpd_output.txt @@ -1,5 +1,5 @@ - + diff --git a/packager/mpd/test/data/video_media_info1_expected_mpd_output.txt b/packager/mpd/test/data/video_media_info1_expected_mpd_output.txt index 5e4775bc1a..8d66cd8ca8 100644 --- a/packager/mpd/test/data/video_media_info1_expected_mpd_output.txt +++ b/packager/mpd/test/data/video_media_info1_expected_mpd_output.txt @@ -1,5 +1,5 @@ - + diff --git a/packager/mpd/test/data/video_media_info1and2_expected_mpd_output.txt b/packager/mpd/test/data/video_media_info1and2_expected_mpd_output.txt index 5a4052b25c..927fe1cada 100644 --- a/packager/mpd/test/data/video_media_info1and2_expected_mpd_output.txt +++ b/packager/mpd/test/data/video_media_info1and2_expected_mpd_output.txt @@ -1,5 +1,5 @@ - +