Various small fixes.
authorCarl Hetherington <cth@carlh.net>
Wed, 12 Feb 2014 23:25:57 +0000 (23:25 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 12 Feb 2014 23:25:57 +0000 (23:25 +0000)
src/asset.cc
src/asset.h
src/reel_sound_asset.h
src/util.cc
src/util.h
src/wscript

index 738fb0193d1636fd45f83e00766629bfd5b75204..f8de10b6529d2e3125433628374cc467bb7c081f 100644 (file)
@@ -31,6 +31,7 @@
 using std::string;
 using boost::lexical_cast;
 using boost::function;
+using boost::optional;
 using namespace dcp;
 
 /** Create an Asset with a randomly-generated ID */
@@ -80,7 +81,7 @@ Asset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const
        asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
        xmlpp::Node* chunk_list = asset->add_child ("ChunkList");
        xmlpp::Node* chunk = chunk_list->add_child ("Chunk");
-       boost::optional<boost::filesystem::path> path = relative_to_root (root, _file);
+       optional<boost::filesystem::path> path = relative_to_root (root, _file);
        if (!path) {
                throw MiscError (String::compose ("Asset %1 is not within the directory %2", _file, root));
        }
@@ -91,12 +92,12 @@ Asset::write_to_assetmap (xmlpp::Node* node, boost::filesystem::path root) const
 }
 
 string
-Asset::hash () const
+Asset::hash (function<void (float)> progress) const
 {
        assert (!_file.empty ());
                
        if (_hash.empty ()) {
-               _hash = make_digest (_file, 0);
+               _hash = make_digest (_file, progress);
        }
 
        return _hash;
index e6a302c15010be3fccfd977cfb13fa6caba5927f..57143310a1b95b8cd229c473e2d822259c060296 100644 (file)
@@ -28,6 +28,7 @@
 #include "types.h"
 #include <boost/filesystem.hpp>
 #include <boost/function.hpp>
+#include <boost/bind.hpp>
 
 namespace xmlpp {
        class Node;
@@ -70,14 +71,12 @@ public:
 
        void set_file (boost::filesystem::path file) const;
 
-       /** @return the hash of this asset's file.  It will be
-        *  computed by this call if necessary.
-        */
-       std::string hash () const;
+       /** @return the hash of this asset's file */
+       std::string hash (boost::function<void (float)> progress = 0) const;
 
 protected:
        virtual std::string pkl_type () const = 0;
-       
+
        /** The disk file that represents this asset, if one exists */
        mutable boost::filesystem::path _file;
        /** Hash of _file, or empty if the hash has not yet been computed */
index fb233016e3f63b3e112253b7e5e037db228644f1..42835c848f192652065db6f0b46368a184b68854 100644 (file)
@@ -40,6 +40,10 @@ public:
        boost::shared_ptr<SoundMXF> mxf () {
                return boost::dynamic_pointer_cast<SoundMXF> (_content.object ());
        }
+
+       boost::shared_ptr<const SoundMXF> mxf () const {
+               return boost::dynamic_pointer_cast<const SoundMXF> (_content.object ());
+       }
        
 private:
        std::string cpl_node_name () const;
index 4be026d28f0c35d9c0c0d3123a36bc752bf16162..1e32fbc9f6ce36ea95eaaa36b0751bc373a0c667 100644 (file)
@@ -54,7 +54,10 @@ using std::max;
 using std::list;
 using std::setw;
 using std::setfill;
+using std::ostream;
 using boost::shared_ptr;
+using boost::optional;
+using boost::function;
 using namespace dcp;
 
 /** Create a UUID.
@@ -73,12 +76,12 @@ dcp::make_uuid ()
 
 /** Create a digest for a file.
  *  @param filename File name.
- *  @param progress Pointer to a progress reporting function, or 0.  The function will be called
+ *  @param progress Optional progress reporting function.  The function will be called
  *  with a progress value between 0 and 1.
  *  @return Digest.
  */
 string
-dcp::make_digest (boost::filesystem::path filename, boost::function<void (float)>* progress)
+dcp::make_digest (boost::filesystem::path filename, function<void (float)> progress)
 {
        Kumu::FileReader reader;
        Kumu::Result_t r = reader.OpenRead (filename.string().c_str ());
@@ -107,7 +110,7 @@ dcp::make_digest (boost::filesystem::path filename, boost::function<void (float)
                SHA1_Update (&sha, read_buffer.Data(), read);
 
                if (progress) {
-                       (*progress) (float (done) / size);
+                       progress (float (done) / size);
                        done += read;
                }
        }
@@ -271,6 +274,12 @@ bool dcp::operator!= (dcp::Size const & a, dcp::Size const & b)
        return !(a == b);
 }
 
+ostream& dcp::operator<< (ostream& s, dcp::Size const & a)
+{
+       s << a.width << "x" << a.height;
+       return s;
+}
+
 /** Decode a base64 string.  The base64 decode routine in KM_util.cpp
  *  gives different values to both this and the command-line base64
  *  for some inputs.  Not sure why.
@@ -385,7 +394,7 @@ dcp::fopen_boost (boost::filesystem::path p, string t)
 #endif
 }
 
-boost::optional<boost::filesystem::path>
+optional<boost::filesystem::path>
 dcp::relative_to_root (boost::filesystem::path root, boost::filesystem::path file)
 {
        boost::filesystem::path::const_iterator i = root.begin ();
@@ -397,7 +406,7 @@ dcp::relative_to_root (boost::filesystem::path root, boost::filesystem::path fil
        }
 
        if (i != root.end ()) {
-               return boost::optional<boost::filesystem::path> ();
+               return optional<boost::filesystem::path> ();
        }
 
        boost::filesystem::path rel;
index 2bfeb60ab9f3a5845a5a75d17802933fefd5ea1d..ca00ecb9147a1a232760426636d9cc16b35e667b 100644 (file)
@@ -70,9 +70,10 @@ struct Size
        
 extern bool operator== (Size const & a, Size const & b);
 extern bool operator!= (Size const & a, Size const & b);
+extern std::ostream& operator<< (std::ostream& s, Size const & a);
 
 extern std::string make_uuid ();
-extern std::string make_digest (boost::filesystem::path filename, boost::function<void (float)> *);
+extern std::string make_digest (boost::filesystem::path filename, boost::function<void (float)>);
 extern std::string content_kind_to_string (ContentKind kind);
 extern ContentKind content_kind_from_string (std::string kind);
 extern bool empty_or_white_space (std::string s);
index 294e36bc4b118f8aa954d4bbd0563062f94d13be..1f40197734d9d3f1168af9748b062137b76d7013 100644 (file)
@@ -87,15 +87,22 @@ def build(bld):
               picture_mxf_writer.h
               rgb_xyz.h
               reel.h
+              reel_asset.h
+              reel_mono_picture_asset.h
+              reel_picture_asset.h
+              reel_sound_asset.h
+              reel_stereo_picture_asset.h
               ref.h
               argb_frame.h
               signer.h
               signer_chain.h
-              sound_mxf.h
               sound_frame.h
+              sound_mxf.h
+              sound_mxf_writer.h
               stereo_picture_mxf.h
               stereo_picture_frame.h
               subtitle.h
+              subtitle_content.h
               subtitle_string.h
               types.h
               util.h