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;
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
}
}
- 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;
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);
}
static int const REFERENCE_SUBTITLE;
};
+class ContentPart;
+
/** @class DCPContent
* @brief An existing DCP used as input.
*/
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 */
/*
- 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
*/
-/** @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
+ );