Switch away from the many-constructor-arguments approach to a hopefully simpler API.
authorCarl Hetherington <cth@carlh.net>
Wed, 25 Sep 2013 19:41:45 +0000 (20:41 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 25 Sep 2013 19:41:45 +0000 (20:41 +0100)
19 files changed:
examples/make_dcp.cc
src/asset.cc
src/asset.h
src/cpl.cc
src/mxf_asset.cc
src/mxf_asset.h
src/picture_asset.cc
src/picture_asset.h
src/picture_asset_writer.cc
src/picture_asset_writer.h
src/sound_asset.cc
src/sound_asset.h
test/dcp_test.cc
test/encryption_test.cc
test/error_test.cc
test/recovery_test.cc
test/round_trip_test.cc
test/wscript
wscript

index 7e8398679eb4dff8c7ef464862ce00627ec173de..2cf0a2694cad95755dbf8729912b7fda1542e00b 100644 (file)
@@ -64,19 +64,29 @@ main ()
        /* And add the CPL to the DCP */
        dcp.add_cpl (cpl);
 
-       /* Now make a `picture asset'.  This is a collection of the JPEG2000 files that make up the picture, one per frame.
-          Here we're using a function (video_frame) to obtain the name of the JPEG2000 file for each frame.
+       /* Now make a `picture asset'.  This is a collection of the JPEG2000 files that make up the picture; one per frame.
+          First, create the object.
+       */
+
+       boost::shared_ptr<libdcp::MonoPictureAsset> picture_asset (
+               new libdcp::MonoPictureAsset ("My Film DCP", "video.mxf")
+               );
+
+       /* Now set up its parameters; we have the frame rate, the
+          number of frames and the resolution of the frames;
+          1998x1080 is the DCI Flat specification for 2K projectors.
+       */
 
+       picture_asset->set_edit_rate (24);
+       picture_asset->set_intrinsic_duration (24);
+       picture_asset->set_size (libdcp::Size (1998, 1080));
+
+       /* Now we can create the asset itself.  Here using a function (video_frame) to obtain the name of the JPEG2000 file for each frame.
           The result will be an MXF file written to the directory "My Film DCP" (which should be the same as the DCP's
           directory above) called "video.mxf".
-
-          The other parameters specify the entry_point (the frame at which the projector should start showing the picture),
-          the frame rate, the number of frames and the resolution of the frames; 1998x1080 is the DCI Flat specification
-          for 2K projectors.
        */
-       boost::shared_ptr<libdcp::MonoPictureAsset> picture_asset (
-               new libdcp::MonoPictureAsset (video_frame, "My Film DCP", "video.mxf", 0, 24, 48, libdcp::Size (1998, 1080), false)
-               );
+
+       picture_asset->create (video_frame);
 
        /* Now we will create a `sound asset', which is made up of a WAV file for each channel of audio.  Here we're using
           stereo, so we add two WAV files to a vector.
@@ -94,9 +104,10 @@ main ()
        sound_files.push_back ("examples/sine_880_-12dB.wav");
 
        /* Now we can create the sound asset using these files */
-       boost::shared_ptr<libdcp::SoundAsset> sound_asset (
-               new libdcp::SoundAsset (sound_files, "My Film DCP", "audio.mxf", 0, 24, 48, false)
-               );
+       boost::shared_ptr<libdcp::SoundAsset> sound_asset (new libdcp::SoundAsset ("My Film DCP", "audio.mxf"));
+       sound_asset->set_edit_rate (24);
+       sound_asset->set_intrinsic_duration (48);
+       sound_asset->create (sound_files);
 
        /* Now that we have the assets, we can create a Reel to put them in and add it to the CPL */
        cpl->add_reel (
index 6e4901b5886b53c9a6981b6245a82691b4bc2a5e..4e17f855b9176d4e8eb30bffdb71065508dd9e71 100644 (file)
@@ -37,14 +37,14 @@ using namespace std;
 using namespace boost;
 using namespace libdcp;
 
-Asset::Asset (boost::filesystem::path directory, string file_name, int edit_rate, int intrinsic_duration)
+Asset::Asset (boost::filesystem::path directory, string file_name)
        : _directory (directory)
        , _file_name (file_name)
        , _uuid (make_uuid ())
-       , _edit_rate (edit_rate)
+       , _edit_rate (0)
        , _entry_point (0)
-       , _intrinsic_duration (intrinsic_duration)
-       , _duration (intrinsic_duration)
+       , _intrinsic_duration (0)
+       , _duration (0)
 {
        if (_file_name.empty ()) {
                _file_name = _uuid + ".xml";
index 940ed5483934736c524a5ecb827d3525852efe24..ec1385e673bda2a5123982c8ba3bf1ad1b2ad3f3 100644 (file)
@@ -53,7 +53,7 @@ public:
         *  @param directory Directory where our XML or MXF file is.
         *  @param file_name Name of our file within directory, or empty to make one up based on UUID.
         */
-       Asset (boost::filesystem::path directory, std::string file_name = "", int edit_rate = 0, int intrinsic_duration = 0);
+       Asset (boost::filesystem::path directory, std::string file_name = "");
 
        virtual ~Asset() {}
 
@@ -123,6 +123,10 @@ public:
                _intrinsic_duration = d;
        }
 
+       void set_edit_rate (int r) {
+               _edit_rate = r;
+       }
+
        virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const;
 
 protected:
index 5d57c7c78c3ecd2fe195d6baa84071492d861210..48d08035fb18b8d7e99b194918c2c8b059533a39 100644 (file)
@@ -107,15 +107,13 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass
 
                if (!(*i)->asset_list->main_stereoscopic_picture && p->edit_rate == p->frame_rate) {
 
-                       pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, p->id);
-
                        try {
-                               picture.reset (new MonoPictureAsset (
-                                                      asset.first,
-                                                      asset.second->chunks.front()->path
-                                                      )
-                                       );
+                               pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, p->id);
 
+                               picture.reset (new MonoPictureAsset (asset.first, asset.second->chunks.front()->path));
+
+                               picture->read ();
+                               picture->set_edit_rate (_fps);
                                picture->set_entry_point (p->entry_point);
                                picture->set_duration (p->duration);
                                if (p->key_id.length() > 9) {
@@ -132,14 +130,10 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass
                        try {
                                pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, p->id);
 
-                               picture.reset (new StereoPictureAsset (
-                                                      asset.first,
-                                                      asset.second->chunks.front()->path,
-                                                      _fps,
-                                                      p->duration
-                                                      )
-                                       );
+                               picture.reset (new StereoPictureAsset (asset.first, asset.second->chunks.front()->path));
 
+                               picture->read ();
+                               picture->set_edit_rate (_fps);
                                picture->set_entry_point (p->entry_point);
                                picture->set_duration (p->duration);
                                if (p->key_id.length() > 9) {
@@ -160,14 +154,10 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass
                        try {
                                pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, (*i)->asset_list->main_sound->id);
                        
-                               sound.reset (new SoundAsset (
-                                                    asset.first,
-                                                    asset.second->chunks.front()->path
-                                                    )
-                                       );
-
+                               sound.reset (new SoundAsset (asset.first, asset.second->chunks.front()->path));
                                shared_ptr<parse::MainSound> s = (*i)->asset_list->main_sound;
 
+                               sound->read ();
                                sound->set_entry_point (s->entry_point);
                                sound->set_duration (s->duration);
                                if (s->key_id.length() > 9) {
@@ -185,11 +175,7 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass
                        
                        pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, (*i)->asset_list->main_subtitle->id);
 
-                       subtitle.reset (new SubtitleAsset (
-                                               asset.first,
-                                               asset.second->chunks.front()->path
-                                               )
-                               );
+                       subtitle.reset (new SubtitleAsset (asset.first, asset.second->chunks.front()->path));
 
                        subtitle->set_entry_point ((*i)->asset_list->main_subtitle->entry_point);
                        subtitle->set_duration ((*i)->asset_list->main_subtitle->duration);
index 956d38f92df7c1adc86fac6da465c8577e47d70a..7bffc9f2be7bd5a1e8580ad74b99bcbdfba95aef 100644 (file)
@@ -48,19 +48,11 @@ MXFAsset::MXFAsset (boost::filesystem::path directory, string file_name)
        , _progress (0)
        , _encryption_context (0)
        , _decryption_context (0)
+       , _interop (false)
 {
 
 }
 
-MXFAsset::MXFAsset (boost::filesystem::path directory, string file_name, boost::signals2::signal<void (float)>* progress, int edit_rate, int intrinsic_duration) 
-       : Asset (directory, file_name, edit_rate, intrinsic_duration)
-       , _progress (progress)
-       , _encryption_context (0)
-       , _decryption_context (0)
-{
-       
-}
-
 MXFAsset::~MXFAsset ()
 {
        delete _encryption_context;
index e566c32c7afde49262594434732f108fff7ec54c..b71442817a8bf9b023bbfdd70c65ff5dc563ab9d 100644 (file)
@@ -23,6 +23,7 @@
 #include <boost/signals2.hpp>
 #include "asset.h"
 #include "key.h"
+#include "metadata.h"
 
 namespace ASDCP {
        class AESEncContext;
@@ -46,29 +47,12 @@ public:
         */
        MXFAsset (boost::filesystem::path directory, std::string file_name);
        
-       /** Construct an MXFAsset.
-        *  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.
-        *  @param progress Signal to use to inform of progress, or 0.
-        *  @param edit_rate Edit rate in frames per second (usually equal to the video frame rate).
-        *  @param intrinsic_duration Duration of the whole asset in frames.
-        */
-       MXFAsset (
-               boost::filesystem::path directory,
-               std::string file_name,
-               boost::signals2::signal<void (float)>* progress,
-               int edit_rate,
-               int intrinsic_duration
-               );
-
        ~MXFAsset ();
 
        virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
-
        virtual void write_to_cpl (xmlpp::Element *, bool interop) const;
-
+       virtual std::string key_type () const = 0;
+       
        /** Fill in a ADSCP::WriteInfo struct.
         *  @param w struct to fill in.
         *  @param uuid uuid to use.
@@ -76,6 +60,10 @@ public:
         */
        void fill_writer_info (ASDCP::WriterInfo* w, std::string uuid, bool interop, MXFMetadata const & metadata);
 
+       void set_progress (boost::signals2::signal<void (float)>* progress) {
+               _progress = progress;
+       }
+
        bool encrypted () const {
                return !_key_id.empty ();
        }
@@ -98,8 +86,22 @@ public:
                return _encryption_context;
        }
 
-       virtual std::string key_type () const = 0;
-       
+       void set_metadata (MXFMetadata m) {
+               _metadata = m;
+       }
+
+       MXFMetadata metadata () const {
+               return _metadata;
+       }
+
+       void set_interop (bool i) {
+               _interop = i;
+       }
+
+       bool interop () const {
+               return _interop;
+       }
+
 protected:
        virtual std::string cpl_node_name () const = 0;
        virtual std::pair<std::string, std::string> cpl_node_attribute (bool) const {
@@ -112,6 +114,8 @@ protected:
        ASDCP::AESDecContext* _decryption_context;
        std::string _key_id;
        boost::optional<Key> _key;
+       MXFMetadata _metadata;
+       bool _interop;
 };
 
 }
index 78d7576ddc72774a2d90ce83c29a6a6949610f19..97fce2abf1c497fb0ef0f6a35223c84057507a55 100644 (file)
@@ -54,57 +54,12 @@ using boost::dynamic_pointer_cast;
 using boost::lexical_cast;
 using namespace libdcp;
 
-PictureAsset::PictureAsset (
-       boost::filesystem::path directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int intrinsic_duration, Size size
-       )
-       : MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration)
-       , _size (size)
-{
-
-}
-
 PictureAsset::PictureAsset (boost::filesystem::path directory, string mxf_name)
        : MXFAsset (directory, mxf_name)
 {
 
 }
 
-string
-MonoPictureAsset::cpl_node_name () const
-{
-       return "MainPicture";
-}
-
-int
-MonoPictureAsset::edit_rate_factor () const
-{
-       return 1;
-}
-
-string
-StereoPictureAsset::cpl_node_name () const
-{
-       return "msp-cpl:MainStereoscopicPicture";
-}
-
-pair<string, string>
-StereoPictureAsset::cpl_node_attribute (bool interop) const
-{
-       if (interop) {
-               return make_pair ("xmlns:msp-cpl", "http://www.digicine.com/schemas/437-Y/2007/Main-Stereo-Picture-CPL");
-       } else {
-               return make_pair ("xmlns:msp-cpl", "http://www.smpte-ra.org/schemas/429-10/2008/Main-Stereo-Picture-CPL");
-       }
-
-       return make_pair ("", "");
-}
-
-int
-StereoPictureAsset::edit_rate_factor () const
-{
-       return 2;
-}
-
 void
 PictureAsset::write_to_cpl (xmlpp::Element* node, bool interop) const
 {
@@ -189,67 +144,20 @@ PictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost:
        return true;
 }
 
-
-MonoPictureAsset::MonoPictureAsset (
-       boost::function<boost::filesystem::path (int)> get_path,
-       boost::filesystem::path directory,
-       string mxf_name,
-       boost::signals2::signal<void (float)>* progress,
-       int fps,
-       int intrinsic_duration,
-       Size size,
-       bool interop,
-       MXFMetadata const & metadata
-       )
-       : PictureAsset (directory, mxf_name, progress, fps, intrinsic_duration, size)
+MonoPictureAsset::MonoPictureAsset (boost::filesystem::path directory, string mxf_name)
+       : PictureAsset (directory, mxf_name)
 {
-       construct (get_path, interop, metadata);
-}
 
-MonoPictureAsset::MonoPictureAsset (
-       vector<boost::filesystem::path> const & files,
-       boost::filesystem::path directory,
-       string mxf_name,
-       boost::signals2::signal<void (float)>* progress,
-       int fps,
-       int intrinsic_duration,
-       Size size,
-       bool interop,
-       MXFMetadata const & metadata
-       )
-       : PictureAsset (directory, mxf_name, progress, fps, intrinsic_duration, size)
-{
-       construct (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files), interop, metadata);
 }
 
-MonoPictureAsset::MonoPictureAsset (boost::filesystem::path directory, string mxf_name, int fps, Size size)
-       : PictureAsset (directory, mxf_name, 0, fps, 0, size)
+void
+MonoPictureAsset::create (vector<boost::filesystem::path> const & files)
 {
-
-}
-
-MonoPictureAsset::MonoPictureAsset (boost::filesystem::path directory, string mxf_name)
-       : PictureAsset (directory, mxf_name)
-{
-       ASDCP::JP2K::MXFReader reader;
-       if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) {
-               boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string()));
-       }
-       
-       ASDCP::JP2K::PictureDescriptor desc;
-       if (ASDCP_FAILURE (reader.FillPictureDescriptor (desc))) {
-               boost::throw_exception (DCPReadError ("could not read video MXF information"));
-       }
-
-       _size.width = desc.StoredWidth;
-       _size.height = desc.StoredHeight;
-       _edit_rate = desc.EditRate.Numerator;
-       assert (desc.EditRate.Denominator == 1);
-       _intrinsic_duration = desc.ContainerDuration;
+       create (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files));
 }
 
 void
