diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-11-23 13:58:33 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-11-23 13:58:33 +0100 |
| commit | a332bd6be323f03dad5b180fb237afe54f1bf81e (patch) | |
| tree | 70cf0da21c95941cda478717b15ea71aca4c0bdb /src/lib | |
| parent | 1c11eaf92c5d592be6df07e2ac77cfcf65e3ed0c (diff) | |
Remove swaroop variant.
Diffstat (limited to 'src/lib')
35 files changed, 15 insertions, 1557 deletions
diff --git a/src/lib/checker.cc b/src/lib/checker.cc deleted file mode 100644 index b96b965aa..000000000 --- a/src/lib/checker.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifdef DCPOMATIC_VARIANT_SWAROOP - -#include "checker.h" -#include "config.h" -#include "cross.h" - -using boost::bind; -using boost::ref; - -Checker::Checker (int period) - : _terminate (false) - , _ok (true) - , _period (period) -{ - -} - -void -Checker::run () -{ - _thread = boost::thread (boost::bind(&Checker::thread, this)); -} - -Checker::~Checker () -{ - boost::this_thread::disable_interruption dis; - - { - boost::mutex::scoped_lock lm (_mutex); - _terminate = true; - } - - _thread.interrupt (); - try { - _thread.join (); - } catch (...) {} -} - -void -Checker::thread () -{ - while (true) { - boost::mutex::scoped_lock lm (_mutex); - if (_terminate) { - break; - } - - bool const was_ok = _ok; - _ok = check(); - if (was_ok != _ok) { - emit (bind(boost::ref(StateChanged))); - } - - lm.unlock (); - dcpomatic_sleep_seconds (_period); - } -} - -bool -Checker::ok () const -{ - boost::mutex::scoped_lock lm (_mutex); - return _ok; -} - -#endif diff --git a/src/lib/checker.h b/src/lib/checker.h deleted file mode 100644 index 8b80d8527..000000000 --- a/src/lib/checker.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -/** @file src/lib/checker.h - * @brief Checker class. - */ - -#ifndef DCPOMATIC_CHECKER_H -#define DCPOMATIC_CHECKER_H - -#include "signaller.h" -#include <boost/signals2.hpp> - -/** Parent for classes which check some condition every so often and signal - * when the state of the condition changes. - */ -class Checker : public Signaller, public boost::noncopyable -{ -public: - virtual ~Checker (); - - void run (); - - bool ok () const; - - /** Emitted when the state of our condition changes */ - boost::signals2::signal<void (void)> StateChanged; - -protected: - - Checker (int period); - - /** @return true if the condition is `ok', otherwise false */ - virtual bool check () const = 0; - -private: - - void thread (); - - boost::thread _thread; - mutable boost::mutex _mutex; - bool _terminate; - bool _ok; - /** check period in seconds */ - int _period; -}; - -#endif diff --git a/src/lib/config.cc b/src/lib/config.cc index 8b849dcc1..7c126ff19 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -175,16 +175,6 @@ Config::set_defaults () _player_playlist_directory = boost::none; _player_kdm_directory = boost::none; _audio_mapping = boost::none; -#ifdef DCPOMATIC_VARIANT_SWAROOP - _player_background_image = boost::none; - _kdm_server_url = "http://localhost:8000/{CPL}"; - _player_watermark_theatre = ""; - _player_watermark_period = 1; - _player_watermark_duration = 50; - _player_lock_file = boost::none; - _signer_chain_path = "signer"; - _decryption_chain_path = "decryption"; -#endif _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -241,14 +231,6 @@ void Config::read () try { -#if defined(DCPOMATIC_VARIANT_SWAROOP) && defined(DCPOMATIC_LINUX) - if (geteuid() == 0) { - /* Take ownership of the config file if we're root */ - chown (config_file().string().c_str(), 0, 0); - chmod (config_file().string().c_str(), 0644); - } -#endif - cxml::Document f ("Config"); f.read_file (config_file ()); @@ -411,21 +393,6 @@ try } cxml::NodePtr signer = f.optional_node_child ("Signer"); -#ifdef DCPOMATIC_VARIANT_SWAROOP - if (signer && signer->node_children().size() == 1) { - /* The content of <Signer> is a path to a file; if it's relative it's in the same - directory as .config. */ - _signer_chain_path = signer->content(); - if (_signer_chain_path.is_relative()) { - _signer_chain = read_swaroop_chain (path(_signer_chain_path.string())); - } else { - _signer_chain = read_swaroop_chain (_signer_chain_path); - } - } else { - /* <Signer> is not present or has children: ignore it and remake. */ - _signer_chain = create_certificate_chain (); - } -#else if (signer) { shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ()); /* Read the signing certificates and private key in from the config file */ @@ -438,24 +405,8 @@ try /* Make a new set of signing certificates and key */ _signer_chain = create_certificate_chain (); } -#endif cxml::NodePtr decryption = f.optional_node_child ("Decryption"); -#ifdef DCPOMATIC_VARIANT_SWAROOP - if (decryption && decryption->node_children().size() == 1) { - /* The content of <Decryption> is a path to a file; if it's relative, it's in the same - directory as .config. */ - _decryption_chain_path = decryption->content(); - if (_decryption_chain_path.is_relative()) { - _decryption_chain = read_swaroop_chain (path(_decryption_chain_path.string())); - } else { - _decryption_chain = read_swaroop_chain (_decryption_chain_path); - } - } else { - /* <Decryption> is not present or has more children: ignore it and remake. */ - _decryption_chain = create_certificate_chain (); - } -#else if (decryption) { shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ()); BOOST_FOREACH (cxml::NodePtr i, decryption->node_children ("Certificate")) { @@ -466,7 +417,6 @@ try } else { _decryption_chain = create_certificate_chain (); } -#endif /* These must be done before we call Bad as that might set one of the nags. @@ -601,18 +551,6 @@ try _audio_mapping = AudioMapping (f.node_child("AudioMapping"), Film::current_state_version); } -#ifdef DCPOMATIC_VARIANT_SWAROOP - _player_background_image = f.optional_string_child("PlayerBackgroundImage"); - _kdm_server_url = f.optional_string_child("KDMServerURL").get_value_or("http://localhost:8000/{CPL}"); - _player_watermark_theatre = f.optional_string_child("PlayerWatermarkTheatre").get_value_or(""); - _player_watermark_period = f.optional_number_child<int>("PlayerWatermarkPeriod").get_value_or(1); - _player_watermark_duration = f.optional_number_child<int>("PlayerWatermarkDuration").get_value_or(150); - BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("RequiredMonitor")) { - _required_monitors.push_back(Monitor(i)); - } - _player_lock_file = f.optional_string_child("PlayerLockFile"); -#endif - if (boost::filesystem::exists (_cinemas_file)) { cxml::Document f ("Cinemas"); f.read_file (_cinemas_file); @@ -838,14 +776,6 @@ Config::write_config () const root->add_child("Win32Console")->add_child_text (_win32_console ? "1" : "0"); #endif -#ifdef DCPOMATIC_VARIANT_SWAROOP - if (_signer_chain_path.is_relative()) { - write_swaroop_chain (_signer_chain, path(_signer_chain_path.string())); - } else { - write_swaroop_chain (_signer_chain, _signer_chain_path); - } - root->add_child("Signer")->add_child_text(_signer_chain_path.string()); -#else /* [XML] Signer Certificate chain and private key to use when signing DCPs and KDMs. Should contain <code><Certificate></code> tags in order and a <code><PrivateKey></code> tag all containing PEM-encoded certificates or private keys as appropriate. */ @@ -855,16 +785,7 @@ Config::write_config () const signer->add_child("Certificate")->add_child_text (i.certificate (true)); } signer->add_child("PrivateKey")->add_child_text (_signer_chain->key().get ()); -#endif -#ifdef DCPOMATIC_VARIANT_SWAROOP - if (_decryption_chain_path.is_relative()) { - write_swaroop_chain (_decryption_chain, path(_decryption_chain_path.string())); - } else { - write_swaroop_chain (_decryption_chain, _decryption_chain_path); - } - root->add_child("Decryption")->add_child_text(_decryption_chain_path.string()); -#else /* [XML] Decryption Certificate chain and private key to use when decrypting KDMs */ xmlpp::Element* decryption = root->add_child ("Decryption"); DCPOMATIC_ASSERT (_decryption_chain); @@ -872,7 +793,6 @@ Config::write_config () const decryption->add_child("Certificate")->add_child_text (i.certificate (true)); } decryption->add_child("PrivateKey")->add_child_text (_decryption_chain->key().get ()); -#endif /* [XML] History Filename of DCP to present in the <guilabel>File</guilabel> menu of the GUI; there can be more than one of these tags. @@ -1053,21 +973,6 @@ Config::write_config () const if (_audio_mapping) { _audio_mapping->as_xml (root->add_child("AudioMapping")); } -#ifdef DCPOMATIC_VARIANT_SWAROOP - if (_player_background_image) { - root->add_child("PlayerBackgroundImage")->add_child_text(_player_background_image->string()); - } - root->add_child("KDMServerURL")->add_child_text(_kdm_server_url); - root->add_child("PlayerWatermarkTheatre")->add_child_text(_player_watermark_theatre); - root->add_child("PlayerWatermarkPeriod")->add_child_text(raw_convert<string>(_player_watermark_period)); - root->add_child("PlayerWatermarkDuration")->add_child_text(raw_convert<string>(_player_watermark_duration)); - BOOST_FOREACH (Monitor i, _required_monitors) { - i.as_xml(root->add_child("RequiredMonitor")); - } - if (_player_lock_file) { - root->add_child("PlayerLockFile")->add_child_text(_player_lock_file->string()); - } -#endif try { string const s = doc.write_to_string_formatted (); diff --git a/src/lib/config.h b/src/lib/config.h index 11ca36b85..87afcbba8 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -86,9 +86,6 @@ public: HISTORY, SHOW_EXPERIMENTAL_AUDIO_PROCESSORS, AUDIO_MAPPING, -#ifdef DCPOMATIC_VARIANT_SWAROOP - PLAYER_BACKGROUND_IMAGE, -#endif OTHER }; @@ -540,36 +537,6 @@ public: AudioMapping audio_mapping (int output_channels); -#ifdef DCPOMATIC_VARIANT_SWAROOP - boost::optional<boost::filesystem::path> player_background_image () const { - return _player_background_image; - } - - std::string kdm_server_url () const { - return _kdm_server_url; - } - - std::string player_watermark_theatre () const { - return _player_watermark_theatre; - } - - int player_watermark_period () const { - return _player_watermark_period; - } - - int player_watermark_duration () const { - return _player_watermark_duration; - } - - std::vector<Monitor> required_monitors () const { - return _required_monitors; - } - - boost::optional<boost::filesystem::path> player_lock_file () const { - return _player_lock_file; - } -#endif - /* SET (mostly) */ void set_master_encoding_threads (int n) { @@ -1081,52 +1048,6 @@ public: void set_audio_mapping (AudioMapping m); void set_audio_mapping_to_default (); -#ifdef DCPOMATIC_VARIANT_SWAROOP - void set_player_background_image (boost::filesystem::path p) { - maybe_set (_player_background_image, p, PLAYER_BACKGROUND_IMAGE); - } - - void unset_player_background_image () { - if (!_player_background_image) { - return; - } - _player_background_image = boost::none; - changed (PLAYER_BACKGROUND_IMAGE); - } - - void set_kdm_server_url (std::string s) { - maybe_set (_kdm_server_url, s); - } - - void set_player_watermark_theatre (std::string p) { - maybe_set (_player_watermark_theatre, p); - } - - void set_player_watermark_period (int minutes) { - maybe_set (_player_watermark_period, minutes); - } - - void set_player_watermark_duration (int milliseconds) { - maybe_set (_player_watermark_duration, milliseconds); - } - - void set_required_monitors (std::vector<Monitor> monitors) { - maybe_set (_required_monitors, monitors); - } - - void set_player_lock_file (boost::filesystem::path p) { - maybe_set (_player_lock_file, p); - } - - void unset_player_lock_file () { - if (!_player_lock_file) { - return; - } - _player_lock_file = boost::none; - changed (); - } -#endif - void changed (Property p = OTHER); boost::signals2::signal<void (Property)> Changed; /** Emitted if read() failed on an existing Config file. There is nothing @@ -1276,16 +1197,10 @@ private: std::string _notification_bcc; std::string _notification_email; boost::shared_ptr<const dcp::CertificateChain> _signer_chain; -#ifdef DCPOMATIC_VARIANT_SWAROOP - boost::filesystem::path _signer_chain_path; -#endif /** Chain used to decrypt KDMs; the leaf of this chain is the target * certificate for making KDMs given to DCP-o-matic. */ boost::shared_ptr<const dcp::CertificateChain> _decryption_chain; -#ifdef DCPOMATIC_VARIANT_SWAROOP - boost::filesystem::path _decryption_chain_path; -#endif /** true to check for updates on startup */ bool _check_for_updates; bool _check_for_test_updates; @@ -1346,18 +1261,6 @@ private: boost::optional<boost::filesystem::path> _player_playlist_directory; boost::optional<boost::filesystem::path> _player_kdm_directory; boost::optional<AudioMapping> _audio_mapping; -#ifdef DCPOMATIC_VARIANT_SWAROOP - boost::optional<boost::filesystem::path> _player_background_image; - std::string _kdm_server_url; - std::string _player_watermark_theatre; - /** watermark period in minutes */ - int _player_watermark_period; - /** watermark duration in milliseconds */ - int _player_watermark_duration; - std::vector<Monitor> _required_monitors; - /** a file which, if specified, must be present for the player to work */ - boost::optional<boost::filesystem::path> _player_lock_file; -#endif static int const _current_version; diff --git a/src/lib/decrypted_ecinema_kdm.cc b/src/lib/decrypted_ecinema_kdm.cc deleted file mode 100644 index f76161c8b..000000000 --- a/src/lib/decrypted_ecinema_kdm.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2019 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifdef DCPOMATIC_VARIANT_SWAROOP - -#include "encrypted_ecinema_kdm.h" -#include "decrypted_ecinema_kdm.h" -#include "ecinema_kdm_data.h" -#include "exceptions.h" -#include "compose.hpp" -#include <dcp/key.h> -#include <dcp/util.h> -#include <dcp/certificate.h> -#include <openssl/rsa.h> -#include <openssl/pem.h> -#include <openssl/err.h> - -using std::string; -using std::runtime_error; -using dcp::Certificate; -using boost::optional; - -DecryptedECinemaKDM::DecryptedECinemaKDM (string id, string name, dcp::Key content_key, optional<dcp::LocalTime> not_valid_before, optional<dcp::LocalTime> not_valid_after) - : _id (id) - , _name (name) - , _content_key (content_key) - , _not_valid_before (not_valid_before) - , _not_valid_after (not_valid_after) -{ - -} - -DecryptedECinemaKDM::DecryptedECinemaKDM (EncryptedECinemaKDM kdm, string private_key) - : _id (kdm.id()) - , _name (kdm.name()) -{ - /* Read the private key */ - - BIO* bio = BIO_new_mem_buf (const_cast<char *> (private_key.c_str()), -1); - if (!bio) { - throw runtime_error ("could not create memory BIO"); - } - - RSA* rsa = PEM_read_bio_RSAPrivateKey (bio, 0, 0, 0); - if (!rsa) { - throw FileError ("could not read RSA private key file", private_key); - } - - uint8_t value[RSA_size(rsa)]; - int const len = RSA_private_decrypt (kdm.data().size(), kdm.data().data().get(), value, rsa, RSA_PKCS1_OAEP_PADDING); - if (len == -1) { - throw KDMError (ERR_error_string(ERR_get_error(), 0), ""); - } - - if (len != ECINEMA_KDM_KEY_LENGTH && len != (ECINEMA_KDM_KEY_LENGTH + ECINEMA_KDM_NOT_VALID_BEFORE_LENGTH + ECINEMA_KDM_NOT_VALID_AFTER_LENGTH)) { - throw KDMError ( - "Unexpected data block size in ECinema KDM.", - String::compose("Size was %1; expected %2 or %3", ECINEMA_KDM_KEY_LENGTH, ECINEMA_KDM_KEY_LENGTH + ECINEMA_KDM_NOT_VALID_BEFORE_LENGTH + ECINEMA_KDM_NOT_VALID_AFTER_LENGTH) - ); - } - - _content_key = dcp::Key (value + ECINEMA_KDM_KEY, ECINEMA_KDM_KEY_LENGTH); - if (len > ECINEMA_KDM_KEY_LENGTH) { - uint8_t* p = value + ECINEMA_KDM_NOT_VALID_BEFORE; - string b; - for (int i = 0; i < ECINEMA_KDM_NOT_VALID_BEFORE_LENGTH; ++i) { - b += *p++; - } - _not_valid_before = dcp::LocalTime (b); - string a; - for (int i = 0; i < ECINEMA_KDM_NOT_VALID_AFTER_LENGTH; ++i) { - a += *p++; - } - _not_valid_after = dcp::LocalTime (a); - } -} - -EncryptedECinemaKDM -DecryptedECinemaKDM::encrypt (Certificate recipient) -{ - return EncryptedECinemaKDM (_id, _name, _content_key, _not_valid_before, _not_valid_after, recipient); -} - -#endif diff --git a/src/lib/decrypted_ecinema_kdm.h b/src/lib/decrypted_ecinema_kdm.h deleted file mode 100644 index 7a66b63e0..000000000 --- a/src/lib/decrypted_ecinema_kdm.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (C) 2019 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifdef DCPOMATIC_VARIANT_SWAROOP - -#include "encrypted_ecinema_kdm.h" -#include <dcp/key.h> -#include <dcp/data.h> -#include <dcp/certificate.h> - -class DecryptedECinemaKDM -{ -public: - DecryptedECinemaKDM (std::string id, std::string name, dcp::Key content_key, boost::optional<dcp::LocalTime> not_valid_before, boost::optional<dcp::LocalTime> not_valid_after); - DecryptedECinemaKDM (EncryptedECinemaKDM kdm, std::string private_key); - - EncryptedECinemaKDM encrypt (dcp::Certificate recipient); - - std::string id () const { - return _id; - } - - std::string name () const { - return _name; - } - - dcp::Key key () const { - return _content_key; - } - - boost::optional<dcp::LocalTime> not_valid_before () const { - return _not_valid_before; - } - - boost::optional<dcp::LocalTime> not_valid_after () const { - return _not_valid_after; - } - -private: - std::string _id; - std::string _name; - /** unenecrypted content key */ - dcp::Key _content_key; - boost::optional<dcp::LocalTime> _not_valid_before; - boost::optional<dcp::LocalTime> _not_valid_after; -}; - -#endif diff --git a/src/lib/dkdm_recipient.cc b/src/lib/dkdm_recipient.cc index f03a1597b..b9db06152 100644 --- a/src/lib/dkdm_recipient.cc +++ b/src/lib/dkdm_recipient.cc @@ -90,6 +90,6 @@ kdm_for_dkdm_recipient ( name_values['e'] = end.date() + " " + end.time_of_day(true, false); name_values['i'] = kdm.cpl_id(); - return KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, 0, recipient->emails, kdm)); + return KDMWithMetadataPtr(new KDMWithMetadata(name_values, 0, recipient->emails, kdm)); } diff --git a/src/lib/dkdm_wrapper.cc b/src/lib/dkdm_wrapper.cc index 6638bc315..23539bd94 100644 --- a/src/lib/dkdm_wrapper.cc +++ b/src/lib/dkdm_wrapper.cc @@ -37,10 +37,6 @@ DKDMBase::read (cxml::ConstNodePtr node) { if (node->name() == "DKDM") { return shared_ptr<DKDM> (new DKDM (dcp::EncryptedKDM (node->content ()))); -#ifdef DCPOMATIC_VARIANT_SWAROOP - } else if (node->name() == "ECinemaDKDM") { - return shared_ptr<ECinemaDKDM> (new ECinemaDKDM(EncryptedECinemaKDM(node->content()))); -#endif } else if (node->name() == "DKDMGroup") { shared_ptr<DKDMGroup> group (new DKDMGroup (node->string_attribute ("Name"))); BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children()) { @@ -67,20 +63,6 @@ DKDM::as_xml (xmlpp::Element* node) const node->add_child("DKDM")->add_child_text (_dkdm.as_xml ()); } -#ifdef DCPOMATIC_VARIANT_SWAROOP -string -ECinemaDKDM::name () const -{ - return String::compose ("%1 (%2)", _dkdm.name(), _dkdm.id()); -} - -void -ECinemaDKDM::as_xml (xmlpp::Element* node) const -{ - node->add_child("ECinemaDKDM")->add_child_text (_dkdm.as_xml()); -} -#endif - void DKDMGroup::as_xml (xmlpp::Element* node) const { diff --git a/src/lib/dkdm_wrapper.h b/src/lib/dkdm_wrapper.h index d828ffac2..09e9d25c4 100644 --- a/src/lib/dkdm_wrapper.h +++ b/src/lib/dkdm_wrapper.h @@ -18,9 +18,6 @@ */ -#ifdef DCPOMATIC_VARIANT_SWAROOP -#include "encrypted_ecinema_kdm.h" -#endif #include <dcp/encrypted_kdm.h> #include <libcxml/cxml.h> #include <boost/enable_shared_from_this.hpp> @@ -70,26 +67,6 @@ private: dcp::EncryptedKDM _dkdm; }; -#ifdef DCPOMATIC_VARIANT_SWAROOP -class ECinemaDKDM : public DKDMBase -{ -public: - explicit ECinemaDKDM (EncryptedECinemaKDM k) - : _dkdm (k) - {} - - std::string name () const; - void as_xml (xmlpp::Element *) const; - - EncryptedECinemaKDM dkdm () const { - return _dkdm; - } - -private: - EncryptedECinemaKDM _dkdm; -}; -#endif - class DKDMGroup : public DKDMBase { public: diff --git a/src/lib/encrypted_ecinema_kdm.cc b/src/lib/encrypted_ecinema_kdm.cc deleted file mode 100644 index faea03424..000000000 --- a/src/lib/encrypted_ecinema_kdm.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* - Copyright (C) 2019 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifdef DCPOMATIC_VARIANT_SWAROOP - -#include "encrypted_ecinema_kdm.h" -#include "ecinema_kdm_data.h" -#include "exceptions.h" -#include "cross.h" -#include <dcp/key.h> -#include <dcp/certificate.h> -#include <dcp/util.h> -#include <libcxml/cxml.h> -#include <libxml++/libxml++.h> -#include <openssl/rsa.h> -#include <openssl/err.h> -#include <iostream> - -using std::cout; -using std::string; -using boost::shared_ptr; -using boost::optional; -using dcp::Certificate; - -EncryptedECinemaKDM::EncryptedECinemaKDM (string id, string name, dcp::Key content_key, optional<dcp::LocalTime> not_valid_before, optional<dcp::LocalTime> not_valid_after, Certificate recipient) - : _id (id) - , _name (name) -{ - RSA* rsa = recipient.public_key (); - _data = dcp::Data (RSA_size(rsa)); - - int input_size = ECINEMA_KDM_KEY_LENGTH; - if (not_valid_before && not_valid_after) { - input_size += ECINEMA_KDM_NOT_VALID_BEFORE_LENGTH + ECINEMA_KDM_NOT_VALID_AFTER_LENGTH; - } - - dcp::Data input (input_size); - memcpy (input.data().get(), content_key.value(), ECINEMA_KDM_KEY_LENGTH); - if (not_valid_before && not_valid_after) { - memcpy (input.data().get() + ECINEMA_KDM_NOT_VALID_BEFORE, not_valid_before->as_string().c_str(), ECINEMA_KDM_NOT_VALID_BEFORE_LENGTH); - memcpy (input.data().get() + ECINEMA_KDM_NOT_VALID_AFTER, not_valid_after->as_string().c_str(), ECINEMA_KDM_NOT_VALID_AFTER_LENGTH); - } - - int const N = RSA_public_encrypt (input_size, input.data().get(), _data.data().get(), rsa, RSA_PKCS1_OAEP_PADDING); - if (N == -1) { - throw KDMError ("Could not encrypt ECinema KDM", ERR_error_string(ERR_get_error(), 0)); - } - -} - -EncryptedECinemaKDM::EncryptedECinemaKDM (string xml) -{ - cxml::Document doc ("ECinemaSecurityMessage"); - doc.read_string (xml); - _id = doc.string_child ("Id"); - _name = doc.string_child ("Name"); - _data = dcp::Data (256); - int const len = dcp::base64_decode (doc.string_child("Data"), _data.data().get(), _data.size()); - _data.set_size (len); -} - -string -EncryptedECinemaKDM::as_xml () const -{ - string key; - - /* Lazy overallocation */ - char out[_data.size() * 2]; - Kumu::base64encode (_data.data().get(), _data.size(), out, _data.size() * 2); - int const N = strlen (out); - string lines; - for (int i = 0; i < N; ++i) { - if (i > 0 && (i % 64) == 0) { - lines += "\n"; - } - lines += out[i]; - } - - xmlpp::Document document; - xmlpp::Element* root = document.create_root_node ("ECinemaSecurityMessage"); - root->add_child("Id")->add_child_text(_id); - root->add_child("Name")->add_child_text(_name); - root->add_child("Data")->add_child_text(lines); - return document.write_to_string ("UTF-8"); -} - -void -EncryptedECinemaKDM::as_xml (boost::filesystem::path path) const -{ - FILE* f = fopen_boost (path, "w"); - string const x = as_xml (); - fwrite (x.c_str(), 1, x.length(), f); - fclose (f); -} - -#endif diff --git a/src/lib/encrypted_ecinema_kdm.h b/src/lib/encrypted_ecinema_kdm.h deleted file mode 100644 index 90e13422a..000000000 --- a/src/lib/encrypted_ecinema_kdm.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (C) 2019 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifdef DCPOMATIC_VARIANT_SWAROOP - -#ifndef DCPOMATIC_ENCRYPTED_ECINEMA_KDM_H -#define DCPOMATIC_ENCRYPTED_ECINEMA_KDM_H - -#include <dcp/key.h> -#include <dcp/data.h> -#include <dcp/certificate.h> -#include <dcp/local_time.h> -#include <boost/optional.hpp> - -class DecryptedECinemaKDM; - -class EncryptedECinemaKDM -{ -public: - explicit EncryptedECinemaKDM (std::string xml); - - std::string as_xml () const; - void as_xml (boost::filesystem::path out) const; - - std::string id () const { - return _id; - } - - std::string name () const { - return _name; - } - - dcp::Data data () const { - return _data; - } - -private: - friend class DecryptedECinemaKDM; - - EncryptedECinemaKDM (std::string id, std::string name, dcp::Key key, boost::optional<dcp::LocalTime> not_valid_before, boost::optional<dcp::LocalTime> not_valid_after, dcp::Certificate recipient); - - std::string _id; - std::string _name; - /** encrypted data */ - dcp::Data _data; -}; - -#endif - -#endif diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 0802fa159..f9c1ef063 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -27,7 +27,6 @@ #include "dcpomatic_log.h" #include "ffmpeg_subtitle_stream.h" #include "ffmpeg_audio_stream.h" -#include "decrypted_ecinema_kdm.h" #include "digester.h" #include "compose.hpp" #include "config.h" @@ -128,13 +127,6 @@ FFmpeg::setup_general () _format_context->pb = _avio_context; AVDictionary* options = 0; -#ifdef DCPOMATIC_VARIANT_SWAROOP - if (_ffmpeg_content->kdm()) { - DecryptedECinemaKDM kdm (_ffmpeg_content->kdm().get(), Config::instance()->decryption_chain()->key().get()); - av_dict_set (&options, "decryption_key", kdm.key().hex().c_str(), 0); - } -#endif - int e = avformat_open_input (&_format_context, 0, 0, &options); if (e < 0) { throw OpenFileError (_ffmpeg_content->path(0).string(), e, OpenFileError::READ); diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 03763fc28..ac62ac7f4 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -34,7 +34,6 @@ #include "exceptions.h" #include "frame_rate_change.h" #include "text_content.h" -#include "decrypted_ecinema_kdm.h" #include <dcp/raw_convert.h> #include <libcxml/cxml.h> extern "C" { @@ -67,9 +66,6 @@ int const FFmpegContentProperty::KDM = 103; FFmpegContent::FFmpegContent (boost::filesystem::path p) : Content (p) -#ifdef DCPOMATIC_VARIANT_SWAROOP - , _encrypted (false) -#endif { } @@ -130,9 +126,6 @@ FFmpegContent::FFmpegContent (cxml::ConstNodePtr node, int version, list<string> _color_trc = get_optional_enum<AVColorTransferCharacteristic>(node, "ColorTransferCharacteristic"); _colorspace = get_optional_enum<AVColorSpace>(node, "Colorspace"); _bits_per_pixel = node->optional_number_child<int> ("BitsPerPixel"); -#ifdef DCPOMATIC_VARIANT_SWAROOP - _encrypted = node->optional_bool_child("Encrypted").get_value_or(false); -#endif } FFmpegContent::FFmpegContent (vector<shared_ptr<Content> > c) @@ -194,9 +187,6 @@ FFmpegContent::FFmpegContent (vector<shared_ptr<Content> > c) _color_trc = ref->_color_trc; _colorspace = ref->_colorspace; _bits_per_pixel = ref->_bits_per_pixel; -#ifdef DCPOMATIC_VARIANT_SWAROOP - _encrypted = ref->_encrypted; -#endif } void @@ -256,11 +246,6 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const if (_bits_per_pixel) { node->add_child("BitsPerPixel")->add_child_text (raw_convert<string> (*_bits_per_pixel)); } -#ifdef DCPOMATIC_VARIANT_SWAROOP - if (_encrypted) { - node->add_child("Encypted")->add_child_text ("1"); - } -#endif } void @@ -327,10 +312,6 @@ FFmpegContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job) text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN))); _subtitle_stream = _subtitle_streams.front (); } - -#ifdef DCPOMATIC_VARIANT_SWAROOP - _encrypted = first_path.extension() == ".ecinema"; -#endif } if (examiner->has_video ()) { @@ -344,10 +325,6 @@ FFmpegContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job) set_video_frame_rate (24000.0 / 1001); video->set_length (video->length() * 24.0 / 30); } - -#ifdef DCPOMATIC_VARIANT_SWAROOP - _id = examiner->id (); -#endif } string @@ -713,30 +690,3 @@ FFmpegContent::take_settings_from (shared_ptr<const Content> c) _filters = fc->_filters; } -#ifdef DCPOMATIC_VARIANT_SWAROOP -void -FFmpegContent::add_kdm (EncryptedECinemaKDM kdm) -{ - ChangeSignaller<Content> cc (this, FFmpegContentProperty::KDM); - boost::mutex::scoped_lock lm (_mutex); - _kdm = kdm; - -} - -bool -FFmpegContent::kdm_timing_window_valid () const -{ - if (!_kdm) { - return true; - } - - DCPOMATIC_ASSERT (Config::instance()->decryption_chain()->key()); - - DecryptedECinemaKDM decrypted (*_kdm, *Config::instance()->decryption_chain()->key()); - - dcp::LocalTime now; - return (!decrypted.not_valid_before() || *decrypted.not_valid_before() < now) && - (!decrypted.not_valid_after() || now < *decrypted.not_valid_after()); -} - -#endif diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index cf1849971..f933e4195 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -21,9 +21,6 @@ #ifndef DCPOMATIC_FFMPEG_CONTENT_H #define DCPOMATIC_FFMPEG_CONTENT_H -#ifdef DCPOMATIC_VARIANT_SWAROOP -#include "encrypted_ecinema_kdm.h" -#endif #include "content.h" #include "audio_stream.h" @@ -102,27 +99,6 @@ public: void signal_subtitle_stream_changed (); -#ifdef DCPOMATIC_VARIANT_SWAROOP - - bool encrypted () const { - boost::mutex::scoped_lock lm (_mutex); - return _encrypted; - } - - void add_kdm (EncryptedECinemaKDM kdm); - - boost::optional<EncryptedECinemaKDM> kdm () const { - return _kdm; - } - - boost::optional<std::string> id () const { - return _id; - } - - bool kdm_timing_window_valid () const; - -#endif - private: void add_properties (boost::shared_ptr<const Film> film, std::list<UserProperty> &) const; @@ -140,11 +116,6 @@ private: boost::optional<AVColorTransferCharacteristic> _color_trc; boost::optional<AVColorSpace> _colorspace; boost::optional<int> _bits_per_pixel; -#ifdef DCPOMATIC_VARIANT_SWAROOP - bool _encrypted; - boost::optional<EncryptedECinemaKDM> _kdm; - boost::optional<std::string> _id; -#endif }; #endif diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 3c0f48804..41b93dad7 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -159,12 +159,6 @@ FFmpegDecoder::flush () bool FFmpegDecoder::pass () { -#ifdef DCPOMATIC_VARIANT_SWAROOP - if (_ffmpeg_content->encrypted() && !_ffmpeg_content->kdm()) { - return true; - } -#endif - int r = av_read_frame (_format_context, &_packet); /* AVERROR_INVALIDDATA can apparently be returned sometimes even when av_read_frame diff --git a/src/lib/ffmpeg_encoder.cc b/src/lib/ffmpeg_encoder.cc index 2c76a38c3..1d8feffa8 100644 --- a/src/lib/ffmpeg_encoder.cc +++ b/src/lib/ffmpeg_encoder.cc @@ -57,10 +57,6 @@ FFmpegEncoder::FFmpegEncoder ( bool split_reels, bool audio_stream_per_channel, int x264_crf -#ifdef DCPOMATIC_VARIANT_SWAROOP - , optional<dcp::Key> key - , optional<string> id -#endif ) : Encoder (film, job) , _history (200) @@ -154,10 +150,6 @@ FFmpegEncoder::go () _film->three_d(), filename, extension -#ifdef DCPOMATIC_VARIANT_SWAROOP - , key - , id -#endif ) ); } @@ -249,10 +241,6 @@ FFmpegEncoder::FileEncoderSet::FileEncoderSet ( bool three_d, boost::filesystem::path output, string extension -#ifdef DCPOMATIC_VARIANT_SWAROOP - , optional<dcp::Key> key - , optional<string> id -#endif ) { if (three_d) { @@ -260,31 +248,19 @@ FFmpegEncoder::FileEncoderSet::FileEncoderSet ( _encoders[EYES_LEFT] = shared_ptr<FFmpegFileEncoder>( new FFmpegFileEncoder( video_frame_size, video_frame_rate, audio_frame_rate, channels, format, - audio_stream_per_channel, x264_crf, String::compose("%1_%2%3", output.string(), _("L"), extension) -#ifdef DCPOMATIC_VARIANT_SWAROOP - , key, id -#endif - ) + audio_stream_per_channel, x264_crf, String::compose("%1_%2%3", output.string(), _("L"), extension)) ); /// TRANSLATORS: R here is an abbreviation for "right", to indicate the right-eye part of a 3D export _encoders[EYES_RIGHT] = shared_ptr<FFmpegFileEncoder>( new FFmpegFileEncoder( video_frame_size, video_frame_rate, audio_frame_rate, channels, format, - audio_stream_per_channel, x264_crf, String::compose("%1_%2%3", output.string(), _("R"), extension) -#ifdef DCPOMATIC_VARIANT_SWAROOP - , key, id -#endif - ) + audio_stream_per_channel, x264_crf, String::compose("%1_%2%3", output.string(), _("R"), extension)) ); } else { _encoders[EYES_BOTH] = shared_ptr<FFmpegFileEncoder>( new FFmpegFileEncoder( video_frame_size, video_frame_rate, audio_frame_rate, channels, format, - audio_stream_per_channel, x264_crf, String::compose("%1%2", output.string(), extension) -#ifdef DCPOMATIC_VARIANT_SWAROOP - , key, id -#endif - ) + audio_stream_per_channel, x264_crf, String::compose("%1%2", output.string(), extension)) ); } } diff --git a/src/lib/ffmpeg_encoder.h b/src/lib/ffmpeg_encoder.h index 3b0bdd170..c71f8fa63 100644 --- a/src/lib/ffmpeg_encoder.h +++ b/src/lib/ffmpeg_encoder.h @@ -40,10 +40,6 @@ public: bool split_reels, bool audio_stream_per_channel, int x264_crf -#ifdef DCPOMATIC_VARIANT_SWAROOP - , boost::optional<dcp::Key> key - , boost::optional<std::string> id -#endif ); void go (); @@ -70,10 +66,6 @@ private: bool three_d, boost::filesystem::path output, std::string extension -#ifdef DCPOMATIC_VARIANT_SWAROOP - , boost::optional<dcp::Key> key - , boost::optional<std::string> id -#endif ); boost::shared_ptr<FFmpegFileEncoder> get (Eyes eyes) const; diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 8a26f5626..bfd7e7722 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -192,13 +192,6 @@ DCPOMATIC_ENABLE_WARNINGS _pulldown = true; LOG_GENERAL_NC("Suggest that this may be 2:3 pull-down (soft telecine)"); } - -#ifdef DCPOMATIC_VARIANT_SWAROOP - AVDictionaryEntry* e = av_dict_get (_format_context->metadata, SWAROOP_ID_TAG, 0, 0); - if (e) { - _id = e->value; - } -#endif } diff --git a/src/lib/ffmpeg_examiner.h b/src/lib/ffmpeg_examiner.h index 4f5110ca0..3852f51a5 100644 --- a/src/lib/ffmpeg_examiner.h +++ b/src/lib/ffmpeg_examiner.h @@ -81,12 +81,6 @@ public: return _pulldown; } -#ifdef DCPOMATIC_VARIANT_SWAROOP - boost::optional<std::string> id () const { - return _id; - } -#endif - private: void video_packet (AVCodecContext *, std::string& temporal_reference); void audio_packet (AVCodecContext *, boost::shared_ptr<FFmpegAudioStream>); @@ -107,10 +101,6 @@ private: boost::optional<double> _rotation; bool _pulldown; -#ifdef DCPOMATIC_VARIANT_SWAROOP - boost::optional<std::string> _id; -#endif - struct SubtitleStart { SubtitleStart (std::string id_, bool image_, dcpomatic::ContentTime time_) diff --git a/src/lib/ffmpeg_file_encoder.cc b/src/lib/ffmpeg_file_encoder.cc index 9a3c434d4..e527b1820 100644 --- a/src/lib/ffmpeg_file_encoder.cc +++ b/src/lib/ffmpeg_file_encoder.cc @@ -218,10 +218,6 @@ FFmpegFileEncoder::FFmpegFileEncoder ( bool audio_stream_per_channel, int x264_crf, boost::filesystem::path output -#ifdef DCPOMATIC_VARIANT_SWAROOP - , optional<dcp::Key> key - , optional<string> id -#endif ) : _audio_stream_per_channel (audio_stream_per_channel) , _video_options (0) @@ -258,11 +254,7 @@ FFmpegFileEncoder::FFmpegFileEncoder ( DCPOMATIC_ASSERT (false); } -#ifdef DCPOMATIC_VARIANT_SWAROOP - int r = avformat_alloc_output_context2 (&_format_context, av_guess_format("mov", 0, 0), 0, 0); -#else int r = avformat_alloc_output_context2 (&_format_context, 0, 0, _output.string().c_str()); -#endif if (!_format_context) { throw runtime_error (String::compose("could not allocate FFmpeg format context (%1)", r)); } @@ -277,21 +269,6 @@ FFmpegFileEncoder::FFmpegFileEncoder ( AVDictionary* options = 0; -#ifdef DCPOMATIC_VARIANT_SWAROOP - if (key) { - av_dict_set (&options, "encryption_key", key->hex().c_str(), 0); - /* XXX: is this OK? */ - av_dict_set (&options, "encryption_kid", "00000000000000000000000000000000", 0); - av_dict_set (&options, "encryption_scheme", "cenc-aes-ctr", 0); - } - - if (id) { - if (av_dict_set(&_format_context->metadata, SWAROOP_ID_TAG, id->c_str(), 0) < 0) { - throw runtime_error ("Could not write ID to output"); - } - } -#endif - if (avformat_write_header (_format_context, &options) < 0) { throw runtime_error ("could not write header to FFmpeg output file"); } diff --git a/src/lib/ffmpeg_file_encoder.h b/src/lib/ffmpeg_file_encoder.h index 19674d249..08fc4778b 100644 --- a/src/lib/ffmpeg_file_encoder.h +++ b/src/lib/ffmpeg_file_encoder.h @@ -47,10 +47,6 @@ public: bool audio_stream_per_channel, int x264_crf, boost::filesystem::path output -#ifdef DCPOMATIC_VARIANT_SWAROOP - , boost::optional<dcp::Key> key - , boost::optional<std::string> id -#endif ); ~FFmpegFileEncoder (); diff --git a/src/lib/kdm_with_metadata.h b/src/lib/kdm_with_metadata.h index b6bec1c4c..2e07334de 100644 --- a/src/lib/kdm_with_metadata.h +++ b/src/lib/kdm_with_metadata.h @@ -21,9 +21,6 @@ #ifndef DCPOMATIC_KDM_WITH_METADATA_H #define DCPOMATIC_KDM_WITH_METADATA_H -#ifdef DCPOMATIC_VARIANT_SWAROOP -#include "encrypted_ecinema_kdm.h" -#endif #include <dcp/encrypted_kdm.h> #include <dcp/name_format.h> #include <boost/shared_ptr.hpp> @@ -33,16 +30,20 @@ class Cinema; class KDMWithMetadata { public: - KDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list<std::string> emails) + KDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list<std::string> emails, dcp::EncryptedKDM kdm) : _name_values (name_values) , _group (group) , _emails (emails) + , _kdm (kdm) {} - virtual ~KDMWithMetadata () {} + std::string kdm_as_xml () const { + return _kdm.as_xml (); + } - virtual std::string kdm_as_xml () const = 0; - virtual void kdm_as_xml (boost::filesystem::path out) const = 0; + void kdm_as_xml (boost::filesystem::path out) const { + return _kdm.as_xml (out); + } dcp::NameFormat::Map const& name_values () const { return _name_values; @@ -62,6 +63,7 @@ private: dcp::NameFormat::Map _name_values; void const* _group; std::list<std::string> _emails; + dcp::EncryptedKDM _kdm; }; @@ -105,31 +107,5 @@ void email ( std::string cpl_name ); - -template <class T> -class SpecialKDMWithMetadata : public KDMWithMetadata -{ -public: - SpecialKDMWithMetadata (dcp::NameFormat::Map const& name_values, void const* group, std::list<std::string> emails, T k) - : KDMWithMetadata (name_values, group, emails) - , kdm (k) - {} - - std::string kdm_as_xml () const { - return kdm.as_xml (); - } - - void kdm_as_xml (boost::filesystem::path out) const { - return kdm.as_xml (out); - } - - T kdm; -}; - -typedef SpecialKDMWithMetadata<dcp::EncryptedKDM> DCPKDMWithMetadata; -#ifdef DCPOMATIC_VARIANT_SWAROOP -typedef SpecialKDMWithMetadata<EncryptedECinemaKDM> ECinemaKDMWithMetadata; -#endif - #endif diff --git a/src/lib/lock_file_checker.cc b/src/lib/lock_file_checker.cc deleted file mode 100644 index 9543c2c9f..000000000 --- a/src/lib/lock_file_checker.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifdef DCPOMATIC_VARIANT_SWAROOP - -#include "lock_file_checker.h" -#include "config.h" -#include "cross.h" - -using boost::bind; -using boost::ref; - -LockFileChecker* LockFileChecker::_instance = 0; - -LockFileChecker::LockFileChecker () - : Checker (10) -{ - -} - -bool -LockFileChecker::check () const -{ - return !Config::instance()->player_lock_file() || boost::filesystem::is_regular_file(Config::instance()->player_lock_file().get()); -} - -LockFileChecker * -LockFileChecker::instance () -{ - if (!_instance) { - _instance = new LockFileChecker (); - } - - return _instance; -} - -#endif diff --git a/src/lib/lock_file_checker.h b/src/lib/lock_file_checker.h deleted file mode 100644 index 76c00717d..000000000 --- a/src/lib/lock_file_checker.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include "checker.h" -#include <boost/signals2.hpp> - -class LockFileChecker : public Checker -{ -public: - LockFileChecker (); - - static LockFileChecker* instance (); - -protected: - bool check () const; - -private: - static LockFileChecker* _instance; -}; diff --git a/src/lib/monitor_checker.cc b/src/lib/monitor_checker.cc deleted file mode 100644 index d15dee63f..000000000 --- a/src/lib/monitor_checker.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifdef DCPOMATIC_VARIANT_SWAROOP - -#include "monitor_checker.h" -#include "config.h" -#include "cross.h" - -MonitorChecker* MonitorChecker::_instance = 0; - -MonitorChecker::MonitorChecker () - : Checker (60) -{ - -} - -bool -MonitorChecker::check () const -{ - return Config::instance()->required_monitors().empty() || get_monitors() == Config::instance()->required_monitors(); -} - - -MonitorChecker * -MonitorChecker::instance () -{ - if (!_instance) { - _instance = new MonitorChecker (); - } - - return _instance; -} - -#endif diff --git a/src/lib/monitor_checker.h b/src/lib/monitor_checker.h deleted file mode 100644 index f99ab4b2a..000000000 --- a/src/lib/monitor_checker.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include "checker.h" -#include <boost/signals2.hpp> - -class MonitorChecker : public Checker -{ -public: - MonitorChecker (); - - static MonitorChecker* instance (); - -protected: - bool check () const; - -private: - static MonitorChecker* _instance; -}; diff --git a/src/lib/player_video.h b/src/lib/player_video.h index 0456457db..56cfbd100 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -126,9 +126,7 @@ private: boost::optional<ColourConversion> _colour_conversion; VideoRange _video_range; boost::optional<PositionImage> _text; - /** Content that we came from. This is so that reset_metadata() can work, and also - * for variant:swaroop's non-skippable ads. - */ + /** Content that we came from. This is so that reset_metadata() can work. */ boost::weak_ptr<Content> _content; /** Video frame that we came from. Again, this is for reset_metadata() */ boost::optional<Frame> _video_frame; diff --git a/src/lib/screen.cc b/src/lib/screen.cc index 61a27f2bc..544bce9ef 100644 --- a/src/lib/screen.cc +++ b/src/lib/screen.cc @@ -107,6 +107,6 @@ kdm_for_screen ( name_values['e'] = end.date() + " " + end.time_of_day(true, false); name_values['i'] = kdm.cpl_id(); - return KDMWithMetadataPtr(new DCPKDMWithMetadata(name_values, cinema.get(), cinema ? cinema->emails : list<string>(), kdm)); + return KDMWithMetadataPtr(new KDMWithMetadata(name_values, cinema.get(), cinema ? cinema->emails : list<string>(), kdm)); } diff --git a/src/lib/swaroop_spl.cc b/src/lib/swaroop_spl.cc deleted file mode 100644 index 02ed966a4..000000000 --- a/src/lib/swaroop_spl.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2018-2019 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include "swaroop_spl.h" -#include "content_store.h" -#include <libcxml/cxml.h> -#include <dcp/raw_convert.h> -#include <libxml++/libxml++.h> -#include <boost/foreach.hpp> -#include <iostream> - -using std::cout; -using std::string; -using boost::shared_ptr; -using dcp::raw_convert; - -void -SPL::read (boost::filesystem::path path, ContentStore* store) -{ - _path = path; - - _spl.clear (); - _missing = false; - cxml::Document doc ("SPL"); - doc.read_file (path); - _id = doc.string_child("Id"); - BOOST_FOREACH (cxml::ConstNodePtr i, doc.node_children("Entry")) { - shared_ptr<Content> c = store->get(i->string_child("Digest")); - if (c) { - add (SPLEntry(c, i)); - } else { - _missing = true; - } - } - - _allowed_shows = doc.optional_number_child<int>("AllowedShows"); -} - -void -SPL::write (boost::filesystem::path path) const -{ - _path = path; - - xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("SPL"); - root->add_child("Id")->add_child_text (_id); - BOOST_FOREACH (SPLEntry i, _spl) { - i.as_xml (root->add_child("Entry")); - } - if (_allowed_shows) { - root->add_child("AllowedShows")->add_child_text(raw_convert<string>(*_allowed_shows)); - } - doc.write_to_file_formatted (path.string()); -} diff --git a/src/lib/swaroop_spl.h b/src/lib/swaroop_spl.h deleted file mode 100644 index 308f5286d..000000000 --- a/src/lib/swaroop_spl.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifndef DCPOMATIC_SPL_H -#define DCPOMATIC_SPL_H - -#include "swaroop_spl_entry.h" -#include <dcp/util.h> - -class ContentStore; - -class SPL -{ -public: - SPL () - : _id (dcp::make_uuid()) - , _missing (false) - {} - - void add (SPLEntry e) { - _spl.push_back (e); - } - - void remove (std::size_t index) { - _spl.erase (_spl.begin() + index); - } - - std::vector<SPLEntry> const & get () const { - return _spl; - } - - SPLEntry & operator[] (std::size_t index) { - return _spl[index]; - } - - SPLEntry const & operator[] (std::size_t index) const { - return _spl[index]; - } - - void read (boost::filesystem::path path, ContentStore* store); - void write (boost::filesystem::path path) const; - - std::string id () const { - return _id; - } - - boost::optional<boost::filesystem::path> path () const { - return _path; - } - - std::string name () const { - if (!_path) { - return ""; - } - return _path->filename().string(); - } - - bool missing () const { - return _missing; - } - - boost::optional<int> allowed_shows () const { - return _allowed_shows; - } - - bool have_allowed_shows () const { - return !_allowed_shows || *_allowed_shows > 0; - } - - void set_allowed_shows (int s) { - _allowed_shows = s; - } - - void unset_allowed_shows () { - _allowed_shows = boost::optional<int>(); - } - - void decrement_allowed_shows () { - if (_allowed_shows) { - (*_allowed_shows)--; - } - - } - -private: - std::string _id; - mutable boost::optional<boost::filesystem::path> _path; - std::vector<SPLEntry> _spl; - /** true if any content was missing when read() was last called on this SPL */ - bool _missing; - /** number of times left that the player will allow this playlist to be played (unset means infinite shows) */ - boost::optional<int> _allowed_shows; -}; - -#endif diff --git a/src/lib/swaroop_spl_entry.cc b/src/lib/swaroop_spl_entry.cc deleted file mode 100644 index ed5a469ac..000000000 --- a/src/lib/swaroop_spl_entry.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#include "swaroop_spl_entry.h" -#include "dcp_content.h" -#include "dcpomatic_assert.h" -#include <libxml++/libxml++.h> - -using boost::shared_ptr; -using boost::dynamic_pointer_cast; - -SPLEntry::SPLEntry (shared_ptr<Content> content) - : skippable (false) - , disable_timeline (false) - , stop_after_play (false) -{ - construct (content); -} - -SPLEntry::SPLEntry (shared_ptr<Content> content, cxml::ConstNodePtr node) - : skippable (node->bool_child("Skippable")) - , disable_timeline (node->bool_child("DisableTimeline")) - , stop_after_play (node->bool_child("StopAfterPlay")) -{ - construct (content); -} - -void -SPLEntry::construct (shared_ptr<Content> c) -{ - content = c; - shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (content); - digest = content->digest (); - if (dcp) { - name = dcp->name (); - DCPOMATIC_ASSERT (dcp->cpl()); - id = *dcp->cpl(); - kind = dcp->content_kind().get_value_or(dcp::FEATURE); - type = DCP; - encrypted = dcp->encrypted (); - } else { - name = content->path(0).filename().string(); - type = ECINEMA; - kind = dcp::FEATURE; - } -} - -void -SPLEntry::as_xml (xmlpp::Element* e) -{ - e->add_child("Digest")->add_child_text(digest); - e->add_child("Skippable")->add_child_text(skippable ? "1" : "0"); - e->add_child("DisableTimeline")->add_child_text(disable_timeline ? "1" : "0"); - e->add_child("StopAfterPlay")->add_child_text(stop_after_play ? "1" : "0"); -} diff --git a/src/lib/swaroop_spl_entry.h b/src/lib/swaroop_spl_entry.h deleted file mode 100644 index 75e0b5223..000000000 --- a/src/lib/swaroop_spl_entry.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. - -*/ - -#ifndef DCPOMATIC_SWAROOP_SPL_ENTRY_H -#define DCPOMATIC_SWAROOP_SPL_ENTRY_H - -#include <libcxml/cxml.h> -#include <dcp/types.h> -#include <boost/shared_ptr.hpp> - -namespace xmlpp { - class Element; -} - -class Content; - -class SPLEntry -{ -public: - SPLEntry (boost::shared_ptr<Content> content); - SPLEntry (boost::shared_ptr<Content> content, cxml::ConstNodePtr node); - - void as_xml (xmlpp::Element* e); - - boost::shared_ptr<Content> content; - std::string name; - /** Digest of this content */ - std::string digest; - /** CPL ID or something else for MP4 (?) */ - std::string id; - dcp::ContentKind kind; - enum Type { - DCP, - ECINEMA - }; - Type type; - bool encrypted; - bool skippable; - bool disable_timeline; - bool stop_after_play; - -private: - void construct (boost::shared_ptr<Content> content); -}; - -#endif diff --git a/src/lib/util.cc b/src/lib/util.cc index 90d78b32e..5310e55c9 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -1094,111 +1094,6 @@ copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::f free (buffer); } -#ifdef DCPOMATIC_VARIANT_SWAROOP - -/* Make up a key from the machine UUID */ -dcp::Data -key_from_uuid () -{ - dcp::Data key (dcpomatic::crypto_key_length()); - memset (key.data().get(), 0, key.size()); - string const magic = command_and_read ("dcpomatic2_uuid"); - strncpy ((char *) key.data().get(), magic.c_str(), dcpomatic::crypto_key_length()); - return key; -} - -/* swaroop chain file format: - * - * 0 [int16_t] IV length - * 2 [int16_t] cert #1 length, or 0 for none - * 4 [int16_t] cert #2 length, or 0 for none - * 6 [int16_t] cert #3 length, or 0 for none - * 8 [int16_t] cert #4 length, or 0 for none - * 10 [int16_t] cert #5 length, or 0 for none - * 12 [int16_t] cert #6 length, or 0 for none - * 14 [int16_t] cert #7 length, or 0 for none - * 16 [int16_t] cert #8 length, or 0 for none - * 16 [int16_t] private key length - * 20 IV - * cert #1 - * cert #2 - * cert #3 - * cert #4 - * cert #5 - * cert #6 - * cert #7 - * cert #8 - * private key - */ - -struct __attribute__ ((packed)) Header_ { - int16_t iv_length; - int16_t cert_length[8]; - int16_t private_key_length; -}; - -typedef struct Header_ Header; - -shared_ptr<dcp::CertificateChain> -read_swaroop_chain (boost::filesystem::path path) -{ - dcp::Data data (path); - Header* header = (Header *) data.data().get(); - uint8_t* p = data.data().get() + sizeof(Header); - - dcp::Data iv (p, header->iv_length); - p += iv.size(); - - shared_ptr<dcp::CertificateChain> cc (new dcp::CertificateChain()); - for (int i = 0; i < 8; ++i) { - if (header->cert_length[i] == 0) { - break; - } - dcp::Data c(p, header->cert_length[i]); - p += c.size(); - cc->add (dcp::Certificate(dcpomatic::decrypt(c, key_from_uuid(), iv))); - } - - dcp::Data k (p, header->private_key_length); - cc->set_key (dcpomatic::decrypt(k, key_from_uuid(), iv)); - return cc; -} - -void -write_swaroop_chain (shared_ptr<const dcp::CertificateChain> chain, boost::filesystem::path output) -{ - scoped_array<uint8_t> buffer (new uint8_t[65536]); - Header* header = (Header *) buffer.get(); - memset (header, 0, sizeof(Header)); - uint8_t* p = buffer.get() + sizeof(Header); - - dcp::Data iv = dcpomatic::random_iv (); - header->iv_length = iv.size (); - memcpy (p, iv.data().get(), iv.size()); - p += iv.size(); - - int N = 0; - BOOST_FOREACH (dcp::Certificate i, chain->root_to_leaf()) { - dcp::Data e = dcpomatic::encrypt (i.certificate(true), key_from_uuid(), iv); - memcpy (p, e.data().get(), e.size()); - p += e.size(); - DCPOMATIC_ASSERT (N < 8); - header->cert_length[N] = e.size (); - ++N; - } - - dcp::Data k = dcpomatic::encrypt (chain->key().get(), key_from_uuid(), iv); - memcpy (p, k.data().get(), k.size()); - p += k.size(); - header->private_key_length = k.size (); - - FILE* f = fopen_boost (output, "wb"); - checked_fwrite (buffer.get(), p - buffer.get(), f, output); - fclose (f); -} - -#endif - double db_to_linear (double db) { diff --git a/src/lib/util.h b/src/lib/util.h index b4378040a..28a6fd660 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -65,10 +65,6 @@ namespace dcp { #define CLOSED_CAPTION_LINES 3 /** Maximum line length of closed caption viewers */ #define CLOSED_CAPTION_LENGTH 30 -/* We are mis-using genre here, as only some metadata tags are written/read. - I tried the use_metadata_tags option but it didn't seem to make any difference. -*/ -#define SWAROOP_ID_TAG "genre" extern std::string program_name; extern bool is_batch_converter; @@ -115,10 +111,6 @@ extern std::string day_of_week_to_string (boost::gregorian::greg_weekday d); extern void emit_subtitle_image (dcpomatic::ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size size, boost::shared_ptr<TextDecoder> decoder); extern bool show_jobs_on_console (bool progress); extern void copy_in_bits (boost::filesystem::path from, boost::filesystem::path to, boost::function<void (float)>); -#ifdef DCPOMATIC_VARIANT_SWAROOP -extern boost::shared_ptr<dcp::CertificateChain> read_swaroop_chain (boost::filesystem::path path); -extern void write_swaroop_chain (boost::shared_ptr<const dcp::CertificateChain> chain, boost::filesystem::path output); -#endif extern dcp::Size scale_for_display (dcp::Size s, dcp::Size display_container, dcp::Size film_container); extern dcp::DecryptedKDM decrypt_kdm_with_helpful_error (dcp::EncryptedKDM kdm); extern boost::filesystem::path default_font_file (); diff --git a/src/lib/wscript b/src/lib/wscript index 04044a8c3..7b7b3cf20 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -47,7 +47,6 @@ sources = """ text_content.cc text_decoder.cc case_insensitive_sorter.cc - checker.cc check_content_change_job.cc cinema.cc cinema_sound_processor.cc @@ -79,7 +78,6 @@ sources = """ decoder.cc decoder_factory.cc decoder_part.cc - decrypted_ecinema_kdm.cc digester.cc dkdm_recipient.cc dkdm_wrapper.cc @@ -91,7 +89,6 @@ sources = """ encode_server.cc encode_server_finder.cc encoded_log_entry.cc - encrypted_ecinema_kdm.cc environment_info.cc event_history.cc examine_content_job.cc @@ -131,11 +128,9 @@ sources = """ json_server.cc kdm_with_metadata.cc kdm_recipient.cc - lock_file_checker.cc log.cc log_entry.cc mid_side_decoder.cc - monitor_checker.cc overlaps.cc player.cc player_text.cc @@ -211,9 +206,6 @@ def build(bld): obj.source = sources + ' version.cc' - if bld.env.VARIANT == 'swaroop-theater' or bld.env.VARIANT == 'swaroop-studio': - obj.source += ' swaroop_spl.cc swaroop_spl_entry.cc' - if bld.env.ENABLE_DISK: obj.source += ' copy_to_drive_job.cc nanomsg.cc' obj.uselib += ' LWEXT4 NANOMSG' |
