Bump version
[libdcp.git] / src / mxf.h
index a83d9fff72f6beebcd1a4ee1db32e36c5a37796c..f8be98446f4516ba8d1166bca5be7a965a65c94b 100644 (file)
--- a/src/mxf.h
+++ b/src/mxf.h
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
     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
 
 */
 
-#ifndef LIBDCP_MXF_ASSET_H
-#define LIBDCP_MXF_ASSET_H
+#ifndef LIBDCP_MXF_H
+#define LIBDCP_MXF_H
 
-#include <boost/signals2.hpp>
-#include "content.h"
+#include "asset.h"
 #include "key.h"
 #include "metadata.h"
 
+#include <boost/signals2.hpp>
+
 namespace ASDCP {
-       class AESEncContext;
        class AESDecContext;
+       class WriterInfo;
 }
 
+/* Undefine some stuff that the OS X 10.5 SDK defines */
+#undef Key
+#undef set_key
+
 namespace dcp
 {
 
-class MXFMetadata;     
+class MXFMetadata;
+class PictureAssetWriter;
 
 /** @class MXF
- *  @brief Parent class for classes which represent MXF files.
+ *  @brief Parent for classes which represent MXF files.
  */
-class MXF : public Content
+class MXF
 {
 public:
-       MXF (boost::filesystem::path file);
-       MXF (int edit_rate);
-       
-       ~MXF ();
-
-       virtual bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
-       virtual void write_to_cpl (xmlpp::Element *) const;
-       virtual std::string key_type () const = 0;
-       
-       /** Fill in a ADSCP::WriteInfo struct.
-        *  @param w struct to fill in.
-        */
-       void fill_writer_info (ASDCP::WriterInfo* w);
-
-       void set_progress (boost::signals2::signal<void (float)>* progress) {
-               _progress = progress;
-       }
+       MXF ();
+       virtual ~MXF ();
 
+       /** @return true if the data is encrypted */
        bool encrypted () const {
-               return !_key_id.empty ();
+               return static_cast<bool>(_key_id);
        }
 
+       /** Set the ID of the key that is used for encryption/decryption.
+        *  @param i key ID.
+        */
        void set_key_id (std::string i) {
                _key_id = i;
        }
 
-       std::string key_id () const {
+       /** @return the ID of the key used for encryption/decryption, if there is one */
+       boost::optional<std::string> key_id () const {
                return _key_id;
        }
-       
+
        void set_key (Key);
 
+       /** @return encryption/decryption key, if one has been set */
        boost::optional<Key> key () const {
                return _key;
        }
 
-       ASDCP::AESEncContext* encryption_context () const {
-               return _encryption_context;
-       }
-
+       /** Set the metadata that is written to the MXF file.
+        *  @param m Metadata.
+        */
        void set_metadata (MXFMetadata m) {
                _metadata = m;
        }
 
+       /** @return metadata from the MXF file */
        MXFMetadata metadata () const {
                return _metadata;
        }
 
-       /** Set whether or not the asset should be written in Interop mode.
-        *  @param i true to use interop.
-        */
-       void set_interop (bool i) {
-               _interop = i;
-       }
+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);
 
-       bool interop () const {
-               return _interop;
-       }
+       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;
 
-protected:
-       virtual std::string cpl_node_name () const = 0;
-       virtual std::pair<std::string, std::string> cpl_node_attribute () const {
-               return std::make_pair ("", "");
-       }
-       
-       /** Signal to emit to report progress, or 0 */
-       boost::signals2::signal<void (float)>* _progress;
-       ASDCP::AESEncContext* _encryption_context;
        ASDCP::AESDecContext* _decryption_context;
-       std::string _key_id;
+       /** 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;
        MXFMetadata _metadata;
-       bool _interop;
 };
 
 }