From 482c60ca1ecb950c691d84cfab5cdba0e5de6967 Mon Sep 17 00:00:00 2001 From: Rintaro Kuroiwa Date: Tue, 4 Mar 2014 12:38:06 -0800 Subject: [PATCH] Put AudioChannelConfig before ContentProtection AudioChannelConfig should appear before ContentProtection in Representation. Enabled tests which covers this case. Bug: 13227181 Change-Id: I0f4e913304ad982761a9296aa95d30200f6314d2 --- mpd/base/mpd_builder.cc | 26 ++++++++++++++++---------- mpd/base/mpd_builder_unittest.cc | 5 ++--- mpd/util/mpd_writer_unittest.cc | 2 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/mpd/base/mpd_builder.cc b/mpd/base/mpd_builder.cc index fd6add49a2..afe9da1bee 100644 --- a/mpd/base/mpd_builder.cc +++ b/mpd/base/mpd_builder.cc @@ -315,6 +315,9 @@ bool Representation::Init() { if (!has_video_info && !has_audio_info) { // TODO(rkuroiwa): Allow text input. + // This is an error. Segment information can be in AdaptationSet, Period, or + // MPD but the interface does not provide a way to set them. + // See 5.3.9.1 ISO 23009-1:2012 for segment info. LOG(ERROR) << "Representation needs video or audio."; return false; } @@ -355,22 +358,19 @@ bool Representation::AddNewSegment(uint64 start_time, uint64 duration) { // internal copy of this element. Then move most of the logic to // RepresentationXmlNode so that all the work is done in it so that this class // just becomes a thin layer. +// // Uses info in |media_info_| and |content_protection_elements_| to create a // "Representation" node. +// MPD schema has strict ordering. The following must be done in order. +// AddVideoInfo() (possibly adds FramePacking elements), AddAudioInfo() (Adds +// AudioChannelConfig elements), AddContentProtectionElements*(), and +// AddVODOnlyInfo() (Adds segment info). xml::ScopedXmlPtr::type Representation::GetXml() { base::AutoLock scoped_lock(lock_); DCHECK(!(HasVODOnlyFields(media_info_) && HasLiveOnlyFields(media_info_))); DCHECK(media_info_.has_bandwidth()); RepresentationXmlNode representation; - if (!representation.AddContentProtectionElements( - content_protection_elements_)) { - return xml::ScopedXmlPtr::type(); - } - - if (!representation.AddContentProtectionElementsFromMediaInfo(media_info_)) - return xml::ScopedXmlPtr::type(); - // Mandatory fields for Representation. representation.SetId(id_); representation.SetIntegerAttribute("bandwidth", media_info_.bandwidth()); @@ -392,11 +392,17 @@ xml::ScopedXmlPtr::type Representation::GetXml() { return xml::ScopedXmlPtr::type(); } + if (!representation.AddContentProtectionElements( + content_protection_elements_)) { + return xml::ScopedXmlPtr::type(); + } + if (!representation.AddContentProtectionElementsFromMediaInfo(media_info_)) + return xml::ScopedXmlPtr::type(); + // TODO(rkuroiwa): Add TextInfo. - // TODO(rkuroiwa): Add ContentProtection info. if (HasVODOnlyFields(media_info_) && !representation.AddVODOnlyInfo(media_info_)) { - LOG(ERROR) << "Failed to add VOD info."; + LOG(ERROR) << "Failed to add VOD segment info."; return xml::ScopedXmlPtr::type(); } diff --git a/mpd/base/mpd_builder_unittest.cc b/mpd/base/mpd_builder_unittest.cc index dabd0837e1..eda5542795 100644 --- a/mpd/base/mpd_builder_unittest.cc +++ b/mpd/base/mpd_builder_unittest.cc @@ -15,7 +15,7 @@ namespace dash_packager { class StaticMpdBuilderTest : public ::testing::Test { public: StaticMpdBuilderTest() : mpd_(MpdBuilder::kStatic) {} - ~StaticMpdBuilderTest() {} + virtual ~StaticMpdBuilderTest() {} void CheckMpd(const std::string& expected_output_file) { std::string mpd_doc; @@ -73,8 +73,7 @@ TEST_F(StaticMpdBuilderTest, VideoAndAudio) { // MPD schema has strict ordering. AudioChannelConfiguration must appear before // ContentProtection. // TODO(rkuroiwa): Enable this when implemented. -TEST_F(StaticMpdBuilderTest, - DISABLED_AudioChannelConfigurationWithContentProtection) { +TEST_F(StaticMpdBuilderTest, AudioChannelConfigurationWithContentProtection) { MediaInfo encrypted_audio_media_info = GetTestMediaInfo(kFileNameEncytpedAudioMediaInfo); diff --git a/mpd/util/mpd_writer_unittest.cc b/mpd/util/mpd_writer_unittest.cc index 2560b34343..8f1fe1104a 100644 --- a/mpd/util/mpd_writer_unittest.cc +++ b/mpd/util/mpd_writer_unittest.cc @@ -81,7 +81,7 @@ TEST(MpdWriterTest, VideoAudioMediaInfo) { } // TODO(rkuroiwa): Enable this when implemented. -TEST(MpdWriterTest, DISABLED_EncryptedAudioMediaInfo) { +TEST(MpdWriterTest, EncryptedAudioMediaInfo) { MpdWriter mpd_writer; base::FilePath encrypted_audio_media_info = GetTestDataFilePath(kFileNameEncytpedAudioMediaInfo);