path -> dir, name for MXFs.
authorCarl Hetherington <cth@carlh.net>
Mon, 30 Jul 2012 23:23:59 +0000 (00:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 30 Jul 2012 23:23:59 +0000 (00:23 +0100)
src/asset.cc
src/asset.h
src/dcp.cc
src/picture_asset.cc
src/picture_asset.h
src/sound_asset.cc
src/sound_asset.h

index 59d106b5fa8e5e8bebdf8116ad7e8769873b896d..740dc592335c6379f07824b6c896af8a1acd52b0 100644 (file)
@@ -33,8 +33,9 @@ using namespace std;
 using namespace boost;
 using namespace libdcp;
 
-Asset::Asset (string mxf_path, sigc::signal1<void, float>* progress, int fps, int length)
-       : _mxf_path (mxf_path)
+Asset::Asset (string directory, string mxf_name, sigc::signal1<void, float>* progress, int fps, int length)
+       : _directory (directory)
+       , _mxf_name (mxf_name)
        , _progress (progress)
        , _fps (fps)
        , _length (length)
@@ -48,13 +49,9 @@ Asset::write_to_pkl (ostream& s) const
 {
        s << "    <Asset>\n"
          << "      <Id>urn:uuid:" << _uuid << "</Id>\n"
-#if BOOST_FILESYSTEM_VERSION == 3
-         << "      <AnnotationText>" << filesystem::path(_mxf_path).filename().string() << "</AnnotationText>\n"
-#else          
-         << "      <AnnotationText>" << filesystem::path(_mxf_path).filename() << "</AnnotationText>\n"
-#endif         
+         << "      <AnnotationText>" << _mxf_name << "</AnnotationText>\n"
          << "      <Hash>" << _digest << "</Hash>\n"
-         << "      <Size>" << filesystem::file_size(_mxf_path) << "</Size>\n"
+         << "      <Size>" << filesystem::file_size(mxf_path()) << "</Size>\n"
          << "      <Type>application/mxf</Type>\n"
          << "    </Asset>\n";
 }
@@ -66,14 +63,10 @@ Asset::write_to_assetmap (ostream& s) const
          << "      <Id>urn:uuid:" << _uuid << "</Id>\n"
          << "      <ChunkList>\n"
          << "        <Chunk>\n"
-#if BOOST_FILESYSTEM_VERSION == 3              
-         << "          <Path>" << filesystem::path(_mxf_path).filename().string() << "</Path>\n"
-#else          
-         << "          <Path>" << filesystem::path(_mxf_path).filename() << "</Path>\n"
-#endif         
+         << "          <Path>" << _mxf_name << "</Path>\n"
          << "          <VolumeIndex>1</VolumeIndex>\n"
          << "          <Offset>0</Offset>\n"
-         << "          <Length>" << filesystem::file_size(_mxf_path) << "</Length>\n"
+         << "          <Length>" << filesystem::file_size(mxf_path()) << "</Length>\n"
          << "        </Chunk>\n"
          << "      </ChunkList>\n"
          << "    </Asset>\n";
@@ -91,3 +84,12 @@ Asset::fill_writer_info (ASDCP::WriterInfo* writer_info) const
        Kumu::hex2bin (_uuid.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c);
        assert (c == Kumu::UUID_Length);
 }
