Supporters update.
[dcpomatic.git] / src / lib / types.cc
1 /*
2     Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic 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     DCP-o-matic 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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "types.h"
22 #include "compose.hpp"
23 #include "dcpomatic_assert.h"
24 #include <dcp/cpl.h>
25 #include <dcp/dcp.h>
26 #include <dcp/filesystem.h>
27 #include <dcp/raw_convert.h>
28 #include <dcp/reel_asset.h>
29 #include <dcp/reel_file_asset.h>
30 #include <dcp/warnings.h>
31 LIBDCP_DISABLE_WARNINGS
32 #include <libxml++/libxml++.h>
33 LIBDCP_ENABLE_WARNINGS
34 #include <libcxml/cxml.h>
35
36 #include "i18n.h"
37
38 using std::max;
39 using std::min;
40 using std::string;
41 using std::list;
42 using std::shared_ptr;
43 using std::vector;
44 using dcp::raw_convert;
45
46
47 CPLSummary::CPLSummary (boost::filesystem::path p)
48         : dcp_directory(p.filename().string())
49 {
50         dcp::DCP dcp (p);
51
52         vector<dcp::VerificationNote> notes;
53         dcp.read (&notes);
54         for (auto i: notes) {
55                 if (i.code() != dcp::VerificationNote::Code::EXTERNAL_ASSET) {
56                         /* It's not just a warning about this DCP being a VF */
57                         throw dcp::ReadError(dcp::note_to_string(i));
58                 }
59         }
60
61         cpl_id = dcp.cpls().front()->id();
62         cpl_annotation_text = dcp.cpls().front()->annotation_text();
63         cpl_file = dcp.cpls().front()->file().get();
64
65         encrypted = false;
66         for (auto j: dcp.cpls()) {
67                 for (auto k: j->reel_file_assets()) {
68                         if (k->encrypted()) {
69                                 encrypted = true;
70                         }
71                 }
72         }
73
74         boost::system::error_code ec;
75         auto last_write = dcp::filesystem::last_write_time(p, ec);
76         last_write_time = ec ? 0 : last_write;
77 }
78
79