Bump version
[dcpomatic.git] / src / lib / decoder_factory.cc
index bb6eff97140edd27328ef957b2793d998466728e..f7f9f4074c52ae50c6e617d1bc22d967f44ff752 100644 (file)
 #include "ffmpeg_decoder.h"
 #include "imagemagick_decoder.h"
 #include "film.h"
+#include "sndfile_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, DecodeOptions o
        )
 {
+       if (f->content().empty()) {
+               return Decoders ();
+       }
+       
        if (boost::filesystem::is_directory (f->content_path()) || f->content_type() == STILL) {
                /* A single image file, or a directory of them */
-               return shared_ptr<Decoder> (new ImageMagickDecoder (f, o, j));
+               return Decoders (
+                       shared_ptr<VideoDecoder> (new ImageMagickDecoder (f, o)),
+                       shared_ptr<AudioDecoder> (new SndfileDecoder (f, o))
+                       );
        }
-       
-       return shared_ptr<Decoder> (new FFmpegDecoder (f, o, j));
+
+       shared_ptr<FFmpegDecoder> fd (new FFmpegDecoder (f, o));
+       if (f->use_content_audio()) {
+               return Decoders (fd, fd);
+       }
+
+       return Decoders (fd, shared_ptr<AudioDecoder> (new SndfileDecoder (f, o)));
 }