Add OK note when picture asset hashes are correct.
[libdcp.git] / src / verify.h
index 37a1fc11400fba8235faa4896e93ffd9039a27b0..339f418666152ed7d130996be2b433402e199f2a 100644 (file)
@@ -41,6 +41,7 @@
 #define LIBDCP_VERIFY_H
 
 
+#include "decrypted_kdm.h"
 #include <boost/any.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/function.hpp>
 namespace dcp {
 
 
+class DCP;
+
+
 class VerificationNote
 {
 public:
        enum class Type {
+               OK,
                ERROR,
                BV21_ERROR, ///< may not always be considered an error, but violates a "shall" requirement of Bv2.1
                WARNING
        };
 
-       /** Codes for errors or warnings from verifying DCPs.
+       /** Codes for successful checks, errors or warnings from verifying DCPs.
         *
         *  The names should (in general) answer the question "what is wrong?" with an answer that begins "There is a ..."
         *  e.g. "There is a INCORRECT_CPL_HASH"
@@ -97,17 +102,23 @@ public:
                 *  note contains (probably technical) details
                 */
                FAILED_READ,
+               MATCHING_CPL_HASHES,
                /** The hash of the CPL in the PKL does not agree with the CPL file
                 *  note contains CPL ID
                 *  file contains CPL filename
+                *  calculated_hash contains current hash of the CPL
+                *  reference_hash contains the hash written in the PKL
                 */
                MISMATCHED_CPL_HASHES,
                /** The frame rate given in a reel for the main picture is not 24, 25, 30, 48, 50 or 60
                 *  note contains the invalid frame rate as "<numerator>/<denominator>"
                 */
                INVALID_PICTURE_FRAME_RATE,
+               CORRECT_PICTURE_HASH,
                /** The hash of a main picture asset does not agree with the PKL file
                 *  file contains the picture asset filename
+                *  calculated_hash contains the current hash of the picture MXF
+                *  reference_hash contains the hash from the PKL
                 */
                INCORRECT_PICTURE_HASH,
                /** The hash of a main picture is different in the CPL and PKL
@@ -116,6 +127,8 @@ public:
                MISMATCHED_PICTURE_HASHES,
                /** The hash of a main sound asset does not agree with the PKL file
                 *  file contains the sound asset filename
+                *  calculated_hash contains the current hash of the picture MXF
+                *  reference_hash contains the hash from the PKL
                 */
                INCORRECT_SOUND_HASH,
                /** The hash of a main sound is different in the CPL and PKL
@@ -146,6 +159,7 @@ public:
                 *  note contains asset ID
                 */
                INVALID_DURATION,
+               VALID_PICTURE_FRAME_SIZES_IN_BYTES,
                /** The JPEG2000 data in at least one picture frame is larger than the equivalent of 250Mbit/s
                 *  file contains the picture asset filename
                 */
@@ -327,9 +341,14 @@ public:
                 *  file contains the PKL filename
                 */
                MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL,
+               /** All content is encrypted */
+               ALL_ENCRYPTED,
+               /** No content is encrypted */
+               NONE_ENCRYPTED,
                /** Some, but not all content, is encrypted */
                PARTIALLY_ENCRYPTED,
                /** General error during JPEG2000 codestream verification
+                *  frame contains the frame index (counted from 0)
                 *  note contains details
                 */
                INVALID_JPEG2000_CODESTREAM,
@@ -462,6 +481,11 @@ public:
                 *  other_id contains the ID from the file.
                 */
                MISMATCHED_ASSET_MAP_ID,
+               /** The <LabelText> inside a <ContentVersion> is empty
+                *  note contains the CPL ID
+                *  file contains the CPL filename
+                */
+               EMPTY_CONTENT_VERSION_LABEL_TEXT,
        };
 
        VerificationNote (Type type, Code code)
@@ -518,6 +542,10 @@ private:
                SIZE,
                ID,
                OTHER_ID,
+               FRAME_RATE,
+               CPL_ID,
+               CALCULATED_HASH,
+               REFERENCE_HASH
        };
 
        template <class T>
@@ -588,6 +616,42 @@ public:
                return data<std::string>(Data::OTHER_ID);
        }
 
+       VerificationNote& set_frame_rate(int frame_rate) {
+               _data[Data::FRAME_RATE] = frame_rate;
+               return *this;
+       }
+
+       boost::optional<int> frame_rate() const {
+               return data<int>(Data::FRAME_RATE);
+       }
+
+       VerificationNote& set_calculated_hash(std::string hash) {
+               _data[Data::CALCULATED_HASH] = hash;
+               return *this;
+       }
+
+       boost::optional<std::string> calculated_hash() const {
+               return data<std::string>(Data::CALCULATED_HASH);
+       }
+
+       VerificationNote& set_reference_hash(std::string hash) {
+               _data[Data::REFERENCE_HASH] = hash;
+               return *this;
+       }
+
+       boost::optional<std::string> reference_hash() const {
+               return data<std::string>(Data::REFERENCE_HASH);
+       }
+
+       VerificationNote& set_cpl_id(std::string id) {
+               _data[Data::CPL_ID] = id;
+               return *this;
+       }
+
+       boost::optional<std::string> cpl_id() const {
+               return data<std::string>(Data::CPL_ID);
+       }
+
 private:
        Type _type;
        Code _code;
@@ -605,10 +669,18 @@ struct VerificationOptions
 };
 
 
-std::vector<VerificationNote> verify (
+struct VerifyResult
+{
+       std::vector<VerificationNote> notes;
+       std::vector<std::shared_ptr<dcp::DCP>> dcps;
+};
+
+
+VerifyResult verify(
        std::vector<boost::filesystem::path> directories,
-       boost::function<void (std::string, boost::optional<boost::filesystem::path>)> stage,
-       boost::function<void (float)> progress,
+       std::vector<dcp::DecryptedKDM> kdms,
+       std::function<void (std::string, boost::optional<boost::filesystem::path>)> stage,
+       std::function<void (float)> progress,
        VerificationOptions options = {},
        boost::optional<boost::filesystem::path> xsd_dtd_directory = boost::optional<boost::filesystem::path>()
        );
@@ -616,6 +688,7 @@ std::vector<VerificationNote> verify (
 std::string note_to_string (dcp::VerificationNote note);
 
 bool operator== (dcp::VerificationNote const& a, dcp::VerificationNote const& b);
+bool operator!=(dcp::VerificationNote const& a, dcp::VerificationNote const& b);
 bool operator< (dcp::VerificationNote const& a, dcp::VerificationNote const& b);
 
 std::ostream& operator<<(std::ostream& s, dcp::VerificationNote const& note);