Don't throw an exception on trying to create a KDM for
authorCarl Hetherington <cth@carlh.net>
Wed, 21 Sep 2016 21:23:06 +0000 (22:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 21 Sep 2016 21:23:06 +0000 (22:23 +0100)
a CPL with non-encrypted parts.

src/decrypted_kdm.cc

index 05ea73a383b3a34e4192bd0a75af45afbf82d1df..c9c5895174e9455dbcc5400c162c2ae91bc4be6a 100644 (file)
@@ -236,16 +236,19 @@ DecryptedKDM::DecryptedKDM (
        , _issue_date (issue_date)
 {
        /* Create DecryptedKDMKey objects for each encryptable asset */
+       bool did_one = false;
        BOOST_FOREACH(shared_ptr<const ReelAsset> i, cpl->reel_assets ()) {
                shared_ptr<const ReelMXF> mxf = boost::dynamic_pointer_cast<const ReelMXF> (i);
                shared_ptr<const ReelAsset> asset = boost::dynamic_pointer_cast<const ReelAsset> (i);
-               if (asset && mxf) {
-                       if (!mxf->key_id ()) {
-                               throw NotEncryptedError (asset->id ());
-                       }
+               if (asset && mxf && mxf->key_id ()) {
                        _keys.push_back (DecryptedKDMKey (mxf->key_type(), mxf->key_id().get(), key, cpl->id ()));
+                       did_one = true;
                }
        }
+
+       if (!did_one) {
+               throw NotEncryptedError (cpl->id ());
+       }
 }
 
 /** @param type (MDIK, MDAK etc.)