summaryrefslogtreecommitdiff
path: root/test/mpeg2_dcp_test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-09-14 22:16:01 +0200
committerCarl Hetherington <cth@carlh.net>2025-09-15 14:27:21 +0200
commit7cd1d82e33d074050b132dba8c4ae4e0d4804310 (patch)
treebe8a4e4e630450736b4cba12a518e1219a688c71 /test/mpeg2_dcp_test.cc
parentde3466fa0e6b8fa39fda86d39c2d4792ec69ecbf (diff)
Allow building with boost::process v2 (added in Ubuntu 25.10).
Diffstat (limited to 'test/mpeg2_dcp_test.cc')
-rw-r--r--test/mpeg2_dcp_test.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/mpeg2_dcp_test.cc b/test/mpeg2_dcp_test.cc
index dd439eac6..0a4d4512e 100644
--- a/test/mpeg2_dcp_test.cc
+++ b/test/mpeg2_dcp_test.cc
@@ -33,6 +33,7 @@
using std::make_shared;
using std::shared_ptr;
using std::string;
+using std::vector;
static
@@ -47,6 +48,8 @@ mbits_per_second(shared_ptr<const Film> film)
#ifdef DCPOMATIC_LINUX
+
+#ifdef DCPOMATIC_BOOST_PROCESS_V1
static
string
bitrate_in_header(shared_ptr<const Film> film)
@@ -71,6 +74,49 @@ bitrate_in_header(shared_ptr<const Film> film)
return rate;
}
+
+#else
+
+static
+string
+bitrate_in_header(shared_ptr<const Film> film)
+{
+ namespace bp = boost::process::v2;
+
+ boost::asio::io_context context;
+ boost::asio::readable_pipe out{context};
+ bp::process child(context, bp::environment::find_executable("mediainfo"), { find_file(film->dir(film->dcp_name()), "mpeg2").string() }, bp::process_stdio{{}, out, {}});
+
+ string output;
+ boost::system::error_code ec;
+ while (child.running()) {
+ string block;
+ boost::asio::read(out, boost::asio::dynamic_buffer(block), ec);
+ output += block;
+ if (ec && ec == boost::asio::error::eof) {
+ break;
+ }
+ }
+
+ vector<string> lines;
+ boost::algorithm::split(lines, output, boost::is_any_of("\n"));
+
+ string rate;
+ for (auto const& line: lines) {
+ if (line.substr(0, 10) == "Bit rate ") {
+ auto colon = line.find(":");
+ if (colon != string::npos) {
+ rate = line.substr(colon + 2);
+ }
+ }
+ }
+
+ child.wait();
+
+ return rate;
+}
+
+#endif
#endif