From d3302b79771116d7e79a841e40e5a1917975442c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 16 May 2016 22:40:50 +0100 Subject: [PATCH 1/1] More of previous. --- src/lib/dcp_content.cc | 31 ++++++++++++++++++++++--------- src/lib/dcp_content.h | 8 +++++++- src/lib/overlaps.h | 29 ++++++++++------------------- src/lib/wscript | 1 + 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index b28e91dd5..023af8e95 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -48,6 +48,7 @@ using std::list; using boost::shared_ptr; using boost::scoped_ptr; using boost::optional; +using boost::function; int const DCPContentProperty::CAN_BE_PLAYED = 600; int const DCPContentProperty::REFERENCE_VIDEO = 601; @@ -327,9 +328,8 @@ DCPContent::reel_split_points () const return s; } -template bool -DCPContent::can_reference (string overlapping, list& why_not) const +DCPContent::can_reference (function (shared_ptr)> part, string overlapping, list& why_not) const { list const fr = film()->reels (); /* fr must contain reels(). It can also contain other reels, but it must at @@ -342,7 +342,7 @@ DCPContent::can_reference (string overlapping, list& why_not) const } } - list > a = overlaps (film()->content(), position(), end()); + ContentList a = overlaps (film()->content(), part, position(), end()); if (a.size() != 1 || a.front().get() != this) { why_not.push_back (overlapping); return false; @@ -354,20 +354,33 @@ DCPContent::can_reference (string overlapping, list& why_not) const bool DCPContent::can_reference_video (list& why_not) const { - /* XXX: this needs to be fixed */ - return true; + return can_reference (bind (&Content::video, _1), _("There is other video content overlapping this DCP; remove it."), why_not); } bool DCPContent::can_reference_audio (list& why_not) const { - /* XXX: this needs to be fixed */ - return true; + DCPDecoder decoder (shared_from_this(), film()->log(), false); + BOOST_FOREACH (shared_ptr i, decoder.reels()) { + if (!i->main_sound()) { + why_not.push_back (_("The DCP does not have sound in all reels.")); + return false; + } + } + + return can_reference (bind (&Content::audio, _1), _("There is other audio content overlapping this DCP; remove it."), why_not); } bool DCPContent::can_reference_subtitle (list& why_not) const { - /* XXX: this needs to be fixed */ - return true; + DCPDecoder decoder (shared_from_this(), film()->log(), false); + BOOST_FOREACH (shared_ptr i, decoder.reels()) { + if (!i->main_subtitle()) { + why_not.push_back (_("The DCP does not have subtitles in all reels.")); + return false; + } + } + + return can_reference (bind (&Content::subtitle, _1), _("There is other subtitle content overlapping this DCP; remove it."), why_not); } diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 5c80587dd..489151e03 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -37,6 +37,8 @@ public: static int const REFERENCE_SUBTITLE; }; +class ContentPart; + /** @class DCPContent * @brief An existing DCP used as input. */ @@ -112,7 +114,11 @@ private: void read_directory (boost::filesystem::path); std::list reels () const; - template bool can_reference (std::string overlapping, std::list& why_not) const; + bool can_reference ( + boost::function (boost::shared_ptr)>, + std::string overlapping, + std::list& why_not + ) const; std::string _name; /** true if our DCP is encrypted */ diff --git a/src/lib/overlaps.h b/src/lib/overlaps.h index 6018af15f..d8a44b554 100644 --- a/src/lib/overlaps.h +++ b/src/lib/overlaps.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,23 +17,14 @@ */ -/** @return Pieces of content type C that overlap a specified time range in the given ContentList */ -template -std::list > -overlaps (ContentList cl, DCPTime from, DCPTime to) -{ - std::list > overlaps; - DCPTimePeriod period (from, to); - for (typename ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) { - boost::shared_ptr c = boost::dynamic_pointer_cast (*i); - if (!c) { - continue; - } +#include "types.h" +#include "dcpomatic_time.h" - if (DCPTimePeriod(c->position(), c->end()).overlaps (period)) { - overlaps.push_back (c); - } - } +class ContentPart; - return overlaps; -} +/** @return Pieces of content with a given part (video, audio, + * subtitle) that overlap a specified time range in the given + * ContentList */ +ContentList overlaps ( + ContentList cl, boost::function (boost::shared_ptr)> part, DCPTime from, DCPTime to + ); diff --git a/src/lib/wscript b/src/lib/wscript index 4104e57a7..4b6754b2e 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -94,6 +94,7 @@ sources = """ magick_image_proxy.cc md5_digester.cc mid_side_decoder.cc + overlaps.cc player.cc player_subtitles.cc player_video.cc -- 2.30.2