A few encryption-related fixes and comments.
[libdcp.git] / src / cpl.h
index f9814337d7f6948b8711224ebf0ad66edd7c75c2..aa07036d3e93c66017a17b9fcbea4aa23a6824a7 100644 (file)
--- a/src/cpl.h
+++ b/src/cpl.h
 
 */
 
+#ifndef LIBDCP_CPL_H
+#define LIBDCP_CPL_H
+
 #include <list>
 #include <boost/shared_ptr.hpp>
 #include <boost/function.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/optional.hpp>
+#include <boost/filesystem.hpp>
 #include <libxml++/libxml++.h>
 #include "types.h"
 #include "certificates.h"
@@ -29,21 +34,24 @@ namespace libdcp {
 
 namespace parse {
        class AssetMap;
+       class AssetMapAsset;
 }
        
 class Asset;
 class Reel;
 class XMLMetadata;
-       class Encryption;
+class MXFMetadata;
+class Encryption;
+class KDM;
        
 /** @brief A CPL within a DCP */
 class CPL
 {
 public:
        CPL (std::string directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
-       CPL (std::string directory, std::string file, boost::shared_ptr<const parse::AssetMap> asset_map, bool require_mxfs = true);
+       CPL (std::string directory, std::string file, std::list<PathAssetMap> asset_maps, bool require_mxfs = true);
 
-       void add_reel (boost::shared_ptr<const Reel> reel);
+       void add_reel (boost::shared_ptr<Reel> reel);
        
        /** @return the length in frames */
        int length () const {
@@ -57,7 +65,7 @@ public:
                return _content_kind;
        }
 
-       std::list<boost::shared_ptr<const Reel> > reels () const {
+       std::list<boost::shared_ptr<Reel> > reels () const {
                return _reels;
        }
 
@@ -74,22 +82,44 @@ public:
        }
 
        std::list<boost::shared_ptr<const Asset> > assets () const;
+
+       bool encrypted () const;
+
+       std::string id () const {
+               return _id;
+       }
        
        bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
        
-       void write_xml (XMLMetadata const &, boost::shared_ptr<Encryption>) const;
+       void write_xml (bool, XMLMetadata const &, boost::shared_ptr<Encryption>) const;
        void write_to_assetmap (xmlpp::Node *) const;
        void write_to_pkl (xmlpp::Node *) const;
 
+       /** Make a KDM for this CPL.
+        *  @param certificates
+        *  @param signer_key Filename of private key to sign the KDM with.
+        *  @param recipient_cert The certificate of the projector that this KDM is targeted at.  This will contain the
+        *  projector's public key (P) which is used to encrypt the content keys.
+        *  @param from Time that the KDM should be valid from.
+        *  @param until Time that the KDM should be valid until.
+        *  @param interop true to generate an interop KDM, false for SMPTE.
+        */
        boost::shared_ptr<xmlpp::Document> make_kdm (
-               CertificateChain const &,
-               std::string const &,
-               boost::shared_ptr<const Certificate>,
+               CertificateChain const & certificates,
+               boost::filesystem::path signer_key,
+               boost::shared_ptr<const Certificate> recipient_cert,
                boost::posix_time::ptime from,
-               boost::posix_time::ptime until
+               boost::posix_time::ptime until,
+               bool interop,
+               MXFMetadata const &,
+               XMLMetadata const &
                ) const;
+
+       void add_kdm (KDM const &);
        
 private:
+       std::pair<std::string, boost::shared_ptr<const parse::AssetMapAsset> > asset_from_id (std::list<PathAssetMap>, std::string id) const;
+       
        std::string _directory;
        /** the name of the DCP */
        std::string _name;
@@ -100,12 +130,14 @@ private:
        /** frames per second */
        int _fps;
        /** reels */
-       std::list<boost::shared_ptr<const Reel> > _reels;
+       std::list<boost::shared_ptr<Reel> > _reels;
 
        /** our UUID */
-       std::string _uuid;
+       std::string _id;
        /** a SHA1 digest of our XML */
        mutable std::string _digest;
 };
 
 }
+
+#endif