X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplaylist.cc;h=9cc1789d135d5c38a66e416b4c90888421d7142e;hb=5fd5e78c51bd5630f6777001db5aa25103218c22;hp=36d6c6b52d789c2f33020b950e49e37efb486c77;hpb=8c6fe8e1e8c8f6d5932606f2a5b6e1b87681ae38;p=dcpomatic.git diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 36d6c6b52..9cc1789d1 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -1,5 +1,3 @@ -/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */ - /* Copyright (C) 2013 Carl Hetherington @@ -51,6 +49,8 @@ using boost::lexical_cast; Playlist::Playlist () : _loop (1) + , _sequence_video (true) + , _sequencing_video (false) { } @@ -72,30 +72,25 @@ Playlist::~Playlist () void Playlist::content_changed (weak_ptr c, int p) { - ContentChanged (c, 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 (*i)) { + continue; + } -string -Playlist::audio_digest () const -{ - string t; - - for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - if (!dynamic_pointer_cast (*i)) { - continue; + (*i)->set_start (last); + last = (*i)->end (); } - - t += (*i)->digest (); - shared_ptr fc = dynamic_pointer_cast (*i); - if (fc) { - t += lexical_cast (fc->audio_stream()->id); - } + _sequencing_video = false; } - - t += lexical_cast (_loop); - - return md5_digest (t.c_str(), t.length()); + + ContentChanged (c, p); } string @@ -122,7 +117,7 @@ Playlist::video_digest () const /** @param node node */ void -Playlist::set_from_xml (shared_ptr node) +Playlist::set_from_xml (shared_ptr film, shared_ptr node) { list > c = node->node_children ("Content"); for (list >::iterator i = c.begin(); i != c.end(); ++i) { @@ -131,11 +126,11 @@ Playlist::set_from_xml (shared_ptr node) boost::shared_ptr content; if (type == "FFmpeg") { - content.reset (new FFmpegContent (*i)); + content.reset (new FFmpegContent (film, *i)); } else if (type == "ImageMagick") { - content.reset (new ImageMagickContent (*i)); + content.reset (new ImageMagickContent (film, *i)); } else if (type == "Sndfile") { - content.reset (new SndfileContent (*i)); + content.reset (new SndfileContent (film, *i)); } _content.push_back (content); @@ -143,6 +138,7 @@ Playlist::set_from_xml (shared_ptr node) reconnect (); _loop = node->number_child ("Loop"); + _sequence_video = node->bool_child ("SequenceVideo"); } /** @param node node */ @@ -154,6 +150,7 @@ Playlist::as_xml (xmlpp::Node* node) } node->add_child("Loop")->add_child_text(lexical_cast (_loop)); + node->add_child("SequenceVideo")->add_child_text(_sequence_video ? "1" : "0"); } void @@ -261,11 +258,11 @@ Playlist::best_dcp_frame_rate () const } Time -Playlist::length (shared_ptr film) const +Playlist::length () const { Time len = 0; for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { - len = max (len, (*i)->end (film)); + len = max (len, (*i)->end ()); } return len; @@ -285,3 +282,27 @@ Playlist::reconnect () } } +Time +Playlist::video_end () const +{ + Time end = 0; + for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) { + if (dynamic_pointer_cast (*i)) { + end = max (end, (*i)->end ()); + } + } + + return end; +} + +void +Playlist::set_sequence_video (bool s) +{ + _sequence_video = s; +} + +bool +ContentSorter::operator() (shared_ptr a, shared_ptr b) +{ + return a->start() < b->start(); +}