diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-08-30 22:29:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-08-30 22:29:22 +0100 |
| commit | 49d779c5289ecfaf9acaac429251b2ffd032228a (patch) | |
| tree | ad70dc32628c9cb61efcc47d39e3b3947231a987 | |
| parent | 29b507d5ed965367c2daa8c68316a1b336edd614 (diff) | |
Hack; separate DCP asset and CPL reads.
| -rw-r--r-- | src/dcp.cc | 33 | ||||
| -rw-r--r-- | src/dcp.h | 13 |
2 files changed, 27 insertions, 19 deletions
@@ -194,12 +194,16 @@ DCP::write_assetmap (string pkl_uuid, int pkl_length, bool interop, XMLMetadata doc.write_to_file_formatted (p.string (), "UTF-8"); } - void DCP::read (bool require_mxfs) { - Files files; + read_assets (); + read_cpls (require_mxfs); +} +void +DCP::read_assets () +{ shared_ptr<parse::AssetMap> asset_map; try { boost::filesystem::path p = _directory; @@ -217,7 +221,7 @@ DCP::read (bool require_mxfs) } } catch (FileError& e) { - boost::throw_exception (FileError ("could not load AssetMap file", files.asset_map)); + boost::throw_exception (FileError ("could not load AssetMap file", _files.asset_map)); } for (list<shared_ptr<libdcp::parse::AssetMapAsset> >::const_iterator i = asset_map->assets.begin(); i != asset_map->assets.end(); ++i) { @@ -244,37 +248,38 @@ DCP::read (bool require_mxfs) delete p; if (root == "CompositionPlaylist") { - files.cpls.push_back (t.string()); + _files.cpls.push_back (t.string()); } else if (root == "PackingList") { - if (files.pkl.empty ()) { - files.pkl = t.string(); + if (_files.pkl.empty ()) { + _files.pkl = t.string(); } else { boost::throw_exception (DCPReadError ("duplicate PKLs found")); } } } - if (files.cpls.empty ()) { + if (_files.cpls.empty ()) { boost::throw_exception (FileError ("no CPL files found", "")); } - if (files.pkl.empty ()) { + if (_files.pkl.empty ()) { boost::throw_exception (FileError ("no PKL file found", "")); } shared_ptr<parse::PKL> pkl; try { - pkl.reset (new parse::PKL (files.pkl)); + pkl.reset (new parse::PKL (_files.pkl)); } catch (FileError& e) { - boost::throw_exception (FileError ("could not load PKL file", files.pkl)); + boost::throw_exception (FileError ("could not load PKL file", _files.pkl)); } - /* Cross-check */ - /* XXX */ - _asset_maps.push_back (make_pair (boost::filesystem::absolute (_directory).string(), asset_map)); +} - for (list<string>::iterator i = files.cpls.begin(); i != files.cpls.end(); ++i) { +void +DCP::read_cpls (bool require_mxfs) +{ + for (list<string>::iterator i = _files.cpls.begin(); i != _files.cpls.end(); ++i) { _cpls.push_back (shared_ptr<CPL> (new CPL (_directory, *i, _asset_maps, require_mxfs))); } } @@ -69,15 +69,16 @@ public: */ DCP (std::string directory); - /** Read an existing DCP's data. + void read (bool require_mxfs = true); + + /** Read an existing DCP's assets. * * The DCP's XML metadata will be examined, and you can then look at the contents * of the DCP. - * - * @param require_mxfs true to throw an exception if MXF files are missing; setting to false - * can be useful for testing, but normally it should be set to true. */ - void read (bool require_mxfs = true); + void read_assets (); + + void read_cpls (bool require_mxfs = true); /** Write the required XML files to the directory that was * passed into the constructor. @@ -145,6 +146,8 @@ private: std::string asset_map; }; + Files _files; + /** the directory that we are writing to */ std::string _directory; /** our CPLs */ |
