X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fplaylist.cc;h=e8714e9d6d4ffedac4ab9dd6fc6ae83ee1efe66b;hb=924f4edb20d14bc697956254951fb87513cf2e19;hp=20534e467778b58246e87cb0ec5ab12033cfc09a;hpb=8fedaaa75c4586a4cc7ffb393bd71d1fdb091dc8;p=dcpomatic.git diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 20534e467..e8714e9d6 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2018 Carl Hetherington + Copyright (C) 2013-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,6 +18,7 @@ */ + #include "playlist.h" #include "video_content.h" #include "text_content.h" @@ -39,6 +40,7 @@ #include "i18n.h" + using std::list; using std::cout; using std::vector; @@ -55,13 +57,13 @@ using namespace dcpomatic; using namespace boost::placeholders; #endif + Playlist::Playlist () - : _sequence (true) - , _sequencing (false) { } + Playlist::~Playlist () { boost::mutex::scoped_lock lm (_mutex); @@ -69,6 +71,7 @@ Playlist::~Playlist () disconnect (); } + void Playlist::content_change (weak_ptr weak_film, ChangeType type, weak_ptr content, int property, bool frequent) { @@ -117,6 +120,7 @@ Playlist::content_change (weak_ptr weak_film, ChangeType type, weak_ ContentChange (type, content, property, frequent); } + void Playlist::maybe_sequence (shared_ptr film) { @@ -126,7 +130,7 @@ Playlist::maybe_sequence (shared_ptr film) _sequencing = true; - ContentList cont = content (); + auto cont = content (); /* Keep track of the content that we've set the position of so that we don't do it twice. @@ -171,6 +175,7 @@ Playlist::maybe_sequence (shared_ptr film) _sequencing = false; } + string Playlist::video_identifier () const { @@ -193,6 +198,7 @@ Playlist::video_identifier () const return digester.get (); } + /** @param film Film that this Playlist is for. * @param node <Playlist> node. * @param version Metadata version number. @@ -227,7 +233,7 @@ Playlist::set_from_xml (shared_ptr film, cxml::ConstNodePtr node, in } /* ...or have a start trim which is an integer number of frames */ - ContentTime const old_trim = content->trim_start(); + auto const old_trim = content->trim_start(); content->set_trim_start(old_trim); if (old_trim != content->trim_start()) { string note = _("Your project contains video content whose trim was not aligned to a frame boundary."); @@ -255,6 +261,7 @@ Playlist::set_from_xml (shared_ptr film, cxml::ConstNodePtr node, in reconnect (film); } + /** @param node <Playlist> node. * @param with_content_paths true to include <Path> nodes in <Content> nodes, false to omit them. */ @@ -266,6 +273,7 @@ Playlist::as_xml (xmlpp::Node* node, bool with_content_paths) } } + void Playlist::add (shared_ptr film, shared_ptr c) { @@ -283,6 +291,7 @@ Playlist::add (shared_ptr film, shared_ptr c) LengthChange (); } + void Playlist::remove (shared_ptr c) { @@ -316,6 +325,7 @@ Playlist::remove (shared_ptr c) LengthChange (); } + void Playlist::remove (ContentList c) { @@ -325,7 +335,7 @@ Playlist::remove (ContentList c) boost::mutex::scoped_lock lm (_mutex); for (auto i: c) { - ContentList::iterator j = _content.begin (); + auto j = _content.begin (); while (j != _content.end() && *j != i) { ++j; } @@ -343,6 +353,7 @@ Playlist::remove (ContentList c) LengthChange (); } + class FrameRateCandidate { public: @@ -355,6 +366,7 @@ public: int dcp; }; + /** @return the best frame rate from Config::_allowed_dcp_frame_rates for the content in this list */ int Playlist::best_video_frame_rate () const @@ -412,6 +424,7 @@ Playlist::best_video_frame_rate () const return best->dcp; } + /** @return length of the playlist from time 0 to the last thing on the playlist */ DCPTime Playlist::length (shared_ptr film) const @@ -424,6 +437,7 @@ Playlist::length (shared_ptr film) const return len; } + /** @return position of the first thing on the playlist, if it's not empty */ optional Playlist::start () const @@ -441,6 +455,7 @@ Playlist::start () const return start; } + /** Must be called with a lock held on _mutex */ void Playlist::disconnect () @@ -452,6 +467,7 @@ Playlist::disconnect () _content_connections.clear (); } + /** Must be called with a lock held on _mutex */ void Playlist::reconnect (shared_ptr film) @@ -463,6 +479,7 @@ Playlist::reconnect (shared_ptr film) } } + DCPTime Playlist::video_end (shared_ptr film) const { @@ -476,6 +493,7 @@ Playlist::video_end (shared_ptr film) const return end; } + DCPTime Playlist::text_end (shared_ptr film) const { @@ -489,10 +507,11 @@ Playlist::text_end (shared_ptr film) const return end; } + FrameRateChange Playlist::active_frame_rate_change (DCPTime t, int dcp_video_frame_rate) const { - ContentList cont = content (); + auto cont = content (); for (ContentList::const_reverse_iterator i = cont.rbegin(); i != cont.rend(); ++i) { if (!(*i)->video) { continue; @@ -515,12 +534,14 @@ Playlist::active_frame_rate_change (DCPTime t, int dcp_video_frame_rate) const return FrameRateChange (dcp_video_frame_rate, dcp_video_frame_rate); } + void Playlist::set_sequence (bool s) { _sequence = s; } + bool ContentSorter::operator() (shared_ptr a, shared_ptr b) { @@ -539,6 +560,7 @@ ContentSorter::operator() (shared_ptr a, shared_ptr b) return a->digest() < b->digest(); } + /** @return content in ascending order of position */ ContentList Playlist::content () const @@ -547,10 +569,11 @@ Playlist::content () const return _content; } + void Playlist::repeat (shared_ptr film, ContentList c, int n) { - pair range (DCPTime::max (), DCPTime ()); + pair range (DCPTime::max(), DCPTime()); for (auto i: c) { range.first = min (range.first, i->position ()); range.second = max (range.second, i->position ()); @@ -580,6 +603,7 @@ Playlist::repeat (shared_ptr film, ContentList c, int n) Change (ChangeType::DONE); } + void Playlist::move_earlier (shared_ptr film, shared_ptr c) { @@ -603,6 +627,7 @@ Playlist::move_earlier (shared_ptr film, shared_ptr c) c->set_position (film, p); } + void Playlist::move_later (shared_ptr film, shared_ptr c) { @@ -627,6 +652,7 @@ Playlist::move_later (shared_ptr film, shared_ptr c) c->set_position (film, c->position() + next_c->length_after_trim(film)); } + int64_t Playlist::required_disk_space (shared_ptr film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const { @@ -649,6 +675,7 @@ Playlist::required_disk_space (shared_ptr film, int j2k_bandwidth, i return video + audio + 65536; } + string Playlist::content_summary (shared_ptr film, DCPTimePeriod period) const { @@ -674,6 +701,7 @@ Playlist::content_summary (shared_ptr film, DCPTimePeriod period) co return best_summary; } + pair Playlist::speed_up_range (int dcp_video_frame_rate) const {