From f976e8ac94dfc6130797c5d98a0399321dce43e7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 25 Aug 2013 12:17:48 +0100 Subject: [PATCH] Untested interop DCP/KDM support. --- examples/make_dcp.cc | 4 ++-- src/cpl.cc | 26 ++++++++++++++++++++------ src/cpl.h | 3 ++- src/dcp.cc | 29 ++++++++++++++++++++--------- src/dcp.h | 8 ++++---- src/mxf_asset.cc | 8 ++++++-- src/mxf_asset.h | 3 ++- src/picture_asset.cc | 18 ++++++++++-------- src/picture_asset.h | 10 ++++++---- src/picture_asset_writer.cc | 13 +++++++------ src/picture_asset_writer.h | 7 ++++--- src/sound_asset.cc | 18 ++++++++++-------- src/sound_asset.h | 9 +++++---- src/util.cc | 10 ++++++++-- src/util.h | 2 +- test/dcp_test.cc | 2 ++ test/error_test.cc | 11 +++++++++-- test/recovery_test.cc | 4 ++-- 18 files changed, 120 insertions(+), 65 deletions(-) diff --git a/examples/make_dcp.cc b/examples/make_dcp.cc index da029f27..14b0da36 100644 --- a/examples/make_dcp.cc +++ b/examples/make_dcp.cc @@ -75,7 +75,7 @@ main () for 2K projectors. */ boost::shared_ptr picture_asset ( - new libdcp::MonoPictureAsset (video_frame, "My Film DCP", "video.mxf", 0, 24, 48, false, libdcp::Size (1998, 1080)) + new libdcp::MonoPictureAsset (video_frame, "My Film DCP", "video.mxf", 0, 24, 48, false, libdcp::Size (1998, 1080), false) ); /* Now we will create a `sound asset', which is made up of a WAV file for each channel of audio. Here we're using @@ -95,7 +95,7 @@ main () /* Now we can create the sound asset using these files */ boost::shared_ptr 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, false, false) ); /* Now that we have the assets, we can create a Reel to put them in and add it to the CPL */ diff --git a/src/cpl.cc b/src/cpl.cc index f585cc08..7c28fc25 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -195,7 +195,7 @@ CPL::add_reel (shared_ptr reel) } void -CPL::write_xml (XMLMetadata const & metadata, shared_ptr crypt) const +CPL::write_xml (bool interop, XMLMetadata const & metadata, shared_ptr crypt) const { boost::filesystem::path p; p /= _directory; @@ -204,7 +204,12 @@ CPL::write_xml (XMLMetadata const & metadata, shared_ptr crypt) cons p /= s.str(); xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("CompositionPlaylist", "http://www.smpte-ra.org/schemas/429-7/2006/CPL"); + xmlpp::Element* root; + if (interop) { + root = doc.create_root_node ("CompositionPlaylist", "http://www.digicine.com/PROTO-ASDCP-CPL-20040511#"); + } else { + root = doc.create_root_node ("CompositionPlaylist", "http://www.smpte-ra.org/schemas/429-7/2006/CPL"); + } if (crypt) { root->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "dsig"); @@ -230,7 +235,7 @@ CPL::write_xml (XMLMetadata const & metadata, shared_ptr crypt) cons } if (crypt) { - sign (root, crypt->certificates, crypt->signer_key); + sign (root, crypt->certificates, crypt->signer_key, interop); } doc.write_to_file_formatted (p.string (), "UTF-8"); @@ -334,6 +339,7 @@ CPL::make_kdm ( shared_ptr recipient_cert, boost::posix_time::ptime from, boost::posix_time::ptime until, + bool interop, MXFMetadata const & mxf_metadata, XMLMetadata const & xml_metadata ) const @@ -449,9 +455,17 @@ CPL::make_kdm ( signed_info->add_child("CanonicalizationMethod", "ds")->set_attribute( "Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments" ); - signed_info->add_child("SignatureMethod", "ds")->set_attribute( - "Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" - ); + + if (interop) { + signed_info->add_child("SignatureMethod", "ds")->set_attribute( + "Algorithm", "http://www.w3.org/2000/09/xmldsig#rsa-sha1" + ); + } else { + signed_info->add_child("SignatureMethod", "ds")->set_attribute( + "Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" + ); + } + { xmlpp::Element* reference = signed_info->add_child("Reference", "ds"); reference->set_attribute("URI", "#ID_AuthenticatedPublic"); diff --git a/src/cpl.h b/src/cpl.h index 2b37257d..94ab877a 100644 --- a/src/cpl.h +++ b/src/cpl.h @@ -88,7 +88,7 @@ public: bool equals (CPL const & other, EqualityOptions options, boost::function note) const; - void write_xml (XMLMetadata const &, boost::shared_ptr) const; + void write_xml (bool, XMLMetadata const &, boost::shared_ptr) const; void write_to_assetmap (xmlpp::Node *) const; void write_to_pkl (xmlpp::Node *) const; @@ -98,6 +98,7 @@ public: boost::shared_ptr, boost::posix_time::ptime from, boost::posix_time::ptime until, + bool, MXFMetadata const &, XMLMetadata const & ) const; diff --git a/src/dcp.cc b/src/dcp.cc index 684e249d..1658200b 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -64,21 +64,21 @@ DCP::DCP (string directory) } void -DCP::write_xml (XMLMetadata const & metadata, shared_ptr crypt) const +DCP::write_xml (XMLMetadata const & metadata, bool interop, shared_ptr crypt) const { for (list >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) { - (*i)->write_xml (metadata, crypt); + (*i)->write_xml (interop, metadata, crypt); } string pkl_uuid = make_uuid (); - string pkl_path = write_pkl (pkl_uuid, metadata, crypt); + string pkl_path = write_pkl (pkl_uuid, interop, metadata, crypt); write_volindex (); - write_assetmap (pkl_uuid, boost::filesystem::file_size (pkl_path), metadata); + write_assetmap (pkl_uuid, boost::filesystem::file_size (pkl_path), interop, metadata); } std::string -DCP::write_pkl (string pkl_uuid, XMLMetadata const & metadata, shared_ptr crypt) const +DCP::write_pkl (string pkl_uuid, bool interop, XMLMetadata const & metadata, shared_ptr crypt) const { assert (!_cpls.empty ()); @@ -89,7 +89,13 @@ DCP::write_pkl (string pkl_uuid, XMLMetadata const & metadata, shared_ptrset_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "dsig"); } @@ -112,7 +118,7 @@ DCP::write_pkl (string pkl_uuid, XMLMetadata const & metadata, shared_ptrcertificates, crypt->signer_key); + sign (pkl, crypt->certificates, crypt->signer_key, interop); } doc.write_to_file_formatted (p.string (), "UTF-8"); @@ -133,14 +139,19 @@ DCP::write_volindex () const } void -DCP::write_assetmap (string pkl_uuid, int pkl_length, XMLMetadata const & metadata) const +DCP::write_assetmap (string pkl_uuid, int pkl_length, bool interop, XMLMetadata const & metadata) const { boost::filesystem::path p; p /= _directory; p /= "ASSETMAP.xml"; xmlpp::Document doc; - xmlpp::Element* root = doc.create_root_node ("AssetMap", "http://www.smpte-ra.org/schemas/429-9/2007/AM"); + xmlpp::Element* root; + if (interop) { + root = doc.create_root_node ("AssetMap", "http://www.digicine.com/PROTO-ASDCP-AM-20040311#"); + } else { + root = doc.create_root_node ("AssetMap", "http://www.smpte-ra.org/schemas/429-9/2007/AM"); + } root->add_child("Id")->add_child_text ("urn:uuid:" + make_uuid()); root->add_child("Creator")->add_child_text (metadata.creator); diff --git a/src/dcp.h b/src/dcp.h index d7919e61..60faeb73 100644 --- a/src/dcp.h +++ b/src/dcp.h @@ -54,7 +54,7 @@ class KDM; * @brief A class to create or read a DCP. */ -class DCP +class DCP : public boost::noncopyable { public: /** Construct a DCP. You can pass an existing DCP's directory @@ -78,7 +78,7 @@ public: /** Write the required XML files to the directory that was * passed into the constructor. */ - void write_xml (XMLMetadata const &, boost::shared_ptr crypt = boost::shared_ptr ()) const; + void write_xml (XMLMetadata const &, bool interop = false, boost::shared_ptr crypt = boost::shared_ptr ()) const; /** Compare this DCP with another, according to various options. * @param other DCP to compare this one to. @@ -111,7 +111,7 @@ private: /** Write the PKL file. * @param pkl_uuid UUID to use. */ - std::string write_pkl (std::string pkl_uuid, XMLMetadata const &, boost::shared_ptr) const; + std::string write_pkl (std::string pkl_uuid, bool, XMLMetadata const &, boost::shared_ptr) const; /** Write the VOLINDEX file */ void write_volindex () const; @@ -120,7 +120,7 @@ private: * @param pkl_uuid UUID of our PKL. * @param pkl_length Length of our PKL in bytes. */ - void write_assetmap (std::string pkl_uuid, int pkl_length, XMLMetadata const &) const; + void write_assetmap (std::string pkl_uuid, int pkl_length, bool, XMLMetadata const &) const; /** @return Assets in all this CPLs in this DCP */ std::list > assets () const; diff --git a/src/mxf_asset.cc b/src/mxf_asset.cc index 1c45dcbc..a7cc0a58 100644 --- a/src/mxf_asset.cc +++ b/src/mxf_asset.cc @@ -87,13 +87,17 @@ MXFAsset::~MXFAsset () } void -MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info, string uuid, MXFMetadata const & metadata) +MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info, string uuid, bool interop, MXFMetadata const & metadata) { writer_info->ProductVersion = metadata.product_version; writer_info->CompanyName = metadata.company_name; writer_info->ProductName = metadata.product_name.c_str(); - writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE; + if (interop) { + writer_info->LabelSetType = ASDCP::LS_MXF_INTEROP; + } else { + writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE; + } unsigned int c; Kumu::hex2bin (uuid.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c); assert (c == Kumu::UUID_Length); diff --git a/src/mxf_asset.h b/src/mxf_asset.h index 763f405b..b9842dda 100644 --- a/src/mxf_asset.h +++ b/src/mxf_asset.h @@ -66,8 +66,9 @@ public: /** Fill in a ADSCP::WriteInfo struct. * @param w struct to fill in. * @param uuid uuid to use. + * @param true to label as interop, false for SMPTE. */ - void fill_writer_info (ASDCP::WriterInfo* w, std::string uuid, MXFMetadata const & metadata); + void fill_writer_info (ASDCP::WriterInfo* w, std::string uuid, bool interop, MXFMetadata const & metadata); void add_typed_key_id (xmlpp::Element *) const; diff --git a/src/picture_asset.cc b/src/picture_asset.cc index 2aec187a..c3a67430 100644 --- a/src/picture_asset.cc +++ b/src/picture_asset.cc @@ -181,11 +181,12 @@ MonoPictureAsset::MonoPictureAsset ( int intrinsic_duration, bool encrypted, Size size, + bool interop, MXFMetadata const & metadata ) : PictureAsset (directory, mxf_name, progress, fps, intrinsic_duration, encrypted, size) { - construct (get_path, metadata); + construct (get_path, interop, metadata); } MonoPictureAsset::MonoPictureAsset ( @@ -197,11 +198,12 @@ MonoPictureAsset::MonoPictureAsset ( int intrinsic_duration, bool encrypted, Size size, + bool interop, MXFMetadata const & metadata ) : PictureAsset (directory, mxf_name, progress, fps, intrinsic_duration, encrypted, size) { - construct (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files), metadata); + construct (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files), interop, metadata); } MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name, int fps, Size size) @@ -231,7 +233,7 @@ MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name) } void -MonoPictureAsset::construct (boost::function get_path, MXFMetadata const & metadata) +MonoPictureAsset::construct (boost::function get_path, bool interop, MXFMetadata const & metadata) { ASDCP::JP2K::CodestreamParser j2k_parser; ASDCP::JP2K::FrameBuffer frame_buffer (4 * Kumu::Megabyte); @@ -244,7 +246,7 @@ MonoPictureAsset::construct (boost::function get_path, MXFMetadata picture_desc.EditRate = ASDCP::Rational (_edit_rate, 1); ASDCP::WriterInfo writer_info; - fill_writer_info (&writer_info, _uuid, 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))) { @@ -442,10 +444,10 @@ StereoPictureAsset::get_frame (int n) const } shared_ptr -MonoPictureAsset::start_write (bool overwrite, MXFMetadata const & metadata) +MonoPictureAsset::start_write (bool overwrite, bool interop, MXFMetadata const & metadata) { /* XXX: can't we use shared_ptr here? */ - return shared_ptr (new MonoPictureAssetWriter (this, overwrite, metadata)); + return shared_ptr (new MonoPictureAssetWriter (this, overwrite, interop, metadata)); } string @@ -461,9 +463,9 @@ StereoPictureAsset::StereoPictureAsset (string directory, string mxf_name, int f } shared_ptr -StereoPictureAsset::start_write (bool overwrite, MXFMetadata const & metadata) +StereoPictureAsset::start_write (bool overwrite, bool interop, MXFMetadata const & metadata) { /* XXX: can't we use shared_ptr here? */ - return shared_ptr (new StereoPictureAssetWriter (this, overwrite, metadata)); + return shared_ptr (new StereoPictureAssetWriter (this, overwrite, interop, metadata)); } diff --git a/src/picture_asset.h b/src/picture_asset.h index df8415d3..e99b1f0c 100644 --- a/src/picture_asset.h +++ b/src/picture_asset.h @@ -73,7 +73,7 @@ public: * MXF file does not exist. * @param metadata MXF metadata to use. */ - virtual boost::shared_ptr start_write (bool overwrite, MXFMetadata const & metadata = MXFMetadata ()) = 0; + virtual boost::shared_ptr start_write (bool overwrite, bool interop, MXFMetadata const & metadata = MXFMetadata ()) = 0; bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; @@ -124,6 +124,7 @@ public: int intrinsic_duration, bool encrypted, Size size, + bool interop, MXFMetadata const & metadata = MXFMetadata () ); @@ -148,6 +149,7 @@ public: int intrinsic_duration, bool encrypted, Size size, + bool interop, MXFMetadata const & metadata = MXFMetadata () ); @@ -168,14 +170,14 @@ public: MonoPictureAsset (std::string directory, std::string mxf_name, int fps, Size size); /** Start a progressive write to a MonoPictureAsset */ - boost::shared_ptr start_write (bool, MXFMetadata const & metadata = MXFMetadata ()); + boost::shared_ptr start_write (bool, bool, MXFMetadata const & metadata = MXFMetadata ()); boost::shared_ptr get_frame (int n) const; bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; private: std::string path_from_list (int f, std::vector const & files) const; - void construct (boost::function, MXFMetadata const &); + void construct (boost::function, bool, MXFMetadata const &); std::string cpl_node_name () const; int edit_rate_factor () const; }; @@ -197,7 +199,7 @@ public: StereoPictureAsset (std::string directory, std::string mxf_name, int fps, Size size); /** Start a progressive write to a StereoPictureAsset */ - boost::shared_ptr start_write (bool, MXFMetadata const & metadata = MXFMetadata ()); + boost::shared_ptr start_write (bool, bool, MXFMetadata const & metadata = MXFMetadata ()); boost::shared_ptr get_frame (int n) const; bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; diff --git a/src/picture_asset_writer.cc b/src/picture_asset_writer.cc index 1789562f..e16dac72 100644 --- a/src/picture_asset_writer.cc +++ b/src/picture_asset_writer.cc @@ -52,12 +52,13 @@ FrameInfo::write (ostream& s) } -PictureAssetWriter::PictureAssetWriter (PictureAsset* asset, bool overwrite, MXFMetadata const & metadata) +PictureAssetWriter::PictureAssetWriter (PictureAsset* asset, bool overwrite, bool interop, MXFMetadata const & metadata) : _asset (asset) , _frames_written (0) , _started (false) , _finalized (false) , _overwrite (overwrite) + , _interop (interop) , _metadata (metadata) { @@ -88,15 +89,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, MXFMetadata const & metadata) - : PictureAssetWriter (asset, overwrite, metadata) +MonoPictureAssetWriter::MonoPictureAssetWriter (PictureAsset* asset, bool overwrite, bool interop, MXFMetadata const & metadata) + : PictureAssetWriter (asset, overwrite, interop, metadata) , _state (new MonoPictureAssetWriter::ASDCPState) { } -StereoPictureAssetWriter::StereoPictureAssetWriter (PictureAsset* asset, bool overwrite, MXFMetadata const & metadata) - : PictureAssetWriter (asset, overwrite, metadata) +StereoPictureAssetWriter::StereoPictureAssetWriter (PictureAsset* asset, bool overwrite, bool interop, MXFMetadata const & metadata) + : PictureAssetWriter (asset, overwrite, interop, metadata) , _state (new StereoPictureAssetWriter::ASDCPState) , _next_eye (EYE_LEFT) { @@ -113,7 +114,7 @@ void libdcp::start (PictureAssetWriter* writer, shared_ptr

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->_metadata); + asset->fill_writer_info (&state->writer_info, asset->uuid(), writer->_interop, writer->_metadata); if (ASDCP_FAILURE (state->mxf_writer.OpenWrite ( asset->path().string().c_str(), diff --git a/src/picture_asset_writer.h b/src/picture_asset_writer.h index a0f0bdc8..b6d2e92c 100644 --- a/src/picture_asset_writer.h +++ b/src/picture_asset_writer.h @@ -58,7 +58,7 @@ protected: template friend void start (PictureAssetWriter *, boost::shared_ptr

, Q *, uint8_t *, int); - PictureAssetWriter (PictureAsset *, bool, MXFMetadata const &); + PictureAssetWriter (PictureAsset *, bool, bool, MXFMetadata const &); PictureAsset* _asset; @@ -71,6 +71,7 @@ protected: /** true if finalize() has been called */ bool _finalized; bool _overwrite; + bool _interop; MXFMetadata _metadata; }; @@ -94,7 +95,7 @@ public: private: friend class MonoPictureAsset; - MonoPictureAssetWriter (PictureAsset *, bool, MXFMetadata const &); + MonoPictureAssetWriter (PictureAsset *, bool, bool, MXFMetadata const &); void start (uint8_t *, int); /* do this with an opaque pointer so we don't have to include @@ -125,7 +126,7 @@ public: private: friend class StereoPictureAsset; - StereoPictureAssetWriter (PictureAsset *, bool, MXFMetadata const &); + StereoPictureAssetWriter (PictureAsset *, bool, bool, MXFMetadata const &); void start (uint8_t *, int); /* do this with an opaque pointer so we don't have to include diff --git a/src/sound_asset.cc b/src/sound_asset.cc index 0d829b75..51f49d0e 100644 --- a/src/sound_asset.cc +++ b/src/sound_asset.cc @@ -50,6 +50,7 @@ SoundAsset::SoundAsset ( int fps, int intrinsic_duration, bool encrypted, + bool interop, MXFMetadata const & metadata ) : MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration, encrypted) @@ -58,7 +59,7 @@ SoundAsset::SoundAsset ( { assert (_channels); - construct (boost::bind (&SoundAsset::path_from_channel, this, _1, files), metadata); + construct (boost::bind (&SoundAsset::path_from_channel, this, _1, files), interop, metadata); } SoundAsset::SoundAsset ( @@ -70,6 +71,7 @@ SoundAsset::SoundAsset ( int intrinsic_duration, int channels, bool encrypted, + bool interop, MXFMetadata const & metadata ) : MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration, encrypted) @@ -78,7 +80,7 @@ SoundAsset::SoundAsset ( { assert (_channels); - construct (get_path, metadata); + construct (get_path, interop, metadata); } SoundAsset::SoundAsset (string directory, string mxf_name) @@ -119,7 +121,7 @@ SoundAsset::path_from_channel (Channel channel, vector const & files) } void -SoundAsset::construct (boost::function get_path, MXFMetadata const & metadata) +SoundAsset::construct (boost::function get_path, bool interop, MXFMetadata const & metadata) { ASDCP::Rational asdcp_edit_rate (_edit_rate, 1); @@ -172,7 +174,7 @@ SoundAsset::construct (boost::function get_path, MXFMetadata c frame_buffer.Size (ASDCP::PCM::CalcFrameBufferSize (audio_desc)); ASDCP::WriterInfo writer_info; - MXFAsset::fill_writer_info (&writer_info, _uuid, 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 +306,10 @@ SoundAsset::get_frame (int n) const } shared_ptr -SoundAsset::start_write (MXFMetadata const & metadata) +SoundAsset::start_write (bool interop, MXFMetadata const & metadata) { /* XXX: can't we use a shared_ptr here? */ - return shared_ptr (new SoundAssetWriter (this, metadata)); + return shared_ptr (new SoundAssetWriter (this, interop, metadata)); } struct SoundAssetWriter::ASDCPState @@ -318,7 +320,7 @@ struct SoundAssetWriter::ASDCPState ASDCP::PCM::AudioDescriptor audio_desc; }; -SoundAssetWriter::SoundAssetWriter (SoundAsset* a, MXFMetadata const & m) +SoundAssetWriter::SoundAssetWriter (SoundAsset* a, bool interop, MXFMetadata const & m) : _state (new SoundAssetWriter::ASDCPState) , _asset (a) , _finalized (false) @@ -341,7 +343,7 @@ SoundAssetWriter::SoundAssetWriter (SoundAsset* a, MXFMetadata const & m) _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 (), _metadata); + _asset->fill_writer_info (&_state->writer_info, _asset->uuid (), interop, _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())); diff --git a/src/sound_asset.h b/src/sound_asset.h index 06ad79b4..b7542c73 100644 --- a/src/sound_asset.h +++ b/src/sound_asset.h @@ -43,7 +43,7 @@ public: private: friend class SoundAsset; - SoundAssetWriter (SoundAsset *, MXFMetadata const &); + SoundAssetWriter (SoundAsset *, bool interop, MXFMetadata const &); /* no copy construction */ SoundAssetWriter (SoundAssetWriter const &); @@ -90,6 +90,7 @@ public: int fps, int intrinsic_duration, bool encrypted, + bool interop, MXFMetadata const & metadata = MXFMetadata () ); @@ -113,6 +114,7 @@ public: int intrinsic_duration, int channels, bool encrypted, + bool interop, MXFMetadata const & metadata = MXFMetadata () ); @@ -129,9 +131,8 @@ public: int sampling_rate ); - boost::shared_ptr start_write (MXFMetadata const & metadata = MXFMetadata ()); + boost::shared_ptr start_write (bool, MXFMetadata const & metadata = MXFMetadata ()); - bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; boost::shared_ptr get_frame (int n) const; @@ -146,7 +147,7 @@ public: private: std::string key_type () const; - void construct (boost::function get_path, MXFMetadata const &); + void construct (boost::function get_path, bool interop, MXFMetadata const &); std::string path_from_channel (Channel channel, std::vector const & files); std::string cpl_node_name () const; diff --git a/src/util.cc b/src/util.cc index e0727d9a..875693bf 100644 --- a/src/util.cc +++ b/src/util.cc @@ -286,7 +286,7 @@ libdcp::add_signer (xmlpp::Element* parent, CertificateChain const & certificate } void -libdcp::sign (xmlpp::Element* parent, CertificateChain const & certificates, string const & signer_key) +libdcp::sign (xmlpp::Element* parent, CertificateChain const & certificates, string const & signer_key, bool interop) { add_signer (parent, certificates, "dsig"); @@ -295,7 +295,13 @@ libdcp::sign (xmlpp::Element* parent, CertificateChain const & certificates, str { xmlpp::Element* signed_info = signature->add_child ("SignedInfo", "dsig"); signed_info->add_child("CanonicalizationMethod", "dsig")->set_attribute ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315"); - signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"); + + if (interop) { + signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#rsa-sha1"); + } else { + signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"); + } + { xmlpp::Element* reference = signed_info->add_child("Reference", "dsig"); reference->set_attribute ("URI", ""); diff --git a/src/util.h b/src/util.h index 8a9140c6..9153dbda 100644 --- a/src/util.h +++ b/src/util.h @@ -68,7 +68,7 @@ extern boost::shared_ptr decompress_j2k (uint8_t* data, int64_t size, extern void init (); -extern void sign (xmlpp::Element* parent, CertificateChain const & certificates, std::string const & signer_key); +extern void sign (xmlpp::Element* parent, CertificateChain const & certificates, std::string const & signer_key, bool interop); extern void add_signature_value (xmlpp::Element* parent, CertificateChain const & certificates, std::string const & signer_key, std::string const & ns); extern void add_signer (xmlpp::Element* parent, CertificateChain const & certificates, std::string const & ns); diff --git a/test/dcp_test.cc b/test/dcp_test.cc index 9699eeb2..970ca9dd 100644 --- a/test/dcp_test.cc +++ b/test/dcp_test.cc @@ -47,6 +47,7 @@ BOOST_AUTO_TEST_CASE (dcp_test) 24, false, libdcp::Size (32, 32), + false, mxf_meta )); @@ -59,6 +60,7 @@ BOOST_AUTO_TEST_CASE (dcp_test) 24, 2, false, + false, mxf_meta )); diff --git a/test/error_test.cc b/test/error_test.cc index a2a5716c..380363b4 100644 --- a/test/error_test.cc +++ b/test/error_test.cc @@ -28,6 +28,13 @@ 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, false, libdcp::Size (32, 32)), 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/fred", "video.mxf", &d.Progress, 24, 24, false, libdcp::Size (32, 32), false), + libdcp::FileError + ); + + BOOST_CHECK_THROW ( + new libdcp::SoundAsset (p, "build/test/fred", "audio.mxf", &d.Progress, 24, 24, false, false), + libdcp::FileError + ); } diff --git a/test/recovery_test.cc b/test/recovery_test.cc index df9a839c..d8ffea6a 100644 --- a/test/recovery_test.cc +++ b/test/recovery_test.cc @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE (recovery) boost::filesystem::remove_all ("build/test/baz"); boost::filesystem::create_directories ("build/test/baz"); shared_ptr mp (new libdcp::MonoPictureAsset ("build/test/baz", "video1.mxf", 24, libdcp::Size (32, 32))); - shared_ptr writer = mp->start_write (false); + shared_ptr writer = mp->start_write (false, false); int written_size = 0; for (int i = 0; i < 24; ++i) { @@ -70,7 +70,7 @@ BOOST_AUTO_TEST_CASE (recovery) #endif mp.reset (new libdcp::MonoPictureAsset ("build/test/baz", "video2.mxf", 24, libdcp::Size (32, 32))); - writer = mp->start_write (true); + writer = mp->start_write (true, false); writer->write (data, size); -- 2.30.2