Missed update to private test repo version.
[dcpomatic.git] / src / lib / ffmpeg_subtitle_stream.cc
1 /*
2     Copyright (C) 2013-2017 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 "ffmpeg_subtitle_stream.h"
22 #include <dcp/raw_convert.h>
23 #include <dcp/warnings.h>
24 LIBDCP_DISABLE_WARNINGS
25 #include <libxml++/libxml++.h>
26 LIBDCP_ENABLE_WARNINGS
27 #include <iostream>
28
29 using std::string;
30 using std::map;
31 using std::list;
32 using std::cout;
33 using std::make_pair;
34 using dcp::raw_convert;
35
36 /** Construct a SubtitleStream from a value returned from to_string().
37  *  @param node String returned from to_string().
38  *  @param version State file version.
39  */
40 FFmpegSubtitleStream::FFmpegSubtitleStream (cxml::ConstNodePtr node, int version)
41         : FFmpegStream (node)
42 {
43         if (version >= 33) {
44                 boost::mutex::scoped_lock lm (_mutex);
45                 for (auto i: node->node_children ("Colour")) {
46                         _colours[RGBA(i->node_child("From"))] = RGBA (i->node_child("To"));
47                 }
48         }
49 }
50
51 void
52 FFmpegSubtitleStream::as_xml (xmlpp::Node* root) const
53 {
54         FFmpegStream::as_xml (root);
55
56         boost::mutex::scoped_lock lm (_mutex);
57         for (map<RGBA, RGBA>::const_iterator i = _colours.begin(); i != _colours.end(); ++i) {
58                 xmlpp::Node* node = root->add_child("Colour");
59                 i->first.as_xml (node->add_child("From"));
60                 i->second.as_xml (node->add_child("To"));
61         }
62 }
63
64 map<RGBA, RGBA>
65 FFmpegSubtitleStream::colours () const
66 {
67         boost::mutex::scoped_lock lm (_mutex);
68         return _colours;
69 }
70
71 void
72 FFmpegSubtitleStream::set_colour (RGBA from, RGBA to)
73 {
74         boost::mutex::scoped_lock lm (_mutex);
75         _colours[from] = to;
76 }