return false;
}
- /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
- return can_reference(
- film, [](shared_ptr<const Content> c) {
- return static_cast<bool>(c->audio) && !c->audio->mapping().mapped_output_channels().empty();
- },
- _("it overlaps other audio content; remove the other content."),
- why_not
- );
+ if (audio && audio->stream()) {
+ auto const channels = audio->stream()->channels();
+ if (channels != film->audio_channels()) {
+ why_not = String::compose(_("it has a different number of audio channels than the project; set the project to have %1 channels."), channels);
+ return false;
+ }
+ }
+
+ auto part = [](shared_ptr<const Content> c) {
+ return static_cast<bool>(c->audio) && !c->audio->mapping().mapped_output_channels().empty();
+ };
+
+ if (overlaps(film, part)) {
+ /// TRANSLATORS: this string will follow "Cannot reference this DCP: "
+ why_not = _("it overlaps other audio content.");
+ return false;
+ }
+
+ return can_reference_anything(film, why_not);
}
}
-
+#ifdef DCPOMATIC_GROK
+void
+setup_grok_library_path()
+{
+ static std::string old_path;
+ if (old_path.empty()) {
+ auto const old = getenv("LD_LIRARY_PATH");
+ if (old) {
+ old_path = old;
+ }
+ }
+ auto const grok = Config::instance()->grok();
+ if (!grok || grok->binary_location.empty()) {
+ setenv("LD_LIRARY_PATH", old_path.c_str(), 1);
+ return;
+ }
+
+ std::string new_path = old_path;
+ if (!new_path.empty()) {
+ new_path += ":";
+ }
+ new_path += grok->binary_location.string();
+
+ setenv("LD_LIBRARY_PATH", new_path.c_str(), 1);
+}
+#endif
++
+ string
+ screen_names_to_string(vector<string> names)
+ {
+ if (names.empty()) {
+ return {};
+ }
+
+ auto number = [](string const& s) {
+ return s.find_first_not_of("0123456789") == string::npos;
+ };
+
+ if (std::find_if(names.begin(), names.end(), [number](string const& s) { return !number(s); }) == names.end()) {
+ std::sort(names.begin(), names.end(), [](string const& a, string const& b) {
+ return dcp::raw_convert<int>(a) < dcp::raw_convert<int>(b);
+ });
+ } else {
+ std::sort(names.begin(), names.end());
+ }
+
+ string result;
+ for (auto const& name: names) {
+ result += name + ", ";
+ }
+
+ return result.substr(0, result.length() - 2);
+ }
+
extern bool contains_assetmap(boost::filesystem::path dir);
extern std::string word_wrap(std::string input, int columns);
extern void capture_ffmpeg_logs();
+#ifdef DCPOMATIC_GROK
+extern void setup_grok_library_path();
+#endif
+
+
+template <class T>
+T
+number_attribute(cxml::ConstNodePtr node, std::string name1, std::string name2)
+{
+ auto value = node->optional_number_attribute<T>(name1);
+ if (!value) {
+ value = node->number_attribute<T>(name2);
+ }
+ return *value;
+}
+
+ extern std::string screen_names_to_string(std::vector<std::string> names);
+
#endif