summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-06-04 22:55:10 +0100
committerCarl Hetherington <cth@carlh.net>2015-06-05 14:35:32 +0100
commit7b717db244554300ebed8eade8421ee3faa28d33 (patch)
treeb2000a7049585378d9c98bf2e4edd2115eeca47d /src
parentb7f478b7c5d2e53205dd77dee6955f6d7ac1ce5c (diff)
Unpick MXF from the class hierarchy.
Diffstat (limited to 'src')
-rw-r--r--src/mono_picture_mxf.cc4
-rw-r--r--src/mono_picture_mxf_writer.cc4
-rw-r--r--src/mxf.cc35
-rw-r--r--src/mxf.h14
-rw-r--r--src/mxf_writer.cc2
-rw-r--r--src/picture_mxf.cc2
-rw-r--r--src/picture_mxf.h2
-rw-r--r--src/picture_mxf_writer.cc2
-rw-r--r--src/picture_mxf_writer_common.cc2
-rw-r--r--src/reel_mxf_asset.cc8
-rw-r--r--src/reel_mxf_asset.h2
-rw-r--r--src/reel_picture_asset.cc2
-rw-r--r--src/reel_sound_asset.cc2
-rw-r--r--src/sound_mxf.cc6
-rw-r--r--src/sound_mxf.h2
-rw-r--r--src/sound_mxf_writer.cc4
-rw-r--r--src/stereo_picture_mxf.cc4
-rw-r--r--src/stereo_picture_mxf_writer.cc6
18 files changed, 27 insertions, 76 deletions
diff --git a/src/mono_picture_mxf.cc b/src/mono_picture_mxf.cc
index 2a1e0066..faae8cd8 100644
--- a/src/mono_picture_mxf.cc
+++ b/src/mono_picture_mxf.cc
@@ -74,10 +74,6 @@ MonoPictureMXF::equals (shared_ptr<const Asset> other, EqualityOptions opt, Note
if (!dynamic_pointer_cast<const MonoPictureMXF> (other)) {
return false;
}
-
- if (!MXF::equals (other, opt, note)) {
- return false;
- }
ASDCP::JP2K::MXFReader reader_A;
Kumu::Result_t r = reader_A.OpenRead (_file.string().c_str());
diff --git a/src/mono_picture_mxf_writer.cc b/src/mono_picture_mxf_writer.cc
index 7ad2c1b6..f0914cdc 100644
--- a/src/mono_picture_mxf_writer.cc
+++ b/src/mono_picture_mxf_writer.cc
@@ -91,7 +91,7 @@ MonoPictureMXFWriter::fake_write (int size)
Kumu::Result_t r = _state->mxf_writer.FakeWriteFrame (size);
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in writing video MXF", _mxf->file().string(), r));
+ boost::throw_exception (MXFFileError ("error in writing video MXF", _file.string(), r));
}
++_frames_written;
@@ -102,7 +102,7 @@ MonoPictureMXFWriter::finalize ()
{
Kumu::Result_t r = _state->mxf_writer.Finalize();
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in finalizing video MXF", _mxf->file().string(), r));
+ boost::throw_exception (MXFFileError ("error in finalizing video MXF", _file.string(), r));
}
_picture_mxf->_intrinsic_duration = _frames_written;
diff --git a/src/mxf.cc b/src/mxf.cc
index bc5c0bd1..80a351e6 100644
--- a/src/mxf.cc
+++ b/src/mxf.cc
@@ -48,20 +48,13 @@ MXF::MXF ()
}
-MXF::MXF (boost::filesystem::path file)
- : Asset (file)
- , _decryption_context (0)
-{
-
-}
-
MXF::~MXF ()
{
delete _decryption_context;
}
void
-MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, Standard standard)
+MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, string id, Standard standard)
{
writer_info->ProductVersion = _metadata.product_version;
writer_info->CompanyName = _metadata.company_name;
@@ -73,7 +66,7 @@ MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, Standard standard)
writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE;
}
unsigned int c;
- Kumu::hex2bin (_id.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c);
+ Kumu::hex2bin (id.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c);
DCP_ASSERT (c == Kumu::UUID_Length);
if (_key_id) {
@@ -86,30 +79,6 @@ MXF::fill_writer_info (ASDCP::WriterInfo* writer_info, Standard standard)
}
}
-bool
-MXF::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
-{
- if (!Asset::equals (other, opt, note)) {
- return false;
- }
-
- shared_ptr<const MXF> other_mxf = dynamic_pointer_cast<const MXF> (other);
- if (!other_mxf) {
- return false;
- }
-
- if (_file.leaf() != other_mxf->file().leaf()) {
- if (!opt.mxf_filenames_can_differ) {
- note (DCP_ERROR, "MXF: filenames differ");
- return false;
- } else {
- note (DCP_NOTE, "MXF: filenames differ");
- }
- }
-
- return true;
-}
-
/** Set the (private) key that will be used to encrypt or decrypt this MXF's content.
* This is the top-secret key that is distributed (itself encrypted) to cinemas
* via Key Delivery Messages (KDMs).
diff --git a/src/mxf.h b/src/mxf.h
index b5200b08..e05ddbcd 100644
--- a/src/mxf.h
+++ b/src/mxf.h
@@ -27,7 +27,6 @@
#include <boost/signals2.hpp>
namespace ASDCP {
- class AESEncContext;
class AESDecContext;
class WriterInfo;
}
@@ -45,18 +44,11 @@ class PictureMXFWriter;
/** @class MXF
* @brief Parent class for classes which represent MXF files.
*/
-class MXF : public Asset
+class MXF
{
public:
MXF ();
- MXF (boost::filesystem::path file);
- ~MXF ();
-
- bool equals (
- boost::shared_ptr<const Asset> other,
- EqualityOptions opt,
- NoteHandler note
- ) const;
+ virtual ~MXF ();
/** @return true if the data is encrypted */
bool encrypted () const {
@@ -103,7 +95,7 @@ protected:
* @param w struct to fill in.
* @param standard INTEROP or SMPTE.
*/
- void fill_writer_info (ASDCP::WriterInfo* w, Standard standard);
+ void fill_writer_info (ASDCP::WriterInfo* w, std::string id, Standard standard);
ASDCP::AESDecContext* _decryption_context;
/** ID of the key used for encryption/decryption, if there is one */
diff --git a/src/mxf_writer.cc b/src/mxf_writer.cc
index d616c913..ab1eac1a 100644
--- a/src/mxf_writer.cc
+++ b/src/mxf_writer.cc
@@ -40,8 +40,6 @@ MXFWriter::MXFWriter (MXF* mxf, boost::filesystem::path file)
, _finalized (false)
, _encryption_context (0)
{
- mxf->set_file (file);
-
if (mxf->key ()) {
_encryption_context = new ASDCP::AESEncContext;
if (ASDCP_FAILURE (_encryption_context->InitKey (mxf->key()->value ()))) {
diff --git a/src/picture_mxf.cc b/src/picture_mxf.cc
index a0de9c64..caa3d1a6 100644
--- a/src/picture_mxf.cc
+++ b/src/picture_mxf.cc
@@ -48,7 +48,7 @@ using boost::shared_ptr;
using namespace dcp;
PictureMXF::PictureMXF (boost::filesystem::path file)
- : MXF (file)
+ : Asset (file)
, _intrinsic_duration (0)
{
diff --git a/src/picture_mxf.h b/src/picture_mxf.h
index fa7936ac..c5066513 100644
--- a/src/picture_mxf.h
+++ b/src/picture_mxf.h
@@ -45,7 +45,7 @@ class PictureMXFWriter;
/** @class PictureMXF
* @brief An asset made up of JPEG2000 data.
*/
-class PictureMXF : public MXF
+class PictureMXF : public Asset, public MXF
{
public:
PictureMXF (boost::filesystem::path file);
diff --git a/src/picture_mxf_writer.cc b/src/picture_mxf_writer.cc
index 42fa614c..4593c49a 100644
--- a/src/picture_mxf_writer.cc
+++ b/src/picture_mxf_writer.cc
@@ -38,5 +38,5 @@ PictureMXFWriter::PictureMXFWriter (PictureMXF* mxf, boost::filesystem::path fil
, _standard (standard)
, _overwrite (overwrite)
{
-
+ mxf->set_file (file);
}
diff --git a/src/picture_mxf_writer_common.cc b/src/picture_mxf_writer_common.cc
index dc5b340a..b625d1ff 100644
--- a/src/picture_mxf_writer_common.cc
+++ b/src/picture_mxf_writer_common.cc
@@ -46,7 +46,7 @@ void dcp::start (PictureMXFWriter* writer, shared_ptr<P> state, Standard standar
mxf->set_size (Size (state->picture_descriptor.StoredWidth, state->picture_descriptor.StoredHeight));
mxf->set_screen_aspect_ratio (Fraction (state->picture_descriptor.AspectRatio.Numerator, state->picture_descriptor.AspectRatio.Denominator));
- mxf->fill_writer_info (&state->writer_info, standard);
+ mxf->fill_writer_info (&state->writer_info, mxf->id(), standard);
Kumu::Result_t r = state->mxf_writer.OpenWrite (
mxf->file().string().c_str(),
diff --git a/src/reel_mxf_asset.cc b/src/reel_mxf_asset.cc
index 938f1e48..f32ea805 100644
--- a/src/reel_mxf_asset.cc
+++ b/src/reel_mxf_asset.cc
@@ -23,7 +23,9 @@
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
+using std::string;
using boost::shared_ptr;
+using boost::optional;
using namespace dcp;
ReelMXFAsset::ReelMXFAsset ()
@@ -32,9 +34,9 @@ ReelMXFAsset::ReelMXFAsset ()
}
-ReelMXFAsset::ReelMXFAsset (shared_ptr<MXF> mxf, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
- : ReelAsset (mxf, edit_rate, intrinsic_duration, entry_point)
- , _key_id (mxf->key_id ())
+ReelMXFAsset::ReelMXFAsset (shared_ptr<Asset> asset, optional<string> key_id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point)
+ : ReelAsset (asset, edit_rate, intrinsic_duration, entry_point)
+ , _key_id (key_id)
{
}
diff --git a/src/reel_mxf_asset.h b/src/reel_mxf_asset.h
index 9b6a78a9..c9637549 100644
--- a/src/reel_mxf_asset.h
+++ b/src/reel_mxf_asset.h
@@ -37,7 +37,7 @@ class ReelMXFAsset : public ReelAsset
{
public:
ReelMXFAsset ();
- ReelMXFAsset (boost::shared_ptr<MXF> mxf, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
+ ReelMXFAsset (boost::shared_ptr<Asset> mxf, boost::optional<std::string> key_id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
ReelMXFAsset (boost::shared_ptr<const cxml::Node>);
/** @return the 4-character key type for this MXF (MDIK, MDAK, etc.) */
diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc
index de4ae5f6..d222095c 100644
--- a/src/reel_picture_asset.cc
+++ b/src/reel_picture_asset.cc
@@ -44,7 +44,7 @@ ReelPictureAsset::ReelPictureAsset ()
}
ReelPictureAsset::ReelPictureAsset (shared_ptr<PictureMXF> asset, int64_t entry_point)
- : ReelMXFAsset (asset, asset->edit_rate(), asset->intrinsic_duration(), entry_point)
+ : ReelMXFAsset (asset, asset->key_id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
, _frame_rate (asset->frame_rate ())
, _screen_aspect_ratio (asset->screen_aspect_ratio ())
{
diff --git a/src/reel_sound_asset.cc b/src/reel_sound_asset.cc
index 9d3e00d7..504d376d 100644
--- a/src/reel_sound_asset.cc
+++ b/src/reel_sound_asset.cc
@@ -30,7 +30,7 @@ using boost::shared_ptr;
using namespace dcp;
ReelSoundAsset::ReelSoundAsset (shared_ptr<SoundMXF> asset, int64_t entry_point)
- : ReelMXFAsset (asset, asset->edit_rate(), asset->intrinsic_duration(), entry_point)
+ : ReelMXFAsset (asset, asset->key_id(), asset->edit_rate(), asset->intrinsic_duration(), entry_point)
{
}
diff --git a/src/sound_mxf.cc b/src/sound_mxf.cc
index adeeddcf..19a30bff 100644
--- a/src/sound_mxf.cc
+++ b/src/sound_mxf.cc
@@ -44,7 +44,7 @@ using boost::shared_ptr;
using namespace dcp;
SoundMXF::SoundMXF (boost::filesystem::path file)
- : MXF (file)
+ : Asset (file)
, _intrinsic_duration (0)
, _channels (0)
, _sampling_rate (0)
@@ -86,10 +86,6 @@ SoundMXF::SoundMXF (Fraction edit_rate, int sampling_rate, int channels)
bool
SoundMXF::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
{
- if (!MXF::equals (other, opt, note)) {
- return false;
- }
-
ASDCP::PCM::MXFReader reader_A;
Kumu::Result_t r = reader_A.OpenRead (file().string().c_str());
if (ASDCP_FAILURE (r)) {
diff --git a/src/sound_mxf.h b/src/sound_mxf.h
index 42ca2c67..ed0a60d6 100644
--- a/src/sound_mxf.h
+++ b/src/sound_mxf.h
@@ -37,7 +37,7 @@ class SoundMXFWriter;
/** @class SoundMXF
* @brief Representation of a MXF file containing sound
*/
-class SoundMXF : public MXF
+class SoundMXF : public Asset, public MXF
{
public:
SoundMXF (boost::filesystem::path file);
diff --git a/src/sound_mxf_writer.cc b/src/sound_mxf_writer.cc
index 6da009fc..71b72aa8 100644
--- a/src/sound_mxf_writer.cc
+++ b/src/sound_mxf_writer.cc
@@ -55,12 +55,14 @@ SoundMXFWriter::SoundMXFWriter (SoundMXF* m, boost::filesystem::path file, Stand
_state->frame_buffer.Size (ASDCP::PCM::CalcFrameBufferSize (_state->audio_desc));
memset (_state->frame_buffer.Data(), 0, _state->frame_buffer.Capacity());
- _sound_mxf->fill_writer_info (&_state->writer_info, standard);
+ _sound_mxf->fill_writer_info (&_state->writer_info, _sound_mxf->id(), standard);
Kumu::Result_t r = _state->mxf_writer.OpenWrite (file.string().c_str(), _state->writer_info, _state->audio_desc);
if (ASDCP_FAILURE (r)) {
boost::throw_exception (FileError ("could not open audio MXF for writing", file.string(), r));
}
+
+ _sound_mxf->set_file (file);
}
void
diff --git a/src/stereo_picture_mxf.cc b/src/stereo_picture_mxf.cc
index ce30d0be..0ac0cc83 100644
--- a/src/stereo_picture_mxf.cc
+++ b/src/stereo_picture_mxf.cc
@@ -77,10 +77,6 @@ StereoPictureMXF::start_write (boost::filesystem::path file, Standard standard,
bool
StereoPictureMXF::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler note) const
{
- if (!MXF::equals (other, opt, note)) {
- return false;
- }
-
ASDCP::JP2K::MXFSReader reader_A;
Kumu::Result_t r = reader_A.OpenRead (file().string().c_str());
if (ASDCP_FAILURE (r)) {
diff --git a/src/stereo_picture_mxf_writer.cc b/src/stereo_picture_mxf_writer.cc
index 328db829..7a65556f 100644
--- a/src/stereo_picture_mxf_writer.cc
+++ b/src/stereo_picture_mxf_writer.cc
@@ -81,7 +81,7 @@ StereoPictureMXFWriter::write (uint8_t* data, int size)
);
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in writing video MXF", _mxf->file().string(), r));
+ boost::throw_exception (MXFFileError ("error in writing video MXF", _file.string(), r));
}
_next_eye = _next_eye == EYE_LEFT ? EYE_RIGHT : EYE_LEFT;
@@ -101,7 +101,7 @@ StereoPictureMXFWriter::fake_write (int size)
Kumu::Result_t r = _state->mxf_writer.FakeWriteFrame (size, _next_eye == EYE_LEFT ? ASDCP::JP2K::SP_LEFT : ASDCP::JP2K::SP_RIGHT);
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in writing video MXF", _mxf->file().string(), r));
+ boost::throw_exception (MXFFileError ("error in writing video MXF", _file.string(), r));
}
_next_eye = _next_eye == EYE_LEFT ? EYE_RIGHT : EYE_LEFT;
@@ -115,7 +115,7 @@ StereoPictureMXFWriter::finalize ()
{
Kumu::Result_t r = _state->mxf_writer.Finalize();
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in finalizing video MXF", _mxf->file().string(), r));
+ boost::throw_exception (MXFFileError ("error in finalizing video MXF", _file.string(), r));
}
_picture_mxf->_intrinsic_duration = _frames_written;