2 Copyright (C) 2016-2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
22 #include "atmos_mxf_content.h"
23 #include "atmos_mxf_decoder.h"
24 #include "dcp_content.h"
25 #include "dcp_decoder.h"
26 #include "dcp_subtitle_content.h"
27 #include "dcp_subtitle_decoder.h"
28 #include "ffmpeg_content.h"
29 #include "ffmpeg_decoder.h"
30 #include "image_content.h"
31 #include "image_decoder.h"
32 #include "string_text_file_content.h"
33 #include "string_text_file_decoder.h"
35 #include "video_mxf_content.h"
36 #include "video_mxf_decoder.h"
39 using std::dynamic_pointer_cast;
41 using std::make_shared;
42 using std::shared_ptr;
47 maybe_cast (shared_ptr<Decoder> d)
52 return dynamic_pointer_cast<T> (d);
56 @param tolerant true to proceed in the face of `survivable' errors, otherwise false.
57 @param old_decoder A `used' decoder that has been previously made for this piece of content, or 0
60 decoder_factory (shared_ptr<const Film> film, shared_ptr<const Content> content, bool fast, bool tolerant, shared_ptr<Decoder> old_decoder)
62 auto fc = dynamic_pointer_cast<const FFmpegContent> (content);
64 return make_shared<FFmpegDecoder>(film, fc, fast);
67 auto dc = dynamic_pointer_cast<const DCPContent> (content);
70 return make_shared<DCPDecoder>(film, dc, fast, tolerant, maybe_cast<DCPDecoder>(old_decoder));
71 } catch (KDMError& e) {
72 /* This will be found and reported to the user when the content is examined */
77 auto ic = dynamic_pointer_cast<const ImageContent> (content);
79 return make_shared<ImageDecoder>(film, ic);
82 auto rc = dynamic_pointer_cast<const StringTextFileContent> (content);
84 return make_shared<StringTextFileDecoder>(film, rc);
87 auto dsc = dynamic_pointer_cast<const DCPSubtitleContent> (content);
89 return make_shared<DCPSubtitleDecoder>(film, dsc);
92 auto vmc = dynamic_pointer_cast<const VideoMXFContent> (content);
94 return make_shared<VideoMXFDecoder>(film, vmc);
97 auto amc = dynamic_pointer_cast<const AtmosMXFContent> (content);
99 return make_shared<AtmosMXFDecoder>(film, amc);