-MonoPictureAsset::construct (boost::function<boost::filesystem::path (int)> get_path, bool interop, MXFMetadata const & metadata)
+MonoPictureAsset::create (boost::function<boost::filesystem::path (int)> get_path)
 {
        ASDCP::JP2K::CodestreamParser j2k_parser;
        ASDCP::JP2K::FrameBuffer frame_buffer (4 * Kumu::Megabyte);
@@ -262,7 +170,7 @@ MonoPictureAsset::construct (boost::function<boost::filesystem::path (int)> get_
        picture_desc.EditRate = ASDCP::Rational (_edit_rate, 1);
        
        ASDCP::WriterInfo writer_info;
-       fill_writer_info (&writer_info, _uuid, interop, metadata);
+       fill_writer_info (&writer_info, _uuid, _interop, _metadata);
        
        ASDCP::JP2K::MXFWriter mxf_writer;
        if (ASDCP_FAILURE (mxf_writer.OpenWrite (path().string().c_str(), writer_info, picture_desc, 16384, false))) {
@@ -291,6 +199,26 @@ MonoPictureAsset::construct (boost::function<boost::filesystem::path (int)> get_
        }
 }
 
+void
+MonoPictureAsset::read ()
+{
+       ASDCP::JP2K::MXFReader reader;
+       if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) {
+               boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string()));
+       }
+       
+       ASDCP::JP2K::PictureDescriptor desc;
+       if (ASDCP_FAILURE (reader.FillPictureDescriptor (desc))) {
+               boost::throw_exception (DCPReadError ("could not read video MXF information"));
+       }
+
+       _size.width = desc.StoredWidth;
+       _size.height = desc.StoredHeight;
+       _edit_rate = desc.EditRate.Numerator;
+       assert (desc.EditRate.Denominator == 1);
+       _intrinsic_duration = desc.ContainerDuration;
+}
+
 boost::filesystem::path
 MonoPictureAsset::path_from_list (int f, vector<boost::filesystem::path> const & files) const
 {
@@ -303,7 +231,6 @@ MonoPictureAsset::get_frame (int n) const
        return shared_ptr<const MonoPictureFrame> (new MonoPictureFrame (path().string(), n, _decryption_context));
 }
 
