summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/argb_frame.cc2
-rw-r--r--src/argb_frame.h2
-rw-r--r--src/asset.cc101
-rw-r--r--src/asset.h134
-rw-r--r--src/certificates.cc2
-rw-r--r--src/certificates.h2
-rw-r--r--src/colour_matrix.cc6
-rw-r--r--src/colour_matrix.h2
-rw-r--r--src/content.cc91
-rw-r--r--src/content.h114
-rw-r--r--src/cpl.cc68
-rw-r--r--src/cpl.h19
-rw-r--r--src/dcp.cc31
-rw-r--r--src/dcp.h8
-rw-r--r--src/dcp_time.cc24
-rw-r--r--src/dcp_time.h2
-rw-r--r--src/exceptions.cc2
-rw-r--r--src/exceptions.h2
-rw-r--r--src/gamma_lut.cc2
-rw-r--r--src/gamma_lut.h2
-rw-r--r--src/image.cc2
-rw-r--r--src/image.h2
-rw-r--r--src/kdm.cc16
-rw-r--r--src/kdm.h2
-rw-r--r--src/key.cc6
-rw-r--r--src/key.h2
-rw-r--r--src/lut.h2
-rw-r--r--src/metadata.cc2
-rw-r--r--src/metadata.h2
-rw-r--r--src/mono_picture_asset.h64
-rw-r--r--src/mono_picture_frame.cc2
-rw-r--r--src/mono_picture_frame.h2
-rw-r--r--src/mono_picture_mxf.cc (renamed from src/mono_picture_asset.cc)108
-rw-r--r--src/mono_picture_mxf.h56
-rw-r--r--src/mono_picture_mxf_writer.cc (renamed from src/mono_picture_asset_writer.cc)36
-rw-r--r--src/mono_picture_mxf_writer.h (renamed from src/mono_picture_asset_writer.h)15
-rw-r--r--src/mxf.cc (renamed from src/mxf_asset.cc)30
-rw-r--r--src/mxf.h (renamed from src/mxf_asset.h)23
-rw-r--r--src/object.cc36
-rw-r--r--src/object.h45
-rw-r--r--src/parse/asset_map.cc2
-rw-r--r--src/parse/asset_map.h2
-rw-r--r--src/parse/cpl.cc2
-rw-r--r--src/parse/cpl.h2
-rw-r--r--src/parse/pkl.cc2
-rw-r--r--src/parse/pkl.h2
-rw-r--r--src/parse/subtitle.cc4
-rw-r--r--src/parse/subtitle.h2
-rw-r--r--src/picture_mxf.cc (renamed from src/picture_asset.cc)26
-rw-r--r--src/picture_mxf.h (renamed from src/picture_asset.h)39
-rw-r--r--src/picture_mxf_writer.cc (renamed from src/picture_asset_writer.cc)11
-rw-r--r--src/picture_mxf_writer.h (renamed from src/picture_asset_writer.h)19
-rw-r--r--src/picture_mxf_writer_common.cc (renamed from src/picture_asset_writer_common.cc)12
-rw-r--r--src/rec709_linearised_gamma_lut.cc2
-rw-r--r--src/rec709_linearised_gamma_lut.h2
-rw-r--r--src/reel.cc14
-rw-r--r--src/reel.h20
-rw-r--r--src/rgb_xyz.cc8
-rw-r--r--src/rgb_xyz.h2
-rw-r--r--src/signer.cc2
-rw-r--r--src/signer.h2
-rw-r--r--src/signer_chain.cc14
-rw-r--r--src/signer_chain.h2
-rw-r--r--src/sound_frame.cc2
-rw-r--r--src/sound_frame.h2
-rw-r--r--src/sound_mxf.cc (renamed from src/sound_asset.cc)192
-rw-r--r--src/sound_mxf.h (renamed from src/sound_asset.h)50
-rw-r--r--src/srgb_linearised_gamma_lut.cc2
-rw-r--r--src/srgb_linearised_gamma_lut.h2
-rw-r--r--src/stereo_picture_frame.cc7
-rw-r--r--src/stereo_picture_frame.h2
-rw-r--r--src/stereo_picture_mxf.cc (renamed from src/stereo_picture_asset.cc)50
-rw-r--r--src/stereo_picture_mxf.h (renamed from src/stereo_picture_asset.h)20
-rw-r--r--src/stereo_picture_mxf_writer.cc (renamed from src/stereo_picture_asset_writer.cc)38
-rw-r--r--src/stereo_picture_mxf_writer.h (renamed from src/stereo_picture_asset_writer.h)12
-rw-r--r--src/subtitle_asset.cc70
-rw-r--r--src/subtitle_asset.h11
-rw-r--r--src/types.cc20
-rw-r--r--src/types.h2
-rw-r--r--src/util.cc34
-rw-r--r--src/util.h2
-rw-r--r--src/version.h2
-rw-r--r--src/wscript31
-rw-r--r--src/xml.h2
-rw-r--r--src/xml/kdm_smpte.h2
-rw-r--r--src/xyz_frame.cc6
-rw-r--r--src/xyz_frame.h4
87 files changed, 826 insertions, 1001 deletions
diff --git a/src/argb_frame.cc b/src/argb_frame.cc
index a48f80bb..79637329 100644
--- a/src/argb_frame.cc
+++ b/src/argb_frame.cc
@@ -19,7 +19,7 @@
#include "argb_frame.h"
-using namespace libdcp;
+using namespace dcp;
/** Construct an empty ARGBFrame of a given size and with
* undefined contents.
diff --git a/src/argb_frame.h b/src/argb_frame.h
index f26436cd..2ad6f69d 100644
--- a/src/argb_frame.h
+++ b/src/argb_frame.h
@@ -24,7 +24,7 @@
#include <stdint.h>
#include "util.h"
-namespace libdcp
+namespace dcp
{
/** @class ARGBFrame
diff --git a/src/asset.cc b/src/asset.cc
index 91a19e69..0147eba2 100644
--- a/src/asset.cc
+++ b/src/asset.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014 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
@@ -17,107 +17,18 @@
*/
-/** @file src/asset.cc
- * @brief Parent class for assets of DCPs.
- */
-
-#include <iostream>
-#include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/function.hpp>
-#include <libxml++/nodes/element.h>
-#include "AS_DCP.h"
-#include "KM_util.h"
#include "asset.h"
-#include "util.h"
-#include "metadata.h"
-
-using namespace std;
-using namespace boost;
-using namespace libdcp;
-
-Asset::Asset (boost::filesystem::path directory, boost::filesystem::path file_name)
- : _directory (directory)
- , _file_name (file_name)
- , _uuid (make_uuid ())
- , _edit_rate (0)
- , _entry_point (0)
- , _intrinsic_duration (0)
- , _duration (0)
-{
- if (_file_name.empty ()) {
- _file_name = _uuid + ".xml";
- }
-}
-
-void
-Asset::write_to_pkl (xmlpp::Node* node) const
-{
- xmlpp::Node* asset = node->add_child ("Asset");
- asset->add_child("Id")->add_child_text ("urn:uuid:" + _uuid);
- asset->add_child("AnnotationText")->add_child_text (_file_name.string ());
- asset->add_child("Hash")->add_child_text (digest ());
- asset->add_child("Size")->add_child_text (lexical_cast<string> (filesystem::file_size(path())));
- asset->add_child("Type")->add_child_text ("application/mxf");
-}
-
-void
-Asset::write_to_assetmap (xmlpp::Node* node) const
-{
- xmlpp::Node* asset = node->add_child ("Asset");
- asset->add_child("Id")->add_child_text ("urn:uuid:" + _uuid);
- xmlpp::Node* chunk_list = asset->add_child ("ChunkList");
- xmlpp::Node* chunk = chunk_list->add_child ("Chunk");
- chunk->add_child("Path")->add_child_text (_file_name.string ());
- chunk->add_child("VolumeIndex")->add_child_text ("1");
- chunk->add_child("Offset")->add_child_text ("0");
- chunk->add_child("Length")->add_child_text (lexical_cast<string> (filesystem::file_size(path())));
-}
-filesystem::path
-Asset::path () const
-{
- filesystem::path p;
- p /= _directory;
- p /= _file_name;
- return p;
-}
+using std::string;
+using namespace dcp;
-string
-Asset::digest () const
+Asset::Asset ()
{
- if (_digest.empty ()) {
- _digest = make_digest (path().string(), 0);
- }
- return _digest;
}
-void
-Asset::compute_digest (boost::function<void (float)> progress)
+Asset::Asset (string id)
+ : Object (id)
{
- if (!_digest.empty ()) {
- return;
- }
-
- _digest = make_digest (path().string(), &progress);
-}
-
-bool
-Asset::equals (shared_ptr<const Asset> other, EqualityOptions, boost::function<void (NoteType, string)> note) const
-{
- if (_edit_rate != other->_edit_rate) {
- note (ERROR, "asset edit rates differ");
- return false;
- }
-
- if (_intrinsic_duration != other->_intrinsic_duration) {
- note (ERROR, "asset intrinsic durations differ");
- }
-
- if (_duration != other->_duration) {
- note (ERROR, "asset durations differ");
- }
- return true;
}
diff --git a/src/asset.h b/src/asset.h
index 269d5c4b..f3546cd8 100644
--- a/src/asset.h
+++ b/src/asset.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014 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
@@ -17,139 +17,23 @@
*/
-/** @file src/asset.h
- * @brief Parent class for assets of DCPs.
- */
-
#ifndef LIBDCP_ASSET_H
#define LIBDCP_ASSET_H
-#include <string>
-#include <list>
-#include <boost/filesystem.hpp>
-#include <boost/function.hpp>
-#include <libxml++/libxml++.h>
-#include "types.h"
-
-namespace ASDCP {
- class WriterInfo;
-}
-
-namespace xmlpp {
- class Element;
-}
+#include "object.h"
-namespace libdcp
-{
+namespace dcp {
-/** @brief Parent class for assets of DCPs
- *
- * These are collections of pictures or sound.
+/** @class Asset
+ * @brief Parent class for DCP assets, i.e. picture/sound/subtitles, CPLs and PKLs.
*/
-class Asset
+
+class Asset : public Object
{
public:
- /** Construct an Asset.
- * @param directory Directory where our XML or MXF file is.
- * @param file_name Name of our file within directory, or empty to make one up based on UUID.
- */
- Asset (boost::filesystem::path directory, boost::filesystem::path file_name = "");
-
- virtual ~Asset() {}
-
- /** Write details of the asset to a CPL AssetList node.
- * @param p Parent element.
- */
- virtual void write_to_cpl (xmlpp::Element* p) const = 0;
-
- /** Write details of the asset to a PKL AssetList node.
- * @param p Parent node.
- */
- void write_to_pkl (xmlpp::Node *) const;
-
- /** Write details of the asset to a ASSETMAP stream.
- * @param s Stream.
- */
- void write_to_assetmap (xmlpp::Node *) const;
-
- /** Compute the digest for this asset. Calling this is optional: if
- * it is not called, the digest will be computed when required. However,
- * calling this method allows the caller to see the progress of the
- * computation, which can be long for large assets.
- * @param Called with progress between 0 and 1.
- */
- void compute_digest (boost::function<void (float)> progress);
-
- std::string uuid () const {
- return _uuid;
- }
-
- boost::filesystem::path path () const;
-
- void set_directory (boost::filesystem::path d) {
- _directory = d;
- }
-
- void set_file_name (boost::filesystem::path f) {
- _file_name = f;
- }
-
- int entry_point () const {
- return _entry_point;
- }
-
- int duration () const {
- return _duration;
- }
-
- int intrinsic_duration () const {
- return _intrinsic_duration;
- }
-
- int edit_rate () const {
- return _edit_rate;
- }
-
- void set_entry_point (int e) {
- _entry_point = e;
- }
-
- void set_duration (int d) {
- _duration = d;
- }
-
- void set_intrinsic_duration (int d) {
- _intrinsic_duration = d;
- }
-
- void set_edit_rate (int r) {
- _edit_rate = r;
- }
-
- virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const;
-
-protected:
-
- std::string digest () const;
-
- /** Directory that our MXF or XML file is in */
- boost::filesystem::path _directory;
- /** Name of our MXF or XML file */
- boost::filesystem::path _file_name;
- /** Our UUID */
- std::string _uuid;
- /** The edit rate; this is normally equal to the number of video frames per second */
- int _edit_rate;
- /** Start point to present in frames */
- int _entry_point;
- /** Total length in frames */
- int _intrinsic_duration;
- /** Length to present in frames */
- int _duration;
+ Asset ();
+ Asset (std::string id);
-private:
- /** Digest of our MXF or XML file */
- mutable std::string _digest;
};
}
diff --git a/src/certificates.cc b/src/certificates.cc
index 2f5d47fd..caa4c830 100644
--- a/src/certificates.cc
+++ b/src/certificates.cc
@@ -37,7 +37,7 @@ using std::string;
using std::stringstream;
using std::vector;
using boost::shared_ptr;
-using namespace libdcp;
+using namespace dcp;
/** @param c X509 certificate, which this object will take ownership of */
Certificate::Certificate (X509* c)
diff --git a/src/certificates.h b/src/certificates.h
index 2bf8d0db..c7d6698b 100644
--- a/src/certificates.h
+++ b/src/certificates.h
@@ -34,7 +34,7 @@ namespace xmlpp {
class Element;
}
-namespace libdcp {
+namespace dcp {
class Certificate
{
diff --git a/src/colour_matrix.cc b/src/colour_matrix.cc
index b633e384..19243d4d 100644
--- a/src/colour_matrix.cc
+++ b/src/colour_matrix.cc
@@ -23,19 +23,19 @@
EasyDCP player, I think.
*/
-double const libdcp::colour_matrix::xyz_to_rgb[3][3] = {
+double const dcp::colour_matrix::xyz_to_rgb[3][3] = {
{ 3.24096989631653, -1.5373831987381, -0.498610764741898 },
{ -0.96924364566803, 1.87596750259399, 0.0415550582110882 },
{ 0.0556300804018974, -0.203976958990097, 1.05697154998779 }
};
-double const libdcp::colour_matrix::srgb_to_xyz[3][3] = {
+double const dcp::colour_matrix::srgb_to_xyz[3][3] = {
{0.4124564, 0.3575761, 0.1804375},
{0.2126729, 0.7151522, 0.0721750},
{0.0193339, 0.1191920, 0.9503041}
};
-double const libdcp::colour_matrix::rec709_to_xyz[3][3] = {
+double const dcp::colour_matrix::rec709_to_xyz[3][3] = {
{ 0.412390799265959, 0.357584339383878, 0.180480788401834 },
{ 0.21263900587151, 0.715168678767756, 0.0721923153607337 },
{ 0.0193308187155918, 0.119194779794626, 0.950532152249661 }
diff --git a/src/colour_matrix.h b/src/colour_matrix.h
index 615e8b38..010ac3b9 100644
--- a/src/colour_matrix.h
+++ b/src/colour_matrix.h
@@ -17,7 +17,7 @@
*/
-namespace libdcp {
+namespace dcp {
namespace colour_matrix {
diff --git a/src/content.cc b/src/content.cc
new file mode 100644
index 00000000..9a035c80
--- /dev/null
+++ b/src/content.cc
@@ -0,0 +1,91 @@
+/*
+ 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.
+
+*/
+
+#include <iostream>
+#include <boost/filesystem.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/function.hpp>
+#include <libxml++/nodes/element.h>
+#include "AS_DCP.h"
+#include "KM_util.h"
+#include "content.h"
+#include "util.h"
+#include "metadata.h"
+
+using namespace std;
+using namespace boost;
+using namespace dcp;
+
+Content::Content (boost::filesystem::path file)
+ : _file (file)
+ , _edit_rate (0)
+ , _intrinsic_duration (0)
+{
+
+}
+
+Content::Content (int edit_rate)
+ : _edit_rate (edit_rate)
+ , _intrinsic_duration (0)
+{
+
+}
+
+void
+Content::write_to_pkl (xmlpp::Node* node) const
+{
+ xmlpp::Node* asset = node->add_child ("Asset");
+ asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
+ asset->add_child("AnnotationText")->add_child_text (_id);
+//XXX asset->add_child("Hash")->add_child_text (digest ());
+ asset->add_child("Size")->add_child_text (lexical_cast<string> (filesystem::file_size (_file)));
+ asset->add_child("Type")->add_child_text ("application/mxf");
+}
+
+void
+Content::write_to_assetmap (xmlpp::Node* node) const
+{
+ xmlpp::Node* asset = node->add_child ("Asset");
+ asset->add_child("Id")->add_child_text ("urn:uuid:" + _id);
+ xmlpp::Node* chunk_list = asset->add_child ("ChunkList");
+ xmlpp::Node* chunk = chunk_list->add_child ("Chunk");
+ chunk->add_child("Path")->add_child_text (_file.string ());
+ chunk->add_child("VolumeIndex")->add_child_text ("1");
+ chunk->add_child("Offset")->add_child_text ("0");
+ chunk->add_child("Length")->add_child_text (lexical_cast<string> (filesystem::file_size (_file)));
+}
+
+bool
+Content::equals (shared_ptr<const Content> other, EqualityOptions, boost::function<void (NoteType, string)> note) const
+{
+ // if (_edit_rate != other->_edit_rate) {
+ // note (ERROR, "asset edit rates differ");
+ // return false;
+ // }
+
+ // if (_intrinsic_duration != other->_intrinsic_duration) {
+ // note (ERROR, "asset intrinsic durations differ");
+ // }
+
+ // if (_duration != other->_duration) {
+ // note (ERROR, "asset durations differ");
+ // }
+
+ // return true;
+}
diff --git a/src/content.h b/src/content.h
new file mode 100644
index 00000000..75e39a01
--- /dev/null
+++ b/src/content.h
@@ -0,0 +1,114 @@
+/*
+ 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.
+
+*/
+
+#ifndef LIBDCP_CONTENT_H
+#define LIBDCP_CONTENT_H
+
+#include <string>
+#include <list>
+#include <boost/filesystem.hpp>
+#include <boost/function.hpp>
+#include <libxml++/libxml++.h>
+#include "types.h"
+#include "asset.h"
+
+namespace ASDCP {
+ class WriterInfo;
+}
+
+namespace xmlpp {
+ class Element;
+}
+
+namespace dcp
+{
+
+/** @class Content
+ * @brief An asset that represents a piece of content, i.e. picture, sound or subtitle.
+ *
+ * Such a piece of content will be contained in a file (either MXF or XML) within a DCP.
+ */
+class Content : public Asset
+{
+public:
+ Content (boost::filesystem::path file);
+ Content (int edit_rate);
+
+ virtual ~Content () {}
+
+ /** Write details of the asset to a PKL AssetList node.
+ * @param p Parent node.
+ */
+ void write_to_pkl (xmlpp::Node *) const;
+
+ /** Write details of the asset to a ASSETMAP stream.
+ * @param s Stream.
+ */
+ void write_to_assetmap (xmlpp::Node *) const;
+
+ boost::filesystem::path file () const {
+ return _file;
+ }
+
+ void set_file (boost::filesystem::path file) {
+ _file = file;
+ }
+
+ int edit_rate () const {
+ return _edit_rate;
+ }
+
+ void set_edit_rate (int r) {
+ _edit_rate = r;
+ }
+
+ void set_entry_point (int64_t p) {
+ _entry_point = p;
+ }
+
+ int64_t intrinsic_duration () const {
+ return _intrinsic_duration;
+ }
+
+ void set_intrinsic_duration (int64_t d) {
+ _intrinsic_duration = d;
+ }
+
+ int64_t duration () const {
+ return _duration;
+ }
+
+ void set_duration (int64_t d) {
+ _duration = d;
+ }
+
+ virtual bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)>) const;
+
+protected:
+ boost::filesystem::path _file;
+ /** The edit rate; this is normally equal to the number of video frames per second */
+ int _edit_rate;
+ int64_t _entry_point;
+ int64_t _intrinsic_duration;
+ int64_t _duration;
+};
+
+}
+
+#endif
diff --git a/src/cpl.cc b/src/cpl.cc
index dcb730ff..9f7ef7b3 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -21,9 +21,9 @@
#include "cpl.h"
#include "parse/cpl.h"
#include "util.h"
-#include "mono_picture_asset.h"
-#include "stereo_picture_asset.h"
-#include "sound_asset.h"
+#include "mono_picture_mxf.h"
+#include "stereo_picture_mxf.h"
+#include "sound_mxf.h"
#include "subtitle_asset.h"
#include "parse/asset_map.h"
#include "reel.h"
@@ -41,7 +41,7 @@ using std::make_pair;
using boost::shared_ptr;
using boost::lexical_cast;
using boost::optional;
-using namespace libdcp;
+using namespace dcp;
CPL::CPL (boost::filesystem::path directory, string name, ContentKind content_kind, int length, int frames_per_second)
: _directory (directory)
@@ -50,7 +50,7 @@ CPL::CPL (boost::filesystem::path directory, string name, ContentKind content_ki
, _length (length)
, _fps (frames_per_second)
{
- _id = make_uuid ();
+
}
/** Construct a CPL object from a XML file.
@@ -94,8 +94,8 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass
_fps = p->edit_rate.numerator;
_length += p->duration;
- shared_ptr<PictureAsset> picture;
- shared_ptr<SoundAsset> sound;
+ shared_ptr<PictureMXF> picture;
+ shared_ptr<SoundMXF> sound;
shared_ptr<SubtitleAsset> subtitle;
/* Some rather twisted logic to decide if we are 3D or not;
@@ -109,15 +109,15 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass
try {
pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, p->id);
- picture.reset (new MonoPictureAsset (asset.first, asset.second->chunks.front()->path));
+// picture.reset (new MonoPictureMXF (asset.first, asset.second->chunks.front()->path));
- picture->read ();
- picture->set_edit_rate (_fps);
- picture->set_entry_point (p->entry_point);
- picture->set_duration (p->duration);
+// picture->read ();
+// picture->set_edit_rate (_fps);
+// picture->set_entry_point (p->entry_point);
+// picture->set_duration (p->duration);
if (p->key_id.length() > 9) {
/* Trim urn:uuid: */
- picture->set_key_id (p->key_id.substr (9));
+// picture->set_key_id (p->key_id.substr (9));
}
} catch (MXFFileError) {
if (require_mxfs) {
@@ -129,15 +129,15 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass
try {
pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, p->id);
- picture.reset (new StereoPictureAsset (asset.first, asset.second->chunks.front()->path));
+// picture.reset (new StereoPictureMXF (asset.first, asset.second->chunks.front()->path));
- picture->read ();
- picture->set_edit_rate (_fps);
- picture->set_entry_point (p->entry_point);
- picture->set_duration (p->duration);
+// picture->read ();
+// picture->set_edit_rate (_fps);
+// picture->set_entry_point (p->entry_point);
+// picture->set_duration (p->duration);
if (p->key_id.length() > 9) {
/* Trim urn:uuid: */
- picture->set_key_id (p->key_id.substr (9));
+// picture->set_key_id (p->key_id.substr (9));
}
} catch (MXFFileError) {
@@ -153,16 +153,16 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass
try {
pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, (*i)->asset_list->main_sound->id);
- sound.reset (new SoundAsset (asset.first, asset.second->chunks.front()->path));
- shared_ptr<parse::MainSound> s = (*i)->asset_list->main_sound;
+// sound.reset (new SoundMXF (asset.first, asset.second->chunks.front()->path));
+// shared_ptr<parse::MainSound> s = (*i)->asset_list->main_sound;
- sound->read ();
- sound->set_entry_point (s->entry_point);
- sound->set_duration (s->duration);
- if (s->key_id.length() > 9) {
+// sound->read ();
+// sound->set_entry_point (s->entry_point);
+// sound->set_duration (s->duration);
+// if (s->key_id.length() > 9) {
/* Trim urn:uuid: */
- sound->set_key_id (s->key_id.substr (9));
- }
+// sound->set_key_id (s->key_id.substr (9));
+// }
} catch (MXFFileError) {
if (require_mxfs) {
throw;
@@ -172,15 +172,15 @@ CPL::CPL (boost::filesystem::path directory, string file, list<PathAssetMap> ass
if ((*i)->asset_list->main_subtitle) {
- pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, (*i)->asset_list->main_subtitle->id);
+// pair<string, shared_ptr<const parse::AssetMapAsset> > asset = asset_from_id (asset_maps, (*i)->asset_list->main_subtitle->id);
- subtitle.reset (new SubtitleAsset (asset.first, asset.second->chunks.front()->path));
+// subtitle.reset (new SubtitleAsset (asset.first, asset.second->chunks.front()->path));
- subtitle->set_entry_point ((*i)->asset_list->main_subtitle->entry_point);
- subtitle->set_duration ((*i)->asset_list->main_subtitle->duration);
+// subtitle->set_entry_point ((*i)->asset_list->main_subtitle->entry_point);
+// subtitle->set_duration ((*i)->asset_list->main_subtitle->duration);
}
- _reels.push_back (shared_ptr<Reel> (new Reel (picture, sound, subtitle)));
+// _reels.push_back (shared_ptr<Reel> (new Reel (picture, sound, subtitle)));
}
}
@@ -252,10 +252,10 @@ CPL::write_to_pkl (xmlpp::Node* node) const
asset->add_child("Type")->add_child_text ("text/xml");
}
-list<shared_ptr<const Asset> >
+list<shared_ptr<const Content> >
CPL::assets () const
{
- list<shared_ptr<const Asset> > a;
+ list<shared_ptr<const Content> > a;
for (list<shared_ptr<Reel> >::const_iterator i = _reels.begin(); i != _reels.end(); ++i) {
if ((*i)->main_picture ()) {
a.push_back ((*i)->main_picture ());
diff --git a/src/cpl.h b/src/cpl.h
index aadc7347..abfb92f6 100644
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -30,23 +30,26 @@
#include "types.h"
#include "certificates.h"
#include "key.h"
+#include "asset.h"
-namespace libdcp {
+namespace dcp {
namespace parse {
class AssetMap;
class AssetMapAsset;
}
-class Asset;
+class Content;
class Reel;
class XMLMetadata;
class MXFMetadata;
class Signer;
class KDM;
-/** @brief A CPL within a DCP */
-class CPL
+/** @class CPL
+ * @brief A Composition Playlist.
+ */
+class CPL : public Asset
{
public:
CPL (boost::filesystem::path directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
@@ -82,16 +85,12 @@ public:
return _fps;
}
- std::list<boost::shared_ptr<const Asset> > assets () const;
+ std::list<boost::shared_ptr<const Content> > assets () const;
bool encrypted () const;
void set_mxf_keys (Key);
- std::string id () const {
- return _id;
- }
-
bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
void write_xml (bool, XMLMetadata const &, boost::shared_ptr<const Signer>) const;
@@ -115,8 +114,6 @@ private:
/** reels */
std::list<boost::shared_ptr<Reel> > _reels;
- /** our UUID */
- std::string _id;
/** a SHA1 digest of our XML */
mutable std::string _digest;
};
diff --git a/src/dcp.cc b/src/dcp.cc
index f80726fc..a5b0c6e4 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -33,9 +33,8 @@
#include <xmlsec/xmldsig.h>
#include <xmlsec/app.h>
#include "dcp.h"
-#include "asset.h"
-#include "sound_asset.h"
-#include "picture_asset.h"
+#include "sound_mxf.h"
+#include "picture_mxf.h"
#include "subtitle_asset.h"
#include "util.h"
#include "metadata.h"
@@ -56,7 +55,7 @@ using std::back_inserter;
using std::make_pair;
using boost::shared_ptr;
using boost::lexical_cast;
-using namespace libdcp;
+using namespace dcp;
DCP::DCP (boost::filesystem::path directory)
: _directory (directory)
@@ -109,8 +108,8 @@ DCP::write_pkl (string pkl_uuid, bool interop, XMLMetadata const & metadata, sha
pkl->add_child("Creator")->add_child_text (metadata.creator);
xmlpp::Element* asset_list = pkl->add_child("AssetList");
- list<shared_ptr<const Asset> > a = assets ();
- for (list<shared_ptr<const Asset> >::const_iterator i = a.begin(); i != a.end(); ++i) {
+ list<shared_ptr<const Content> > a = assets ();
+ for (list<shared_ptr<const Content> >::const_iterator i = a.begin(); i != a.end(); ++i) {
(*i)->write_to_pkl (asset_list);
}
@@ -192,8 +191,8 @@ DCP::write_assetmap (string pkl_uuid, int pkl_length, bool interop, XMLMetadata
(*i)->write_to_assetmap (asset_list);
}
- list<shared_ptr<const Asset> > a = assets ();
- for (list<shared_ptr<const Asset> >::const_iterator i = a.begin(); i != a.end(); ++i) {
+ list<shared_ptr<const Content> > a = assets ();
+ for (list<shared_ptr<const Content> >::const_iterator i = a.begin(); i != a.end(); ++i) {
(*i)->write_to_assetmap (asset_list);
}
@@ -216,12 +215,12 @@ DCP::read_assets ()
boost::filesystem::path p = _directory;
p /= "ASSETMAP";
if (boost::filesystem::exists (p)) {
- asset_map.reset (new libdcp::parse::AssetMap (p.string ()));
+ asset_map.reset (new dcp::parse::AssetMap (p.string ()));
} else {
p = _directory;
p /= "ASSETMAP.xml";
if (boost::filesystem::exists (p)) {
- asset_map.reset (new libdcp::parse::AssetMap (p.string ()));
+ asset_map.reset (new dcp::parse::AssetMap (p.string ()));
} else {
boost::throw_exception (DCPReadError ("could not find AssetMap file"));
}
@@ -231,7 +230,7 @@ DCP::read_assets ()
boost::throw_exception (FileError ("could not load AssetMap file", _files.asset_map, e.number ()));
}
- for (list<shared_ptr<libdcp::parse::AssetMapAsset> >::const_iterator i = asset_map->assets.begin(); i != asset_map->assets.end(); ++i) {
+ for (list<shared_ptr<dcp::parse::AssetMapAsset> >::const_iterator i = asset_map->assets.begin(); i != asset_map->assets.end(); ++i) {
if ((*i)->chunks.size() != 1) {
boost::throw_exception (XMLError ("unsupported asset chunk count"));
}
@@ -322,17 +321,17 @@ DCP::add_cpl (shared_ptr<CPL> cpl)
class AssetComparator
{
public:
- bool operator() (shared_ptr<const Asset> a, shared_ptr<const Asset> b) {
- return a->uuid() < b->uuid();
+ bool operator() (shared_ptr<const Content> a, shared_ptr<const Content> b) {
+ return a->id() < b->id();
}
};
-list<shared_ptr<const Asset> >
+list<shared_ptr<const Content> >
DCP::assets () const
{
- list<shared_ptr<const Asset> > a;
+ list<shared_ptr<const Content> > a;
for (list<shared_ptr<CPL> >::const_iterator i = _cpls.begin(); i != _cpls.end(); ++i) {
- list<shared_ptr<const Asset> > t = (*i)->assets ();
+ list<shared_ptr<const Content> > t = (*i)->assets ();
a.merge (t);
}
diff --git a/src/dcp.h b/src/dcp.h
index 45ccce88..19903d3f 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -37,10 +37,10 @@ namespace xmlpp {
}
/** @brief Namespace for everything in libdcp */
-namespace libdcp
+namespace dcp
{
-class Asset;
+class Content;
class PictureAsset;
class SoundAsset;
class SubtitleAsset;
@@ -110,7 +110,7 @@ public:
* supplemental.add_assets_from (original_version);
* supplemental.read ();
*/
- void add_assets_from (libdcp::DCP const &);
+ void add_assets_from (DCP const &);
bool encrypted () const;
@@ -138,7 +138,7 @@ private:
void write_assetmap (std::string pkl_uuid, int pkl_length, bool, XMLMetadata const &) const;
/** @return Assets in all the CPLs in this DCP */
- std::list<boost::shared_ptr<const Asset> > assets () const;
+ std::list<boost::shared_ptr<const Content> > assets () const;
struct Files {
std::list<std::string> cpls;
diff --git a/src/dcp_time.cc b/src/dcp_time.cc
index 14155fdb..605c4a40 100644
--- a/src/dcp_time.cc
+++ b/src/dcp_time.cc
@@ -31,7 +31,7 @@
using namespace std;
using namespace boost;
-using namespace libdcp;
+using namespace dcp;
Time::Time (int frame, int frames_per_second)
: h (0)
@@ -85,19 +85,19 @@ Time::Time (string time)
}
bool
-libdcp::operator== (Time const & a, Time const & b)
+dcp::operator== (Time const & a, Time const & b)
{
return (a.h == b.h && a.m == b.m && a.s == b.s && a.t == b.t);
}
bool
-libdcp::operator!= (Time const & a, Time const & b)
+dcp::operator!= (Time const & a, Time const & b)
{
return !(a == b);
}
bool
-libdcp::operator<= (Time const & a, Time const & b)
+dcp::operator<= (Time const & a, Time const & b)
{
if (a.h != b.h) {
return a.h <= b.h;
@@ -119,7 +119,7 @@ libdcp::operator<= (Time const & a, Time const & b)
}
bool
-libdcp::operator< (Time const & a, Time const & b)
+dcp::operator< (Time const & a, Time const & b)
{
if (a.h != b.h) {
return a.h < b.h;
@@ -141,7 +141,7 @@ libdcp::operator< (Time const & a, Time const & b)
}
bool
-libdcp::operator> (Time const & a, Time const & b)
+dcp::operator> (Time const & a, Time const & b)
{
if (a.h != b.h) {
return a.h > b.h;
@@ -163,14 +163,14 @@ libdcp::operator> (Time const & a, Time const & b)
}
ostream &
-libdcp::operator<< (ostream& s, Time const & t)
+dcp::operator<< (ostream& s, Time const & t)
{
s << t.h << ":" << t.m << ":" << t.s << "." << t.t;
return s;
}
-libdcp::Time
-libdcp::operator+ (Time a, Time const & b)
+dcp::Time
+dcp::operator+ (Time a, Time const & b)
{
Time r;
@@ -197,8 +197,8 @@ libdcp::operator+ (Time a, Time const & b)
return r;
}
-libdcp::Time
-libdcp::operator- (Time a, Time const & b)
+dcp::Time
+dcp::operator- (Time a, Time const & b)
{
Time r;
@@ -226,7 +226,7 @@ libdcp::operator- (Time a, Time const & b)
}
float
-libdcp::operator/ (Time a, Time const & b)
+dcp::operator/ (Time a, Time const & b)
{
int64_t const at = a.h * 3600 * 250 + a.m * 60 * 250 + a.s * 250 + a.t;
int64_t const bt = b.h * 3600 * 250 + b.m * 60 * 250 + b.s * 250 + b.t;
diff --git a/src/dcp_time.h b/src/dcp_time.h
index 92cee9a0..885393c1 100644
--- a/src/dcp_time.h
+++ b/src/dcp_time.h
@@ -28,7 +28,7 @@
#include <iostream>
#include <stdint.h>
-namespace libdcp {
+namespace dcp {
/** @class Time
* @brief A representation of time within a DCP.
diff --git a/src/exceptions.cc b/src/exceptions.cc
index 6a32a33f..c3755a60 100644
--- a/src/exceptions.cc
+++ b/src/exceptions.cc
@@ -21,7 +21,7 @@
#include "compose.hpp"
using std::string;
-using namespace libdcp;
+using namespace dcp;
FileError::FileError (std::string const & message, boost::filesystem::path filename, int number)
: _message (String::compose ("%1 (error %2) (%3)", message, filename.string(), number))
diff --git a/src/exceptions.h b/src/exceptions.h
index 2070dd0f..2a7fbdda 100644
--- a/src/exceptions.h
+++ b/src/exceptions.h
@@ -26,7 +26,7 @@
* @brief Exceptions thrown by libdcp.
*/
-namespace libdcp
+namespace dcp
{
/** @brief An exception related to a file */
diff --git a/src/gamma_lut.cc b/src/gamma_lut.cc
index 80d9b902..0b8ad2fd 100644
--- a/src/gamma_lut.cc
+++ b/src/gamma_lut.cc
@@ -21,7 +21,7 @@
#include "gamma_lut.h"
#include "lut_cache.h"
-using namespace libdcp;
+using namespace dcp;
LUTCache<GammaLUT> GammaLUT::cache;
diff --git a/src/gamma_lut.h b/src/gamma_lut.h
index 32e4af02..095ad882 100644
--- a/src/gamma_lut.h
+++ b/src/gamma_lut.h
@@ -23,7 +23,7 @@
#include "lut.h"
#include "lut_cache.h"
-namespace libdcp {
+namespace dcp {
class GammaLUT : public LUT
{
diff --git a/src/image.cc b/src/image.cc
index 24174fca..2cb5a7a4 100644
--- a/src/image.cc
+++ b/src/image.cc
@@ -20,7 +20,7 @@
#include "image.h"
using boost::shared_ptr;
-using namespace libdcp;
+using namespace dcp;
Image::Image (Size s)
: _size (s)
diff --git a/src/image.h b/src/image.h
index 8b7fee09..a8786b77 100644
--- a/src/image.h
+++ b/src/image.h
@@ -19,7 +19,7 @@
#include "util.h"
-namespace libdcp {
+namespace dcp {
class Image
{
diff --git a/src/kdm.cc b/src/kdm.cc
index 4132b242..bdfa1fec 100644
--- a/src/kdm.cc
+++ b/src/kdm.cc
@@ -32,7 +32,7 @@
#include "exceptions.h"
#include "signer.h"
#include "cpl.h"
-#include "mxf_asset.h"
+#include "mxf.h"
#include "xml/kdm_smpte.h"
using std::list;
@@ -43,7 +43,7 @@ using std::setw;
using std::setfill;
using std::cout;
using boost::shared_ptr;
-using namespace libdcp;
+using namespace dcp;
KDM::KDM (boost::filesystem::path kdm, boost::filesystem::path private_key)
: _xml_kdm (new xml::DCinemaSecurityMessage (kdm))
@@ -124,10 +124,10 @@ KDM::KDM (
*/
apu.authorized_device_info.device_list.push_back ("2jmj7l5rSw0yVb/vlWAYkK/YBwk=");
- list<shared_ptr<const Asset> > assets = cpl->assets ();
- for (list<shared_ptr<const Asset> >::iterator i = assets.begin(); i != assets.end(); ++i) {
+ list<shared_ptr<const Content> > assets = cpl->assets ();
+ for (list<shared_ptr<const Content> >::iterator i = assets.begin(); i != assets.end(); ++i) {
/* XXX: non-MXF assets? */
- shared_ptr<const MXFAsset> mxf = boost::dynamic_pointer_cast<const MXFAsset> (*i);
+ shared_ptr<const MXF> mxf = boost::dynamic_pointer_cast<const MXF> (*i);
if (mxf) {
apu.key_id_list.push_back (xml::TypedKeyId (mxf->key_type(), "urn:uuid:" + mxf->key_id()));
}
@@ -138,9 +138,9 @@ KDM::KDM (
/* AuthenticatedPrivate */
- for (list<shared_ptr<const Asset> >::iterator i = assets.begin(); i != assets.end(); ++i) {
+ for (list<shared_ptr<const Content> >::iterator i = assets.begin(); i != assets.end(); ++i) {
/* XXX: non-MXF assets? */
- shared_ptr<const MXFAsset> mxf = boost::dynamic_pointer_cast<const MXFAsset> (*i);
+ shared_ptr<const MXF> mxf = boost::dynamic_pointer_cast<const MXF> (*i);
if (mxf) {
KDMKey kkey (
signer, cpl->id (), mxf->key_type (), mxf->key_id (),
@@ -383,7 +383,7 @@ KDMKey::put_uuid (uint8_t ** d, string id) const
}
bool
-libdcp::operator== (libdcp::KDMKey const & a, libdcp::KDMKey const & b)
+dcp::operator== (dcp::KDMKey const & a, dcp::KDMKey const & b)
{
if (memcmp (a._signer_thumbprint, b._signer_thumbprint, 20) != 0) {
return false;
diff --git a/src/kdm.h b/src/kdm.h
index 4e897ca8..9ee793c9 100644
--- a/src/kdm.h
+++ b/src/kdm.h
@@ -32,7 +32,7 @@
class kdm_key_test;
-namespace libdcp {
+namespace dcp {
namespace xml {
class DCinemaSecurityMessage;
diff --git a/src/key.cc b/src/key.cc
index 8cac04a3..0e04c27a 100644
--- a/src/key.cc
+++ b/src/key.cc
@@ -29,7 +29,7 @@ using std::string;
using std::stringstream;
using std::setw;
using std::setfill;
-using namespace libdcp;
+using namespace dcp;
Key::Key ()
: _value (new uint8_t[ASDCP::KeyLen])
@@ -86,13 +86,13 @@ Key::hex () const
}
bool
-libdcp::operator== (Key const & a, Key const & b)
+dcp::operator== (Key const & a, Key const & b)
{
return memcmp (a.value(), b.value(), ASDCP::KeyLen) == 0;
}
bool
-libdcp::operator!= (Key const & a, Key const & b)
+dcp::operator!= (Key const & a, Key const & b)
{
return !(a == b);
}
diff --git a/src/key.h b/src/key.h
index d0286627..be9f95f4 100644
--- a/src/key.h
+++ b/src/key.h
@@ -26,7 +26,7 @@
#include <stdint.h>
-namespace libdcp {
+namespace dcp {
/** @class Key
* @brief A key for encrypting MXFs.
diff --git a/src/lut.h b/src/lut.h
index ad291467..f56676a2 100644
--- a/src/lut.h
+++ b/src/lut.h
@@ -23,7 +23,7 @@
#include <cmath>
#include <boost/utility.hpp>
-namespace libdcp {
+namespace dcp {
class LUT : boost::noncopyable
{
diff --git a/src/metadata.cc b/src/metadata.cc
index acbc3b2e..d2357a1f 100644
--- a/src/metadata.cc
+++ b/src/metadata.cc
@@ -31,7 +31,7 @@
#include "util.h"
using namespace std;
-using namespace libdcp;
+using namespace dcp;
MXFMetadata::MXFMetadata ()
: company_name ("libdcp")
diff --git a/src/metadata.h b/src/metadata.h
index b4c0896d..0a707534 100644
--- a/src/metadata.h
+++ b/src/metadata.h
@@ -28,7 +28,7 @@
class utc_offset_to_string_test;
-namespace libdcp
+namespace dcp
{
class MXFMetadata
diff --git a/src/mono_picture_asset.h b/src/mono_picture_asset.h
deleted file mode 100644
index ae2df4d2..00000000
--- a/src/mono_picture_asset.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- Copyright (C) 2012-2013 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.
-
-*/
-
-#ifndef LIBDCP_MONO_PICTURE_ASSET_H
-#define LIBDCP_MONO_PICTURE_ASSET_H
-
-#include "picture_asset.h"
-
-namespace libdcp {
-
-/** A 2D (monoscopic) picture asset */
-class MonoPictureAsset : public PictureAsset
-{
-public:
- MonoPictureAsset (boost::filesystem::path directory, boost::filesystem::path mxf_name);
-
- void read ();
-
- /** The following parameters must be set up (if required) before calling this:
- * Interop mode (set_interop)
- * Edit rate (set_edit_rate)
- * MXF Metadata (set_metadata)
- */
- void create (std::vector<boost::filesystem::path> const & files);
-
- /** The following parameters must be set up (if required) before calling this:
- * Interop mode (set_interop)
- * Edit rate (set_edit_rate)
- * MXF Metadata (set_metadata)
- */
- void create (boost::function<boost::filesystem::path (int)> get_path);
-
- /** Start a progressive write to a MonoPictureAsset */
- boost::shared_ptr<PictureAssetWriter> start_write (bool);
-
- 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:
- boost::filesystem::path path_from_list (int f, std::vector<boost::filesystem::path> const & files) const;
- void construct (boost::function<boost::filesystem::path (int)>, bool, MXFMetadata const &);
- std::string cpl_node_name () const;
- int edit_rate_factor () const;
-};
-
-}
-
-#endif
diff --git a/src/mono_picture_frame.cc b/src/mono_picture_frame.cc
index 890967d1..964b543b 100644
--- a/src/mono_picture_frame.cc
+++ b/src/mono_picture_frame.cc
@@ -32,7 +32,7 @@
using std::string;
using boost::shared_ptr;
-using namespace libdcp;
+using namespace dcp;
/** Make a picture frame from a 2D (monoscopic) asset.
* @param mxf_path Path to the asset's MXF file.
diff --git a/src/mono_picture_frame.h b/src/mono_picture_frame.h
index 0eedfb95..44df68c9 100644
--- a/src/mono_picture_frame.h
+++ b/src/mono_picture_frame.h
@@ -29,7 +29,7 @@ namespace ASDCP {
class AESDecContext;
}
-namespace libdcp {
+namespace dcp {
class ARGBFrame;
diff --git a/src/mono_picture_asset.cc b/src/mono_picture_mxf.cc
index 0ac48d37..cea21c15 100644
--- a/src/mono_picture_asset.cc
+++ b/src/mono_picture_mxf.cc
@@ -17,8 +17,8 @@
*/
-#include "mono_picture_asset.h"
-#include "mono_picture_asset_writer.h"
+#include "mono_picture_mxf.h"
+#include "mono_picture_mxf_writer.h"
#include "AS_DCP.h"
#include "KM_fileio.h"
#include "exceptions.h"
@@ -29,75 +29,15 @@ using std::vector;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using boost::lexical_cast;
-using namespace libdcp;
+using namespace dcp;
-MonoPictureAsset::MonoPictureAsset (boost::filesystem::path directory, boost::filesystem::path mxf_name)
- : PictureAsset (directory, mxf_name)
-{
-
-}
-
-void
-MonoPictureAsset::create (vector<boost::filesystem::path> const & files)
-{
- create (boost::bind (&MonoPictureAsset::path_from_list, this, _1, files));
-}
-
-void
-MonoPictureAsset::create (boost::function<boost::filesystem::path (int)> get_path)
-{
- ASDCP::JP2K::CodestreamParser j2k_parser;
- ASDCP::JP2K::FrameBuffer frame_buffer (4 * Kumu::Megabyte);
- Kumu::Result_t r = j2k_parser.OpenReadFrame (get_path(0).string().c_str(), frame_buffer);
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (FileError ("could not open JPEG2000 file for reading", get_path(0), r));
- }
-
- ASDCP::JP2K::PictureDescriptor picture_desc;
- j2k_parser.FillPictureDescriptor (picture_desc);
- picture_desc.EditRate = ASDCP::Rational (_edit_rate, 1);
-
- ASDCP::WriterInfo writer_info;
- fill_writer_info (&writer_info);
-
- ASDCP::JP2K::MXFWriter mxf_writer;
- r = mxf_writer.OpenWrite (path().string().c_str(), writer_info, picture_desc, 16384, false);
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for writing", path().string(), r));
- }
-
- for (int i = 0; i < _intrinsic_duration; ++i) {
-
- boost::filesystem::path const path = get_path (i);
-
- Kumu::Result_t r = j2k_parser.OpenReadFrame (path.string().c_str(), frame_buffer);
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (FileError ("could not open JPEG2000 file for reading", path, r));
- }
-
- r = mxf_writer.WriteFrame (frame_buffer, _encryption_context, 0);
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in writing video MXF", this->path().string(), r));
- }
-
- if (_progress) {
- (*_progress) (0.5 * float (i) / _intrinsic_duration);
- }
- }
-
- r = mxf_writer.Finalize();
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in finalising video MXF", path().string(), r));
- }
-}
-
-void
-MonoPictureAsset::read ()
+MonoPictureMXF::MonoPictureMXF (boost::filesystem::path file)
+ : PictureMXF (file)
{
ASDCP::JP2K::MXFReader reader;
- Kumu::Result_t r = reader.OpenRead (path().string().c_str());
+ Kumu::Result_t r = reader.OpenRead (file.string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file.string(), r));
}
ASDCP::JP2K::PictureDescriptor desc;
@@ -112,35 +52,35 @@ MonoPictureAsset::read ()
_intrinsic_duration = desc.ContainerDuration;
}
-boost::filesystem::path
-MonoPictureAsset::path_from_list (int f, vector<boost::filesystem::path> const & files) const
+MonoPictureMXF::MonoPictureMXF (int edit_rate)
+ : PictureMXF (edit_rate)
{
- return files[f];
+
}
shared_ptr<const MonoPictureFrame>
-MonoPictureAsset::get_frame (int n) const
+MonoPictureMXF::get_frame (int n) const
{
- return shared_ptr<const MonoPictureFrame> (new MonoPictureFrame (path(), n, _decryption_context));
+ return shared_ptr<const MonoPictureFrame> (new MonoPictureFrame (_file, n, _decryption_context));
}
bool
-MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
+MonoPictureMXF::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
{
- if (!MXFAsset::equals (other, opt, note)) {
+ if (!MXF::equals (other, opt, note)) {
return false;
}
ASDCP::JP2K::MXFReader reader_A;
- Kumu::Result_t r = reader_A.OpenRead (path().string().c_str());
+ Kumu::Result_t r = reader_A.OpenRead (_file.string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", _file.string(), r));
}
ASDCP::JP2K::MXFReader reader_B;
- r = reader_B.OpenRead (other->path().string().c_str());
+ r = reader_B.OpenRead (other->file().string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", other->file().string(), r));
}
ASDCP::JP2K::PictureDescriptor desc_A;
@@ -156,7 +96,7 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, bo
return false;
}
- shared_ptr<const MonoPictureAsset> other_picture = dynamic_pointer_cast<const MonoPictureAsset> (other);
+ shared_ptr<const MonoPictureMXF> other_picture = dynamic_pointer_cast<const MonoPictureMXF> (other);
assert (other_picture);
for (int i = 0; i < _intrinsic_duration; ++i) {
@@ -180,21 +120,21 @@ MonoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, bo
return true;
}
-shared_ptr<PictureAssetWriter>
-MonoPictureAsset::start_write (bool overwrite)
+shared_ptr<PictureMXFWriter>
+MonoPictureMXF::start_write (boost::filesystem::path file, bool overwrite)
{
/* XXX: can't we use shared_ptr here? */
- return shared_ptr<MonoPictureAssetWriter> (new MonoPictureAssetWriter (this, overwrite));
+ return shared_ptr<MonoPictureMXFWriter> (new MonoPictureMXFWriter (this, file, overwrite));
}
string
-MonoPictureAsset::cpl_node_name () const
+MonoPictureMXF::cpl_node_name () const
{
return "MainPicture";
}
int
-MonoPictureAsset::edit_rate_factor () const
+MonoPictureMXF::edit_rate_factor () const
{
return 1;
}
diff --git a/src/mono_picture_mxf.h b/src/mono_picture_mxf.h
new file mode 100644
index 00000000..8c8ee531
--- /dev/null
+++ b/src/mono_picture_mxf.h
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2012-2013 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.
+
+*/
+
+#ifndef LIBDCP_MONO_PICTURE_MXF_H
+#define LIBDCP_MONO_PICTURE_MXF_H
+
+#include "picture_mxf.h"
+
+namespace dcp {
+
+/** @class MonoPictureMXF
+ * @brief A 2D (monoscopic) picture MXF.
+ */
+class MonoPictureMXF : public PictureMXF
+{
+public:
+ /** Create a MonoPictureMXF by reading a file.
+ * @param file MXF file to read.
+ */
+ MonoPictureMXF (boost::filesystem::path file);
+
+ /** Create a MonoPictureMXF with a given edit rate.
+ * @param edit_rate Edit rate (i.e. frame rate) in frames per second.
+ */
+ MonoPictureMXF (int edit_rate);
+
+ /** Start a progressive write to a MonoPictureMXF */
+ boost::shared_ptr<PictureMXFWriter> start_write (boost::filesystem::path, bool);
+
+ boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
+ bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
+
+private:
+ std::string cpl_node_name () const;
+ int edit_rate_factor () const;
+};
+
+}
+
+#endif
diff --git a/src/mono_picture_asset_writer.cc b/src/mono_picture_mxf_writer.cc
index 6f0ba973..590a3f7d 100644
--- a/src/mono_picture_asset_writer.cc
+++ b/src/mono_picture_mxf_writer.cc
@@ -19,20 +19,20 @@
#include "AS_DCP.h"
#include "KM_fileio.h"
-#include "mono_picture_asset_writer.h"
+#include "mono_picture_mxf_writer.h"
#include "exceptions.h"
-#include "picture_asset.h"
+#include "picture_mxf.h"
-#include "picture_asset_writer_common.cc"
+#include "picture_mxf_writer_common.cc"
using std::istream;
using std::ostream;
using std::string;
using boost::shared_ptr;
using boost::lexical_cast;
-using namespace libdcp;
+using namespace dcp;
-struct MonoPictureAssetWriter::ASDCPState : public ASDCPStateBase
+struct MonoPictureMXFWriter::ASDCPState : public ASDCPStateBase
{
ASDCP::JP2K::MXFWriter mxf_writer;
};
@@ -40,21 +40,21 @@ struct MonoPictureAssetWriter::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)
- : PictureAssetWriter (asset, overwrite)
- , _state (new MonoPictureAssetWriter::ASDCPState)
+MonoPictureMXFWriter::MonoPictureMXFWriter (PictureMXF* asset, boost::filesystem::path file, bool overwrite)
+ : PictureMXFWriter (asset, file, overwrite)
+ , _state (new MonoPictureMXFWriter::ASDCPState)
{
_state->encryption_context = asset->encryption_context ();
}
void
-MonoPictureAssetWriter::start (uint8_t* data, int size)
+MonoPictureMXFWriter::start (uint8_t* data, int size)
{
- libdcp::start (this, _state, _asset, data, size);
+ dcp::start (this, _state, _mxf, data, size);
}
FrameInfo
-MonoPictureAssetWriter::write (uint8_t* data, int size)
+MonoPictureMXFWriter::write (uint8_t* data, int size)
{
assert (!_finalized);
@@ -71,7 +71,7 @@ MonoPictureAssetWriter::write (uint8_t* data, int size)
string hash;
ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _state->encryption_context, 0, &hash);
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string(), r));
+ boost::throw_exception (MXFFileError ("error in writing video MXF", _file.string(), r));
}
++_frames_written;
@@ -79,31 +79,31 @@ MonoPictureAssetWriter::write (uint8_t* data, int size)
}
void
-MonoPictureAssetWriter::fake_write (int size)
+MonoPictureMXFWriter::fake_write (int size)
{
assert (_started);
assert (!_finalized);
Kumu::Result_t r = _state->mxf_writer.FakeWriteFrame (size);
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string(), r));
+ boost::throw_exception (MXFFileError ("error in writing video MXF", _mxf->file().string(), r));
}
++_frames_written;
}
void
-MonoPictureAssetWriter::finalize ()
+MonoPictureMXFWriter::finalize ()
{
assert (!_finalized);
Kumu::Result_t r = _state->mxf_writer.Finalize();
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in finalizing video MXF", _asset->path().string(), r));
+ boost::throw_exception (MXFFileError ("error in finalizing video MXF", _mxf->file().string(), r));
}
_finalized = true;
- _asset->set_intrinsic_duration (_frames_written);
- _asset->set_duration (_frames_written);
+ _mxf->set_intrinsic_duration (_frames_written);
+ _mxf->set_duration (_frames_written);
}
diff --git a/src/mono_picture_asset_writer.h b/src/mono_picture_mxf_writer.h
index e3922623..c4d9b6ed 100644
--- a/src/mono_picture_asset_writer.h
+++ b/src/mono_picture_mxf_writer.h
@@ -22,21 +22,20 @@
#include <fstream>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
-#include "picture_asset_writer.h"
+#include "picture_mxf_writer.h"
-namespace libdcp {
+namespace dcp {
-/** A helper class for writing to MonoPictureAssets progressively (i.e. writing frame-by-frame,
- * rather than giving libdcp all the frames in one go).
+/** A helper class for writing to MonoPictureMXFs.
*
- * Objects of this class can only be created with MonoPictureAsset::start_write().
+ * Objects of this class can only be created with MonoPictureMXF::start_write().
*
* Frames can be written to the MonoPictureAsset by calling write() with a JPEG2000 image
* (a verbatim .j2c file). finalize() must be called after the last frame has been written.
* The action of finalize() can't be done in MonoPictureAssetWriter's destructor as it may
* throw an exception.
*/
-class MonoPictureAssetWriter : public PictureAssetWriter
+class MonoPictureMXFWriter : public PictureMXFWriter
{
public:
FrameInfo write (uint8_t *, int);
@@ -44,9 +43,9 @@ public:
void finalize ();
private:
- friend class MonoPictureAsset;
+ friend class MonoPictureMXF;
- MonoPictureAssetWriter (PictureAsset *, bool);
+ MonoPictureMXFWriter (PictureMXF *, boost::filesystem::path file, bool);
void start (uint8_t *, int);
/* do this with an opaque pointer so we don't have to include
diff --git a/src/mxf_asset.cc b/src/mxf.cc
index c2428a3c..fa3aed8b 100644
--- a/src/mxf_asset.cc
+++ b/src/mxf.cc
@@ -28,7 +28,7 @@
#include "AS_DCP.h"
#include "KM_prng.h"
#include "KM_util.h"
-#include "mxf_asset.h"
+#include "mxf.h"
#include "util.h"
#include "metadata.h"
#include "exceptions.h"
@@ -40,10 +40,10 @@ using std::pair;
using boost::shared_ptr;
using boost::lexical_cast;
using boost::dynamic_pointer_cast;
-using namespace libdcp;
+using namespace dcp;
-MXFAsset::MXFAsset (boost::filesystem::path directory, boost::filesystem::path file_name)
- : Asset (directory, file_name)
+MXF::MXF (boost::filesystem::path file)
+ : Content (file)
, _progress (0)
, _encryption_context (0)
, _decryption_context (0)
@@ -52,14 +52,14 @@ MXFAsset::MXFAsset (boost::filesystem::path directory, boost::filesystem::path f
}
-MXFAsset::~MXFAsset ()
+MXF::~MXF ()
{
delete _encryption_context;
delete _decryption_context;
}
void
-MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info)
+MXF::fill_writer_info (ASDCP::WriterInfo* writer_info)
{
writer_info->ProductVersion = _metadata.product_version;
writer_info->CompanyName = _metadata.company_name;
@@ -71,7 +71,7 @@ MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info)
writer_info->LabelSetType = ASDCP::LS_MXF_SMPTE;
}
unsigned int c;
- Kumu::hex2bin (_uuid.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c);
+ Kumu::hex2bin (_id.c_str(), writer_info->AssetUUID, Kumu::UUID_Length, &c);
assert (c == Kumu::UUID_Length);
if (_key) {
@@ -85,19 +85,19 @@ MXFAsset::fill_writer_info (ASDCP::WriterInfo* writer_info)
}
bool
-MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
+MXF::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
{
- if (!Asset::equals (other, opt, note)) {
+ if (!Content::equals (other, opt, note)) {
return false;
}
- shared_ptr<const MXFAsset> other_mxf = dynamic_pointer_cast<const MXFAsset> (other);
+ shared_ptr<const MXF> other_mxf = dynamic_pointer_cast<const MXF> (other);
if (!other_mxf) {
note (ERROR, "comparing an MXF asset with a non-MXF asset");
return false;
}
- if (_file_name != other_mxf->_file_name) {
+ if (_file != other_mxf->file ()) {
note (ERROR, "MXF names differ");
if (!opt.mxf_names_can_differ) {
return false;
@@ -108,15 +108,15 @@ MXFAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::fun
}
void
-MXFAsset::write_to_cpl (xmlpp::Element* node) const
+MXF::write_to_cpl (xmlpp::Element* node) const
{
pair<string, string> const attr = cpl_node_attribute ();
xmlpp::Element* a = node->add_child (cpl_node_name ());
if (!attr.first.empty ()) {
a->set_attribute (attr.first, attr.second);
}
- a->add_child ("Id")->add_child_text ("urn:uuid:" + _uuid);
- a->add_child ("AnnotationText")->add_child_text (_file_name.string ());
+ a->add_child ("Id")->add_child_text ("urn:uuid:" + _id);
+ a->add_child ("AnnotationText")->add_child_text (_file.string ());
a->add_child ("EditRate")->add_child_text (lexical_cast<string> (_edit_rate) + " 1");
a->add_child ("IntrinsicDuration")->add_child_text (lexical_cast<string> (_intrinsic_duration));
a->add_child ("EntryPoint")->add_child_text (lexical_cast<string> (_entry_point));
@@ -127,7 +127,7 @@ MXFAsset::write_to_cpl (xmlpp::Element* node) const
}
void
-MXFAsset::set_key (Key key)
+MXF::set_key (Key key)
{
_key = key;
diff --git a/src/mxf_asset.h b/src/mxf.h
index 7a645b7c..a83d9fff 100644
--- a/src/mxf_asset.h
+++ b/src/mxf.h
@@ -21,7 +21,7 @@
#define LIBDCP_MXF_ASSET_H
#include <boost/signals2.hpp>
-#include "asset.h"
+#include "content.h"
#include "key.h"
#include "metadata.h"
@@ -30,26 +30,23 @@ namespace ASDCP {
class AESDecContext;
}
-namespace libdcp
+namespace dcp
{
class MXFMetadata;
-/** @brief Parent class for assets which have MXF files */
-class MXFAsset : public Asset
+/** @class MXF
+ * @brief Parent class for classes which represent MXF files.
+ */
+class MXF : public Content
{
public:
- /** Construct an MXFAsset.
- * This class will not write anything to disk in this constructor, but subclasses may.
- *
- * @param directory Directory where MXF file is.
- * @param file_name Name of MXF file.
- */
- MXFAsset (boost::filesystem::path directory, boost::filesystem::path file_name);
+ MXF (boost::filesystem::path file);
+ MXF (int edit_rate);
- ~MXFAsset ();
+ ~MXF ();
- virtual bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
+ virtual bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
virtual void write_to_cpl (xmlpp::Element *) const;
virtual std::string key_type () const = 0;
diff --git a/src/object.cc b/src/object.cc
new file mode 100644
index 00000000..e9a4f62b
--- /dev/null
+++ b/src/object.cc
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 2014 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.
+
+*/
+
+#include "object.h"
+#include "util.h"
+
+using std::string;
+using namespace dcp;
+
+Object::Object ()
+ : _id (make_uuid ())
+{
+
+}
+
+Object::Object (string id)
+ : _id (id)
+{
+
+}
diff --git a/src/object.h b/src/object.h
new file mode 100644
index 00000000..636c76a0
--- /dev/null
+++ b/src/object.h
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 2014 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.
+
+*/
+
+#ifndef LIBDCP_OBJECT_H
+#define LIBDCP_OBJECT_H
+
+#include <string>
+
+namespace dcp {
+
+/** Some part of a DCP that has a UUID */
+class Object
+{
+public:
+ Object ();
+ Object (std::string id);
+ virtual ~Object () {}
+
+ std::string id () const {
+ return _id;
+ }
+
+protected:
+ std::string _id;
+};
+
+}
+
+#endif
diff --git a/src/parse/asset_map.cc b/src/parse/asset_map.cc
index 484c2710..0b323fb3 100644
--- a/src/parse/asset_map.cc
+++ b/src/parse/asset_map.cc
@@ -29,7 +29,7 @@
using std::string;
using std::list;
using boost::shared_ptr;
-using namespace libdcp::parse;
+using namespace dcp::parse;
AssetMap::AssetMap (string file)
{
diff --git a/src/parse/asset_map.h b/src/parse/asset_map.h
index af3e8918..e3035593 100644
--- a/src/parse/asset_map.h
+++ b/src/parse/asset_map.h
@@ -25,7 +25,7 @@
#include <boost/shared_ptr.hpp>
#include <libcxml/cxml.h>
-namespace libdcp {
+namespace dcp {
namespace parse {
diff --git a/src/parse/cpl.cc b/src/parse/cpl.cc
index f6ce434c..d94fb68e 100644
--- a/src/parse/cpl.cc
+++ b/src/parse/cpl.cc
@@ -29,7 +29,7 @@
using std::string;
using std::bad_cast;
using boost::shared_ptr;
-using namespace libdcp::parse;
+using namespace dcp::parse;
CPL::CPL (string file)
{
diff --git a/src/parse/cpl.h b/src/parse/cpl.h
index 04bf9351..4889a1c4 100644
--- a/src/parse/cpl.h
+++ b/src/parse/cpl.h
@@ -26,7 +26,7 @@
#include <libcxml/cxml.h>
#include "../types.h"
-namespace libdcp {
+namespace dcp {
namespace parse {
diff --git a/src/parse/pkl.cc b/src/parse/pkl.cc
index bbf070ae..d0fa1556 100644
--- a/src/parse/pkl.cc
+++ b/src/parse/pkl.cc
@@ -26,7 +26,7 @@
using namespace std;
using namespace boost;
-using namespace libdcp::parse;
+using namespace dcp::parse;
PKL::PKL (string file)
{
diff --git a/src/parse/pkl.h b/src/parse/pkl.h
index 13d87fa1..f31eef7d 100644
--- a/src/parse/pkl.h
+++ b/src/parse/pkl.h
@@ -24,7 +24,7 @@
#include <boost/shared_ptr.hpp>
#include "../xml.h"
-namespace libdcp {
+namespace dcp {
namespace parse {
diff --git a/src/parse/subtitle.cc b/src/parse/subtitle.cc
index 612af716..3f9869b4 100644
--- a/src/parse/subtitle.cc
+++ b/src/parse/subtitle.cc
@@ -27,8 +27,8 @@ using std::list;
using boost::shared_ptr;
using boost::optional;
using boost::lexical_cast;
-using namespace libdcp;
-using namespace libdcp::parse;
+using namespace dcp;
+using namespace dcp::parse;
Font::Font (shared_ptr<const cxml::Node> node)
{
diff --git a/src/parse/subtitle.h b/src/parse/subtitle.h
index c20278a3..50c2ebc5 100644
--- a/src/parse/subtitle.h
+++ b/src/parse/subtitle.h
@@ -21,7 +21,7 @@
#include "../dcp_time.h"
#include "../types.h"
-namespace libdcp
+namespace dcp
{
namespace parse
diff --git a/src/picture_asset.cc b/src/picture_mxf.cc
index b2eecee5..8f0f85b9 100644
--- a/src/picture_asset.cc
+++ b/src/picture_mxf.cc
@@ -31,11 +31,11 @@
#include <libxml++/nodes/element.h>
#include "AS_DCP.h"
#include "KM_fileio.h"
-#include "picture_asset.h"
+#include "picture_mxf.h"
#include "util.h"
#include "exceptions.h"
#include "xyz_frame.h"
-#include "picture_asset_writer.h"
+#include "picture_mxf_writer.h"
using std::string;
using std::ostream;
@@ -50,18 +50,24 @@ using std::cout;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using boost::lexical_cast;
-using namespace libdcp;
+using namespace dcp;
-PictureAsset::PictureAsset (boost::filesystem::path directory, boost::filesystem::path mxf_name)
- : MXFAsset (directory, mxf_name)
+PictureMXF::PictureMXF (boost::filesystem::path file)
+ : MXF (file)
+{
+
+}
+
+PictureMXF::PictureMXF (int edit_rate)
+ : MXF (edit_rate)
{
}
void
-PictureAsset::write_to_cpl (xmlpp::Element* node) const
+PictureMXF::write_to_cpl (xmlpp::Element* node) const
{
- MXFAsset::write_to_cpl (node);
+ MXF::write_to_cpl (node);
xmlpp::Node::NodeList c = node->get_children ();
xmlpp::Node::NodeList::iterator i = c.begin();
@@ -82,7 +88,7 @@ PictureAsset::write_to_cpl (xmlpp::Element* node) const
}
bool
-PictureAsset::descriptor_equals (
+PictureMXF::descriptor_equals (
ASDCP::JP2K::PictureDescriptor const & a, ASDCP::JP2K::PictureDescriptor const & b, boost::function<void (NoteType, string)> note
) const
{
@@ -124,7 +130,7 @@ PictureAsset::descriptor_equals (
}
bool
-PictureAsset::frame_buffer_equals (
+PictureMXF::frame_buffer_equals (
int frame, EqualityOptions opt, boost::function<void (NoteType, string)> note,
uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
) const
@@ -202,7 +208,7 @@ PictureAsset::frame_buffer_equals (
}
string
-PictureAsset::key_type () const
+PictureMXF::key_type () const
{
return "MDIK";
}
diff --git a/src/picture_asset.h b/src/picture_mxf.h
index b8dab052..3a587280 100644
--- a/src/picture_asset.h
+++ b/src/picture_mxf.h
@@ -17,15 +17,15 @@
*/
-#ifndef LIBDCP_PICTURE_ASSET_H
-#define LIBDCP_PICTURE_ASSET_H
+#ifndef LIBDCP_PICTURE_MXF_H
+#define LIBDCP_PICTURE_MXF_H
/** @file src/picture_asset.h
* @brief An asset made up of JPEG2000 data
*/
#include <openjpeg.h>
-#include "mxf_asset.h"
+#include "mxf.h"
#include "util.h"
#include "metadata.h"
@@ -35,39 +35,22 @@ namespace ASDCP {
}
}
-namespace libdcp
+namespace dcp
{
class MonoPictureFrame;
class StereoPictureFrame;
-class PictureAssetWriter;
+class PictureMXFWriter;
/** @brief An asset made up of JPEG2000 data */
-class PictureAsset : public MXFAsset
+class PictureMXF : public MXF
{
public:
- /** Construct a PictureAsset.
- *
- * @param directory Directory where MXF file is.
- * @param mxf_name Name of MXF file.
- */
- PictureAsset (boost::filesystem::path directory, boost::filesystem::path mxf_name);
-
- /** Start a progressive write to this asset.
- * The following parameters must be set up (if required) before calling this:
- * Interop mode (set_interop)
- * Edit rate (set_edit_rate)
- * MXF Metadata (set_metadata)
- *
- * @param overwrite true to overwrite an existing MXF file; in this mode, writing can be resumed to a partially-written MXF; false if the
- * MXF file does not exist.
- */
- virtual boost::shared_ptr<PictureAssetWriter> start_write (bool overwrite) = 0;
-
- virtual void read () = 0;
- virtual void create (std::vector<boost::filesystem::path> const &) {}
- virtual void create (boost::function<boost::filesystem::path (int)>) {}
-
+ PictureMXF (boost::filesystem::path file);
+ PictureMXF (int edit_rate);
+
+ virtual boost::shared_ptr<PictureMXFWriter> start_write (boost::filesystem::path file, bool overwrite) = 0;
+
Size size () const {
return _size;
}
diff --git a/src/picture_asset_writer.cc b/src/picture_mxf_writer.cc
index 92b384db..1a128b33 100644
--- a/src/picture_asset_writer.cc
+++ b/src/picture_mxf_writer.cc
@@ -21,15 +21,15 @@
#include <stdint.h>
#include "AS_DCP.h"
#include "KM_fileio.h"
-#include "picture_asset_writer.h"
+#include "picture_mxf_writer.h"
#include "exceptions.h"
-#include "picture_asset.h"
+#include "picture_mxf.h"
using std::istream;
using std::ostream;
using std::string;
using boost::shared_ptr;
-using namespace libdcp;
+using namespace dcp;
FrameInfo::FrameInfo (istream& s)
: offset (0)
@@ -83,8 +83,9 @@ FrameInfo::write (FILE* f) const
}
-PictureAssetWriter::PictureAssetWriter (PictureAsset* asset, bool overwrite)
- : _asset (asset)
+PictureMXFWriter::PictureMXFWriter (PictureMXF* mxf, boost::filesystem::path file, bool overwrite)
+ : _mxf (mxf)
+ , _file (file)
, _frames_written (0)
, _started (false)
, _finalized (false)
diff --git a/src/picture_asset_writer.h b/src/picture_mxf_writer.h
index a62b20b2..bcd8873d 100644
--- a/src/picture_asset_writer.h
+++ b/src/picture_mxf_writer.h
@@ -25,9 +25,9 @@
#include "metadata.h"
#include "types.h"
-namespace libdcp {
+namespace dcp {
-class PictureAsset;
+class PictureMXF;
/** Information about a single frame (either a monoscopic frame or a left *or* right eye stereoscopic frame) */
struct FrameInfo
@@ -49,22 +49,23 @@ struct FrameInfo
std::string hash;
};
-class PictureAssetWriter : public boost::noncopyable
+class PictureMXFWriter : public boost::noncopyable
{
public:
- virtual ~PictureAssetWriter () {}
+ virtual ~PictureMXFWriter () {}
virtual FrameInfo write (uint8_t *, int) = 0;
virtual void finalize () = 0;
virtual void fake_write (int) = 0;
-
+
protected:
template <class P, class Q>
- friend void start (PictureAssetWriter *, boost::shared_ptr<P>, Q *, uint8_t *, int);
+ friend void start (PictureMXFWriter *, boost::shared_ptr<P>, Q *, uint8_t *, int);
- PictureAssetWriter (PictureAsset *, bool);
+ PictureMXFWriter (PictureMXF *, boost::filesystem::path, bool);
- PictureAsset* _asset;
-
+ PictureMXF* _mxf;
+
+ boost::filesystem::path _file;
/** Number of picture frames written to the asset so far. For stereo assets
* this will be incremented for each eye (i.e. there will be twice the number
* of frames as in a mono asset).
diff --git a/src/picture_asset_writer_common.cc b/src/picture_mxf_writer_common.cc
index 52848745..6ac8ae35 100644
--- a/src/picture_asset_writer_common.cc
+++ b/src/picture_mxf_writer_common.cc
@@ -33,19 +33,21 @@ struct ASDCPStateBase
};
template <class P, class Q>
-void libdcp::start (PictureAssetWriter* writer, shared_ptr<P> state, Q* asset, uint8_t* data, int size)
+void dcp::start (PictureMXFWriter* writer, shared_ptr<P> state, Q* mxf, uint8_t* data, int size)
{
+ mxf->set_file (writer->_file);
+
if (ASDCP_FAILURE (state->j2k_parser.OpenReadFrame (data, size, state->frame_buffer))) {
boost::throw_exception (MiscError ("could not parse J2K frame"));
}
state->j2k_parser.FillPictureDescriptor (state->picture_descriptor);
- state->picture_descriptor.EditRate = ASDCP::Rational (asset->edit_rate(), 1);
+ state->picture_descriptor.EditRate = ASDCP::Rational (mxf->edit_rate(), 1);
- asset->fill_writer_info (&state->writer_info);
+ mxf->fill_writer_info (&state->writer_info);
Kumu::Result_t r = state->mxf_writer.OpenWrite (
- asset->path().string().c_str(),
+ mxf->file().string().c_str(),
state->writer_info,
state->picture_descriptor,
16384,
@@ -53,7 +55,7 @@ void libdcp::start (PictureAssetWriter* writer, shared_ptr<P> state, Q* asset, u
);
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for writing", asset->path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for writing", mxf->file().string(), r));
}
writer->_started = true;
diff --git a/src/rec709_linearised_gamma_lut.cc b/src/rec709_linearised_gamma_lut.cc
index f14e4472..29f39ac0 100644
--- a/src/rec709_linearised_gamma_lut.cc
+++ b/src/rec709_linearised_gamma_lut.cc
@@ -19,7 +19,7 @@
#include "rec709_linearised_gamma_lut.h"
-using namespace libdcp;
+using namespace dcp;
LUTCache<Rec709LinearisedGammaLUT> Rec709LinearisedGammaLUT::cache;
diff --git a/src/rec709_linearised_gamma_lut.h b/src/rec709_linearised_gamma_lut.h
index af0158a5..e7130ef3 100644
--- a/src/rec709_linearised_gamma_lut.h
+++ b/src/rec709_linearised_gamma_lut.h
@@ -20,7 +20,7 @@
#include "lut.h"
#include "lut_cache.h"
-namespace libdcp {
+namespace dcp {
class Rec709LinearisedGammaLUT : public LUT
{
diff --git a/src/reel.cc b/src/reel.cc
index ff51c025..9f514d88 100644
--- a/src/reel.cc
+++ b/src/reel.cc
@@ -20,10 +20,10 @@
#include <libxml++/nodes/element.h>
#include "reel.h"
#include "util.h"
-#include "picture_asset.h"
-#include "mono_picture_asset.h"
-#include "stereo_picture_asset.h"
-#include "sound_asset.h"
+#include "picture_mxf.h"
+#include "mono_picture_mxf.h"
+#include "stereo_picture_mxf.h"
+#include "sound_mxf.h"
#include "subtitle_asset.h"
#include "kdm.h"
@@ -32,7 +32,7 @@ using std::list;
using std::cout;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
-using namespace libdcp;
+using namespace dcp;
void
Reel::write_to_cpl (xmlpp::Element* node) const
@@ -41,7 +41,7 @@ Reel::write_to_cpl (xmlpp::Element* node) const
reel->add_child("Id")->add_child_text ("urn:uuid:" + make_uuid());
xmlpp::Element* asset_list = reel->add_child ("AssetList");
- if (_main_picture && dynamic_pointer_cast<MonoPictureAsset> (_main_picture)) {
+ if (_main_picture && dynamic_pointer_cast<MonoPictureMXF> (_main_picture)) {
/* Mono pictures come before other stuff... */
_main_picture->write_to_cpl (asset_list);
}
@@ -54,7 +54,7 @@ Reel::write_to_cpl (xmlpp::Element* node) const
_main_subtitle->write_to_cpl (asset_list);
}
- if (_main_picture && dynamic_pointer_cast<StereoPictureAsset> (_main_picture)) {
+ if (_main_picture && dynamic_pointer_cast<StereoPictureMXF> (_main_picture)) {
/* ... but stereo pictures must come after */
_main_picture->write_to_cpl (asset_list);
}
diff --git a/src/reel.h b/src/reel.h
index 35302f17..41e811e4 100644
--- a/src/reel.h
+++ b/src/reel.h
@@ -31,10 +31,10 @@ namespace xmlpp {
class Node;
}
-namespace libdcp {
+namespace dcp {
-class PictureAsset;
-class SoundAsset;
+class PictureMXF;
+class SoundMXF;
class SubtitleAsset;
class KDM;
@@ -43,8 +43,8 @@ class Reel
{
public:
Reel (
- boost::shared_ptr<PictureAsset> picture,
- boost::shared_ptr<SoundAsset> sound,
+ boost::shared_ptr<PictureMXF> picture,
+ boost::shared_ptr<SoundMXF> sound,
boost::shared_ptr<SubtitleAsset> subtitle
)
: _main_picture (picture)
@@ -52,11 +52,11 @@ public:
, _main_subtitle (subtitle)
{}
- boost::shared_ptr<const PictureAsset> main_picture () const {
+ boost::shared_ptr<const PictureMXF> main_picture () const {
return _main_picture;
}
- boost::shared_ptr<const SoundAsset> main_sound () const {
+ boost::shared_ptr<const SoundMXF> main_sound () const {
return _main_sound;
}
@@ -68,15 +68,15 @@ public:
bool encrypted () const;
- void set_mxf_keys (libdcp::Key);
+ void set_mxf_keys (dcp::Key);
bool equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> notes) const;
void add_kdm (KDM const &);
private:
- boost::shared_ptr<PictureAsset> _main_picture;
- boost::shared_ptr<SoundAsset> _main_sound;
+ boost::shared_ptr<PictureMXF> _main_picture;
+ boost::shared_ptr<SoundMXF> _main_sound;
boost::shared_ptr<SubtitleAsset> _main_subtitle;
};
diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc
index dea2106c..7d30d32e 100644
--- a/src/rgb_xyz.cc
+++ b/src/rgb_xyz.cc
@@ -27,7 +27,7 @@
using std::min;
using std::max;
using boost::shared_ptr;
-using namespace libdcp;
+using namespace dcp;
#define DCI_COEFFICIENT (48.0 / 52.37)
@@ -36,7 +36,7 @@ using namespace libdcp;
* @return RGB image.
*/
shared_ptr<ARGBFrame>
-libdcp::xyz_to_rgb (shared_ptr<const XYZFrame> xyz_frame, shared_ptr<const LUT> lut_in, shared_ptr<const LUT> lut_out)
+dcp::xyz_to_rgb (shared_ptr<const XYZFrame> xyz_frame, shared_ptr<const LUT> lut_in, shared_ptr<const LUT> lut_out)
{
int const max_colour = pow (2, lut_out->bit_depth()) - 1;
@@ -99,8 +99,8 @@ libdcp::xyz_to_rgb (shared_ptr<const XYZFrame> xyz_frame, shared_ptr<const LUT>
return argb_frame;
}
-shared_ptr<libdcp::XYZFrame>
-libdcp::rgb_to_xyz (shared_ptr<const Image> rgb, shared_ptr<const LUT> lut_in, shared_ptr<const LUT> lut_out, double const colour_matrix[3][3])
+shared_ptr<dcp::XYZFrame>
+dcp::rgb_to_xyz (shared_ptr<const Image> rgb, shared_ptr<const LUT> lut_in, shared_ptr<const LUT> lut_out, double const colour_matrix[3][3])
{
assert (lut_in->bit_depth() == 12);
assert (lut_out->bit_depth() == 16);
diff --git a/src/rgb_xyz.h b/src/rgb_xyz.h
index 87959cb3..f4c8b686 100644
--- a/src/rgb_xyz.h
+++ b/src/rgb_xyz.h
@@ -19,7 +19,7 @@
#include <boost/shared_ptr.hpp>
-namespace libdcp {
+namespace dcp {
class ARGBFrame;
class XYZFrame;
diff --git a/src/signer.cc b/src/signer.cc
index 63da8d8e..ea13563f 100644
--- a/src/signer.cc
+++ b/src/signer.cc
@@ -30,7 +30,7 @@ using std::string;
using std::list;
using std::cout;
using boost::shared_ptr;
-using namespace libdcp;
+using namespace dcp;
/** @param signer_key Filename of private key to sign with */
void
diff --git a/src/signer.h b/src/signer.h
index efb8099b..7c2864fd 100644
--- a/src/signer.h
+++ b/src/signer.h
@@ -25,7 +25,7 @@ namespace xmlpp {
class Node;
}
-namespace libdcp {
+namespace dcp {
class Signer
{
diff --git a/src/signer_chain.cc b/src/signer_chain.cc
index d407286e..5f9941f9 100644
--- a/src/signer_chain.cc
+++ b/src/signer_chain.cc
@@ -76,7 +76,7 @@ static void command (string cmd)
if (code) {
stringstream s;
s << "error " << code << " in " << cmd << " within " << boost::filesystem::current_path();
- throw libdcp::MiscError (s.str());
+ throw dcp::MiscError (s.str());
}
}
@@ -101,7 +101,7 @@ public_key_digest (boost::filesystem::path private_key, boost::filesystem::path
string pub;
ifstream f (public_name.string().c_str ());
if (!f.good ()) {
- throw libdcp::MiscError ("public key not found");
+ throw dcp::MiscError ("public key not found");
}
bool read = false;
@@ -120,22 +120,22 @@ public_key_digest (boost::filesystem::path private_key, boost::filesystem::path
/* Decode the base64 of the public key */
unsigned char buffer[512];
- int const N = libdcp::base64_decode (pub, buffer, 1024);
+ int const N = dcp::base64_decode (pub, buffer, 1024);
/* Hash it with SHA1 (without the first 24 bytes, for reasons that are not entirely clear) */
SHA_CTX context;
if (!SHA1_Init (&context)) {
- throw libdcp::MiscError ("could not init SHA1 context");
+ throw dcp::MiscError ("could not init SHA1 context");
}
if (!SHA1_Update (&context, buffer + 24, N - 24)) {
- throw libdcp::MiscError ("could not update SHA1 digest");
+ throw dcp::MiscError ("could not update SHA1 digest");
}
unsigned char digest[SHA_DIGEST_LENGTH];
if (!SHA1_Final (digest, &context)) {
- throw libdcp::MiscError ("could not finish SHA1 digest");
+ throw dcp::MiscError ("could not finish SHA1 digest");
}
char digest_base64[64];
@@ -149,7 +149,7 @@ public_key_digest (boost::filesystem::path private_key, boost::filesystem::path
}
void
-libdcp::make_signer_chain (boost::filesystem::path directory, boost::filesystem::path openssl)
+dcp::make_signer_chain (boost::filesystem::path directory, boost::filesystem::path openssl)
{
boost::filesystem::path const cwd = boost::filesystem::current_path ();
diff --git a/src/signer_chain.h b/src/signer_chain.h
index 50f56ed9..034e2290 100644
--- a/src/signer_chain.h
+++ b/src/signer_chain.h
@@ -19,7 +19,7 @@
#include <boost/filesystem.hpp>
-namespace libdcp {
+namespace dcp {
/** Create a chain of certificates for signing things.
* @param directory Directory to write files to.
diff --git a/src/sound_frame.cc b/src/sound_frame.cc
index 6bc52c1a..06d2b88e 100644
--- a/src/sound_frame.cc
+++ b/src/sound_frame.cc
@@ -23,7 +23,7 @@
#include "exceptions.h"
using namespace std;
-using namespace libdcp;
+using namespace dcp;
SoundFrame::SoundFrame (string mxf_path, int n, ASDCP::AESDecContext* c)
{
diff --git a/src/sound_frame.h b/src/sound_frame.h
index 154ff84b..bc46b53a 100644
--- a/src/sound_frame.h
+++ b/src/sound_frame.h
@@ -30,7 +30,7 @@ namespace ASDCP {
class AESDecContext;
}
-namespace libdcp {
+namespace dcp {
class SoundFrame
{
diff --git a/src/sound_asset.cc b/src/sound_mxf.cc
index 95244b90..63f9ba05 100644
--- a/src/sound_asset.cc
+++ b/src/sound_mxf.cc
@@ -28,7 +28,7 @@
#include <libxml++/nodes/element.h>
#include "KM_fileio.h"
#include "AS_DCP.h"
-#include "sound_asset.h"
+#include "sound_mxf.h"
#include "util.h"
#include "exceptions.h"
#include "sound_frame.h"
@@ -40,29 +40,17 @@ using std::vector;
using std::list;
using boost::shared_ptr;
using boost::lexical_cast;
-using namespace libdcp;
+using namespace dcp;
-SoundAsset::SoundAsset (boost::filesystem::path directory, boost::filesystem::path mxf_name)
- : MXFAsset (directory, mxf_name)
+SoundMXF::SoundMXF (boost::filesystem::path file)
+ : MXF (file)
, _channels (0)
, _sampling_rate (0)
{
-
-}
-
-void
-SoundAsset::create (vector<boost::filesystem::path> const & files)
-{
- create (boost::bind (&SoundAsset::path_from_channel, this, _1, files));
-}
-
-void
-SoundAsset::read ()
-{
ASDCP::PCM::MXFReader reader;
- Kumu::Result_t r = reader.OpenRead (path().string().c_str());
+ Kumu::Result_t r = reader.OpenRead (file.string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file.string(), r));
}
ASDCP::PCM::AudioDescriptor desc;
@@ -77,155 +65,29 @@ SoundAsset::read ()
_intrinsic_duration = desc.ContainerDuration;
}
-boost::filesystem::path
-SoundAsset::path_from_channel (Channel channel, vector<boost::filesystem::path> const & files)
-{
- unsigned int const c = int (channel);
- assert (c < files.size ());
- return files[c];
-}
-
-void
-SoundAsset::create (boost::function<boost::filesystem::path (Channel)> get_path)
-{
- ASDCP::Rational asdcp_edit_rate (_edit_rate, 1);
-
- assert (_channels > 0);
- ASDCP::PCM::WAVParser* pcm_parser_channel[_channels];
- for (int i = 0; i < _channels; ++i) {
- pcm_parser_channel[i] = new ASDCP::PCM::WAVParser ();
- }
-
- Kumu::Result_t r = pcm_parser_channel[0]->OpenRead (get_path(LEFT).string().c_str(), asdcp_edit_rate);
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (FileError ("could not open WAV file for reading", get_path(LEFT), r));
- }
-
- ASDCP::PCM::AudioDescriptor audio_desc;
- pcm_parser_channel[0]->FillAudioDescriptor (audio_desc);
- audio_desc.ChannelCount = 0;
- audio_desc.BlockAlign = 0;
- audio_desc.EditRate = asdcp_edit_rate;
- audio_desc.AvgBps = audio_desc.AvgBps * _channels;
-
- Channel channels[] = {
- LEFT,
- RIGHT,
- CENTRE,
- LFE,
- LS,
- RS,
- /* XXX: not quite sure what these should be yet */
- CHANNEL_7,
- CHANNEL_8
- };
-
- assert (int(_channels) <= int(sizeof(channels) / sizeof(Channel)));
-
- ASDCP::PCM::FrameBuffer* frame_buffer_channel[_channels];
- ASDCP::PCM::AudioDescriptor* audio_desc_channel[_channels];
- for (int i = 0; i < _channels; ++i) {
- frame_buffer_channel[i] = new ASDCP::PCM::FrameBuffer ();
- audio_desc_channel[i] = new ASDCP::PCM::AudioDescriptor ();
- }
-
- for (int i = 0; i < _channels; ++i) {
-
- boost::filesystem::path const path = get_path (channels[i]);
-
- Kumu::Result_t r = pcm_parser_channel[i]->OpenRead (path.string().c_str(), asdcp_edit_rate);
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (FileError ("could not open WAV file for reading", path, r));
- }
-
- pcm_parser_channel[i]->FillAudioDescriptor (*audio_desc_channel[i]);
- frame_buffer_channel[i]->Capacity (ASDCP::PCM::CalcFrameBufferSize (*audio_desc_channel[i]));
-
- audio_desc.ChannelCount += audio_desc_channel[i]->ChannelCount;
- audio_desc.BlockAlign += audio_desc_channel[i]->BlockAlign;
- }
-
- ASDCP::PCM::FrameBuffer frame_buffer;
- frame_buffer.Capacity (ASDCP::PCM::CalcFrameBufferSize (audio_desc));
- frame_buffer.Size (ASDCP::PCM::CalcFrameBufferSize (audio_desc));
-
- ASDCP::WriterInfo writer_info;
- MXFAsset::fill_writer_info (&writer_info);
-
- ASDCP::PCM::MXFWriter mxf_writer;
- r = mxf_writer.OpenWrite (path().string().c_str(), writer_info, audio_desc);
- if (ASDCP_FAILURE (r)) {
- boost::throw_exception (FileError ("could not open audio MXF for writing", path().string(), r));
- }
-
- for (int i = 0; i < _intrinsic_duration; ++i) {
-
- for (int j = 0; j < _channels; ++j) {
- memset (frame_buffer_channel[j]->Data(), 0, frame_buffer_channel[j]->Capacity());
- if (ASDCP_FAILURE (pcm_parser_channel[j]->ReadFrame (*frame_buffer_channel[j]))) {
- boost::throw_exception (MiscError ("could not read audio frame"));
- }
- }
-
- byte_t *data_s = frame_buffer.Data();
- byte_t *data_e = data_s + frame_buffer.Capacity();
- byte_t sample_size = ASDCP::PCM::CalcSampleSize (*audio_desc_channel[0]);
- int offset = 0;
-
- while (data_s < data_e) {
- for (int j = 0; j < _channels; ++j) {
- byte_t* frame = frame_buffer_channel[j]->Data() + offset;
- memcpy (data_s, frame, sample_size);
- data_s += sample_size;
- }
- offset += sample_size;
- }
-
- if (ASDCP_FAILURE (mxf_writer.WriteFrame (frame_buffer, _encryption_context, 0))) {
- boost::throw_exception (MiscError ("could not write audio MXF frame"));
- }
-
- if (_progress) {
- (*_progress) (0.5 * float (i) / _intrinsic_duration);
- }
- }
-
- bool const failed = ASDCP_FAILURE (mxf_writer.Finalize());
-
- for (int i = 0; i < _channels; ++i) {
- delete pcm_parser_channel[i];
- delete frame_buffer_channel[i];
- delete audio_desc_channel[i];
- }
-
- if (failed) {
- boost::throw_exception (MiscError ("could not finalise audio MXF"));
- }
-}
-
string
-SoundAsset::cpl_node_name () const
+SoundMXF::cpl_node_name () const
{
return "MainSound";
}
bool
-SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
+SoundMXF::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
{
- if (!MXFAsset::equals (other, opt, note)) {
+ if (!MXF::equals (other, opt, note)) {
return false;
}
ASDCP::PCM::MXFReader reader_A;
- Kumu::Result_t r = reader_A.OpenRead (path().string().c_str());
+ Kumu::Result_t r = reader_A.OpenRead (file().string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file().string(), r));
}
ASDCP::PCM::MXFReader reader_B;
- r = reader_B.OpenRead (other->path().string().c_str());
+ r = reader_B.OpenRead (other->file().string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file().string(), r));
}
ASDCP::PCM::AudioDescriptor desc_A;
@@ -286,20 +148,20 @@ SoundAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::f
}
shared_ptr<const SoundFrame>
-SoundAsset::get_frame (int n) const
+SoundMXF::get_frame (int n) const
{
/* XXX: should add on entry point here? */
- return shared_ptr<const SoundFrame> (new SoundFrame (path().string(), n, _decryption_context));
+ return shared_ptr<const SoundFrame> (new SoundFrame (file().string(), n, _decryption_context));
}
-shared_ptr<SoundAssetWriter>
-SoundAsset::start_write ()
+shared_ptr<SoundMXFWriter>
+SoundMXF::start_write ()
{
/* XXX: can't we use a shared_ptr here? */
- return shared_ptr<SoundAssetWriter> (new SoundAssetWriter (this));
+ return shared_ptr<SoundMXFWriter> (new SoundMXFWriter (this));
}
-struct SoundAssetWriter::ASDCPState
+struct SoundMXFWriter::ASDCPState
{
ASDCP::PCM::MXFWriter mxf_writer;
ASDCP::PCM::FrameBuffer frame_buffer;
@@ -308,8 +170,8 @@ struct SoundAssetWriter::ASDCPState
ASDCP::AESEncContext* encryption_context;
};
-SoundAssetWriter::SoundAssetWriter (SoundAsset* a)
- : _state (new SoundAssetWriter::ASDCPState)
+SoundMXFWriter::SoundMXFWriter (SoundMXF* a)
+ : _state (new SoundMXFWriter::ASDCPState)
, _asset (a)
, _finalized (false)
, _frames_written (0)
@@ -334,14 +196,14 @@ SoundAssetWriter::SoundAssetWriter (SoundAsset* a)
_asset->fill_writer_info (&_state->writer_info);
- Kumu::Result_t r = _state->mxf_writer.OpenWrite (_asset->path().string().c_str(), _state->writer_info, _state->audio_desc);
+ Kumu::Result_t r = _state->mxf_writer.OpenWrite (_asset->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", _asset->path().string(), r));
+ boost::throw_exception (FileError ("could not open audio MXF for writing", _asset->file().string(), r));
}
}
void
-SoundAssetWriter::write (float const * const * data, int frames)
+SoundMXFWriter::write (float const * const * data, int frames)
{
for (int i = 0; i < frames; ++i) {
@@ -368,7 +230,7 @@ SoundAssetWriter::write (float const * const * data, int frames)
}
void
-SoundAssetWriter::write_current_frame ()
+SoundMXFWriter::write_current_frame ()
{
ASDCP::Result_t const r = _state->mxf_writer.WriteFrame (_state->frame_buffer, _state->encryption_context, 0);
if (ASDCP_FAILURE (r)) {
@@ -379,7 +241,7 @@ SoundAssetWriter::write_current_frame ()
}
void
-SoundAssetWriter::finalize ()
+SoundMXFWriter::finalize ()
{
if (_frame_buffer_offset > 0) {
write_current_frame ();
@@ -395,7 +257,7 @@ SoundAssetWriter::finalize ()
}
string
-SoundAsset::key_type () const
+SoundMXF::key_type () const
{
return "MDAK";
}
diff --git a/src/sound_asset.h b/src/sound_mxf.h
index d2e49bd1..4216accb 100644
--- a/src/sound_asset.h
+++ b/src/sound_mxf.h
@@ -24,30 +24,30 @@
* @brief An asset made up of PCM audio data files
*/
-#include "mxf_asset.h"
+#include "mxf.h"
#include "types.h"
#include "metadata.h"
-namespace libdcp
+namespace dcp
{
class SoundFrame;
-class SoundAsset;
+class SoundMXF;
-class SoundAssetWriter
+class SoundMXFWriter
{
public:
void write (float const * const *, int);
void finalize ();
private:
- friend class SoundAsset;
+ friend class SoundMXF;
- SoundAssetWriter (SoundAsset *);
+ SoundMXFWriter (SoundMXF *);
/* no copy construction */
- SoundAssetWriter (SoundAssetWriter const &);
- SoundAssetWriter& operator= (SoundAssetWriter const &);
+ SoundMXFWriter (SoundMXFWriter const &);
+ SoundMXFWriter& operator= (SoundMXFWriter const &);
void write_current_frame ();
@@ -58,41 +58,21 @@ private:
struct ASDCPState;
boost::shared_ptr<ASDCPState> _state;
- SoundAsset* _asset;
+ SoundMXF* _asset;
bool _finalized;
int _frames_written;
int _frame_buffer_offset;
};
/** @brief An asset made up of WAV files */
-class SoundAsset : public MXFAsset
+class SoundMXF : public MXF
{
public:
- SoundAsset (boost::filesystem::path directory, boost::filesystem::path mxf_name);
-
- void read ();
-
- /** The following parameters must be set up (if required) before calling this:
- * Interop mode (set_interop)
- * Edit rate (set_edit_rate)
- * MXF Metadata (set_metadata)
- * Channels (set_channels)
- * Intrinsic duration (set_intrinsic_duration)
- */
- void create (std::vector<boost::filesystem::path> const & files);
-
- /** The following parameters must be set up (if required) before calling this:
- * Interop mode (set_interop)
- * Edit rate (set_edit_rate)
- * MXF Metadata (set_metadata)
- * Channels (set_channels)
- * Intrinsic duration (set_intrinsic_duration)
- */
- void create (boost::function<boost::filesystem::path (Channel)> get_path);
-
- boost::shared_ptr<SoundAssetWriter> start_write ();
+ SoundMXF (boost::filesystem::path file);
+
+ boost::shared_ptr<SoundMXFWriter> start_write ();
- bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
+ bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
boost::shared_ptr<const SoundFrame> get_frame (int n) const;
@@ -114,8 +94,6 @@ public:
private:
std::string key_type () const;
- void construct (boost::function<boost::filesystem::path (Channel)> get_path);
- boost::filesystem::path path_from_channel (Channel channel, std::vector<boost::filesystem::path> const & files);
std::string cpl_node_name () const;
/** Number of channels in the asset */
diff --git a/src/srgb_linearised_gamma_lut.cc b/src/srgb_linearised_gamma_lut.cc
index 0d3650f4..bab36cb1 100644
--- a/src/srgb_linearised_gamma_lut.cc
+++ b/src/srgb_linearised_gamma_lut.cc
@@ -19,7 +19,7 @@
#include "srgb_linearised_gamma_lut.h"
-using namespace libdcp;
+using namespace dcp;
LUTCache<SRGBLinearisedGammaLUT> SRGBLinearisedGammaLUT::cache;
diff --git a/src/srgb_linearised_gamma_lut.h b/src/srgb_linearised_gamma_lut.h
index 34800c66..68030610 100644
--- a/src/srgb_linearised_gamma_lut.h
+++ b/src/srgb_linearised_gamma_lut.h
@@ -20,7 +20,7 @@
#include "lut.h"
#include "lut_cache.h"
-namespace libdcp {
+namespace dcp {
class SRGBLinearisedGammaLUT : public LUT
{
diff --git a/src/stereo_picture_frame.cc b/src/stereo_picture_frame.cc
index dce1f106..893a9f72 100644
--- a/src/stereo_picture_frame.cc
+++ b/src/stereo_picture_frame.cc
@@ -32,7 +32,7 @@
using std::string;
using boost::shared_ptr;
-using namespace libdcp;
+using namespace dcp;
/** Make a picture frame from a 3D (stereoscopic) asset.
* @param mxf_path Path to the asset's MXF file.
@@ -59,12 +59,11 @@ StereoPictureFrame::~StereoPictureFrame ()
delete _buffer;
}
-/** @param reduce a factor by which to reduce the resolution
+/** @param eye Eye to return (EYE_LEFT or EYE_RIGHT).
+ * @param reduce a factor by which to reduce the resolution
* of the image, expressed as a power of two (pass 0 for no
* reduction).
*
- * @param eye Eye to return (EYE_LEFT or EYE_RIGHT).
- *
* @return An ARGB representation of one of the eyes (left or right)
* of this frame. This is ARGB in the Cairo sense, so that each
* pixel takes up 4 bytes; the first byte is blue, second green,
diff --git a/src/stereo_picture_frame.h b/src/stereo_picture_frame.h
index ab99ceac..40c2a441 100644
--- a/src/stereo_picture_frame.h
+++ b/src/stereo_picture_frame.h
@@ -29,7 +29,7 @@ namespace ASDCP {
class AESDecContext;
}
-namespace libdcp {
+namespace dcp {
class ARGBFrame;
diff --git a/src/stereo_picture_asset.cc b/src/stereo_picture_mxf.cc
index 47a41cc2..7e112687 100644
--- a/src/stereo_picture_asset.cc
+++ b/src/stereo_picture_mxf.cc
@@ -18,35 +18,35 @@
*/
#include "AS_DCP.h"
-#include "stereo_picture_asset.h"
+#include "stereo_picture_mxf.h"
#include "stereo_picture_frame.h"
#include "exceptions.h"
-#include "stereo_picture_asset_writer.h"
+#include "stereo_picture_mxf_writer.h"
using std::string;
using std::pair;
using std::make_pair;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
-using namespace libdcp;
+using namespace dcp;
bool
-StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
+StereoPictureMXF::equals (shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, string)> note) const
{
- if (!MXFAsset::equals (other, opt, note)) {
+ if (!MXF::equals (other, opt, note)) {
return false;
}
ASDCP::JP2K::MXFSReader reader_A;
- Kumu::Result_t r = reader_A.OpenRead (path().string().c_str());
+ Kumu::Result_t r = reader_A.OpenRead (file().string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file().string(), r));
}
ASDCP::JP2K::MXFSReader reader_B;
- r = reader_B.OpenRead (other->path().string().c_str());
+ r = reader_B.OpenRead (other->file().string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file().string(), r));
}
ASDCP::JP2K::PictureDescriptor desc_A;
@@ -62,7 +62,7 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt,
return false;
}
- shared_ptr<const StereoPictureAsset> other_picture = dynamic_pointer_cast<const StereoPictureAsset> (other);
+ shared_ptr<const StereoPictureMXF> other_picture = dynamic_pointer_cast<const StereoPictureMXF> (other);
assert (other_picture);
for (int i = 0; i < _intrinsic_duration; ++i) {
@@ -89,19 +89,13 @@ StereoPictureAsset::equals (shared_ptr<const Asset> other, EqualityOptions opt,
return true;
}
-StereoPictureAsset::StereoPictureAsset (boost::filesystem::path directory, boost::filesystem::path mxf_name)
- : PictureAsset (directory, mxf_name)
-{
-
-}
-
-void
-StereoPictureAsset::read ()
+StereoPictureMXF::StereoPictureMXF (boost::filesystem::path file)
+ : PictureMXF (file)
{
ASDCP::JP2K::MXFSReader reader;
- Kumu::Result_t r = reader.OpenRead (path().string().c_str());
+ Kumu::Result_t r = reader.OpenRead (file.string().c_str());
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("could not open MXF file for reading", path().string(), r));
+ boost::throw_exception (MXFFileError ("could not open MXF file for reading", file.string(), r));
}
ASDCP::JP2K::PictureDescriptor desc;
@@ -114,25 +108,25 @@ StereoPictureAsset::read ()
}
shared_ptr<const StereoPictureFrame>
-StereoPictureAsset::get_frame (int n) const
+StereoPictureMXF::get_frame (int n) const
{
- return shared_ptr<const StereoPictureFrame> (new StereoPictureFrame (path().string(), n));
+ return shared_ptr<const StereoPictureFrame> (new StereoPictureFrame (file().string(), n));
}
-shared_ptr<PictureAssetWriter>
-StereoPictureAsset::start_write (bool overwrite)
+shared_ptr<PictureMXFWriter>
+StereoPictureMXF::start_write (boost::filesystem::path file, bool overwrite)
{
- return shared_ptr<StereoPictureAssetWriter> (new StereoPictureAssetWriter (this, overwrite));
+ return shared_ptr<StereoPictureMXFWriter> (new StereoPictureMXFWriter (this, file, overwrite));
}
string
-StereoPictureAsset::cpl_node_name () const
+StereoPictureMXF::cpl_node_name () const
{
return "msp-cpl:MainStereoscopicPicture";
}
pair<string, string>
-StereoPictureAsset::cpl_node_attribute () const
+StereoPictureMXF::cpl_node_attribute () const
{
if (_interop) {
return make_pair ("xmlns:msp-cpl", "http://www.digicine.com/schemas/437-Y/2007/Main-Stereo-Picture-CPL");
@@ -144,7 +138,7 @@ StereoPictureAsset::cpl_node_attribute () const
}
int
-StereoPictureAsset::edit_rate_factor () const
+StereoPictureMXF::edit_rate_factor () const
{
return 2;
}
diff --git a/src/stereo_picture_asset.h b/src/stereo_picture_mxf.h
index 64cdb6b3..4af8a327 100644
--- a/src/stereo_picture_asset.h
+++ b/src/stereo_picture_mxf.h
@@ -17,26 +17,24 @@
*/
-#ifndef LIBDCP_STEREO_PICTURE_ASSET_H
-#define LIBDCP_STEREO_PICTURE_ASSET_H
+#ifndef LIBDCP_STEREO_PICTURE_MXF_H
+#define LIBDCP_STEREO_PICTURE_MXF_H
-#include "picture_asset.h"
+#include "picture_mxf.h"
-namespace libdcp {
+namespace dcp {
/** A 3D (stereoscopic) picture asset */
-class StereoPictureAsset : public PictureAsset
+class StereoPictureMXF : public PictureMXF
{
public:
- StereoPictureAsset (boost::filesystem::path directory, boost::filesystem::path mxf_name);
+ StereoPictureMXF (boost::filesystem::path file);
- void read ();
-
- /** Start a progressive write to a StereoPictureAsset */
- boost::shared_ptr<PictureAssetWriter> start_write (bool);
+ /** Start a progressive write to a StereoPictureMXF */
+ boost::shared_ptr<PictureMXFWriter> start_write (boost::filesystem::path file, bool);
boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
- bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
+ bool equals (boost::shared_ptr<const Content> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
private:
std::string cpl_node_name () const;
diff --git a/src/stereo_picture_asset_writer.cc b/src/stereo_picture_mxf_writer.cc
index b4b0ad52..ad029b57 100644
--- a/src/stereo_picture_asset_writer.cc
+++ b/src/stereo_picture_mxf_writer.cc
@@ -19,35 +19,35 @@
#include "AS_DCP.h"
#include "KM_fileio.h"
-#include "stereo_picture_asset_writer.h"
+#include "stereo_picture_mxf_writer.h"
#include "exceptions.h"
-#include "picture_asset.h"
+#include "picture_mxf.h"
-#include "picture_asset_writer_common.cc"
+#include "picture_mxf_writer_common.cc"
using std::istream;
using std::ostream;
using std::string;
using boost::shared_ptr;
-using namespace libdcp;
+using namespace dcp;
-struct StereoPictureAssetWriter::ASDCPState : public ASDCPStateBase
+struct StereoPictureMXFWriter::ASDCPState : public ASDCPStateBase
{
ASDCP::JP2K::MXFSWriter mxf_writer;
};
-StereoPictureAssetWriter::StereoPictureAssetWriter (PictureAsset* asset, bool overwrite)
- : PictureAssetWriter (asset, overwrite)
- , _state (new StereoPictureAssetWriter::ASDCPState)
+StereoPictureMXFWriter::StereoPictureMXFWriter (PictureMXF* mxf, boost::filesystem::path file, bool overwrite)
+ : PictureMXFWriter (mxf, file, overwrite)
+ , _state (new StereoPictureMXFWriter::ASDCPState)
, _next_eye (EYE_LEFT)
{
- _state->encryption_context = asset->encryption_context ();
+ _state->encryption_context = mxf->encryption_context ();
}
void
-StereoPictureAssetWriter::start (uint8_t* data, int size)
+StereoPictureMXFWriter::start (uint8_t* data, int size)
{
- libdcp::start (this, _state, _asset, data, size);
+ dcp::start (this, _state, _mxf, data, size);
}
/** Write a frame for one eye. Frames must be written left, then right, then left etc.
@@ -55,7 +55,7 @@ StereoPictureAssetWriter::start (uint8_t* data, int size)
* @param size Size of data.
*/
FrameInfo
-StereoPictureAssetWriter::write (uint8_t* data, int size)
+StereoPictureMXFWriter::write (uint8_t* data, int size)
{
assert (!_finalized);
@@ -79,7 +79,7 @@ StereoPictureAssetWriter::write (uint8_t* data, int size)
);
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in writing video MXF", _asset->path().string(), r));
+ boost::throw_exception (MXFFileError ("error in writing video MXF", _mxf->file().string(), r));
}
_next_eye = _next_eye == EYE_LEFT ? EYE_RIGHT : EYE_LEFT;
@@ -89,14 +89,14 @@ StereoPictureAssetWriter::write (uint8_t* data, int size)
}
void
-StereoPictureAssetWriter::fake_write (int size)
+StereoPictureMXFWriter::fake_write (int size)
{
assert (_started);
assert (!_finalized);
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", _asset->path().string(), r));
+ boost::throw_exception (MXFFileError ("error in writing video MXF", _mxf->file().string(), r));
}
_next_eye = _next_eye == EYE_LEFT ? EYE_RIGHT : EYE_LEFT;
@@ -104,16 +104,16 @@ StereoPictureAssetWriter::fake_write (int size)
}
void
-StereoPictureAssetWriter::finalize ()
+StereoPictureMXFWriter::finalize ()
{
assert (!_finalized);
Kumu::Result_t r = _state->mxf_writer.Finalize();
if (ASDCP_FAILURE (r)) {
- boost::throw_exception (MXFFileError ("error in finalizing video MXF", _asset->path().string(), r));
+ boost::throw_exception (MXFFileError ("error in finalizing video MXF", _mxf->file().string(), r));
}
_finalized = true;
- _asset->set_intrinsic_duration (_frames_written / 2);
- _asset->set_duration (_frames_written / 2);
+ _mxf->set_intrinsic_duration (_frames_written / 2);
+ _mxf->set_duration (_frames_written / 2);
}
diff --git a/src/stereo_picture_asset_writer.h b/src/stereo_picture_mxf_writer.h
index 771524c4..a34af069 100644
--- a/src/stereo_picture_asset_writer.h
+++ b/src/stereo_picture_mxf_writer.h
@@ -22,9 +22,9 @@
#include <fstream>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
-#include "picture_asset_writer.h"
+#include "picture_mxf_writer.h"
-namespace libdcp {
+namespace dcp {
/** A helper class for writing to StereoPictureAssets progressively (i.e. writing frame-by-frame,
* rather than giving libdcp all the frames in one go).
@@ -36,7 +36,7 @@ namespace libdcp {
* The action of finalize() can't be done in MonoPictureAssetWriter's destructor as it may
* throw an exception.
*/
-class StereoPictureAssetWriter : public PictureAssetWriter
+class StereoPictureMXFWriter : public PictureMXFWriter
{
public:
FrameInfo write (uint8_t *, int);
@@ -44,9 +44,9 @@ public:
void finalize ();
private:
- friend class StereoPictureAsset;
+ friend class StereoPictureMXF;
- StereoPictureAssetWriter (PictureAsset *, bool);
+ StereoPictureMXFWriter (PictureMXF *, boost::filesystem::path file, bool);
void start (uint8_t *, int);
/* do this with an opaque pointer so we don't have to include
@@ -56,7 +56,7 @@ private:
struct ASDCPState;
boost::shared_ptr<ASDCPState> _state;
- libdcp::Eye _next_eye;
+ dcp::Eye _next_eye;
};
}
diff --git a/src/subtitle_asset.cc b/src/subtitle_asset.cc
index a48a614d..1c36fdfc 100644
--- a/src/subtitle_asset.cc
+++ b/src/subtitle_asset.cc
@@ -34,40 +34,24 @@ using std::stringstream;
using boost::shared_ptr;
using boost::lexical_cast;
using boost::optional;
-using namespace libdcp;
+using namespace dcp;
-SubtitleAsset::SubtitleAsset (string directory, string xml_file)
- : Asset (directory, xml_file)
+SubtitleAsset::SubtitleAsset (boost::filesystem::path file)
+ : Content (file)
, _need_sort (false)
{
- read_xml (path().string());
-}
-
-SubtitleAsset::SubtitleAsset (string directory, string movie_title, string language)
- : Asset (directory)
- , _movie_title (movie_title)
- , _reel_number ("1")
- , _language (language)
- , _need_sort (false)
-{
-
-}
-
-void
-SubtitleAsset::read_xml (string xml_file)
-{
shared_ptr<cxml::Document> xml (new cxml::Document ("DCSubtitle"));
- xml->read_file (xml_file);
+ xml->read_file (file);
- _uuid = xml->string_child ("SubtitleID");
+ _id = xml->string_child ("SubtitleID");
_movie_title = xml->string_child ("MovieTitle");
_reel_number = xml->string_child ("ReelNumber");
_language = xml->string_child ("Language");
xml->ignore_child ("LoadFont");
- list<shared_ptr<libdcp::parse::Font> > font_nodes = type_children<libdcp::parse::Font> (xml, "Font");
- _load_font_nodes = type_children<libdcp::parse::LoadFont> (xml, "LoadFont");
+ list<shared_ptr<dcp::parse::Font> > font_nodes = type_children<dcp::parse::Font> (xml, "Font");
+ _load_font_nodes = type_children<dcp::parse::LoadFont> (xml, "LoadFont");
/* Now make Subtitle objects to represent the raw XML nodes
in a sane way.
@@ -77,19 +61,29 @@ SubtitleAsset::read_xml (string xml_file)
examine_font_nodes (xml, font_nodes, parse_state);
}
+SubtitleAsset::SubtitleAsset (string directory, string movie_title, string language)
+ : Content (directory)
+ , _movie_title (movie_title)
+ , _reel_number ("1")
+ , _language (language)
+ , _need_sort (false)
+{
+
+}
+
void
SubtitleAsset::examine_font_nodes (
shared_ptr<const cxml::Node> xml,
- list<shared_ptr<libdcp::parse::Font> > const & font_nodes,
+ list<shared_ptr<dcp::parse::Font> > const & font_nodes,
ParseState& parse_state
)
{
- for (list<shared_ptr<libdcp::parse::Font> >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) {
+ for (list<shared_ptr<dcp::parse::Font> >::const_iterator i = font_nodes.begin(); i != font_nodes.end(); ++i) {
parse_state.font_nodes.push_back (*i);
maybe_add_subtitle ((*i)->text, parse_state);
- for (list<shared_ptr<libdcp::parse::Subtitle> >::iterator j = (*i)->subtitle_nodes.begin(); j != (*i)->subtitle_nodes.end(); ++j) {
+ for (list<shared_ptr<dcp::parse::Subtitle> >::iterator j = (*i)->subtitle_nodes.begin(); j != (*i)->subtitle_nodes.end(); ++j) {
parse_state.subtitle_nodes.push_back (*j);
examine_text_nodes (xml, (*j)->text_nodes, parse_state);
examine_font_nodes (xml, (*j)->font_nodes, parse_state);
@@ -106,11 +100,11 @@ SubtitleAsset::examine_font_nodes (
void
SubtitleAsset::examine_text_nodes (
shared_ptr<const cxml::Node> xml,
- list<shared_ptr<libdcp::parse::Text> > const & text_nodes,
+ list<shared_ptr<dcp::parse::Text> > const & text_nodes,
ParseState& parse_state
)
{
- for (list<shared_ptr<libdcp::parse::Text> >::const_iterator i = text_nodes.begin(); i != text_nodes.end(); ++i) {
+ for (list<shared_ptr<dcp::parse::Text> >::const_iterator i = text_nodes.begin(); i != text_nodes.end(); ++i) {
parse_state.text_nodes.push_back (*i);
maybe_add_subtitle ((*i)->text, parse_state);
examine_font_nodes (xml, (*i)->font_nodes, parse_state);
@@ -132,9 +126,9 @@ SubtitleAsset::maybe_add_subtitle (string text, ParseState const & parse_state)
assert (!parse_state.text_nodes.empty ());
assert (!parse_state.subtitle_nodes.empty ());
- libdcp::parse::Font effective_font (parse_state.font_nodes);
- libdcp::parse::Text effective_text (*parse_state.text_nodes.back ());
- libdcp::parse::Subtitle effective_subtitle (*parse_state.subtitle_nodes.back ());
+ dcp::parse::Font effective_font (parse_state.font_nodes);
+ dcp::parse::Text effective_text (*parse_state.text_nodes.back ());
+ dcp::parse::Subtitle effective_subtitle (*parse_state.subtitle_nodes.back ());
_subtitles.push_back (
shared_ptr<Subtitle> (
@@ -173,7 +167,7 @@ SubtitleAsset::subtitles_at (Time t) const
std::string
SubtitleAsset::font_id_to_name (string id) const
{
- list<shared_ptr<libdcp::parse::LoadFont> >::const_iterator i = _load_font_nodes.begin();
+ list<shared_ptr<dcp::parse::LoadFont> >::const_iterator i = _load_font_nodes.begin();
while (i != _load_font_nodes.end() && (*i)->id != id) {
++i;
}
@@ -233,7 +227,7 @@ Subtitle::size_in_pixels (int screen_height) const
}
bool
-libdcp::operator== (Subtitle const & a, Subtitle const & b)
+dcp::operator== (Subtitle const & a, Subtitle const & b)
{
return (
a.font() == b.font() &&
@@ -253,7 +247,7 @@ libdcp::operator== (Subtitle const & a, Subtitle const & b)
}
ostream&
-libdcp::operator<< (ostream& s, Subtitle const & sub)
+dcp::operator<< (ostream& s, Subtitle const & sub)
{
s << "\n`" << sub.text() << "' from " << sub.in() << " to " << sub.out() << ";\n"
<< "fade up " << sub.fade_up_time() << ", fade down " << sub.fade_down_time() << ";\n"
@@ -284,8 +278,8 @@ SubtitleAsset::write_to_cpl (xmlpp::Element* node) const
/* XXX: should EditRate, Duration and IntrinsicDuration be in here? */
xmlpp::Node* ms = node->add_child ("MainSubtitle");
- ms->add_child("Id")->add_child_text("urn:uuid:" + _uuid);
- ms->add_child("AnnotationText")->add_child_text (_file_name.string ());
+ ms->add_child("Id")->add_child_text("urn:uuid:" + _id);
+ ms->add_child("AnnotationText")->add_child_text (_file.string ());
/* XXX */
ms->add_child("EntryPoint")->add_child_text ("0");
}
@@ -302,7 +296,7 @@ struct SubtitleSorter {
void
SubtitleAsset::write_xml () const
{
- FILE* f = fopen_boost (path (), "r");
+ FILE* f = fopen_boost (file (), "r");
Glib::ustring const s = xml_as_string ();
fwrite (s.c_str(), 1, s.length(), f);
fclose (f);
@@ -315,7 +309,7 @@ SubtitleAsset::xml_as_string () const
xmlpp::Element* root = doc.create_root_node ("DCSubtitle");
root->set_attribute ("Version", "1.0");
- root->add_child("SubtitleID")->add_child_text (_uuid);
+ root->add_child("SubtitleID")->add_child_text (_id);
root->add_child("MovieTitle")->add_child_text (_movie_title);
root->add_child("ReelNumber")->add_child_text (lexical_cast<string> (_reel_number));
root->add_child("Language")->add_child_text (_language);
diff --git a/src/subtitle_asset.h b/src/subtitle_asset.h
index 74ab9873..cbd3ad58 100644
--- a/src/subtitle_asset.h
+++ b/src/subtitle_asset.h
@@ -21,10 +21,10 @@
#define LIBDCP_SUBTITLE_ASSET_H
#include <libcxml/cxml.h>
-#include "asset.h"
+#include "content.h"
#include "dcp_time.h"
-namespace libdcp
+namespace dcp
{
namespace parse
@@ -133,14 +133,14 @@ private:
bool operator== (Subtitle const & a, Subtitle const & b);
std::ostream& operator<< (std::ostream& s, Subtitle const & sub);
-class SubtitleAsset : public Asset
+class SubtitleAsset : public Content
{
public:
- SubtitleAsset (std::string directory, std::string xml_file);
+ SubtitleAsset (boost::filesystem::path file);
SubtitleAsset (std::string directory, std::string movie_title, std::string language);
void write_to_cpl (xmlpp::Element *) const;
- virtual bool equals (boost::shared_ptr<const Asset>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const {
+ virtual bool equals (boost::shared_ptr<const Content>, EqualityOptions, boost::function<void (NoteType, std::string)> note) const {
/* XXX */
note (ERROR, "subtitle assets not compared yet");
return true;
@@ -157,7 +157,6 @@ public:
void add (boost::shared_ptr<Subtitle>);
- void read_xml (std::string);
void write_xml () const;
Glib::ustring xml_as_string () const;
diff --git a/src/types.cc b/src/types.cc
index 693b9ab2..113fc85f 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -7,7 +7,7 @@
#include "exceptions.h"
using namespace std;
-using namespace libdcp;
+using namespace dcp;
using namespace boost;
Fraction::Fraction (string s)
@@ -22,13 +22,13 @@ Fraction::Fraction (string s)
}
bool
-libdcp::operator== (Fraction const & a, Fraction const & b)
+dcp::operator== (Fraction const & a, Fraction const & b)
{
return (a.numerator == b.numerator && a.denominator == b.denominator);
}
bool
-libdcp::operator!= (Fraction const & a, Fraction const & b)
+dcp::operator!= (Fraction const & a, Fraction const & b)
{
return (a.numerator != b.numerator || a.denominator != b.denominator);
}
@@ -84,7 +84,7 @@ Color::to_argb_string () const
* @param b Second color to compare.
*/
bool
-libdcp::operator== (Color const & a, Color const & b)
+dcp::operator== (Color const & a, Color const & b)
{
return (a.r == b.r && a.g == b.g && a.b == b.b);
}
@@ -94,20 +94,20 @@ libdcp::operator== (Color const & a, Color const & b)
* @param b Second color to compare.
*/
bool
-libdcp::operator!= (Color const & a, Color const & b)
+dcp::operator!= (Color const & a, Color const & b)
{
return !(a == b);
}
ostream &
-libdcp::operator<< (ostream& s, Color const & c)
+dcp::operator<< (ostream& s, Color const & c)
{
s << "(" << c.r << ", " << c.g << ", " << c.b << ")";
return s;
}
string
-libdcp::effect_to_string (Effect e)
+dcp::effect_to_string (Effect e)
{
switch (e) {
case NONE:
@@ -122,7 +122,7 @@ libdcp::effect_to_string (Effect e)
}
Effect
-libdcp::string_to_effect (string s)
+dcp::string_to_effect (string s)
{
if (s == "none") {
return NONE;
@@ -136,7 +136,7 @@ libdcp::string_to_effect (string s)
}
string
-libdcp::valign_to_string (VAlign v)
+dcp::valign_to_string (VAlign v)
{
switch (v) {
case TOP:
@@ -151,7 +151,7 @@ libdcp::valign_to_string (VAlign v)
}
VAlign
-libdcp::string_to_valign (string s)
+dcp::string_to_valign (string s)
{
if (s == "top") {
return TOP;
diff --git a/src/types.h b/src/types.h
index 013c1863..021d1ecf 100644
--- a/src/types.h
+++ b/src/types.h
@@ -27,7 +27,7 @@
#include <string>
#include <boost/shared_ptr.hpp>
-namespace libdcp
+namespace dcp
{
namespace parse {
diff --git a/src/util.cc b/src/util.cc
index a668b7fc..3807b4cc 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -56,13 +56,13 @@ using std::setw;
using std::setfill;
using boost::shared_ptr;
using boost::lexical_cast;
-using namespace libdcp;
+using namespace dcp;
/** Create a UUID.
* @return UUID.
*/
string
-libdcp::make_uuid ()
+dcp::make_uuid ()
{
char buffer[64];
Kumu::UUID id;
@@ -79,7 +79,7 @@ libdcp::make_uuid ()
* @return Digest.
*/
string
-libdcp::make_digest (string filename, boost::function<void (float)>* progress)
+dcp::make_digest (string filename, boost::function<void (float)>* progress)
{
Kumu::FileReader reader;
Kumu::Result_t r = reader.OpenRead (filename.c_str ());
@@ -126,7 +126,7 @@ libdcp::make_digest (string filename, boost::function<void (float)>* progress)
* @return string.
*/
string
-libdcp::content_kind_to_string (ContentKind kind)
+dcp::content_kind_to_string (ContentKind kind)
{
switch (kind) {
case FEATURE:
@@ -159,8 +159,8 @@ libdcp::content_kind_to_string (ContentKind kind)
* @param type Content kind string.
* @return libdcp ContentKind.
*/
-libdcp::ContentKind
-libdcp::content_kind_from_string (string type)
+dcp::ContentKind
+dcp::content_kind_from_string (string type)
{
transform (type.begin(), type.end(), type.begin(), ::tolower);
@@ -198,8 +198,8 @@ libdcp::content_kind_from_string (string type)
* This is useful for scaling 4K DCP images down to 2K.
* @return XYZ image.
*/
-shared_ptr<libdcp::XYZFrame>
-libdcp::decompress_j2k (uint8_t* data, int64_t size, int reduce)
+shared_ptr<dcp::XYZFrame>
+dcp::decompress_j2k (uint8_t* data, int64_t size, int reduce)
{
opj_dinfo_t* decoder = opj_create_decompress (CODEC_J2K);
opj_dparameters_t parameters;
@@ -226,7 +226,7 @@ libdcp::decompress_j2k (uint8_t* data, int64_t size, int reduce)
* @return true if the string contains only space, newline or tab characters, or is empty.
*/
bool
-libdcp::empty_or_white_space (string s)
+dcp::empty_or_white_space (string s)
{
for (size_t i = 0; i < s.length(); ++i) {
if (s[i] != ' ' && s[i] != '\n' && s[i] != '\t') {
@@ -238,7 +238,7 @@ libdcp::empty_or_white_space (string s)
}
void
-libdcp::init ()
+dcp::init ()
{
if (xmlSecInit() < 0) {
throw MiscError ("could not initialise xmlsec");
@@ -259,12 +259,12 @@ libdcp::init ()
}
}
-bool libdcp::operator== (libdcp::Size const & a, libdcp::Size const & b)
+bool dcp::operator== (dcp::Size const & a, dcp::Size const & b)
{
return (a.width == b.width && a.height == b.height);
}
-bool libdcp::operator!= (libdcp::Size const & a, libdcp::Size const & b)
+bool dcp::operator!= (dcp::Size const & a, dcp::Size const & b)
{
return !(a == b);
}
@@ -273,7 +273,7 @@ bool libdcp::operator!= (libdcp::Size const & a, libdcp::Size const & b)
* this and the command-line base64 for some inputs. Not sure why.
*/
int
-libdcp::base64_decode (string const & in, unsigned char* out, int out_length)
+dcp::base64_decode (string const & in, unsigned char* out, int out_length)
{
BIO* b64 = BIO_new (BIO_f_base64 ());
@@ -298,7 +298,7 @@ libdcp::base64_decode (string const & in, unsigned char* out, int out_length)
}
string
-libdcp::tm_to_string (struct tm* tm)
+dcp::tm_to_string (struct tm* tm)
{
char buffer[64];
strftime (buffer, 64, "%Y-%m-%dT%H:%M:%S", tm);
@@ -320,7 +320,7 @@ libdcp::tm_to_string (struct tm* tm)
* @return string of the form e.g. -01:00.
*/
string
-libdcp::utc_offset_to_string (int b)
+dcp::utc_offset_to_string (int b)
{
bool const negative = (b < 0);
b = negative ? -b : b;
@@ -340,7 +340,7 @@ libdcp::utc_offset_to_string (int b)
}
string
-libdcp::ptime_to_string (boost::posix_time::ptime t)
+dcp::ptime_to_string (boost::posix_time::ptime t)
{
struct tm t_tm = boost::posix_time::to_tm (t);
return tm_to_string (&t_tm);
@@ -352,7 +352,7 @@ libdcp::ptime_to_string (boost::posix_time::ptime t)
with this wrapper.
*/
FILE *
-libdcp::fopen_boost (boost::filesystem::path p, string t)
+dcp::fopen_boost (boost::filesystem::path p, string t)
{
#ifdef LIBDCP_WINDOWS
wstring w (t.begin(), t.end());
diff --git a/src/util.h b/src/util.h
index 2a6aae1b..f12f0ff0 100644
--- a/src/util.h
+++ b/src/util.h
@@ -37,7 +37,7 @@ namespace xmlpp {
class Element;
}
-namespace libdcp {
+namespace dcp {
class ARGBFrame;
class CertificateChain;
diff --git a/src/version.h b/src/version.h
index 52abd13a..9b6dc65f 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,5 +1,5 @@
-namespace libdcp {
+namespace dcp {
extern char const * version;
extern char const * git_commit;
diff --git a/src/wscript b/src/wscript
index cdf3c062..3e92900a 100644
--- a/src/wscript
+++ b/src/wscript
@@ -16,6 +16,7 @@ def build(bld):
asset.cc
certificates.cc
colour_matrix.cc
+ content.cc
cpl.cc
dcp.cc
dcp_time.cc
@@ -25,22 +26,23 @@ def build(bld):
kdm.cc
key.cc
metadata.cc
- mono_picture_asset.cc
- mono_picture_asset_writer.cc
+ mono_picture_mxf.cc
+ mono_picture_mxf_writer.cc
mono_picture_frame.cc
- mxf_asset.cc
- picture_asset.cc
- picture_asset_writer.cc
+ mxf.cc
+ object.cc
+ picture_mxf.cc
+ picture_mxf_writer.cc
rec709_linearised_gamma_lut.cc
reel.cc
rgb_xyz.cc
signer.cc
signer_chain.cc
- sound_asset.cc
+ sound_mxf.cc
sound_frame.cc
srgb_linearised_gamma_lut.cc
- stereo_picture_asset.cc
- stereo_picture_asset_writer.cc
+ stereo_picture_mxf.cc
+ stereo_picture_mxf_writer.cc
stereo_picture_frame.cc
subtitle_asset.cc
types.cc
@@ -68,21 +70,22 @@ def build(bld):
lut.h
lut_cache.h
metadata.h
- mono_picture_asset.h
+ mono_picture_mxf.h
mono_picture_frame.h
- mxf_asset.h
- picture_asset.h
- picture_asset_writer.h
+ mxf.h
+ object.h
+ picture_mxf.h
+ picture_mxf_writer.h
rgb_xyz.h
rec709_linearised_gamma_lut.h
reel.h
argb_frame.h
signer.h
signer_chain.h
- sound_asset.h
+ sound_mxf.h
sound_frame.h
srgb_linearised_gamma_lut.h
- stereo_picture_asset.h
+ stereo_picture_mxf.h
stereo_picture_frame.h
subtitle_asset.h
types.h
diff --git a/src/xml.h b/src/xml.h
index 5978ff7e..665cfe43 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -23,7 +23,7 @@
#include <libcxml/cxml.h>
#include "exceptions.h"
-namespace libdcp
+namespace dcp
{
template <class T>
diff --git a/src/xml/kdm_smpte.h b/src/xml/kdm_smpte.h
index 32a297f8..49281d70 100644
--- a/src/xml/kdm_smpte.h
+++ b/src/xml/kdm_smpte.h
@@ -41,7 +41,7 @@
#include <libcxml/cxml.h>
#include "../exceptions.h"
-namespace libdcp {
+namespace dcp {
namespace xml {
class Writer
diff --git a/src/xyz_frame.cc b/src/xyz_frame.cc
index f5b0ee86..e75a43bc 100644
--- a/src/xyz_frame.cc
+++ b/src/xyz_frame.cc
@@ -21,7 +21,7 @@
#include <stdexcept>
#include "xyz_frame.h"
-using namespace libdcp;
+using namespace dcp;
/** Construct an XYZFrame, taking ownership of the opj_image_t */
XYZFrame::XYZFrame (opj_image_t* image)
@@ -70,9 +70,9 @@ XYZFrame::data (int c) const
return _opj_image->comps[c].data;
}
-libdcp::Size
+dcp::Size
XYZFrame::size () const
{
/* XXX: this may not be right; x0 and y0 can presumably be non-zero */
- return libdcp::Size (_opj_image->x1, _opj_image->y1);
+ return dcp::Size (_opj_image->x1, _opj_image->y1);
}
diff --git a/src/xyz_frame.h b/src/xyz_frame.h
index a4dcb2c0..2118331c 100644
--- a/src/xyz_frame.h
+++ b/src/xyz_frame.h
@@ -20,7 +20,7 @@
#include <openjpeg.h>
#include "util.h"
-namespace libdcp {
+namespace dcp {
class XYZFrame
{
@@ -30,7 +30,7 @@ public:
~XYZFrame ();
int* data (int) const;
- libdcp::Size size () const;
+ dcp::Size size () const;
opj_image_t* opj_image () const {
return _opj_image;