From c9cf540a0fee44b724d1f879489dd7e7f51c60c7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 27 Aug 2013 20:13:53 +0100 Subject: Basics of OV/supplemental support when reading. --- src/cpl.cc | 27 ++++++++++++++++++++------- src/cpl.h | 5 ++++- src/dcp.cc | 12 +++++++++++- src/dcp.h | 18 +++++++++++++++++- 4 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/cpl.cc b/src/cpl.cc index 8d8f6a00..e22ddc71 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -54,10 +54,10 @@ CPL::CPL (string directory, string name, ContentKind content_kind, int length, i /** Construct a CPL object from a XML file. * @param directory The directory containing this CPL's DCP. * @param file The CPL XML filename. - * @param asset_map The corresponding asset map. + * @param asset_maps AssetMaps to look for assets in. * @param require_mxfs true to throw an exception if a required MXF file does not exist. */ -CPL::CPL (string directory, string file, shared_ptr asset_map, bool require_mxfs) +CPL::CPL (string directory, string file, list > asset_maps, bool require_mxfs) : _directory (directory) , _content_kind (FEATURE) , _length (0) @@ -79,7 +79,7 @@ CPL::CPL (string directory, string file, shared_ptrid.substr (9); - for (list >::iterator i = cpl->reels.begin(); i != cpl->reels.end(); ++i) { + for (list >::iterator i = cpl->reels.begin(); i != cpl->reels.end(); ++i) { shared_ptr p; @@ -107,7 +107,7 @@ CPL::CPL (string directory, string file, shared_ptrasset_from_id (p->id)->chunks.front()->path + asset_from_id (asset_maps, p->id)->chunks.front()->path ) ); @@ -127,7 +127,7 @@ CPL::CPL (string directory, string file, shared_ptrasset_from_id (p->id)->chunks.front()->path, + asset_from_id (asset_maps, p->id)->chunks.front()->path, _fps, p->duration ) @@ -153,7 +153,7 @@ CPL::CPL (string directory, string file, shared_ptrasset_from_id ((*i)->asset_list->main_sound->id)->chunks.front()->path + asset_from_id (asset_maps, (*i)->asset_list->main_sound->id)->chunks.front()->path ) ); @@ -176,7 +176,7 @@ CPL::CPL (string directory, string file, shared_ptrasset_from_id ((*i)->asset_list->main_subtitle->id)->chunks.front()->path + asset_from_id (asset_maps, (*i)->asset_list->main_subtitle->id)->chunks.front()->path ) ); @@ -508,3 +508,16 @@ CPL::add_kdm (KDM const & kdm) (*i)->add_kdm (kdm); } } + +shared_ptr +CPL::asset_from_id (list > asset_maps, string id) const +{ + for (list >::const_iterator i = asset_maps.begin(); i != asset_maps.end(); ++i) { + shared_ptr a = (*i)->asset_from_id (id); + if (a) { + return a; + } + } + + return shared_ptr (); +} diff --git a/src/cpl.h b/src/cpl.h index 94ab877a..57d4373f 100644 --- a/src/cpl.h +++ b/src/cpl.h @@ -32,6 +32,7 @@ namespace libdcp { namespace parse { class AssetMap; + class AssetMapAsset; } class Asset; @@ -46,7 +47,7 @@ class CPL { public: CPL (std::string directory, std::string name, ContentKind content_kind, int length, int frames_per_second); - CPL (std::string directory, std::string file, boost::shared_ptr asset_map, bool require_mxfs = true); + CPL (std::string directory, std::string file, std::list > asset_maps, bool require_mxfs = true); void add_reel (boost::shared_ptr reel); @@ -106,6 +107,8 @@ public: void add_kdm (KDM const &); private: + boost::shared_ptr asset_from_id (std::list > asset_maps, std::string id) const; + std::string _directory; /** the name of the DCP */ std::string _name; diff --git a/src/dcp.cc b/src/dcp.cc index a69a5198..b9f43472 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -53,6 +53,8 @@ using std::list; using std::stringstream; using std::ofstream; using std::ostream; +using std::copy; +using std::back_inserter; using boost::shared_ptr; using boost::lexical_cast; using namespace libdcp; @@ -269,8 +271,10 @@ DCP::read (bool require_mxfs) /* Cross-check */ /* XXX */ + _asset_maps.push_back (asset_map); + for (list::iterator i = files.cpls.begin(); i != files.cpls.end(); ++i) { - _cpls.push_back (shared_ptr (new CPL (_directory, *i, asset_map, require_mxfs))); + _cpls.push_back (shared_ptr (new CPL (_directory, *i, _asset_maps, require_mxfs))); } } @@ -349,3 +353,9 @@ DCP::add_kdm (KDM const & kdm) } } } + +void +DCP::add_assets_from (DCP const & ov) +{ + copy (ov._asset_maps.begin(), ov._asset_maps.end(), back_inserter (_asset_maps)); +} diff --git a/src/dcp.h b/src/dcp.h index d6237e8a..55d3d705 100644 --- a/src/dcp.h +++ b/src/dcp.h @@ -50,6 +50,10 @@ class XMLMetadata; class Encryption; class KDM; +namespace parse { + class AssetMap; +} + /** @class DCP * @brief A class to create or read a DCP. */ @@ -97,6 +101,16 @@ public: return _cpls; } + /** Add another DCP as a source of assets for this DCP. This should be called before + * ::read() on the DCP that needs the extra assets. For example + * + * DCP original_version ("my_dcp_OV"); + * DCP supplemental ("my_dcp_VF"); + * supplemental.add_assets_from (original_version); + * supplemental.read (); + */ + void add_assets_from (libdcp::DCP const &); + bool encrypted () const; void add_kdm (KDM const &); @@ -122,7 +136,7 @@ private: */ void write_assetmap (std::string pkl_uuid, int pkl_length, bool, XMLMetadata const &) const; - /** @return Assets in all this CPLs in this DCP */ + /** @return Assets in all the CPLs in this DCP */ std::list > assets () const; struct Files { @@ -135,6 +149,8 @@ private: std::string _directory; /** our CPLs */ std::list > _cpls; + + std::list > _asset_maps; }; } -- cgit v1.2.3