Reword again: Text -> Caption and Plain -> Text.
[dcpomatic.git] / src / lib / decoder_factory.cc
1 /*
2     Copyright (C) 2016 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_content.h"
22 #include "ffmpeg_decoder.h"
23 #include "dcp_content.h"
24 #include "dcp_decoder.h"
25 #include "image_content.h"
26 #include "image_decoder.h"
27 #include "text_caption_file_content.h"
28 #include "text_caption_file_decoder.h"
29 #include "dcp_text_content.h"
30 #include "dcp_text_decoder.h"
31 #include "video_mxf_content.h"
32 #include "video_mxf_decoder.h"
33 #include <boost/foreach.hpp>
34
35 using std::list;
36 using boost::shared_ptr;
37 using boost::dynamic_pointer_cast;
38
39 shared_ptr<Decoder>
40 decoder_factory (shared_ptr<const Content> content, shared_ptr<Log> log, bool fast)
41 {
42         shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (content);
43         if (fc) {
44                 return shared_ptr<Decoder> (new FFmpegDecoder (fc, log, fast));
45         }
46
47         shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent> (content);
48         if (dc) {
49                 return shared_ptr<Decoder> (new DCPDecoder (dc, log, fast));
50         }
51
52         shared_ptr<const ImageContent> ic = dynamic_pointer_cast<const ImageContent> (content);
53         if (ic) {
54                 return shared_ptr<Decoder> (new ImageDecoder (ic, log));
55         }
56
57         shared_ptr<const TextCaptionFileContent> rc = dynamic_pointer_cast<const TextCaptionFileContent> (content);
58         if (rc) {
59                 return shared_ptr<Decoder> (new TextCaptionFileDecoder (rc, log));
60         }
61
62         shared_ptr<const DCPTextContent> dsc = dynamic_pointer_cast<const DCPTextContent> (content);
63         if (dsc) {
64                 return shared_ptr<Decoder> (new DCPTextDecoder (dsc, log));
65         }
66
67         shared_ptr<const VideoMXFContent> vmc = dynamic_pointer_cast<const VideoMXFContent> (content);
68         if (vmc) {
69                 return shared_ptr<Decoder> (new VideoMXFDecoder (vmc, log));
70         }
71
72         return shared_ptr<Decoder> ();
73 }