/** 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)
/* 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;
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
)
);
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
)
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
)
);
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
)
);
(*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> ();
+}
namespace parse {
class AssetMap;
+ class AssetMapAsset;
}
class Asset;
{
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);
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;
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;
/* 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)));
}
}
}
}
}
+
+void
+DCP::add_assets_from (DCP const & ov)
+{
+ copy (ov._asset_maps.begin(), ov._asset_maps.end(), back_inserter (_asset_maps));
+}
class Encryption;
class KDM;
+namespace parse {
+ class AssetMap;
+}
+
/** @class DCP
* @brief A class to create or read a DCP.
*/
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 &);
*/
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 {
std::string _directory;
/** our CPLs */
std::list<boost::shared_ptr<CPL> > _cpls;
+
+ std::list<boost::shared_ptr<const parse::AssetMap> > _asset_maps;
};
}