diff options
| -rw-r--r-- | src/dcp.cc | 10 | ||||
| -rw-r--r-- | src/dcp.h | 3 | ||||
| -rw-r--r-- | src/pkl.cc | 4 | ||||
| -rw-r--r-- | src/pkl.h | 15 | ||||
| -rw-r--r-- | src/util.cc | 11 | ||||
| -rw-r--r-- | src/util.h | 1 |
6 files changed, 40 insertions, 4 deletions
@@ -449,7 +449,12 @@ DCP::write_volindex (Standard standard) const void -DCP::write_xml(shared_ptr<const CertificateChain> signer, bool include_mca_subdescriptors, NameFormat name_format) +DCP::write_xml( + shared_ptr<const CertificateChain> signer, + bool include_mca_subdescriptors, + NameFormat name_format, + optional<string> group_id + ) { if (_cpls.empty()) { throw MiscError ("Cannot write DCP with no CPLs."); @@ -478,7 +483,8 @@ DCP::write_xml(shared_ptr<const CertificateChain> signer, bool include_mca_subde _new_annotation_text.get_value_or(String::compose("Created by libdcp %1", dcp::version)), _new_issue_date.get_value_or(LocalTime().as_string()), _new_issuer.get_value_or(String::compose("libdcp %1", dcp::version)), - _new_creator.get_value_or(String::compose("libdcp %1", dcp::version)) + _new_creator.get_value_or(String::compose("libdcp %1", dcp::version)), + group_id ) ); } @@ -157,7 +157,8 @@ public: void write_xml( std::shared_ptr<const CertificateChain> signer = std::shared_ptr<const CertificateChain>(), bool include_mca_subdescriptors = true, - NameFormat name_format = NameFormat("%t") + NameFormat name_format = NameFormat("%t"), + boost::optional<std::string> group_id = boost::none ); void resolve_refs (std::vector<std::shared_ptr<Asset>> assets); @@ -97,6 +97,7 @@ PKL::PKL(boost::filesystem::path file, vector<dcp::VerificationNote>* notes) _issue_date = pkl.string_child ("IssueDate"); _issuer = pkl.string_child ("Issuer"); _creator = pkl.string_child ("Creator"); + _group_id = remove_urn_uuid(pkl.optional_string_child("GroupId")); for (auto i: pkl.node_child("AssetList")->node_children("Asset")) { _assets.push_back(make_shared<Asset>(i)); @@ -129,6 +130,9 @@ PKL::write_xml (boost::filesystem::path file, shared_ptr<const CertificateChain> cxml::add_text_child(pkl, "IssueDate", _issue_date); cxml::add_text_child(pkl, "Issuer", _issuer); cxml::add_text_child(pkl, "Creator", _creator); + if (_group_id) { + cxml::add_text_child(pkl, "GroupId", "urn:uuid:" + *_group_id); + } auto asset_list = cxml::add_child(pkl, "AssetList"); for (auto i: _assets) { @@ -58,8 +58,16 @@ class VerificationNote; class PKL : public Object, public AssetList { public: - PKL (Standard standard, boost::optional<std::string> annotation_text, std::string issue_date, std::string issuer, std::string creator) + PKL( + Standard standard, + boost::optional<std::string> annotation_text, + std::string issue_date, + std::string issuer, + std::string creator, + boost::optional<std::string> group_id = boost::none + ) : AssetList(standard, annotation_text, issue_date, issuer, creator) + , _group_id(group_id) {} explicit PKL(boost::filesystem::path file, std::vector<dcp::VerificationNote>* notes = nullptr); @@ -129,8 +137,13 @@ public: return _assets; } + boost::optional<std::string> group_id() const { + return _group_id; + } + private: std::vector<std::shared_ptr<Asset>> _assets; + boost::optional<std::string> _group_id; /** The most recent disk file used to read or write this PKL */ mutable boost::optional<boost::filesystem::path> _file; }; diff --git a/src/util.cc b/src/util.cc index 01bc8dea..5f19d323 100644 --- a/src/util.cc +++ b/src/util.cc @@ -317,6 +317,17 @@ dcp::remove_urn_uuid (string raw) } +optional<string> +dcp::remove_urn_uuid(optional<string> raw) +{ + if (!raw) { + return {}; + } + + return remove_urn_uuid(*raw); +} + + string dcp::openjpeg_version () { @@ -95,6 +95,7 @@ extern std::string make_digest (ArrayData data); extern bool ids_equal (std::string a, std::string b); extern std::string remove_urn_uuid (std::string raw); +extern boost::optional<std::string> remove_urn_uuid(boost::optional<std::string> raw); /** Set up various bits that the library needs. Should be called once * by client applications. |
