using boost::optional;
using namespace libdcp;
-CPL::CPL (string directory, string name, ContentKind content_kind, int length, int frames_per_second)
+CPL::CPL (boost::filesystem::path directory, string name, ContentKind content_kind, int length, int frames_per_second)
: _directory (directory)
, _name (name)
, _content_kind (content_kind)
* @param asset_maps AssetMaps to look for assets in.
* @param require_mxfs true to throw an exception if a required MXF file does not exist.
*/
-CPL::CPL (string directory, string file, list<PathAssetMap> asset_maps, bool require_mxfs)
+CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> asset_maps, bool require_mxfs)
: _directory (directory)
, _content_kind (FEATURE)
, _length (0)
CPL::make_kdm (
shared_ptr<const Signer> signer,
shared_ptr<const Certificate> recipient_cert,
+ Key key,
boost::posix_time::ptime from,
boost::posix_time::ptime until,
bool interop,
authenticated_private->set_attribute ("Id", "ID_AuthenticatedPrivate");
xmlAddID (0, doc->cobj(), (const xmlChar *) "ID_AuthenticatedPrivate", authenticated_private->get_attribute("Id")->cobj());
- /* Hex keys that we have already written into the node */
- list<Key> written_keys;
-
- list<shared_ptr<const Asset> > a = assets();
- for (list<shared_ptr<const Asset> >::iterator i = a.begin(); i != a.end(); ++i) {
- /* XXX: non-MXF assets? */
- shared_ptr<const MXFAsset> mxf = boost::dynamic_pointer_cast<const MXFAsset> (*i);
- if (!mxf || find (written_keys.begin(), written_keys.end(), mxf->key ()) != written_keys.end ()) {
- continue;
- }
-
- xmlpp::Element* encrypted_key = authenticated_private->add_child ("EncryptedKey", "enc");
- xmlpp::Element* encryption_method = encrypted_key->add_child ("EncryptionMethod", "enc");
- encryption_method->set_attribute ("Algorithm", "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p");
- encryption_method->add_child("DigestMethod", "ds")->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1");
- xmlpp::Element* cipher_data = authenticated_private->add_child ("CipherData", "enc");
- cipher_data->add_child("CipherValue", "enc")->add_child_text(mxf->key()->hex());
-
- written_keys.push_back (mxf->key().get());
- }
+ xmlpp::Element* encrypted_key = authenticated_private->add_child ("EncryptedKey", "enc");
+ xmlpp::Element* encryption_method = encrypted_key->add_child ("EncryptionMethod", "enc");
+ encryption_method->set_attribute ("Algorithm", "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p");
+ encryption_method->add_child("DigestMethod", "ds")->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1");
+ xmlpp::Element* cipher_data = authenticated_private->add_child ("CipherData", "enc");
+ cipher_data->add_child("CipherValue", "enc")->add_child_text(key.hex());
}
{
#include <libxml++/libxml++.h>
#include "types.h"
#include "certificates.h"
+#include "key.h"
namespace libdcp {
class CPL
{
public:
- CPL (std::string directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
- CPL (std::string directory, std::string file, std::list<PathAssetMap> asset_maps, bool require_mxfs = true);
+ CPL (boost::filesystem::path directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
+ CPL (boost::filesystem::path, std::string file, std::list<PathAssetMap> asset_maps, bool require_mxfs = true);
void add_reel (boost::shared_ptr<Reel> reel);
* @param signer Details of the certificates and private key to sign the KDM with.
* @param recipient_cert The certificate of the projector that this KDM is targeted at. This will contain the
* projector's public key which is used to encrypt the content keys.
+ * @param key Private key used to encrypt the MXFs referenced by this CPL.
* @param from Time that the KDM should be valid from.
* @param until Time that the KDM should be valid until.
* @param interop true to generate an interop KDM, false for SMPTE.
boost::shared_ptr<xmlpp::Document> make_kdm (
boost::shared_ptr<const Signer> signer,
boost::shared_ptr<const Certificate> recipient_cert,
+ Key key,
boost::posix_time::ptime from,
boost::posix_time::ptime until,
bool interop,
private:
std::pair<std::string, boost::shared_ptr<const parse::AssetMapAsset> > asset_from_id (std::list<PathAssetMap>, std::string id) const;
- std::string _directory;
+ boost::filesystem::path _directory;
/** the name of the DCP */
std::string _name;
/** the content kind of the CPL */
using boost::lexical_cast;
using namespace libdcp;
-DCP::DCP (string directory)
+DCP::DCP (boost::filesystem::path directory)
: _directory (directory)
{
boost::filesystem::create_directories (directory);
*
* @param directory Directory containing the DCP's files.
*/
- DCP (std::string directory);
+ DCP (boost::filesystem::path directory);
void read (bool require_mxfs = true);
Files _files;
/** the directory that we are writing to */
- std::string _directory;
+ boost::filesystem::path _directory;
/** our CPLs */
std::list<boost::shared_ptr<CPL> > _cpls;
boost::optional<Key> key () const {
return _key;
}
+
+ ASDCP::AESEncContext* encryption_context () const {
+ return _encryption_context;
+ }
protected:
virtual std::string key_type () const = 0;
shared_ptr<PictureAssetWriter>
StereoPictureAsset::start_write (bool overwrite, bool interop, MXFMetadata const & metadata)
{
- /* XXX: can't we use shared_ptr here? */
return shared_ptr<StereoPictureAssetWriter> (new StereoPictureAssetWriter (this, overwrite, interop, metadata));
}
, _interop (interop)
, _metadata (metadata)
{
-
+
}
struct ASDCPStateBase
ASDCP::JP2K::FrameBuffer frame_buffer;
ASDCP::WriterInfo writer_info;
ASDCP::JP2K::PictureDescriptor picture_descriptor;
+ ASDCP::AESEncContext* encryption_context;
};
struct MonoPictureAssetWriter::ASDCPState : public ASDCPStateBase
: PictureAssetWriter (asset, overwrite, interop, metadata)
, _state (new MonoPictureAssetWriter::ASDCPState)
{
-
+ _state->encryption_context = asset->encryption_context ();
}
StereoPictureAssetWriter::StereoPictureAssetWriter (PictureAsset* asset, bool overwrite, bool interop, MXFMetadata const & metadata)
, _state (new StereoPictureAssetWriter::ASDCPState)
, _next_eye (EYE_LEFT)
{
-
+ _state->encryption_context = asset->encryption_context ();
}
template <class P, class Q>
uint64_t const before_offset = _state->mxf_writer.Tell ();
string hash;
- if (ASDCP_FAILURE (_state->mxf_writer.WriteFrame (_state->frame_buffer, 0, 0, &hash))) {
+ if (ASDCP_FAILURE (_state->mxf_writer.WriteFrame (_state->frame_buffer, _state->encryption_context, 0, &hash))) {
boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string()));
}
_state->mxf_writer.WriteFrame (
_state->frame_buffer,
_next_eye == EYE_LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT,
- 0,
+ _state->encryption_context,
0,
&hash)
)) {
ASDCP::PCM::FrameBuffer frame_buffer;
ASDCP::WriterInfo writer_info;
ASDCP::PCM::AudioDescriptor audio_desc;
+ ASDCP::AESEncContext* encryption_context;
};
SoundAssetWriter::SoundAssetWriter (SoundAsset* a, bool interop, MXFMetadata const & m)
, _frame_buffer_offset (0)
, _metadata (m)
{
+ _state->encryption_context = a->encryption_context ();
+
/* Derived from ASDCP::Wav::SimpleWaveHeader::FillADesc */
_state->audio_desc.EditRate = ASDCP::Rational (_asset->edit_rate(), 1);
_state->audio_desc.AudioSamplingRate = ASDCP::Rational (_asset->sampling_rate(), 1);
void
SoundAssetWriter::write_current_frame ()
{
- if (ASDCP_FAILURE (_state->mxf_writer.WriteFrame (_state->frame_buffer, 0, 0))) {
+ if (ASDCP_FAILURE (_state->mxf_writer.WriteFrame (_state->frame_buffer, _state->encryption_context, 0))) {
boost::throw_exception (MiscError ("could not write audio MXF frame"));
}
mxf_metadata
));
- mp->set_key (libdcp::Key ());
+ libdcp::Key key;
+
+ mp->set_key (key);
shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset (
wav,
mxf_metadata
));
- ms->set_key (libdcp::Key ());
+ ms->set_key (key);
cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ())));
d.add_cpl (cpl);
shared_ptr<xmlpp::Document> kdm = cpl->make_kdm (
signer,
signer->certificates().leaf(),
+ key,
boost::posix_time::time_from_string ("2013-01-01 00:00:00"),
boost::posix_time::time_from_string ("2013-01-08 00:00:00"),
false,