diff --git a/mpd/base/mpd_builder.cc b/mpd/base/mpd_builder.cc index 292340be21..6abdd45cc4 100644 --- a/mpd/base/mpd_builder.cc +++ b/mpd/base/mpd_builder.cc @@ -279,7 +279,7 @@ xml::ScopedXmlPtr::type Representation::GetXml() { // Two 'Mandatory' fields for Representation. representation.SetId(id_); - representation.SetNumberAttribute("bandwidth", media_info_.bandwidth()); + representation.SetIntegerAttribute("bandwidth", media_info_.bandwidth()); const bool has_video_info = media_info_.video_info_size() > 0; const bool has_audio_info = media_info_.audio_info_size() > 0; diff --git a/mpd/base/mpd_utils.cc b/mpd/base/mpd_utils.cc index deb27ad581..6bd8b05d4d 100644 --- a/mpd/base/mpd_utils.cc +++ b/mpd/base/mpd_utils.cc @@ -34,12 +34,14 @@ namespace dash_packager { bool HasVODOnlyFields(const MediaInfo& media_info) { return media_info.has_init_range() || media_info.has_index_range() || - media_info.has_media_file_name() || media_info.has_media_duration(); + media_info.has_media_file_name() || + media_info.has_media_duration_seconds(); } bool HasLiveOnlyFields(const MediaInfo& media_info) { return media_info.has_init_segment_name() || - media_info.has_segment_template() || media_info.has_segment_duration(); + media_info.has_segment_template() || + media_info.has_segment_duration_seconds(); } void RemoveDuplicateAttributes( diff --git a/mpd/base/xml/xml_node.cc b/mpd/base/xml/xml_node.cc index f33d8a764c..ae3094d142 100644 --- a/mpd/base/xml/xml_node.cc +++ b/mpd/base/xml/xml_node.cc @@ -45,7 +45,7 @@ void XmlNode::SetStringAttribute(const char* attribute_name, xmlNewProp(node_.get(), BAD_CAST attribute_name, BAD_CAST attribute.c_str()); } -void XmlNode::SetNumberAttribute(const char* attribute_name, uint64 number) { +void XmlNode::SetIntegerAttribute(const char* attribute_name, uint64 number) { DCHECK(node_); DCHECK(attribute_name); xmlNewProp(node_.get(), @@ -53,8 +53,17 @@ void XmlNode::SetNumberAttribute(const char* attribute_name, uint64 number) { BAD_CAST (base::Uint64ToString(number).c_str())); } +void XmlNode::SetFloatingPointAttribute(const char* attribute_name, + double number) { + DCHECK(node_); + DCHECK(attribute_name); + xmlNewProp(node_.get(), + BAD_CAST attribute_name, + BAD_CAST (base::DoubleToString(number).c_str())); +} + void XmlNode::SetId(uint32 id) { - SetNumberAttribute("id", id); + SetIntegerAttribute("id", id); } void XmlNode::SetContent(const std::string& content) { @@ -152,10 +161,10 @@ bool RepresentationXmlNode::AddVideoInfo( } if (width != 0) - SetNumberAttribute("width", width); + SetIntegerAttribute("width", width); if (height != 0) - SetNumberAttribute("height", height); + SetIntegerAttribute("height", height); return true; } @@ -175,8 +184,8 @@ bool RepresentationXmlNode::AddAudioInfo( // classes should do this or maybe in this class. bool RepresentationXmlNode::AddVODOnlyInfo(const MediaInfo& media_info) { const bool need_segment_base = media_info.has_index_range() || - media_info.has_time_scale() || - media_info.has_init_range(); + media_info.has_init_range() || + media_info.has_reference_time_scale(); if (need_segment_base) { XmlNode segment_base("SegmentBase"); @@ -185,8 +194,10 @@ bool RepresentationXmlNode::AddVODOnlyInfo(const MediaInfo& media_info) { RangeToString(media_info.index_range())); } - if (media_info.has_time_scale()) - segment_base.SetNumberAttribute("timescale", media_info.time_scale()); + if (media_info.has_reference_time_scale()) { + segment_base.SetIntegerAttribute("timescale", + media_info.reference_time_scale()); + } if (media_info.has_init_range()) { XmlNode initialization("Initialization"); @@ -209,10 +220,10 @@ bool RepresentationXmlNode::AddVODOnlyInfo(const MediaInfo& media_info) { return false; } - if (media_info.has_media_duration()) { + if (media_info.has_media_duration_seconds()) { // Adding 'duration' attribute, so that this information can be used when // generating one MPD file. This should be removed from the final MPD. - SetNumberAttribute("duration", media_info.media_duration()); + SetFloatingPointAttribute("duration", media_info.media_duration_seconds()); } return true; @@ -236,7 +247,7 @@ bool RepresentationXmlNode::AddAudioChannelInfo( "urn:mpeg:dash:23003:3:audio_channel_configuration:2011"; audio_channel_config.SetStringAttribute("schemeIdUri", kAudioChannelConfigScheme); - audio_channel_config.SetNumberAttribute("value", *num_channels_it); + audio_channel_config.SetIntegerAttribute("value", *num_channels_it); if (!AddChild(audio_channel_config.PassScopedPtr())) return false; @@ -268,7 +279,7 @@ void RepresentationXmlNode::AddAudioSamplingRateInfo( if (has_sampling_frequency) { if (min_sampling_frequency == max_sampling_frequency) { - SetNumberAttribute("audioSamplingRate", min_sampling_frequency); + SetIntegerAttribute("audioSamplingRate", min_sampling_frequency); } else { std::string sample_rate_string = base::UintToString(min_sampling_frequency) + " " + diff --git a/mpd/base/xml/xml_node.h b/mpd/base/xml/xml_node.h index eaa00cc5e1..a1b1c9a011 100644 --- a/mpd/base/xml/xml_node.h +++ b/mpd/base/xml/xml_node.h @@ -30,7 +30,8 @@ class XmlNode { void SetStringAttribute(const char* attribute_name, const std::string& attribute); - void SetNumberAttribute(const char* attribute_name, uint64 number); + void SetIntegerAttribute(const char* attribute_name, uint64 number); + void SetFloatingPointAttribute(const char* attribute_name, double number); void SetId(uint32 id);