Fix error when loading encrypted DCPs (#2257).
authorCarl Hetherington <cth@carlh.net>
Sat, 21 May 2022 20:16:55 +0000 (22:16 +0200)
committerCarl Hetherington <cth@carlh.net>
Sat, 21 May 2022 20:16:55 +0000 (22:16 +0200)
In d1b4dbb793e2850d032ce3c91f0c91d045ae19dc I changed have_video()
to look at can_be_played() but forgot to also change have_audio().

src/lib/player.cc
test/player_test.cc

index f3d78ab323803b396186ba928b5688c129b469a3..0f72ed8588dbbc7f3fa7861f64e415f81f532279 100644 (file)
@@ -154,7 +154,7 @@ have_video (shared_ptr<const Content> content)
 bool
 have_audio (shared_ptr<const Content> content)
 {
-       return static_cast<bool>(content->audio);
+       return static_cast<bool>(content->audio) && content->can_be_played();
 }
 
 
index 3fb8691a5222571560b3e1bf25fe1c8387b9d58e..03f2eb6e655d977f0910c3338e15f94cbd13675c 100644 (file)
@@ -466,3 +466,34 @@ BOOST_AUTO_TEST_CASE (player_silence_at_end_crash)
        film2->set_video_frame_rate (24);
        make_and_verify_dcp (film2);
 }
+
+
+/** #2257 */
+BOOST_AUTO_TEST_CASE (encrypted_dcp_with_no_kdm_gives_no_butler_error)
+{
+       auto content = content_factory("test/data/flat_red.png").front();
+       auto film = new_test_film2 ("encrypted_dcp_with_no_kdm_gives_no_butler_error", { content });
+       int constexpr length = 24 * 25;
+       content->video->set_length(length);
+       film->set_encrypted (true);
+       make_and_verify_dcp (
+               film,
+               {
+                       dcp::VerificationNote::Code::MISSING_CPL_METADATA,
+               });
+
+       auto content2 = std::make_shared<DCPContent>(film->dir(film->dcp_name()));
+       auto film2 = new_test_film2 ("encrypted_dcp_with_no_kdm_gives_no_butler_error2", { content2 });
+
+       auto player = std::make_shared<Player>(film2, Image::Alignment::COMPACT);
+       Butler butler(film2, player, AudioMapping(), 2, bind(PlayerVideo::force, AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::PADDED, true, false);
+
+       float buffer[2000 * 6];
+       for (int i = 0; i < length; ++i) {
+               butler.get_video(Butler::Behaviour::BLOCKING, 0);
+               butler.get_audio(Butler::Behaviour::BLOCKING, buffer, 2000);
+       }
+
+       BOOST_CHECK_NO_THROW(butler.rethrow());
+}
+