+ /* Check first that anything encrypted has a key. We must do this, as if we try to
+ * read encrypted data with asdcplib without even offering a key it will just return
+ * the encrypted data. Secondly, check that we can read the first thing from each
+ * asset in each reel. This checks that when we do have a key it's the right one.
+ */
+ try {
+ for (auto i: selected_cpl->reels()) {
+ LOG_GENERAL ("Reel %1", i->id());
+ if (i->main_picture() && i->main_picture()->asset_ref().resolved()) {
+ auto pic = i->main_picture()->asset();
+ if (pic->encrypted() && !pic->key()) {
+ _kdm_valid = false;
+ LOG_GENERAL_NC ("Picture has no key");
+ break;
+ }
+ auto mono = dynamic_pointer_cast<dcp::MonoPictureAsset>(pic);
+ auto stereo = dynamic_pointer_cast<dcp::StereoPictureAsset>(pic);
+
+ if (mono) {
+ auto reader = mono->start_read();
+ reader->set_check_hmac (false);
+ reader->get_frame(0)->xyz_image();
+ } else {
+ auto reader = stereo->start_read();
+ reader->set_check_hmac (false);
+ reader->get_frame(0)->xyz_image(dcp::Eye::LEFT);
+ }