diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-11-16 00:19:29 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-11-16 00:19:29 +0000 |
| commit | 8a05e8f7d58fb7411e091ae8161c351f735f7735 (patch) | |
| tree | 4585a7105edc9095d7f5e7719f310f3e799c5ee8 /src/lib | |
| parent | 12a621982da4a7e0976829654ecc16026665c4e9 (diff) | |
Catch failures to read missing DCPs in various places.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dcp_content.cc | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index dc32a243e..8c1b2d8a1 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -428,10 +428,18 @@ DCPContent::can_reference (function<shared_ptr<ContentPart> (shared_ptr<const Co list<DCPTimePeriod> const fr = film()->reels (); + list<DCPTimePeriod> reel_list; + try { + reel_list = reels (); + } catch (dcp::DCPReadError) { + /* We couldn't read the DCP; it's probably missing */ + return false; + } + /* fr must contain reels(). It can also contain other reels, but it must at least contain reels(). */ - BOOST_FOREACH (DCPTimePeriod i, reels()) { + BOOST_FOREACH (DCPTimePeriod i, reel_list) { if (find (fr.begin(), fr.end(), i) == fr.end ()) { why_not.push_back (_("The reel lengths in the film differ from those in the DCP; set the reel mode to 'split by video content'.")); return false; @@ -461,8 +469,15 @@ DCPContent::can_reference_video (list<string>& why_not) const bool DCPContent::can_reference_audio (list<string>& why_not) const { - DCPDecoder decoder (shared_from_this(), film()->log()); - BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder.reels()) { + shared_ptr<DCPDecoder> decoder; + try { + decoder.reset (new DCPDecoder (shared_from_this(), film()->log())); + } catch (dcp::DCPReadError) { + /* We couldn't read the DCP, so it's probably missing */ + return 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; @@ -475,8 +490,15 @@ DCPContent::can_reference_audio (list<string>& why_not) const bool DCPContent::can_reference_subtitle (list<string>& why_not) const { - DCPDecoder decoder (shared_from_this(), film()->log()); - BOOST_FOREACH (shared_ptr<dcp::Reel> i, decoder.reels()) { + shared_ptr<DCPDecoder> decoder; + try { + decoder.reset (new DCPDecoder (shared_from_this(), film()->log())); + } catch (dcp::DCPReadError) { + /* We couldn't read the DCP, so it's probably missing */ + return 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; |
