C++11 tidying.
[dcpomatic.git] / src / lib / subtitle_encoder.h
1 /*
2     Copyright (C) 2019-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
22 #include "types.h"
23 #include "player_text.h"
24 #include "dcp_text_track.h"
25 #include "encoder.h"
26 #include "dcpomatic_time.h"
27
28
29 namespace dcp {
30         class SubtitleAsset;
31 }
32
33
34 class Film;
35
36
37 /** @class SubtitleEncoder.
38  *  @brief An `encoder' which extracts a film's subtitles to DCP XML format.
39  */
40 class SubtitleEncoder : public Encoder
41 {
42 public:
43         SubtitleEncoder (std::shared_ptr<const Film> film, std::shared_ptr<Job> job, boost::filesystem::path output, std::string intial_name, bool split_reels, bool include_font);
44
45         void go () override;
46
47         /** @return the number of frames that are done */
48         Frame frames_done () const override;
49
50         bool finishing () const override {
51                 return false;
52         }
53
54 private:
55         void text (PlayerText subs, TextType type, boost::optional<DCPTextTrack> track, dcpomatic::DCPTimePeriod period);
56
57         std::vector<std::pair<std::shared_ptr<dcp::SubtitleAsset>, boost::filesystem::path> > _assets;
58         std::vector<dcpomatic::DCPTimePeriod> _reels;
59         bool _split_reels;
60         bool _include_font;
61         int _reel_index;
62         boost::optional<dcpomatic::DCPTime> _last;
63         dcpomatic::DCPTime _length;
64         dcp::ArrayData _default_font;
65 };