+
+filesystem::path
+Asset::mxf_path () const
+{
+       filesystem::path p;
+       p /= _directory;
+       p /= _mxf_name;
+       return p;
+}
index b0cc450c999865e2f77dddd99c98a08fee961e92..62b7b4ac494745776910eec1ff608064a294ca8c 100644 (file)
@@ -42,12 +42,13 @@ class Asset
 {
 public:
        /** Construct an Asset.
-        *  @param mxf_path Pathname of MXF file.
+        *  @param directory Directory where MXF file is.
+        *  @param mxf_name Name of MXF file.
         *  @param progress Signal to inform of progress.
         *  @param fps Frames per second.
         *  @param length Length in frames.
         */
-       Asset (std::string mxf_path, sigc::signal1<void, float>* progress, int fps, int length);
+       Asset (std::string directory, std::string mxf_path, sigc::signal1<void, float>* progress, int fps, int length);
 
        /** Write details of the asset to a CPL stream.
         *  @param s Stream.
@@ -70,8 +71,12 @@ protected:
         */
        void fill_writer_info (ASDCP::WriterInfo* w) const;
 
-       /** Path to our MXF file */
-       std::string _mxf_path;
+       boost::filesystem::path mxf_path () const;
+
+       /** Directory that our MXF file is in */
+       std::string _directory;
+       /** Name of our MXF file */
+       std::string _mxf_name;
        /** Signal to emit to report progress */
        sigc::signal1<void, float>* _progress;
        /** Frames per second */
index 4b0e9087d95a5b374edcb9e310feb50a82e57858..8f7a73bcedaadc44a0cefe59e97c12c6371c9aa1 100644 (file)
@@ -54,37 +54,25 @@ DCP::DCP (string directory, string name, ContentKind content_kind, int fps, int
 void
 DCP::add_sound_asset (vector<string> const & files)
 {
-       filesystem::path p;
-       p /= _directory;
-       p /= "audio.mxf";
-       _assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (files, p.string(), &Progress, _fps, _length)));
+       _assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (files, _directory, "audio.mxf", &Progress, _fps, _length)));
 }
 
 void
 DCP::add_sound_asset (sigc::slot<string, Channel> get_path, int channels)
 {
-       filesystem::path p;
-       p /= _directory;
-       p /= "audio.mxf";
-       _assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (get_path, p.string(), &Progress, _fps, _length, channels)));
+       _assets.push_back (shared_ptr<SoundAsset> (new SoundAsset (get_path, _directory, "audio.mxf", &Progress, _fps, _length, channels)));
 }
 
 void
 DCP::add_picture_asset (vector<string> const & files, int width, int height)
 {
-       filesystem::path p;
-       p /= _directory;
-       p /= "video.mxf";
-       _assets.push_back (shared_ptr<PictureAsset> (new PictureAsset (files, p.string(), &Progress, _fps, _length, width, height)));
+       _assets.push_back (shared_ptr<PictureAsset> (new PictureAsset (files, _directory, "video.mxf", &Progress, _fps, _length, width, height)));
 }
 
 void
 DCP::add_picture_asset (sigc::slot<string, int> get_path, int width, int height)
 {
-       filesystem::path p;
-       p /= _directory;
-       p /= "video.mxf";
-       _assets.push_back (shared_ptr<PictureAsset> (new PictureAsset (get_path, p.string(), &Progress, _fps, _length, width, height)));
+       _assets.push_back (shared_ptr<PictureAsset> (new PictureAsset (get_path, _directory, "video.mxf", &Progress, _fps, _length, width, height)));
 }
 
 void
