swaroop: Disable play/stop/pause and slider during ad content.
[dcpomatic.git] / src / lib / ffmpeg_content.cc
index e18977944648fc1faff37e83987d8018a63fe473..961c0b0a39c77d9a63372f4fb34b870fa98fdc33 100644 (file)
@@ -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);
-       subtitle = TextContent::from_xml (this, node, version);
+       text = 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) {
@@ -135,12 +135,12 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
 
        bool need_video = false;
        bool need_audio = false;
-       bool need_subtitle = false;
+       bool need_text = false;
 
        if (i != c.end ()) {
                need_video = static_cast<bool> ((*i)->video);
                need_audio = static_cast<bool> ((*i)->audio);
-               need_subtitle = static_cast<bool> ((*i)->subtitle);
+               need_text = !(*i)->text.empty();
        }
 
        while (i != c.end ()) {
@@ -150,8 +150,8 @@ 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_subtitle != static_cast<bool> ((*i)->subtitle)) {
-                       throw JoinError (_("Content to be joined must all have or not have subtitles"));
+               if (need_text != !(*i)->text.empty()) {
+                       throw JoinError (_("Content to be joined must all have or not have subtitles or captions"));
                }
                ++i;
        }
@@ -162,8 +162,8 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<shared_ptr<Con
        if (need_audio) {
                audio.reset (new AudioContent (this, c));
        }
-       if (need_subtitle) {
-               subtitle.reset (new TextContent (this, c));
+       if (need_text) {
+               text.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->subtitle && fc->subtitle->use() && *(fc->_subtitle_stream.get()) != *(ref->_subtitle_stream.get())) {
+               if (fc->only_text() && fc->only_text()->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 (subtitle) {
-               subtitle->as_xml (node);
+       if (only_text()) {
+               only_text()->as_xml (node);
        }
 
        boost::mutex::scoped_lock lm (_mutex);
@@ -251,6 +251,9 @@ FFmpegContent::as_xml (xmlpp::Node* node, bool with_paths) const
 void
 FFmpegContent::examine (shared_ptr<Job> job)
 {
+       ChangeSignaller<Content> cc1 (this, FFmpegContentProperty::SUBTITLE_STREAMS);
+       ChangeSignaller<Content> cc2 (this, FFmpegContentProperty::SUBTITLE_STREAM);
+
        job->set_progress_unknown ();
 
        Content::examine (job);
@@ -303,7 +306,8 @@ FFmpegContent::examine (shared_ptr<Job> job)
 
                _subtitle_streams = examiner->subtitle_streams ();
                if (!_subtitle_streams.empty ()) {
-                       subtitle.reset (new TextContent (this));
+                       text.clear ();
+                       text.push_back (shared_ptr<TextContent> (new TextContent (this, TEXT_OPEN_SUBTITLE, TEXT_UNKNOWN)));
                        _subtitle_stream = _subtitle_streams.front ();
                }
 
@@ -312,9 +316,6 @@ FFmpegContent::examine (shared_ptr<Job> job)
        if (examiner->has_video ()) {
                set_default_colour_conversion ();
        }
-
-       signal_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
-       signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
 }
 
 string
@@ -368,12 +369,12 @@ FFmpegContent::technical_summary () const
 void
 FFmpegContent::set_subtitle_stream (shared_ptr<FFmpegSubtitleStream> s)
 {
+       ChangeSignaller<Content> cc (this, FFmpegContentProperty::SUBTITLE_STREAM);
+
        {
                boost::mutex::scoped_lock lm (_mutex);
                _subtitle_stream = s;
        }
-
-       signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
 }
 
 bool
@@ -409,12 +410,12 @@ FFmpegContent::full_length () const
 void
 FFmpegContent::set_filters (vector<Filter const *> const & filters)
 {
+       ChangeSignaller<Content> cc (this, FFmpegContentProperty::FILTERS);
+
        {
                boost::mutex::scoped_lock lm (_mutex);
                _filters = filters;
        }
-
-       signal_changed (FFmpegContentProperty::FILTERS);
 }
 
 string
@@ -426,8 +427,8 @@ FFmpegContent::identifier () const
                s += "_" + video->identifier();
        }
 
-       if (subtitle && subtitle->use() && subtitle->burn()) {
-               s += "_" + subtitle->identifier();
+       if (only_text() && only_text()->use() && only_text()->burn()) {
+               s += "_" + only_text()->identifier();
        }
 
        boost::mutex::scoped_lock lm (_mutex);
@@ -628,7 +629,8 @@ FFmpegContent::add_properties (list<UserProperty>& p) const
 void
 FFmpegContent::signal_subtitle_stream_changed ()
 {
-       signal_changed (FFmpegContentProperty::SUBTITLE_STREAM);
+       /* XXX: this is too late; really it should be before the change */
+       ChangeSignaller<Content> cc (this, FFmpegContentProperty::SUBTITLE_STREAM);
 }
 
 vector<shared_ptr<FFmpegAudioStream> >