Fix the build for older macOS.
[dcpomatic.git] / src / lib / dcp_subtitle.cc
1 /*
2     Copyright (C) 2014-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 "dcp_subtitle.h"
23 #include "exceptions.h"
24 #include "compose.hpp"
25 #include <dcp/interop_subtitle_asset.h>
26 #include <dcp/smpte_subtitle_asset.h>
27
28 #include "i18n.h"
29
30
31 using std::exception;
32 using std::shared_ptr;
33 using std::string;
34 using std::make_shared;
35
36
37 shared_ptr<dcp::SubtitleAsset>
38 DCPSubtitle::load (boost::filesystem::path file) const
39 {
40         shared_ptr<dcp::SubtitleAsset> sc;
41         string interop_error;
42         string smpte_error;
43
44         try {
45                 sc = make_shared<dcp::InteropSubtitleAsset>(file);
46         } catch (exception& e) {
47                 interop_error = e.what ();
48         }
49
50         if (!sc) {
51                 try {
52                         sc = make_shared<dcp::SMPTESubtitleAsset>(file);
53                 } catch (exception& e) {
54                         smpte_error = e.what();
55                 }
56         }
57
58         if (!sc) {
59                 throw FileError(String::compose(_("Could not read subtitles (%1 / %2)"), interop_error, smpte_error), file);
60         }
61
62         return sc;
63 }