Note that newer libsub version is required.
[dcpomatic.git] / src / lib / util.cc
index 997470a210d9437d87efa81a8bf1e12a81e8d69e..fdc647fbab8c9506bc9a2ee4cc7894b44a341982 100644 (file)
@@ -598,6 +598,7 @@ digest_head_tail (vector<boost::filesystem::path> files, boost::uintmax_t size)
 string
 simple_digest (vector<boost::filesystem::path> paths)
 {
+       DCP_ASSERT(!paths.empty());
        return digest_head_tail(paths, 1000000) + raw_convert<string>(dcp::filesystem::file_size(paths.front()));
 }
 
@@ -839,6 +840,8 @@ audio_channel_types (list<int> mapped, int channels)
                case dcp::Channel::BSR:
                        ++non_lfe;
                        break;
+               case dcp::Channel::LC:
+               case dcp::Channel::RC:
                case dcp::Channel::HI:
                case dcp::Channel::VI:
                case dcp::Channel::MOTION_DATA:
@@ -1122,3 +1125,31 @@ word_wrap(string input, int columns)
        return output;
 }
 
+
+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);
+}
+