X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fmxf.h;h=f8be98446f4516ba8d1166bca5be7a965a65c94b;hb=d97e1600057d796c4163cecf28f9f04a6ea6402b;hp=3e9e666604ffafb5f427433a8ec75f0598e8c531;hpb=9fd79fb05fa47833ed431d83d73fd6d9a4a9f774;p=libdcp.git diff --git a/src/mxf.h b/src/mxf.h index 3e9e6666..f8be9844 100644 --- a/src/mxf.h +++ b/src/mxf.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington 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 @@ -17,108 +17,92 @@ */ -#ifndef LIBDCP_MXF_ASSET_H -#define LIBDCP_MXF_ASSET_H +#ifndef LIBDCP_MXF_H +#define LIBDCP_MXF_H -#include -#include "content_asset.h" +#include "asset.h" #include "key.h" #include "metadata.h" +#include + 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 ContentAsset +class MXF { public: - /** Construct an MXF. - * This class will not write anything to disk in this constructor, but subclasses may. - * - * @param directory Directory where MXF file is. - * @param file_name Name of MXF file. - */ - MXF (boost::filesystem::path directory, boost::filesystem::path file_name); - - ~MXF (); - - virtual bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function 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* progress) { - _progress = progress; - } + MXF (); + virtual ~MXF (); + /** @return true if the data is encrypted */ bool encrypted () const { - return !_key_id.empty (); + return static_cast(_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 key_id () const { return _key_id; } - + void set_key (Key); + /** @return encryption/decryption key, if one has been set */ boost::optional 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 + friend void start (PictureAssetWriter* writer, boost::shared_ptr

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 cpl_node_attribute () const { - return std::make_pair ("", ""); - } - - /** Signal to emit to report progress, or 0 */ - boost::signals2::signal* _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 _key_id; + /** Key used for encryption/decryption, if there is one */ boost::optional _key; MXFMetadata _metadata; - bool _interop; }; }