Some compilers don't like x = {} where x is a boost::optional<string>
[libdcp.git] / src / mxf.h
index 89e4f6352be687119d3a1d3f4f9addd0d2a5fa8b..82c86e8e0c5bc3d7e903bca9cc3206460350379b 100644 (file)
--- a/src/mxf.h
+++ b/src/mxf.h
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of libdcp.
 
     files in the program, then also delete it here.
 */
 
+
+/** @file  src/mxf.h
+ *  @brief MXF class
+ */
+
+
 #ifndef LIBDCP_MXF_H
 #define LIBDCP_MXF_H
 
+
 #include "asset.h"
 #include "key.h"
 #include "metadata.h"
-
+#include "dcp_assert.h"
 #include <boost/signals2.hpp>
 
+
 namespace ASDCP {
        class AESDecContext;
        struct WriterInfo;
 }
 
+
 /* Undefine some stuff that the OS X 10.5 SDK defines */
 #undef Key
 #undef set_key
 
+
 namespace dcp
 {
 
+
 class MXFMetadata;
 class PictureAssetWriter;
 
+
 /** @class MXF
- *  @brief Parent for classes which represent MXF files.
+ *  @brief Parent for classes which represent MXF files
  */
 class MXF
 {
 public:
+       MXF (Standard standard);
        virtual ~MXF () {}
 
        /** @return true if the data is encrypted */
@@ -80,13 +93,30 @@ public:
                return _key_id;
        }
 
-       void set_key (Key);
+       /** Set the (private) key that will be used to encrypt or decrypt this MXF's content
+        *  This is the top-secret key that is distributed (itself encrypted) to cinemas
+        *  via Key Delivery Messages (KDMs)
+        *  @param key Key to use
+        */
+       virtual void set_key (Key);
 
        /** @return encryption/decryption key, if one has been set */
        boost::optional<Key> key () const {
                return _key;
        }
 
+       /** Set the context ID to be used when encrypting.
+        *  @param id New ID.
+        */
+       void set_context_id (std::string id) {
+               _context_id = id;
+       }
+
+       /** @return context ID used when encrypting; this starts off as a random value */
+       std::string context_id () const {
+               return _context_id;
+       }
+
        /** Set the metadata that is written to the MXF file.
         *  @param m Metadata.
         */
@@ -99,24 +129,34 @@ public:
                return _metadata;
        }
 
+       Standard standard () const {
+               DCP_ASSERT (_standard);
+               return *_standard;
+       }
+
 protected:
        template <class P, class Q>
-       friend void start (PictureAssetWriter* writer, boost::shared_ptr<P> state, Standard standard, Q* mxf, uint8_t* data, int size);
+       friend void start (PictureAssetWriter* writer, std::shared_ptr<P> state, Q* mxf, uint8_t const * data, int size);
+
+       MXF ();
 
        std::string read_writer_info (ASDCP::WriterInfo const &);
        /** Fill in a ADSCP::WriteInfo struct.
         *  @param w struct to fill in.
-        *  @param standard INTEROP or SMPTE.
         */
-       void fill_writer_info (ASDCP::WriterInfo* w, std::string id, Standard standard) const;
+       void fill_writer_info (ASDCP::WriterInfo* w, std::string id) const;
 
        /** ID of the key used for encryption/decryption, if there is one */
        boost::optional<std::string> _key_id;
        /** Key used for encryption/decryption, if there is one */
        boost::optional<Key> _key;
+       std::string _context_id;
        MXFMetadata _metadata;
+       boost::optional<Standard> _standard;
 };
 
+
 }
 
+
 #endif