Add minimal player HTTP server (#2830).
[dcpomatic.git] / src / lib / util.cc
index 60117f61ddeeb8a4425c2bdea29bf7389a9e91b6..172b8d763e73dee9a959e0b0cd402a7e2f227f2d 100644 (file)
@@ -56,6 +56,7 @@
 #include <dcp/file.h>
 #include <dcp/filesystem.h>
 #include <dcp/locale_convert.h>
+#include <dcp/mpeg2_picture_asset.h>
 #include <dcp/picture_asset.h>
 #include <dcp/raw_convert.h>
 #include <dcp/scope_guard.h>
@@ -88,10 +89,11 @@ LIBDCP_ENABLE_WARNINGS
 #include <dbghelp.h>
 #endif
 #include <signal.h>
+#include <climits>
 #include <iomanip>
 #include <iostream>
 #include <fstream>
-#include <climits>
+#include <numeric>
 #include <stdexcept>
 #ifdef DCPOMATIC_POSIX
 #include <execinfo.h>
@@ -103,6 +105,7 @@ LIBDCP_ENABLE_WARNINGS
 
 using std::bad_alloc;
 using std::cout;
+using std::dynamic_pointer_cast;
 using std::endl;
 using std::istream;
 using std::list;
@@ -119,9 +122,6 @@ using std::vector;
 using std::wstring;
 using boost::thread;
 using boost::optional;
-using boost::lexical_cast;
-using boost::bad_lexical_cast;
-using boost::scoped_array;
 using dcp::Size;
 using dcp::raw_convert;
 using dcp::locale_convert;
@@ -748,9 +748,10 @@ asset_filename (shared_ptr<dcp::Asset> asset, string type, int reel_index, int r
 
 
 string
-video_asset_filename (shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count, optional<string> summary)
+video_asset_filename(shared_ptr<dcp::PictureAsset> asset, int reel_index, int reel_count, optional<string> summary)
 {
-       return asset_filename(asset, "j2c", reel_index, reel_count, summary, ".mxf");
+       string type = dynamic_pointer_cast<dcp::MPEG2PictureAsset>(asset) ? "mpeg2" : "j2c";
+       return asset_filename(asset, type, reel_index, reel_count, summary, ".mxf");
 }
 
 
@@ -847,6 +848,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:
@@ -1148,6 +1151,7 @@ setup_grok_library_path()
 }
 #endif
 
+
 string
 screen_names_to_string(vector<string> names)
 {
@@ -1175,3 +1179,23 @@ screen_names_to_string(vector<string> names)
        return result.substr(0, result.length() - 2);
 }
 
+
+string
+report_problem()
+{
+       return String::compose(_("Please report this problem by using Help -> Report a problem or via email to %1"), variant::report_problem_email());
+}
+
+
+string
+join_strings(vector<string> const& in, string const& separator)
+{
+       if (in.empty()) {
+               return {};
+       }
+
+       return std::accumulate(std::next(in.begin()), in.end(), in.front(), [separator](string a, string b) {
+               return a + separator + b;
+       });
+}
+