Note correct/incorrect hashes when the verifier raises related errors.
[libdcp.git] / src / verify.h
index 08a24227ab1cc97d7799114772e734ad73c81014..4ca3297ac582d1b01c9f541d7f812b2d320414df 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>
@@ -50,7 +51,7 @@
 #include <vector>
 
 
-/* Something in windows.h defines this */
+/* windows.h defines this but we want to use it */
 #undef ERROR
 
 
@@ -100,6 +101,8 @@ public:
                /** 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
@@ -108,6 +111,8 @@ public:
                INVALID_PICTURE_FRAME_RATE,
                /** 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 +121,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
@@ -330,6 +337,7 @@ public:
                /** 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,
@@ -413,7 +421,7 @@ public:
                 *  file contains the ASSETMAP filename
                 */
                DUPLICATE_ASSET_ID_IN_ASSETMAP,
-               /** An Interop subtitle asset has no subtitles.
+               /** An Interop subtitle asset has no subtitles
                 *  note contains the asset ID
                 *  file contains the asset filename
                 */
@@ -447,7 +455,26 @@ public:
                /** A subtitle XML root node has more than one namespace (xmlns) declaration.
                 *  note contains the asset ID
                 */
-               INCORRECT_SUBTITLE_NAMESPACE_COUNT
+               INCORRECT_SUBTITLE_NAMESPACE_COUNT,
+               /** A subtitle or closed caption file has a <Font> tag which refers to a font that is not
+                *  first introduced with a <LoadFont>.
+                *  id contains the ID of the <Font> tag.
+                */
+               MISSING_LOAD_FONT_FOR_FONT,
+               /** A SMPTE subtitle asset has at least one <Text> element but no <LoadFont>
+                *  id contains the ID of the subtitle asset.
+                */
+               MISSING_LOAD_FONT,
+               /** An ID in an asset map does not match the ID obtained from reading the actual file.
+                *  id contains the ID from the asset map.
+                *  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)
@@ -503,6 +530,10 @@ private:
                COMPONENT,
                SIZE,
                ID,
+               OTHER_ID,
+               FRAME_RATE,
+               CALCULATED_HASH,
+               REFERENCE_HASH
        };
 
        template <class T>
@@ -564,6 +595,42 @@ public:
                return data<std::string>(Data::ID);
        }
 
+       VerificationNote& set_other_id(std::string other_id) {
+               _data[Data::OTHER_ID] = other_id;
+               return *this;
+       }
+
+       boost::optional<std::string> other_id() const {
+               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);
+       }
+
 private:
        Type _type;
        Code _code;
@@ -583,6 +650,7 @@ struct VerificationOptions
 
 std::vector<VerificationNote> verify (
        std::vector<boost::filesystem::path> directories,
+       std::vector<dcp::DecryptedKDM> kdms,
        boost::function<void (std::string, boost::optional<boost::filesystem::path>)> stage,
        boost::function<void (float)> progress,
        VerificationOptions options = {},