-
 bool
 MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
 {
@@ -436,8 +363,14 @@ PictureAsset::frame_buffer_equals (
 }
 
 
-StereoPictureAsset::StereoPictureAsset (boost::filesystem::path directory, string mxf_name, int fps, int intrinsic_duration)
-       : PictureAsset (directory, mxf_name, 0, fps, intrinsic_duration, Size (0, 0))
+StereoPictureAsset::StereoPictureAsset (boost::filesystem::path directory, string mxf_name)
+       : PictureAsset (directory, mxf_name)
+{
+       
+}
+
+void
+StereoPictureAsset::read ()
 {
        ASDCP::JP2K::MXFSReader reader;
        if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) {
@@ -460,10 +393,10 @@ StereoPictureAsset::get_frame (int n) const
 }
 
 shared_ptr<PictureAssetWriter>
-MonoPictureAsset::start_write (bool overwrite, bool interop, MXFMetadata const & metadata)
+MonoPictureAsset::start_write (bool overwrite)
 {
        /* XXX: can't we use shared_ptr here? */
-       return shared_ptr<MonoPictureAssetWriter> (new MonoPictureAssetWriter (this, overwrite, interop, metadata));
+       return shared_ptr<MonoPictureAssetWriter> (new MonoPictureAssetWriter (this, overwrite));
 }
 
 string
@@ -472,15 +405,45 @@ PictureAsset::key_type () const
        return "MDIK";
 }
 
