X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplaylist.cc;h=a30dde633cde3120bc29cdc2b762e3c723f802de;hb=5bbf16e87ca09369174c9d2bb7f7fe94b6d70275;hp=739c5a20b3d0317f506786ce8dbc4fd544a91bab;hpb=a306df9145d16046e51e8b7ff5222e341e98fdbd;p=dcpomatic.git diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 739c5a20b..a30dde633 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -175,10 +175,10 @@ Playlist::set_from_xml (shared_ptr film, cxml::ConstNodePtr node, in /** @param node node */ void -Playlist::as_xml (xmlpp::Node* node) +Playlist::as_xml (xmlpp::Node* node, bool with_content_paths) { BOOST_FOREACH (shared_ptr i, _content) { - i->as_xml (node->add_child ("Content")); + i->as_xml (node->add_child ("Content"), with_content_paths); } } @@ -511,3 +511,28 @@ Playlist::required_disk_space (int j2k_bandwidth, int audio_channels, int audio_ /* Add on 64k for bits and pieces (metadata, subs etc) */ return video + audio + 65536; } + +string +Playlist::content_summary (DCPTimePeriod period) const +{ + string best_summary; + int best_score = -1; + BOOST_FOREACH (shared_ptr i, _content) { + int score = 0; + optional const o = DCPTimePeriod(i->position(), i->end()).overlap (period); + if (o) { + score += 100 * o.get().duration().get() / period.duration().get(); + } + + if (i->video) { + score += 100; + } + + if (score > best_score) { + best_summary = i->path(0).leaf().string(); + best_score = score; + } + } + + return best_summary; +}