Merge master
authorCarl Hetherington <cth@carlh.net>
Mon, 14 Jan 2013 20:15:43 +0000 (20:15 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 14 Jan 2013 20:15:43 +0000 (20:15 +0000)
16 files changed:
1  2 
examples/make_dcp.cc
run-tests.sh
src/asset.cc
src/dcp.cc
src/dcp.h
src/dcp_time.cc
src/dcp_time.h
src/mxf_asset.h
src/reel.cc
src/reel.h
src/sound_asset.cc
src/sound_asset.h
src/util.cc
src/util.h
test/tests.cc
wscript

index 22490d714789f04f0eee2733c5324486a930c9f3,68e3f4f92c4b5a3e68d75110239497afc944f3ae..8061ca614d26dba3cf3188939748c65d079c9e56
@@@ -93,7 -93,7 +93,7 @@@ main (
  
        /* 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)
 -              new libdcp::SoundAsset (sound_files, "My Film DCP", "audio.mxf", 0, 24, 48, 0)
++              new libdcp::SoundAsset (sound_files, "My Film DCP", "audio.mxf", 0, 24, 48, 0, false)
                );
  
        /* Now that we have the assets, we can create a Reel to put them in and add it to the CPL */
diff --cc run-tests.sh
Simple merge
diff --cc src/asset.cc
Simple merge
diff --cc src/dcp.cc
index 54ab6660c357d3150d6146b210b2934aa7f9d4ab,6c62693954ba4bca297486e928226969fb2006a8..b3048bae0475fe8b54d7da778c049864d9f4d8ad
  #include <cassert>
  #include <iostream>
  #include <boost/filesystem.hpp>
 +#include <boost/lexical_cast.hpp>
+ #include <boost/algorithm/string.hpp>
  #include <libxml++/libxml++.h>
 +#include <xmlsec/xmldsig.h>
 +#include <xmlsec/app.h>
  #include "dcp.h"
  #include "asset.h"
  #include "sound_asset.h"
@@@ -441,41 -437,33 +448,41 @@@ CPL::write_xml (shared_ptr<Encryption> 
        stringstream s;
        s << _uuid << "_cpl.xml";
        p /= s.str();
 -      ofstream os (p.string().c_str());
 -      
 -      os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
 -         << "<CompositionPlaylist xmlns=\"http://www.smpte-ra.org/schemas/429-7/2006/CPL\">\n"
 -         << "  <Id>urn:uuid:" << _uuid << "</Id>\n"
 -         << "  <AnnotationText>" << _name << "</AnnotationText>\n"
 -         << "  <IssueDate>" << Metadata::instance()->issue_date << "</IssueDate>\n"
 -         << "  <Creator>" << Metadata::instance()->creator << "</Creator>\n"
 -         << "  <ContentTitleText>" << _name << "</ContentTitleText>\n"
 -         << "  <ContentKind>" << content_kind_to_string (_content_kind) << "</ContentKind>\n"
 -         << "  <ContentVersion>\n"
 -         << "    <Id>urn:uri:" << _uuid << "_" << Metadata::instance()->issue_date << "</Id>\n"
 -         << "    <LabelText>" << _uuid << "_" << Metadata::instance()->issue_date << "</LabelText>\n"
 -         << "  </ContentVersion>\n"
 -         << "  <RatingList/>\n"
 -         << "  <ReelList>\n";
 -      
 +
 +      xmlpp::Document doc;
 +      xmlpp::Element* cpl = doc.create_root_node("CompositionPlaylist", "http://www.smpte-ra.org/schemas/429-7/2006/CPL");
 +
 +      if (crypt) {
 +              cpl->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "dsig");
 +      }
 +
 +      cpl->add_child("Id")->add_child_text ("urn:uuid:" + _uuid);
 +      cpl->add_child("AnnotationText")->add_child_text (_name);
 +      cpl->add_child("IssueDate")->add_child_text (Metadata::instance()->issue_date);
 +      cpl->add_child("Creator")->add_child_text (Metadata::instance()->creator);
 +      cpl->add_child("ContentTitleText")->add_child_text (_name);
 +      cpl->add_child("ContentKind")->add_child_text (content_kind_to_string (_content_kind));
 +
 +      {
 +              xmlpp::Element* cv = cpl->add_child ("ContentVersion");
 +              cv->add_child("Id")->add_child_text ("urn:uri:" + _uuid + "_" + Metadata::instance()->issue_date);
 +              cv->add_child("LabelText")->add_child_text (_uuid + "_" + Metadata::instance()->issue_date);
 +      }
 +
 +      cpl->add_child("RatingList");
 +
 +      xmlpp::Element* reel_list = cpl->add_child("ReelList");
        for (list<shared_ptr<const Reel> >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) {
 -              (*i)->write_to_cpl (os);
 +              (*i)->write_to_cpl (reel_list);
        }
  
 -      os << "  </ReelList>\n"
 -         << "</CompositionPlaylist>\n";
 +      if (crypt) {
 +              sign (cpl, crypt->certificates, crypt->signer_key);
 +      }
  
 -      os.close ();
 +      doc.write_to_file_formatted (p.string(), "UTF-8");
  
-       _digest = make_digest (p.string (), 0);
+       _digest = make_digest (p.string ());
        _length = boost::filesystem::file_size (p.string ());
  }
  
diff --cc src/dcp.h
index 63e579de9af134b07ffca07c9d734353e83f7dc1,c5734542a97e17cff311f199da3f1c2200c0b154..5a9150196c9b5088173a50b5575328f4c4024213
+++ b/src/dcp.h
@@@ -48,18 -45,7 +48,19 @@@ class SubtitleAsset
  class Reel;
  class AssetMap;
  
 +class Encryption
 +{
 +public:
 +      Encryption (CertificateChain c, std::string const & k)
 +              : certificates (c)
 +              , signer_key (k)
 +      {}
 +
 +      CertificateChain certificates;
 +      std::string signer_key;
 +};
 +
+ /** @brief A CPL within a DCP */
  class CPL
  {
  public:
diff --cc src/dcp_time.cc
Simple merge
diff --cc src/dcp_time.h
Simple merge
diff --cc src/mxf_asset.h
Simple merge
diff --cc src/reel.cc
index d8703dd02e5eb62da8fb4c45bb8d6e2395bf186d,8995f874ab8b710ac170d7dc98ecf2cc4de4e13a..ae3080ad6386987e2877ad38a01332ea6196993d
@@@ -43,8 -42,11 +43,11 @@@ Reel::write_to_cpl (xmlpp::Node* parent
        }
  
        if (_main_subtitle) {
 -              _main_subtitle->write_to_cpl (s);
 +              _main_subtitle->write_to_cpl (asset_list);
        }
+       s << "      </AssetList>\n"
+         << "    </Reel>\n";
  }
        
  bool
diff --cc src/reel.h
Simple merge
index 77267cbd33701037598114361b44e1db97691c5c,98266b2805d486164f75545b6b5dd67b98ce2e8d..d964a46d80601e56c74179ade40ca974fccf0ca2
@@@ -43,12 -42,15 +43,22 @@@ using boost::lexical_cast
  using namespace libdcp;
  
  SoundAsset::SoundAsset (
-       vector<string> const & files, string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int length, bool encrypted
 -      vector<string> const & files, string directory, string mxf_name, boost::signals2::signal<void (float)>* progress, int fps, int length, int start_frame
++      vector<string> const & files,
++      string directory,
++      string mxf_name,
++      boost::signals2::signal<void (float)>* progress,
++      int fps,
++      int length,
++      int start_frame,
++      bool encrypted
        )
 -      : MXFAsset (directory, mxf_name, progress, fps, 0, length)
 +      : MXFAsset (directory, mxf_name, progress, fps, 0, length, encrypted)
        , _channels (files.size ())
        , _sampling_rate (0)
+       , _start_frame (start_frame)
  {
+       assert (_channels);
+       
        construct (boost::bind (&SoundAsset::path_from_channel, this, _1, files));
  }
  
@@@ -57,18 -59,22 +67,26 @@@ SoundAsset::SoundAsset 
        string directory,
        string mxf_name,
        boost::signals2::signal<void (float)>* progress,
-       int fps, int length, int channels, bool encrypted
 -      int fps, int length, int start_frame, int channels
++      int fps,
++      int length,
++      int start_frame,
++      int channels,
++      bool encrypted
        )
 -      : MXFAsset (directory, mxf_name, progress, fps, 0, length)
 +      : MXFAsset (directory, mxf_name, progress, fps, 0, length, encrypted)
        , _channels (channels)
        , _sampling_rate (0)