-StereoPictureAsset::StereoPictureAsset (boost::filesystem::path directory, string mxf_name, int fps, Size size)
-       : PictureAsset (directory, mxf_name, 0, fps, 0, size)
+shared_ptr<PictureAssetWriter>
+StereoPictureAsset::start_write (bool overwrite)
 {
+       return shared_ptr<StereoPictureAssetWriter> (new StereoPictureAssetWriter (this, overwrite));
+}
 
+string
+MonoPictureAsset::cpl_node_name () const
+{
+       return "MainPicture";
 }
 
-shared_ptr<PictureAssetWriter>
-StereoPictureAsset::start_write (bool overwrite, bool interop, MXFMetadata const & metadata)
+int
+MonoPictureAsset::edit_rate_factor () const
+{
+       return 1;
+}
+
+string
+StereoPictureAsset::cpl_node_name () const
 {
-       return shared_ptr<StereoPictureAssetWriter> (new StereoPictureAssetWriter (this, overwrite, interop, metadata));
+       return "msp-cpl:MainStereoscopicPicture";
+}
+
+pair<string, string>
+StereoPictureAsset::cpl_node_attribute (bool interop) const
+{
+       if (interop) {
+               return make_pair ("xmlns:msp-cpl", "http://www.digicine.com/schemas/437-Y/2007/Main-Stereo-Picture-CPL");
+       } else {
+               return make_pair ("xmlns:msp-cpl", "http://www.smpte-ra.org/schemas/429-10/2008/Main-Stereo-Picture-CPL");
+       }
+
+       return make_pair ("", "");
+}
+
+int
+StereoPictureAsset::edit_rate_factor () const
+{
+       return 2;
 }
 
index 495c6647ebc89cf94fbe295448f3decf9fcc49a6..d1b097fab6d49b9e757a77a46f9b5729445c6e0b 100644 (file)
@@ -48,31 +48,15 @@ public:
         */
        PictureAsset (boost::filesystem::path directory, std::string mxf_name);
 
-       /** Construct a PictureAsset.
-        *  This class will not write anything to disk in this constructor, but subclasses may.
-        *
-        *  @param directory Directory where MXF file is.
-        *  @param mxf_name Name of MXF file.
-        *  @param progress Signal to use to inform of progres, or 0.
-        *  @param fps Video frames per second.
-        *  @param intrinsic_duration Total number of frames in the asset.
-        *  @param size Size of video frame images in pixels.
-        */
-       PictureAsset (
-               boost::filesystem::path directory,
-               std::string mxf_name,
-               boost::signals2::signal<void (float)>* progress,
-               int fps,
-               int intrinsic_duration,
-               Size
-               );
-
        /** Start a progressive write to this asset.
         *  @param overwrite true to overwrite an existing MXF file; in this mode, writing can be resumed to a partially-written MXF; false if the
         *  MXF file does not exist.
-        *  @param metadata MXF metadata to use.
         */
-       virtual boost::shared_ptr<PictureAssetWriter> start_write (bool overwrite, bool interop, MXFMetadata const & metadata = MXFMetadata ()) = 0;
+       virtual boost::shared_ptr<PictureAssetWriter> start_write (bool overwrite) = 0;
+
+       virtual void read () = 0;
+       virtual void create (std::vector<boost::filesystem::path> const &) {}
+       virtual void create (boost::function<boost::filesystem::path (int)>) {}
        
        bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
 
@@ -80,6 +64,10 @@ public:
                return _size;
        }
 
+       void set_size (Size s) {
+               _size = s;
+       }
+
        void write_to_cpl (xmlpp::Element *, bool) const;
 
 protected:     
