Report every frame (with index) that has a JPEG2000 codestream error (DoM #2698).
[libdcp.git] / src / verify.h
index 8eec9749c44c3a121bea8ea10fc12ea12f9f0c23..7bfe4217c5f934cc77ac8725003363ea0727bcd4 100644 (file)
 #define LIBDCP_VERIFY_H
 
 
+#include "decrypted_kdm.h"
 #include <boost/any.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/function.hpp>
 #include <boost/optional.hpp>
+#include <map>
 #include <string>
 #include <vector>
 
 
-/* Something in windows.h defines this */
+/* windows.h defines this but we want to use it */
 #undef ERROR
 
 
@@ -329,6 +331,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,
@@ -412,7 +415,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
                 */
@@ -436,7 +439,36 @@ public:
                /** An interop subtitle file has a <LoadFont> node which refers to a font file that is not found.
                 *  note contains the <LoadFont> ID
                 */
-               MISSING_FONT
+               MISSING_FONT,
+               /** A tile part in a JPEG2000 frame is too big.
+                *  frame contains the frame index (counted from 0)
+                *  component contains the component index (0, 1 or 2)
+                *  size contains the invalid size in bytes.
+                */
+               INVALID_JPEG2000_TILE_PART_SIZE,
+               /** A subtitle XML root node has more than one namespace (xmlns) declaration.
+                *  note contains the asset ID
+                */
+               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)
@@ -485,9 +517,15 @@ public:
 
 private:
        enum class Data {
-               NOTE, ///< further information about the error
-               FILE, ///< path of file containing the error
-               LINE  ///< error line number within the FILE
+               NOTE,  ///< further information about the error
+               FILE,  ///< path of file containing the error
+               LINE,  ///< error line number within the FILE
+               FRAME,
+               COMPONENT,
+               SIZE,
+               ID,
+               OTHER_ID,
+               FRAME_RATE
        };
 
        template <class T>
@@ -513,6 +551,60 @@ public:
                return data<uint64_t>(Data::LINE);
        }
 
+       VerificationNote& set_frame(int frame) {
+               _data[Data::FRAME] = frame;
+               return *this;
+       }
+
+       boost::optional<int> frame() const {
+               return data<int>(Data::FRAME);
+       }
+
+       VerificationNote& set_component(int component) {
+               _data[Data::COMPONENT] = component;
+               return *this;
+       }
+
+       boost::optional<int> component() const {
+               return data<int>(Data::COMPONENT);
+       }
+
+       VerificationNote& set_size(int size) {
+               _data[Data::SIZE] = size;
+               return *this;
+       }
+
+       boost::optional<int> size() const {
+               return data<int>(Data::SIZE);
+       }
+
+       VerificationNote& set_id(std::string id) {
+               _data[Data::ID] = id;
+               return *this;
+       }
+
+       boost::optional<std::string> id() const {
+               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);
+       }
+
 private:
        Type _type;
        Code _code;
@@ -532,6 +624,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 = {},