summaryrefslogtreecommitdiff
path: root/src/dcp.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-10-10 16:07:44 +0100
committerCarl Hetherington <cth@carlh.net>2014-10-10 16:07:44 +0100
commite30c30ef7bbd8413ac0c8390abe574d5dd1cf5f7 (patch)
treef67b4a9364264d433535dbc24a19b6df6ac59049 /src/dcp.cc
parent863ff8cced5b7d1d36ad6761fa1f6e2dbeafcad6 (diff)
Adapt to new libcxml ARI. Compiles but does not pass tests.1.0-new-cxml
Diffstat (limited to 'src/dcp.cc')
-rw-r--r--src/dcp.cc99
1 files changed, 49 insertions, 50 deletions
diff --git a/src/dcp.cc b/src/dcp.cc
index 58b6c66f..f7698e9c 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -93,15 +93,14 @@ DCP::read (bool keep_going, ReadErrors* errors)
boost::throw_exception (DCPReadError (String::compose ("could not find AssetMap file in `%1'", _directory.string())));
}
- cxml::Document asset_map ("AssetMap");
- asset_map.read_file (asset_map_file);
- list<shared_ptr<cxml::Node> > asset_nodes = asset_map.node_child("AssetList")->node_children ("Asset");
+ cxml::NodePtr asset_map = cxml::read_file (asset_map_file);
+ cxml::NodeList asset_nodes = asset_map->child("AssetList")->children ("Asset");
map<string, boost::filesystem::path> paths;
- for (list<shared_ptr<cxml::Node> >::const_iterator i = asset_nodes.begin(); i != asset_nodes.end(); ++i) {
- if ((*i)->node_child("ChunkList")->node_children("Chunk").size() != 1) {
+ for (cxml::NodeList::const_iterator i = asset_nodes.begin(); i != asset_nodes.end(); ++i) {
+ if ((*i)->child("ChunkList")->children("Chunk").size() != 1) {
boost::throw_exception (XMLError ("unsupported asset chunk count"));
}
- string p = (*i)->node_child("ChunkList")->node_child("Chunk")->string_child ("Path");
+ string p = (*i)->child("ChunkList")->child("Chunk")->string_child ("Path");
if (starts_with (p, "file://")) {
p = p.substr (7);
}
@@ -235,29 +234,29 @@ DCP::write_pkl (Standard standard, string pkl_uuid, XMLMetadata metadata, shared
boost::filesystem::path p = _directory;
p /= String::compose ("%1_pkl.xml", pkl_uuid);
- xmlpp::Document doc;
- xmlpp::Element* pkl;
+ cxml::NodePtr pkl (new cxml::Node);
+ pkl->set_name ("PackingList");
if (standard == INTEROP) {
- pkl = doc.create_root_node("PackingList", "http://www.digicine.com/PROTO-ASDCP-PKL-20040311#");
+ pkl->set_attribute ("xmlns", "http://www.digicine.com/PROTO-ASDCP-PKL-20040311#");
} else {
- pkl = doc.create_root_node("PackingList", "http://www.smpte-ra.org/schemas/429-8/2007/PKL");
+ pkl->set_attribute ("xmlns", "http://www.smpte-ra.org/schemas/429-8/2007/PKL");
}
if (signer) {
- pkl->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "dsig");
+ pkl->set_attribute ("xmlns:dsig", "http://www.w3.org/2000/09/xmldsig#");
}
- pkl->add_child("Id")->add_child_text ("urn:uuid:" + pkl_uuid);
+ pkl->add_child("Id")->set_content ("urn:uuid:" + pkl_uuid);
/* XXX: this is a bit of a hack */
assert (cpls().size() > 0);
- pkl->add_child("AnnotationText")->add_child_text (cpls().front()->annotation_text ());
+ pkl->add_child("AnnotationText")->set_content (cpls().front()->annotation_text ());
- pkl->add_child("IssueDate")->add_child_text (metadata.issue_date);
- pkl->add_child("Issuer")->add_child_text (metadata.issuer);
- pkl->add_child("Creator")->add_child_text (metadata.creator);
+ pkl->add_child("IssueDate")->set_content (metadata.issue_date);
+ pkl->add_child("Issuer")->set_content (metadata.issuer);
+ pkl->add_child("Creator")->set_content (metadata.creator);
- xmlpp::Element* asset_list = pkl->add_child("AssetList");
+ cxml::NodePtr asset_list = pkl->add_child("AssetList");
for (list<shared_ptr<Asset> >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) {
(*i)->write_to_pkl (asset_list, standard);
}
@@ -266,7 +265,7 @@ DCP::write_pkl (Standard standard, string pkl_uuid, XMLMetadata metadata, shared
signer->sign (pkl, standard);
}
- doc.write_to_file (p.string (), "UTF-8");
+ cxml::write_to_file (pkl, p.string ());
return p.string ();
}
@@ -288,22 +287,22 @@ DCP::write_volindex (Standard standard) const
assert (false);
}
- xmlpp::Document doc;
- xmlpp::Element* root;
+ cxml::NodePtr root (new cxml::Node);
+ root->set_name ("VolumeIndex");
switch (standard) {
case INTEROP:
- root = doc.create_root_node ("VolumeIndex", "http://www.digicine.com/PROTO-ASDCP-AM-20040311#");
+ root->set_attribute ("xmlns", "http://www.digicine.com/PROTO-ASDCP-AM-20040311#");
break;
case SMPTE:
- root = doc.create_root_node ("VolumeIndex", "http://www.smpte-ra.org/schemas/429-9/2007/AM");
+ root->set_attribute ("xmlns", "http://www.smpte-ra.org/schemas/429-9/2007/AM");
break;
default:
assert (false);
}
- root->add_child("Index")->add_child_text ("1");
- doc.write_to_file (p.string (), "UTF-8");
+ root->add_child("Index")->set_content ("1");
+ cxml::write_to_file (root, p.string ());
}
void
@@ -322,58 +321,58 @@ DCP::write_assetmap (Standard standard, string pkl_uuid, int pkl_length, XMLMeta
assert (false);
}
- xmlpp::Document doc;
- xmlpp::Element* root;
+ cxml::NodePtr root (new cxml::Node);
+ root->set_name ("AssetMap");
switch (standard) {
case INTEROP:
- root = doc.create_root_node ("AssetMap", "http://www.digicine.com/PROTO-ASDCP-AM-20040311#");
+ root->set_attribute ("xmlns", "http://www.digicine.com/PROTO-ASDCP-AM-20040311#");
break;
case SMPTE:
- root = doc.create_root_node ("AssetMap", "http://www.smpte-ra.org/schemas/429-9/2007/AM");
+ root->set_attribute ("xmlns", "http://www.smpte-ra.org/schemas/429-9/2007/AM");
break;
default:
assert (false);
}
- root->add_child("Id")->add_child_text ("urn:uuid:" + make_uuid());
- root->add_child("AnnotationText")->add_child_text ("Created by " + metadata.creator);
+ root->add_child("Id")->set_content ("urn:uuid:" + make_uuid());
+ root->add_child("AnnotationText")->set_content ("Created by " + metadata.creator);
switch (standard) {
case INTEROP:
- root->add_child("VolumeCount")->add_child_text ("1");
- root->add_child("IssueDate")->add_child_text (metadata.issue_date);
- root->add_child("Issuer")->add_child_text (metadata.issuer);
- root->add_child("Creator")->add_child_text (metadata.creator);
+ root->add_child("VolumeCount")->set_content ("1");
+ root->add_child("IssueDate")->set_content (metadata.issue_date);
+ root->add_child("Issuer")->set_content (metadata.issuer);
+ root->add_child("Creator")->set_content (metadata.creator);
break;
case SMPTE:
- root->add_child("Creator")->add_child_text (metadata.creator);
- root->add_child("VolumeCount")->add_child_text ("1");
- root->add_child("IssueDate")->add_child_text (metadata.issue_date);
- root->add_child("Issuer")->add_child_text (metadata.issuer);
+ root->add_child("Creator")->set_content (metadata.creator);
+ root->add_child("VolumeCount")->set_content ("1");
+ root->add_child("IssueDate")->set_content (metadata.issue_date);
+ root->add_child("Issuer")->set_content (metadata.issuer);
break;
default:
assert (false);
}
- xmlpp::Node* asset_list = root->add_child ("AssetList");
-
- xmlpp::Node* asset = asset_list->add_child ("Asset");
- asset->add_child("Id")->add_child_text ("urn:uuid:" + pkl_uuid);
- asset->add_child("PackingList")->add_child_text ("true");
- xmlpp::Node* chunk_list = asset->add_child ("ChunkList");
- xmlpp::Node* chunk = chunk_list->add_child ("Chunk");
- chunk->add_child("Path")->add_child_text (pkl_uuid + "_pkl.xml");
- chunk->add_child("VolumeIndex")->add_child_text ("1");
- chunk->add_child("Offset")->add_child_text ("0");
- chunk->add_child("Length")->add_child_text (raw_convert<string> (pkl_length));
+ cxml::NodePtr asset_list = root->add_child ("AssetList");
+
+ cxml::NodePtr asset = asset_list->add_child ("Asset");
+ asset->add_child("Id")->set_content ("urn:uuid:" + pkl_uuid);
+ asset->add_child("PackingList")->set_content ("true");
+ cxml::NodePtr chunk_list = asset->add_child ("ChunkList");
+ cxml::NodePtr chunk = chunk_list->add_child ("Chunk");
+ chunk->add_child("Path")->set_content (pkl_uuid + "_pkl.xml");
+ chunk->add_child("VolumeIndex")->set_content ("1");
+ chunk->add_child("Offset")->set_content ("0");
+ chunk->add_child("Length")->set_content (raw_convert<string> (pkl_length));
for (list<shared_ptr<Asset> >::const_iterator i = _assets.begin(); i != _assets.end(); ++i) {
(*i)->write_to_assetmap (asset_list, _directory);
}
/* This must not be the _formatted version otherwise signature digests will be wrong */
- doc.write_to_file (p.string (), "UTF-8");
+ cxml::write_to_file (root, p.string ());
}
/** Write all the XML files for this DCP.