diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-08-27 20:13:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-08-27 20:13:53 +0100 |
| commit | c9cf540a0fee44b724d1f879489dd7e7f51c60c7 (patch) | |
| tree | b7791ada0bd8a628c12bf90b9545bf5ec27e18a7 /src | |
| parent | 0db83488a33b025d70c588ebd635554dd8be4f88 (diff) | |
Basics of OV/supplemental support when reading.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 27 | ||||
| -rw-r--r-- | src/cpl.h | 5 | ||||
| -rw-r--r-- | src/dcp.cc | 12 | ||||
| -rw-r--r-- | src/dcp.h | 18 |
4 files changed, 52 insertions, 10 deletions
@@ -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<const libdcp::parse::AssetMap> asset_map, bool require_mxfs) +CPL::CPL (string directory, string file, list<shared_ptr<const parse::AssetMap> > asset_maps, bool require_mxfs) : _directory (directory) , _content_kind (FEATURE) , _length (0) @@ -79,7 +79,7 @@ CPL::CPL (string directory, string file, shared_ptr<const libdcp::parse::AssetMa /* Trim urn:uuid: off the front */ _id = cpl->id.substr (9); - for (list<shared_ptr<libdcp::parse::Reel> >::iterator i = cpl->reels.begin(); i != cpl->reels.end(); ++i) { + for (list<shared_ptr<parse::Reel> >::iterator i = cpl->reels.begin(); i != cpl->reels.end(); ++i) { shared_ptr<parse::Picture> p; @@ -107,7 +107,7 @@ CPL::CPL (string directory, string file, shared_ptr<const libdcp::parse::AssetMa try { picture.reset (new MonoPictureAsset ( _directory, - asset_map->asset_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_ptr<const libdcp::parse::AssetMa try { picture.reset (new StereoPictureAsset ( _directory, - asset_map->asset_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_ptr<const libdcp::parse::AssetMa try { sound.reset (new SoundAsset ( _directory, - asset_map->asset_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_ptr<const libdcp::parse::AssetMa subtitle.reset (new SubtitleAsset ( _directory, - asset_map->asset_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<parse::AssetMapAsset> +CPL::asset_from_id (list<shared_ptr<const parse::AssetMap> > asset_maps, string id) const +{ + for (list<shared_ptr<const parse::AssetMap> >::const_iterator i = asset_maps.begin(); i != asset_maps.end(); ++i) { + shared_ptr<parse::AssetMapAsset> a = (*i)->asset_from_id (id); + if (a) { + return a; + } + } + + return shared_ptr<parse::AssetMapAsset> (); +} @@ -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<const parse::AssetMap> asset_map, bool require_mxfs = true); + CPL (std::string directory, std::string file, std::list<boost::shared_ptr<const parse::AssetMap> > asset_maps, bool require_mxfs = true); void add_reel (boost::shared_ptr<Reel> reel); @@ -106,6 +107,8 @@ public: void add_kdm (KDM const &); private: + boost::shared_ptr<parse::AssetMapAsset> asset_from_id (std::list<boost::shared_ptr<const parse::AssetMap> > asset_maps, std::string id) const; + std::string _directory; /** the name of the DCP */ std::string _name; @@ -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<string>::iterator i = files.cpls.begin(); i != files.cpls.end(); ++i) { - _cpls.push_back (shared_ptr<CPL> (new CPL (_directory, *i, asset_map, require_mxfs))); + _cpls.push_back (shared_ptr<CPL> (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)); +} @@ -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<boost::shared_ptr<const Asset> > assets () const; struct Files { @@ -135,6 +149,8 @@ private: std::string _directory; /** our CPLs */ std::list<boost::shared_ptr<CPL> > _cpls; + + std::list<boost::shared_ptr<const parse::AssetMap> > _asset_maps; }; } |
