+
+ _encrypted = cpl->encrypted ();
+ _kdm_valid = true;
+
+ /* Check that we can read the first picture frame */
+ try {
+ if (!cpl->reels().empty ()) {
+ shared_ptr<dcp::PictureAsset> asset = cpl->reels().front()->main_picture()->asset ();
+ shared_ptr<dcp::MonoPictureAsset> mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (asset);
+ shared_ptr<dcp::StereoPictureAsset> stereo = dynamic_pointer_cast<dcp::StereoPictureAsset> (asset);
+
+ if (mono) {
+ mono->start_read()->get_frame(0)->xyz_image ();
+ } else {
+ stereo->start_read()->get_frame(0)->xyz_image (dcp::EYE_LEFT);
+ }
+
+ }
+ } catch (dcp::DCPReadError& e) {
+ _kdm_valid = false;
+ if (_encrypted && content->kdm ()) {
+ /* XXX: maybe don't use an exception for this */
+ throw runtime_error (_("The KDM does not decrypt the DCP. Perhaps it is targeted at the wrong CPL."));
+ }
+ }
+
+ DCPOMATIC_ASSERT (cpl->standard ());
+ _standard = cpl->standard().get();
+ _three_d = !cpl->reels().empty() && cpl->reels().front()->main_picture() &&
+ dynamic_pointer_cast<dcp::StereoPictureAsset> (cpl->reels().front()->main_picture()->asset());
+
+ _cpl = cpl->id ();