Make it possible to do more stuff when there is missing DCP content in a project.
authorCarl Hetherington <cth@carlh.net>
Fri, 30 Oct 2015 13:16:52 +0000 (13:16 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 30 Oct 2015 13:16:52 +0000 (13:16 +0000)
src/lib/dcp_content.cc
src/lib/player.cc

index 747216f3c666853a212bc3291d7262c0b744ed11..c072dfa3d115a50b3774efaecf76ff536f9bac41 100644 (file)
@@ -42,6 +42,7 @@ using std::distance;
 using std::pair;
 using std::list;
 using boost::shared_ptr;
+using boost::scoped_ptr;
 using boost::optional;
 
 int const DCPContentProperty::CAN_BE_PLAYED      = 600;
@@ -255,12 +256,20 @@ list<DCPTimePeriod>
 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()) {
+       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;
index b8eadf793ae3f54c516764efbbc91717df9d01f2..3ae95cf5275d2ea0f5393c6d7d9abc40909e9501 100644 (file)
@@ -74,6 +74,7 @@ using boost::shared_ptr;
 using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
+using boost::scoped_ptr;
 
 Player::Player (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist)
        : _film (film)
@@ -752,9 +753,16 @@ Player::get_reel_assets ()
                if (!j) {
                        continue;
                }
-               DCPDecoder decoder (j, false);
+
+               scoped_ptr<DCPDecoder> decoder;
+               try {
+                       decoder.reset (new DCPDecoder (j, false));
+               } catch (...) {
+                       return a;
+               }
+
                int64_t offset = 0;
-               BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder.reels()) {
+               BOOST_FOREACH (shared_ptr<dcp::Reel> k, decoder->reels()) {
                        DCPTime const from = i->position() + DCPTime::from_frames (offset, _film->video_frame_rate());
                        if (j->reference_video ()) {
                                a.push_back (