46 LIBDCP_DISABLE_WARNINGS
47 #include <libxml++/libxml++.h>
48 LIBDCP_ENABLE_WARNINGS
53 using std::shared_ptr;
54 using std::make_shared;
55 using boost::optional;
59 static string const pkl_interop_ns =
"http://www.digicine.com/PROTO-ASDCP-PKL-20040311#";
60 static string const pkl_smpte_ns =
"http://www.smpte-ra.org/schemas/429-8/2007/PKL";
63 PKL::PKL (boost::filesystem::path file)
66 cxml::Document pkl (
"PackingList");
69 if (pkl.namespace_uri() == pkl_interop_ns) {
70 _standard = Standard::INTEROP;
71 }
else if (pkl.namespace_uri() == pkl_smpte_ns) {
72 _standard = Standard::SMPTE;
74 boost::throw_exception (
XMLError (
"Unrecognised packing list namesapce " + pkl.namespace_uri()));
77 _id = remove_urn_uuid (pkl.string_child (
"Id"));
78 _annotation_text = pkl.optional_string_child (
"AnnotationText");
79 _issue_date = pkl.string_child (
"IssueDate");
80 _issuer = pkl.string_child (
"Issuer");
81 _creator = pkl.string_child (
"Creator");
83 for (
auto i: pkl.node_child(
"AssetList")->node_children(
"Asset")) {
84 _asset_list.push_back (make_shared<Asset>(i));
90 PKL::add_asset (std::string
id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type)
92 _asset_list.push_back (make_shared<Asset>(
id, annotation_text, hash, size, type));
97 PKL::write (boost::filesystem::path file, shared_ptr<const CertificateChain> signer)
const
101 if (_standard == Standard::INTEROP) {
102 pkl = doc.create_root_node(
"PackingList", pkl_interop_ns);
104 pkl = doc.create_root_node(
"PackingList", pkl_smpte_ns);
107 pkl->add_child(
"Id")->add_child_text (
"urn:uuid:" + _id);
108 if (_annotation_text) {
109 pkl->add_child(
"AnnotationText")->add_child_text (*_annotation_text);
111 pkl->add_child(
"IssueDate")->add_child_text (_issue_date);
112 pkl->add_child(
"Issuer")->add_child_text (_issuer);
113 pkl->add_child(
"Creator")->add_child_text (_creator);
115 auto asset_list = pkl->add_child(
"AssetList");
116 for (
auto i: _asset_list) {
117 auto asset = asset_list->add_child(
"Asset");
118 asset->add_child(
"Id")->add_child_text (
"urn:uuid:" + i->id());
119 if (i->annotation_text()) {
120 asset->add_child(
"AnnotationText")->add_child_text (*i->annotation_text());
122 asset->add_child(
"Hash")->add_child_text (i->hash());
123 asset->add_child(
"Size")->add_child_text (raw_convert<string>(i->size()));
124 asset->add_child(
"Type")->add_child_text (i->type());
130 signer->sign (pkl, _standard);
133 doc.write_to_file_formatted (
file.string(),
"UTF-8");
139 PKL::hash (
string id)
const
141 for (
auto i: _asset_list) {
152 PKL::type (
string id)
const
154 for (
auto i: _asset_list) {
boost::optional< boost::filesystem::path > file() const
boost::optional< boost::filesystem::path > _file
Exceptions thrown by libdcp.
Namespace for everything in libdcp.
Methods for conversion to/from string.
Utility methods and classes.