Merge master.
[dcpomatic.git] / src / lib / content_factory.cc
index d42491f7f58c16f40b4542a11699edbf041bc107..092efd7903d7dba9219c483c57a03307d6733945 100644 (file)
 
 #include <libcxml/cxml.h>
 #include "ffmpeg_content.h"
-#include "still_image_content.h"
-#include "moving_image_content.h"
+#include "image_content.h"
 #include "sndfile_content.h"
+#include "subrip_content.h"
 #include "util.h"
 
 using std::string;
+using std::list;
 using boost::shared_ptr;
 
 shared_ptr<Content>
-content_factory (shared_ptr<const Film> film, shared_ptr<cxml::Node> node)
+content_factory (shared_ptr<const Film> film, cxml::NodePtr node, int version, list<string>& notes)
 {
        string const type = node->string_child ("Type");
 
        boost::shared_ptr<Content> content;
        
        if (type == "FFmpeg") {
-               content.reset (new FFmpegContent (film, node));
-       } else if (type == "StillImage") {
-               content.reset (new StillImageContent (film, node));
-       } else if (type == "MovingImage") {
-               content.reset (new MovingImageContent (film, node));
+               content.reset (new FFmpegContent (film, node, version, notes));
+       } else if (type == "Image") {
+               content.reset (new ImageContent (film, node, version));
        } else if (type == "Sndfile") {
-               content.reset (new SndfileContent (film, node));
+               content.reset (new SndfileContent (film, node, version));
+       } else if (type == "SubRip") {
+               content.reset (new SubRipContent (film, node, version));
        }
 
        return content;
@@ -51,11 +52,16 @@ shared_ptr<Content>
 content_factory (shared_ptr<const Film> film, boost::filesystem::path path)
 {
        shared_ptr<Content> content;
+
+       string ext = path.extension().string ();
+       transform (ext.begin(), ext.end(), ext.begin(), ::tolower);
                
        if (valid_image_file (path)) {
-               content.reset (new StillImageContent (film, path));
+               content.reset (new ImageContent (film, path));
        } else if (SndfileContent::valid_file (path)) {
                content.reset (new SndfileContent (film, path));
+       } else if (ext == ".srt") {
+               content.reset (new SubRipContent (film, path));
        } else {
                content.reset (new FFmpegContent (film, path));
        }