using std::pair;
using std::list;
using boost::shared_ptr;
+using boost::scoped_ptr;
using boost::optional;
int const DCPContentProperty::CAN_BE_PLAYED = 600;
DCPTime
DCPContent::full_length () const
{
- shared_ptr<const Film> film = _film.lock ();
- DCPOMATIC_ASSERT (film);
- FrameRateChange const frc (video_frame_rate (), film->video_frame_rate ());
- return DCPTime::from_frames (llrint (video_length () * frc.factor ()), film->video_frame_rate ());
+ FrameRateChange const frc (video_frame_rate (), film()->video_frame_rate ());
+ return DCPTime::from_frames (llrint (video_length () * frc.factor ()), film()->video_frame_rate ());
}
string
DCPContent::reels () const
{
list<DCPTimePeriod> p;
- DCPDecoder decoder (shared_from_this(), false);
+ scoped_ptr<DCPDecoder> decoder;
+ try {
+ decoder.reset (new DCPDecoder (shared_from_this(), false));
+ } catch (...) {
+ /* Could not load the DCP; guess reels */
+ list<DCPTimePeriod> p;
+ p.push_back (DCPTimePeriod (position(), end()));
+ return p;
+ }
- shared_ptr<const Film> film = _film.lock ();
- DCPOMATIC_ASSERT (film);
DCPTime from = position ();
- BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder.reels()) {
- DCPTime const to = from + DCPTime::from_frames (i->main_picture()->duration(), film->video_frame_rate());
+ BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder->reels()) {
+ DCPTime const to = from + DCPTime::from_frames (i->main_picture()->duration(), film()->video_frame_rate());
p.push_back (DCPTimePeriod (from, to));
from = to;
}
bool
DCPContent::can_reference (string overlapping, list<string>& why_not) const
{
- shared_ptr<const Film> film = _film.lock ();
- DCPOMATIC_ASSERT (film);
-
- list<DCPTimePeriod> const fr = film->reels ();
+ list<DCPTimePeriod> const fr = film()->reels ();
/* fr must contain reels(). It can also contain other reels, but it must at
least contain reels().
*/
}
}
- list<shared_ptr<T> > a = overlaps<T> (film->content(), position(), end());
+ list<shared_ptr<T> > a = overlaps<T> (film()->content(), position(), end());
if (a.size() != 1 || a.front().get() != this) {
why_not.push_back (overlapping);
return false;
bool
DCPContent::can_reference_audio (list<string>& why_not) const
{
+ DCPDecoder decoder (shared_from_this(), 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<AudioContent> (_("There is other audio content overlapping this DCP; remove it."), why_not);
}
bool
DCPContent::can_reference_subtitle (list<string>& why_not) const
{
+ DCPDecoder decoder (shared_from_this(), 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<SubtitleContent> (_("There is other subtitle content overlapping this DCP; remove it."), why_not);
}