Hack; separate DCP asset and CPL reads.
authorCarl Hetherington <cth@carlh.net>
Fri, 30 Aug 2013 21:29:22 +0000 (22:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 30 Aug 2013 21:29:22 +0000 (22:29 +0100)
src/dcp.cc
src/dcp.h

index 9bed7e938185eb0658d19b4d59912aa771d1e775..234c134e71b5f0b1d0bff08f008426c33d94b82c 100644 (file)
@@ -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)));
        }
 }
index 8086f4de21177eeed67bd578e94a1449c8327ce6..7da08eff716e7659909d958aca489cb72918e61a 100644 (file)
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -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 */