libdcp
verify_internal.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2024 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 
43 #ifndef LIBDCP_VERIFY_INTERNAL_H
44 #define LIBDCP_VERIFY_INTERNAL_H
45 
46 
47 #include "cpl.h"
48 #include "verify.h"
49 #include <boost/filesystem.hpp>
50 #include <boost/optional.hpp>
51 #include <memory>
52 #include <vector>
53 
54 
55 namespace dcp {
56 
57 class TextAsset;
58 
60 {
61  bool warning_length_exceeded = false;
62  bool error_length_exceeded = false;
63  bool line_count_exceeded = false;
64 };
65 
66 
68  std::shared_ptr<const dcp::TextAsset> asset,
69  int warning_length,
70  int error_length,
72  );
73 
74 
75 class Context
76 {
77 public:
78  Context(
79  std::vector<VerificationNote>& notes_,
80  boost::filesystem::path xsd_dtd_directory_,
81  std::function<void (std::string, boost::optional<boost::filesystem::path>)> stage_,
82  std::function<void (float)> progress_,
83  VerificationOptions options_
84  )
85  : notes(notes_)
86  , xsd_dtd_directory(xsd_dtd_directory_)
87  , stage(stage_)
88  , progress(progress_)
89  , options(options_)
90  {}
91 
92  Context(Context const&) = delete;
93  Context& operator=(Context const&) = delete;
94 
95  template<typename... Args>
96  void ok(dcp::VerificationNote::Code code, Args... args)
97  {
98  add_note({dcp::VerificationNote::Type::OK, code, std::forward<Args>(args)...});
99  }
100 
101  template<typename... Args>
102  void warning(dcp::VerificationNote::Code code, Args... args)
103  {
104  add_note({dcp::VerificationNote::Type::WARNING, code, std::forward<Args>(args)...});
105  }
106 
107  template<typename... Args>
108  void bv21_error(dcp::VerificationNote::Code code, Args... args)
109  {
110  add_note({dcp::VerificationNote::Type::BV21_ERROR, code, std::forward<Args>(args)...});
111  }
112 
113  template<typename... Args>
114  void error(dcp::VerificationNote::Code code, Args... args)
115  {
116  add_note({dcp::VerificationNote::Type::ERROR, code, std::forward<Args>(args)...});
117  }
118 
119  void add_note(dcp::VerificationNote note)
120  {
121  if (cpl) {
122  note.set_cpl_id(cpl->id());
123  }
124  notes.push_back(std::move(note));
125  }
126 
127  void add_note_if_not_existing(dcp::VerificationNote note)
128  {
129  if (find(notes.begin(), notes.end(), note) == notes.end()) {
130  add_note(note);
131  }
132  }
133 
134  std::vector<VerificationNote>& notes;
135  std::shared_ptr<const DCP> dcp;
136  std::shared_ptr<const CPL> cpl;
137  boost::filesystem::path xsd_dtd_directory;
138  std::function<void (std::string, boost::optional<boost::filesystem::path>)> stage;
139  std::function<void (float)> progress;
140  VerificationOptions options;
141 
142  boost::optional<std::string> subtitle_language;
143  boost::optional<int> audio_channels;
144 };
145 
146 
147 extern void verify_extension_metadata(dcp::Context& context);
148 
149 }
150 
151 
152 #endif
@ BV21_ERROR
may not always be considered an error, but violates a "shall" requirement of Bv2.1
CPL class.
Namespace for everything in libdcp.
Definition: array_data.h:50
void verify_text_lines_and_characters(std::shared_ptr< const dcp::TextAsset > asset, int warning_length, int error_length, dcp::LinesCharactersResult *result)
Definition: verify.cc:1131
dcp::verify() method and associated code