diff --git a/packager/mpd/base/mpd_builder.cc b/packager/mpd/base/mpd_builder.cc index 8e8dca27c7..7bddb8aa48 100644 --- a/packager/mpd/base/mpd_builder.cc +++ b/packager/mpd/base/mpd_builder.cc @@ -697,6 +697,11 @@ xml::ScopedXmlPtr::type AdaptationSet::GetXml() { content_protection_elements_)) { return xml::ScopedXmlPtr::type(); } + for (std::set::const_iterator role_it = roles_.begin(); + role_it != roles_.end(); ++role_it) { + adaptation_set.AddRoleElement("urn:mpeg:dash:role:2011", + RoleToText(*role_it)); + } std::list::iterator representation_it = representations_.begin(); @@ -751,11 +756,6 @@ xml::ScopedXmlPtr::type AdaptationSet::GetXml() { if (group_ >= 0) adaptation_set.SetIntegerAttribute("group", group_); - for (std::set::const_iterator role_it = roles_.begin(); - role_it != roles_.end(); ++role_it) { - adaptation_set.AddRoleElement("urn:mpeg:dash:role:2011", - RoleToText(*role_it)); - } return adaptation_set.PassScopedPtr(); } diff --git a/packager/mpd/base/mpd_builder_unittest.cc b/packager/mpd/base/mpd_builder_unittest.cc index 8497286fa4..e306ba2e05 100644 --- a/packager/mpd/base/mpd_builder_unittest.cc +++ b/packager/mpd/base/mpd_builder_unittest.cc @@ -607,15 +607,24 @@ TEST_F(CommonMpdBuilderTest, AdaptationAddRoleElementMain) { << "Actual: " << mpd_output; } -// Add Role and ContentProtection elements. Verify that ContentProtection appear -// before Role. -TEST_F(CommonMpdBuilderTest, AddContentProtectionAndRole) { +// Add Role, ContentProtection, and Representation elements. Verify that +// ContentProtection -> Role -> Representation are in order. +TEST_F(CommonMpdBuilderTest, CheckContentProtectionRoleRepresentationOrder) { MpdBuilder mpd_builder(MpdBuilder::kStatic, MpdOptions()); AdaptationSet* adaptation_set = mpd_builder.AddAdaptationSet(""); adaptation_set->AddRole(AdaptationSet::kRoleMain); ContentProtectionElement any_content_protection; any_content_protection.scheme_id_uri = "any_scheme"; adaptation_set->AddContentProtectionElement(any_content_protection); + const char kAudioMediaInfo[] = + "audio_info {\n" + " codec: 'mp4a.40.2'\n" + " sampling_frequency: 44100\n" + " time_scale: 1200\n" + " num_channels: 2\n" + "}\n" + "container_type: 1\n"; + adaptation_set->AddRepresentation(ConvertToMediaInfo(kAudioMediaInfo)); xml::ScopedXmlPtr::type adaptation_set_xml(adaptation_set->GetXml()); const char kExpectedOutput[] = @@ -628,9 +637,16 @@ TEST_F(CommonMpdBuilderTest, AddContentProtectionAndRole) { " profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\"\n" " mediaPresentationDuration=\"PT0S\">\n" " \n" - " \n" + " \n" " \n" " \n" + " \n" + " \n" + " \n" " \n" " \n" "";