Hand-apply d849d411cff28ef5453085791d0b4d7cd73bd070 from master; replace all assert...
[dcpomatic.git] / src / lib / dcp_content.cc
index 9d4ee63887e9e5d4aecc7d8d167639cef314b226..2bf14dcffd77074229c9d9a6cbb01aaba9a62a6f 100644 (file)
 
 */
 
-#include <dcp/dcp.h>
-#include <dcp/exceptions.h>
 #include "dcp_content.h"
 #include "dcp_examiner.h"
 #include "job.h"
 #include "film.h"
 #include "config.h"
 #include "compose.hpp"
+#include <dcp/dcp.h>
+#include <dcp/exceptions.h>
 
 #include "i18n.h"
 
@@ -58,6 +58,9 @@ DCPContent::DCPContent (shared_ptr<const Film> f, cxml::ConstNodePtr node, int v
        _has_subtitles = node->bool_child ("HasSubtitles");
        _directory = node->string_child ("Directory");
        _encrypted = node->bool_child ("Encrypted");
+       if (node->optional_node_child ("KDM")) {
+               _kdm = dcp::EncryptedKDM (node->string_child ("KDM"));
+       }
        _kdm_valid = node->bool_child ("KDMValid");
 }
 
@@ -74,12 +77,12 @@ DCPContent::read_directory (boost::filesystem::path p)
 }
 
 void
-DCPContent::examine (shared_ptr<Job> job)
+DCPContent::examine (shared_ptr<Job> job, bool calculate_digest)
 {
        bool const could_be_played = can_be_played ();
                
        job->set_progress_unknown ();
-       Content::examine (job);
+       Content::examine (job, calculate_digest);
        
        shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ()));
        take_from_video_examiner (examiner);
@@ -126,7 +129,9 @@ DCPContent::as_xml (xmlpp::Node* node) const
        node->add_child("HasSubtitles")->add_child_text (_has_subtitles ? "1" : "0");
        node->add_child("Encrypted")->add_child_text (_encrypted ? "1" : "0");
        node->add_child("Directory")->add_child_text (_directory.string ());
-       /* XXX: KDM */
+       if (_kdm) {
+               node->add_child("KDM")->add_child_text (_kdm->as_xml ());
+       }
        node->add_child("KDMValid")->add_child_text (_kdm_valid ? "1" : "0");
 }
 
@@ -134,7 +139,7 @@ DCPTime
 DCPContent::full_length () const
 {
        shared_ptr<const Film> film = _film.lock ();
-       assert (film);
+       DCPOMATIC_ASSERT (film);
        return DCPTime (video_length (), FrameRateChange (video_frame_rate (), film->video_frame_rate ()));
 }