summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-04 11:13:04 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-04 11:13:04 +0100
commitaf87bfc82beee0b0600558c84c3843dfd5a252f6 (patch)
tree6f0cb5a87ba4662ac1e23fae67589be9d374e4f6
parent09ad2806848f5c3609b7915da504f94db099e3af (diff)
Split metadata into XML and MXF bits; remove singleton.
-rw-r--r--examples/make_dcp.cc3
-rw-r--r--src/cpl.cc10
-rw-r--r--src/cpl.h3
-rw-r--r--src/dcp.cc24
-rw-r--r--src/dcp.h7
-rw-r--r--src/metadata.cc30
-rw-r--r--src/metadata.h29
-rw-r--r--src/mxf_asset.cc8
-rw-r--r--src/mxf_asset.h6
-rw-r--r--src/picture_asset.cc27
-rw-r--r--src/picture_asset.h14
-rw-r--r--src/sound_asset.cc23
-rw-r--r--src/sound_asset.h15
-rw-r--r--src/test_mode.cc45
-rw-r--r--src/test_mode.h29
-rw-r--r--src/wscript3
-rw-r--r--test/tests.cc23
17 files changed, 124 insertions, 175 deletions
diff --git a/examples/make_dcp.cc b/examples/make_dcp.cc
index 06dd05ab..0d6a8215 100644
--- a/examples/make_dcp.cc
+++ b/examples/make_dcp.cc
@@ -108,7 +108,8 @@ main ()
/* Finally, we call this to write the XML description files to the DCP. After this, the DCP
is ready to ingest and play.
*/
- dcp.write_xml ();
+ libdcp::XMLMetadata metadata;
+ dcp.write_xml (metadata);
return 0;
}
diff --git a/src/cpl.cc b/src/cpl.cc
index 90c48ae9..18526b24 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -168,7 +168,7 @@ CPL::add_reel (shared_ptr<const Reel> reel)
}
void
-CPL::write_xml () const
+CPL::write_xml (XMLMetadata const & metadata) const
{
boost::filesystem::path p;
p /= _directory;
@@ -181,13 +181,13 @@ CPL::write_xml () const
<< "<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"
+ << " <IssueDate>" << metadata.issue_date << "</IssueDate>\n"
+ << " <Creator>" << metadata.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"
+ << " <Id>urn:uri:" << _uuid << "_" << metadata.issue_date << "</Id>\n"
+ << " <LabelText>" << _uuid << "_" << metadata.issue_date << "</LabelText>\n"
<< " </ContentVersion>\n"
<< " <RatingList/>\n"
<< " <ReelList>\n";
diff --git a/src/cpl.h b/src/cpl.h
index 3be10894..0abff749 100644
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -27,6 +27,7 @@ namespace libdcp {
class AssetMap;
class Asset;
class Reel;
+class XMLMetadata;
/** @brief A CPL within a DCP */
class CPL
@@ -69,7 +70,7 @@ public:
bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
- void write_xml () const;
+ void write_xml (XMLMetadata const &) const;
void write_to_assetmap (std::ostream& s) const;
void write_to_pkl (std::ostream& s) const;
diff --git a/src/dcp.cc b/src/dcp.cc
index e74e0d95..7af3f353 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -58,21 +58,21 @@ DCP::DCP (string directory)
}
void
-DCP::write_xml () const
+DCP::write_xml (XMLMetadata const & metadata) const
{
for (list<shared_ptr<const CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
- (*i)->write_xml ();
+ (*i)->write_xml (metadata);
}
string pkl_uuid = make_uuid ();
- string pkl_path = write_pkl (pkl_uuid);
+ string pkl_path = write_pkl (pkl_uuid, metadata);
write_volindex ();
- write_assetmap (pkl_uuid, boost::filesystem::file_size (pkl_path));
+ write_assetmap (pkl_uuid, boost::filesystem::file_size (pkl_path), metadata);
}
std::string
-DCP::write_pkl (string pkl_uuid) const
+DCP::write_pkl (string pkl_uuid, XMLMetadata const & metadata) const
{
assert (!_cpls.empty ());
@@ -88,9 +88,9 @@ DCP::write_pkl (string pkl_uuid) const
<< " <Id>urn:uuid:" << pkl_uuid << "</Id>\n"
/* XXX: this is a bit of a hack */
<< " <AnnotationText>" << _cpls.front()->name() << "</AnnotationText>\n"
- << " <IssueDate>" << Metadata::instance()->issue_date << "</IssueDate>\n"
- << " <Issuer>" << Metadata::instance()->issuer << "</Issuer>\n"
- << " <Creator>" << Metadata::instance()->creator << "</Creator>\n"
+ << " <IssueDate>" << metadata.issue_date << "</IssueDate>\n"
+ << " <Issuer>" << metadata.issuer << "</Issuer>\n"
+ << " <Creator>" << metadata.creator << "</Creator>\n"
<< " <AssetList>\n";
list<shared_ptr<const Asset> > a = assets ();
@@ -123,7 +123,7 @@ DCP::write_volindex () const
}
void
-DCP::write_assetmap (string pkl_uuid, int pkl_length) const
+DCP::write_assetmap (string pkl_uuid, int pkl_length, XMLMetadata const & metadata) const
{
boost::filesystem::path p;
p /= _directory;
@@ -133,10 +133,10 @@ DCP::write_assetmap (string pkl_uuid, int pkl_length) const
am << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
<< "<AssetMap xmlns=\"http://www.smpte-ra.org/schemas/429-9/2007/AM\">\n"
<< " <Id>urn:uuid:" << make_uuid() << "</Id>\n"
- << " <Creator>" << Metadata::instance()->creator << "</Creator>\n"
+ << " <Creator>" << metadata.creator << "</Creator>\n"
<< " <VolumeCount>1</VolumeCount>\n"
- << " <IssueDate>" << Metadata::instance()->issue_date << "</IssueDate>\n"
- << " <Issuer>" << Metadata::instance()->issuer << "</Issuer>\n"
+ << " <IssueDate>" << metadata.issue_date << "</IssueDate>\n"
+ << " <Issuer>" << metadata.issuer << "</Issuer>\n"
<< " <AssetList>\n";
am << " <Asset>\n"
diff --git a/src/dcp.h b/src/dcp.h
index decac4f2..42c0c6d9 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -45,6 +45,7 @@ class SubtitleAsset;
class Reel;
class AssetMap;
class CPL;
+class XMLMetadata;
/** @class DCP
* @brief A class to create or read a DCP.
@@ -74,7 +75,7 @@ public:
/** Write the required XML files to the directory that was
* passed into the constructor.
*/
- void write_xml () const;
+ void write_xml (XMLMetadata const &) const;
/** Compare this DCP with another, according to various options.
* @param other DCP to compare this one to.
@@ -103,7 +104,7 @@ private:
/** Write the PKL file.
* @param pkl_uuid UUID to use.
*/
- std::string write_pkl (std::string pkl_uuid) const;
+ std::string write_pkl (std::string pkl_uuid, XMLMetadata const &) const;
/** Write the VOLINDEX file */
void write_volindex () const;
@@ -112,7 +113,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) const;
+ void write_assetmap (std::string pkl_uuid, int pkl_length, XMLMetadata const &) const;
/** @return Assets in all this CPLs in this DCP */
std::list<boost::shared_ptr<const Asset> > assets () const;
diff --git a/src/metadata.cc b/src/metadata.cc
index 7e900e50..2967ac1d 100644
--- a/src/metadata.cc
+++ b/src/metadata.cc
@@ -27,16 +27,25 @@
using namespace std;
using namespace libdcp;
-Metadata* Metadata::_instance = 0;
-
-/** Construct a Metadata object with some default values */
-Metadata::Metadata ()
+MXFMetadata::MXFMetadata ()
: company_name ("libdcp")
, product_name ("libdcp")
, product_version (LIBDCP_VERSION)
- , issuer ("libdcp" LIBDCP_VERSION)
+{
+
+}
+
+
+XMLMetadata::XMLMetadata ()
+ : issuer ("libdcp" LIBDCP_VERSION)
, creator ("libdcp" LIBDCP_VERSION)
{
+ set_issue_date_now ();
+}
+
+void
+XMLMetadata::set_issue_date_now ()
+{
char buffer[64];
time_t now;
time (&now);
@@ -44,15 +53,4 @@ Metadata::Metadata ()
strftime (buffer, 64, "%Y-%m-%dT%I:%M:%S+00:00", tm);
issue_date = string (buffer);
}
-
-/** @return Singleton Metadata instance */
-Metadata *
-Metadata::instance ()
-{
- if (_instance == 0) {
- _instance = new Metadata;
- }
-
- return _instance;
-}
diff --git a/src/metadata.h b/src/metadata.h
index 1610491e..7336766d 100644
--- a/src/metadata.h
+++ b/src/metadata.h
@@ -17,6 +17,9 @@
*/
+#ifndef LIBDCP_METADATA_H
+#define LIBDCP_METADATA_H
+
/** @file src/metadata.h
* @brief Metadata for writing to the DCP.
*/
@@ -26,28 +29,28 @@
namespace libdcp
{
-/** @brief A class to hold various metadata that will be written
- * to the DCP.
- *
- * The values are initialised, and can be modified if desired.
- */
-class Metadata
+class MXFMetadata
{
public:
- static Metadata* instance ();
+ MXFMetadata ();
std::string company_name;
std::string product_name;
std::string product_version;
+};
+
+class XMLMetadata
+{
+public:
+ XMLMetadata ();
+
+ void set_issue_date_now ();
+
std::string issuer;
std::string creator;
std::string issue_date;
-
-private:
- Metadata ();
-
- /** Singleton instance of Metadata */
- static Metadata* _instance;
};
}
+
+#endif
diff --git a/src/mxf_asset.cc b/src/mxf_asset.cc
index 144532f8..eb323f59 100644
--- a/src/mxf_asset.cc
+++ b/src/mxf_asset.cc
@@ -58,11 +58,11 @@ MXFAsset::MXFAsset (string directory, string file_name, boost::signals2::signal<
}
void
-MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info, string uuid)
+MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info, string uuid, MXFMetadata const & metadata)
{
- writer_info->ProductVersion = Metadata::instance()->product_version;
- writer_info->CompanyName = Metadata::instance()->company_name;
- writer_info->ProductName = Metadata::instance()->product_name.c_str();
+ 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;
unsigned int c;
diff --git a/src/mxf_asset.h b/src/mxf_asset.h
index 29b3c1b0..f5cee5de 100644
--- a/src/mxf_asset.h
+++ b/src/mxf_asset.h
@@ -26,6 +26,8 @@
namespace libdcp
{
+class MXFMetadata;
+
/** @brief Parent class for assets which have MXF files */
class MXFAsset : public Asset
{
@@ -75,10 +77,10 @@ public:
* @param w struct to fill in.
* @param uuid uuid to use.
*/
- static void fill_writer_info (ASDCP::WriterInfo* w, std::string uuid);
+ static void fill_writer_info (ASDCP::WriterInfo* w, std::string uuid, MXFMetadata const & metadata);
protected:
-
+
/** Signal to emit to report progress, or 0 */
boost::signals2::signal<void (float)>* _progress;
/** The edit rate; this is normally equal to the number of video frames per second */
diff --git a/src/picture_asset.cc b/src/picture_asset.cc
index f2982b47..d98ef066 100644
--- a/src/picture_asset.cc
+++ b/src/picture_asset.cc
@@ -146,10 +146,12 @@ MonoPictureAsset::MonoPictureAsset (
boost::signals2::signal<void (float)>* progress,
int fps,
int intrinsic_duration,
- Size size)
+ Size size,
+ MXFMetadata const & metadata
+ )
: PictureAsset (directory, mxf_name, progress, fps, intrinsic_duration, size)
{
- construct (get_path);
+ construct (get_path, metadata);
}
MonoPictureAsset::MonoPictureAsset (
@@ -159,10 +161,12 @@ MonoPictureAsset::MonoPictureAsset (
boost::signals2::signal<void (float)>* progress,
int fps,
int intrinsic_duration,
- Size size)
+ Size size,
+ MXFMetadata const & metadata
+ )
: PictureAsset (directory, mxf_name, progress, fps, intrinsic_duration, size)
{
- construct (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files));
+ construct (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files), metadata);
}
MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name, int fps, Size size)
@@ -192,7 +196,7 @@ MonoPictureAsset::MonoPictureAsset (string directory, string mxf_name)
}
void
-MonoPictureAsset::construct (boost::function<string (int)> get_path)
+MonoPictureAsset::construct (boost::function<string (int)> get_path, MXFMetadata const & metadata)
{
ASDCP::JP2K::CodestreamParser j2k_parser;
ASDCP::JP2K::FrameBuffer frame_buffer (4 * Kumu::Megabyte);
@@ -205,7 +209,7 @@ MonoPictureAsset::construct (boost::function<string (int)> get_path)
picture_desc.EditRate = ASDCP::Rational (_edit_rate, 1);
ASDCP::WriterInfo writer_info;
- fill_writer_info (&writer_info, _uuid);
+ fill_writer_info (&writer_info, _uuid, metadata);
ASDCP::JP2K::MXFWriter mxf_writer;
if (ASDCP_FAILURE (mxf_writer.OpenWrite (path().string().c_str(), writer_info, picture_desc, 16384, false))) {
@@ -402,10 +406,10 @@ StereoPictureAsset::get_frame (int n) const
}
shared_ptr<MonoPictureAssetWriter>
-MonoPictureAsset::start_write (bool overwrite)
+MonoPictureAsset::start_write (bool overwrite, MXFMetadata const & metadata)
{
- /* XXX: can't we use a shared_ptr here? */
- return shared_ptr<MonoPictureAssetWriter> (new MonoPictureAssetWriter (this, overwrite));
+ /* XXX: can't we use shared_ptr here? */
+ return shared_ptr<MonoPictureAssetWriter> (new MonoPictureAssetWriter (this, overwrite, metadata));
}
FrameInfo::FrameInfo (istream& s)
@@ -436,13 +440,14 @@ struct MonoPictureAssetWriter::ASDCPState
/** @param a Asset to write to. `a' must not be deleted while
* this writer class still exists, or bad things will happen.
*/
-MonoPictureAssetWriter::MonoPictureAssetWriter (MonoPictureAsset* a, bool overwrite)
+MonoPictureAssetWriter::MonoPictureAssetWriter (MonoPictureAsset* a, bool overwrite, MXFMetadata const & m)
: _state (new MonoPictureAssetWriter::ASDCPState)
, _asset (a)
, _frames_written (0)
, _started (false)
, _finalized (false)
, _overwrite (overwrite)
+ , _metadata (m)
{
}
@@ -458,7 +463,7 @@ MonoPictureAssetWriter::start (uint8_t* data, int size)
_state->j2k_parser.FillPictureDescriptor (_state->picture_descriptor);
_state->picture_descriptor.EditRate = ASDCP::Rational (_asset->edit_rate(), 1);
- MXFAsset::fill_writer_info (&_state->writer_info, _asset->uuid());
+ MXFAsset::fill_writer_info (&_state->writer_info, _asset->uuid(), _metadata);
if (ASDCP_FAILURE (_state->mxf_writer.OpenWrite (
_asset->path().string().c_str(),
diff --git a/src/picture_asset.h b/src/picture_asset.h
index c9226b1f..59c4dc00 100644
--- a/src/picture_asset.h
+++ b/src/picture_asset.h
@@ -27,6 +27,7 @@
#include <openjpeg.h>
#include "mxf_asset.h"
#include "util.h"
+#include "metadata.h"
namespace libdcp
{
@@ -121,7 +122,7 @@ public:
private:
friend class MonoPictureAsset;
- MonoPictureAssetWriter (MonoPictureAsset *, bool);
+ MonoPictureAssetWriter (MonoPictureAsset *, bool, MXFMetadata const &);
void start (uint8_t *, int);
/* no copy construction */
@@ -142,6 +143,7 @@ private:
/** true if finalize() has been called */
bool _finalized;
bool _overwrite;
+ MXFMetadata _metadata;
};
/** A 2D (monoscopic) picture asset */
@@ -166,7 +168,8 @@ public:
boost::signals2::signal<void (float)>* progress,
int fps,
int intrinsic_duration,
- Size size
+ Size size,
+ MXFMetadata const & metadata = MXFMetadata ()
);
/** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
@@ -187,7 +190,8 @@ public:
boost::signals2::signal<void (float)>* progress,
int fps,
int intrinsic_duration,
- Size size
+ Size size,
+ MXFMetadata const & metadata = MXFMetadata ()
);
/** Construct a MonoPictureAsset, reading the MXF from disk.
@@ -207,14 +211,14 @@ public:
MonoPictureAsset (std::string directory, std::string mxf_name, int fps, Size size);
/** Start a progressive write to a MonoPictureAsset */
- boost::shared_ptr<MonoPictureAssetWriter> start_write (bool);
+ boost::shared_ptr<MonoPictureAssetWriter> start_write (bool, MXFMetadata const & metadata = MXFMetadata ());
boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
private:
std::string path_from_list (int f, std::vector<std::string> const & files) const;
- void construct (boost::function<std::string (int)>);
+ void construct (boost::function<std::string (int)>, MXFMetadata const &);
};
/** A 3D (stereoscopic) picture asset */
diff --git a/src/sound_asset.cc b/src/sound_asset.cc
index 6e29aadf..9b6b48aa 100644
--- a/src/sound_asset.cc
+++ b/src/sound_asset.cc
@@ -46,7 +46,8 @@ SoundAsset::SoundAsset (
string directory,
string mxf_name,
boost::signals2::signal<void (float)>* progress,
- int fps, int intrinsic_duration
+ int fps, int intrinsic_duration,
+ MXFMetadata const & metadata
)
: MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration)
, _channels (files.size ())
@@ -54,7 +55,7 @@ SoundAsset::SoundAsset (
{
assert (_channels);
- construct (boost::bind (&SoundAsset::path_from_channel, this, _1, files));
+ construct (boost::bind (&SoundAsset::path_from_channel, this, _1, files), metadata);
}
SoundAsset::SoundAsset (
@@ -62,7 +63,8 @@ SoundAsset::SoundAsset (
string directory,
string mxf_name,
boost::signals2::signal<void (float)>* progress,
- int fps, int intrinsic_duration, int channels
+ int fps, int intrinsic_duration, int channels,
+ MXFMetadata const & metadata
)
: MXFAsset (directory, mxf_name, progress, fps, intrinsic_duration)
, _channels (channels)
@@ -70,7 +72,7 @@ SoundAsset::SoundAsset (
{
assert (_channels);
- construct (get_path);
+ construct (get_path, metadata);
}
SoundAsset::SoundAsset (string directory, string mxf_name)
@@ -111,7 +113,7 @@ SoundAsset::path_from_channel (Channel channel, vector<string> const & files)
}
void
-SoundAsset::construct (boost::function<string (Channel)> get_path)
+SoundAsset::construct (boost::function<string (Channel)> get_path, MXFMetadata const & metadata)
{
ASDCP::Rational asdcp_edit_rate (_edit_rate, 1);
@@ -164,7 +166,7 @@ SoundAsset::construct (boost::function<string (Channel)> get_path)
frame_buffer.Size (ASDCP::PCM::CalcFrameBufferSize (audio_desc));
ASDCP::WriterInfo writer_info;
- MXFAsset::fill_writer_info (&writer_info, _uuid);
+ MXFAsset::fill_writer_info (&writer_info, _uuid, metadata);
ASDCP::PCM::MXFWriter mxf_writer;
if (ASDCP_FAILURE (mxf_writer.OpenWrite (path().string().c_str(), writer_info, audio_desc))) {
@@ -303,10 +305,10 @@ SoundAsset::get_frame (int n) const
}
shared_ptr<SoundAssetWriter>
-SoundAsset::start_write ()
+SoundAsset::start_write (MXFMetadata const & metadata)
{
/* XXX: can't we use a shared_ptr here? */
- return shared_ptr<SoundAssetWriter> (new SoundAssetWriter (this));
+ return shared_ptr<SoundAssetWriter> (new SoundAssetWriter (this, metadata));
}
struct SoundAssetWriter::ASDCPState
@@ -317,12 +319,13 @@ struct SoundAssetWriter::ASDCPState
ASDCP::PCM::AudioDescriptor audio_desc;
};
-SoundAssetWriter::SoundAssetWriter (SoundAsset* a)
+SoundAssetWriter::SoundAssetWriter (SoundAsset* a, MXFMetadata const & m)
: _state (new SoundAssetWriter::ASDCPState)
, _asset (a)
, _finalized (false)
, _frames_written (0)
, _frame_buffer_offset (0)
+ , _metadata (m)
{
/* Derived from ASDCP::Wav::SimpleWaveHeader::FillADesc */
_state->audio_desc.EditRate = ASDCP::Rational (_asset->edit_rate(), 1);
@@ -339,7 +342,7 @@ SoundAssetWriter::SoundAssetWriter (SoundAsset* a)
_state->frame_buffer.Size (ASDCP::PCM::CalcFrameBufferSize (_state->audio_desc));
memset (_state->frame_buffer.Data(), 0, _state->frame_buffer.Capacity());
- MXFAsset::fill_writer_info (&_state->writer_info, _asset->uuid ());
+ MXFAsset::fill_writer_info (&_state->writer_info, _asset->uuid (), _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 9e6e75cf..5c230e06 100644
--- a/src/sound_asset.h
+++ b/src/sound_asset.h
@@ -26,12 +26,12 @@
#include "mxf_asset.h"
#include "types.h"
+#include "metadata.h"
namespace libdcp
{
class SoundFrame;
-
class SoundAsset;
class SoundAssetWriter
@@ -45,7 +45,7 @@ public:
private:
friend class SoundAsset;
- SoundAssetWriter (SoundAsset *);
+ SoundAssetWriter (SoundAsset *, MXFMetadata const &);
/* no copy construction */
SoundAssetWriter (SoundAssetWriter const &);
@@ -64,6 +64,7 @@ private:
bool _finalized;
int _frames_written;
int _frame_buffer_offset;
+ MXFMetadata _metadata;
};
/** @brief An asset made up of WAV files */
@@ -86,7 +87,8 @@ public:
std::string mxf_name,
boost::signals2::signal<void (float)>* progress,
int fps,
- int intrinsic_duration
+ int intrinsic_duration,
+ MXFMetadata const & metadata = MXFMetadata ()
);
/** Construct a SoundAsset, generating the MXF from some WAV files.
@@ -106,7 +108,8 @@ public:
boost::signals2::signal<void (float)>* progress,
int fps,
int intrinsic_duration,
- int channels
+ int channels,
+ MXFMetadata const & metadata = MXFMetadata ()
);
SoundAsset (
@@ -122,7 +125,7 @@ public:
int sampling_rate
);
- boost::shared_ptr<SoundAssetWriter> start_write ();
+ boost::shared_ptr<SoundAssetWriter> start_write (MXFMetadata const & metadata = MXFMetadata ());
/** Write details of this asset to a CPL stream.
* @param s Stream.
@@ -142,7 +145,7 @@ public:
}
private:
- void construct (boost::function<std::string (Channel)> get_path);
+ void construct (boost::function<std::string (Channel)> get_path, MXFMetadata const &);
std::string path_from_channel (Channel channel, std::vector<std::string> const & files);
/** Number of channels in the asset */
diff --git a/src/test_mode.cc b/src/test_mode.cc
deleted file mode 100644
index bfe10fee..00000000
--- a/src/test_mode.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/test_mode.cc
- * @brief A method to enable test mode for libdcp.
- */
-
-#include "KM_prng.h"
-#include "test_mode.h"
-#include "metadata.h"
-
-/** Calling this will seed the random number generator used to
- * generate UUIDs with a known value, and set the DCP issue
- * date to 1st January 2012 at midnight. This means that
- * two runs of libdcp with the same inputs will produce
- * the same output.
- */
-
-void
-libdcp::enable_test_mode ()
-{
- Kumu::libdcp_test = true;
- Metadata::instance()->issue_date = "2012-01-01T00:00:00+00:00";
-
- /* Remove version strings */
- Metadata::instance()->issuer = "libdcp-test";
- Metadata::instance()->creator = "libdcp-test";
- Metadata::instance()->product_version = "test";
-}
diff --git a/src/test_mode.h b/src/test_mode.h
deleted file mode 100644
index b2e671d5..00000000
--- a/src/test_mode.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/test_mode.h
- * @brief A method to enable test mode for libdcp.
- */
-
-namespace libdcp
-{
-
-extern void enable_test_mode ();
-
-}
diff --git a/src/wscript b/src/wscript
index 95092173..81c39926 100644
--- a/src/wscript
+++ b/src/wscript
@@ -27,7 +27,6 @@ def build(bld):
sound_asset.cc
sound_frame.cc
subtitle_asset.cc
- test_mode.cc
types.cc
util.cc
version.cc
@@ -36,6 +35,7 @@ def build(bld):
headers = """
asset.h
+ cpl.h
dcp.h
dcp_time.h
exceptions.h
@@ -48,7 +48,6 @@ def build(bld):
sound_asset.h
sound_frame.h
subtitle_asset.h
- test_mode.h
types.h
util.h
version.h
diff --git a/test/tests.cc b/test/tests.cc
index d33890b6..d8b7e5d4 100644
--- a/test/tests.cc
+++ b/test/tests.cc
@@ -59,13 +59,14 @@ BOOST_AUTO_TEST_CASE (dcp_test)
{
Kumu::libdcp_test = true;
- libdcp::Metadata* t = libdcp::Metadata::instance ();
- t->issuer = "OpenDCP 0.0.25";
- t->creator = "OpenDCP 0.0.25";
- t->company_name = "OpenDCP";
- t->product_name = "OpenDCP";
- t->product_version = "0.0.25";
- t->issue_date = "2012-07-17T04:45:18+00:00";
+ libdcp::XMLMetadata xml_meta;
+ xml_meta.issuer = "OpenDCP 0.0.25";
+ xml_meta.creator = "OpenDCP 0.0.25";
+ xml_meta.issue_date = "2012-07-17T04:45:18+00:00";
+ libdcp::MXFMetadata mxf_meta;
+ mxf_meta.company_name = "OpenDCP";
+ mxf_meta.product_name = "OpenDCP";
+ mxf_meta.product_version = "0.0.25";
boost::filesystem::remove_all ("build/test/foo");
boost::filesystem::create_directories ("build/test/foo");
libdcp::DCP d ("build/test/foo");
@@ -78,7 +79,8 @@ BOOST_AUTO_TEST_CASE (dcp_test)
&d.Progress,
24,
24,
- libdcp::Size (32, 32)
+ libdcp::Size (32, 32),
+ mxf_meta
));
shared_ptr<libdcp::SoundAsset> ms (new libdcp::SoundAsset (
@@ -88,13 +90,14 @@ BOOST_AUTO_TEST_CASE (dcp_test)
&(d.Progress),
24,
24,
- 2
+ 2,
+ mxf_meta
));
cpl->add_reel (shared_ptr<libdcp::Reel> (new libdcp::Reel (mp, ms, shared_ptr<libdcp::SubtitleAsset> ())));
d.add_cpl (cpl);
- d.write_xml ();
+ d.write_xml (xml_meta);
}
BOOST_AUTO_TEST_CASE (error_test)