+       , _start_frame (start_frame)
  {
+       assert (_channels);
+       
        construct (get_path);
  }
  
  SoundAsset::SoundAsset (string directory, string mxf_name, int fps, int entry_point, int length)
 -      : MXFAsset (directory, mxf_name, 0, fps, entry_point, length)
 +      : MXFAsset (directory, mxf_name, 0, fps, entry_point, length, false)
        , _channels (0)
+       , _start_frame (0)
  {
        ASDCP::PCM::MXFReader reader;
        if (ASDCP_FAILURE (reader.OpenRead (path().string().c_str()))) {
index 6711560660bfd9d56be0e3883caefcc0366b21a7,9fb1d60b2581bbcc6ff1becef0d4becd2bbcc8e4..2b9256416db87cf5909dfeb92ece1b7a293f3437
@@@ -44,7 -44,7 +44,8 @@@ public
         *  @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 encrypted true if asset should be encrypted.
         */
        SoundAsset (
                std::vector<std::string> const & files,
@@@ -53,7 -53,7 +54,8 @@@
                boost::signals2::signal<void (float)>* progress,
                int fps,
                int length,
+               int start_frame
 +              bool encrypted
                );
  
        /** Construct a SoundAsset, generating the MXF from some WAV files.
@@@ -64,8 -64,8 +66,9 @@@
         *  @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 channels Number of audio channels.
 +       *  @param encrypted true if asset should be encrypted.
         */
        SoundAsset (
                boost::function<std::string (Channel)> get_path,
@@@ -74,8 -74,8 +77,9 @@@
                boost::signals2::signal<void (float)>* progress,
                int fps,
                int length,
 -              int channels
+               int start_frame,
 +              int channels,
 +              bool encrypted
                );
  
        SoundAsset (
diff --cc src/util.cc
Simple merge
diff --cc src/util.h
index 3b60e0c7359ac0c245047d66c80d6df3072138ae,721d11385beccfc08b7ddf1ef23f533329c86ec4..ddc5a3223b929a3c23804261ef472e4e9d6f533b
  #include <openjpeg.h>
  #include "types.h"
  
 +namespace xmlpp {
 +      class Element;
 +}
 +
  namespace libdcp {
  
 -class ARGBFrame;      
 +class ARGBFrame;
 +class CertificateChain;
        
- /** Create a UUID.
-  *  @return UUID.
-  */
  extern std::string make_uuid ();
- /** Create a digest for a file.
-  *  @param filename File name.
-  *  @param progress If non-0, a signal which will be emitted periodically to update
-  *  progress; the parameter will start at 0.5 and proceed to 1.
-  *  @return Digest.
-  */
- extern std::string make_digest (std::string filename, boost::signals2::signal<void (float)>* progress);
+ extern std::string make_digest (std::string filename);
  extern std::string content_kind_to_string (ContentKind kind);
  extern ContentKind content_kind_from_string (std::string kind);
- extern bool starts_with (std::string big, std::string little);
- extern bool ends_with (std::string big, std::string little);
  extern bool empty_or_white_space (std::string s);
  extern opj_image_t* decompress_j2k (uint8_t* data, int64_t size, int reduce);
  extern boost::shared_ptr<ARGBFrame> xyz_to_rgb (opj_image_t* xyz_frame);
  
diff --cc test/tests.cc
index b15556c1dc47d6bdd5f7c110d0c36fc247bb43b2,be960699d5870350655d7fd170aedec785b397d8..45087b413dfa4696ea36a5d8c9b560a1a8472563
@@@ -93,8 -86,8 +93,9 @@@ BOOST_AUTO_TEST_CASE (dcp_test
                                                   &(d.Progress),
                                                   24,
                                                   24,
 -                                                 2
+                                                  0,
 +                                                 2,
 +                                                 false
                                                   ));
        
        cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ())));
