X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder_factory.cc;h=ec0140b0c1933ac1eee8bd991aa2f236928d9bb3;hb=5a5324ed3a381a86dfe0a6e3932c1d58fdcd596f;hp=5f8fc55b3b20736bf00cb506fe80984cbd3601db;hpb=bb767c7e338414beee132af3e96829c1448e214b;p=dcpomatic.git diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc index 5f8fc55b3..ec0140b0c 100644 --- a/src/lib/decoder_factory.cc +++ b/src/lib/decoder_factory.cc @@ -1,48 +1,75 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2016 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ -/** @file src/decoder_factory.cc - * @brief A method to create an appropriate decoder for some content. - */ - -#include +#include "ffmpeg_content.h" #include "ffmpeg_decoder.h" -#include "tiff_decoder.h" -#include "imagemagick_decoder.h" -#include "film_state.h" +#include "dcp_content.h" +#include "dcp_decoder.h" +#include "image_content.h" +#include "image_decoder.h" +#include "text_subtitle_content.h" +#include "text_subtitle_decoder.h" +#include "dcp_subtitle_content.h" +#include "dcp_subtitle_decoder.h" +#include "video_mxf_content.h" +#include "video_mxf_decoder.h" +#include +#include -using namespace std; -using namespace boost; +using std::list; +using boost::shared_ptr; +using boost::dynamic_pointer_cast; +using boost::make_shared; shared_ptr -decoder_factory ( - shared_ptr fs, shared_ptr o, Job* j, Log* l, bool minimal = false, bool ignore_length = false - ) +decoder_factory (shared_ptr content, shared_ptr log, bool fast) { - if (filesystem::is_directory (fs->content_path ())) { - /* Assume a directory contains TIFFs */ - return shared_ptr (new TIFFDecoder (fs, o, j, l, minimal, ignore_length)); + shared_ptr fc = dynamic_pointer_cast (content); + if (fc) { + return make_shared (fc, log, fast); + } + + shared_ptr dc = dynamic_pointer_cast (content); + if (dc) { + return make_shared (dc, log, fast); + } + + shared_ptr ic = dynamic_pointer_cast (content); + if (ic) { + return make_shared (ic, log); } - if (fs->content_type() == STILL) { - return shared_ptr (new ImageMagickDecoder (fs, o, j, l, minimal, ignore_length)); + shared_ptr rc = dynamic_pointer_cast (content); + if (rc) { + return make_shared (rc); } - - return shared_ptr (new FFmpegDecoder (fs, o, j, l, minimal, ignore_length)); + + shared_ptr dsc = dynamic_pointer_cast (content); + if (dsc) { + return make_shared (dsc); + } + + shared_ptr vmc = dynamic_pointer_cast (content); + if (vmc) { + return make_shared (vmc, log); + } + + return shared_ptr (); }