Put Role element before Representation

- Follwing the MPD schema.

Change-Id: I2aadf43be224c7fb565592b1814e4bec74ac4800
This commit is contained in:
Rintaro Kuroiwa 2015-08-24 12:35:00 -07:00
parent 0614caed83
commit 5a38dc9c12
2 changed files with 25 additions and 9 deletions

View File

@ -697,6 +697,11 @@ xml::ScopedXmlPtr<xmlNode>::type AdaptationSet::GetXml() {
content_protection_elements_)) { content_protection_elements_)) {
return xml::ScopedXmlPtr<xmlNode>::type(); return xml::ScopedXmlPtr<xmlNode>::type();
} }
for (std::set<Role>::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<Representation*>::iterator representation_it = std::list<Representation*>::iterator representation_it =
representations_.begin(); representations_.begin();
@ -751,11 +756,6 @@ xml::ScopedXmlPtr<xmlNode>::type AdaptationSet::GetXml() {
if (group_ >= 0) if (group_ >= 0)
adaptation_set.SetIntegerAttribute("group", group_); adaptation_set.SetIntegerAttribute("group", group_);
for (std::set<Role>::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(); return adaptation_set.PassScopedPtr();
} }

View File

@ -607,15 +607,24 @@ TEST_F(CommonMpdBuilderTest, AdaptationAddRoleElementMain) {
<< "Actual: " << mpd_output; << "Actual: " << mpd_output;
} }
// Add Role and ContentProtection elements. Verify that ContentProtection appear // Add Role, ContentProtection, and Representation elements. Verify that
// before Role. // ContentProtection -> Role -> Representation are in order.
TEST_F(CommonMpdBuilderTest, AddContentProtectionAndRole) { TEST_F(CommonMpdBuilderTest, CheckContentProtectionRoleRepresentationOrder) {
MpdBuilder mpd_builder(MpdBuilder::kStatic, MpdOptions()); MpdBuilder mpd_builder(MpdBuilder::kStatic, MpdOptions());
AdaptationSet* adaptation_set = mpd_builder.AddAdaptationSet(""); AdaptationSet* adaptation_set = mpd_builder.AddAdaptationSet("");
adaptation_set->AddRole(AdaptationSet::kRoleMain); adaptation_set->AddRole(AdaptationSet::kRoleMain);
ContentProtectionElement any_content_protection; ContentProtectionElement any_content_protection;
any_content_protection.scheme_id_uri = "any_scheme"; any_content_protection.scheme_id_uri = "any_scheme";
adaptation_set->AddContentProtectionElement(any_content_protection); 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<xmlNode>::type adaptation_set_xml(adaptation_set->GetXml()); xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(adaptation_set->GetXml());
const char kExpectedOutput[] = const char kExpectedOutput[] =
@ -628,9 +637,16 @@ TEST_F(CommonMpdBuilderTest, AddContentProtectionAndRole) {
" profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\"\n" " profiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\"\n"
" mediaPresentationDuration=\"PT0S\">\n" " mediaPresentationDuration=\"PT0S\">\n"
" <Period>\n" " <Period>\n"
" <AdaptationSet id=\"0\" contentType=\"\">\n" " <AdaptationSet id=\"0\" contentType=\"audio\">\n"
" <ContentProtection schemeIdUri=\"any_scheme\"/>\n" " <ContentProtection schemeIdUri=\"any_scheme\"/>\n"
" <Role schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"main\"/>\n" " <Role schemeIdUri=\"urn:mpeg:dash:role:2011\" value=\"main\"/>\n"
" <Representation id=\"0\" bandwidth=\"0\" codecs=\"mp4a.40.2\"\n"
" mimeType=\"audio/mp4\" audioSamplingRate=\"44100\">\n"
" <AudioChannelConfiguration\n"
" schemeIdUri=\n"
" \"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\"\n"
" value=\"2\"/>\n"
" </Representation>\n"
" </AdaptationSet>\n" " </AdaptationSet>\n"
" </Period>\n" " </Period>\n"
"</MPD>"; "</MPD>";