- dcp::DCP dcp (c->directory ());
- dcp.read ();
- if (c->kdm ()) {
- dcp.add (dcp::DecryptedKDM (c->kdm().get (), Config::instance()->decryption_chain()->key().get ()));
+ if (c->video) {
+ video.reset (new VideoDecoder (this, c, log));
+ }
+ if (c->audio) {
+ audio.reset (new AudioDecoder (this, c->audio, log, fast));
+ }
+ if (c->subtitle) {
+ /* XXX: this time here should be the time of the first subtitle, not 0 */
+ subtitle.reset (new TextDecoder (this, c->subtitle, log, ContentTime()));
+ }
+
+ list<shared_ptr<dcp::CPL> > cpl_list = cpls ();
+
+ if (cpl_list.empty()) {
+ throw DCPError (_("No CPLs found in DCP."));
+ }
+
+ shared_ptr<dcp::CPL> cpl;
+ BOOST_FOREACH (shared_ptr<dcp::CPL> i, cpl_list) {
+ if (_dcp_content->cpl() && i->id() == _dcp_content->cpl().get()) {
+ cpl = i;
+ }
+ }
+
+ if (!cpl) {
+ /* No CPL found; probably an old file that doesn't specify it;
+ just use the first one.
+ */
+ cpl = cpls().front ();