diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-11 22:24:44 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-12 01:22:10 +0200 |
| commit | 498806d76160a6b1fa0af58e7734c0f553abf12b (patch) | |
| tree | c5898dca2e84901ea003decb1f3671226d8e53c9 /src | |
| parent | 7d66bda50ade8ea618f331b885f1bfa4fa0a2af9 (diff) | |
Specify CPL standard on construction.
Then choose which standard DCP should use based on the CPL(s).
Diffstat (limited to 'src')
| -rw-r--r-- | src/combine.cc | 2 | ||||
| -rw-r--r-- | src/cpl.cc | 15 | ||||
| -rw-r--r-- | src/cpl.h | 8 | ||||
| -rw-r--r-- | src/dcp.cc | 20 | ||||
| -rw-r--r-- | src/dcp.h | 1 |
5 files changed, 29 insertions, 17 deletions
diff --git a/src/combine.cc b/src/combine.cc index da893cb7..e974c407 100644 --- a/src/combine.cc +++ b/src/combine.cc @@ -173,5 +173,5 @@ dcp::combine ( } } - output_dcp.write_xml (*standard, issuer, creator, issue_date, annotation_text, signer); + output_dcp.write_xml (issuer, creator, issue_date, annotation_text, signer); } @@ -80,7 +80,7 @@ static string const smpte_395_ns = "http://www.smpte-ra.org/reg/395/2014/13/1/aa static string const smpte_335_ns = "http://www.smpte-ra.org/reg/335/2012"; -CPL::CPL (string annotation_text, ContentKind content_kind) +CPL::CPL (string annotation_text, ContentKind content_kind, Standard standard) /* default _content_title_text to annotation_text */ : _issuer ("libdcp" LIBDCP_VERSION) , _creator ("libdcp" LIBDCP_VERSION) @@ -88,6 +88,7 @@ CPL::CPL (string annotation_text, ContentKind content_kind) , _annotation_text (annotation_text) , _content_title_text (annotation_text) , _content_kind (content_kind) + , _standard (standard) { ContentVersion cv; cv.label_text = cv.id + LocalTime().as_string(); @@ -139,7 +140,7 @@ CPL::CPL (boost::filesystem::path file) } for (auto i: f.node_child("ReelList")->node_children("Reel")) { - _reels.push_back (make_shared<Reel>(i, *_standard)); + _reels.push_back (make_shared<Reel>(i, _standard)); } auto reel_list = f.node_child ("ReelList"); @@ -170,11 +171,11 @@ CPL::add (std::shared_ptr<Reel> reel) void -CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<const CertificateChain> signer) const +CPL::write_xml (boost::filesystem::path file, shared_ptr<const CertificateChain> signer) const { xmlpp::Document doc; xmlpp::Element* root; - if (standard == Standard::INTEROP) { + if (_standard == Standard::INTEROP) { root = doc.create_root_node ("CompositionPlaylist", cpl_interop_ns); } else { root = doc.create_root_node ("CompositionPlaylist", cpl_smpte_ns); @@ -209,8 +210,8 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons bool first = true; for (auto i: _reels) { - auto asset_list = i->write_to_cpl (reel_list, standard); - if (first && standard == Standard::SMPTE) { + auto asset_list = i->write_to_cpl (reel_list, _standard); + if (first && _standard == Standard::SMPTE) { maybe_write_composition_metadata_asset (asset_list); first = false; } @@ -219,7 +220,7 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons indent (root, 0); if (signer) { - signer->sign (root, standard); + signer->sign (root, _standard); } doc.write_to_file_formatted (file.string(), "UTF-8"); @@ -73,7 +73,7 @@ class DecryptedKDM; class CPL : public Asset { public: - CPL (std::string annotation_text, ContentKind content_kind); + CPL (std::string annotation_text, ContentKind content_kind, Standard standard); /** Construct a CPL object from a XML file */ explicit CPL (boost::filesystem::path file); @@ -117,12 +117,10 @@ public: /** Write an CompositonPlaylist XML file * * @param file Filename to write - * @param standard INTEROP or SMPTE * @param signer Signer to sign the CPL, or 0 to add no signature */ void write_xml ( boost::filesystem::path file, - Standard standard, std::shared_ptr<const CertificateChain> ) const; @@ -306,7 +304,7 @@ public: void set_additional_subtitle_languages (std::vector<dcp::LanguageTag> const& lang); - boost::optional<Standard> standard () const { + Standard standard () const { return _standard; } @@ -354,7 +352,7 @@ private: std::vector<std::shared_ptr<Reel>> _reels; /** Standard of CPL that was read in */ - boost::optional<Standard> _standard; + Standard _standard; }; @@ -67,6 +67,7 @@ #include <libxml++/libxml++.h> #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> +#include <numeric> using std::string; @@ -229,7 +230,7 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m if (root == "CompositionPlaylist") { auto cpl = make_shared<CPL>(path); - if (_standard && cpl->standard() && cpl->standard().get() != _standard.get() && notes) { + if (_standard && cpl->standard() != _standard.get() && notes) { notes->push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::MISMATCHED_STANDARD}); } _cpls.push_back (cpl); @@ -469,7 +470,6 @@ DCP::write_assetmap ( void DCP::write_xml ( - Standard standard, string issuer, string creator, string issue_date, @@ -478,10 +478,24 @@ DCP::write_xml ( NameFormat name_format ) { + if (_cpls.empty()) { + throw MiscError ("Cannot write DCP with no CPLs."); + } + + auto standard = std::accumulate ( + std::next(_cpls.begin()), _cpls.end(), _cpls[0]->standard(), + [](Standard s, shared_ptr<CPL> c) { + if (s != c->standard()) { + throw MiscError ("Cannot make DCP with mixed Interop and SMPTE CPLs."); + } + return s; + } + ); + for (auto i: cpls()) { NameFormat::Map values; values['t'] = "cpl"; - i->write_xml (_directory / (name_format.get(values, "_" + i->id() + ".xml")), standard, signer); + i->write_xml (_directory / (name_format.get(values, "_" + i->id() + ".xml")), signer); } shared_ptr<PKL> pkl; @@ -151,7 +151,6 @@ public: * @param name_format Name format to use for the CPL and PKL filenames */ void write_xml ( - Standard standard, 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(), |
