+ cxml::Document asset_map ("AssetMap");
+ asset_map.read_file (asset_map_file);
+ list<shared_ptr<cxml::Node> > asset_nodes = asset_map.node_child("AssetList")->node_children ("Asset");
+ map<string, boost::filesystem::path> paths;
+ for (list<shared_ptr<cxml::Node> >::const_iterator i = asset_nodes.begin(); i != asset_nodes.end(); ++i) {
+ if ((*i)->node_child("ChunkList")->node_children("Chunk").size() != 1) {
+ boost::throw_exception (XMLError ("unsupported asset chunk count"));
+ }
+ string p = (*i)->node_child("ChunkList")->node_child("Chunk")->string_child ("Path");
+ if (starts_with (p, "file://")) {
+ p = p.substr (7);
+ }
+ paths.insert (make_pair ((*i)->string_child ("Id"), p));
+ }
+
+ /* Read all the assets from the asset map */
+ /* XXX: I think we should be looking at the PKL here to decide type, not
+ the extension of the file.
+ */
+ for (map<string, boost::filesystem::path>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
+ boost::filesystem::path path = _directory / i->second;
+
+ if (!boost::filesystem::exists (path)) {
+ survivable_error (keep_going, errors, MissingAssetError (path));
+ continue;
+ }
+
+ if (boost::algorithm::ends_with (path.string(), ".xml")) {
+ xmlpp::DomParser* p = new xmlpp::DomParser;
+ try {
+ p->parse_file (path.string());
+ } catch (std::exception& e) {
+ delete p;
+ continue;
+ }
+
+ string const root = p->get_document()->get_root_node()->get_name ();
+ delete p;
+
+ if (root == "CompositionPlaylist") {
+ _assets.push_back (shared_ptr<CPL> (new CPL (path)));
+ } else if (root == "DCSubtitle") {
+ _assets.push_back (shared_ptr<InteropSubtitleContent> (new InteropSubtitleContent (path)));
+ }
+ } else if (boost::algorithm::ends_with (path.string(), ".mxf")) {
+ ASDCP::EssenceType_t type;
+ if (ASDCP::EssenceType (path.string().c_str(), type) != ASDCP::RESULT_OK) {
+ throw DCPReadError ("Could not find essence type");
+ }
+ switch (type) {
+ case ASDCP::ESS_UNKNOWN:
+ case ASDCP::ESS_MPEG2_VES:
+ throw DCPReadError ("MPEG2 video essences are not supported");
+ case ASDCP::ESS_JPEG_2000:
+ _assets.push_back (shared_ptr<MonoPictureMXF> (new MonoPictureMXF (path)));
+ break;
+ case ASDCP::ESS_PCM_24b_48k:
+ case ASDCP::ESS_PCM_24b_96k:
+ _assets.push_back (shared_ptr<SoundMXF> (new SoundMXF (path)));
+ break;
+ case ASDCP::ESS_JPEG_2000_S:
+ _assets.push_back (shared_ptr<StereoPictureMXF> (new StereoPictureMXF (path)));
+ break;
+ case ASDCP::ESS_TIMED_TEXT:
+ _assets.push_back (shared_ptr<SMPTESubtitleContent> (new SMPTESubtitleContent (path)));
+ break;
+ default:
+ throw DCPReadError ("Unknown MXF essence type");
+ }
+ }
+ }
+
+ list<shared_ptr<CPL> > cpl = cpls ();
+ for (list<shared_ptr<CPL> >::const_iterator i = cpl.begin(); i != cpl.end(); ++i) {
+ (*i)->resolve_refs (list_of_type<Asset, Object> (assets ()));
+ }
+}
+
+bool
+DCP::equals (DCP const & other, EqualityOptions opt, NoteHandler note) const
+{
+ list<shared_ptr<CPL> > a = cpls ();
+ list<shared_ptr<CPL> > b = other.cpls ();