@@ -101,70 +89,14 @@ private:
 class MonoPictureAsset : public PictureAsset
 {
 public:
-       /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
-        *  This may take some time; progress is indicated by emission of the Progress signal.
-        *
-        *  @param files Pathnames of JPEG2000 files, in frame order.
-        *  @param directory Directory in which to create MXF file.
-        *  @param mxf_name Name of MXF file to create.
-        *  @param progress Signal to inform of progress.
-        *  @param fps Video frames per second.
-        *  @param intrinsic_duration Total number of frames in the asset.
-        *  @param size Size of images in pixels.
-        */
-       MonoPictureAsset (
-               std::vector<boost::filesystem::path> const & files,
-               boost::filesystem::path directory,
-               std::string mxf_name,
-               boost::signals2::signal<void (float)>* progress,
-               int fps,
-               int intrinsic_duration,
-               Size size,
-               bool interop,
-               MXFMetadata const & metadata = MXFMetadata ()
-               );
-
-       /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
-        *  This may take some time; progress is indicated by emission of the Progress signal.
-        *
-        *  @param get_path Functor which returns a JPEG2000 file path for a given frame (frames counted from 0).
-        *  @param directory Directory in which to create MXF file.
-        *  @param mxf_name Name of MXF file to create.
-        *  @param progress Signal to inform of progress.
-        *  @param fps Video frames per second.
-        *  @param intrinsic_duration Total number of frames in the asset.
-        *  @param size Size of images in pixels.
-        */
-       MonoPictureAsset (
-               boost::function<boost::filesystem::path (int)> get_path,
-               boost::filesystem::path directory,
-               std::string mxf_name,
-               boost::signals2::signal<void (float)>* progress,
-               int fps,
-               int intrinsic_duration,
-               Size size,
-               bool interop,
-               MXFMetadata const & metadata = MXFMetadata ()
-               );
-
-       /** Construct a MonoPictureAsset, reading the MXF from disk.
-        *  @param directory Directory that the MXF is in.
-        *  @param mxf_name The filename of the MXF within `directory'.
-        */
        MonoPictureAsset (boost::filesystem::path directory, std::string mxf_name);
 
-       /** Construct a MonoPictureAsset for progressive writing using
-        *  start_write() and a MonoPictureAssetWriter.
-        *
-        *  @param directory Directory to put the MXF in.
-        *  @param mxf_name Filename of the MXF within this directory.
-        *  @param fps Video frames per second.
-        *  @param size Size in pixels that the picture frames will be.
-        */
-       MonoPictureAsset (boost::filesystem::path directory, std::string mxf_name, int fps, Size size);
+       void read ();
+       void create (std::vector<boost::filesystem::path> const & files);
+       void create (boost::function<boost::filesystem::path (int)> get_path);
 
        /** Start a progressive write to a MonoPictureAsset */
-       boost::shared_ptr<PictureAssetWriter> start_write (bool, bool, MXFMetadata const & metadata = MXFMetadata ());
+       boost::shared_ptr<PictureAssetWriter> start_write (bool);
 
        boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
        bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
@@ -180,20 +112,12 @@ private:
 class StereoPictureAsset : public PictureAsset
 {
 public:
-       StereoPictureAsset (boost::filesystem::path directory, std::string mxf_name, int fps, int intrinsic_duration);
-
-       /** Construct a StereoPictureAsset for progressive writing using
-        *  start_write() and a StereoPictureAssetWriter.
-        *
-        *  @param directory Directory to put the MXF in.
-        *  @param mxf_name Filename of the MXF within this directory.
-        *  @param fps Video frames per second.
-        *  @param size Size in pixels that the picture frames will be.
-        */
-       StereoPictureAsset (boost::filesystem::path directory, std::string mxf_name, int fps, Size size);
+       StereoPictureAsset (boost::filesystem::path directory, std::string mxf_name);
 
+       void read ();
+       
        /** Start a progressive write to a StereoPictureAsset */
-       boost::shared_ptr<PictureAssetWriter> start_write (bool, bool, MXFMetadata const & metadata = MXFMetadata ());
+       boost::shared_ptr<PictureAssetWriter> start_write (bool);
 
        boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
        bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
index f5767e3d4c02d83aca338741d17fb9909ee3933b..ca5a3e961605e1b43df84d437967af442d5ba110 100644 (file)
@@ -52,14 +52,12 @@ FrameInfo::write (ostream& s)
 }
 
 
-PictureAssetWriter::PictureAssetWriter (PictureAsset* asset, bool overwrite, bool interop, MXFMetadata const & metadata)
+PictureAssetWriter::PictureAssetWriter (PictureAsset* asset, bool overwrite)
        : _asset (asset)
        , _frames_written (0)
        , _started (false)
        , _finalized (false)
        , _overwrite (overwrite)
-       , _interop (interop)
-       , _metadata (metadata)
 {
 
 }
@@ -90,15 +88,15 @@ struct StereoPictureAssetWriter::ASDCPState : public ASDCPStateBase
 /** @param a Asset to write to.  `a' must not be deleted while
  *  this writer class still exists, or bad things will happen.
  */
-MonoPictureAssetWriter::MonoPictureAssetWriter (PictureAsset* asset, bool overwrite, bool interop, MXFMetadata const & metadata)
-       : PictureAssetWriter (asset, overwrite, interop, metadata)
+MonoPictureAssetWriter::MonoPictureAssetWriter (PictureAsset* asset, bool overwrite)
+       : PictureAssetWriter (asset, overwrite)
        , _state (new MonoPictureAssetWriter::ASDCPState)
 {
        _state->encryption_context = asset->encryption_context ();
 }
 
-StereoPictureAssetWriter::StereoPictureAssetWriter (PictureAsset* asset, bool overwrite, bool interop, MXFMetadata const & metadata)
-       : PictureAssetWriter (asset, overwrite, interop, metadata)
+StereoPictureAssetWriter::StereoPictureAssetWriter (PictureAsset* asset, bool overwrite)
+       : PictureAssetWriter (asset, overwrite)
        , _state (new StereoPictureAssetWriter::ASDCPState)
        , _next_eye (EYE_LEFT)
 {
@@ -115,7 +113,7 @@ void libdcp::start (PictureAssetWriter* writer, shared_ptr<P> state, Q* asset, u
        state->j2k_parser.FillPictureDescriptor (state->picture_descriptor);
        state->picture_descriptor.EditRate = ASDCP::Rational (asset->edit_rate(), 1);
        
-       asset->fill_writer_info (&state->writer_info, asset->uuid(), writer->_interop, writer->_metadata);
+       asset->fill_writer_info (&state->writer_info, asset->uuid(), writer->_asset->interop(), writer->_asset->metadata());
        
        if (ASDCP_FAILURE (state->mxf_writer.OpenWrite (
                                   asset->path().string().c_str(),
index b6d2e92c8cca02fa0f4bde9ec4db4ed0b739581f..fd4f81eee7507285d59b4101ac2741e870c016f9 100644 (file)
@@ -58,7 +58,7 @@ protected:
        template <class P, class Q>
        friend void start (PictureAssetWriter *, boost::shared_ptr<P>, Q *, uint8_t *, int);
 
-       PictureAssetWriter (PictureAsset *, bool, bool, MXFMetadata const &);
+       PictureAssetWriter (PictureAsset *, bool);
 
        PictureAsset* _asset;
        
@@ -71,8 +71,6 @@ protected:
        /** true if finalize() has been called */
        bool _finalized;
        bool _overwrite;
-       bool _interop;
-       MXFMetadata _metadata;
 };
 
 /** A helper class for writing to MonoPictureAssets progressively (i.e. writing frame-by-frame,
@@ -95,7 +93,7 @@ public:
 private:
        friend class MonoPictureAsset;
 
-       MonoPictureAssetWriter (PictureAsset *, bool, bool, MXFMetadata const &);
+       MonoPictureAssetWriter (PictureAsset *, bool);
        void start (uint8_t *, int);
 
        /* do this with an opaque pointer so we don't have to include
@@ -126,7 +124,7 @@ public:
 private:
        friend class StereoPictureAsset;
 
-       StereoPictureAssetWriter (PictureAsset *, bool, bool, MXFMetadata const &);
+       StereoPictureAssetWriter (PictureAsset *, bool);
        void start (uint8_t *, int);
 
        /* do this with an opaque pointer so we don't have to include
index 984d8f0f148cd2e9f228b506a86cb09d87cc8904..ec82752c290ea6f68efb912942f4d4e654169b94 100644 (file)
@@ -42,48 +42,22 @@ using boost::shared_ptr;
 using boost::lexical_cast;
 using namespace libdcp;
 
-SoundAsset::SoundAsset (
-       vector<boost::filesystem::path> const & files,
-       boost::filesystem::path directory,
-       string mxf_name,
-       boost::signals2::signal<void (float)>* progress,
-       int fps,
-       int intrinsic_duration,
-       bool interop,
-       MXFMetadata const & metadata
-       )
-       : MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration)
-       , _channels (files.size ())
+SoundAsset::SoundAsset (boost::filesystem::path directory, string mxf_name)
+       : MXFAsset (directory, mxf_name)
+       , _channels (0)
        , _sampling_rate (0)
 {
-       assert (_channels);
-       
-       construct (boost::bind (&SoundAsset::path_from_channel, this, _1, files), interop, metadata);
+
 }
 
-SoundAsset::SoundAsset (
-       boost::function<boost::filesystem::path (Channel)> get_path,
-       boost::filesystem::path directory,
-       string mxf_name,
-       boost::signals2::signal<void (float)>* progress,
-       int fps,
-       int intrinsic_duration,
-       int channels,
-       bool interop,
-       MXFMetadata const & metadata
-       )
-       : MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration)
-       , _channels (channels)
-       , _sampling_rate (0)
+void
+SoundAsset::create (vector<boost::filesystem::path> const & files)
 {
-       assert (_channels);
-       
-       construct (get_path, interop, metadata);
+       create (boost::bind (&SoundAsset::path_from_channel, this, _1, files));
 }
 
-SoundAsset::SoundAsset (boost::filesystem::path directory, string mxf_name)
-       : MXFAsset (directory, mxf_name)
-       , _channels (0)
+void
+SoundAsset::read ()
 {
        ASDCP::PCM::MXFReader reader;
        if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) {
@@ -102,14 +76,6 @@ SoundAsset::SoundAsset (boost::filesystem::path directory, string mxf_name)
        _intrinsic_duration = desc.ContainerDuration;
 }
 
-SoundAsset::SoundAsset (boost::filesystem::path directory, string mxf_name, int fps, int channels, int sampling_rate)
-       : MXFAsset (directory, mxf_name, 0, fps, 0)
-       , _channels (channels)
-       , _sampling_rate (sampling_rate)
-{
-
-}
-
 boost::filesystem::path
 SoundAsset::path_from_channel (Channel channel, vector<boost::filesystem::path> const & files)
 {
@@ -119,10 +85,11 @@ SoundAsset::path_from_channel (Channel channel, vector<boost::filesystem::path>
 }
 
 void
-SoundAsset::construct (boost::function<boost::filesystem::path (Channel)> get_path, bool interop, MXFMetadata const & metadata)
+SoundAsset::create (boost::function<boost::filesystem::path (Channel)> get_path)
 {
        ASDCP::Rational asdcp_edit_rate (_edit_rate, 1);
 
+       assert (_channels > 0);
        ASDCP::PCM::WAVParser pcm_parser_channel[_channels];
        if (pcm_parser_channel[0].OpenRead (get_path(LEFT).c_str(), asdcp_edit_rate)) {
                boost::throw_exception (FileError ("could not open WAV file for reading", get_path(LEFT)));
@@ -172,7 +139,7 @@ SoundAsset::construct (boost::function<boost::filesystem::path (Channel)> get_pa
        frame_buffer.Size (ASDCP::PCM::CalcFrameBufferSize (audio_desc));
 
        ASDCP::WriterInfo writer_info;
-       MXFAsset::fill_writer_info (&writer_info, _uuid, interop, metadata);
+       MXFAsset::fill_writer_info (&writer_info, _uuid, _interop, _metadata);
 
        ASDCP::PCM::MXFWriter mxf_writer;
        if (ASDCP_FAILURE (mxf_writer.OpenWrite (path().string().c_str(), writer_info, audio_desc))) {
@@ -304,10 +271,10 @@ SoundAsset::get_frame (int n) const
 }
 
 shared_ptr<SoundAssetWriter>
-SoundAsset::start_write (bool interop, MXFMetadata const & metadata)
+SoundAsset::start_write ()
 {
        /* XXX: can't we use a shared_ptr here? */
-       return shared_ptr<SoundAssetWriter> (new SoundAssetWriter (this, interop, metadata));
+       return shared_ptr<SoundAssetWriter> (new SoundAssetWriter (this));
 }
 
 struct SoundAssetWriter::ASDCPState
@@ -319,13 +286,12 @@ struct SoundAssetWriter::ASDCPState
        ASDCP::AESEncContext* encryption_context;
 };
 
-SoundAssetWriter::SoundAssetWriter (SoundAsset* a, bool interop, MXFMetadata const & m)
+SoundAssetWriter::SoundAssetWriter (SoundAsset* a)
        : _state (new SoundAssetWriter::ASDCPState)
        , _asset (a)
        , _finalized (false)
        , _frames_written (0)
        , _frame_buffer_offset (0)
-       , _metadata (m)
 {
        _state->encryption_context = a->encryption_context ();
        
@@ -344,7 +310,7 @@ SoundAssetWriter::SoundAssetWriter (SoundAsset* a, bool interop, MXFMetadata con
        _state->frame_buffer.Size (ASDCP::PCM::CalcFrameBufferSize (_state->audio_desc));
        memset (_state->frame_buffer.Data(), 0, _state->frame_buffer.Capacity());
        
-       _asset->fill_writer_info (&_state->writer_info, _asset->uuid (), interop, _metadata);
+       _asset->fill_writer_info (&_state->writer_info, _asset->uuid (), _asset->interop(), _asset->metadata());
        
        if (ASDCP_FAILURE (_state->mxf_writer.OpenWrite (_asset->path().string().c_str(), _state->writer_info, _state->audio_desc))) {
                boost::throw_exception (FileError ("could not open audio MXF for writing", _asset->path().string()));
index 1d2a4755eb158af0019a9db69d3dda0ee10747f9..d41b72d5f995adc3862529f97bfa735be606d743 100644 (file)
@@ -43,7 +43,7 @@ public:
 private:
        friend class SoundAsset;
 
-       SoundAssetWriter (SoundAsset *, bool interop, MXFMetadata const &);
+       SoundAssetWriter (SoundAsset *);
 
        /* no copy construction */
        SoundAssetWriter (SoundAssetWriter const &);
@@ -62,76 +62,27 @@ private:
        bool _finalized;
        int _frames_written;
        int _frame_buffer_offset;
-       MXFMetadata _metadata;
 };
 
 /** @brief An asset made up of WAV files */
 class SoundAsset : public MXFAsset
 {
 public:
-       /** Construct a SoundAsset, generating the MXF from some WAV files.
-        *  This may take some time; progress is indicated by emission of the Progress signal.
-        *  @param files Pathnames of sound files, in the order Left, Right, Centre, Lfe (sub), Left surround, Right surround.
-        *  @param directory Directory in which to create MXF file.
-        *  @param mxf_name Name of MXF file to create.
-        *  @param progress Signal to inform of progress.
-        *  @param fps Frames per second.
-        *  @param length Length in frames.
-        *  @param start_frame Frame in the source to start writing from.
-        *  @param intrinsic_duration Length of the whole asset in frames.
-        *  Note that this is different to entry_point in that the asset will contain no data before start_frame.
-        */
-       SoundAsset (
-               std::vector<boost::filesystem::path> const & files,
-               boost::filesystem::path directory,
-               std::string mxf_name,
-               boost::signals2::signal<void (float)>* progress,
-               int fps,
-               int intrinsic_duration,
-               bool interop,
-               MXFMetadata const & metadata = MXFMetadata ()
-               );
-
-       /** Construct a SoundAsset, generating the MXF from some WAV files.
-        *  This may take some time; progress is indicated by emission of the Progress signal.
-        *  @param get_path Functor which returns a WAV file path for a given channel.
-        *  @param directory Directory in which to create MXF file.
-        *  @param mxf_name Name of MXF file to create.
-        *  @param progress Signal to inform of progress.
-        *  @param fps Frames per second.
-        *  @param intrinsic_duration Length of the whole asset in frames.
-        *  @param channels Number of audio channels.
-        */
-       SoundAsset (
-               boost::function<boost::filesystem::path (Channel)> get_path,
-               boost::filesystem::path directory,
-               std::string mxf_name,
-               boost::signals2::signal<void (float)>* progress,
-               int fps,
-               int intrinsic_duration,
-               int channels,
-               bool interop,
-               MXFMetadata const & metadata = MXFMetadata ()
-               );
-
-       SoundAsset (
-               boost::filesystem::path directory,
-               std::string mxf_name
-               );
-
-       SoundAsset (
-               boost::filesystem::path directory,
-               std::string mxf_name,
-               int fps,
-               int channels,
-               int sampling_rate
-               );
-
-       boost::shared_ptr<SoundAssetWriter> start_write (bool, MXFMetadata const & metadata = MXFMetadata ());
+       SoundAsset (boost::filesystem::path directory, std::string mxf_name);
+
+       void read ();
+       void create (std::vector<boost::filesystem::path> const & files);
+       void create (boost::function<boost::filesystem::path (Channel)> get_path);
+
+       boost::shared_ptr<SoundAssetWriter> start_write ();
        
        bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
 
        boost::shared_ptr<const SoundFrame> get_frame (int n) const;
+
+       void set_channels (int c) {
+               _channels = c;
+       }
        
        int channels () const {
                return _channels;
@@ -143,7 +94,7 @@ public:
 
 private:
        std::string key_type () const;
-       void construct (boost::function<boost::filesystem::path (Channel)> get_path, bool interop, MXFMetadata const &);
+       void construct (boost::function<boost::filesystem::path (Channel)> get_path);
        boost::filesystem::path path_from_channel (Channel channel, std::vector<boost::filesystem::path> const & files);
        std::string cpl_node_name () const;
 
index 9d3b8171b2baffd6e5f318765350637135a92e9d..b9c94bd8383d3e23dbda9668ad757d6796a684ab 100644 (file)
@@ -50,29 +50,23 @@ BOOST_AUTO_TEST_CASE (dcp_test)
        libdcp::DCP d ("build/test/foo");
        shared_ptr<libdcp::CPL> cpl (new libdcp::CPL ("build/test/foo", "A Test DCP", libdcp::FEATURE, 24, 24));
 
-       shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset (
-                                                        j2c,
-                                                        "build/test/foo",
-                                                        "video.mxf",
-                                                        &d.Progress,
-                                                        24,
-                                                        24,
-                                                        libdcp::Size (32, 32),
-                                                        false,
-                                                        mxf_meta
-                                                        ));
+       shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/foo", "video.mxf"));
+       mp->set_progress (&d.Progress);
+       mp->set_edit_rate (24);
+       mp->set_intrinsic_duration (24);
+       mp->set_duration (24);
+       mp->set_size (libdcp::Size (32, 32));
+       mp->set_metadata (mxf_meta);
+       mp->create (j2c);
 
-       shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset (
-                                                  wav,
-                                                  "build/test/foo",
-                                                  "audio.mxf",
-                                                  &(d.Progress),
-                                                  24,
-                                                  24,
-                                                  2,
-                                                  false,
-                                                  mxf_meta
-                                                  ));
+       shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset ("build/test/foo", "audio.mxf"));
+       ms->set_progress (&d.Progress);
+       ms->set_edit_rate (24);
+       ms->set_intrinsic_duration (24);
+       ms->set_duration (24);
+       ms->set_channels (2);
+       ms->set_metadata (mxf_meta);
+       ms->create (wav);
        
        cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ())));
        d.add_cpl (cpl);
index 82d5fe2798d9f1fe4976a3c3011b3d2f4d441d5e..aa83d3ec04c4ac26e59dcc5d6179e43ce4698b76 100644 (file)
@@ -29,6 +29,7 @@
 #include "sound_asset.h"
 #include "reel.h"
 #include "test.h"
+#include "signer_chain.h"
 
 using boost::shared_ptr;
 
@@ -37,6 +38,10 @@ using boost::shared_ptr;
 */
 BOOST_AUTO_TEST_CASE (encryption)
 {
+       boost::filesystem::remove_all ("build/test/signer");
+       boost::filesystem::create_directory ("build/test/signer");
+       libdcp::make_signer_chain ("build/test/signer");
+       
        Kumu::libdcp_test = true;
 
        libdcp::MXFMetadata mxf_metadata;
@@ -66,36 +71,28 @@ BOOST_AUTO_TEST_CASE (encryption)
                );
 
        shared_ptr<libdcp::CPL> cpl (new libdcp::CPL ("build/test/bar", "A Test DCP", libdcp::FEATURE, 24, 24));
-       
-       shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset (
-                                                        j2c,
-                                                        "build/test/bar",
-                                                        "video.mxf",
-                                                        &d.Progress,
-                                                        24,
-                                                        24,
-                                                        libdcp::Size (32, 32),
-                                                        false,
-                                                        mxf_metadata
-                                                        ));
 
        libdcp::Key key;
