set_notification_email_to_default ();
set_cover_sheet_to_default ();
- _gpu_binary_location = "";
- _enable_gpu = false;
- _selected_gpu = 0;
- _gpu_license_server = "";
- _gpu_license_port = 5000;
- _gpu_license = "";
+#ifdef DCPOMATIC_GROK
+ _grok = boost::none;
+#endif
_main_divider_sash_position = {};
_main_content_divider_sash_position = {};
_allow_smpte_bv20 = f.optional_bool_child("AllowSMPTEBv20").get_value_or(false);
_isdcf_name_part_length = f.optional_number_child<int>("ISDCFNamePartLength").get_value_or(14);
- _enable_gpu = f.optional_bool_child("EnableGPU").get_value_or(false);
- _gpu_binary_location = f.string_child("GPUBinaryLocation");
- _selected_gpu = f.number_child<int>("SelectedGPU");
- _gpu_license_server = f.string_child ("GPULicenseServer");
- _gpu_license_port = f.number_child<int> ("GPULicensePort");
- _gpu_license = f.string_child("GPULicense");
+#ifdef DCPOMATIC_GROK
+ if (auto grok = f.optional_node_child("Grok")) {
+ _grok = Grok(grok);
+ }
+#endif
_export.read(f.optional_node_child("Export"));
}
/* [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.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);
- root->add_child("GPULicensePort")->add_child_text (raw_convert<string> (_gpu_license_port));
- root->add_child("GPULicense")->add_child_text (_gpu_license);
+#ifdef DCPOMATIC_GROK
+ if (_grok) {
+ _grok->as_xml(root->add_child("Grok"));
+ }
+#endif
_export.write(root->add_child("Export"));
return iter->second;
}
+
+#ifdef DCPOMATIC_GROK
+
+Config::Grok::Grok(cxml::ConstNodePtr node)
+ : enable(node->bool_child("Enable"))
+ , binary_location(node->string_child("BinaryLocation"))
+ , selected(node->number_child<int>("Selected"))
+ , licence_server(node->string_child("LicenceServer"))
+ , licence_port(node->number_child<int>("LicencePort"))
+ , licence(node->string_child("Licence"))
+{
+
+}
+
+
+void
+Config::Grok::as_xml(xmlpp::Element* node) const
+{
+ node->add_child("BinaryLocation")->add_child_text(binary_location.string());
+ node->add_child("Enable")->add_child_text((enable ? "1" : "0"));
+ node->add_child("Selected")->add_child_text(raw_convert<string>(selected));
+ node->add_child("LicenceServer")->add_child_text(licence_server);
+ node->add_child("LicencePort")->add_child_text(raw_convert<string>(licence_port));
+ node->add_child("Licence")->add_child_text(licence);
+}
+
+
+void
+Config::set_grok(Grok const& grok)
+{
+ _grok = grok;
+ changed(OTHER);
+}
+
+#endif
return _allow_smpte_bv20;
}
- boost::filesystem::path gpu_binary_location() const {
- return _gpu_binary_location;
- }
-
- bool enable_gpu () const {
- return _enable_gpu;
- }
-
- int selected_gpu () const {
- return _selected_gpu;
- }
- std::string gpu_license_server () const {
- return _gpu_license_server;
- }
+#ifdef DCPOMATIC_GROK
+ class Grok
+ {
+ public:
+ Grok() = default;
+ Grok(cxml::ConstNodePtr node);
+
+ void as_xml(xmlpp::Element* node) const;
+
+ bool enable = false;
+ boost::filesystem::path binary_location;
+ int selected = 0;
+ std::string licence_server;
+ int licence_port = 5000;
+ std::string licence;
+ };
- int gpu_license_port () const {
- return _gpu_license_port;
- }
- std::string gpu_license () const {
- return _gpu_license;
+ boost::optional<Grok> grok() const {
+ return _grok;
}
+#endif
int isdcf_name_part_length() const {
return _isdcf_name_part_length;
maybe_set(_allow_smpte_bv20, allow, ALLOW_SMPTE_BV20);
}
- 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);
- }
+#ifdef DCPOMATIC_GROK
+ void set_grok(Grok const& grok);
+#endif
void set_isdcf_name_part_length(int length) {
maybe_set(_isdcf_name_part_length, length, ISDCF_NAME_PART_LENGTH);
bool _allow_smpte_bv20;
int _isdcf_name_part_length;
- /* GPU */
- bool _enable_gpu;
- boost::filesystem::path _gpu_binary_location;
- int _selected_gpu;
- std::string _gpu_license_server;
- int _gpu_license_port;
- std::string _gpu_license;
+#ifdef DCPOMATIC_GROK
+ boost::optional<Grok> _grok;
+#endif
ExportConfig _export;
explicit GrokContext(DcpomaticContext* dcpomatic_context)
: _dcpomatic_context(dcpomatic_context)
{
- if (!Config::instance()->enable_gpu()) {
+ auto grok = Config::instance()->grok().get_value_or({});
+ if (!grok.enable) {
return;
}
auto s = dcpv.get_size();
_dcpomatic_context->set_dimensions(s.width, s.height);
- auto config = Config::instance();
+ auto grok = Config::instance()->grok().get_value_or({});
if (!_messenger->launchGrok(
_dcpomatic_context->location,
_dcpomatic_context->width,
_dcpomatic_context->film->resolution() == Resolution::FOUR_K,
_dcpomatic_context->film->video_frame_rate(),
_dcpomatic_context->film->j2k_bandwidth(),
- config->gpu_license_server(),
- config->gpu_license_port(),
- config->gpu_license())) {
+ grok.licence_server,
+ grok.licence_port,
+ grok.licence)) {
_launch_failed = true;
return false;
}
LOG_TIMING("encoder-pop thread=%1 frame=%2 eyes=%3", thread_id(), frame.index(), static_cast<int>(frame.eyes()));
- if (_context->launch(frame, Config::instance()->selected_gpu()) && _context->scheduleCompress(frame)) {
+ auto grok = Config::instance()->grok().get_value_or({});
+
+ if (_context->launch(frame, grok.selected) && _context->scheduleCompress(frame)) {
frame_guard.cancel();
}
}
: _film (film)
, _history (200)
, _writer (writer)
+{
#ifdef DCPOMATIC_GROK
- , _dcpomatic_context(new grk_plugin::DcpomaticContext(film, writer, _history, Config::instance()->gpu_binary_location()))
- , _context(Config::instance()->enable_gpu() ? new grk_plugin::GrokContext(_dcpomatic_context) : nullptr)
+ auto grok = Config::instance()->grok().get_value_or({});
+ _dcpomatic_context = new grk_plugin::DcpomaticContext(film, writer, _history, grok.binary_location);
+ if (grok.enable) {
+ _context = new grk_plugin::GrokContext(_dcpomatic_context);
+ }
#endif
-{
}
J2KEncoder::servers_list_changed()
{
auto config = Config::instance();
+#ifdef DCPOMATIC_GROK
+ auto const grok_enable = config->grok().get_value_or({}).enable;
+#else
+ auto const grok_enable = false;
+#endif
- auto const cpu = (config->enable_gpu() || config->only_servers_encode()) ? 0 : config->master_encoding_threads();
- auto const gpu = config->enable_gpu() ? config->master_encoding_threads() : 0;
+ auto const cpu = (grok_enable || config->only_servers_encode()) ? 0 : config->master_encoding_threads();
+ auto const gpu = grok_enable ? config->master_encoding_threads() : 0;
remake_threads(cpu, gpu, EncodeServerFinder::instance()->servers());
}
void
J2KEncoder::pause()
{
- if (!Config::instance()->enable_gpu()) {
+#ifdef DCPOMATIC_GROK
+ if (!Config::instance()->grok().get_value_or({}).enable) {
return;
}
+ return;
terminate_threads ();
/* Something might have been thrown during terminate_threads */
rethrow ();
-#ifdef DCPOMATIC_GROK
delete _context;
_context = nullptr;
#endif
void J2KEncoder::resume()
{
- if (!Config::instance()->enable_gpu()) {
+#ifdef DCPOMATIC_GROK
+ if (!Config::instance()->grok().get_value_or({}).enable) {
return;
}
-#ifdef DCPOMATIC_GROK
_context = new grk_plugin::GrokContext(_dcpomatic_context);
-#endif
servers_list_changed();
+#endif
}
*/
for (auto & i: _queue) {
#ifdef DCPOMATIC_GROK
- if (Config::instance()->enable_gpu ()) {
+ if (Config::instance()->grok().get_value_or({}).enable) {
if (!_context->scheduleCompress(i)){
LOG_GENERAL (N_("[%1] J2KEncoder thread pushes frame %2 back onto queue after failure"), thread_id(), i.index());
// handle error
boost::signals2::scoped_connection _server_found_connection;
#ifdef DCPOMATIC_GROK
- grk_plugin::DcpomaticContext* _dcpomatic_context;
- grk_plugin::GrokContext *_context;
+ grk_plugin::DcpomaticContext* _dcpomatic_context = nullptr;
+ grk_plugin::GrokContext *_context = nullptr;
#endif
bool _ending = false;
void update()
{
- auto cfg = Config::instance();
- auto lister_binary = cfg->gpu_binary_location() / "gpu_lister";
- auto lister_file = cfg->gpu_binary_location () / "gpus.txt";
+ auto grok = Config::instance()->grok().get_value_or({});
+ auto lister_binary = grok.binary_location / "gpu_lister";
+ auto lister_file = grok.binary_location / "gpus.txt";
if (boost::filesystem::exists(lister_binary)) {
auto gpu_names = get_gpu_names(lister_binary, lister_file);
{
auto selection = _combo_box->GetSelection();
if (selection != wxNOT_FOUND) {
- Config::instance()->set_selected_gpu(selection);
+ auto grok = Config::instance()->grok().get_value_or({});
+ grok.selected = selection;
+ Config::instance()->set_grok(grok);
}
}
table->Add(_port);
add_label_to_sizer(table, _panel, _("License"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _license = new PasswordEntry(_panel);
- table->Add(_license->get_panel(), 1, wxEXPAND | wxALL);
+ _licence = new PasswordEntry(_panel);
+ table->Add(_licence->get_panel(), 1, wxEXPAND | wxALL);
_enable_gpu->bind(&GPUPage::enable_gpu_changed, this);
_binary_location->Bind(wxEVT_DIRPICKER_CHANGED, boost::bind (&GPUPage::binary_location_changed, this));
_server->Bind(wxEVT_TEXT, boost::bind(&GPUPage::server_changed, this));
_port->Bind(wxEVT_SPINCTRL, boost::bind(&GPUPage::port_changed, this));
- _license->Changed.connect(boost::bind(&GPUPage::license_changed, this));
+ _licence->Changed.connect(boost::bind(&GPUPage::licence_changed, this));
setup_sensitivity();
}
void setup_sensitivity()
{
- auto config = Config::instance();
+ auto grok = Config::instance()->grok().get_value_or({});
- _binary_location->Enable(config->enable_gpu());
- _gpu_list_control->Enable(config->enable_gpu());
- _server->Enable(config->enable_gpu());
- _port->Enable(config->enable_gpu());
- _license->get_panel()->Enable(config->enable_gpu());
+ _binary_location->Enable(grok.enable);
+ _gpu_list_control->Enable(grok.enable);
+ _server->Enable(grok.enable);
+ _port->Enable(grok.enable);
+ _licence->get_panel()->Enable(grok.enable);
}
void config_changed() override
{
- auto config = Config::instance();
+ auto grok = Config::instance()->grok().get_value_or({});
- checked_set(_enable_gpu, config->enable_gpu());
- _binary_location->SetPath(std_to_wx(config->gpu_binary_location().string()));
+ checked_set(_enable_gpu, grok.enable);
+ _binary_location->SetPath(std_to_wx(grok.binary_location.string()));
_gpu_list_control->update();
- _gpu_list_control->set_selection(config->selected_gpu());
- checked_set(_server, config->gpu_license_server());
- checked_set(_port, config->gpu_license_port());
- checked_set(_license, config->gpu_license());
+ _gpu_list_control->set_selection(grok.selected);
+ checked_set(_server, grok.licence_server);
+ checked_set(_port, grok.licence_port);
+ checked_set(_licence, grok.licence);
}
void enable_gpu_changed()
{
- auto config = Config::instance();
- config->set_enable_gpu(_enable_gpu->GetValue());
+ auto grok = Config::instance()->grok().get_value_or({});
+ grok.enable = _enable_gpu->GetValue();
+ Config::instance()->set_grok(grok);
+
setup_sensitivity();
}
void binary_location_changed()
{
- Config::instance()->set_gpu_binary_location(wx_to_std(_binary_location->GetPath()));
+ auto grok = Config::instance()->grok().get_value_or({});
+ grok.binary_location = wx_to_std(_binary_location->GetPath());
+ Config::instance()->set_grok(grok);
+
_gpu_list_control->update();
}
void server_changed()
{
- Config::instance()->set_gpu_license_server(wx_to_std(_server->GetValue()));
+ auto grok = Config::instance()->grok().get_value_or({});
+ grok.licence_server = wx_to_std(_server->GetValue());
+ Config::instance()->set_grok(grok);
}
void port_changed()
{
- Config::instance()->set_gpu_license_port(_port->GetValue());
+ auto grok = Config::instance()->grok().get_value_or({});
+ grok.licence_port = _port->GetValue();
+ Config::instance()->set_grok(grok);
}
- void license_changed()
+ void licence_changed()
{
- Config::instance()->set_gpu_license(_license->get());
+ auto grok = Config::instance()->grok().get_value_or({});
+ grok.licence = wx_to_std(_licence->get());
+ Config::instance()->set_grok(grok);
}
CheckBox* _enable_gpu = nullptr;
GpuList* _gpu_list_control = nullptr;
wxTextCtrl* _server = nullptr;
wxSpinCtrl* _port = nullptr;
- PasswordEntry* _license = nullptr;
+ PasswordEntry* _licence = nullptr;
};