LOG_ERROR("Could not write assets file %1", file(assets_file));
}
}
+
+
+vector<ReelType>
+Film::possible_reel_types() const
+{
+ auto film_reels = reels_for_type(ReelType::SINGLE);
+
+ bool referring = false;
+ bool dcp_reel_not_present = false;
+
+ for (auto c: content()) {
+ if (auto dcp = dynamic_pointer_cast<DCPContent>(c)) {
+ if (dcp->reference_anything()) {
+ referring = true;
+ try {
+ for (auto const& dcp_reel: dcp->reels(shared_from_this())) {
+ if (std::find(film_reels.begin(), film_reels.end(), dcp_reel) == film_reels.end()) {
+ dcp_reel_not_present = true;
+ }
+ }
+ } catch (dcp::ReadError &) {
+ /* We couldn't read the DCP; it's probably missing */
+ }
+ }
+ }
+ }
+
+ if (referring && !dcp_reel_not_present) {
+ /* We're referring to some DCP content but single-reel mode is possible.
+ * We'll disallow BY_LENGTH and CUSTOM just for an easy life.
+ */
+
+ return { ReelType::SINGLE, ReelType::BY_VIDEO_CONTENT };
+ } else if (referring && dcp_reel_not_present) {
+ /* We have to use by-video */
+ return { ReelType::BY_VIDEO_CONTENT };
+ }
+
+ return { ReelType::SINGLE, ReelType::BY_VIDEO_CONTENT, ReelType::BY_LENGTH, ReelType::CUSTOM };
+}
+
void add_ffoc_lfoc(Markers& markers) const;
+ /** @return Reel types that are allowed given the current state of the film */
+ std::vector<ReelType> possible_reel_types() const;
+
void set_ui_state(std::string key, std::string value);
boost::optional<std::string> ui_state(std::string key) const;
void read_ui_state();
#include "lib/content_factory.h"
+#include "lib/dcp_content.h"
#include "lib/film.h"
+#include "lib/job_manager.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
+using std::make_shared;
+
+
BOOST_AUTO_TEST_CASE(film_contains_atmos_content_test)
{
auto atmos = content_factory("test/data/atmos_0.mxf")[0];
BOOST_CHECK(!film4->contains_atmos_content());
}
+
+BOOST_AUTO_TEST_CASE(film_possible_reel_types_test1)
+{
+ auto film = new_test_film("film_possible_reel_types_test1");
+ BOOST_CHECK_EQUAL(film->possible_reel_types().size(), 4U);
+
+ film->examine_and_add_content(content_factory("test/data/flat_red.png")[0]);
+ BOOST_REQUIRE(!wait_for_jobs());
+ BOOST_CHECK_EQUAL(film->possible_reel_types().size(), 4U);
+
+ auto dcp = make_shared<DCPContent>("test/data/reels_test2");
+ film->examine_and_add_content(dcp);
+ BOOST_REQUIRE(!wait_for_jobs());
+ BOOST_CHECK_EQUAL(film->possible_reel_types().size(), 4U);
+
+ /* If we don't do this the set_reference_video will be overridden by the Film's
+ * check_settings_consistency() stuff.
+ */
+ film->set_reel_type(ReelType::BY_VIDEO_CONTENT);
+ dcp->set_reference_video(true);
+ BOOST_CHECK_EQUAL(film->possible_reel_types().size(), 1U);
+}
+
+
+BOOST_AUTO_TEST_CASE(film_possible_reel_types_test2)
+{
+ auto film = new_test_film("film_possible_reel_types_test2");
+
+ auto dcp = make_shared<DCPContent>("test/data/dcp_digest_test_dcp");
+ film->examine_and_add_content(dcp);
+ BOOST_REQUIRE(!wait_for_jobs());
+ BOOST_CHECK_EQUAL(film->possible_reel_types().size(), 4U);
+
+ dcp->set_reference_video(true);
+ BOOST_CHECK_EQUAL(film->possible_reel_types().size(), 2U);
+}
+