diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-09-06 14:27:08 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-09-06 14:27:08 +0100 |
| commit | d406283ff669a33973b43839da6200d972d25f2a (patch) | |
| tree | e66d9f393a75cd87d3b342f951d646779a4d8d89 /src | |
| parent | 8f6f5c5c8f09d8aa880c3f2f29530744576212a1 (diff) | |
Somewhat experimental; read files to use from the ASSETMAP rather than scanning them.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dcp.cc | 132 | ||||
| -rw-r--r-- | src/dcp.h | 2 |
2 files changed, 60 insertions, 74 deletions
@@ -218,8 +218,67 @@ DCP::DCP (string directory, bool read_mxfs) : _directory (directory) { Files files; - scan (files, directory); + shared_ptr<AssetMap> asset_map; + try { + filesystem::path p = _directory; + p /= "ASSETMAP"; + if (filesystem::exists (p)) { + asset_map.reset (new AssetMap (p.string ())); + } else { + p = _directory; + p /= "ASSETMAP.xml"; + if (filesystem::exists (p)) { + asset_map.reset (new AssetMap (p.string ())); + } else { + throw DCPReadError ("could not find AssetMap file"); + } + } + + } catch (FileError& e) { + throw FileError ("could not load AssetMap file", files.asset_map); + } + + for (list<shared_ptr<AssetMapAsset> >::const_iterator i = asset_map->assets.begin(); i != asset_map->assets.end(); ++i) { + if ((*i)->chunks.size() != 1) { + throw XMLError ("unsupported asset chunk count"); + } + + filesystem::path t = _directory; + t /= (*i)->chunks.front()->path; + + if (ends_with (t.string(), ".mxf") || ends_with (t.string(), ".ttf")) { + continue; + } + + xmlpp::DomParser* p = new xmlpp::DomParser; + try { + p->parse_file (t.string()); + } catch (std::exception& e) { + delete p; + continue; + } + + string const root = p->get_document()->get_root_node()->get_name (); + delete p; + + if (root == "CompositionPlaylist") { + if (files.cpl.empty ()) { + files.cpl = t.string(); + } else { + throw DCPReadError ("duplicate CPLs found"); + } + } else if (root == "PackingList") { + if (files.pkl.empty ()) { + files.pkl = t.string(); + } else { + throw DCPReadError ("duplicate PKLs found"); + } + } else if (root == "DCSubtitle") { + files.subtitles.push_back (t.string()); + } + } + if (files.cpl.empty ()) { throw FileError ("no CPL file found", ""); } @@ -228,10 +287,6 @@ DCP::DCP (string directory, bool read_mxfs) throw FileError ("no PKL file found", ""); } - if (files.asset_map.empty ()) { - throw FileError ("no AssetMap file found", ""); - } - /* Read the XML */ shared_ptr<CPL> cpl; try { @@ -247,13 +302,6 @@ DCP::DCP (string directory, bool read_mxfs) throw FileError ("could not load PKL file", files.pkl); } - shared_ptr<AssetMap> asset_map; - try { - asset_map.reset (new AssetMap (files.asset_map)); - } catch (FileError& e) { - throw FileError ("could not load AssetMap file", files.asset_map); - } - /* Cross-check */ /* XXX */ @@ -351,66 +399,6 @@ DCP::DCP (string directory, bool read_mxfs) } } - -void -DCP::scan (Files& files, string directory) const -{ - for (filesystem::directory_iterator i = filesystem::directory_iterator(directory); i != filesystem::directory_iterator(); ++i) { - - string const t = i->path().string (); - - if (filesystem::is_directory (*i)) { - scan (files, t); - continue; - } - - if (ends_with (t, ".mxf") || ends_with (t, ".ttf")) { - continue; - } - - xmlpp::DomParser* p = new xmlpp::DomParser; - - try { - p->parse_file (t); - } catch (std::exception& e) { - delete p; - continue; - } - - if (!p) { - delete p; - continue; - } - - string const root = p->get_document()->get_root_node()->get_name (); - delete p; - - if (root == "CompositionPlaylist") { - if (files.cpl.empty ()) { - files.cpl = t; - } else { - throw DCPReadError ("duplicate CPLs found"); - } - } else if (root == "PackingList") { - if (files.pkl.empty ()) { - files.pkl = t; - } else { - throw DCPReadError ("duplicate PKLs found"); - } - } else if (root == "AssetMap") { - if (files.asset_map.empty ()) { - files.asset_map = t; - } else { - throw DCPReadError ("duplicate AssetMaps found"); - } - files.asset_map = t; - } else if (root == "DCSubtitle") { - files.subtitles.push_back (t); - } - } -} - - list<string> DCP::equals (DCP const & other, EqualityOptions opt) const { @@ -156,8 +156,6 @@ private: std::list<std::string> subtitles; }; - void scan (Files& files, std::string directory) const; - /** the directory that we are writing to */ std::string _directory; /** the name of the DCP */ |
