Use alias template for ScopedXmlPtr
- Also renamed to scoped_xml_ptr to match other smart pointers. Change-Id: Idb998aa3252d4f3a50068a09e26a05f124e94a2f
This commit is contained in:
parent
8072fd1eaf
commit
d3c52cffd9
|
@ -427,7 +427,7 @@ template <typename OutputType>
|
||||||
bool MpdBuilder::WriteMpdToOutput(OutputType* output) {
|
bool MpdBuilder::WriteMpdToOutput(OutputType* output) {
|
||||||
static LibXmlInitializer lib_xml_initializer;
|
static LibXmlInitializer lib_xml_initializer;
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type doc(GenerateMpd());
|
xml::scoped_xml_ptr<xmlDoc> doc(GenerateMpd());
|
||||||
if (!doc.get())
|
if (!doc.get())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ bool MpdBuilder::WriteMpdToOutput(OutputType* output) {
|
||||||
xmlDocPtr MpdBuilder::GenerateMpd() {
|
xmlDocPtr MpdBuilder::GenerateMpd() {
|
||||||
// Setup nodes.
|
// Setup nodes.
|
||||||
static const char kXmlVersion[] = "1.0";
|
static const char kXmlVersion[] = "1.0";
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type doc(xmlNewDoc(BAD_CAST kXmlVersion));
|
xml::scoped_xml_ptr<xmlDoc> doc(xmlNewDoc(BAD_CAST kXmlVersion));
|
||||||
XmlNode mpd("MPD");
|
XmlNode mpd("MPD");
|
||||||
|
|
||||||
// Iterate thru AdaptationSets and add them to one big Period element.
|
// Iterate thru AdaptationSets and add them to one big Period element.
|
||||||
|
@ -456,7 +456,7 @@ xmlDocPtr MpdBuilder::GenerateMpd() {
|
||||||
std::list<AdaptationSet*>::iterator adaptation_sets_it =
|
std::list<AdaptationSet*>::iterator adaptation_sets_it =
|
||||||
adaptation_sets_.begin();
|
adaptation_sets_.begin();
|
||||||
for (; adaptation_sets_it != adaptation_sets_.end(); ++adaptation_sets_it) {
|
for (; adaptation_sets_it != adaptation_sets_.end(); ++adaptation_sets_it) {
|
||||||
xml::ScopedXmlPtr<xmlNode>::type child((*adaptation_sets_it)->GetXml());
|
xml::scoped_xml_ptr<xmlNode> child((*adaptation_sets_it)->GetXml());
|
||||||
if (!child.get() || !period.AddChild(child.Pass()))
|
if (!child.get() || !period.AddChild(child.Pass()))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -725,12 +725,12 @@ void AdaptationSet::AddRole(Role role) {
|
||||||
|
|
||||||
// Creates a copy of <AdaptationSet> xml element, iterate thru all the
|
// Creates a copy of <AdaptationSet> xml element, iterate thru all the
|
||||||
// <Representation> (child) elements and add them to the copy.
|
// <Representation> (child) elements and add them to the copy.
|
||||||
xml::ScopedXmlPtr<xmlNode>::type AdaptationSet::GetXml() {
|
xml::scoped_xml_ptr<xmlNode> AdaptationSet::GetXml() {
|
||||||
AdaptationSetXmlNode adaptation_set;
|
AdaptationSetXmlNode adaptation_set;
|
||||||
|
|
||||||
if (!adaptation_set.AddContentProtectionElements(
|
if (!adaptation_set.AddContentProtectionElements(
|
||||||
content_protection_elements_)) {
|
content_protection_elements_)) {
|
||||||
return xml::ScopedXmlPtr<xmlNode>::type();
|
return xml::scoped_xml_ptr<xmlNode>();
|
||||||
}
|
}
|
||||||
for (std::set<Role>::const_iterator role_it = roles_.begin();
|
for (std::set<Role>::const_iterator role_it = roles_.begin();
|
||||||
role_it != roles_.end(); ++role_it) {
|
role_it != roles_.end(); ++role_it) {
|
||||||
|
@ -742,9 +742,9 @@ xml::ScopedXmlPtr<xmlNode>::type AdaptationSet::GetXml() {
|
||||||
representations_.begin();
|
representations_.begin();
|
||||||
|
|
||||||
for (; representation_it != representations_.end(); ++representation_it) {
|
for (; representation_it != representations_.end(); ++representation_it) {
|
||||||
xml::ScopedXmlPtr<xmlNode>::type child((*representation_it)->GetXml());
|
xml::scoped_xml_ptr<xmlNode> child((*representation_it)->GetXml());
|
||||||
if (!child || !adaptation_set.AddChild(child.Pass()))
|
if (!child || !adaptation_set.AddChild(child.Pass()))
|
||||||
return xml::ScopedXmlPtr<xmlNode>::type();
|
return xml::scoped_xml_ptr<xmlNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
adaptation_set.SetId(id_);
|
adaptation_set.SetId(id_);
|
||||||
|
@ -1101,10 +1101,10 @@ void Representation::SetSampleDuration(uint32_t sample_duration) {
|
||||||
// AddVideoInfo() (possibly adds FramePacking elements), AddAudioInfo() (Adds
|
// AddVideoInfo() (possibly adds FramePacking elements), AddAudioInfo() (Adds
|
||||||
// AudioChannelConfig elements), AddContentProtectionElements*(), and
|
// AudioChannelConfig elements), AddContentProtectionElements*(), and
|
||||||
// AddVODOnlyInfo() (Adds segment info).
|
// AddVODOnlyInfo() (Adds segment info).
|
||||||
xml::ScopedXmlPtr<xmlNode>::type Representation::GetXml() {
|
xml::scoped_xml_ptr<xmlNode> Representation::GetXml() {
|
||||||
if (!HasRequiredMediaInfoFields()) {
|
if (!HasRequiredMediaInfoFields()) {
|
||||||
LOG(ERROR) << "MediaInfo missing required fields.";
|
LOG(ERROR) << "MediaInfo missing required fields.";
|
||||||
return xml::ScopedXmlPtr<xmlNode>::type();
|
return xml::scoped_xml_ptr<xmlNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t bandwidth = media_info_.has_bandwidth()
|
const uint64_t bandwidth = media_info_.has_bandwidth()
|
||||||
|
@ -1127,31 +1127,31 @@ xml::ScopedXmlPtr<xmlNode>::type Representation::GetXml() {
|
||||||
if (has_video_info &&
|
if (has_video_info &&
|
||||||
!representation.AddVideoInfo(media_info_.video_info())) {
|
!representation.AddVideoInfo(media_info_.video_info())) {
|
||||||
LOG(ERROR) << "Failed to add video info to Representation XML.";
|
LOG(ERROR) << "Failed to add video info to Representation XML.";
|
||||||
return xml::ScopedXmlPtr<xmlNode>::type();
|
return xml::scoped_xml_ptr<xmlNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_audio_info &&
|
if (has_audio_info &&
|
||||||
!representation.AddAudioInfo(media_info_.audio_info())) {
|
!representation.AddAudioInfo(media_info_.audio_info())) {
|
||||||
LOG(ERROR) << "Failed to add audio info to Representation XML.";
|
LOG(ERROR) << "Failed to add audio info to Representation XML.";
|
||||||
return xml::ScopedXmlPtr<xmlNode>::type();
|
return xml::scoped_xml_ptr<xmlNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!representation.AddContentProtectionElements(
|
if (!representation.AddContentProtectionElements(
|
||||||
content_protection_elements_)) {
|
content_protection_elements_)) {
|
||||||
return xml::ScopedXmlPtr<xmlNode>::type();
|
return xml::scoped_xml_ptr<xmlNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasVODOnlyFields(media_info_) &&
|
if (HasVODOnlyFields(media_info_) &&
|
||||||
!representation.AddVODOnlyInfo(media_info_)) {
|
!representation.AddVODOnlyInfo(media_info_)) {
|
||||||
LOG(ERROR) << "Failed to add VOD segment info.";
|
LOG(ERROR) << "Failed to add VOD segment info.";
|
||||||
return xml::ScopedXmlPtr<xmlNode>::type();
|
return xml::scoped_xml_ptr<xmlNode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasLiveOnlyFields(media_info_) &&
|
if (HasLiveOnlyFields(media_info_) &&
|
||||||
!representation.AddLiveOnlyInfo(media_info_, segment_infos_,
|
!representation.AddLiveOnlyInfo(media_info_, segment_infos_,
|
||||||
start_number_)) {
|
start_number_)) {
|
||||||
LOG(ERROR) << "Failed to add Live info.";
|
LOG(ERROR) << "Failed to add Live info.";
|
||||||
return xml::ScopedXmlPtr<xmlNode>::type();
|
return xml::scoped_xml_ptr<xmlNode>();
|
||||||
}
|
}
|
||||||
// TODO(rkuroiwa): It is likely that all representations have the exact same
|
// TODO(rkuroiwa): It is likely that all representations have the exact same
|
||||||
// SegmentTemplate. Optimize and propagate the tag up to AdaptationSet level.
|
// SegmentTemplate. Optimize and propagate the tag up to AdaptationSet level.
|
||||||
|
|
|
@ -210,9 +210,9 @@ class AdaptationSet {
|
||||||
|
|
||||||
/// Makes a copy of AdaptationSet xml element with its child Representation
|
/// Makes a copy of AdaptationSet xml element with its child Representation
|
||||||
/// and ContentProtection elements.
|
/// and ContentProtection elements.
|
||||||
/// @return On success returns a non-NULL ScopedXmlPtr. Otherwise returns a
|
/// @return On success returns a non-NULL scoped_xml_ptr. Otherwise returns a
|
||||||
/// NULL ScopedXmlPtr.
|
/// NULL scoped_xml_ptr.
|
||||||
xml::ScopedXmlPtr<xmlNode>::type GetXml();
|
xml::scoped_xml_ptr<xmlNode> GetXml();
|
||||||
|
|
||||||
/// Forces the (sub)segmentAlignment field to be set to @a segment_alignment.
|
/// Forces the (sub)segmentAlignment field to be set to @a segment_alignment.
|
||||||
/// Use this if you are certain that the (sub)segments are alinged/unaligned
|
/// Use this if you are certain that the (sub)segments are alinged/unaligned
|
||||||
|
@ -468,7 +468,7 @@ class Representation {
|
||||||
virtual void SetSampleDuration(uint32_t sample_duration);
|
virtual void SetSampleDuration(uint32_t sample_duration);
|
||||||
|
|
||||||
/// @return Copy of <Representation>.
|
/// @return Copy of <Representation>.
|
||||||
xml::ScopedXmlPtr<xmlNode>::type GetXml();
|
xml::scoped_xml_ptr<xmlNode> GetXml();
|
||||||
|
|
||||||
/// @return ID number for <Representation>.
|
/// @return ID number for <Representation>.
|
||||||
uint32_t id() const { return id_; }
|
uint32_t id() const { return id_; }
|
||||||
|
|
|
@ -41,7 +41,7 @@ const int kDefaultStartNumber = 1;
|
||||||
// number.
|
// number.
|
||||||
void ExpectXmlElementIdEqual(xmlNodePtr node, uint32_t id) {
|
void ExpectXmlElementIdEqual(xmlNodePtr node, uint32_t id) {
|
||||||
const char kId[] = "id";
|
const char kId[] = "id";
|
||||||
xml::ScopedXmlPtr<xmlChar>::type id_attribute_xml_str(
|
xml::scoped_xml_ptr<xmlChar> id_attribute_xml_str(
|
||||||
xmlGetProp(node, BAD_CAST kId));
|
xmlGetProp(node, BAD_CAST kId));
|
||||||
ASSERT_TRUE(id_attribute_xml_str);
|
ASSERT_TRUE(id_attribute_xml_str);
|
||||||
|
|
||||||
|
@ -59,14 +59,14 @@ void CheckIdEqual(uint32_t expected_id, T* node) {
|
||||||
ASSERT_EQ(expected_id, node->id());
|
ASSERT_EQ(expected_id, node->id());
|
||||||
|
|
||||||
// Also check if the XML generated by libxml2 has the correct id attribute.
|
// Also check if the XML generated by libxml2 has the correct id attribute.
|
||||||
xml::ScopedXmlPtr<xmlNode>::type node_xml(node->GetXml());
|
xml::scoped_xml_ptr<xmlNode> node_xml(node->GetXml());
|
||||||
ASSERT_NO_FATAL_FAILURE(ExpectXmlElementIdEqual(node_xml.get(), expected_id));
|
ASSERT_NO_FATAL_FAILURE(ExpectXmlElementIdEqual(node_xml.get(), expected_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExpectAttributeEqString(base::StringPiece attribute,
|
void ExpectAttributeEqString(base::StringPiece attribute,
|
||||||
base::StringPiece expected_value,
|
base::StringPiece expected_value,
|
||||||
xmlNodePtr node) {
|
xmlNodePtr node) {
|
||||||
xml::ScopedXmlPtr<xmlChar>::type attribute_xml_str(
|
xml::scoped_xml_ptr<xmlChar> attribute_xml_str(
|
||||||
xmlGetProp(node, BAD_CAST attribute.data()));
|
xmlGetProp(node, BAD_CAST attribute.data()));
|
||||||
ASSERT_TRUE(attribute_xml_str);
|
ASSERT_TRUE(attribute_xml_str);
|
||||||
EXPECT_STREQ(expected_value.data(),
|
EXPECT_STREQ(expected_value.data(),
|
||||||
|
@ -75,7 +75,7 @@ void ExpectAttributeEqString(base::StringPiece attribute,
|
||||||
|
|
||||||
// |attribute| should not be set in |node|.
|
// |attribute| should not be set in |node|.
|
||||||
void ExpectAttributeNotSet(base::StringPiece attribute, xmlNodePtr node) {
|
void ExpectAttributeNotSet(base::StringPiece attribute, xmlNodePtr node) {
|
||||||
xml::ScopedXmlPtr<xmlChar>::type attribute_xml_str(
|
xml::scoped_xml_ptr<xmlChar> attribute_xml_str(
|
||||||
xmlGetProp(node, BAD_CAST attribute.data()));
|
xmlGetProp(node, BAD_CAST attribute.data()));
|
||||||
ASSERT_FALSE(attribute_xml_str);
|
ASSERT_FALSE(attribute_xml_str);
|
||||||
}
|
}
|
||||||
|
@ -382,13 +382,13 @@ TEST_F(CommonMpdBuilderTest, SetAdaptationSetGroup) {
|
||||||
MpdBuilder::kStatic, &sequence_counter);
|
MpdBuilder::kStatic, &sequence_counter);
|
||||||
adaptation_set->SetGroup(1);
|
adaptation_set->SetGroup(1);
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type xml_with_group(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> xml_with_group(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("group", "1", xml_with_group.get()));
|
ExpectAttributeEqString("group", "1", xml_with_group.get()));
|
||||||
|
|
||||||
// Unset by passing a negative value.
|
// Unset by passing a negative value.
|
||||||
adaptation_set->SetGroup(-1);
|
adaptation_set->SetGroup(-1);
|
||||||
xml::ScopedXmlPtr<xmlNode>::type xml_without_group(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> xml_without_group(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("group", xml_without_group.get()));
|
ExpectAttributeNotSet("group", xml_without_group.get()));
|
||||||
}
|
}
|
||||||
|
@ -486,7 +486,7 @@ TEST_F(CommonMpdBuilderTest, CheckVideoInfoReflectedInXml) {
|
||||||
CreateRepresentation(ConvertToMediaInfo(kTestMediaInfo), MpdOptions(),
|
CreateRepresentation(ConvertToMediaInfo(kTestMediaInfo), MpdOptions(),
|
||||||
kAnyRepresentationId, NoListener());
|
kAnyRepresentationId, NoListener());
|
||||||
EXPECT_TRUE(representation->Init());
|
EXPECT_TRUE(representation->Init());
|
||||||
xml::ScopedXmlPtr<xmlNode>::type node_xml(representation->GetXml());
|
xml::scoped_xml_ptr<xmlNode> node_xml(representation->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("codecs", "avc1", node_xml.get()));
|
ExpectAttributeEqString("codecs", "avc1", node_xml.get()));
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
|
@ -687,7 +687,7 @@ TEST_F(CommonMpdBuilderTest, CheckLanguageAttributeSet) {
|
||||||
MpdBuilder::kStatic, &sequence_counter);
|
MpdBuilder::kStatic, &sequence_counter);
|
||||||
adaptation_set->AddRepresentation(ConvertToMediaInfo(kTextMediaInfo));
|
adaptation_set->AddRepresentation(ConvertToMediaInfo(kTextMediaInfo));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type node_xml(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> node_xml(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("lang", "en", node_xml.get()));
|
ExpectAttributeEqString("lang", "en", node_xml.get()));
|
||||||
}
|
}
|
||||||
|
@ -707,7 +707,7 @@ TEST_F(CommonMpdBuilderTest, AdaptationAddRoleElementMain) {
|
||||||
AdaptationSet* adaptation_set = mpd_builder.AddAdaptationSet("");
|
AdaptationSet* adaptation_set = mpd_builder.AddAdaptationSet("");
|
||||||
|
|
||||||
adaptation_set->AddRole(AdaptationSet::kRoleMain);
|
adaptation_set->AddRole(AdaptationSet::kRoleMain);
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(adaptation_set->GetXml());
|
||||||
// The empty contentType is sort of a side effect of being able to generate an
|
// The empty contentType is sort of a side effect of being able to generate an
|
||||||
// MPD without adding any Representations.
|
// MPD without adding any Representations.
|
||||||
const char kExpectedOutput[] =
|
const char kExpectedOutput[] =
|
||||||
|
@ -752,7 +752,7 @@ TEST_F(CommonMpdBuilderTest, CheckContentProtectionRoleRepresentationOrder) {
|
||||||
"container_type: 1\n";
|
"container_type: 1\n";
|
||||||
adaptation_set->AddRepresentation(ConvertToMediaInfo(kAudioMediaInfo));
|
adaptation_set->AddRepresentation(ConvertToMediaInfo(kAudioMediaInfo));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(adaptation_set->GetXml());
|
||||||
const char kExpectedOutput[] =
|
const char kExpectedOutput[] =
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
"<MPD xmlns=\"urn:mpeg:DASH:schema:MPD:2011\"\n"
|
"<MPD xmlns=\"urn:mpeg:DASH:schema:MPD:2011\"\n"
|
||||||
|
@ -812,7 +812,7 @@ TEST_F(CommonMpdBuilderTest, AdapatationSetFrameRate) {
|
||||||
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
||||||
ConvertToMediaInfo(kVideoMediaInfo2)));
|
ConvertToMediaInfo(kVideoMediaInfo2)));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
|
||||||
video_adaptation_set->GetXml());
|
video_adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("frameRate", "10/3", adaptation_set_xml.get()));
|
ExpectAttributeEqString("frameRate", "10/3", adaptation_set_xml.get()));
|
||||||
|
@ -849,7 +849,7 @@ TEST_F(CommonMpdBuilderTest, AdapatationSetMaxFrameRate) {
|
||||||
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
||||||
ConvertToMediaInfo(kVideoMediaInfo15fps)));
|
ConvertToMediaInfo(kVideoMediaInfo15fps)));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
|
||||||
video_adaptation_set->GetXml());
|
video_adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString("maxFrameRate", "3000/100",
|
EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString("maxFrameRate", "3000/100",
|
||||||
adaptation_set_xml.get()));
|
adaptation_set_xml.get()));
|
||||||
|
@ -898,7 +898,7 @@ TEST_F(CommonMpdBuilderTest,
|
||||||
|
|
||||||
// First, make sure that maxFrameRate nor frameRate are set because
|
// First, make sure that maxFrameRate nor frameRate are set because
|
||||||
// frame durations were not provided in the MediaInfo.
|
// frame durations were not provided in the MediaInfo.
|
||||||
xml::ScopedXmlPtr<xmlNode>::type no_frame_rate(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> no_frame_rate(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("maxFrameRate", no_frame_rate.get()));
|
ExpectAttributeNotSet("maxFrameRate", no_frame_rate.get()));
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
|
@ -910,7 +910,7 @@ TEST_F(CommonMpdBuilderTest,
|
||||||
representation_480p->SetSampleDuration(kSameFrameDuration);
|
representation_480p->SetSampleDuration(kSameFrameDuration);
|
||||||
representation_360p->SetSampleDuration(kSameFrameDuration);
|
representation_360p->SetSampleDuration(kSameFrameDuration);
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type same_frame_rate(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> same_frame_rate(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("maxFrameRate", same_frame_rate.get()));
|
ExpectAttributeNotSet("maxFrameRate", same_frame_rate.get()));
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
|
@ -922,7 +922,7 @@ TEST_F(CommonMpdBuilderTest,
|
||||||
frame_duration_must_be_shorter_for_max_frame_rate);
|
frame_duration_must_be_shorter_for_max_frame_rate);
|
||||||
representation_480p->SetSampleDuration(k5FPSFrameDuration);
|
representation_480p->SetSampleDuration(k5FPSFrameDuration);
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type max_frame_rate(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> max_frame_rate(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("maxFrameRate", "10/2", max_frame_rate.get()));
|
ExpectAttributeEqString("maxFrameRate", "10/2", max_frame_rate.get()));
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
|
@ -991,7 +991,7 @@ TEST_F(CommonMpdBuilderTest, AdaptationSetParAllSame) {
|
||||||
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
||||||
ConvertToMediaInfo(k360pVideoInfo)));
|
ConvertToMediaInfo(k360pVideoInfo)));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
|
||||||
video_adaptation_set->GetXml());
|
video_adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString("par", "16:9",
|
EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString("par", "16:9",
|
||||||
adaptation_set_xml.get()));
|
adaptation_set_xml.get()));
|
||||||
|
@ -1031,7 +1031,7 @@ TEST_F(CommonMpdBuilderTest, AdaptationSetParDifferent) {
|
||||||
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
||||||
ConvertToMediaInfo(k2by1VideoInfo)));
|
ConvertToMediaInfo(k2by1VideoInfo)));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
|
||||||
video_adaptation_set->GetXml());
|
video_adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("par", adaptation_set_xml.get()));
|
ExpectAttributeNotSet("par", adaptation_set_xml.get()));
|
||||||
|
@ -1055,7 +1055,7 @@ TEST_F(CommonMpdBuilderTest, AdaptationSetParUnknown) {
|
||||||
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
||||||
ConvertToMediaInfo(kUknownPixelWidthAndHeight)));
|
ConvertToMediaInfo(kUknownPixelWidthAndHeight)));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
|
||||||
video_adaptation_set->GetXml());
|
video_adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("par", adaptation_set_xml.get()));
|
ExpectAttributeNotSet("par", adaptation_set_xml.get()));
|
||||||
|
@ -1093,7 +1093,7 @@ TEST_F(CommonMpdBuilderTest,
|
||||||
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
||||||
ConvertToMediaInfo(kVideoMediaInfo2)));
|
ConvertToMediaInfo(kVideoMediaInfo2)));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
|
||||||
video_adaptation_set->GetXml());
|
video_adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString("maxFrameRate", "11/3",
|
EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString("maxFrameRate", "11/3",
|
||||||
adaptation_set_xml.get()));
|
adaptation_set_xml.get()));
|
||||||
|
@ -1149,13 +1149,13 @@ TEST_F(StaticMpdBuilderTest, SubSegmentAlignment) {
|
||||||
adaptation_set->AddRepresentation(ConvertToMediaInfo(k360pMediaInfo));
|
adaptation_set->AddRepresentation(ConvertToMediaInfo(k360pMediaInfo));
|
||||||
representation_360p->AddNewSegment(kStartTime, kDuration, kAnySize);
|
representation_360p->AddNewSegment(kStartTime, kDuration, kAnySize);
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type aligned(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> aligned(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("subSegmentAlignment", "true", aligned.get()));
|
ExpectAttributeEqString("subSegmentAlignment", "true", aligned.get()));
|
||||||
|
|
||||||
// Unknown because 480p has an extra subsegments.
|
// Unknown because 480p has an extra subsegments.
|
||||||
representation_480p->AddNewSegment(11, 20, kAnySize);
|
representation_480p->AddNewSegment(11, 20, kAnySize);
|
||||||
xml::ScopedXmlPtr<xmlNode>::type alignment_unknown(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> alignment_unknown(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("subSegmentAlignment", alignment_unknown.get()));
|
ExpectAttributeNotSet("subSegmentAlignment", alignment_unknown.get()));
|
||||||
|
|
||||||
|
@ -1163,7 +1163,7 @@ TEST_F(StaticMpdBuilderTest, SubSegmentAlignment) {
|
||||||
representation_360p->AddNewSegment(10, 1, kAnySize);
|
representation_360p->AddNewSegment(10, 1, kAnySize);
|
||||||
representation_360p->AddNewSegment(11, 19, kAnySize);
|
representation_360p->AddNewSegment(11, 19, kAnySize);
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type unaligned(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> unaligned(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("subSegmentAlignment", unaligned.get()));
|
ExpectAttributeNotSet("subSegmentAlignment", unaligned.get()));
|
||||||
}
|
}
|
||||||
|
@ -1209,13 +1209,13 @@ TEST_F(StaticMpdBuilderTest, ForceSetSubSegmentAlignment) {
|
||||||
const uint64_t kAnySize = 19834u;
|
const uint64_t kAnySize = 19834u;
|
||||||
representation_480p->AddNewSegment(kStartTime1, kDuration, kAnySize);
|
representation_480p->AddNewSegment(kStartTime1, kDuration, kAnySize);
|
||||||
representation_360p->AddNewSegment(kStartTime2, kDuration, kAnySize);
|
representation_360p->AddNewSegment(kStartTime2, kDuration, kAnySize);
|
||||||
xml::ScopedXmlPtr<xmlNode>::type unaligned(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> unaligned(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("subSegmentAlignment", unaligned.get()));
|
ExpectAttributeNotSet("subSegmentAlignment", unaligned.get()));
|
||||||
|
|
||||||
// Then force set the segment alignment attribute to true.
|
// Then force set the segment alignment attribute to true.
|
||||||
adaptation_set->ForceSetSegmentAlignment(true);
|
adaptation_set->ForceSetSegmentAlignment(true);
|
||||||
xml::ScopedXmlPtr<xmlNode>::type aligned(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> aligned(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("subSegmentAlignment", "true", aligned.get()));
|
ExpectAttributeEqString("subSegmentAlignment", "true", aligned.get()));
|
||||||
}
|
}
|
||||||
|
@ -1261,7 +1261,7 @@ TEST_F(DynamicMpdBuilderTest, SegmentAlignment) {
|
||||||
const uint64_t kAnySize = 19834u;
|
const uint64_t kAnySize = 19834u;
|
||||||
representation_480p->AddNewSegment(kStartTime, kDuration, kAnySize);
|
representation_480p->AddNewSegment(kStartTime, kDuration, kAnySize);
|
||||||
representation_360p->AddNewSegment(kStartTime, kDuration, kAnySize);
|
representation_360p->AddNewSegment(kStartTime, kDuration, kAnySize);
|
||||||
xml::ScopedXmlPtr<xmlNode>::type aligned(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> aligned(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("segmentAlignment", "true", aligned.get()));
|
ExpectAttributeEqString("segmentAlignment", "true", aligned.get()));
|
||||||
|
|
||||||
|
@ -1270,7 +1270,7 @@ TEST_F(DynamicMpdBuilderTest, SegmentAlignment) {
|
||||||
representation_360p->AddNewSegment(10, 1, kAnySize);
|
representation_360p->AddNewSegment(10, 1, kAnySize);
|
||||||
representation_360p->AddNewSegment(11, 19, kAnySize);
|
representation_360p->AddNewSegment(11, 19, kAnySize);
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type unaligned(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> unaligned(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("subSegmentAlignment", unaligned.get()));
|
ExpectAttributeNotSet("subSegmentAlignment", unaligned.get()));
|
||||||
}
|
}
|
||||||
|
@ -1304,7 +1304,7 @@ TEST_F(StaticMpdBuilderTest, AdapatationSetWidthAndHeight) {
|
||||||
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
||||||
ConvertToMediaInfo(kVideoMediaInfo2)));
|
ConvertToMediaInfo(kVideoMediaInfo2)));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
|
||||||
video_adaptation_set->GetXml());
|
video_adaptation_set->GetXml());
|
||||||
ASSERT_NO_FATAL_FAILURE(
|
ASSERT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("width", "1280", adaptation_set_xml.get()));
|
ExpectAttributeEqString("width", "1280", adaptation_set_xml.get()));
|
||||||
|
@ -1344,7 +1344,7 @@ TEST_F(StaticMpdBuilderTest, AdapatationSetMaxWidthAndMaxHeight) {
|
||||||
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
|
||||||
ConvertToMediaInfo(kVideoMediaInfo720p)));
|
ConvertToMediaInfo(kVideoMediaInfo720p)));
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
|
||||||
video_adaptation_set->GetXml());
|
video_adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeEqString("maxWidth", "1920", adaptation_set_xml.get()));
|
ExpectAttributeEqString("maxWidth", "1920", adaptation_set_xml.get()));
|
||||||
|
@ -1390,7 +1390,7 @@ TEST_F(CommonMpdBuilderTest, SetSampleDuration) {
|
||||||
adaptation_set->AddRepresentation(video_media_info);
|
adaptation_set->AddRepresentation(video_media_info);
|
||||||
EXPECT_TRUE(representation->Init());
|
EXPECT_TRUE(representation->Init());
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(adaptation_set->GetXml());
|
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(adaptation_set->GetXml());
|
||||||
EXPECT_NO_FATAL_FAILURE(
|
EXPECT_NO_FATAL_FAILURE(
|
||||||
ExpectAttributeNotSet("frameRate", adaptation_set_xml.get()));
|
ExpectAttributeNotSet("frameRate", adaptation_set_xml.get()));
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ bool GetDurationAttribute(xmlNodePtr node, float* duration) {
|
||||||
DCHECK(node);
|
DCHECK(node);
|
||||||
DCHECK(duration);
|
DCHECK(duration);
|
||||||
static const char kDuration[] = "duration";
|
static const char kDuration[] = "duration";
|
||||||
xml::ScopedXmlPtr<xmlChar>::type duration_value(
|
xml::scoped_xml_ptr<xmlChar> duration_value(
|
||||||
xmlGetProp(node, BAD_CAST kDuration));
|
xmlGetProp(node, BAD_CAST kDuration));
|
||||||
|
|
||||||
if (!duration_value)
|
if (!duration_value)
|
||||||
|
|
|
@ -34,13 +34,8 @@ struct XmlDeleter {
|
||||||
inline void operator()(xmlChar* ptr) const { xmlFree(ptr); }
|
inline void operator()(xmlChar* ptr) const { xmlFree(ptr); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// C++11 allows template alias but standards before it do not. This struct is
|
|
||||||
// for aliasing scoped_ptr with libxml2 object deleter.
|
|
||||||
/// scoped_ptr for libxml2 resources.
|
|
||||||
template <typename XmlType>
|
template <typename XmlType>
|
||||||
struct ScopedXmlPtr {
|
using scoped_xml_ptr = scoped_ptr<XmlType, XmlDeleter>;
|
||||||
typedef scoped_ptr<XmlType, XmlDeleter> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace xml
|
} // namespace xml
|
||||||
} // namespace edash_packager
|
} // namespace edash_packager
|
||||||
|
|
|
@ -61,7 +61,7 @@ XmlNode::XmlNode(const char* name) : node_(xmlNewNode(NULL, BAD_CAST name)) {
|
||||||
|
|
||||||
XmlNode::~XmlNode() {}
|
XmlNode::~XmlNode() {}
|
||||||
|
|
||||||
bool XmlNode::AddChild(ScopedXmlPtr<xmlNode>::type child) {
|
bool XmlNode::AddChild(scoped_xml_ptr<xmlNode> child) {
|
||||||
DCHECK(node_);
|
DCHECK(node_);
|
||||||
DCHECK(child);
|
DCHECK(child);
|
||||||
if (!xmlAddChild(node_.get(), child.get()))
|
if (!xmlAddChild(node_.get(), child.get()))
|
||||||
|
@ -136,7 +136,7 @@ void XmlNode::SetContent(const std::string& content) {
|
||||||
xmlNodeSetContent(node_.get(), BAD_CAST content.c_str());
|
xmlNodeSetContent(node_.get(), BAD_CAST content.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedXmlPtr<xmlNode>::type XmlNode::PassScopedPtr() {
|
scoped_xml_ptr<xmlNode> XmlNode::PassScopedPtr() {
|
||||||
DVLOG(2) << "Passing node_.";
|
DVLOG(2) << "Passing node_.";
|
||||||
DCHECK(node_);
|
DCHECK(node_);
|
||||||
return node_.Pass();
|
return node_.Pass();
|
||||||
|
|
|
@ -39,7 +39,7 @@ class XmlNode {
|
||||||
/// @param child is a xmlNode to add as a child for this element. Ownership
|
/// @param child is a xmlNode to add as a child for this element. Ownership
|
||||||
/// of the child node is transferred.
|
/// of the child node is transferred.
|
||||||
/// @return true on success, false otherwise.
|
/// @return true on success, false otherwise.
|
||||||
bool AddChild(ScopedXmlPtr<xmlNode>::type child);
|
bool AddChild(scoped_xml_ptr<xmlNode> child);
|
||||||
|
|
||||||
/// Adds Elements to this node using the Element struct.
|
/// Adds Elements to this node using the Element struct.
|
||||||
bool AddElements(const std::vector<Element>& elements);
|
bool AddElements(const std::vector<Element>& elements);
|
||||||
|
@ -75,7 +75,7 @@ class XmlNode {
|
||||||
/// Transfer the ownership of the xmlNodePtr. After calling this method, the
|
/// Transfer the ownership of the xmlNodePtr. After calling this method, the
|
||||||
/// behavior of any methods, except the destructor, is undefined.
|
/// behavior of any methods, except the destructor, is undefined.
|
||||||
/// @return The resource of this object.
|
/// @return The resource of this object.
|
||||||
ScopedXmlPtr<xmlNode>::type PassScopedPtr();
|
scoped_xml_ptr<xmlNode> PassScopedPtr();
|
||||||
|
|
||||||
/// Release the xmlNodePtr of this object. After calling this method, the
|
/// Release the xmlNodePtr of this object. After calling this method, the
|
||||||
/// behavior of any methods, except the destructor, is undefined.
|
/// behavior of any methods, except the destructor, is undefined.
|
||||||
|
@ -85,7 +85,7 @@ class XmlNode {
|
||||||
xmlNodePtr GetRawPtr();
|
xmlNodePtr GetRawPtr();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScopedXmlPtr<xmlNode>::type node_;
|
scoped_xml_ptr<xmlNode> node_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(XmlNode);
|
DISALLOW_COPY_AND_ASSIGN(XmlNode);
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,8 +44,8 @@ std::string GetDocAsFlatString(xmlDocPtr doc) {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedXmlPtr<xmlDoc>::type MakeDoc(ScopedXmlPtr<xmlNode>::type node) {
|
scoped_xml_ptr<xmlDoc> MakeDoc(scoped_xml_ptr<xmlNode> node) {
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type doc(xmlNewDoc(BAD_CAST ""));
|
xml::scoped_xml_ptr<xmlDoc> doc(xmlNewDoc(BAD_CAST ""));
|
||||||
xmlDocSetRootElement(doc.get(), node.release());
|
xmlDocSetRootElement(doc.get(), node.release());
|
||||||
return doc.Pass();
|
return doc.Pass();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ class RepresentationTest : public ::testing::Test {
|
||||||
// |node|. Returns |node| in string format.
|
// |node|. Returns |node| in string format.
|
||||||
// You should not call this function multiple times.
|
// You should not call this function multiple times.
|
||||||
std::string GetStringFormat() {
|
std::string GetStringFormat() {
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type doc(xmlNewDoc(BAD_CAST ""));
|
xml::scoped_xml_ptr<xmlDoc> doc(xmlNewDoc(BAD_CAST ""));
|
||||||
|
|
||||||
// Because you cannot easily get the string format of a xmlNodePtr, it gets
|
// Because you cannot easily get the string format of a xmlNodePtr, it gets
|
||||||
// attached to a temporary xml doc.
|
// attached to a temporary xml doc.
|
||||||
|
@ -202,7 +202,7 @@ TEST_F(RepresentationTest, AddContentProtectionElements) {
|
||||||
content_protections.push_back(content_protection_clearkey);
|
content_protections.push_back(content_protection_clearkey);
|
||||||
|
|
||||||
representation_.AddContentProtectionElements(content_protections);
|
representation_.AddContentProtectionElements(content_protections);
|
||||||
ScopedXmlPtr<xmlDoc>::type doc(MakeDoc(representation_.PassScopedPtr()));
|
scoped_xml_ptr<xmlDoc> doc(MakeDoc(representation_.PassScopedPtr()));
|
||||||
ASSERT_TRUE(XmlEqual(
|
ASSERT_TRUE(XmlEqual(
|
||||||
"<Representation>\n"
|
"<Representation>\n"
|
||||||
" <ContentProtection\n"
|
" <ContentProtection\n"
|
||||||
|
|
|
@ -62,7 +62,7 @@ MediaInfo GetTestMediaInfo(const std::string& media_info_file_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ValidateMpdSchema(const std::string& mpd) {
|
bool ValidateMpdSchema(const std::string& mpd) {
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type doc(
|
xml::scoped_xml_ptr<xmlDoc> doc(
|
||||||
xmlParseMemory(mpd.data(), mpd.size()));
|
xmlParseMemory(mpd.data(), mpd.size()));
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
LOG(ERROR) << "Failed to parse mpd into an xml doc.";
|
LOG(ERROR) << "Failed to parse mpd into an xml doc.";
|
||||||
|
@ -75,22 +75,22 @@ bool ValidateMpdSchema(const std::string& mpd) {
|
||||||
// First, I need to load the schema as a xmlDoc so that I can pass the path of
|
// First, I need to load the schema as a xmlDoc so that I can pass the path of
|
||||||
// the DASH-MPD.xsd. Then it can resolve the relative path included from the
|
// the DASH-MPD.xsd. Then it can resolve the relative path included from the
|
||||||
// XSD when creating xmlSchemaParserCtxt.
|
// XSD when creating xmlSchemaParserCtxt.
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type schema_as_doc(
|
xml::scoped_xml_ptr<xmlDoc> schema_as_doc(
|
||||||
xmlReadMemory(schema_str.data(),
|
xmlReadMemory(schema_str.data(),
|
||||||
schema_str.size(),
|
schema_str.size(),
|
||||||
schema_path.value().c_str(),
|
schema_path.value().c_str(),
|
||||||
NULL,
|
NULL,
|
||||||
0));
|
0));
|
||||||
DCHECK(schema_as_doc);
|
DCHECK(schema_as_doc);
|
||||||
xml::ScopedXmlPtr<xmlSchemaParserCtxt>::type
|
xml::scoped_xml_ptr<xmlSchemaParserCtxt>
|
||||||
schema_parser_ctxt(xmlSchemaNewDocParserCtxt(schema_as_doc.get()));
|
schema_parser_ctxt(xmlSchemaNewDocParserCtxt(schema_as_doc.get()));
|
||||||
DCHECK(schema_parser_ctxt);
|
DCHECK(schema_parser_ctxt);
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlSchema>::type schema(
|
xml::scoped_xml_ptr<xmlSchema> schema(
|
||||||
xmlSchemaParse(schema_parser_ctxt.get()));
|
xmlSchemaParse(schema_parser_ctxt.get()));
|
||||||
DCHECK(schema);
|
DCHECK(schema);
|
||||||
|
|
||||||
xml::ScopedXmlPtr<xmlSchemaValidCtxt>::type valid_ctxt(
|
xml::scoped_xml_ptr<xmlSchemaValidCtxt> valid_ctxt(
|
||||||
xmlSchemaNewValidCtxt(schema.get()));
|
xmlSchemaNewValidCtxt(schema.get()));
|
||||||
DCHECK(valid_ctxt);
|
DCHECK(valid_ctxt);
|
||||||
int validation_result =
|
int validation_result =
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
namespace edash_packager {
|
namespace edash_packager {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type GetDocFromString(const std::string& xml_str) {
|
xml::scoped_xml_ptr<xmlDoc> GetDocFromString(const std::string& xml_str) {
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type schema_as_doc(xmlReadMemory(
|
xml::scoped_xml_ptr<xmlDoc> schema_as_doc(xmlReadMemory(
|
||||||
xml_str.data(), xml_str.size(), NULL, NULL, 0));
|
xml_str.data(), xml_str.size(), NULL, NULL, 0));
|
||||||
return schema_as_doc.Pass();
|
return schema_as_doc.Pass();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ std::map<std::string, std::string> GetMapOfAttributes(xmlNodePtr node) {
|
||||||
attribute && attribute->name && attribute->children;
|
attribute && attribute->name && attribute->children;
|
||||||
attribute = attribute->next) {
|
attribute = attribute->next) {
|
||||||
const char* name = reinterpret_cast<const char*>(attribute->name);
|
const char* name = reinterpret_cast<const char*>(attribute->name);
|
||||||
xml::ScopedXmlPtr<xmlChar>::type value(
|
xml::scoped_xml_ptr<xmlChar> value(
|
||||||
xmlNodeListGetString(node->doc, attribute->children, 1));
|
xmlNodeListGetString(node->doc, attribute->children, 1));
|
||||||
|
|
||||||
attribute_map[name] = reinterpret_cast<const char*>(value.get());
|
attribute_map[name] = reinterpret_cast<const char*>(value.get());
|
||||||
|
@ -76,8 +76,8 @@ bool CompareNames(xmlNodePtr node1, xmlNodePtr node2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompareContents(xmlNodePtr node1, xmlNodePtr node2) {
|
bool CompareContents(xmlNodePtr node1, xmlNodePtr node2) {
|
||||||
xml::ScopedXmlPtr<xmlChar>::type node1_content_ptr(xmlNodeGetContent(node1));
|
xml::scoped_xml_ptr<xmlChar> node1_content_ptr(xmlNodeGetContent(node1));
|
||||||
xml::ScopedXmlPtr<xmlChar>::type node2_content_ptr(xmlNodeGetContent(node2));
|
xml::scoped_xml_ptr<xmlChar> node2_content_ptr(xmlNodeGetContent(node2));
|
||||||
std::string node1_content =
|
std::string node1_content =
|
||||||
reinterpret_cast<const char*>(node1_content_ptr.get());
|
reinterpret_cast<const char*>(node1_content_ptr.get());
|
||||||
std::string node2_content =
|
std::string node2_content =
|
||||||
|
@ -144,13 +144,13 @@ bool CompareNodes(xmlNodePtr node1, xmlNodePtr node2) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool XmlEqual(const std::string& xml1, const std::string& xml2) {
|
bool XmlEqual(const std::string& xml1, const std::string& xml2) {
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type xml1_doc(GetDocFromString(xml1));
|
xml::scoped_xml_ptr<xmlDoc> xml1_doc(GetDocFromString(xml1));
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type xml2_doc(GetDocFromString(xml2));
|
xml::scoped_xml_ptr<xmlDoc> xml2_doc(GetDocFromString(xml2));
|
||||||
return XmlEqual(xml1_doc.get(), xml2_doc.get());
|
return XmlEqual(xml1_doc.get(), xml2_doc.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlEqual(const std::string& xml1, xmlDocPtr xml2) {
|
bool XmlEqual(const std::string& xml1, xmlDocPtr xml2) {
|
||||||
xml::ScopedXmlPtr<xmlDoc>::type xml1_doc(GetDocFromString(xml1));
|
xml::scoped_xml_ptr<xmlDoc> xml1_doc(GetDocFromString(xml1));
|
||||||
return XmlEqual(xml1_doc.get(), xml2);
|
return XmlEqual(xml1_doc.get(), xml2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue