4d65fae70442f184aed7f63f5ae6a4b76980b7d8
[libdcp.git] / src / verify.h
1 /*
2     Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     libdcp is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
18
19     In addition, as a special exception, the copyright holders give
20     permission to link the code of portions of this program with the
21     OpenSSL library under certain conditions as described in each
22     individual source file, and distribute linked combinations
23     including the two.
24
25     You must obey the GNU General Public License in all respects
26     for all of the code used other than OpenSSL.  If you modify
27     file(s) with this exception, you may extend this exception to your
28     version of the file(s), but you are not obligated to do so.  If you
29     do not wish to do so, delete this exception statement from your
30     version.  If you delete this exception statement from all source
31     files in the program, then also delete it here.
32 */
33
34
35 /** @file  src/verify.h
36  *  @brief dcp::verify() method and associated code
37  */
38
39
40 #ifndef LIBDCP_VERIFY_H
41 #define LIBDCP_VERIFY_H
42
43
44 #include <boost/any.hpp>
45 #include <boost/filesystem.hpp>
46 #include <boost/function.hpp>
47 #include <boost/optional.hpp>
48 #include <string>
49 #include <vector>
50
51
52 /* Something in windows.h defines this */
53 #undef ERROR
54
55
56 namespace dcp {
57
58
59 class VerificationNote
60 {
61 public:
62         enum class Type {
63                 ERROR,
64                 BV21_ERROR, ///< may not always be considered an error, but violates a "shall" requirement of Bv2.1
65                 WARNING
66         };
67
68         /** Codes for errors or warnings from verifying DCPs.
69          *
70          *  The names should (in general) answer the question "what is wrong?" with an answer that begins "There is a ..."
71          *  e.g. "There is a INCORRECT_CPL_HASH"
72          *       "There is a MISSING_ASSET"
73          *
74          *  In general the pattern should be <negative-adjective> <noun>.
75          *  Some <negative-adjective>s are:
76          *
77          *  - INCORRECT: something, which could have any value, is wrong.
78          *  - INVALID: something, which should only be one of a set of values, is not in the set, or some preformatted
79          *             quantity (e.g. XML) is in the wrong format.
80          *  - MISMATCHED: two things, which should be the same, are not.
81          *  - EMPTY: something, which should have a value, has no value.
82          *  - MISSING: something, which should be present, is not.
83          *  - UNEXPECTED: something, which is present, should not be.
84          *  - FAILED: some part of the verification failed in some serious way.
85          *
86          *  Comments should clarify meaning and also say which of the optional fields (e.g. file)
87          *  are filled in when this code is used.
88          */
89
90         // If you change the next line, also look in doc/manual/verifier.py in DCP-o-matic
91         // as it looks for it when compiling the manual.  Also, in this enum:
92         //   [...]  will be taken as a reference to a section of Bv2.1
93         //   _foo_  means foo should be written as a piece of code
94         enum class Code {
95                 /** A general error when reading the DCP
96                  *  note contains (probably technical) details
97                  */
98                 FAILED_READ,
99                 /** The hash of the CPL in the PKL does not agree with the CPL file
100                  *  note contains CPL ID
101                  *  file contains CPL filename
102                  */
103                 MISMATCHED_CPL_HASHES,
104                 /** The frame rate given in a reel for the main picture is not 24, 25, 30, 48, 50 or 60
105                  *  note contains the invalid frame rate as "<numerator>/<denominator>"
106                  */
107                 INVALID_PICTURE_FRAME_RATE,
108                 /** The hash of a main picture asset does not agree with the PKL file
109                  *  file contains the picture asset filename
110                  */
111                 INCORRECT_PICTURE_HASH,
112                 /** The hash of a main picture is different in the CPL and PKL
113                  *  file contains the picture asset filename
114                  */
115                 MISMATCHED_PICTURE_HASHES,
116                 /** The hash of a main sound asset does not agree with the PKL file
117                  *  file contains the sound asset filename
118                  */
119                 INCORRECT_SOUND_HASH,
120                 /** The hash of a main sound is different in the CPL and PKL
121                  *  file contains the sound asset filename
122                  */
123                 MISMATCHED_SOUND_HASHES,
124                 /** An assetmap's _<Path>_ entry is empty */
125                 EMPTY_ASSET_PATH,
126                 /** A file mentioned in an asset map cannot be found
127                  *  file contains the filename that is missing
128                  */
129                 MISSING_ASSET,
130                 /** The DCP contains both SMPTE and Interop-standard components */
131                 MISMATCHED_STANDARD,
132                 /** Some XML fails to validate against its XSD/DTD
133                  *  note contains the (probably technical) details
134                  *  file contains the invalid filename
135                  *  line contains the line number
136                  */
137                 INVALID_XML,
138                 /** No _ASSETMAP_ or _ASSETMAP.xml_ was found */
139                 MISSING_ASSETMAP,
140                 /** An asset's _IntrinsicDuration_ is less than 1 second
141                  *  note contains asset ID
142                  */
143                 INVALID_INTRINSIC_DURATION,
144                 /** An asset's _Duration_ is less than 1 second
145                  *  note contains asset ID
146                  */
147                 INVALID_DURATION,
148                 /** The JPEG2000 data in at least one picture frame is larger than the equivalent of 250Mbit/s
149                  *  file contains the picture asset filename
150                  */
151                 INVALID_PICTURE_FRAME_SIZE_IN_BYTES,
152                 /** The JPEG2000 data in at least one picture frame is larger than the equivalent of 230Mbit/s
153                  *  file contains the picture asset filename
154                  */
155                 NEARLY_INVALID_PICTURE_FRAME_SIZE_IN_BYTES,
156                 /** An asset that the CPL requires is not in this DCP; the DCP may be a VF
157                  *  note contains the asset ID
158                  */
159                 EXTERNAL_ASSET,
160                 /** A stereoscopic asset has an MXF which is marked as being monoscopic
161                  *  file contains the asset filename
162                  */
163                 THREED_ASSET_MARKED_AS_TWOD,
164                 /** DCP is Interop, not SMPTE [Bv2.1_6.1] */
165                 INVALID_STANDARD,
166                 /** A language or territory does not conform to RFC 5646 [Bv2.1_6.2.1]
167                  *  note contains the invalid language
168                  */
169                 INVALID_LANGUAGE,
170                 /** A picture asset does not have one of the required Bv2.1 sizes (in pixels) [Bv2.1_7.1]
171                  *  note contains the incorrect size as "<width>x<height>"
172                  *  file contains the asset filename
173                  */
174                 INVALID_PICTURE_SIZE_IN_PIXELS,
175                 /** A picture asset is 2K but is not at 24, 25 or 48 fps as required by Bv2.1 [Bv2.1_7.1]
176                  *  note contains the invalid frame rate as "<numerator>/<denominator>"
177                  *  file contains the asset filename
178                  */
179                 INVALID_PICTURE_FRAME_RATE_FOR_2K,
180                 /** A picture asset is 4K but is not at 24fps as required by Bv2.1 [Bv2.1_7.1]
181                  *  note contains the invalid frame rate as "<numerator>/<denominator>"
182                  *  file contains the asset filename
183                  */
184                 INVALID_PICTURE_FRAME_RATE_FOR_4K,
185                 /** A picture asset is 4K but is 3D which is not allowed by Bv2.1 [Bv2.1_7.1]
186                  *  note contains the invalid frame rate as "<numerator>/<denominator>"
187                  *  file contains the asset filename
188                  */
189                 INVALID_PICTURE_ASSET_RESOLUTION_FOR_3D,
190                 /** A closed caption's XML file is larger than 256KB [Bv2.1_7.2.1]
191                  *  note contains the invalid size in bytes
192                  *  file contains the asset filename
193                  */
194                 INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES,
195                 /** Any timed text asset's total files is larger than 115MB [Bv2.1_7.2.1]
196                  *  note contains the invalid size in bytes
197                  *  file contains the asset filename
198                  */
199                 INVALID_TIMED_TEXT_SIZE_IN_BYTES,
200                 /** The total size of all a timed text asset's fonts is larger than 10MB [Bv2.1_7.2.1]
201                  *  note contains the invalid size in bytes
202                  *  file contains the asset filename
203                  */
204                 INVALID_TIMED_TEXT_FONT_SIZE_IN_BYTES,
205                 /** Some SMPTE subtitle XML has no _<Language>_ tag [Bv2.1_7.2.2]
206                  *  file contains the asset filename
207                  */
208                 MISSING_SUBTITLE_LANGUAGE,
209                 /** Not all subtitle assets specify the same _<Language>_ tag [Bv2.1_7.2.2] */
210                 MISMATCHED_SUBTITLE_LANGUAGES,
211                 /** Some SMPTE subtitle XML has no _<StartTime>_ tag [Bv2.1_7.2.3]
212                  *  file contains the asset filename
213                  */
214                 MISSING_SUBTITLE_START_TIME,
215                 /** Some SMPTE subtitle XML has a non-zero _<StartTime>_ tag [Bv2.1_7.2.3]
216                  *  file contains the asset filename
217                  */
218                 INVALID_SUBTITLE_START_TIME,
219                 /** The first subtitle or closed caption happens before 4s into the first reel [Bv2.1_7.2.4] */
220                 INVALID_SUBTITLE_FIRST_TEXT_TIME,
221                 /** At least one subtitle is less than the minimum of 15 frames suggested by [Bv2.1_7.2.5] */
222                 INVALID_SUBTITLE_DURATION,
223                 /** At least one pair of subtitles are separated by less than the the minimum of 2 frames suggested by [Bv2.1_7.2.5] */
224                 INVALID_SUBTITLE_SPACING,
225                 /** A subtitle lasts for longer than the reel which contains it */
226                 SUBTITLE_OVERLAPS_REEL_BOUNDARY,
227                 /** There are more than 3 subtitle lines in at least one place [Bv2.1_7.2.7] */
228                 INVALID_SUBTITLE_LINE_COUNT,
229                 /** There are more than 52 characters in at least one subtitle line [Bv2.1_7.2.7] */
230                 NEARLY_INVALID_SUBTITLE_LINE_LENGTH,
231                 /** There are more than 79 characters in at least one subtitle line [Bv2.1_7.2.7] */
232                 INVALID_SUBTITLE_LINE_LENGTH,
233                 /** There are more than 3 closed caption lines in at least one place [Bv2.1_7.2.6] */
234                 INVALID_CLOSED_CAPTION_LINE_COUNT,
235                 /** There are more than 32 characters in at least one closed caption line [Bv2.1_7.2.6] */
236                 INVALID_CLOSED_CAPTION_LINE_LENGTH,
237                 /** The audio sampling rate must be 48kHz [Bv2.1_7.3]
238                  *  note contains the invalid frame rate
239                  *  file contains the asset filename
240                  */
241                 INVALID_SOUND_FRAME_RATE,
242                 /** The CPL has no _<AnnotationText>_ tag [Bv2.1_8.1]
243                  *  note contains the CPL ID
244                  *  file contains the CPL filename
245                  */
246                 MISSING_CPL_ANNOTATION_TEXT,
247                 /** The _<AnnotationText>_ is not the same as the _<ContentTitleText>_ [Bv2.1_8.1]
248                  *  note contains the CPL ID
249                  *  file contains the CPL filename
250                  */
251                 MISMATCHED_CPL_ANNOTATION_TEXT,
252                 /** At least one asset in a reel does not have the same duration as the others */
253                 MISMATCHED_ASSET_DURATION,
254                 /** If one reel has a _MainSubtitle_, all must have them */
255                 MISSING_MAIN_SUBTITLE_FROM_SOME_REELS,
256                 /** If one reel has at least one _ClosedCaption_, all reels must have the same number of _ClosedCaptions_ */
257                 MISMATCHED_CLOSED_CAPTION_ASSET_COUNTS,
258                 /** MainSubtitle in reels must have _<EntryPoint>_ [Bv2.1_8.3.2]
259                  *  note contains the asset ID
260                  */
261                 MISSING_SUBTITLE_ENTRY_POINT,
262                 /** MainSubtitle _<EntryPoint>_ must be zero [Bv2.1_8.3.2]
263                  *  note contains the asset ID
264                  */
265                 INCORRECT_SUBTITLE_ENTRY_POINT,
266                 /** Closed caption in reels must have _<EntryPoint>_ [Bv2.1_8.3.2]
267                  *  note contains the asset ID
268                  */
269                 MISSING_CLOSED_CAPTION_ENTRY_POINT,
270                 /** Closed caption _MainSubtitle_ _<EntryPoint>_ must be zero [Bv2.1_8.3.2]
271                  *  note contains the asset ID
272                  */
273                 INCORRECT_CLOSED_CAPTION_ENTRY_POINT,
274                 /** _<Hash>_ must be present for assets in CPLs
275                  * note contains the asset ID
276                  */
277                 MISSING_HASH,
278                 /** If _ContentKind_ is Feature there must be a FFEC marker */
279                 MISSING_FFEC_IN_FEATURE,
280                 /** If _ContentKind_ is Feature there must be a FFMC marker */
281                 MISSING_FFMC_IN_FEATURE,
282                 /** There should be a FFOC marker */
283                 MISSING_FFOC,
284                 /** There should be a LFOC marker */
285                 MISSING_LFOC,
286                 /** The FFOC marker should be 1
287                  *  note contains the incorrect value.
288                  */
289                 INCORRECT_FFOC,
290                 /** The LFOC marker should be the last frame in the reel
291                  *  note contains the incorrect value
292                  */
293                 INCORRECT_LFOC,
294                 /** There must be a _<CompositionMetadataAsset>_
295                  *  note contains the CPL ID
296                  *  file contains the CPL filename
297                  */
298                 MISSING_CPL_METADATA,
299                 /** CPL metadata should contain _<VersionNumber>_ of 1, at least
300                  *  note contains the CPL ID
301                  *  file contains the CPL filename
302                  */
303                 MISSING_CPL_METADATA_VERSION_NUMBER,
304                 /** There must be an _<ExtensionMetadata>_ in _<CompositionMetadataAsset>_ [Bv2.1_8.6.3]
305                  *  note contains the CPL ID
306                  *  file contains the CPL filename
307                  */
308                 MISSING_EXTENSION_METADATA,
309                 /** _<ExtensionMetadata>_ does not have the correct form [Bv2.1_8.6.3]
310                  *  note contains details of what's wrong
311                  *  file contains the CPL filename
312                  */
313                 INVALID_EXTENSION_METADATA,
314                 /** A CPL containing encrypted content is not signed [Bv2.1_8.7]
315                  *  note contains the CPL ID
316                  *  file contains the CPL filename
317                  */
318                 UNSIGNED_CPL_WITH_ENCRYPTED_CONTENT,
319                 /** A PKL containing encrypted content is not signed [Bv2.1_8.7]
320                  *  note contains the PKL ID
321                  *  file contains the PKL filename
322                  */
323                 UNSIGNED_PKL_WITH_ENCRYPTED_CONTENT,
324                 /** If a PKL has one CPL its _<ContentTitleText>_ must be the same as the PKL's _<AnnotationText>_
325                  *  note contains the PKL ID
326                  *  file contains the PKL filename
327                  */
328                 MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL,
329                 /** Some, but not all content, is encrypted */
330                 PARTIALLY_ENCRYPTED,
331                 /** General error during JPEG2000 codestream verification
332                  *  note contains details
333                  */
334                 INVALID_JPEG2000_CODESTREAM,
335                 /** Invalid number of guard bits in a 2K JPEG2000 stream (should be 1) [Bv2.1_10.2.1]
336                  *  note contains the number of guard bits
337                  */
338                 INVALID_JPEG2000_GUARD_BITS_FOR_2K,
339                 /** Invalid number of guard bits in a 4K JPEG2000 stream (should be 2) [Bv2.1_10.2.1]
340                  *  note contains the number of guard bits
341                  */
342                 INVALID_JPEG2000_GUARD_BITS_FOR_4K,
343                 /** JPEG2000 tile size is not the same as the image size [Bv2.1_10.2.1] */
344                 INVALID_JPEG2000_TILE_SIZE,
345                 /** JPEG2000 code block width is not 32 [Bv2.1_10.2.1]
346                  *  note contains the code block width
347                  */
348                 INVALID_JPEG2000_CODE_BLOCK_WIDTH,
349                 /** JPEG2000 code block height is not 32 [Bv2.1_10.2.1]
350                  *  note contains the code block height
351                  */
352                 INVALID_JPEG2000_CODE_BLOCK_HEIGHT,
353                 /** There must be no POC markers in a 2K codestream [Bv2.1_10.2.1]
354                  *  note contains the number of POC markers found
355                  */
356                 INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_2K,
357                 /** There must be exactly one POC marker in a 4K codestream [Bv2.1_10.2.1]
358                  *  note contains the number of POC markers found
359                  */
360                 INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_4K,
361                 /** A POC marker has incorrect content [Bv2.1_10.2.1]
362                  *  note contains details
363                  */
364                 INCORRECT_JPEG2000_POC_MARKER,
365                 /** A POC marker was found outside the main head [Bv2.1_10.2.1] */
366                 INVALID_JPEG2000_POC_MARKER_LOCATION,
367                 /** Invalid number of tile parts for 2K JPEG2000 stream (should be 3) [Bv2.1_10.2.1]
368                  *  note contains the number of tile parts
369                  */
370                 INVALID_JPEG2000_TILE_PARTS_FOR_2K,
371                 /** Invalid number of tile parts for 4K JPEG2000 stream (should be 6) [Bv2.1_10.2.1]
372                  *  note contains the number of tile parts
373                  */
374                 INVALID_JPEG2000_TILE_PARTS_FOR_4K,
375                 /** No TLM marker was found [Bv2.1_10.2.1] */
376                 MISSING_JPEG200_TLM_MARKER,
377                 /** The MXF _ResourceID_ of a timed text resource was not the same as that of the contained XML essence [Bv2.1_10.4.3] */
378                 MISMATCHED_TIMED_TEXT_RESOURCE_ID,
379                 /** The AssetID of a timed text MXF is the same as its _ResourceID_ or that of the contained XML essence [Bv2.1_10.4.2] */
380                 INCORRECT_TIMED_TEXT_ASSET_ID,
381                 /** The ContainerDuration of a timed text MXF is not the same as the _Duration_ in its reel [Bv2.1_10.4.3]
382                  *  note contains the reel duration, followed by a space, followed by the MXF duration
383                  *  file contains the asset filename
384                  */
385                 MISMATCHED_TIMED_TEXT_DURATION,
386                 /** Something could not be verified because content is encrypted and no key is available */
387                 MISSED_CHECK_OF_ENCRYPTED,
388                 /** Some timed-text XML has an empty <_Text_> node */
389                 EMPTY_TEXT,
390                 /** Some closed captions do not have the same vertical alignment within a <_Subtitle_> node */
391                 MISMATCHED_CLOSED_CAPTION_VALIGN,
392                 /** Some closed captions are not listed in the XML in the order of their vertical position */
393                 INCORRECT_CLOSED_CAPTION_ORDERING,
394                 /** Some <MainMarkers> asset has an <EntryPoint> that should not be there */
395                 UNEXPECTED_ENTRY_POINT,
396                 /** Some <MainMarkers> asset has an <Duration> that should not be there */
397                 UNEXPECTED_DURATION,
398                 /** A <ContentKind> has been specified with either no scope or the SMPTE 429-7 scope, but which is not one of those allowed */
399                 INVALID_CONTENT_KIND,
400                 /** Either the width or height of a <MainPictureActiveArea> in a CPL is either not an even number, or bigger than the corresponding asset dimension.
401                  *  note contains details of what is wrong
402                  *  file contains the CPL filename
403                  */
404                 INVALID_MAIN_PICTURE_ACTIVE_AREA,
405                 /** A PKL has more than one asset with the same ID
406                  *  note contains the PKL ID
407                  *  file contains the PKL filename
408                  */
409                 DUPLICATE_ASSET_ID_IN_PKL,
410                 /** An ASSETMAP has more than one asset with the same ID
411                  *  note contains the ASSETMAP ID
412                  *  file contains the ASSETMAP filename
413                  */
414                 DUPLICATE_ASSET_ID_IN_ASSETMAP,
415                 /** An Interop subtitle asset has no subtitles.
416                  *  note contains the asset ID
417                  *  file contains the asset filename
418                  */
419                 MISSING_SUBTITLE,
420                 /** A SMPTE subtitle asset as an <IssueDate> which is not of the form yyyy-mm-ddThh:mm:ss
421                  *  I can find no reference in a standard to this being required, but the Deluxe delivery
422                  *  specifications require it and their QC will fail DCPs that don't have it.
423                  *  note contains the incorrect <IssueDate>
424                  */
425                 INVALID_SUBTITLE_ISSUE_DATE,
426                 /** The sound assets in the CPL do not have the same audio channel count.
427                  *  file contains the filename of the first asset to differ
428                  */
429                 MISMATCHED_SOUND_CHANNEL_COUNTS,
430                 /** The CPL contains a MainSoundConfiguration tag which does not describe the number of
431                  *  channels in the audio assets.
432                  *  note contains details of what is wrong
433                  *  file contains the CPL filename
434                  */
435                 INVALID_MAIN_SOUND_CONFIGURATION,
436                 /** An interop subtitle file has a <LoadFont> node which refers to a font file that is not found.
437                  *  note contains the <LoadFont> ID
438                  */
439                 MISSING_FONT,
440                 /** A tile part in a JPEG2000 frame is too big.
441                  *  frame contains the frame index (counted from 0)
442                  *  component contains the component index (0, 1 or 2)
443                  *  size contains the invalid size in bytes.
444                  */
445                 INVALID_JPEG2000_TILE_PART_SIZE,
446         };
447
448         VerificationNote (Type type, Code code)
449                 : _type (type)
450                 , _code (code)
451         {}
452
453         VerificationNote (Type type, Code code, std::string note)
454                 : _type (type)
455                 , _code (code)
456         {
457                 _data[Data::NOTE] = note;
458         }
459
460         VerificationNote (Type type, Code code, boost::filesystem::path file)
461                 : _type (type)
462                 , _code (code)
463         {
464                 _data[Data::FILE] = file;
465         }
466
467         VerificationNote (Type type, Code code, std::string note, boost::filesystem::path file)
468                 : _type (type)
469                 , _code (code)
470         {
471                 _data[Data::NOTE] = note;
472                 _data[Data::FILE] = file;
473         }
474
475         VerificationNote (Type type, Code code, std::string note, boost::filesystem::path file, uint64_t line)
476                 : _type (type)
477                 , _code (code)
478         {
479                 _data[Data::NOTE] = note;
480                 _data[Data::FILE] = file;
481                 _data[Data::LINE] = line;
482         }
483
484         Type type () const {
485                 return _type;
486         }
487
488         Code code () const {
489                 return _code;
490         }
491
492 private:
493         enum class Data {
494                 NOTE,  ///< further information about the error
495                 FILE,  ///< path of file containing the error
496                 LINE,  ///< error line number within the FILE
497                 FRAME,
498                 COMPONENT,
499                 SIZE,
500         };
501
502         template <class T>
503         boost::optional<T> data(Data key) const
504         {
505                 auto iter = _data.find(key);
506                 if (iter == _data.end()) {
507                         return {};
508                 }
509                 return boost::any_cast<T>(iter->second);
510         }
511
512 public:
513         boost::optional<std::string> note () const {
514                 return data<std::string>(Data::NOTE);
515         }
516
517         boost::optional<boost::filesystem::path> file () const {
518                 return data<boost::filesystem::path>(Data::FILE);
519         }
520
521         boost::optional<uint64_t> line () const {
522                 return data<uint64_t>(Data::LINE);
523         }
524
525         VerificationNote& set_frame(int frame) {
526                 _data[Data::FRAME] = frame;
527                 return *this;
528         }
529
530         boost::optional<int> frame() const {
531                 return data<int>(Data::FRAME);
532         }
533
534         VerificationNote& set_component(int component) {
535                 _data[Data::COMPONENT] = component;
536                 return *this;
537         }
538
539         boost::optional<int> component() const {
540                 return data<int>(Data::COMPONENT);
541         }
542
543         VerificationNote& set_size(int size) {
544                 _data[Data::SIZE] = size;
545                 return *this;
546         }
547
548         boost::optional<int> size() const {
549                 return data<int>(Data::SIZE);
550         }
551
552 private:
553         Type _type;
554         Code _code;
555         std::map<Data, boost::any> _data;
556 };
557
558
559 struct VerificationOptions
560 {
561         ///< If set, any assets larger than this number of bytes will not have their hashes checked
562         boost::optional<boost::uintmax_t> maximum_asset_size_for_hash_check;
563         ///< true to check asset hashes (except those which match maximum_asset_size_for_hash_check)
564         ///< false to check no asset hashes.
565         bool check_asset_hashes = true;
566 };
567
568
569 std::vector<VerificationNote> verify (
570         std::vector<boost::filesystem::path> directories,
571         boost::function<void (std::string, boost::optional<boost::filesystem::path>)> stage,
572         boost::function<void (float)> progress,
573         VerificationOptions options = {},
574         boost::optional<boost::filesystem::path> xsd_dtd_directory = boost::optional<boost::filesystem::path>()
575         );
576
577 std::string note_to_string (dcp::VerificationNote note);
578
579 bool operator== (dcp::VerificationNote const& a, dcp::VerificationNote const& b);
580 bool operator< (dcp::VerificationNote const& a, dcp::VerificationNote const& b);
581
582 std::ostream& operator<<(std::ostream& s, dcp::VerificationNote const& note);
583
584
585 }
586
587
588 #endif