@@ -295,6 +283,7 @@ DCP::DCP (string directory)
 
        _assets.push_back (shared_ptr<PictureAsset> (
                                   new PictureAsset (
+                                          _directory,
                                           cpl_assets->main_picture->annotation_text,
                                           _fps,
                                           _length,
@@ -306,6 +295,7 @@ DCP::DCP (string directory)
        if (cpl_assets->main_sound) {
                _assets.push_back (shared_ptr<SoundAsset> (
                                           new SoundAsset (
+                                                  _directory,
                                                   cpl_assets->main_picture->annotation_text,
                                                   _fps,
                                                   _length
index 2f8a622ab5771247ce5304a898c3555da03983a7..db3f02c3c89857c512ebb53a40a97d273972285e 100644 (file)
@@ -38,13 +38,14 @@ using namespace libdcp;
 
 PictureAsset::PictureAsset (
        sigc::slot<string, int> get_path,
-       string mxf_path,
+       string directory,
+       string mxf_name,
        sigc::signal1<void, float>* progress,
        int fps,
        int length,
        int width,
        int height)
-       : Asset (mxf_path, progress, fps, length)
+       : Asset (directory, mxf_name, progress, fps, length)
        , _width (width)
        , _height (height)
 {
@@ -53,21 +54,22 @@ PictureAsset::PictureAsset (
 
 PictureAsset::PictureAsset (
        vector<string> const & files,
-       string mxf_path,
+       string directory,
+       string mxf_name,
        sigc::signal1<void, float>* progress,
        int fps,
        int length,
        int width,
        int height)
-       : Asset (mxf_path, progress, fps, length)
+       : Asset (directory, mxf_name, progress, fps, length)
        , _width (width)
        , _height (height)
 {
        construct (sigc::bind (sigc::mem_fun (*this, &PictureAsset::path_from_list), files));
 }
 
-PictureAsset::PictureAsset (string mxf_path, int fps, int length, int width, int height)
-       : Asset (mxf_path, 0, fps, length)
+PictureAsset::PictureAsset (string directory, string mxf_name, int fps, int length, int width, int height)
+       : Asset (directory, mxf_name, 0, fps, length)
        , _width (width)
        , _height (height)
 {
@@ -97,8 +99,8 @@ PictureAsset::construct (sigc::slot<string, int> get_path)
        fill_writer_info (&writer_info);
        
        ASDCP::JP2K::MXFWriter mxf_writer;
-       if (ASDCP_FAILURE (mxf_writer.OpenWrite (_mxf_path.c_str(), writer_info, picture_desc))) {
-               throw FileError ("could not open MXF file for writing", _mxf_path);
+       if (ASDCP_FAILURE (mxf_writer.OpenWrite (mxf_path().c_str(), writer_info, picture_desc))) {
+               throw FileError ("could not open MXF file for writing", mxf_path().string());
        }
 
        for (int i = 0; i < _length; ++i) {
@@ -121,7 +123,7 @@ PictureAsset::construct (sigc::slot<string, int> get_path)
                throw MiscError ("error in finalising video MXF");
        }
 
-       _digest = make_digest (_mxf_path, _progress);
+       _digest = make_digest (mxf_path().string(), _progress);
 }
 
 void
@@ -129,11 +131,7 @@ PictureAsset::write_to_cpl (ostream& s) const
 {
        s << "        <MainPicture>\n"
          << "          <Id>urn:uuid:" << _uuid << "</Id>\n"
-#if BOOST_FILESYSTEM_VERSION == 3
-         << "          <AnnotationText>" << filesystem::path(_mxf_path).filename().string() << "</AnnotationText>\n"
-#else          
-         << "          <AnnotationText>" << filesystem::path(_mxf_path).filename() << "</AnnotationText>\n"
-#endif         
+         << "          <AnnotationText>" << _mxf_name << "</AnnotationText>\n"
          << "          <EditRate>" << _fps << " 1</EditRate>\n"
          << "          <IntrinsicDuration>" << _length << "</IntrinsicDuration>\n"
          << "          <EntryPoint>0</EntryPoint>\n"
index e540c074c9b8b39652de2d85b6a6358c1c5a5560..9fa4f99e894b88861288c6fdee1659025a655239 100644 (file)
@@ -33,7 +33,8 @@ public:
        /** Construct a PictureAsset, 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 mxf_path Pathname of MXF file to create.
+        *  @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.
@@ -42,7 +43,8 @@ public:
         */
        PictureAsset (
                std::vector<std::string> const & files,
-               std::string mxf_path,
+               std::string directory,
+               std::string mxf_name,
                sigc::signal1<void, float>* progress,
                int fps,
                int length,
@@ -53,7 +55,8 @@ public:
        /** Construct a PictureAsset, 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 mxf_path Pathname of MXF file to create.
+        *  @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.
@@ -62,7 +65,8 @@ public:
         */
        PictureAsset (
                sigc::slot<std::string, int> get_path,
-               std::string mxf_path,
+               std::string directory,
+               std::string mxf_name,
                sigc::signal1<void, float>* progress,
                int fps,
                int length,
@@ -70,7 +74,7 @@ public:
                int height
                );
 
-       PictureAsset (std::string mxf_path, int fps, int length, int width, int height);
+       PictureAsset (std::string directory, std::string mxf_name, int fps, int length, int width, int height);
        
        /** Write details of this asset to a CPL stream.
         *  @param s Stream.
index a0d17f29ebf6aabfc319bfd7879282c2b25c6c51..e22357fd1ed2833427a0e915d56049c17f59f7e8 100644 (file)
@@ -34,25 +34,25 @@ using namespace boost;
 using namespace libdcp;
 
 SoundAsset::SoundAsset (
-       vector<string> const & files, string mxf_path, sigc::signal1<void, float>* progress, int fps, int length
+       vector<string> const & files, string directory, string mxf_name, sigc::signal1<void, float>* progress, int fps, int length
        )
-       : Asset (mxf_path, progress, fps, length)
+       : Asset (directory, mxf_name, progress, fps, length)
        , _channels (files.size ())
 {
        construct (sigc::bind (sigc::mem_fun (*this, &SoundAsset::path_from_channel), files));
 }
 
 SoundAsset::SoundAsset (
-       sigc::slot<string, Channel> get_path, string mxf_path, sigc::signal1<void, float>* progress, int fps, int length, int channels
+       sigc::slot<string, Channel> get_path, string directory, string mxf_name, sigc::signal1<void, float>* progress, int fps, int length, int channels
        )
-       : Asset (mxf_path, progress, fps, length)
+       : Asset (directory, mxf_name, progress, fps, length)
        , _channels (channels)
 {
        construct (get_path);
 }
 
-SoundAsset::SoundAsset (string mxf_path, int fps, int length)
-       : Asset (mxf_path, 0, fps, length)
+SoundAsset::SoundAsset (string directory, string mxf_name, int fps, int length)
+       : Asset (directory, mxf_name, 0, fps, length)
        , _channels (0)
 {
 
@@ -118,8 +118,8 @@ SoundAsset::construct (sigc::slot<string, Channel> get_path)
        fill_writer_info (&writer_info);
 
        ASDCP::PCM::MXFWriter mxf_writer;
-       if (ASDCP_FAILURE (mxf_writer.OpenWrite (_mxf_path.c_str(), writer_info, audio_desc))) {
-               throw FileError ("could not open audio MXF for writing", _mxf_path);
+       if (ASDCP_FAILURE (mxf_writer.OpenWrite (mxf_path().c_str(), writer_info, audio_desc))) {
+               throw FileError ("could not open audio MXF for writing", mxf_path().string());
        }
 
        for (int i = 0; i < _length; ++i) {
@@ -160,7 +160,7 @@ SoundAsset::construct (sigc::slot<string, Channel> get_path)
                throw MiscError ("could not finalise audio MXF");
        }
 
-       _digest = make_digest (_mxf_path, _progress);
+       _digest = make_digest (mxf_path().string(), _progress);
 }
 
 void
@@ -168,11 +168,7 @@ SoundAsset::write_to_cpl (ostream& s) const
 {
        s << "        <MainSound>\n"
          << "          <Id>urn:uuid:" << _uuid << "</Id>\n"
-#if BOOST_FILESYSTEM_VERSION == 3              
-         << "          <AnnotationText>" << filesystem::path(_mxf_path).filename().string() << "</AnnotationText>\n"
-#else          
-         << "          <AnnotationText>" << filesystem::path(_mxf_path).filename() << "</AnnotationText>\n"
-#endif         
+         << "          <AnnotationText>" << _mxf_name << "</AnnotationText>\n"
          << "          <EditRate>" << _fps << " 1</EditRate>\n"
          << "          <IntrinsicDuration>" << _length << "</IntrinsicDuration>\n"
          << "          <EntryPoint>0</EntryPoint>\n"
index 914823a2a5db368f2fbe78e931ef85cf77abece0..4fbec895f874001677e9b675d2ea80c65848219f 100644 (file)
@@ -37,14 +37,16 @@ public:
        /** Construct a SoundAsset, generating the MXF from the 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 mxf_path Pathname of MXF file to create.
+        *  @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.
         */
        SoundAsset (
                std::vector<std::string> const & files,
-               std::string mxf_path,
+               std::string directory,
+               std::string mxf_name,
                sigc::signal1<void, float>* progress,
                int fps,
                int length
@@ -53,7 +55,8 @@ public:
        /** Construct a SoundAsset, generating the MXF from the 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 mxf_path Pathname of MXF file to create.
+        *  @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.
@@ -61,7 +64,8 @@ public:
         */
        SoundAsset (
                sigc::slot<std::string, Channel> get_path,
-               std::string mxf_path,
+               std::string directory,
+               std::string mxf_name,
                sigc::signal1<void, float>* progress,
                int fps,
                int length,
@@ -69,7 +73,8 @@ public:
                );
 
        SoundAsset (
-               std::string mxf_path,
+               std::string directory,
+               std::string mxf_name,
                int fps,
                int length
                );