Use alias template for ScopedXmlPtr

- Also renamed to scoped_xml_ptr to match other smart pointers.

Change-Id: Idb998aa3252d4f3a50068a09e26a05f124e94a2f
This commit is contained in:
Rintaro Kuroiwa 2015-11-16 16:06:17 -08:00 committed by Gerrit Code Review
parent 8072fd1eaf
commit d3c52cffd9
10 changed files with 71 additions and 76 deletions

View File

@ -427,7 +427,7 @@ template <typename OutputType>
bool MpdBuilder::WriteMpdToOutput(OutputType* output) {
static LibXmlInitializer lib_xml_initializer;
xml::ScopedXmlPtr<xmlDoc>::type doc(GenerateMpd());
xml::scoped_xml_ptr<xmlDoc> doc(GenerateMpd());
if (!doc.get())
return false;
@ -448,7 +448,7 @@ bool MpdBuilder::WriteMpdToOutput(OutputType* output) {
xmlDocPtr MpdBuilder::GenerateMpd() {
// Setup nodes.
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");
// 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 =
adaptation_sets_.begin();
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()))
return NULL;
}
@ -725,12 +725,12 @@ void AdaptationSet::AddRole(Role role) {
// Creates a copy of <AdaptationSet> xml element, iterate thru all the
// <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;
if (!adaptation_set.AddContentProtectionElements(
content_protection_elements_)) {
return xml::ScopedXmlPtr<xmlNode>::type();
return xml::scoped_xml_ptr<xmlNode>();
}
for (std::set<Role>::const_iterator role_it = roles_.begin();
role_it != roles_.end(); ++role_it) {
@ -742,9 +742,9 @@ xml::ScopedXmlPtr<xmlNode>::type AdaptationSet::GetXml() {
representations_.begin();
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()))
return xml::ScopedXmlPtr<xmlNode>::type();
return xml::scoped_xml_ptr<xmlNode>();
}
adaptation_set.SetId(id_);
@ -1101,10 +1101,10 @@ void Representation::SetSampleDuration(uint32_t sample_duration) {
// AddVideoInfo() (possibly adds FramePacking elements), AddAudioInfo() (Adds
// AudioChannelConfig elements), AddContentProtectionElements*(), and
// AddVODOnlyInfo() (Adds segment info).
xml::ScopedXmlPtr<xmlNode>::type Representation::GetXml() {
xml::scoped_xml_ptr<xmlNode> Representation::GetXml() {
if (!HasRequiredMediaInfoFields()) {
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()
@ -1127,31 +1127,31 @@ xml::ScopedXmlPtr<xmlNode>::type Representation::GetXml() {
if (has_video_info &&
!representation.AddVideoInfo(media_info_.video_info())) {
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 &&
!representation.AddAudioInfo(media_info_.audio_info())) {
LOG(ERROR) << "Failed to add audio info to Representation XML.";
return xml::ScopedXmlPtr<xmlNode>::type();
return xml::scoped_xml_ptr<xmlNode>();
}
if (!representation.AddContentProtectionElements(
content_protection_elements_)) {
return xml::ScopedXmlPtr<xmlNode>::type();
return xml::scoped_xml_ptr<xmlNode>();
}
if (HasVODOnlyFields(media_info_) &&
!representation.AddVODOnlyInfo(media_info_)) {
LOG(ERROR) << "Failed to add VOD segment info.";
return xml::ScopedXmlPtr<xmlNode>::type();
return xml::scoped_xml_ptr<xmlNode>();
}
if (HasLiveOnlyFields(media_info_) &&
!representation.AddLiveOnlyInfo(media_info_, segment_infos_,
start_number_)) {
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
// SegmentTemplate. Optimize and propagate the tag up to AdaptationSet level.

View File

@ -210,9 +210,9 @@ class AdaptationSet {
/// Makes a copy of AdaptationSet xml element with its child Representation
/// and ContentProtection elements.
/// @return On success returns a non-NULL ScopedXmlPtr. Otherwise returns a
/// NULL ScopedXmlPtr.
xml::ScopedXmlPtr<xmlNode>::type GetXml();
/// @return On success returns a non-NULL scoped_xml_ptr. Otherwise returns a
/// NULL scoped_xml_ptr.
xml::scoped_xml_ptr<xmlNode> GetXml();
/// 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
@ -468,7 +468,7 @@ class Representation {
virtual void SetSampleDuration(uint32_t sample_duration);
/// @return Copy of <Representation>.
xml::ScopedXmlPtr<xmlNode>::type GetXml();
xml::scoped_xml_ptr<xmlNode> GetXml();
/// @return ID number for <Representation>.
uint32_t id() const { return id_; }

View File

@ -41,7 +41,7 @@ const int kDefaultStartNumber = 1;
// number.
void ExpectXmlElementIdEqual(xmlNodePtr node, uint32_t 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));
ASSERT_TRUE(id_attribute_xml_str);
@ -59,14 +59,14 @@ void CheckIdEqual(uint32_t expected_id, T* node) {
ASSERT_EQ(expected_id, node->id());
// 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));
}
void ExpectAttributeEqString(base::StringPiece attribute,
base::StringPiece expected_value,
xmlNodePtr node) {
xml::ScopedXmlPtr<xmlChar>::type attribute_xml_str(
xml::scoped_xml_ptr<xmlChar> attribute_xml_str(
xmlGetProp(node, BAD_CAST attribute.data()));
ASSERT_TRUE(attribute_xml_str);
EXPECT_STREQ(expected_value.data(),
@ -75,7 +75,7 @@ void ExpectAttributeEqString(base::StringPiece attribute,
// |attribute| should not be set in |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()));
ASSERT_FALSE(attribute_xml_str);
}
@ -382,13 +382,13 @@ TEST_F(CommonMpdBuilderTest, SetAdaptationSetGroup) {
MpdBuilder::kStatic, &sequence_counter);
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(
ExpectAttributeEqString("group", "1", xml_with_group.get()));
// Unset by passing a negative value.
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(
ExpectAttributeNotSet("group", xml_without_group.get()));
}
@ -486,7 +486,7 @@ TEST_F(CommonMpdBuilderTest, CheckVideoInfoReflectedInXml) {
CreateRepresentation(ConvertToMediaInfo(kTestMediaInfo), MpdOptions(),
kAnyRepresentationId, NoListener());
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(
ExpectAttributeEqString("codecs", "avc1", node_xml.get()));
EXPECT_NO_FATAL_FAILURE(
@ -687,7 +687,7 @@ TEST_F(CommonMpdBuilderTest, CheckLanguageAttributeSet) {
MpdBuilder::kStatic, &sequence_counter);
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(
ExpectAttributeEqString("lang", "en", node_xml.get()));
}
@ -707,7 +707,7 @@ TEST_F(CommonMpdBuilderTest, AdaptationAddRoleElementMain) {
AdaptationSet* adaptation_set = mpd_builder.AddAdaptationSet("");
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
// MPD without adding any Representations.
const char kExpectedOutput[] =
@ -752,7 +752,7 @@ TEST_F(CommonMpdBuilderTest, CheckContentProtectionRoleRepresentationOrder) {
"container_type: 1\n";
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[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<MPD xmlns=\"urn:mpeg:DASH:schema:MPD:2011\"\n"
@ -812,7 +812,7 @@ TEST_F(CommonMpdBuilderTest, AdapatationSetFrameRate) {
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
ConvertToMediaInfo(kVideoMediaInfo2)));
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
video_adaptation_set->GetXml());
EXPECT_NO_FATAL_FAILURE(
ExpectAttributeEqString("frameRate", "10/3", adaptation_set_xml.get()));
@ -849,7 +849,7 @@ TEST_F(CommonMpdBuilderTest, AdapatationSetMaxFrameRate) {
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
ConvertToMediaInfo(kVideoMediaInfo15fps)));
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
video_adaptation_set->GetXml());
EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString("maxFrameRate", "3000/100",
adaptation_set_xml.get()));
@ -898,7 +898,7 @@ TEST_F(CommonMpdBuilderTest,
// First, make sure that maxFrameRate nor frameRate are set because
// 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(
ExpectAttributeNotSet("maxFrameRate", no_frame_rate.get()));
EXPECT_NO_FATAL_FAILURE(
@ -910,7 +910,7 @@ TEST_F(CommonMpdBuilderTest,
representation_480p->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(
ExpectAttributeNotSet("maxFrameRate", same_frame_rate.get()));
EXPECT_NO_FATAL_FAILURE(
@ -922,7 +922,7 @@ TEST_F(CommonMpdBuilderTest,
frame_duration_must_be_shorter_for_max_frame_rate);
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(
ExpectAttributeEqString("maxFrameRate", "10/2", max_frame_rate.get()));
EXPECT_NO_FATAL_FAILURE(
@ -991,7 +991,7 @@ TEST_F(CommonMpdBuilderTest, AdaptationSetParAllSame) {
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
ConvertToMediaInfo(k360pVideoInfo)));
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
video_adaptation_set->GetXml());
EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString("par", "16:9",
adaptation_set_xml.get()));
@ -1031,7 +1031,7 @@ TEST_F(CommonMpdBuilderTest, AdaptationSetParDifferent) {
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
ConvertToMediaInfo(k2by1VideoInfo)));
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
video_adaptation_set->GetXml());
EXPECT_NO_FATAL_FAILURE(
ExpectAttributeNotSet("par", adaptation_set_xml.get()));
@ -1055,7 +1055,7 @@ TEST_F(CommonMpdBuilderTest, AdaptationSetParUnknown) {
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
ConvertToMediaInfo(kUknownPixelWidthAndHeight)));
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
video_adaptation_set->GetXml());
EXPECT_NO_FATAL_FAILURE(
ExpectAttributeNotSet("par", adaptation_set_xml.get()));
@ -1093,7 +1093,7 @@ TEST_F(CommonMpdBuilderTest,
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
ConvertToMediaInfo(kVideoMediaInfo2)));
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
video_adaptation_set->GetXml());
EXPECT_NO_FATAL_FAILURE(ExpectAttributeEqString("maxFrameRate", "11/3",
adaptation_set_xml.get()));
@ -1149,13 +1149,13 @@ TEST_F(StaticMpdBuilderTest, SubSegmentAlignment) {
adaptation_set->AddRepresentation(ConvertToMediaInfo(k360pMediaInfo));
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(
ExpectAttributeEqString("subSegmentAlignment", "true", aligned.get()));
// Unknown because 480p has an extra subsegments.
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(
ExpectAttributeNotSet("subSegmentAlignment", alignment_unknown.get()));
@ -1163,7 +1163,7 @@ TEST_F(StaticMpdBuilderTest, SubSegmentAlignment) {
representation_360p->AddNewSegment(10, 1, 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(
ExpectAttributeNotSet("subSegmentAlignment", unaligned.get()));
}
@ -1209,13 +1209,13 @@ TEST_F(StaticMpdBuilderTest, ForceSetSubSegmentAlignment) {
const uint64_t kAnySize = 19834u;
representation_480p->AddNewSegment(kStartTime1, 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(
ExpectAttributeNotSet("subSegmentAlignment", unaligned.get()));
// Then force set the segment alignment attribute to 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(
ExpectAttributeEqString("subSegmentAlignment", "true", aligned.get()));
}
@ -1261,7 +1261,7 @@ TEST_F(DynamicMpdBuilderTest, SegmentAlignment) {
const uint64_t kAnySize = 19834u;
representation_480p->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(
ExpectAttributeEqString("segmentAlignment", "true", aligned.get()));
@ -1270,7 +1270,7 @@ TEST_F(DynamicMpdBuilderTest, SegmentAlignment) {
representation_360p->AddNewSegment(10, 1, 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(
ExpectAttributeNotSet("subSegmentAlignment", unaligned.get()));
}
@ -1304,7 +1304,7 @@ TEST_F(StaticMpdBuilderTest, AdapatationSetWidthAndHeight) {
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
ConvertToMediaInfo(kVideoMediaInfo2)));
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
video_adaptation_set->GetXml());
ASSERT_NO_FATAL_FAILURE(
ExpectAttributeEqString("width", "1280", adaptation_set_xml.get()));
@ -1344,7 +1344,7 @@ TEST_F(StaticMpdBuilderTest, AdapatationSetMaxWidthAndMaxHeight) {
ASSERT_TRUE(video_adaptation_set->AddRepresentation(
ConvertToMediaInfo(kVideoMediaInfo720p)));
xml::ScopedXmlPtr<xmlNode>::type adaptation_set_xml(
xml::scoped_xml_ptr<xmlNode> adaptation_set_xml(
video_adaptation_set->GetXml());
EXPECT_NO_FATAL_FAILURE(
ExpectAttributeEqString("maxWidth", "1920", adaptation_set_xml.get()));
@ -1390,7 +1390,7 @@ TEST_F(CommonMpdBuilderTest, SetSampleDuration) {
adaptation_set->AddRepresentation(video_media_info);
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(
ExpectAttributeNotSet("frameRate", adaptation_set_xml.get()));

View File

@ -82,7 +82,7 @@ bool GetDurationAttribute(xmlNodePtr node, float* duration) {
DCHECK(node);
DCHECK(duration);
static const char kDuration[] = "duration";
xml::ScopedXmlPtr<xmlChar>::type duration_value(
xml::scoped_xml_ptr<xmlChar> duration_value(
xmlGetProp(node, BAD_CAST kDuration));
if (!duration_value)

View File

@ -34,13 +34,8 @@ struct XmlDeleter {
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>
struct ScopedXmlPtr {
typedef scoped_ptr<XmlType, XmlDeleter> type;
};
using scoped_xml_ptr = scoped_ptr<XmlType, XmlDeleter>;
} // namespace xml
} // namespace edash_packager

View File

@ -61,7 +61,7 @@ XmlNode::XmlNode(const char* name) : node_(xmlNewNode(NULL, BAD_CAST name)) {
XmlNode::~XmlNode() {}
bool XmlNode::AddChild(ScopedXmlPtr<xmlNode>::type child) {
bool XmlNode::AddChild(scoped_xml_ptr<xmlNode> child) {
DCHECK(node_);
DCHECK(child);
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());
}
ScopedXmlPtr<xmlNode>::type XmlNode::PassScopedPtr() {
scoped_xml_ptr<xmlNode> XmlNode::PassScopedPtr() {
DVLOG(2) << "Passing node_.";
DCHECK(node_);
return node_.Pass();

View File

@ -39,7 +39,7 @@ class XmlNode {
/// @param child is a xmlNode to add as a child for this element. Ownership
/// of the child node is transferred.
/// @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.
bool AddElements(const std::vector<Element>& elements);
@ -75,7 +75,7 @@ class XmlNode {
/// Transfer the ownership of the xmlNodePtr. After calling this method, the
/// behavior of any methods, except the destructor, is undefined.
/// @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
/// behavior of any methods, except the destructor, is undefined.
@ -85,7 +85,7 @@ class XmlNode {
xmlNodePtr GetRawPtr();
private:
ScopedXmlPtr<xmlNode>::type node_;
scoped_xml_ptr<xmlNode> node_;
DISALLOW_COPY_AND_ASSIGN(XmlNode);
};

View File

@ -44,8 +44,8 @@ std::string GetDocAsFlatString(xmlDocPtr doc) {
return output;
}
ScopedXmlPtr<xmlDoc>::type MakeDoc(ScopedXmlPtr<xmlNode>::type node) {
xml::ScopedXmlPtr<xmlDoc>::type doc(xmlNewDoc(BAD_CAST ""));
scoped_xml_ptr<xmlDoc> MakeDoc(scoped_xml_ptr<xmlNode> node) {
xml::scoped_xml_ptr<xmlDoc> doc(xmlNewDoc(BAD_CAST ""));
xmlDocSetRootElement(doc.get(), node.release());
return doc.Pass();
}
@ -61,7 +61,7 @@ class RepresentationTest : public ::testing::Test {
// |node|. Returns |node| in string format.
// You should not call this function multiple times.
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
// attached to a temporary xml doc.
@ -202,7 +202,7 @@ TEST_F(RepresentationTest, AddContentProtectionElements) {
content_protections.push_back(content_protection_clearkey);
representation_.AddContentProtectionElements(content_protections);
ScopedXmlPtr<xmlDoc>::type doc(MakeDoc(representation_.PassScopedPtr()));
scoped_xml_ptr<xmlDoc> doc(MakeDoc(representation_.PassScopedPtr()));
ASSERT_TRUE(XmlEqual(
"<Representation>\n"
" <ContentProtection\n"

View File

@ -62,7 +62,7 @@ MediaInfo GetTestMediaInfo(const std::string& media_info_file_name) {
}
bool ValidateMpdSchema(const std::string& mpd) {
xml::ScopedXmlPtr<xmlDoc>::type doc(
xml::scoped_xml_ptr<xmlDoc> doc(
xmlParseMemory(mpd.data(), mpd.size()));
if (!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
// the DASH-MPD.xsd. Then it can resolve the relative path included from the
// XSD when creating xmlSchemaParserCtxt.
xml::ScopedXmlPtr<xmlDoc>::type schema_as_doc(
xml::scoped_xml_ptr<xmlDoc> schema_as_doc(
xmlReadMemory(schema_str.data(),
schema_str.size(),
schema_path.value().c_str(),
NULL,
0));
DCHECK(schema_as_doc);
xml::ScopedXmlPtr<xmlSchemaParserCtxt>::type
xml::scoped_xml_ptr<xmlSchemaParserCtxt>
schema_parser_ctxt(xmlSchemaNewDocParserCtxt(schema_as_doc.get()));
DCHECK(schema_parser_ctxt);
xml::ScopedXmlPtr<xmlSchema>::type schema(
xml::scoped_xml_ptr<xmlSchema> schema(
xmlSchemaParse(schema_parser_ctxt.get()));
DCHECK(schema);
xml::ScopedXmlPtr<xmlSchemaValidCtxt>::type valid_ctxt(
xml::scoped_xml_ptr<xmlSchemaValidCtxt> valid_ctxt(
xmlSchemaNewValidCtxt(schema.get()));
DCHECK(valid_ctxt);
int validation_result =

View File

@ -15,8 +15,8 @@
namespace edash_packager {
namespace {
xml::ScopedXmlPtr<xmlDoc>::type GetDocFromString(const std::string& xml_str) {
xml::ScopedXmlPtr<xmlDoc>::type schema_as_doc(xmlReadMemory(
xml::scoped_xml_ptr<xmlDoc> GetDocFromString(const std::string& xml_str) {
xml::scoped_xml_ptr<xmlDoc> schema_as_doc(xmlReadMemory(
xml_str.data(), xml_str.size(), NULL, NULL, 0));
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->next) {
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));
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) {
xml::ScopedXmlPtr<xmlChar>::type node1_content_ptr(xmlNodeGetContent(node1));
xml::ScopedXmlPtr<xmlChar>::type node2_content_ptr(xmlNodeGetContent(node2));
xml::scoped_xml_ptr<xmlChar> node1_content_ptr(xmlNodeGetContent(node1));
xml::scoped_xml_ptr<xmlChar> node2_content_ptr(xmlNodeGetContent(node2));
std::string node1_content =
reinterpret_cast<const char*>(node1_content_ptr.get());
std::string node2_content =
@ -144,13 +144,13 @@ bool CompareNodes(xmlNodePtr node1, xmlNodePtr node2) {
} // namespace
bool XmlEqual(const std::string& xml1, const std::string& xml2) {
xml::ScopedXmlPtr<xmlDoc>::type xml1_doc(GetDocFromString(xml1));
xml::ScopedXmlPtr<xmlDoc>::type xml2_doc(GetDocFromString(xml2));
xml::scoped_xml_ptr<xmlDoc> xml1_doc(GetDocFromString(xml1));
xml::scoped_xml_ptr<xmlDoc> xml2_doc(GetDocFromString(xml2));
return XmlEqual(xml1_doc.get(), xml2_doc.get());
}
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);
}