diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-04-25 23:31:13 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-04-25 23:31:13 +0200 |
| commit | ef9671811920cbef50f0f01d063eab418de8925e (patch) | |
| tree | 0161463370f4a995f5e1b275b642de534b68f6d4 /src | |
| parent | 98227f0ca88034061092cd2a179c5cade2924f50 (diff) | |
Tidy up write_xml() API a little.
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset_map.h | 16 | ||||
| -rw-r--r-- | src/combine.cc | 7 | ||||
| -rw-r--r-- | src/dcp.cc | 80 | ||||
| -rw-r--r-- | src/dcp.h | 21 | ||||
| -rw-r--r-- | src/pkl.h | 16 |
5 files changed, 120 insertions, 20 deletions
diff --git a/src/asset_map.h b/src/asset_map.h index d135380f..cf91a95b 100644 --- a/src/asset_map.h +++ b/src/asset_map.h @@ -69,6 +69,22 @@ public: return _standard; } + void set_annotation_text(std::string annotation_text) { + _annotation_text = annotation_text; + } + + void set_issue_date(std::string issue_date) { + _issue_date = issue_date; + } + + void set_issuer(std::string issuer) { + _issuer = issuer; + } + + void set_creator(std::string creator) { + _creator = creator; + } + void clear_assets(); void add_asset(std::string id, boost::filesystem::path path, bool pkl); diff --git a/src/combine.cc b/src/combine.cc index e974c407..05ad519e 100644 --- a/src/combine.cc +++ b/src/combine.cc @@ -173,5 +173,10 @@ dcp::combine ( } } - output_dcp.write_xml (issuer, creator, issue_date, annotation_text, signer); + output_dcp.set_issuer(issuer); + output_dcp.set_creator(creator); + output_dcp.set_issue_date(issue_date); + output_dcp.set_annotation_text(annotation_text); + + output_dcp.write_xml(signer); } @@ -371,14 +371,7 @@ DCP::write_volindex (Standard standard) const void -DCP::write_xml ( - string issuer, - string creator, - string issue_date, - string annotation_text, - shared_ptr<const CertificateChain> signer, - NameFormat name_format - ) +DCP::write_xml (shared_ptr<const CertificateChain> signer, NameFormat name_format) { if (_cpls.empty()) { throw MiscError ("Cannot write DCP with no CPLs."); @@ -401,7 +394,15 @@ DCP::write_xml ( } if (_pkls.empty()) { - _pkls.push_back(make_shared<PKL>(standard, annotation_text, issue_date, issuer, creator)); + _pkls.push_back( + make_shared<PKL>( + standard, + _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)) + ) + ); } auto pkl = _pkls.front(); @@ -418,7 +419,13 @@ DCP::write_xml ( pkl->write (pkl_path, signer); if (!_asset_map) { - _asset_map = AssetMap(standard, annotation_text, issue_date, issuer, creator); + _asset_map = AssetMap( + standard, + _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)) + ); } /* The assets may have changed since we read the asset map, so re-add them */ @@ -490,3 +497,56 @@ DCP::directories_from_files (vector<boost::filesystem::path> files) } return d; } + + +void +DCP::set_issuer(string issuer) +{ + for (auto pkl: _pkls) { + pkl->set_issuer(issuer); + } + if (_asset_map) { + _asset_map->set_issuer(issuer); + } + _new_issuer = issuer; +} + + +void +DCP::set_creator(string creator) +{ + for (auto pkl: _pkls) { + pkl->set_creator(creator); + } + if (_asset_map) { + _asset_map->set_creator(creator); + } + _new_creator = creator; +} + + +void +DCP::set_issue_date(string issue_date) +{ + for (auto pkl: _pkls) { + pkl->set_issue_date(issue_date); + } + if (_asset_map) { + _asset_map->set_issue_date(issue_date); + } + _new_issue_date = issue_date; +} + + +void +DCP::set_annotation_text(string annotation_text) +{ + for (auto pkl: _pkls) { + pkl->set_annotation_text(annotation_text); + } + if (_asset_map) { + _asset_map->set_annotation_text(annotation_text); + } + _new_annotation_text = annotation_text; +} + @@ -142,20 +142,17 @@ public: */ void add (DecryptedKDM const &); - /** Write all the XML files for this DCP + void set_issuer(std::string issuer); + void set_creator(std::string creator); + void set_issue_date(std::string issue_date); + void set_annotation_text(std::string annotation_text); + + /** Write all the XML files for this DCP. * @param standand INTEROP or SMPTE - * @param issuer Value for the PKL and AssetMap <Issuer> tags - * @param creator Value for the PKL and AssetMap <Creator> tags - * @param issue_date Value for the PKL and AssetMap <IssueDate> tags - * @param annotation_text Value for the PKL and AssetMap <AnnotationText> tags * @param signer Signer to use * @param name_format Name format to use for the CPL and PKL filenames */ void write_xml ( - std::string issuer = String::compose("libdcp %1", dcp::version), - std::string creator = String::compose("libdcp %1", dcp::version), - std::string issue_date = LocalTime().as_string(), - std::string annotation_text = String::compose("Created by libdcp %1", dcp::version), std::shared_ptr<const CertificateChain> signer = std::shared_ptr<const CertificateChain>(), NameFormat name_format = NameFormat("%t") ); @@ -203,6 +200,12 @@ private: /** The PKLs that make up this DCP */ std::vector<std::shared_ptr<PKL>> _pkls; boost::optional<AssetMap> _asset_map; + + /* Metadata to use for newly created PKLs and AssetMaps */ + boost::optional<std::string> _new_issuer; + boost::optional<std::string> _new_creator; + boost::optional<std::string> _new_issue_date; + boost::optional<std::string> _new_annotation_text; }; @@ -73,6 +73,22 @@ public: return _annotation_text; } + void set_annotation_text(std::string annotation_text) { + _annotation_text = annotation_text; + } + + void set_issue_date(std::string issue_date) { + _issue_date = issue_date; + } + + void set_issuer(std::string issuer) { + _issuer = issuer; + } + + void set_creator(std::string creator) { + _creator = creator; + } + boost::optional<std::string> hash (std::string id) const; boost::optional<std::string> type (std::string id) const; |
