Fix merge.
[dcpomatic.git] / src / lib / decoder_factory.cc
index d4a91d8d97d312954247f4287e018013fdaa370b..1d8d12cd552bf3f7236243d489026359fb94b3d5 100644 (file)
 
 #include <boost/filesystem.hpp>
 #include "ffmpeg_decoder.h"
-#include "tiff_decoder.h"
 #include "imagemagick_decoder.h"
 #include "film.h"
+#include "external_audio_decoder.h"
+#include "decoder_factory.h"
 
 using std::string;
+using std::pair;
+using std::make_pair;
 using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
 
-shared_ptr<Decoder>
+Decoders
 decoder_factory (
-       shared_ptr<Film> f, shared_ptr<const Options> o, Job* j
+       shared_ptr<Film> f, shared_ptr<const DecodeOptions> o, Job* j
        )
 {
-       if (boost::filesystem::is_directory (f->content_path ())) {
-               /* Assume a directory contains TIFFs */
-               return shared_ptr<Decoder> (new TIFFDecoder (f, o, j));
+       if (boost::filesystem::is_directory (f->content_path()) || f->content_type() == STILL) {
+               /* A single image file, or a directory of them */
+               return Decoders (
+                       shared_ptr<VideoDecoder> (new ImageMagickDecoder (f, o, j)),
+                       shared_ptr<AudioDecoder> ()
+                       );
        }
 
-       if (f->content_type() == STILL) {
-               return shared_ptr<Decoder> (new ImageMagickDecoder (f, o, j));
+       shared_ptr<FFmpegDecoder> fd (new FFmpegDecoder (f, o, j));
+       if (f->use_content_audio()) {
+               return Decoders (fd, fd);
        }
-       
-       return shared_ptr<Decoder> (new FFmpegDecoder (f, o, j));
+
+       return Decoders (fd, shared_ptr<AudioDecoder> (new ExternalAudioDecoder (f, o, j)));
 }