More automated renaming.
[dcpomatic.git] / src / lib / ffmpeg_content.cc
index dd4ed7063f91199c6232dc4d3f684059c1c11312..86965ff4952b7edaa3fd56437ec0b2f855012d00 100644 (file)
@@ -32,7 +32,7 @@
 #include "log.h"
 #include "exceptions.h"
 #include "frame_rate_change.h"
-#include "caption_content.h"
+#include "text_content.h"
 #include <dcp/raw_convert.h>
 #include <libcxml/cxml.h>
 extern "C" {
@@ -85,7 +85,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr no
 {
        video = VideoContent::from_xml (this, node, version);
        audio = AudioContent::from_xml (this, node, version);
-       caption = CaptionContent::from_xml (this, node, version);
+       caption = TextContent::from_xml (this, node, version);
 
        list<cxml::NodePtr> c = node->node_children ("SubtitleStream");
        for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
@@ -140,7 +140,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
        if (i != c.end ()) {
                need_video = static_cast<bool> ((*i)->video);
                need_audio = static_cast<bool> ((*i)->audio);
-               need_caption = static_cast<bool> ((*i)->caption);
+               need_caption = !(*i)->caption.empty();
        }
 
        while (i != c.end ()) {
@@ -150,7 +150,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
                if (need_audio != static_cast<bool> ((*i)->audio)) {
                        throw JoinError (_("Content to be joined must all have or not have audio"));
                }
-               if (need_caption != static_cast<bool> ((*i)->caption)) {
+               if (need_caption != !(*i)->caption.empty()) {
                        throw JoinError (_("Content to be joined must all have or not have captions"));
                }
                ++i;
@@ -163,7 +163,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
                audio.reset (new AudioContent (this, c));
        }
        if (need_caption) {
-               caption.reset (new CaptionContent (this, c));
+               caption.push_back (shared_ptr<TextContent> (new TextContent (this, c)));
        }
 
        shared_ptr<FFmpegContent> ref = dynamic_pointer_cast<FFmpegContent> (c[0]);
@@ -171,7 +171,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
 
        for (size_t i = 0; i < c.size(); ++i) {
                shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c[i]);
-               if (fc->caption && fc->caption->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
+               if (fc->only_caption() && fc->only_caption()->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
                        throw JoinError (_("Content to be joined must use the same subtitle stream."));
                }
        }
@@ -209,8 +209,8 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const
                }
        }
 
-       if (caption) {
-               caption->as_xml (node);
+       if (only_caption()) {
+               only_caption()->as_xml (node);
        }
 
        boost::mutex::scoped_lock lm (_mutex);
@@ -303,7 +303,8 @@ FFmpegContent::examine (shared_ptr<Job> job)
 
                _subtitle_streams = examiner->subtitle_streams ();
                if (!_subtitle_streams.empty ()) {
-                       caption.reset (new CaptionContent (this));
+                       caption.clear ();
+                       caption.push_back (shared_ptr<TextContent> (new TextContent (this, CAPTION_OPEN)));
                        _subtitle_stream = _subtitle_streams.front ();
                }
 
@@ -426,8 +427,8 @@ FFmpegContent::identifier () const
                s += "_" + video->identifier();
        }
 
-       if (caption && caption->use() && caption->burn()) {
-               s += "_" + caption->identifier();
+       if (only_caption() && only_caption()->use() && only_caption()->burn()) {
+               s += "_" + only_caption()->identifier();
        }
 
        boost::mutex::scoped_lock lm (_mutex);