@@@ -109,8 -102,8 +110,8 @@@ BOOST_AUTO_TEST_CASE (error_test
        vector<string> p;
        p.push_back ("frobozz");
  
-       BOOST_CHECK_THROW (new libdcp::MonoPictureAsset (p, "build/test/fred", "video.mxf", &d.Progress, 24, 24, 32, 32, false), libdcp::FileError);
-       BOOST_CHECK_THROW (new libdcp::SoundAsset (p, "build/test/fred", "audio.mxf", &d.Progress, 24, 24, false), libdcp::FileError);
 -      BOOST_CHECK_THROW (new libdcp::MonoPictureAsset (p, "build/test/bar", "video.mxf", &d.Progress, 24, 24, 32, 32), libdcp::FileError);
 -      BOOST_CHECK_THROW (new libdcp::SoundAsset (p, "build/test/bar", "audio.mxf", &d.Progress, 24, 24, 0), libdcp::FileError);
++      BOOST_CHECK_THROW (new libdcp::MonoPictureAsset (p, "build/test/bar", "video.mxf", &d.Progress, 24, 24, 32, 32, false), libdcp::FileError);
++      BOOST_CHECK_THROW (new libdcp::SoundAsset (p, "build/test/bar", "audio.mxf", &d.Progress, 24, 24, 0, false), libdcp::FileError);
  }
  
  BOOST_AUTO_TEST_CASE (read_dcp)
diff --cc wscript
Simple merge