-
+       
+       shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/bar", "video.mxf"));
+       mp->set_progress (&d.Progress);
+       mp->set_edit_rate (24);
+       mp->set_intrinsic_duration (24);
+       mp->set_duration (24);
+       mp->set_size (libdcp::Size (32, 32));
+       mp->set_metadata (mxf_metadata);
        mp->set_key (key);
-
-       shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset (
-                                                  wav,
-                                                  "build/test/bar",
-                                                  "audio.mxf",
-                                                  &(d.Progress),
-                                                  24,
-                                                  24,
-                                                  2,
-                                                  false,
-                                                  mxf_metadata
-                                                  ));
-
+       mp->create (j2c);
+
+       shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset ("build/test/bar", "audio.mxf"));
+       ms->set_progress (&d.Progress);
+       ms->set_edit_rate (24);
+       ms->set_intrinsic_duration (24);
+       mp->set_duration (24);
+       ms->set_channels (2);
+       ms->set_metadata (mxf_metadata);
        ms->set_key (key);
+       ms->create (wav);
        
        cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ())));
        d.add_cpl (cpl);
index a0f6a0f3948ce4bd1d0d340f8300093a64fca830..f01fbdd06a0d7e294e28d76c778c35f91430edce 100644 (file)
@@ -38,13 +38,10 @@ BOOST_AUTO_TEST_CASE (error_test)
        p.push_back ("frobozz");
 
        /* Trying to create video/audio MXFs using a non-existant file should throw an exception */
