/* [XML] ISDCFNamePartLength Maximum length of the "name" part of an ISDCF name, which should be 14 according to the standard */
root->add_child("ISDCFNamePartLength")->add_child_text(raw_convert<string>(_isdcf_name_part_length));
- root->add_child("GpuBinaryLocation")->add_child_text (_gpu_binary_location);
+ root->add_child("GpuBinaryLocation")->add_child_text (_gpu_binary_location.string());
root->add_child("EnableGpu")->add_child_text ((_enable_gpu ? "1" : "0"));
root->add_child("SelectedGpu")->add_child_text (raw_convert<string> (_selected_gpu));
root->add_child("GpuLicenseServer")->add_child_text (_gpu_license_server);
return _allow_smpte_bv20;
}
- std::string gpu_binary_location () const {
+ boost::filesystem::path gpu_binary_location() const {
return _gpu_binary_location;
}
void set_allow_smpte_bv20(bool allow) {
maybe_set(_allow_smpte_bv20, allow, ALLOW_SMPTE_BV20);
}
- void set_gpu_binary_location (std::string location) {
+
+ void set_gpu_binary_location(boost::filesystem::path location) {
maybe_set (_gpu_binary_location, location);
}
+
void set_enable_gpu (bool enable) {
maybe_set (_enable_gpu, enable);
}
+
void set_selected_gpu (int selected) {
maybe_set (_selected_gpu, selected);
}
+
void set_gpu_license_server (std::string s) {
maybe_set (_gpu_license_server, s);
}
+
void set_gpu_license_port (int p) {
maybe_set (_gpu_license_port, p);
}
+
void set_gpu_license (std::string p) {
maybe_set (_gpu_license, p);
}
+
void set_isdcf_name_part_length(int length) {
maybe_set(_isdcf_name_part_length, length, ISDCF_NAME_PART_LENGTH);
}
/* GPU */
bool _enable_gpu;
- std::string _gpu_binary_location;
+ boost::filesystem::path _gpu_binary_location;
int _selected_gpu;
std::string _gpu_license_server;
int _gpu_license_port;
};
struct DcpomaticContext {
- DcpomaticContext(std::shared_ptr<const Film> film, Writer& writer,
- EventHistory &history, const std::string &location) :
- film_(film), writer_(writer),
- history_(history), location_(location),
- width_(0), height_(0)
- {}
+ DcpomaticContext(
+ std::shared_ptr<const Film> film,
+ Writer& writer,
+ EventHistory& history,
+ boost::filesystem::path const& location
+ )
+ : film_(film)
+ , writer_(writer)
+ , history_(history)
+ , _location(location)
+ , width_(0)
+ , height_(0)
+ {
+
+ }
+
void setDimensions(uint32_t w, uint32_t h) {
width_ = w;
height_ = h;
std::shared_ptr<const Film> film_;
Writer& writer_;
EventHistory &history_;
- std::string location_;
+ boost::filesystem::path _location;
uint32_t width_;
uint32_t height_;
};
launched_(false)
{
if (Config::instance()->enable_gpu ()) {
- boost::filesystem::path folder(dcpomaticContext_.location_);
+ boost::filesystem::path folder(dcpomaticContext_._location);
boost::filesystem::path binaryPath = folder / "grk_compress";
if (!boost::filesystem::exists(binaryPath)) {
- getMessengerLogger()->error("Invalid binary location %s",
- dcpomaticContext_.location_.c_str());
- return;
+ getMessengerLogger()->error(
+ "Invalid binary location %s", dcpomaticContext_._location.c_str()
+ );
+ return;
}
auto proc = [this](const std::string& str) {
try {
auto s = dcpv.get_size();
dcpomaticContext_.setDimensions(s.width, s.height);
auto config = Config::instance();
- messenger_->launchGrok(dcpomaticContext_.location_,
- dcpomaticContext_.width_,dcpomaticContext_.width_,
- dcpomaticContext_.height_,
- 3, 12, device,
- dcpomaticContext_.film_->resolution() == Resolution::FOUR_K,
- dcpomaticContext_.film_->video_frame_rate(),
- dcpomaticContext_.film_->j2k_bandwidth(),
- config->gpu_license_server(),
- config->gpu_license_port(),
- config->gpu_license());
+ messenger_->launchGrok(
+ dcpomaticContext_._location,
+ dcpomaticContext_.width_,dcpomaticContext_.width_,
+ dcpomaticContext_.height_,
+ 3, 12, device,
+ dcpomaticContext_.film_->resolution() == Resolution::FOUR_K,
+ dcpomaticContext_.film_->video_frame_rate(),
+ dcpomaticContext_.film_->j2k_bandwidth(),
+ config->gpu_license_server(),
+ config->gpu_license_port(),
+ config->gpu_license()
+ );
}
launched_ = messenger_->waitForClientInit();
sendQueue.push(oss.str());
}
- void launchGrok(const std::string &dir, uint32_t width, uint32_t stride,
- uint32_t height, uint32_t samplesPerPixel, uint32_t depth,
- int device, bool is4K, uint32_t fps, uint32_t bandwidth,
- const std::string server, uint32_t port,
- const std::string license)
+
+ void launchGrok(
+ boost::filesystem::path const& dir,
+ uint32_t width,
+ uint32_t stride,
+ uint32_t height,
+ uint32_t samplesPerPixel,
+ uint32_t depth,
+ int device,
+ bool is4K,
+ uint32_t fps,
+ uint32_t bandwidth,
+ const std::string server,
+ uint32_t port,
+ const std::string license
+ )
{
std::unique_lock<std::mutex> lk(shutdownMutex_);
protected:
std::condition_variable clientInitializedCondition_;
private:
- void launch(const std::string &cmd, const std::string &dir)
+ void launch(std::string const& cmd, boost::filesystem::path const& dir)
{
// Change the working directory
if(!dir.empty())
{
- if(chdir(dir.c_str()) != 0)
- {
+ boost::system::error_code ec;
+ boost::filesystem::current_path(dir, ec);
+ if (ec) {
getMessengerLogger()->error("Error: failed to change the working directory");
return;
}
#pragma once
-static std::vector<std::string> get_gpu_names(std::string binary, std::string filename)
+static std::vector<std::string> get_gpu_names(boost::filesystem::path binary, boost::filesystem::path filename)
{
// Execute the GPU listing program and redirect its output to a file
- if (std::system((binary + " > " + filename).c_str()) < 0) {
+ if (std::system((binary.string() + " > " + filename.string()).c_str()) < 0) {
return {};
}
std::vector<std::string> gpu_names;
- std::ifstream file(filename);
+ std::ifstream file(filename.c_str());
if (file.is_open())
{
std::string line;
}
void update(void) {
auto cfg = Config::instance();
- auto lister_binary = cfg->gpu_binary_location() + "/" + "gpu_lister";
- auto lister_file = cfg->gpu_binary_location () + "/" + "gpus.txt";
+ auto lister_binary = cfg->gpu_binary_location() / "gpu_lister";
+ auto lister_file = cfg->gpu_binary_location () / "gpus.txt";
if (boost::filesystem::exists(lister_binary)) {
auto gpu_names = get_gpu_names(lister_binary, lister_file);
auto config = Config::instance ();
checked_set (_enable_gpu, config->enable_gpu());
- _binary_location->SetPath(config->gpu_binary_location ());
+ _binary_location->SetPath(std_to_wx(config->gpu_binary_location().string()));
_gpu_list_control->update();
_gpu_list_control->setSelection(config->selected_gpu());
checked_set (_server, config->gpu_license_server());