C++11 tidying.
[dcpomatic.git] / src / lib / copy_dcp_details_to_film.cc
1 /*
2     Copyright (C) 2020-2021 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 "copy_dcp_details_to_film.h"
22 #include "dcp_content.h"
23 #include "film.h"
24 #include "types.h"
25 #include "video_content.h"
26 #include "audio_content.h"
27 #include "ratio.h"
28 #include "dcp_content_type.h"
29 #include <map>
30
31
32 using std::map;
33 using std::string;
34 using std::vector;
35 using std::shared_ptr;
36
37
38 void
39 copy_dcp_details_to_film (shared_ptr<const DCPContent> dcp, shared_ptr<Film> film)
40 {
41         auto name = dcp->name ();
42         name = name.substr (0, name.find("_"));
43         film->set_name (name);
44         film->set_use_isdcf_name (true);
45         if (dcp->content_kind()) {
46                 film->set_dcp_content_type (DCPContentType::from_libdcp_kind(dcp->content_kind().get()));
47         }
48         film->set_encrypted (dcp->encrypted());
49         film->set_reel_type (ReelType::BY_VIDEO_CONTENT);
50         film->set_interop (dcp->standard() == dcp::Standard::INTEROP);
51         film->set_three_d (dcp->three_d());
52
53         if (dcp->video) {
54                 film->set_container (Ratio::nearest_from_ratio(dcp->video->size().ratio()));
55                 film->set_resolution (dcp->resolution());
56                 DCPOMATIC_ASSERT (dcp->video_frame_rate());
57                 film->set_video_frame_rate (*dcp->video_frame_rate());
58         }
59
60         if (dcp->audio) {
61                 film->set_audio_channels (dcp->audio->stream()->channels());
62         }
63
64         film->clear_markers ();
65         for (auto const& i: dcp->markers()) {
66                 film->set_marker (i.first, dcpomatic::DCPTime(i.second.get()));
67         }
68
69         film->set_ratings (dcp->ratings());
70         film->set_content_versions (dcp->content_versions());
71 }
72