-       BOOST_CHECK_THROW (
-               new libdcp::MonoPictureAsset (p, "build/test/fred", "video.mxf", &d.Progress, 24, 24, libdcp::Size (32, 32), false),
-               libdcp::FileError
-               );
+       libdcp::MonoPictureAsset pa ("build/test/fred", "video.mxf");
+       BOOST_CHECK_THROW (pa.create (p), libdcp::FileError);
        
-       BOOST_CHECK_THROW (
-               new libdcp::SoundAsset (p, "build/test/fred", "audio.mxf", &d.Progress, 24, 24, false),
-               libdcp::FileError
-               );
+       libdcp::SoundAsset sa ("build/test/fred", "audio.mxf");
+       sa.set_channels (1);
+       BOOST_CHECK_THROW (sa.create (p), libdcp::FileError);
 }
index 43858b10284a7cd15ab35b7cd4d3d920f3a94f00..206fe200347840a4fe9a7dc12fbd6b953399da6d 100644 (file)
@@ -48,8 +48,10 @@ BOOST_AUTO_TEST_CASE (recovery)
        
        boost::filesystem::remove_all ("build/test/baz");
        boost::filesystem::create_directories ("build/test/baz");
-       shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/baz", "video1.mxf", 24, libdcp::Size (32, 32)));
-       shared_ptr<libdcp::PictureAssetWriter> writer = mp->start_write (false, false);
+       shared_ptr<libdcp::MonoPictureAsset> mp (new libdcp::MonoPictureAsset ("build/test/baz", "video1.mxf"));
+       mp->set_edit_rate (24);
+       mp->set_size (libdcp::Size (32, 32));
+       shared_ptr<libdcp::PictureAssetWriter> writer = mp->start_write (false);
 
        int written_size = 0;
        for (int i = 0; i < 24; ++i) {
@@ -76,8 +78,10 @@ BOOST_AUTO_TEST_CASE (recovery)
        Kumu::ResetTestRNG ();
 #endif 
 
-       mp.reset (new libdcp::MonoPictureAsset ("build/test/baz", "video2.mxf", 24, libdcp::Size (32, 32)));
-       writer = mp->start_write (true, false);
+       mp.reset (new libdcp::MonoPictureAsset ("build/test/baz", "video2.mxf"));
+       mp->set_edit_rate (24);
+       mp->set_size (libdcp::Size (32, 32));
+       writer = mp->start_write (true);
 
        writer->write (data, size);
 
index 96563ee81f19837188387b9123b709c42944dbb1..82f6223cd12c2b301e419727efaecca51e6618da 100644 (file)
 #include "cpl.h"
 #include "picture_frame.h"
 #include "argb_frame.h"
+#include "signer_chain.h"
 
 using boost::shared_ptr;
 
 /* Build an encrypted picture MXF and a KDM for it and check that the KDM can be decrypted */
 BOOST_AUTO_TEST_CASE (round_trip_test)
 {
+       boost::filesystem::remove_all ("build/test/signer");
+       boost::filesystem::create_directory ("build/test/signer");
+       libdcp::make_signer_chain ("build/test/signer");
+       
        libdcp::CertificateChain chain;
        chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("build/test/signer/ca.self-signed.pem"))));
        chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (boost::filesystem::path ("build/test/signer/intermediate.signed.pem"))));
