Fix incorrect free and leak.
[libdcp.git] / src / reel.cc
index 481b153b93176b6ace07f099d7b203dc367d5ad6..c8ea54ebca5be8a915857877d6328a00541c3243 100644 (file)
 
 */
 
+#include <libxml++/nodes/element.h>
 #include "reel.h"
 #include "util.h"
 #include "picture_asset.h"
 #include "sound_asset.h"
 #include "subtitle_asset.h"
+#include "kdm.h"
 
-using namespace std;
+using std::string;
+using std::list;
+using std::cout;
+using boost::shared_ptr;
 using namespace libdcp;
 
 void
@@ -79,3 +84,23 @@ Reel::equals (boost::shared_ptr<const Reel> other, EqualityOptions opt, boost::f
        return true;
 }
 
+bool
+Reel::encrypted () const
+{
+       return ((_main_picture && _main_picture->encrypted ()) || (_main_sound && _main_sound->encrypted ()));
+}
+
+void
+Reel::add_kdm (KDM const & kdm)
+{
+       list<KDMCipher> ciphers = kdm.ciphers ();
+       
+       for (list<KDMCipher>::iterator i = ciphers.begin(); i != ciphers.end(); ++i) {
+               if (i->key_id() == _main_picture->key_id()) {
+                       _main_picture->set_kdm_cipher (*i);
+               }
+               if (i->key_id() == _main_sound->key_id()) {
+                       _main_sound->set_kdm_cipher (*i);
+               }
+       }
+}