Resequence video (perhaps) on DCP video frame rate change.
[dcpomatic.git] / src / lib / playlist.cc
index 995067b66ee7bf7133f6d0b025c70f381869dd1e..aea6c5f413deaae0f6c95e2a702a596f6e7010ae 100644 (file)
@@ -72,41 +72,46 @@ Playlist::~Playlist ()
 void
 Playlist::content_changed (weak_ptr<Content> c, int p)
 {
-       if (p == ContentProperty::LENGTH && _sequence_video && !_sequencing_video) {
-               _sequencing_video = true;
-
-               ContentList cl = _content;
-               sort (cl.begin(), cl.end(), ContentSorter ());
-               Time last = 0;
-               for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) {
-                       if (!dynamic_pointer_cast<VideoContent> (*i)) {
-                               continue;
-                       }
+       if (p == ContentProperty::LENGTH) {
+               maybe_sequence_video ();
+       }
+       
+       ContentChanged (c, p);
+}
 
-                       (*i)->set_start (last);
-                       last = (*i)->end ();
+void
+Playlist::maybe_sequence_video ()
+{
+       if (!_sequence_video || _sequencing_video) {
+               return;
+       }
+       
+       _sequencing_video = true;
+       
+       ContentList cl = _content;
+       sort (cl.begin(), cl.end(), ContentSorter ());
+       Time last = 0;
+       for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) {
+               if (!dynamic_pointer_cast<VideoContent> (*i)) {
+                       continue;
                }
-
-               _sequencing_video = false;
+               
+               (*i)->set_start (last);
+               last = (*i)->end ();
        }
        
-       ContentChanged (c, p);
+       _sequencing_video = false;
 }
 
 string
-Playlist::video_digest () const
+Playlist::video_identifier () const
 {
        string t;
        
        for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
-               if (!dynamic_pointer_cast<const VideoContent> (*i)) {
-                       continue;
-               }
-               
-               t += (*i)->digest ();
-               shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (*i);
-               if (fc && fc->subtitle_stream()) {
-                       t += fc->subtitle_stream()->id;
+               shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (*i);
+               if (vc) {
+                       t += vc->identifier ();
                }
        }