summaryrefslogtreecommitdiff
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
parent863ff8cced5b7d1d36ad6761fa1f6e2dbeafcad6 (diff)
Adapt to new libcxml ARI. Compiles but does not pass tests.1.0-new-cxml
-rwxr-xr-xrun/tests2
-rw-r--r--src/asset.cc32
-rw-r--r--src/asset.h9
-rw-r--r--src/cpl.cc63
-rw-r--r--src/dcp.cc99
-rw-r--r--src/dcp.h5
-rw-r--r--src/encrypted_kdm.cc216
-rw-r--r--src/font.cc2
-rw-r--r--src/font.h2
-rw-r--r--src/load_font.cc2
-rw-r--r--src/load_font.h3
-rw-r--r--src/reel.cc20
-rw-r--r--src/reel.h10
-rw-r--r--src/reel_asset.cc20
-rw-r--r--src/reel_asset.h13
-rw-r--r--src/reel_mono_picture_asset.cc2
-rw-r--r--src/reel_mono_picture_asset.h2
-rw-r--r--src/reel_mxf_asset.cc12
-rw-r--r--src/reel_mxf_asset.h4
-rw-r--r--src/reel_picture_asset.cc16
-rw-r--r--src/reel_picture_asset.h4
-rw-r--r--src/reel_sound_asset.cc2
-rw-r--r--src/reel_sound_asset.h2
-rw-r--r--src/reel_stereo_picture_asset.cc2
-rw-r--r--src/reel_stereo_picture_asset.h2
-rw-r--r--src/reel_subtitle_asset.cc2
-rw-r--r--src/reel_subtitle_asset.h2
-rw-r--r--src/signer.cc46
-rw-r--r--src/signer.h10
-rw-r--r--src/subtitle.cc4
-rw-r--r--src/subtitle.h9
-rw-r--r--src/subtitle_content.cc40
-rw-r--r--src/subtitle_content.h4
-rw-r--r--src/text.cc2
-rw-r--r--src/text.h7
-rw-r--r--src/util.h11
-rw-r--r--src/xml.h18
-rw-r--r--test/cpl_sar_test.cc14
38 files changed, 335 insertions, 380 deletions
diff --git a/run/tests b/run/tests
index 5c99f479..1f858a07 100755
--- a/run/tests
+++ b/run/tests
@@ -10,7 +10,7 @@ private=../libdcp-test-private
work=build/test
dcpinfo=build/tools/dcpinfo
-export LD_LIBRARY_PATH=build/src:build/asdcplib/src
+export LD_LIBRARY_PATH=build/src:build/asdcplib/src:$LD_LIBRARY_PATH
# Run the unit tests in test/
if [ "$1" == "--debug" ]; then
diff --git a/src/asset.cc b/src/asset.cc
index 96196b41..8f4836e9 100644
--- a/src/asset.cc
+++ b/src/asset.cc
@@ -58,35 +58,35 @@ Asset::Asset (string id)
}
void
-Asset::write_to_pkl (xmlpp::Node* node, Standard standard) const
+Asset::write_to_pkl (cxml::NodePtr node, Standard standard) const
{
assert (!_file.empty ());
- xmlpp::Node* asset = node->add_child ("Asset");
- asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
- asset->add_child("AnnotationText")->add_child_text (_id);
- asset->add_child("Hash")->add_child_text (hash ());
- asset->add_child("Size")->add_child_text (raw_convert<string> (boost::filesystem::file_size (_file)));
- asset->add_child("Type")->add_child_text (pkl_type (standard));
+ cxml::NodePtr asset = node->add_child ("Asset");
+ asset->add_child("Id")->set_content ("urn:uuid:" + _id);
+ asset->add_child("AnnotationText")->set_content (_id);
+ asset->add_child("Hash")->set_content (hash ());
+ asset->add_child("Size")->set_content (raw_convert<string> (boost::filesystem::file_size (_file)));
+ asset->add_child("Type")->set_content (pkl_type (standard));
}
void
-Asset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const
+Asset::write_to_assetmap (cxml::NodePtr node, boost::filesystem::path root) const
{
assert (!_file.empty ());
- xmlpp::Node* asset = node->add_child ("Asset");
- asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
- xmlpp::Node* chunk_list = asset->add_child ("ChunkList");
- xmlpp::Node* chunk = chunk_list->add_child ("Chunk");
+ cxml::NodePtr asset = node->add_child ("Asset");
+ asset->add_child("Id")->set_content ("urn:uuid:" + _id);
+ cxml::NodePtr chunk_list = asset->add_child ("ChunkList");
+ cxml::NodePtr chunk = chunk_list->add_child ("Chunk");
optional<boost::filesystem::path> path = relative_to_root (root, _file);
if (!path) {
throw MiscError (String::compose ("Asset %1 is not within the directory %2", _file, root));
}
- chunk->add_child("Path")->add_child_text (path.get().string ());
- 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> (boost::filesystem::file_size (_file)));
+ chunk->add_child("Path")->set_content (path.get().string ());
+ chunk->add_child("VolumeIndex")->set_content ("1");
+ chunk->add_child("Offset")->set_content ("0");
+ chunk->add_child("Length")->set_content (raw_convert<string> (boost::filesystem::file_size (_file)));
}
string
diff --git a/src/asset.h b/src/asset.h
index 86d5daf5..19aa2996 100644
--- a/src/asset.h
+++ b/src/asset.h
@@ -26,14 +26,11 @@
#include "object.h"
#include "types.h"
+#include <libcxml/cxml.h>
#include <boost/filesystem.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
-namespace xmlpp {
- class Node;
-}
-
namespace dcp {
/** @class Asset
@@ -58,13 +55,13 @@ public:
/** Write details of the asset to a ASSETMAP.
* @param node Parent node.
*/
- void write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const;
+ void write_to_assetmap (cxml::NodePtr node, boost::filesystem::path root) const;
/** Write details of the asset to a PKL AssetList node.
* @param node Parent node.
* @param standard Standard to use.
*/
- void write_to_pkl (xmlpp::Node* node, Standard standard) const;
+ void write_to_pkl (cxml::NodePtr node, Standard standard) const;
boost::filesystem::path file () const {
return _file;
diff --git a/src/cpl.cc b/src/cpl.cc
index d7f3a79a..bb2ada64 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -61,33 +61,32 @@ CPL::CPL (boost::filesystem::path file)
: Asset (file)
, _content_kind (FEATURE)
{
- cxml::Document f ("CompositionPlaylist");
- f.read_file (file);
+ cxml::NodePtr f = cxml::read_file (file);
- _id = f.string_child ("Id");
+ _id = f->string_child ("Id");
if (_id.length() > 9) {
_id = _id.substr (9);
}
- _annotation_text = f.optional_string_child ("AnnotationText").get_value_or ("");
- _metadata.issuer = f.optional_string_child ("Issuer").get_value_or ("");
- _metadata.creator = f.optional_string_child ("Creator").get_value_or ("");
- _metadata.issue_date = f.string_child ("IssueDate");
- _content_title_text = f.string_child ("ContentTitleText");
- _content_kind = content_kind_from_string (f.string_child ("ContentKind"));
- shared_ptr<cxml::Node> content_version = f.optional_node_child ("ContentVersion");
+ _annotation_text = f->optional_string_child ("AnnotationText").get_value_or ("");
+ _metadata.issuer = f->optional_string_child ("Issuer").get_value_or ("");
+ _metadata.creator = f->optional_string_child ("Creator").get_value_or ("");
+ _metadata.issue_date = f->string_child ("IssueDate");
+ _content_title_text = f->string_child ("ContentTitleText");
+ _content_kind = content_kind_from_string (f->string_child ("ContentKind"));
+ cxml::NodePtr content_version = f->optional_child ("ContentVersion");
if (content_version) {
_content_version_id = content_version->optional_string_child ("Id").get_value_or ("");
_content_version_label_text = content_version->string_child ("LabelText");
content_version->done ();
}
- f.ignore_child ("RatingList");
+ f->ignore_child ("RatingList");
_reels = type_grand_children<Reel> (f, "ReelList", "Reel");
- f.ignore_child ("Issuer");
- f.ignore_child ("Signer");
- f.ignore_child ("Signature");
+ f->ignore_child ("Issuer");
+ f->ignore_child ("Signer");
+ f->ignore_child ("Signature");
- f.done ();
+ f->done ();
}
/** Add a reel to this CPL.
@@ -107,33 +106,33 @@ CPL::add (boost::shared_ptr<Reel> reel)
void
CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<const Signer> signer) const
{
- xmlpp::Document doc;
- xmlpp::Element* root;
+ cxml::NodePtr root (new cxml::Node);
+ root->set_name ("CompositonPlaylist");
if (standard == INTEROP) {
- root = doc.create_root_node ("CompositionPlaylist", "http://www.digicine.com/PROTO-ASDCP-CPL-20040511#");
+ root->set_attribute ("xmlns", "http://www.digicine.com/PROTO-ASDCP-CPL-20040511#");
} else {
- root = doc.create_root_node ("CompositionPlaylist", "http://www.smpte-ra.org/schemas/429-7/2006/CPL");
+ root->set_attribute ("xmlns", "http://www.smpte-ra.org/schemas/429-7/2006/CPL");
}
if (signer) {
- root->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "dsig");
+ root->set_attribute ("xmlns:dsig", "http://www.w3.org/2000/09/xmldsig#");
}
- root->add_child("Id")->add_child_text ("urn:uuid:" + _id);
- root->add_child("AnnotationText")->add_child_text (_annotation_text);
- 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("ContentTitleText")->add_child_text (_content_title_text);
- root->add_child("ContentKind")->add_child_text (content_kind_to_string (_content_kind));
+ root->add_child("Id")->set_content ("urn:uuid:" + _id);
+ root->add_child("AnnotationText")->set_content (_annotation_text);
+ 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);
+ root->add_child("ContentTitleText")->set_content (_content_title_text);
+ root->add_child("ContentKind")->set_content (content_kind_to_string (_content_kind));
{
- xmlpp::Node* cv = root->add_child ("ContentVersion");
- cv->add_child ("Id")->add_child_text (_content_version_id);
- cv->add_child ("LabelText")->add_child_text (_content_version_label_text);
+ cxml::NodePtr cv = root->add_child ("ContentVersion");
+ cv->add_child ("Id")->set_content (_content_version_id);
+ cv->add_child ("LabelText")->set_content (_content_version_label_text);
}
root->add_child("RatingList");
- xmlpp::Element* reel_list = root->add_child ("ReelList");
+ cxml::NodePtr reel_list = root->add_child ("ReelList");
for (list<shared_ptr<Reel> >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) {
(*i)->write_to_cpl (reel_list, standard);
@@ -144,7 +143,7 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons
}
/* This must not be the _formatted version otherwise signature digests will be wrong */
- doc.write_to_file (file.string (), "UTF-8");
+ cxml::write_to_file (root, file.string ());
set_file (file);
}
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.
diff --git a/src/dcp.h b/src/dcp.h
index 3d42b92a..477e32e8 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -32,11 +32,6 @@
#include <string>
#include <vector>
-namespace xmlpp {
- class Document;
- class Element;
-}
-
/** @brief Namespace for everything in libdcp */
namespace dcp
{
diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc
index 7cae0533..960af070 100644
--- a/src/encrypted_kdm.cc
+++ b/src/encrypted_kdm.cc
@@ -43,17 +43,17 @@ class Signer
public:
Signer () {}
- Signer (shared_ptr<const cxml::Node> node)
+ Signer (cxml::ConstNodePtr node)
: x509_issuer_name (node->string_child ("X509IssuerName"))
, x509_serial_number (node->string_child ("X509SerialNumber"))
{
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
- node->add_child("X509IssuerName", "ds")->add_child_text (x509_issuer_name);
- node->add_child("X509SerialNumber", "ds")->add_child_text (x509_serial_number);
+ node->add_child("X509IssuerName", "ds")->set_content (x509_issuer_name);
+ node->add_child("X509SerialNumber", "ds")->set_content (x509_serial_number);
}
string x509_issuer_name;
@@ -65,17 +65,17 @@ class X509Data
public:
X509Data () {}
- X509Data (boost::shared_ptr<const cxml::Node> node)
- : x509_issuer_serial (Signer (node->node_child ("X509IssuerSerial")))
+ X509Data (cxml::ConstNodePtr node)
+ : x509_issuer_serial (Signer (node->child ("X509IssuerSerial")))
, x509_certificate (node->string_child ("X509Certificate"))
{
node->done ();
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
x509_issuer_serial.as_xml (node->add_child ("X509IssuerSerial", "ds"));
- node->add_child("X509Certificate", "ds")->add_child_text (x509_certificate);
+ node->add_child("X509Certificate", "ds")->set_content (x509_certificate);
}
Signer x509_issuer_serial;
@@ -91,18 +91,18 @@ public:
: uri (u)
{}
- Reference (shared_ptr<const cxml::Node> node)
+ Reference (cxml::ConstNodePtr node)
: uri (node->string_attribute ("URI"))
, digest_value (node->string_child ("DigestValue"))
{
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
node->set_attribute ("URI", uri);
node->add_child("DigestMethod", "ds")->set_attribute ("Algorithm", "http://www.w3.org/2001/04/xmlenc#sha256");
- node->add_child("DigestValue", "ds")->add_child_text (digest_value);
+ node->add_child("DigestValue", "ds")->set_content (digest_value);
}
string uri;
@@ -117,10 +117,10 @@ public:
, authenticated_private ("#ID_AuthenticatedPrivate")
{}
- SignedInfo (shared_ptr<const cxml::Node> node)
+ SignedInfo (cxml::ConstNodePtr node)
{
- list<shared_ptr<cxml::Node> > references = node->node_children ("Reference");
- for (list<shared_ptr<cxml::Node> >::const_iterator i = references.begin(); i != references.end(); ++i) {
+ cxml::NodeList references = node->children ("Reference");
+ for (cxml::NodeList::const_iterator i = references.begin(); i != references.end(); ++i) {
if ((*i)->string_attribute ("URI") == "#ID_AuthenticatedPublic") {
authenticated_public = Reference (*i);
} else if ((*i)->string_attribute ("URI") == "#ID_AuthenticatedPrivate") {
@@ -131,7 +131,7 @@ public:
}
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
node->add_child ("CanonicalizationMethod", "ds")->set_attribute (
"Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"
@@ -155,22 +155,22 @@ class Signature
public:
Signature () {}
- Signature (shared_ptr<const cxml::Node> node)
- : signed_info (node->node_child ("SignedInfo"))
+ Signature (cxml::ConstNodePtr node)
+ : signed_info (node->child ("SignedInfo"))
, signature_value (node->string_child ("SignatureValue"))
{
- list<shared_ptr<cxml::Node> > x509_data_nodes = node->node_child("KeyInfo")->node_children ("X509Data");
- for (list<shared_ptr<cxml::Node> >::const_iterator i = x509_data_nodes.begin(); i != x509_data_nodes.end(); ++i) {
+ cxml::NodeList x509_data_nodes = node->child("KeyInfo")->children ("X509Data");
+ for (cxml::NodeList::const_iterator i = x509_data_nodes.begin(); i != x509_data_nodes.end(); ++i) {
x509_data.push_back (X509Data (*i));
}
}
- void as_xml (xmlpp::Node* node) const
+ void as_xml (cxml::NodePtr node) const
{
signed_info.as_xml (node->add_child ("SignedInfo", "ds"));
- node->add_child("SignatureValue", "ds")->add_child_text (signature_value);
+ node->add_child("SignatureValue", "ds")->set_content (signature_value);
- xmlpp::Element* key_info_node = node->add_child ("KeyInfo", "ds");
+ cxml::NodePtr key_info_node = node->add_child ("KeyInfo", "ds");
for (std::list<X509Data>::const_iterator i = x509_data.begin(); i != x509_data.end(); ++i) {
i->as_xml (key_info_node->add_child ("X509Data", "ds"));
}
@@ -186,26 +186,26 @@ class AuthenticatedPrivate
public:
AuthenticatedPrivate () {}
- AuthenticatedPrivate (shared_ptr<const cxml::Node> node)
+ AuthenticatedPrivate (cxml::ConstNodePtr node)
{
- list<shared_ptr<cxml::Node> > encrypted_key_nodes = node->node_children ("EncryptedKey");
- for (list<shared_ptr<cxml::Node> >::const_iterator i = encrypted_key_nodes.begin(); i != encrypted_key_nodes.end(); ++i) {
- encrypted_key.push_back ((*i)->node_child("CipherData")->string_child ("CipherValue"));
+ cxml::NodeList encrypted_key_nodes = node->children ("EncryptedKey");
+ for (cxml::NodeList::const_iterator i = encrypted_key_nodes.begin(); i != encrypted_key_nodes.end(); ++i) {
+ encrypted_key.push_back ((*i)->child("CipherData")->string_child ("CipherValue"));
}
}
- void as_xml (xmlpp::Element* node, map<string, xmlpp::Attribute *>& references) const
+ void as_xml (cxml::NodePtr node) const
{
- references["ID_AuthenticatedPrivate"] = node->set_attribute ("Id", "ID_AuthenticatedPrivate");
+ node->set_attribute ("Id", "ID_AuthenticatedPrivate");
for (list<string>::const_iterator i = encrypted_key.begin(); i != encrypted_key.end(); ++i) {
- xmlpp::Element* encrypted_key = node->add_child ("EncryptedKey", "enc");
- xmlpp::Element* encryption_method = encrypted_key->add_child ("EncryptionMethod", "enc");
+ cxml::NodePtr encrypted_key = node->add_child ("EncryptedKey", "enc");
+ cxml::NodePtr encryption_method = encrypted_key->add_child ("EncryptionMethod", "enc");
encryption_method->set_attribute ("Algorithm", "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p");
- xmlpp::Element* digest_method = encryption_method->add_child ("DigestMethod", "ds");
+ cxml::NodePtr digest_method = encryption_method->add_child ("DigestMethod", "ds");
digest_method->set_attribute ("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1");
- xmlpp::Element* cipher_data = encrypted_key->add_child ("CipherData", "enc");
- cipher_data->add_child("CipherValue", "enc")->add_child_text (*i);
+ cxml::NodePtr cipher_data = encrypted_key->add_child ("CipherData", "enc");
+ cipher_data->add_child("CipherValue", "enc")->set_content (*i);
}
}
@@ -217,7 +217,7 @@ class TypedKeyId
public:
TypedKeyId () {}
- TypedKeyId (shared_ptr<const cxml::Node> node)
+ TypedKeyId (cxml::ConstNodePtr node)
: key_type (node->string_child ("KeyType"))
, key_id (node->string_child ("KeyId").substr (9))
{
@@ -229,10 +229,10 @@ public:
, key_id (id)
{}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
- node->add_child("KeyType")->add_child_text (key_type);
- node->add_child("KeyId")->add_child_text ("urn:uuid:" + key_id);
+ node->add_child("KeyType")->set_content (key_type);
+ node->add_child("KeyId")->set_content ("urn:uuid:" + key_id);
}
string key_type;
@@ -244,15 +244,15 @@ class KeyIdList
public:
KeyIdList () {}
- KeyIdList (shared_ptr<const cxml::Node> node)
+ KeyIdList (cxml::ConstNodePtr node)
{
- list<shared_ptr<cxml::Node> > typed_key_id_nodes = node->node_children ("TypedKeyId");
- for (list<shared_ptr<cxml::Node> >::const_iterator i = typed_key_id_nodes.begin(); i != typed_key_id_nodes.end(); ++i) {
+ cxml::NodeList typed_key_id_nodes = node->children ("TypedKeyId");
+ for (cxml::NodeList::const_iterator i = typed_key_id_nodes.begin(); i != typed_key_id_nodes.end(); ++i) {
typed_key_id.push_back (TypedKeyId (*i));
}
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
for (list<TypedKeyId>::const_iterator i = typed_key_id.begin(); i != typed_key_id.end(); ++i) {
i->as_xml (node->add_child("TypedKeyId"));
@@ -267,20 +267,20 @@ class AuthorizedDeviceInfo
public:
AuthorizedDeviceInfo () {}
- AuthorizedDeviceInfo (shared_ptr<const cxml::Node> node)
+ AuthorizedDeviceInfo (cxml::ConstNodePtr node)
: device_list_identifier (node->string_child ("DeviceListIdentifier").substr (9))
, device_list_description (node->string_child ("DeviceListDescription"))
- , certificate_thumbprint (node->node_child("DeviceList")->string_child ("CertificateThumbprint"))
+ , certificate_thumbprint (node->child("DeviceList")->string_child ("CertificateThumbprint"))
{
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
- node->add_child ("DeviceListIdentifier")->add_child_text ("urn:uuid:" + device_list_identifier);
- node->add_child ("DeviceListDescription")->add_child_text (device_list_description);
- xmlpp::Element* device_list = node->add_child ("DeviceList");
- device_list->add_child("CertificateThumbprint")->add_child_text (certificate_thumbprint);
+ node->add_child ("DeviceListIdentifier")->set_content ("urn:uuid:" + device_list_identifier);
+ node->add_child ("DeviceListDescription")->set_content (device_list_description);
+ cxml::NodePtr device_list = node->add_child ("DeviceList");
+ device_list->add_child("CertificateThumbprint")->set_content (certificate_thumbprint);
}
/** DeviceListIdentifier without the urn:uuid: prefix */
@@ -294,17 +294,17 @@ class X509IssuerSerial
public:
X509IssuerSerial () {}
- X509IssuerSerial (shared_ptr<const cxml::Node> node)
+ X509IssuerSerial (cxml::ConstNodePtr node)
: x509_issuer_name (node->string_child ("X509IssuerName"))
, x509_serial_number (node->string_child ("X509SerialNumber"))
{
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
- node->add_child("X509IssuerName", "ds")->add_child_text (x509_issuer_name);
- node->add_child("X509SerialNumber", "ds")->add_child_text (x509_serial_number);
+ node->add_child("X509IssuerName", "ds")->set_content (x509_issuer_name);
+ node->add_child("X509SerialNumber", "ds")->set_content (x509_serial_number);
}
string x509_issuer_name;
@@ -316,17 +316,17 @@ class Recipient
public:
Recipient () {}
- Recipient (shared_ptr<const cxml::Node> node)
- : x509_issuer_serial (node->node_child ("X509IssuerSerial"))
+ Recipient (cxml::ConstNodePtr node)
+ : x509_issuer_serial (node->child ("X509IssuerSerial"))
, x509_subject_name (node->string_child ("X509SubjectName"))
{
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
x509_issuer_serial.as_xml (node->add_child ("X509IssuerSerial"));
- node->add_child("X509SubjectName")->add_child_text (x509_subject_name);
+ node->add_child("X509SubjectName")->set_content (x509_subject_name);
}
X509IssuerSerial x509_issuer_serial;
@@ -338,36 +338,36 @@ class KDMRequiredExtensions
public:
KDMRequiredExtensions () {}
- KDMRequiredExtensions (shared_ptr<const cxml::Node> node)
- : recipient (node->node_child ("Recipient"))
+ KDMRequiredExtensions (cxml::ConstNodePtr node)
+ : recipient (node->child ("Recipient"))
, composition_playlist_id (node->string_child ("CompositionPlaylistId").substr (9))
, content_title_text (node->string_child ("ContentTitleText"))
, not_valid_before (node->string_child ("ContentKeysNotValidBefore"))
, not_valid_after (node->string_child ("ContentKeysNotValidAfter"))
- , authorized_device_info (node->node_child ("AuthorizedDeviceInfo"))
- , key_id_list (node->node_child ("KeyIdList"))
+ , authorized_device_info (node->child ("AuthorizedDeviceInfo"))
+ , key_id_list (node->child ("KeyIdList"))
{
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
node->set_attribute ("xmlns", "http://www.smpte-ra.org/schemas/430-1/2006/KDM");
recipient.as_xml (node->add_child ("Recipient"));
- node->add_child("CompositionPlaylistId")->add_child_text ("urn:uuid:" + composition_playlist_id);
+ node->add_child("CompositionPlaylistId")->set_content ("urn:uuid:" + composition_playlist_id);
if (content_authenticator) {
- node->add_child("ContentAuthenticator")->add_child_text (content_authenticator.get ());
+ node->add_child("ContentAuthenticator")->set_content (content_authenticator.get ());
}
- node->add_child("ContentTitleText")->add_child_text (content_title_text);
- node->add_child("ContentKeysNotValidBefore")->add_child_text (not_valid_before.as_string ());
- node->add_child("ContentKeysNotValidAfter")->add_child_text (not_valid_after.as_string ());
+ node->add_child("ContentTitleText")->set_content (content_title_text);
+ node->add_child("ContentKeysNotValidBefore")->set_content (not_valid_before.as_string ());
+ node->add_child("ContentKeysNotValidAfter")->set_content (not_valid_after.as_string ());
authorized_device_info.as_xml (node->add_child ("AuthorizedDeviceInfo"));
key_id_list.as_xml (node->add_child ("KeyIdList"));
- xmlpp::Element* forensic_mark_flag_list = node->add_child ("ForensicMarkFlagList");
- forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text ("http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-picture-disable");
- forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text ("http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-audio-disable");
+ cxml::NodePtr forensic_mark_flag_list = node->add_child ("ForensicMarkFlagList");
+ forensic_mark_flag_list->add_child("ForensicMarkFlag")->set_content ("http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-picture-disable");
+ forensic_mark_flag_list->add_child("ForensicMarkFlag")->set_content ("http://www.smpte-ra.org/430-1/2006/KDM#mrkflg-audio-disable");
}
Recipient recipient;
@@ -385,13 +385,13 @@ class RequiredExtensions
public:
RequiredExtensions () {}
- RequiredExtensions (shared_ptr<const cxml::Node> node)
- : kdm_required_extensions (node->node_child ("KDMRequiredExtensions"))
+ RequiredExtensions (cxml::ConstNodePtr node)
+ : kdm_required_extensions (node->child ("KDMRequiredExtensions"))
{
}
- void as_xml (xmlpp::Element* node) const
+ void as_xml (cxml::NodePtr node) const
{
kdm_required_extensions.as_xml (node->add_child ("KDMRequiredExtensions"));
}
@@ -407,24 +407,24 @@ public:
, issue_date (LocalTime().as_string ())
{}
- AuthenticatedPublic (shared_ptr<const cxml::Node> node)
+ AuthenticatedPublic (cxml::ConstNodePtr node)
: message_id (node->string_child ("MessageId").substr (9))
, annotation_text (node->string_child ("AnnotationText"))
, issue_date (node->string_child ("IssueDate"))
- , signer (node->node_child ("Signer"))
- , required_extensions (node->node_child ("RequiredExtensions"))
+ , signer (node->child ("Signer"))
+ , required_extensions (node->child ("RequiredExtensions"))
{
}
- void as_xml (xmlpp::Element* node, map<string, xmlpp::Attribute *>& references) const
+ void as_xml (cxml::NodePtr node) const
{
- references["ID_AuthenticatedPublic"] = node->set_attribute ("Id", "ID_AuthenticatedPublic");
+ node->set_attribute ("Id", "ID_AuthenticatedPublic");
- node->add_child("MessageId")->add_child_text ("urn:uuid:" + message_id);
- node->add_child("MessageType")->add_child_text ("http://www.smpte-ra.org/430-1/2006/KDM#kdm-key-type");
- node->add_child("AnnotationText")->add_child_text (annotation_text);
- node->add_child("IssueDate")->add_child_text (issue_date);
+ node->add_child("MessageId")->set_content ("urn:uuid:" + message_id);
+ node->add_child("MessageType")->set_content ("http://www.smpte-ra.org/430-1/2006/KDM#kdm-key-type");
+ node->add_child("AnnotationText")->set_content (annotation_text);
+ node->add_child("IssueDate")->set_content (issue_date);
signer.as_xml (node->add_child ("Signer"));
required_extensions.as_xml (node->add_child ("RequiredExtensions"));
@@ -450,30 +450,31 @@ public:
}
- EncryptedKDMData (shared_ptr<const cxml::Node> node)
- : authenticated_public (node->node_child ("AuthenticatedPublic"))
- , authenticated_private (node->node_child ("AuthenticatedPrivate"))
- , signature (node->node_child ("Signature"))
+ EncryptedKDMData (cxml::ConstNodePtr node)
+ : authenticated_public (node->child ("AuthenticatedPublic"))
+ , authenticated_private (node->child ("AuthenticatedPrivate"))
+ , signature (node->child ("Signature"))
{
}
- shared_ptr<xmlpp::Document> as_xml () const
+ cxml::NodePtr as_xml () const
{
- shared_ptr<xmlpp::Document> document (new xmlpp::Document ());
- xmlpp::Element* root = document->create_root_node ("DCinemaSecurityMessage", "http://www.smpte-ra.org/schemas/430-3/2006/ETM");
- root->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "ds");
- root->set_namespace_declaration ("http://www.w3.org/2001/04/xmlenc#", "enc");
- map<string, xmlpp::Attribute *> references;
- authenticated_public.as_xml (root->add_child ("AuthenticatedPublic"), references);
- authenticated_private.as_xml (root->add_child ("AuthenticatedPrivate"), references);
+ cxml::NodePtr root (new cxml::Node);
+ root->set_name ("DCinemaSecurityMessage");
+ root->set_attribute ("xmlns", "http://www.smpte-ra.org/schemas/430-3/2006/ETM");
+ root->set_attribute ("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
+ root->set_attribute ("xmlns:enc", "http://www.w3.org/2001/04/xmlenc#");
+ authenticated_public.as_xml (root->add_child ("AuthenticatedPublic"));
+ authenticated_private.as_xml (root->add_child ("AuthenticatedPrivate"));
signature.as_xml (root->add_child ("Signature", "ds"));
- for (map<string, xmlpp::Attribute*>::const_iterator i = references.begin(); i != references.end(); ++i) {
- xmlAddID (0, document->cobj(), (const xmlChar *) i->first.c_str(), i->second->cobj ());
- }
+ /* XXX */
+// for (map<string, xmlpp::Attribute*>::const_iterator i = references.begin(); i != references.end(); ++i) {
+// xmlAddID (0, document->cobj(), (const xmlChar *) i->first.c_str(), i->second->cobj ());
+// }
- return document;
+ return root;
}
AuthenticatedPublic authenticated_public;
@@ -486,8 +487,7 @@ public:
EncryptedKDM::EncryptedKDM (string s)
{
- shared_ptr<cxml::Document> doc (new cxml::Document ("DCinemaSecurityMessage"));
- doc->read_string (s);
+ cxml::NodePtr doc = cxml::read_string (s);
_data = new data::EncryptedKDMData (doc);
}
@@ -545,17 +545,16 @@ EncryptedKDM::EncryptedKDM (
_data->authenticated_private.encrypted_key = keys;
/* Read the XML so far and sign it */
- shared_ptr<xmlpp::Document> doc = _data->as_xml ();
- xmlpp::Node::NodeList children = doc->get_root_node()->get_children ();
- for (xmlpp::Node::NodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
- if ((*i)->get_name() == "Signature") {
+ cxml::NodePtr doc = _data->as_xml ();
+ cxml::NodeList children = doc->children ();
+ for (cxml::NodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
+ if ((*i)->name() == "Signature") {
signer->add_signature_value (*i, "ds");
}
}
/* Read the bits that add_signature_value did back into our variables */
- shared_ptr<cxml::Node> signed_doc (new cxml::Node (doc->get_root_node ()));
- _data->signature = data::Signature (signed_doc->node_child ("Signature"));
+ _data->signature = data::Signature (doc->child ("Signature"));
}
EncryptedKDM::EncryptedKDM (EncryptedKDM const & other)
@@ -593,12 +592,7 @@ EncryptedKDM::as_xml (boost::filesystem::path path) const
string
EncryptedKDM::as_xml () const
{
- xmlpp::Document document;
- xmlpp::Element* root = document.create_root_node ("DCinemaSecurityMessage", "http://www.smpte-ra.org/schemas/430-3/2006/ETM");
- root->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "ds");
- root->set_namespace_declaration ("http://www.w3.org/2001/04/xmlenc#", "enc");
-
- return _data->as_xml()->write_to_string ("UTF-8");
+ return cxml::write_to_string (_data->as_xml ());
}
list<string>
diff --git a/src/font.cc b/src/font.cc
index 51bd866e..7cad478d 100644
--- a/src/font.cc
+++ b/src/font.cc
@@ -30,7 +30,7 @@ using boost::shared_ptr;
using boost::optional;
using namespace dcp;
-Font::Font (boost::shared_ptr<const cxml::Node> node)
+Font::Font (cxml::ConstNodePtr node)
{
text = node->content ();
diff --git a/src/font.h b/src/font.h
index 0250e997..8c194422 100644
--- a/src/font.h
+++ b/src/font.h
@@ -43,7 +43,7 @@ public:
: size (0)
{}
- Font (boost::shared_ptr<const cxml::Node> node);
+ Font (cxml::ConstNodePtr node);
Font (std::list<boost::shared_ptr<Font> > const & font_nodes);
std::string text;
diff --git a/src/load_font.cc b/src/load_font.cc
index b46569c8..12bd4320 100644
--- a/src/load_font.cc
+++ b/src/load_font.cc
@@ -25,7 +25,7 @@ using boost::shared_ptr;
using boost::optional;
using namespace dcp;
-LoadFont::LoadFont (boost::shared_ptr<const cxml::Node> node)
+LoadFont::LoadFont (cxml::ConstNodePtr node)
{
optional<string> x = node->optional_string_attribute ("Id");
if (!x) {
diff --git a/src/load_font.h b/src/load_font.h
index 6d52a509..4c419bdb 100644
--- a/src/load_font.h
+++ b/src/load_font.h
@@ -17,6 +17,7 @@
*/
+#include <libcxml/cxml.h>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
@@ -30,7 +31,7 @@ class LoadFont
{
public:
LoadFont () {}
- LoadFont (boost::shared_ptr<const cxml::Node> node);
+ LoadFont (cxml::ConstNodePtr node);
std::string id;
boost::optional<std::string> uri;
diff --git a/src/reel.cc b/src/reel.cc
index 0071de86..607a01eb 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -39,27 +39,27 @@ using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using namespace dcp;
-Reel::Reel (boost::shared_ptr<const cxml::Node> node)
+Reel::Reel (cxml::ConstNodePtr node)
: Object (node->string_child ("Id"))
{
- shared_ptr<cxml::Node> asset_list = node->node_child ("AssetList");
+ cxml::NodePtr asset_list = node->child ("AssetList");
- shared_ptr<cxml::Node> main_picture = asset_list->optional_node_child ("MainPicture");
+ cxml::NodePtr main_picture = asset_list->optional_child ("MainPicture");
if (main_picture) {
_main_picture.reset (new ReelMonoPictureAsset (main_picture));
}
- shared_ptr<cxml::Node> main_stereoscopic_picture = asset_list->optional_node_child ("MainStereoscopicPicture");
+ cxml::NodePtr main_stereoscopic_picture = asset_list->optional_child ("MainStereoscopicPicture");
if (main_stereoscopic_picture) {
_main_picture.reset (new ReelStereoPictureAsset (main_stereoscopic_picture));
}
- shared_ptr<cxml::Node> main_sound = asset_list->optional_node_child ("MainSound");
+ cxml::NodePtr main_sound = asset_list->optional_child ("MainSound");
if (main_sound) {
_main_sound.reset (new ReelSoundAsset (main_sound));
}
- shared_ptr<cxml::Node> main_subtitle = asset_list->optional_node_child ("MainSubtitle");
+ cxml::NodePtr main_subtitle = asset_list->optional_child ("MainSubtitle");
if (main_subtitle) {
_main_subtitle.reset (new ReelSubtitleAsset (main_subtitle));
}
@@ -69,11 +69,11 @@ Reel::Reel (boost::shared_ptr<const cxml::Node> node)
}
void
-Reel::write_to_cpl (xmlpp::Element* node, Standard standard) const
+Reel::write_to_cpl (cxml::NodePtr node, Standard standard) const
{
- xmlpp::Element* reel = node->add_child ("Reel");
- reel->add_child("Id")->add_child_text ("urn:uuid:" + make_uuid());
- xmlpp::Element* asset_list = reel->add_child ("AssetList");
+ cxml::NodePtr reel = node->add_child ("Reel");
+ reel->add_child("Id")->set_content ("urn:uuid:" + make_uuid());
+ cxml::NodePtr asset_list = reel->add_child ("AssetList");
if (_main_picture && dynamic_pointer_cast<ReelMonoPictureAsset> (_main_picture)) {
/* Mono pictures come before other stuff... */
diff --git a/src/reel.h b/src/reel.h
index 584ba597..78e7ae7e 100644
--- a/src/reel.h
+++ b/src/reel.h
@@ -23,15 +23,11 @@
#include "key.h"
#include "types.h"
#include "ref.h"
-#include <libxml++/libxml++.h>
+#include <libcxml/cxml.h>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <list>
-namespace cxml {
- class Node;
-}
-
namespace dcp {
class DecryptedKDM;
@@ -57,7 +53,7 @@ public:
, _main_subtitle (subtitle)
{}
- Reel (boost::shared_ptr<const cxml::Node>);
+ Reel (cxml::ConstNodePtr);
boost::shared_ptr<ReelPictureAsset> main_picture () const {
return _main_picture;
@@ -73,7 +69,7 @@ public:
void add (boost::shared_ptr<ReelAsset> asset);
- void write_to_cpl (xmlpp::Element* node, Standard standard) const;
+ void write_to_cpl (cxml::NodePtr node, Standard standard) const;
bool encrypted () const;
diff --git a/src/reel_asset.cc b/src/reel_asset.cc
index 31422173..f30f4799 100644
--- a/src/reel_asset.cc
+++ b/src/reel_asset.cc
@@ -60,7 +60,7 @@ ReelAsset::ReelAsset (shared_ptr<Content> content, Fraction edit_rate, int64_t i
_annotation_text = content->file().leaf().string ();
}
-ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
+ReelAsset::ReelAsset (cxml::ConstNodePtr node)
: Object (node->string_child ("Id"))
, _content (_id)
, _annotation_text (node->optional_string_child ("AnnotationText").get_value_or (""))
@@ -77,20 +77,20 @@ ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
}
void
-ReelAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+ReelAsset::write_to_cpl (cxml::NodePtr node, Standard standard) const
{
pair<string, string> const attr = cpl_node_attribute (standard);
- xmlpp::Element* a = node->add_child (cpl_node_name ());
+ cxml::NodePtr a = node->add_child (cpl_node_name ());
if (!attr.first.empty ()) {
a->set_attribute (attr.first, attr.second);
}
- a->add_child("Id")->add_child_text ("urn:uuid:" + _id);
- a->add_child("AnnotationText")->add_child_text (_annotation_text);
- a->add_child("EditRate")->add_child_text (String::compose ("%1 %2", _edit_rate.numerator, _edit_rate.denominator));
- a->add_child("IntrinsicDuration")->add_child_text (raw_convert<string> (_intrinsic_duration));
- a->add_child("EntryPoint")->add_child_text (raw_convert<string> (_entry_point));
- a->add_child("Duration")->add_child_text (raw_convert<string> (_duration));
- a->add_child("Hash")->add_child_text (_content.object()->hash ());
+ a->add_child("Id")->set_content ("urn:uuid:" + _id);
+ a->add_child("AnnotationText")->set_content (_annotation_text);
+ a->add_child("EditRate")->set_content (String::compose ("%1 %2", _edit_rate.numerator, _edit_rate.denominator));
+ a->add_child("IntrinsicDuration")->set_content (raw_convert<string> (_intrinsic_duration));
+ a->add_child("EntryPoint")->set_content (raw_convert<string> (_entry_point));
+ a->add_child("Duration")->set_content (raw_convert<string> (_duration));
+ a->add_child("Hash")->set_content (_content.object()->hash ());
}
pair<string, string>
diff --git a/src/reel_asset.h b/src/reel_asset.h
index 61d2b48f..c5932c4f 100644
--- a/src/reel_asset.h
+++ b/src/reel_asset.h
@@ -23,16 +23,9 @@
#include "object.h"
#include "util.h"
#include "ref.h"
+#include <libcxml/cxml.h>
#include <boost/shared_ptr.hpp>
-namespace cxml {
- class Node;
-}
-
-namespace xmlpp {
- class Node;
-}
-
namespace dcp {
class Content;
@@ -49,9 +42,9 @@ class ReelAsset : public Object
public:
ReelAsset ();
ReelAsset (boost::shared_ptr<Content> content, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
- ReelAsset (boost::shared_ptr<const cxml::Node>);
+ ReelAsset (cxml::ConstNodePtr);
- virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+ virtual void write_to_cpl (cxml::NodePtr node, Standard standard) const;
virtual bool equals (boost::shared_ptr<const ReelAsset>, EqualityOptions, boost::function<void (NoteType, std::string)>) const;
/** @return a Ref to our actual content */
diff --git a/src/reel_mono_picture_asset.cc b/src/reel_mono_picture_asset.cc
index b4ed6301..e559cd09 100644
--- a/src/reel_mono_picture_asset.cc
+++ b/src/reel_mono_picture_asset.cc
@@ -40,7 +40,7 @@ ReelMonoPictureAsset::ReelMonoPictureAsset (boost::shared_ptr<MonoPictureMXF> mx
}
-ReelMonoPictureAsset::ReelMonoPictureAsset (boost::shared_ptr<const cxml::Node> node)
+ReelMonoPictureAsset::ReelMonoPictureAsset (cxml::ConstNodePtr node)
: ReelPictureAsset (node)
{
node->done ();
diff --git a/src/reel_mono_picture_asset.h b/src/reel_mono_picture_asset.h
index a25550a4..d6e117cf 100644
--- a/src/reel_mono_picture_asset.h
+++ b/src/reel_mono_picture_asset.h
@@ -38,7 +38,7 @@ class ReelMonoPictureAsset : public ReelPictureAsset
public:
ReelMonoPictureAsset ();
ReelMonoPictureAsset (boost::shared_ptr<MonoPictureMXF> content, int64_t entry_point);
- ReelMonoPictureAsset (boost::shared_ptr<const cxml::Node>);
+ ReelMonoPictureAsset (cxml::ConstNodePtr);
private:
std::string cpl_node_name () const;
diff --git a/src/reel_mxf_asset.cc b/src/reel_mxf_asset.cc
index 8395376e..753dac7c 100644
--- a/src/reel_mxf_asset.cc
+++ b/src/reel_mxf_asset.cc
@@ -37,7 +37,7 @@ ReelMXFAsset::ReelMXFAsset (shared_ptr<MXF> mxf, Fraction edit_rate, int64_t int
}
-ReelMXFAsset::ReelMXFAsset (shared_ptr<const cxml::Node> node)
+ReelMXFAsset::ReelMXFAsset (cxml::ConstNodePtr node)
: ReelAsset (node)
, _key_id (node->optional_string_child ("KeyId").get_value_or (""))
{
@@ -47,19 +47,19 @@ ReelMXFAsset::ReelMXFAsset (shared_ptr<const cxml::Node> node)
}
void
-ReelMXFAsset::write_to_cpl (xmlpp::Node* node, Standard s) const
+ReelMXFAsset::write_to_cpl (cxml::NodePtr node, Standard s) const
{
ReelAsset::write_to_cpl (node, s);
- xmlpp::Node::NodeList c = node->get_children ();
- xmlpp::Node::NodeList::iterator i = c.begin();
- while (i != c.end() && (*i)->get_name() != cpl_node_name ()) {
+ cxml::NodeList c = node->children ();
+ cxml::NodeList::iterator i = c.begin();
+ while (i != c.end() && (*i)->name() != cpl_node_name ()) {
++i;
}
assert (i != c.end ());
if (!_key_id.empty ()) {
- (*i)->add_child("KeyId")->add_child_text ("urn:uuid:" + _key_id);
+ (*i)->add_child("KeyId")->set_content ("urn:uuid:" + _key_id);
}
}
diff --git a/src/reel_mxf_asset.h b/src/reel_mxf_asset.h
index 9d98cd71..5a11644b 100644
--- a/src/reel_mxf_asset.h
+++ b/src/reel_mxf_asset.h
@@ -31,12 +31,12 @@ class ReelMXFAsset : public ReelAsset
public:
ReelMXFAsset ();
ReelMXFAsset (boost::shared_ptr<MXF> mxf, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
- ReelMXFAsset (boost::shared_ptr<const cxml::Node>);
+ ReelMXFAsset (cxml::ConstNodePtr);
/** @return the 4-character key type for this MXF (MDIK, MDAK, etc.) */
virtual std::string key_type () const = 0;
- void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+ void write_to_cpl (cxml::NodePtr node, Standard standard) const;
/** @return true if a KeyId is specified for this asset, implying
* that its content is encrypted.
diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc
index 1fbd635b..cabdc751 100644
--- a/src/reel_picture_asset.cc
+++ b/src/reel_picture_asset.cc
@@ -50,7 +50,7 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureMXF> content, int64_t entr
}
-ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
+ReelPictureAsset::ReelPictureAsset (cxml::ConstNodePtr node)
: ReelMXFAsset (node)
{
_frame_rate = Fraction (node->string_child ("FrameRate"));
@@ -68,25 +68,25 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
}
void
-ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+ReelPictureAsset::write_to_cpl (cxml::NodePtr node, Standard standard) const
{
ReelMXFAsset::write_to_cpl (node, standard);
- xmlpp::Node::NodeList c = node->get_children ();
- xmlpp::Node::NodeList::iterator i = c.begin();
- while (i != c.end() && (*i)->get_name() != cpl_node_name ()) {
+ cxml::NodeList c = node->children ();
+ cxml::NodeList::iterator i = c.begin();
+ while (i != c.end() && (*i)->name() != cpl_node_name ()) {
++i;
}
assert (i != c.end ());
- (*i)->add_child ("FrameRate")->add_child_text (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
+ (*i)->add_child ("FrameRate")->set_content (String::compose ("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
if (standard == INTEROP) {
stringstream s;
s << std::fixed << std::setprecision (2) << (float (_screen_aspect_ratio.numerator) / _screen_aspect_ratio.denominator);
- (*i)->add_child ("ScreenAspectRatio")->add_child_text (s.str ());
+ (*i)->add_child ("ScreenAspectRatio")->set_content (s.str ());
} else {
- (*i)->add_child ("ScreenAspectRatio")->add_child_text (
+ (*i)->add_child ("ScreenAspectRatio")->set_content (
String::compose ("%1 %2", _screen_aspect_ratio.numerator, _screen_aspect_ratio.denominator)
);
}
diff --git a/src/reel_picture_asset.h b/src/reel_picture_asset.h
index 76ba22c9..f430cddf 100644
--- a/src/reel_picture_asset.h
+++ b/src/reel_picture_asset.h
@@ -37,9 +37,9 @@ class ReelPictureAsset : public ReelMXFAsset
public:
ReelPictureAsset ();
ReelPictureAsset (boost::shared_ptr<PictureMXF> content, int64_t entry_point);
- ReelPictureAsset (boost::shared_ptr<const cxml::Node>);
+ ReelPictureAsset (cxml::ConstNodePtr);
- virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const;
+ virtual void write_to_cpl (cxml::NodePtr node, Standard standard) const;
virtual bool equals (boost::shared_ptr<const ReelAsset>, EqualityOptions, boost::function<void (NoteType, std::string)>) const;
boost::shared_ptr<PictureMXF> mxf () {
diff --git a/src/reel_sound_asset.cc b/src/reel_sound_asset.cc
index 55167d82..d1700999 100644
--- a/src/reel_sound_asset.cc
+++ b/src/reel_sound_asset.cc
@@ -34,7 +34,7 @@ ReelSoundAsset::ReelSoundAsset (shared_ptr<SoundMXF> content, int64_t entry_poin
}
-ReelSoundAsset::ReelSoundAsset (shared_ptr<const cxml::Node> node)
+ReelSoundAsset::ReelSoundAsset (cxml::ConstNodePtr node)
: ReelMXFAsset (node)
{
node->ignore_child ("Language");
diff --git a/src/reel_sound_asset.h b/src/reel_sound_asset.h
index 0e27f380..c36627b0 100644
--- a/src/reel_sound_asset.h
+++ b/src/reel_sound_asset.h
@@ -35,7 +35,7 @@ class ReelSoundAsset : public ReelMXFAsset
{
public:
ReelSoundAsset (boost::shared_ptr<dcp::SoundMXF> content, int64_t entry_point);
- ReelSoundAsset (boost::shared_ptr<const cxml::Node>);
+ ReelSoundAsset (cxml::ConstNodePtr);
boost::shared_ptr<SoundMXF> mxf () {
return boost::dynamic_pointer_cast<SoundMXF> (_content.object ());
diff --git a/src/reel_stereo_picture_asset.cc b/src/reel_stereo_picture_asset.cc
index 09178dc2..dc62cbac 100644
--- a/src/reel_stereo_picture_asset.cc
+++ b/src/reel_stereo_picture_asset.cc
@@ -42,7 +42,7 @@ ReelStereoPictureAsset::ReelStereoPictureAsset (boost::shared_ptr<StereoPictureM
}
-ReelStereoPictureAsset::ReelStereoPictureAsset (boost::shared_ptr<const cxml::Node> node)
+ReelStereoPictureAsset::ReelStereoPictureAsset (cxml::ConstNodePtr node)
: ReelPictureAsset (node)
{
node->done ();
diff --git a/src/reel_stereo_picture_asset.h b/src/reel_stereo_picture_asset.h
index 57cc4da1..f5755a78 100644
--- a/src/reel_stereo_picture_asset.h
+++ b/src/reel_stereo_picture_asset.h
@@ -38,7 +38,7 @@ class ReelStereoPictureAsset : public ReelPictureAsset
public:
ReelStereoPictureAsset ();
ReelStereoPictureAsset (boost::shared_ptr<StereoPictureMXF> content, int64_t entry_point);
- ReelStereoPictureAsset (boost::shared_ptr<const cxml::Node>);
+ ReelStereoPictureAsset (cxml::ConstNodePtr);
private:
std::string cpl_node_name () const;
diff --git a/src/reel_subtitle_asset.cc b/src/reel_subtitle_asset.cc
index 139e3a39..40b45769 100644
--- a/src/reel_subtitle_asset.cc
+++ b/src/reel_subtitle_asset.cc
@@ -34,7 +34,7 @@ ReelSubtitleAsset::ReelSubtitleAsset (boost::shared_ptr<SubtitleContent> content
}
-ReelSubtitleAsset::ReelSubtitleAsset (boost::shared_ptr<const cxml::Node> node)
+ReelSubtitleAsset::ReelSubtitleAsset (cxml::ConstNodePtr node)
: ReelAsset (node)
{
node->ignore_child ("Language");
diff --git a/src/reel_subtitle_asset.h b/src/reel_subtitle_asset.h
index f0537cb5..19d638c2 100644
--- a/src/reel_subtitle_asset.h
+++ b/src/reel_subtitle_asset.h
@@ -38,7 +38,7 @@ class ReelSubtitleAsset : public ReelAsset
{
public:
ReelSubtitleAsset (boost::shared_ptr<SubtitleContent> content, Fraction edit_rate, int64_t instrinsic_duration, int64_t entry_point);
- ReelSubtitleAsset (boost::shared_ptr<const cxml::Node>);
+ ReelSubtitleAsset (cxml::ConstNodePtr);
boost::shared_ptr<SubtitleContent> subtitle_content () const {
return boost::dynamic_pointer_cast<SubtitleContent> (_content.object ());
diff --git a/src/signer.cc b/src/signer.cc
index 67c8ac58..bf01382a 100644
--- a/src/signer.cc
+++ b/src/signer.cc
@@ -82,22 +82,22 @@ Signer::create (boost::filesystem::path directory)
* @param standard INTEROP or SMPTE.
*/
void
-Signer::sign (xmlpp::Element* parent, Standard standard) const
+Signer::sign (cxml::NodePtr parent, Standard standard) const
{
/* <Signer> */
- xmlpp::Element* signer = parent->add_child("Signer");
- xmlpp::Element* data = signer->add_child("X509Data", "dsig");
- xmlpp::Element* serial_element = data->add_child("X509IssuerSerial", "dsig");
- serial_element->add_child("X509IssuerName", "dsig")->add_child_text (_certificates.leaf().issuer());
- serial_element->add_child("X509SerialNumber", "dsig")->add_child_text (_certificates.leaf().serial());
- data->add_child("X509SubjectName", "dsig")->add_child_text (_certificates.leaf().subject());
+ cxml::NodePtr signer = parent->add_child("Signer");
+ cxml::NodePtr data = signer->add_child("X509Data", "dsig");
+ cxml::NodePtr serial_element = data->add_child("X509IssuerSerial", "dsig");
+ serial_element->add_child("X509IssuerName", "dsig")->set_content (_certificates.leaf().issuer());
+ serial_element->add_child("X509SerialNumber", "dsig")->set_content (_certificates.leaf().serial());
+ data->add_child("X509SubjectName", "dsig")->set_content (_certificates.leaf().subject());
/* <Signature> */
- xmlpp::Element* signature = parent->add_child("Signature", "dsig");
+ cxml::NodePtr signature = parent->add_child("Signature", "dsig");
- xmlpp::Element* signed_info = signature->add_child ("SignedInfo", "dsig");
+ cxml::NodePtr signed_info = signature->add_child ("SignedInfo", "dsig");
signed_info->add_child("CanonicalizationMethod", "dsig")->set_attribute ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
if (standard == INTEROP) {
@@ -106,10 +106,10 @@ Signer::sign (xmlpp::Element* parent, Standard standard) const
signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
}
- xmlpp::Element* reference = signed_info->add_child("Reference", "dsig");
+ cxml::NodePtr reference = signed_info->add_child("Reference", "dsig");
reference->set_attribute ("URI", "");
- xmlpp::Element* transforms = reference->add_child("Transforms", "dsig");
+ cxml::NodePtr transforms = reference->add_child("Transforms", "dsig");
transforms->add_child("Transform", "dsig")->set_attribute (
"Algorithm", "http://www.w3.org/2000/09/xmldsig#enveloped-signature"
);
@@ -130,23 +130,22 @@ Signer::sign (xmlpp::Element* parent, Standard standard) const
* @param ns Namespace to use for the signature XML nodes.
*/
void
-Signer::add_signature_value (xmlpp::Node* parent, string ns) const
+Signer::add_signature_value (cxml::NodePtr parent, string ns) const
{
- cxml::Node cp (parent);
- xmlpp::Node* key_info = cp.node_child("KeyInfo")->node ();
+ cxml::NodePtr key_info = parent->child("KeyInfo");
/* Add the certificate chain to the KeyInfo child node of parent */
CertificateChain::List c = _certificates.leaf_to_root ();
for (CertificateChain::List::iterator i = c.begin(); i != c.end(); ++i) {
- xmlpp::Element* data = key_info->add_child("X509Data", ns);
+ cxml::NodePtr data = key_info->add_child("X509Data", ns);
{
- xmlpp::Element* serial = data->add_child("X509IssuerSerial", ns);
- serial->add_child("X509IssuerName", ns)->add_child_text (i->issuer ());
- serial->add_child("X509SerialNumber", ns)->add_child_text (i->serial ());
+ cxml::NodePtr serial = data->add_child("X509IssuerSerial", ns);
+ serial->add_child("X509IssuerName", ns)->set_content (i->issuer ());
+ serial->add_child("X509SerialNumber", ns)->set_content (i->serial ());
}
- data->add_child("X509Certificate", ns)->add_child_text (i->certificate());
+ data->add_child("X509Certificate", ns)->set_content (i->certificate());
}
xmlSecDSigCtxPtr signature_context = xmlSecDSigCtxCreate (0);
@@ -167,10 +166,11 @@ Signer::add_signature_value (xmlpp::Node* parent, string ns) const
throw MiscError ("could not set key name");
}
- int const r = xmlSecDSigCtxSign (signature_context, parent->cobj ());
- if (r < 0) {
- throw MiscError (String::compose ("could not sign (%1)", r));
- }
+ /* XXX */
+// int const r = xmlSecDSigCtxSign (signature_context, parent->cobj ());
+// if (r < 0) {
+// throw MiscError (String::compose ("could not sign (%1)", r));
+// }
xmlSecDSigCtxDestroy (signature_context);
}
diff --git a/src/signer.h b/src/signer.h
index 1d53d5ba..b54c6255 100644
--- a/src/signer.h
+++ b/src/signer.h
@@ -26,13 +26,9 @@
#include "certificates.h"
#include "types.h"
+#include <libcxml/cxml.h>
#include <boost/filesystem.hpp>
-namespace xmlpp {
- class Element;
- class Node;
-}
-
namespace dcp {
/** @class Signer
@@ -60,8 +56,8 @@ public:
, _key (k)
{}
- void sign (xmlpp::Element* parent, Standard standard) const;
- void add_signature_value (xmlpp::Node* parent, std::string ns) const;
+ void sign (cxml::NodePtr parent, Standard standard) const;
+ void add_signature_value (cxml::NodePtr parent, std::string ns) const;
CertificateChain const & certificates () const {
return _certificates;
diff --git a/src/subtitle.cc b/src/subtitle.cc
index 12714961..c3c5354f 100644
--- a/src/subtitle.cc
+++ b/src/subtitle.cc
@@ -29,7 +29,7 @@ using boost::shared_ptr;
using boost::lexical_cast;
using namespace dcp;
-Subtitle::Subtitle (boost::shared_ptr<const cxml::Node> node)
+Subtitle::Subtitle (cxml::ConstNodePtr node)
{
in = Time (node->string_attribute ("TimeIn"));
out = Time (node->string_attribute ("TimeOut"));
@@ -40,7 +40,7 @@ Subtitle::Subtitle (boost::shared_ptr<const cxml::Node> node)
}
Time
-Subtitle::fade_time (shared_ptr<const cxml::Node> node, string name)
+Subtitle::fade_time (cxml::ConstNodePtr node, string name)
{
string const u = node->optional_string_attribute (name).get_value_or ("");
Time t;
diff --git a/src/subtitle.h b/src/subtitle.h
index 073bfb0c..ad98152d 100644
--- a/src/subtitle.h
+++ b/src/subtitle.h
@@ -21,13 +21,10 @@
#define LIBDCP_SUBTITLE_H
#include "dcp_time.h"
+#include <libcxml/cxml.h>
#include <boost/shared_ptr.hpp>
#include <list>
-namespace cxml {
- class Node;
-}
-
namespace dcp {
class Font;
@@ -37,7 +34,7 @@ class Subtitle
{
public:
Subtitle () {}
- Subtitle (boost::shared_ptr<const cxml::Node> node);
+ Subtitle (cxml::ConstNodePtr node);
Time in;
Time out;
@@ -47,7 +44,7 @@ public:
std::list<boost::shared_ptr<Text> > text_nodes;
private:
- Time fade_time (boost::shared_ptr<const cxml::Node>, std::string name);
+ Time fade_time (cxml::ConstNodePtr, std::string name);
};
}
diff --git a/src/subtitle_content.cc b/src/subtitle_content.cc
index 4f83d5bd..d79cf864 100644
--- a/src/subtitle_content.cc
+++ b/src/subtitle_content.cc
@@ -44,7 +44,7 @@ using namespace dcp;
SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf)
: Content (file)
{
- shared_ptr<cxml::Document> xml;
+ cxml::NodePtr xml (new cxml::Node);
if (mxf) {
ASDCP::TimedText::MXFReader reader;
@@ -55,10 +55,7 @@ SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf)
string s;
reader.ReadTimedTextResource (s, 0, 0);
- xml.reset (new cxml::Document ("SubtitleReel"));
- stringstream t;
- t << s;
- xml->read_stream (t);
+ xml = cxml::read_string (s);
ASDCP::WriterInfo info;
reader.FillWriterInfo (info);
@@ -68,8 +65,7 @@ SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf)
_id = buffer;
} else {
- xml.reset (new cxml::Document ("DCSubtitle"));
- xml->read_file (file);
+ xml = cxml::read_file (file);
_id = xml->string_child ("SubtitleID");
}
@@ -88,7 +84,7 @@ SubtitleContent::SubtitleContent (boost::filesystem::path file, bool mxf)
in a sane way.
*/
- shared_ptr<cxml::Node> subtitle_list = xml->optional_node_child ("SubtitleList");
+ cxml::NodePtr subtitle_list = xml->optional_child ("SubtitleList");
if (subtitle_list) {
list<shared_ptr<dcp::Font> > font = type_children<dcp::Font> (subtitle_list, "Font");
copy (font.begin(), font.end(), back_inserter (font_nodes));
@@ -108,7 +104,7 @@ SubtitleContent::SubtitleContent (string movie_title, string language)
void
SubtitleContent::examine_font_nodes (
- shared_ptr<const cxml::Node> xml,
+ cxml::ConstNodePtr xml,
list<shared_ptr<dcp::Font> > const & font_nodes,
ParseState& parse_state
)
@@ -134,7 +130,7 @@ SubtitleContent::examine_font_nodes (
void
SubtitleContent::examine_text_nodes (
- shared_ptr<const cxml::Node> xml,
+ cxml::ConstNodePtr xml,
list<shared_ptr<dcp::Text> > const & text_nodes,
ParseState& parse_state
)
@@ -249,23 +245,23 @@ SubtitleContent::write_xml (boost::filesystem::path p) const
Glib::ustring
SubtitleContent::xml_as_string () const
{
- xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node ("DCSubtitle");
+ cxml::NodePtr root (new cxml::Node);
+ root->set_name ("DCSubtitle");
root->set_attribute ("Version", "1.0");
- root->add_child("SubtitleID")->add_child_text (_id);
+ root->add_child("SubtitleID")->set_content (_id);
if (_movie_title) {
- root->add_child("MovieTitle")->add_child_text (_movie_title.get ());
+ root->add_child("MovieTitle")->set_content (_movie_title.get ());
}
- root->add_child("ReelNumber")->add_child_text (raw_convert<string> (_reel_number));
- root->add_child("Language")->add_child_text (_language);
+ root->add_child("ReelNumber")->set_content (raw_convert<string> (_reel_number));
+ root->add_child("Language")->set_content (_language);
if (_load_font_nodes.size() > 1) {
boost::throw_exception (MiscError ("multiple LoadFont nodes not supported"));
}
if (!_load_font_nodes.empty ()) {
- xmlpp::Element* load_font = root->add_child("LoadFont");
+ cxml::NodePtr load_font = root->add_child("LoadFont");
load_font->set_attribute ("Id", _load_font_nodes.front()->id);
if (_load_font_nodes.front()->uri) {
load_font->set_attribute ("URI", _load_font_nodes.front()->uri.get ());
@@ -289,8 +285,8 @@ SubtitleContent::xml_as_string () const
Time last_fade_up_time;
Time last_fade_down_time;
- xmlpp::Element* font = 0;
- xmlpp::Element* subtitle = 0;
+ cxml::NodePtr font;
+ cxml::NodePtr subtitle;
for (list<SubtitleString>::iterator i = sorted.begin(); i != sorted.end(); ++i) {
@@ -351,13 +347,13 @@ SubtitleContent::xml_as_string () const
last_fade_down_time = i->fade_down_time ();
}
- xmlpp::Element* text = subtitle->add_child ("Text");
+ cxml::NodePtr text = subtitle->add_child ("Text");
text->set_attribute ("VAlign", valign_to_string (i->v_align()));
text->set_attribute ("VPosition", raw_convert<string> (i->v_position()));
- text->add_child_text (i->text());
+ text->set_content (i->text());
}
- return doc.write_to_string_formatted ("UTF-8");
+ return cxml::write_to_string_formatted (root);
}
Time
diff --git a/src/subtitle_content.h b/src/subtitle_content.h
index 945eb4d0..9cf99f90 100644
--- a/src/subtitle_content.h
+++ b/src/subtitle_content.h
@@ -97,13 +97,13 @@ private:
void maybe_add_subtitle (std::string text, ParseState const & parse_state);
void examine_font_nodes (
- boost::shared_ptr<const cxml::Node> xml,
+ cxml::ConstNodePtr xml,
std::list<boost::shared_ptr<Font> > const & font_nodes,
ParseState& parse_state
);
void examine_text_nodes (
- boost::shared_ptr<const cxml::Node> xml,
+ cxml::ConstNodePtr xml,
std::list<boost::shared_ptr<Text> > const & text_nodes,
ParseState& parse_state
);
diff --git a/src/text.cc b/src/text.cc
index 6fbdbe6e..c5e6cb74 100644
--- a/src/text.cc
+++ b/src/text.cc
@@ -35,7 +35,7 @@ using namespace dcp;
* in this object's member variables.
* @param node Node to read.
*/
-Text::Text (boost::shared_ptr<const cxml::Node> node)
+Text::Text (cxml::ConstNodePtr node)
: v_align (CENTER)
{
text = node->content ();
diff --git a/src/text.h b/src/text.h
index 268d146c..d6db064b 100644
--- a/src/text.h
+++ b/src/text.h
@@ -22,13 +22,10 @@
*/
#include "types.h"
+#include <libcxml/cxml.h>
#include <boost/shared_ptr.hpp>
#include <list>
-namespace cxml {
- class Node;
-}
-
namespace dcp {
class Font;
@@ -45,7 +42,7 @@ public:
, v_align (TOP)
{}
- Text (boost::shared_ptr<const cxml::Node> node);
+ Text (cxml::ConstNodePtr node);
float v_position;
VAlign v_align;
diff --git a/src/util.h b/src/util.h
index 857f872f..dc639404 100644
--- a/src/util.h
+++ b/src/util.h
@@ -25,6 +25,7 @@
*/
#include "types.h"
+#include <libcxml/cxml.h>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/filesystem.hpp>
@@ -33,10 +34,6 @@
#include <string>
#include <stdint.h>
-namespace xmlpp {
- class Element;
-}
-
namespace dcp {
class ARGBFrame;
@@ -81,9 +78,9 @@ extern bool ids_equal (std::string a, std::string b);
extern void init ();
-extern void sign (xmlpp::Element* parent, CertificateChain const & certificates, boost::filesystem::path signer_key, Standard standard);
-extern void add_signature_value (xmlpp::Element* parent, CertificateChain const & certificates, boost::filesystem::path signer_key, std::string const & ns);
-extern void add_signer (xmlpp::Element* parent, CertificateChain const & certificates, std::string const & ns);
+extern void sign (cxml::NodePtr parent, CertificateChain const & certificates, boost::filesystem::path signer_key, Standard standard);
+extern void add_signature_value (cxml::NodePtr parent, CertificateChain const & certificates, boost::filesystem::path signer_key, std::string const & ns);
+extern void add_signer (cxml::NodePtr parent, CertificateChain const & certificates, std::string const & ns);
extern int base64_decode (std::string const & in, unsigned char* out, int out_length);
extern boost::optional<boost::filesystem::path> relative_to_root (boost::filesystem::path root, boost::filesystem::path file);
diff --git a/src/xml.h b/src/xml.h
index b89d8ccd..0e8c9c91 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -30,7 +30,7 @@ template <class T>
boost::shared_ptr<T>
optional_type_child (cxml::Node const & node, std::string name)
{
- std::list<boost::shared_ptr<cxml::Node> > n = node.node_children (name);
+ std::list<cxml::NodePtr > n = node.children (name);
if (n.size() > 1) {
throw XMLError ("duplicate XML tag");
} else if (n.empty ()) {
@@ -41,13 +41,13 @@ optional_type_child (cxml::Node const & node, std::string name)
}
template <class T>
-boost::shared_ptr<T> type_child (boost::shared_ptr<const cxml::Node> node, std::string name) {
- return boost::shared_ptr<T> (new T (node->node_child (name)));
+boost::shared_ptr<T> type_child (cxml::ConstNodePtr node, std::string name) {
+ return boost::shared_ptr<T> (new T (node->child (name)));
}
template <class T>
boost::shared_ptr<T>
-optional_type_child (boost::shared_ptr<const cxml::Node> node, std::string name)
+optional_type_child (cxml::ConstNodePtr node, std::string name)
{
return optional_type_child<T> (*node.get(), name);
}
@@ -56,9 +56,9 @@ template <class T>
std::list<boost::shared_ptr<T> >
type_children (cxml::Node const & node, std::string name)
{
- std::list<boost::shared_ptr<cxml::Node> > n = node.node_children (name);
+ std::list<cxml::NodePtr > n = node.children (name);
std::list<boost::shared_ptr<T> > r;
- for (typename std::list<boost::shared_ptr<cxml::Node> >::iterator i = n.begin(); i != n.end(); ++i) {
+ for (typename std::list<cxml::NodePtr >::iterator i = n.begin(); i != n.end(); ++i) {
r.push_back (boost::shared_ptr<T> (new T (*i)));
}
return r;
@@ -66,7 +66,7 @@ type_children (cxml::Node const & node, std::string name)
template <class T>
std::list<boost::shared_ptr<T> >
-type_children (boost::shared_ptr<const cxml::Node> node, std::string name)
+type_children (cxml::ConstNodePtr node, std::string name)
{
return type_children<T> (*node.get(), name);
}
@@ -75,13 +75,13 @@ template <class T>
std::list<boost::shared_ptr<T> >
type_grand_children (cxml::Node const & node, std::string name, std::string sub)
{
- boost::shared_ptr<const cxml::Node> p = node.node_child (name);
+ cxml::ConstNodePtr p = node.child (name);
return type_children<T> (p, sub);
}
template <class T>
std::list<boost::shared_ptr<T> >
-type_grand_children (boost::shared_ptr<const cxml::Node> node, std::string name, std::string sub)
+type_grand_children (cxml::ConstNodePtr node, std::string name, std::string sub)
{
return type_grand_children<T> (*node.get(), name, sub);
}
diff --git a/test/cpl_sar_test.cc b/test/cpl_sar_test.cc
index 59a91c84..ca2e3693 100644
--- a/test/cpl_sar_test.cc
+++ b/test/cpl_sar_test.cc
@@ -39,21 +39,19 @@ BOOST_AUTO_TEST_CASE (cpl_sar)
{
pa->set_screen_aspect_ratio (dcp::Fraction (1998, 1080));
- xmlpp::Document doc;
- xmlpp::Element* el = doc.create_root_node ("Test");
+ cxml::NodePtr el (new cxml::Node);
+ el->set_name ("Test");
pa->write_to_cpl (el, dcp::INTEROP);
- cxml::Node node (el);
- BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), "1.85");
+ BOOST_CHECK_EQUAL (el->child("MainPicture")->string_child ("ScreenAspectRatio"), "1.85");
}
{
pa->set_screen_aspect_ratio (dcp::Fraction (2048, 858));
- xmlpp::Document doc;
- xmlpp::Element* el = doc.create_root_node ("Test");
+ cxml::NodePtr el (new cxml::Node);
+ el->set_name ("Test");
pa->write_to_cpl (el, dcp::INTEROP);
- cxml::Node node (el);
- BOOST_CHECK_EQUAL (node.node_child("MainPicture")->string_child ("ScreenAspectRatio"), "2.39");
+ BOOST_CHECK_EQUAL (el->child("MainPicture")->string_child ("ScreenAspectRatio"), "2.39");
}
}