diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-07-20 15:11:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-07-20 15:11:57 +0100 |
| commit | da228f37426ac999f02e03e558acef5501b22361 (patch) | |
| tree | 201e133ec9bd72c0a3f5f2182476717994809ff7 | |
| parent | 454e76146a5bd522e47ebbedd490e89ef95dd186 (diff) | |
Tidy up KDM generation from CPLs a bit.
| -rw-r--r-- | src/cpl.cc | 12 | ||||
| -rw-r--r-- | src/cpl.h | 9 | ||||
| -rw-r--r-- | src/decrypted_kdm.cc | 12 | ||||
| -rw-r--r-- | src/decrypted_kdm.h | 9 | ||||
| -rw-r--r-- | src/exceptions.h | 2 | ||||
| -rw-r--r-- | src/mxf.h | 3 | ||||
| -rw-r--r-- | src/picture_mxf.cc | 6 | ||||
| -rw-r--r-- | src/picture_mxf.h | 1 | ||||
| -rw-r--r-- | src/reel_mxf_asset.h | 3 | ||||
| -rw-r--r-- | src/reel_picture_asset.cc | 6 | ||||
| -rw-r--r-- | src/reel_picture_asset.h | 2 | ||||
| -rw-r--r-- | src/reel_sound_asset.cc | 6 | ||||
| -rw-r--r-- | src/reel_sound_asset.h | 1 | ||||
| -rw-r--r-- | src/sound_mxf.cc | 6 | ||||
| -rw-r--r-- | src/sound_mxf.h | 1 | ||||
| -rw-r--r-- | test/encryption_test.cc | 1 | ||||
| -rw-r--r-- | test/round_trip_test.cc | 1 |
17 files changed, 40 insertions, 41 deletions
@@ -153,20 +153,20 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons set_file (file); } -list<shared_ptr<const Content> > -CPL::content () const +list<shared_ptr<const ReelAsset> > +CPL::reel_assets () const { - list<shared_ptr<const Content> > c; + list<shared_ptr<const ReelAsset> > c; for (list<shared_ptr<Reel> >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) { if ((*i)->main_picture ()) { - c.push_back ((*i)->main_picture()->mxf ()); + c.push_back ((*i)->main_picture()); } if ((*i)->main_sound ()) { - c.push_back ((*i)->main_sound()->mxf ()); + c.push_back ((*i)->main_sound()); } if ((*i)->main_subtitle ()) { - c.push_back ((*i)->main_subtitle()->subtitle_content ()); + c.push_back ((*i)->main_subtitle()); } } @@ -1,7 +1,7 @@ /* Copyright (C) 2014 Carl Hetherington <cth@carlh.net> - This program is free software; you can redistribute it and/or modify + This program 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. @@ -38,7 +38,7 @@ namespace dcp { -class Content; +class ReelAsset; class Reel; class XMLMetadata; class MXFMetadata; @@ -95,10 +95,9 @@ public: return _reels; } - /** @return the Content in this CPL across all its reels - * (Content is picture, sound and subtitles) + /** @return the ReelAssets in this CPL in all reels. */ - std::list<boost::shared_ptr<const Content> > content () const; + std::list<boost::shared_ptr<const ReelAsset> > reel_assets () const; bool encrypted () const; diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc index 556cd9d5..62162346 100644 --- a/src/decrypted_kdm.cc +++ b/src/decrypted_kdm.cc @@ -20,6 +20,7 @@ #include "decrypted_kdm.h" #include "decrypted_kdm_key.h" #include "encrypted_kdm.h" +#include "reel_mxf_asset.h" #include "util.h" #include "exceptions.h" #include "cpl.h" @@ -184,6 +185,7 @@ DecryptedKDM::DecryptedKDM (EncryptedKDM const & kdm, string private_key) DecryptedKDM::DecryptedKDM ( boost::shared_ptr<const CPL> cpl, + Key key, LocalTime not_valid_before, LocalTime not_valid_after, string annotation_text, @@ -197,15 +199,15 @@ DecryptedKDM::DecryptedKDM ( , _issue_date (issue_date) { /* Create DecryptedKDMKey objects for each MXF asset */ - list<shared_ptr<const Content> > content = cpl->content (); - for (list<shared_ptr<const Content> >::iterator i = content.begin(); i != content.end(); ++i) { + list<shared_ptr<const ReelAsset> > assets = cpl->reel_assets (); + for (list<shared_ptr<const ReelAsset> >::iterator i = assets.begin(); i != assets.end(); ++i) { /* XXX: do non-MXF assets need keys? */ - shared_ptr<const MXF> mxf = boost::dynamic_pointer_cast<const MXF> (*i); + shared_ptr<const ReelMXFAsset> mxf = boost::dynamic_pointer_cast<const ReelMXFAsset> (*i); if (mxf) { if (mxf->key_id().empty ()) { - throw NotEncryptedError (mxf->file().string ()); + throw NotEncryptedError (mxf->id()); } - _keys.push_back (DecryptedKDMKey (mxf->key_type(), mxf->key_id(), mxf->key().get (), cpl->id ())); + _keys.push_back (DecryptedKDMKey (mxf->key_type(), mxf->key_id(), key, cpl->id ())); } } } diff --git a/src/decrypted_kdm.h b/src/decrypted_kdm.h index 4c46c74a..88cbc1e6 100644 --- a/src/decrypted_kdm.h +++ b/src/decrypted_kdm.h @@ -57,11 +57,13 @@ public: /** Construct a DecryptedKDM. * @param cpl CPL that the keys are for. + * @param key Key that was used to encrypt the MXFs. * @param not_valid_before Start time for the KDM. * @param not_valid_after End time for the KDM. */ DecryptedKDM ( boost::shared_ptr<const CPL> cpl, + Key key, LocalTime not_valid_before, LocalTime not_valid_after, std::string annotation_text, @@ -69,13 +71,6 @@ public: std::string issue_date ); - /** Add a key to this KDM. - * @param type Key type (MDIK, MDAK etc.) - * @param id Key id. - * @param key the key itself (which has been used to encrypt a MXF). - */ - void add_key (std::string type, std::string id, Key key); - /** Encrypt this KDM's keys and sign the whole KDM. * @param signer Signer. * @param recipient Certificate of the projector/server which should receive this KDM's keys. diff --git a/src/exceptions.h b/src/exceptions.h index be87c40b..fd7c7618 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -162,7 +162,7 @@ public: class NotEncryptedError : public StringError { public: - NotEncryptedError (std::string const & asset_filename); + NotEncryptedError (std::string const & what); ~NotEncryptedError () throw () {} }; @@ -49,9 +49,6 @@ public: MXF (boost::filesystem::path file); ~MXF (); - /** @return the 4-character key type for this MXF (MDIK, MDAK, etc.) */ - virtual std::string key_type () const = 0; - bool equals ( boost::shared_ptr<const Content> other, EqualityOptions opt, diff --git a/src/picture_mxf.cc b/src/picture_mxf.cc index e3a43e37..1f863eb1 100644 --- a/src/picture_mxf.cc +++ b/src/picture_mxf.cc @@ -184,9 +184,3 @@ PictureMXF::frame_buffer_equals ( return true; } - -string -PictureMXF::key_type () const -{ - return "MDIK"; -} diff --git a/src/picture_mxf.h b/src/picture_mxf.h index 1ce2e7de..5b76c116 100644 --- a/src/picture_mxf.h +++ b/src/picture_mxf.h @@ -102,7 +102,6 @@ protected: Fraction _screen_aspect_ratio; private: - std::string key_type () const; std::string asdcp_kind () const { return "Picture"; } diff --git a/src/reel_mxf_asset.h b/src/reel_mxf_asset.h index 21116d28..9d98cd71 100644 --- a/src/reel_mxf_asset.h +++ b/src/reel_mxf_asset.h @@ -33,6 +33,9 @@ public: ReelMXFAsset (boost::shared_ptr<MXF> mxf, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point); ReelMXFAsset (boost::shared_ptr<const cxml::Node>); + /** @return the 4-character key type for this MXF (MDIK, MDAK, etc.) */ + virtual std::string key_type () const = 0; + void write_to_cpl (xmlpp::Node* node, Standard standard) const; /** @return true if a KeyId is specified for this asset, implying diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc index c8556b4c..4f737a91 100644 --- a/src/reel_picture_asset.cc +++ b/src/reel_picture_asset.cc @@ -90,3 +90,9 @@ ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const ); } } + +string +ReelPictureAsset::key_type () const +{ + return "MDIK"; +} diff --git a/src/reel_picture_asset.h b/src/reel_picture_asset.h index e635e850..7ab92228 100644 --- a/src/reel_picture_asset.h +++ b/src/reel_picture_asset.h @@ -54,6 +54,8 @@ public: } private: + std::string key_type () const; + Fraction _frame_rate; Fraction _screen_aspect_ratio; }; diff --git a/src/reel_sound_asset.cc b/src/reel_sound_asset.cc index ee308fa0..55167d82 100644 --- a/src/reel_sound_asset.cc +++ b/src/reel_sound_asset.cc @@ -46,3 +46,9 @@ ReelSoundAsset::cpl_node_name () const { return "MainSound"; } + +string +ReelSoundAsset::key_type () const +{ + return "MDAK"; +} diff --git a/src/reel_sound_asset.h b/src/reel_sound_asset.h index af898b46..0e27f380 100644 --- a/src/reel_sound_asset.h +++ b/src/reel_sound_asset.h @@ -46,6 +46,7 @@ public: } private: + std::string key_type () const; std::string cpl_node_name () const; }; diff --git a/src/sound_mxf.cc b/src/sound_mxf.cc index ff2167d9..89f1ee60 100644 --- a/src/sound_mxf.cc +++ b/src/sound_mxf.cc @@ -170,9 +170,3 @@ SoundMXF::start_write (boost::filesystem::path file, Standard standard) /* XXX: can't we use a shared_ptr here? */ return shared_ptr<SoundMXFWriter> (new SoundMXFWriter (this, file, standard)); } - -string -SoundMXF::key_type () const -{ - return "MDAK"; -} diff --git a/src/sound_mxf.h b/src/sound_mxf.h index 50d10957..d444ad28 100644 --- a/src/sound_mxf.h +++ b/src/sound_mxf.h @@ -64,7 +64,6 @@ public: } private: - std::string key_type () const; std::string asdcp_kind () const { return "Sound"; } diff --git a/test/encryption_test.cc b/test/encryption_test.cc index e096c5fd..e5acdbce 100644 --- a/test/encryption_test.cc +++ b/test/encryption_test.cc @@ -127,6 +127,7 @@ BOOST_AUTO_TEST_CASE (encryption_test) dcp::DecryptedKDM kdm ( cpl, + key, dcp::LocalTime ("2013-01-01T00:00:00+00:00"), dcp::LocalTime ("2017-01-08T00:00:00+00:00"), "libdcp", diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc index 7ba501e6..b0594931 100644 --- a/test/round_trip_test.cc +++ b/test/round_trip_test.cc @@ -67,6 +67,7 @@ BOOST_AUTO_TEST_CASE (round_trip_test) /* A KDM using our certificate chain's leaf key pair */ dcp::DecryptedKDM kdm_A ( cpl, + key, dcp::LocalTime ("2013-01-01T00:00:00+00:00"), dcp::LocalTime ("2013-01-08T00:00:00+00:00"), "libdcp", |
