diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-05-16 22:40:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-05-18 11:50:29 +0100 |
| commit | d3302b79771116d7e79a841e40e5a1917975442c (patch) | |
| tree | efd464a422fa6a700eaa09a8c2859940f7cd5bdc /src/lib | |
| parent | e3d86593186ebf6c73a54b679332964d6b1b750b (diff) | |
More of previous.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dcp_content.cc | 31 | ||||
| -rw-r--r-- | src/lib/dcp_content.h | 8 | ||||
| -rw-r--r-- | src/lib/overlaps.h | 29 | ||||
| -rw-r--r-- | 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 <class T> bool -DCPContent::can_reference (string overlapping, list<string>& why_not) const +DCPContent::can_reference (function<shared_ptr<ContentPart> (shared_ptr<const Content>)> part, string overlapping, list<string>& why_not) const { list<DCPTimePeriod> 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<string>& why_not) const } } - list<shared_ptr<T> > a = overlaps<T> (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<string>& why_not) const bool DCPContent::can_reference_video (list<string>& 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<string>& why_not) const { - /* XXX: this needs to be fixed */ - return true; + DCPDecoder decoder (shared_from_this(), film()->log(), false); + BOOST_FOREACH (shared_ptr<dcp::Reel> 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<string>& why_not) const { - /* XXX: this needs to be fixed */ - return true; + DCPDecoder decoder (shared_from_this(), film()->log(), false); + BOOST_FOREACH (shared_ptr<dcp::Reel> 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<DCPTimePeriod> reels () const; - template <class T> bool can_reference (std::string overlapping, std::list<std::string>& why_not) const; + bool can_reference ( + boost::function <boost::shared_ptr<ContentPart> (boost::shared_ptr<const Content>)>, + std::string overlapping, + std::list<std::string>& 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 <cth@carlh.net> + Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net> 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<class C> -std::list<boost::shared_ptr<C> > -overlaps (ContentList cl, DCPTime from, DCPTime to) -{ - std::list<boost::shared_ptr<C> > overlaps; - DCPTimePeriod period (from, to); - for (typename ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) { - boost::shared_ptr<C> c = boost::dynamic_pointer_cast<C> (*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<ContentPart> (boost::shared_ptr<const Content>)> 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 |
