From 8c2f3517e868078b551bb01d975f2956cb692fbf Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 27 Jan 2014 14:41:33 +0000 Subject: Various tinkerings. --- src/asset.cc | 10 ++++++++ src/asset.h | 28 ++++++++++++++------ src/content.h | 9 ++++--- src/cpl.cc | 24 +++++------------- src/cpl.h | 42 +++++++++++++++--------------- src/dcp.cc | 2 +- src/dcp.h | 12 ++++++++- src/font.cc | 4 +-- src/image.cc | 2 +- src/kdm.cc | 14 +++++++--- src/key.h | 2 +- src/load_font.cc | 2 +- src/mono_picture_mxf.cc | 6 ----- src/mono_picture_mxf.h | 8 ++++-- src/mxf.cc | 5 ++++ src/mxf.h | 10 +++++--- src/mxf_writer.cc | 11 ++++++-- src/mxf_writer.h | 16 ++++++++++++ src/picture_mxf.h | 27 ++++++++++---------- src/reel.cc | 2 +- src/reel.h | 2 +- src/reel_asset.cc | 4 +-- src/reel_asset.h | 55 +++++++++++++++++++++++++++++++--------- src/reel_mono_picture_asset.cc | 4 +-- src/reel_picture_asset.cc | 4 +-- src/reel_picture_asset.h | 4 +-- src/reel_sound_asset.cc | 4 +-- src/reel_stereo_picture_asset.cc | 2 +- src/reel_subtitle_asset.cc | 4 +-- src/ref.h | 33 ++++++++++++++++++++++-- src/rgb_xyz.cc | 15 +++++++++-- src/sound_mxf.cc | 4 +-- src/sound_mxf.h | 6 ++++- src/stereo_picture_mxf.cc | 6 ----- src/stereo_picture_mxf.h | 10 +++++--- src/subtitle.cc | 2 +- src/subtitle_content.h | 6 ++++- src/text.cc | 2 +- src/text.h | 2 +- src/types.cc | 7 +++++ src/types.h | 10 +++++++- 41 files changed, 287 insertions(+), 135 deletions(-) (limited to 'src') diff --git a/src/asset.cc b/src/asset.cc index 74e32cf0..43db41e3 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -37,6 +37,10 @@ Asset::Asset () } +/** Create an Asset from a given file. The ID will + * be extracted from the file. + * @param file File name. + */ Asset::Asset (boost::filesystem::path file) : _file (file) { @@ -55,6 +59,8 @@ Asset::Asset (string id) void Asset::write_to_pkl (xmlpp::Node* node) const { + assert (!_file.empty ()); + 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); @@ -66,6 +72,8 @@ Asset::write_to_pkl (xmlpp::Node* node) const void Asset::write_to_assetmap (xmlpp::Node* node) const { + assert (!_file.empty ()); + 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"); @@ -79,6 +87,8 @@ Asset::write_to_assetmap (xmlpp::Node* node) const string Asset::hash () const { + assert (!_file.empty ()); + if (!_hash.empty ()) { _hash = make_digest (_file, 0); } diff --git a/src/asset.h b/src/asset.h index abaa63be..f9ec949f 100644 --- a/src/asset.h +++ b/src/asset.h @@ -38,7 +38,7 @@ namespace dcp { /** @class Asset * @brief Parent class for DCP assets, i.e. picture/sound/subtitles and CPLs. * - * Note that this class is not used for ReelAssets; they are just for the metadata + * Note that this class is not used for ReelAssets; those are just for the metadata * that gets put into <Reel>s. */ class Asset : public Object @@ -49,28 +49,40 @@ public: Asset (std::string id); virtual std::string pkl_type () const = 0; - virtual bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; - + virtual bool equals ( + boost::shared_ptr other, + EqualityOptions opt, + boost::function note + ) const; + + /** Write details of the asset to a ASSETMAP. + * @param node Parent node. + */ + void write_to_assetmap (xmlpp::Node* node) const; + /** Write details of the asset to a PKL AssetList node. * @param node Parent node. */ void write_to_pkl (xmlpp::Node* node) const; - void write_to_assetmap (xmlpp::Node* node) const; boost::filesystem::path file () const { return _file; } - void set_file (boost::filesystem::path file) { + void set_file (boost::filesystem::path file) const { _file = file; + _hash.clear (); } + /** @return the hash of this asset's file. It will be + * computed by this call if necessary. + */ std::string hash () const; protected: - friend class MXFWriter; - - boost::filesystem::path _file; + /** The disk file that represents this asset, if one exists */ + mutable boost::filesystem::path _file; + /** Hash of _file, or empty if the hash has not yet been computed */ mutable std::string _hash; }; diff --git a/src/content.h b/src/content.h index 57aaa14c..e7445d47 100644 --- a/src/content.h +++ b/src/content.h @@ -53,9 +53,14 @@ class Content : public Asset public: Content (boost::filesystem::path file); Content (Fraction edit_rate); - virtual ~Content () {} + bool equals ( + boost::shared_ptr other, + EqualityOptions opt, + boost::function + ) const; + Fraction edit_rate () const { return _edit_rate; } @@ -64,8 +69,6 @@ public: return _intrinsic_duration; } - virtual bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function) const; - protected: friend class MXFWriter; diff --git a/src/cpl.cc b/src/cpl.cc index 813eb0ed..d99e1cf7 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -48,7 +48,6 @@ using namespace dcp; CPL::CPL (string annotation_text, ContentKind content_kind) : _annotation_text (annotation_text) , _content_kind (content_kind) - , _length (0) { } @@ -56,7 +55,6 @@ CPL::CPL (string annotation_text, ContentKind content_kind) /** Construct a CPL object from a XML file */ CPL::CPL (boost::filesystem::path file) : _content_kind (FEATURE) - , _length (0) { cxml::Document f ("CompositionPlaylist"); f.read_file (file); @@ -87,7 +85,7 @@ CPL::CPL (boost::filesystem::path file) * @param reel Reel to add. */ void -CPL::add (shared_ptr reel) +CPL::add (boost::shared_ptr reel) { _reels.push_back (reel); } @@ -134,8 +132,7 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, XMLMetadata met /* This must not be the _formatted version otherwise signature digests will be wrong */ doc.write_to_file (file.string (), "UTF-8"); - _digest = make_digest (file.string (), 0); - _length = boost::filesystem::file_size (file.string ()); + set_file (file); } list > @@ -156,19 +153,6 @@ CPL::assets () const return a; } - -void -CPL::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 (_id + "_cpl.xml"); - 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 (_length)); -} bool CPL::equals (CPL const & other, EqualityOptions opt, boost::function note) const @@ -225,6 +209,10 @@ CPL::add (KDM const & kdm) } } +/** Set a private key for every MXF referenced by this CPL. This will allow the data + * to be decrypted or encrypted. + * @param key Key to use. + */ void CPL::set_mxf_keys (Key key) { diff --git a/src/cpl.h b/src/cpl.h index 9e7d5aae..35a8bb62 100644 --- a/src/cpl.h +++ b/src/cpl.h @@ -54,8 +54,15 @@ public: return "text/xml"; } - void add (boost::shared_ptr reel); + bool equals ( + CPL const & other, + EqualityOptions options, + boost::function note + ) const; + void add (boost::shared_ptr reel); + void add (KDM const &); + std::string annotation_text () const { return _annotation_text; } @@ -81,29 +88,22 @@ public: void set_mxf_keys (Key); - bool equals (CPL const & other, EqualityOptions options, boost::function note) const; - - void write_xml (boost::filesystem::path file, Standard standard, XMLMetadata, boost::shared_ptr) const; - void write_to_assetmap (xmlpp::Node *) const; - - void add (KDM const &); + void write_xml ( + boost::filesystem::path file, + Standard standard, + XMLMetadata, + boost::shared_ptr + ) const; private: - - std::string _annotation_text; - std::string _issue_date; - std::string _creator; - std::string _content_title_text; - ContentKind _content_kind; - std::string _content_version_id; - std::string _content_version_label_text; - /** reels */ + std::string _annotation_text; ///< + std::string _issue_date; ///< + std::string _creator; ///< + std::string _content_title_text; ///< + ContentKind _content_kind; ///< + std::string _content_version_id; ///< in + std::string _content_version_label_text; ///< in std::list > _reels; - - /** a SHA1 digest of our XML */ - mutable std::string _digest; - /** length in bytes of the XML that we last wrote to disk */ - mutable int64_t _length; }; } diff --git a/src/dcp.cc b/src/dcp.cc index dc67dd2e..6af33663 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -162,7 +162,7 @@ DCP::equals (DCP const & other, EqualityOptions opt, boost::function asset) +DCP::add (boost::shared_ptr asset) { _assets.push_back (asset); } diff --git a/src/dcp.h b/src/dcp.h index 3f4c8418..9d8a5415 100644 --- a/src/dcp.h +++ b/src/dcp.h @@ -82,6 +82,11 @@ public: std::list > cpls () const; + /** @return All this DCP's assets (note that CPLs are assets) */ + std::list > assets () const { + return _assets; + } + bool encrypted () const; void add (KDM const &); @@ -102,7 +107,12 @@ private: /** Write the PKL file. * @param pkl_uuid UUID to use. */ - boost::filesystem::path write_pkl (Standard standard, std::string pkl_uuid, XMLMetadata metadata, boost::shared_ptr signer) const; + boost::filesystem::path write_pkl ( + Standard standard, + std::string pkl_uuid, + XMLMetadata metadata, + boost::shared_ptr signer + ) const; void write_volindex (Standard standard) const; diff --git a/src/font.cc b/src/font.cc index 5a568a63..52996a73 100644 --- a/src/font.cc +++ b/src/font.cc @@ -28,7 +28,7 @@ using boost::shared_ptr; using boost::optional; using namespace dcp; -Font::Font (shared_ptr node) +Font::Font (boost::shared_ptr node) { text = node->content (); @@ -52,7 +52,7 @@ Font::Font (shared_ptr node) text_nodes = type_children (node, "Text"); } -Font::Font (list > const & font_nodes) +Font::Font (std::list > const & font_nodes) : size (0) , italic (false) , color ("FFFFFFFF") diff --git a/src/image.cc b/src/image.cc index f12ceea2..15ff24dc 100644 --- a/src/image.cc +++ b/src/image.cc @@ -34,7 +34,7 @@ Image::Image (Image const & other) } -Image::Image (shared_ptr other) +Image::Image (boost::shared_ptr other) : _size (other->_size) { diff --git a/src/kdm.cc b/src/kdm.cc index 3fd5d67c..c99fc21a 100644 --- a/src/kdm.cc +++ b/src/kdm.cc @@ -91,7 +91,9 @@ KDM::KDM (boost::filesystem::path kdm, boost::filesystem::path private_key) } KDM::KDM ( - shared_ptr cpl, shared_ptr signer, shared_ptr recipient_cert, + boost::shared_ptr cpl, + boost::shared_ptr signer, + boost::shared_ptr recipient_cert, boost::posix_time::ptime not_valid_before, boost::posix_time::ptime not_valid_after, string annotation_text, string issue_date ) @@ -206,7 +208,13 @@ KDM::as_xml () const } KDMKey::KDMKey ( - shared_ptr signer, string cpl_id, string key_type, string key_id, boost::posix_time::ptime from, boost::posix_time::ptime until, Key key + boost::shared_ptr signer, + string cpl_id, + string key_type, + string key_id, + boost::posix_time::ptime from, + boost::posix_time::ptime until, + Key key ) : _cpl_id (cpl_id) , _key_type (key_type) @@ -279,7 +287,7 @@ KDMKey::operator= (KDMKey const & other) } string -KDMKey::encrypted_base64 (shared_ptr recipient_cert) const +KDMKey::encrypted_base64 (boost::shared_ptr recipient_cert) const { assert (_key_type.length() == 4); assert (_not_valid_before.length() == 25); diff --git a/src/key.h b/src/key.h index 43897baf..248a2a95 100644 --- a/src/key.h +++ b/src/key.h @@ -30,7 +30,7 @@ namespace dcp { /** @class Key - * @brief A key for encrypting MXFs. + * @brief A key for decrypting/encrypting MXFs. */ class Key { diff --git a/src/load_font.cc b/src/load_font.cc index a337856c..707f4a0b 100644 --- a/src/load_font.cc +++ b/src/load_font.cc @@ -23,7 +23,7 @@ using boost::shared_ptr; using namespace dcp; -LoadFont::LoadFont (shared_ptr node) +LoadFont::LoadFont (boost::shared_ptr node) { id = node->string_attribute ("Id"); uri = node->string_attribute ("URI"); diff --git a/src/mono_picture_mxf.cc b/src/mono_picture_mxf.cc index 699cfc23..9c16516d 100644 --- a/src/mono_picture_mxf.cc +++ b/src/mono_picture_mxf.cc @@ -128,9 +128,3 @@ MonoPictureMXF::cpl_node_name () const { return "MainPicture"; } - -int -MonoPictureMXF::edit_rate_factor () const -{ - return 1; -} diff --git a/src/mono_picture_mxf.h b/src/mono_picture_mxf.h index c742ae37..c02a63c1 100644 --- a/src/mono_picture_mxf.h +++ b/src/mono_picture_mxf.h @@ -45,12 +45,16 @@ public: /** Start a progressive write to a MonoPictureMXF */ boost::shared_ptr start_write (boost::filesystem::path, Standard standard, bool); + bool equals ( + boost::shared_ptr other, + EqualityOptions opt, + boost::function note + ) const; + boost::shared_ptr get_frame (int n) const; - bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; private: std::string cpl_node_name () const; - int edit_rate_factor () const; }; } diff --git a/src/mxf.cc b/src/mxf.cc index d2ec5629..1a19b817 100644 --- a/src/mxf.cc +++ b/src/mxf.cc @@ -115,6 +115,11 @@ MXF::equals (shared_ptr other, EqualityOptions opt, boost::functi return true; } +/** Set the (private) key that will be used to encrypt or decrypt this MXF's content. + * This is the top-secret key that is distributed (itself encrypted) to cinemas + * via Key Delivery Messages (KDMs). + * @param key Key to use. + */ void MXF::set_key (Key key) { diff --git a/src/mxf.h b/src/mxf.h index 92b7b6b9..f2c0fdf7 100644 --- a/src/mxf.h +++ b/src/mxf.h @@ -43,16 +43,20 @@ class MXF : public Content public: MXF (Fraction edit_rate); MXF (boost::filesystem::path file); - ~MXF (); - virtual bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; virtual std::string key_type () const = 0; - + std::string pkl_type () const { return "application/x-smpte-mxf"; } + bool equals ( + boost::shared_ptr other, + EqualityOptions opt, + boost::function note + ) const; + /** Fill in a ADSCP::WriteInfo struct. * @param w struct to fill in. * @param standard INTEROP or SMPTE. diff --git a/src/mxf_writer.cc b/src/mxf_writer.cc index c5fca159..374e6590 100644 --- a/src/mxf_writer.cc +++ b/src/mxf_writer.cc @@ -17,19 +17,26 @@ */ +/** @file src/mxf_writer.h + * @brief MXFWriter class. + */ + #include "mxf_writer.h" #include "mxf.h" using namespace dcp; +/** Create an MXFWriter. + * @param mxf MXF that we are writing. + * @param file File to write to. + */ MXFWriter::MXFWriter (MXF* mxf, boost::filesystem::path file) : _mxf (mxf) , _file (file) , _frames_written (0) , _finalized (false) { - mxf->_file = file; - mxf->_hash.clear (); + mxf->set_file (file); } MXFWriter::~MXFWriter () diff --git a/src/mxf_writer.h b/src/mxf_writer.h index 19632131..b4e20f33 100644 --- a/src/mxf_writer.h +++ b/src/mxf_writer.h @@ -17,6 +17,10 @@ */ +/** @file src/mxf_writer.h + * @brief MXFWriter class. + */ + #ifndef LIBDCP_MXF_WRITER_H #define LIBDCP_MXF_WRITER_H @@ -26,6 +30,12 @@ namespace dcp { class MXF; +/** @class MXFWriter + * @brief Parent class for classes which can write MXF files. + * + * The MXFWriter lasts for the duration of the write and is then discarded. + * They can only be created by calling start_write() on an MXF object. + */ class MXFWriter : public boost::noncopyable { public: @@ -35,9 +45,15 @@ public: protected: MXFWriter (MXF* mxf, boost::filesystem::path file); + /** MXF that we are writing */ MXF* _mxf; + /** File that we are writing to */ boost::filesystem::path _file; + /** Number of `frames' written so far; the definition of a frame + * varies depending on the subclass. + */ int64_t _frames_written; + /** true if finalize() has been called on this object */ bool _finalized; }; diff --git a/src/picture_mxf.h b/src/picture_mxf.h index 4653196d..e8040a4e 100644 --- a/src/picture_mxf.h +++ b/src/picture_mxf.h @@ -20,14 +20,14 @@ #ifndef LIBDCP_PICTURE_MXF_H #define LIBDCP_PICTURE_MXF_H -/** @file src/picture_asset.h - * @brief An asset made up of JPEG2000 data +/** @file src/picture_mxf.h + * @brief PictureMXF class. */ -#include #include "mxf.h" #include "util.h" #include "metadata.h" +#include namespace ASDCP { namespace JP2K { @@ -42,16 +42,20 @@ class MonoPictureFrame; class StereoPictureFrame; class PictureMXFWriter; -/** @brief An asset made up of JPEG2000 data */ +/** @class PictureMXF + * @brief An asset made up of JPEG2000 data. + */ class PictureMXF : public MXF { public: PictureMXF (boost::filesystem::path file); PictureMXF (Fraction edit_rate); - virtual boost::shared_ptr start_write (boost::filesystem::path file, Standard standard, bool overwrite) = 0; - - void write_to_pkl (xmlpp::Node* node) const; + virtual boost::shared_ptr start_write ( + boost::filesystem::path file, + Standard standard, + bool overwrite + ) = 0; Size size () const { return _size; @@ -65,10 +69,6 @@ public: return _screen_aspect_ratio; } - Fraction edit_rate () const { - return _edit_rate; - } - protected: bool frame_buffer_equals ( @@ -77,7 +77,9 @@ protected: ) const; bool descriptor_equals ( - ASDCP::JP2K::PictureDescriptor const & a, ASDCP::JP2K::PictureDescriptor const & b, boost::function + ASDCP::JP2K::PictureDescriptor const & a, + ASDCP::JP2K::PictureDescriptor const & b, + boost::function ) const; void read_picture_descriptor (ASDCP::JP2K::PictureDescriptor const &); @@ -89,7 +91,6 @@ protected: private: std::string key_type () const; - virtual int edit_rate_factor () const = 0; }; diff --git a/src/reel.cc b/src/reel.cc index 8326c197..7503ae9c 100644 --- a/src/reel.cc +++ b/src/reel.cc @@ -38,7 +38,7 @@ using boost::shared_ptr; using boost::dynamic_pointer_cast; using namespace dcp; -Reel::Reel (shared_ptr node) +Reel::Reel (boost::shared_ptr node) : Object (node->string_child ("Id")) { shared_ptr asset_list = node->node_child ("AssetList"); diff --git a/src/reel.h b/src/reel.h index ea7e1c41..30a0cc4e 100644 --- a/src/reel.h +++ b/src/reel.h @@ -40,7 +40,7 @@ class ReelPictureAsset; class ReelSoundAsset; class ReelSubtitleAsset; -/** @brief A reel within a DCP; the part which actually contains picture, sound and subtitle data */ +/** @brief A reel within a DCP; the part which actually refers to picture, sound and subtitle data */ class Reel : public Object { public: diff --git a/src/reel_asset.cc b/src/reel_asset.cc index 8e03b5c4..28b1937c 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -40,7 +40,7 @@ ReelAsset::ReelAsset () } -ReelAsset::ReelAsset (shared_ptr content, int64_t entry_point) +ReelAsset::ReelAsset (boost::shared_ptr content, int64_t entry_point) : Object (content->id ()) , _content (content) , _edit_rate (content->edit_rate ()) @@ -52,7 +52,7 @@ ReelAsset::ReelAsset (shared_ptr content, int64_t entry_point) } -ReelAsset::ReelAsset (shared_ptr node) +ReelAsset::ReelAsset (boost::shared_ptr node) : Object (node->string_child ("Id")) , _content (_id) , _annotation_text (node->optional_string_child ("AnnotationText").get_value_or ("")) diff --git a/src/reel_asset.h b/src/reel_asset.h index 5207166a..25c13354 100644 --- a/src/reel_asset.h +++ b/src/reel_asset.h @@ -37,6 +37,13 @@ namespace dcp { class Content; +/** @class ReelAsset + * @brief An entry in a <Reel> which refers to a use of a piece of content. + * + * This class encapsulates the XML that exists in a <Reel> to say + * that a piece of content is used in this reel. It does not + * describe the content itself (but links to a Content object which does). + */ class ReelAsset : public Object { public: @@ -44,37 +51,61 @@ public: ReelAsset (boost::shared_ptr content, int64_t entry_point); ReelAsset (boost::shared_ptr); + virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const; + + virtual bool equals ( + boost::shared_ptr, + EqualityOptions, + boost::function) + const { + + return false; + } + + /** @return a Ref to our actual content */ Ref content () const { return _content; } + /** @return true if a KeyId is specified for this asset, implying + * that its content is encrypted. + */ bool encrypted () const { return !_key_id.empty (); } + /** @return Key ID to describe the key that encrypts this asset's; + * content. + */ std::string key_id () const { return _key_id; } - virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const; - virtual bool equals (boost::shared_ptr, EqualityOptions, boost::function) const { - return false; - } - protected: + /** @return the node name that this asset uses in the CPL's node + * e.g. MainPicture, MainSound etc. + */ virtual std::string cpl_node_name () const = 0; + + /** @return Any attribute that should be used on the asset's node in the + * CPL. + */ virtual std::pair cpl_node_attribute () const; + /** Reference to the content (MXF or XML file) that this reel entry + * applies to. + */ Ref _content; private: - std::string _annotation_text; - Fraction _edit_rate; - int64_t _intrinsic_duration; - int64_t _entry_point; - int64_t _duration; - std::string _hash; - std::string _key_id; + + std::string _annotation_text; ///< The from the reel's entry for this asset + Fraction _edit_rate; ///< The from the reel's entry for this asset + int64_t _intrinsic_duration; ///< The from the reel's entry for this asset + int64_t _entry_point; ///< The from the reel's entry for this asset + int64_t _duration; ///< The from the reel's entry for this asset + std::string _hash; ///< The from the reel's entry for this asset + std::string _key_id; ///< The from the reel's entry for this asset, or empty if there isn't one }; } diff --git a/src/reel_mono_picture_asset.cc b/src/reel_mono_picture_asset.cc index 892c9f4e..c0b604a1 100644 --- a/src/reel_mono_picture_asset.cc +++ b/src/reel_mono_picture_asset.cc @@ -29,13 +29,13 @@ ReelMonoPictureAsset::ReelMonoPictureAsset () } -ReelMonoPictureAsset::ReelMonoPictureAsset (shared_ptr mxf, int64_t entry_point) +ReelMonoPictureAsset::ReelMonoPictureAsset (boost::shared_ptr mxf, int64_t entry_point) : ReelPictureAsset (mxf, entry_point) { } -ReelMonoPictureAsset::ReelMonoPictureAsset (shared_ptr node) +ReelMonoPictureAsset::ReelMonoPictureAsset (boost::shared_ptr node) : ReelPictureAsset (node) { diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc index 9fdc3b9e..758ed85e 100644 --- a/src/reel_picture_asset.cc +++ b/src/reel_picture_asset.cc @@ -37,7 +37,7 @@ ReelPictureAsset::ReelPictureAsset () } -ReelPictureAsset::ReelPictureAsset (shared_ptr content, int64_t entry_point) +ReelPictureAsset::ReelPictureAsset (boost::shared_ptr content, int64_t entry_point) : ReelAsset (content, entry_point) , _frame_rate (content->frame_rate ()) , _screen_aspect_ratio (content->screen_aspect_ratio ()) @@ -45,7 +45,7 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr content, int64_t entr } -ReelPictureAsset::ReelPictureAsset (shared_ptr node) +ReelPictureAsset::ReelPictureAsset (boost::shared_ptr node) : ReelAsset (node) { _frame_rate = Fraction (node->string_child ("FrameRate")); diff --git a/src/reel_picture_asset.h b/src/reel_picture_asset.h index c6eb2c73..b433ff88 100644 --- a/src/reel_picture_asset.h +++ b/src/reel_picture_asset.h @@ -32,6 +32,8 @@ public: ReelPictureAsset (boost::shared_ptr content, int64_t entry_point); ReelPictureAsset (boost::shared_ptr); + virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const; + boost::shared_ptr mxf () { return boost::dynamic_pointer_cast (_content.object ()); } @@ -40,8 +42,6 @@ public: _screen_aspect_ratio = a; } - virtual void write_to_cpl (xmlpp::Node* node, Standard standard) const; - private: Fraction _frame_rate; Fraction _screen_aspect_ratio; diff --git a/src/reel_sound_asset.cc b/src/reel_sound_asset.cc index 6ef473fe..b3bc049f 100644 --- a/src/reel_sound_asset.cc +++ b/src/reel_sound_asset.cc @@ -24,13 +24,13 @@ using std::string; using boost::shared_ptr; using namespace dcp; -ReelSoundAsset::ReelSoundAsset (shared_ptr content, int64_t entry_point) +ReelSoundAsset::ReelSoundAsset (boost::shared_ptr content, int64_t entry_point) : ReelAsset (content, entry_point) { } -ReelSoundAsset::ReelSoundAsset (shared_ptr node) +ReelSoundAsset::ReelSoundAsset (boost::shared_ptr node) : ReelAsset (node) { node->ignore_child ("Language"); diff --git a/src/reel_stereo_picture_asset.cc b/src/reel_stereo_picture_asset.cc index 2715eb34..20e33279 100644 --- a/src/reel_stereo_picture_asset.cc +++ b/src/reel_stereo_picture_asset.cc @@ -25,7 +25,7 @@ using std::make_pair; using boost::shared_ptr; using namespace dcp; -ReelStereoPictureAsset::ReelStereoPictureAsset (shared_ptr node) +ReelStereoPictureAsset::ReelStereoPictureAsset (boost::shared_ptr node) : ReelPictureAsset (node) { diff --git a/src/reel_subtitle_asset.cc b/src/reel_subtitle_asset.cc index 326e343c..b2e46f93 100644 --- a/src/reel_subtitle_asset.cc +++ b/src/reel_subtitle_asset.cc @@ -24,13 +24,13 @@ using std::string; using boost::shared_ptr; using namespace dcp; -ReelSubtitleAsset::ReelSubtitleAsset (shared_ptr content, int64_t entry_point) +ReelSubtitleAsset::ReelSubtitleAsset (boost::shared_ptr content, int64_t entry_point) : ReelAsset (content, entry_point) { } -ReelSubtitleAsset::ReelSubtitleAsset (shared_ptr node) +ReelSubtitleAsset::ReelSubtitleAsset (boost::shared_ptr node) : ReelAsset (node) { node->ignore_child ("Language"); diff --git a/src/ref.h b/src/ref.h index db39bfb6..c22222cc 100644 --- a/src/ref.h +++ b/src/ref.h @@ -17,6 +17,10 @@ */ +/** @file src/ref.h + * @brief Ref class. + */ + #ifndef LIBDCP_REF_H #define LIBDCP_REF_H @@ -27,24 +31,41 @@ namespace dcp { +/** @class Ref + * @brief A reference to an object which is identified by a universally-unique identifier (UUID). + * + * This class is a `pointer' to a thing. It will always know the + * UUID of the thing, and it may have a shared_ptr to the C++ object + * which represents the thing. + * + * If the Ref does not have a shared_ptr it may be given one by + * calling resolve() with a list of objects. The shared_ptr will be + * set up using any object on the list which has a matching ID. + */ template class Ref { public: + /** Initialise a Ref with an ID but no shared_ptr */ Ref (std::string id) : _id (id) {} + /** Initialise a Ref with a shared_ptr to an object */ Ref (boost::shared_ptr object) : _id (object->id ()) , _object (object) {} + /** Set the ID of this Ref */ void set_id (std::string id) { _id = id; } + /** Look through a list of objects and copy a shared_ptr to any object + * which matches the ID of this one. + */ void resolve (std::list > objects) { typename std::list >::iterator i = objects.begin(); @@ -57,10 +78,14 @@ public: } } + /** @return the ID of the thing that we are pointing to */ std::string id () const { return _id; } + /** @return a shared_ptr to the thing; an UnresolvedRefError is thrown + * if the shared_ptr is not known. + */ boost::shared_ptr object () const { if (!_object) { throw UnresolvedRefError (_id); @@ -69,6 +94,9 @@ public: return _object; } + /** operator-> to access the shared_ptr; an UnresolvedRefError is thrown + * if the shared_ptr is not known. + */ T * operator->() const { if (!_object) { throw UnresolvedRefError (_id); @@ -77,13 +105,14 @@ public: return _object.get (); } + /** @return true if a shared_ptr is known for this Ref */ bool resolved () const { return _object; } private: - std::string _id; - boost::shared_ptr _object; + std::string _id; ///< ID; will always be known + boost::shared_ptr _object; ///< shared_ptr to the thing, may be null. }; } diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc index 6fc28e3d..9cf12e4c 100644 --- a/src/rgb_xyz.cc +++ b/src/rgb_xyz.cc @@ -33,10 +33,16 @@ using namespace dcp; /** Convert an openjpeg XYZ image to RGB. * @param xyz_frame Frame in XYZ. + * @param lut_in Input Gamma LUT to use. + * @param lut_out Output Gamma LUT to use. * @return RGB image. */ shared_ptr -dcp::xyz_to_rgb (shared_ptr xyz_frame, shared_ptr lut_in, shared_ptr lut_out) +dcp::xyz_to_rgb ( + boost::shared_ptr xyz_frame, + boost::shared_ptr lut_in, + boost::shared_ptr lut_out + ) { int const max_colour = pow (2, lut_out->bit_depth()) - 1; @@ -100,7 +106,12 @@ dcp::xyz_to_rgb (shared_ptr xyz_frame, shared_ptr lut } shared_ptr -dcp::rgb_to_xyz (shared_ptr rgb, shared_ptr lut_in, shared_ptr lut_out, double const colour_matrix[3][3]) +dcp::rgb_to_xyz ( + boost::shared_ptr rgb, + boost::shared_ptr lut_in, + boost::shared_ptr lut_out, + double const colour_matrix[3][3] + ) { assert (lut_in->bit_depth() == 12); assert (lut_out->bit_depth() == 16); diff --git a/src/sound_mxf.cc b/src/sound_mxf.cc index 5ce72b1d..ebcf12c6 100644 --- a/src/sound_mxf.cc +++ b/src/sound_mxf.cc @@ -17,8 +17,8 @@ */ -/** @file src/sound_asset.cc - * @brief An asset made up of WAV files +/** @file src/sound_mxf.cc + * @brief SoundMXF class. */ #include "sound_mxf.h" diff --git a/src/sound_mxf.h b/src/sound_mxf.h index 098680ac..04ec8aeb 100644 --- a/src/sound_mxf.h +++ b/src/sound_mxf.h @@ -38,7 +38,11 @@ public: boost::shared_ptr start_write (boost::filesystem::path file, Standard standard); - bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; + bool equals ( + boost::shared_ptr other, + EqualityOptions opt, + boost::function note + ) const; boost::shared_ptr get_frame (int n) const; diff --git a/src/stereo_picture_mxf.cc b/src/stereo_picture_mxf.cc index 59f16c93..6bcd75c8 100644 --- a/src/stereo_picture_mxf.cc +++ b/src/stereo_picture_mxf.cc @@ -66,12 +66,6 @@ StereoPictureMXF::start_write (boost::filesystem::path file, Standard standard, return shared_ptr (new StereoPictureMXFWriter (this, file, standard, overwrite)); } -int -StereoPictureMXF::edit_rate_factor () const -{ - return 2; -} - bool StereoPictureMXF::equals (shared_ptr other, EqualityOptions opt, boost::function note) const { diff --git a/src/stereo_picture_mxf.h b/src/stereo_picture_mxf.h index f4a4771a..dc4605c7 100644 --- a/src/stereo_picture_mxf.h +++ b/src/stereo_picture_mxf.h @@ -34,11 +34,13 @@ public: /** Start a progressive write to a StereoPictureMXF */ boost::shared_ptr start_write (boost::filesystem::path file, Standard, bool); + bool equals ( + boost::shared_ptr other, + EqualityOptions opt, + boost::function note + ) const; + boost::shared_ptr get_frame (int n) const; - bool equals (boost::shared_ptr other, EqualityOptions opt, boost::function note) const; - -private: - int edit_rate_factor () const; }; } diff --git a/src/subtitle.cc b/src/subtitle.cc index dc7a6b22..8c40254a 100644 --- a/src/subtitle.cc +++ b/src/subtitle.cc @@ -28,7 +28,7 @@ using boost::shared_ptr; using boost::lexical_cast; using namespace dcp; -Subtitle::Subtitle (shared_ptr node) +Subtitle::Subtitle (boost::shared_ptr node) { in = Time (node->string_attribute ("TimeIn")); out = Time (node->string_attribute ("TimeOut")); diff --git a/src/subtitle_content.h b/src/subtitle_content.h index b8db0c2c..476f8fe4 100644 --- a/src/subtitle_content.h +++ b/src/subtitle_content.h @@ -46,7 +46,11 @@ public: return "text/xml"; } - virtual bool equals (boost::shared_ptr, EqualityOptions, boost::function note) const { + bool equals ( + boost::shared_ptr, + EqualityOptions, + boost::function note + ) const { /* XXX */ note (ERROR, "subtitle content not compared yet"); return true; diff --git a/src/text.cc b/src/text.cc index c70e4333..888cab29 100644 --- a/src/text.cc +++ b/src/text.cc @@ -35,7 +35,7 @@ using namespace dcp; * in this object's member variables. * @param node Node to read. */ -Text::Text (shared_ptr node) +Text::Text (boost::shared_ptr node) : v_align (CENTER) { text = node->content (); diff --git a/src/text.h b/src/text.h index 3a44965d..268d146c 100644 --- a/src/text.h +++ b/src/text.h @@ -44,7 +44,7 @@ public: : v_position (0) , v_align (TOP) {} - + Text (boost::shared_ptr node); float v_position; diff --git a/src/types.cc b/src/types.cc index 106fb44c..0ecf7a16 100644 --- a/src/types.cc +++ b/src/types.cc @@ -29,6 +29,9 @@ using namespace std; using namespace dcp; using namespace boost; +/** Construct a Fraction from a string of the form + * e.g. "1 3". + */ Fraction::Fraction (string s) { vector b; @@ -52,6 +55,7 @@ dcp::operator!= (Fraction const & a, Fraction const & b) return (a.numerator != b.numerator || a.denominator != b.denominator); } +/** Construct a Color, initialising it to black. */ Color::Color () : r (0) , g (0) @@ -60,6 +64,9 @@ Color::Color () } +/** Construct a Color from R, G and B. The values run between + * 0 and 255. + */ Color::Color (int r_, int g_, int b_) : r (r_) , g (g_) diff --git a/src/types.h b/src/types.h index 1397dfdc..d34a9039 100644 --- a/src/types.h +++ b/src/types.h @@ -85,12 +85,20 @@ enum Eye EYE_LEFT, EYE_RIGHT }; - + +/** @class Fraction + * @brief A fraction (i.e. a thing with an integer numerator and an integer denominator). + */ class Fraction { public: + /** Construct a fraction of 0/0 */ Fraction () : numerator (0), denominator (0) {} Fraction (std::string s); + /** Construct a fraction with a specified numerator and denominator. + * @param n Numerator. + * @param d Denominator. + */ Fraction (int n, int d) : numerator (n), denominator (d) {} int numerator; -- cgit v1.2.3