@@ -50,11 +55,11 @@ BOOST_AUTO_TEST_CASE (round_trip_test)
        boost::filesystem::path work_dir = "build/test/round_trip_test";
        boost::filesystem::create_directory (work_dir);
 
-       libdcp::MXFMetadata mxf_metadata;
-
-       shared_ptr<libdcp::MonoPictureAsset> asset_A (
-               new libdcp::MonoPictureAsset (j2c, work_dir, "video.mxf", 0, 24, 24, libdcp::Size (32, 32), false, mxf_metadata)
-               );
+       shared_ptr<libdcp::MonoPictureAsset> asset_A (new libdcp::MonoPictureAsset (work_dir, "video.mxf"));
+       asset_A->set_edit_rate (24);
+       asset_A->set_intrinsic_duration (24);
+       asset_A->set_size (libdcp::Size (32, 32));
+       asset_A->create (j2c);
 
        libdcp::Key key;
 
index c02502553f8a4f351c5dc3b2d8ec599e5ce9e4f1..1b2a1055e5d7722f7a7a062a4c967f8574fb1aac 100644 (file)
@@ -21,7 +21,7 @@ def build(bld):
     obj.uselib = 'BOOST_TEST OPENJPEG CXML XMLSEC1'
     obj.use    = 'libdcp'
     obj.source = """
-                 test.cc
+                 test.cc 
                  certificates_test.cc
                  dcp_test.cc
                  encryption_test.cc
diff --git a/wscript b/wscript
index c837493f87ebca46e6621758078a3ce4248293b2..643fe2ff803b482d0197af35238822c14ca2b707 100644 (file)
--- a/wscript
+++ b/wscript
@@ -13,7 +13,7 @@ def options(opt):
 
 def configure(conf):
     conf.load('compiler_cxx')
-    conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-O2', '-D_FILE_OFFSET_BITS=64'])
+    conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64'])
     conf.env.append_value('CXXFLAGS', ['-DLIBDCP_VERSION="%s"' % VERSION])
 
     conf.env.TARGET_WINDOWS = conf.options.target_windows