_player_kdm_directory = boost::none;
#ifdef DCPOMATIC_VARIANT_SWAROOP
_player_background_image = boost::none;
+ _kdm_server_url = "http://localhost:8000/{CPL}";
#endif
_allowed_dcp_frame_rates.clear ();
_player_kdm_directory = f.optional_string_child("PlayerKDMDirectory");
#ifdef DCPOMATIC_VARIANT_SWAROOP
_player_background_image = f.optional_string_child("PlayerBackgroundImage");
+ _kdm_server_url = f.optional_string_child("KDMServerURL").get_value_or("http://localhost:8000/{CPL}");
#endif
/* Replace any cinemas from config.xml with those from the configured file */
if (_player_background_image) {
root->add_child("PlayerBackgroundImage")->add_child_text(_player_background_image->string());
}
+ root->add_child("KDMServerURL")->add_child_text(_kdm_server_url);
#endif
try {
boost::optional<boost::filesystem::path> player_background_image () const {
return _player_background_image;
}
+
+ std::string kdm_server_url () const {
+ return _kdm_server_url;
+ }
#endif
/* SET (mostly) */
_player_background_image = boost::none;
changed (PLAYER_BACKGROUND_IMAGE);
}
+
+ void set_kdm_server_url (std::string s) {
+ maybe_set (_kdm_server_url, s);
+ }
#endif
void changed (Property p = OTHER);
boost::optional<boost::filesystem::path> _player_kdm_directory;
#ifdef DCPOMATIC_VARIANT_SWAROOP
boost::optional<boost::filesystem::path> _player_background_image;
+ std::string _kdm_server_url;
#endif
static int const _current_version;
return fwrite (buffer, size, nmemb, f);
}
-static
optional<string>
get_from_url (string url, bool pasv, ScopedTemporary& temp)
{
#include <boost/function.hpp>
#include <boost/filesystem.hpp>
+class ScopedTemporary;
+
+boost::optional<std::string> get_from_url (std::string url, bool pasv, ScopedTemporary& temp);
boost::optional<std::string> get_from_url (std::string url, bool pasv, boost::function<void (boost::filesystem::path)> load);
boost::optional<std::string> get_from_zip_url (std::string url, std::string file, bool pasv, boost::function<void (boost::filesystem::path)> load);
#include "lib/cross.h"
#include "lib/config.h"
#include "lib/util.h"
+#include "lib/internet.h"
#include "lib/update_checker.h"
#include "lib/compose.hpp"
#include "lib/dcp_content.h"
#include "lib/examine_content_job.h"
#include "lib/server.h"
#include "lib/dcpomatic_socket.h"
+#include "lib/scoped_temporary.h"
#include <wx/wx.h>
#include <wx/stdpaths.h>
#include <wx/splash.h>
optional<boost::filesystem::path> kdm_dir = Config::instance()->player_kdm_directory();
if (dcp->needs_kdm() && kdm_dir) {
/* Look for a KDM */
- using namespace boost::filesystem;
- for (directory_iterator i = directory_iterator(*kdm_dir); i != directory_iterator(); ++i) {
- if (file_size(i->path()) < MAX_KDM_SIZE) {
- try {
- dcp::EncryptedKDM kdm(dcp::file_to_string(i->path()));
- if (kdm.cpl_id() == dcp->cpl()) {
- dcp->add_kdm (kdm);
- dcp->examine (shared_ptr<Job>());
+
+ optional<dcp::EncryptedKDM> kdm;
+
+ ScopedTemporary temp;
+ string url = Config::instance()->kdm_server_url();
+ boost::algorithm::replace_all (url, "{CPL}", "%1");
+ if (dcp->cpl() && !get_from_url(String::compose(url, *dcp->cpl()), false, temp)) {
+ try {
+ kdm = dcp::EncryptedKDM (dcp::file_to_string(temp.file()));
+ if (kdm->cpl_id() != dcp->cpl()) {
+ kdm = boost::none;
+ }
+ } catch (std::exception& e) {
+ /* Hey well */
+ }
+ }
+
+ if (!kdm) {
+ using namespace boost::filesystem;
+ for (directory_iterator i = directory_iterator(*kdm_dir); i != directory_iterator(); ++i) {
+ if (file_size(i->path()) < MAX_KDM_SIZE) {
+ try {
+ kdm = dcp::EncryptedKDM(dcp::file_to_string(i->path()));
+ if (kdm->cpl_id() == dcp->cpl()) {
+ break;
+ }
+ } catch (std::exception& e) {
+ /* Hey well */
}
- } catch (...) {
- /* Hey well */
}
}
}
+
+ if (kdm) {
+ dcp->add_kdm (*kdm);
+ dcp->examine (shared_ptr<Job>());
+ }
}
setup_from_dcp (dcp);
_background_image = new FilePickerCtrl (_panel, _("Select image file"), "*.png;*.jpg;*.jpeg;*.tif;*.tiff", true);
table->Add (_background_image, wxGBPosition (r, 1));
++r;
+
+ add_label_to_sizer (table, _panel, _("KDM server URL"), true, wxGBPosition(r, 0));
+ _kdm_server_url = new wxTextCtrl (_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400, -1));
+ table->Add (_kdm_server_url, wxGBPosition (r, 1));
+ ++r;
#endif
_player_mode->Bind (wxEVT_CHOICE, bind(&PlayerGeneralPage::player_mode_changed, this));
_kdm_directory->Bind (wxEVT_DIRPICKER_CHANGED, bind(&PlayerGeneralPage::kdm_directory_changed, this));
#ifdef DCPOMATIC_VARIANT_SWAROOP
_background_image->Bind (wxEVT_FILEPICKER_CHANGED, bind(&PlayerGeneralPage::background_image_changed, this));
+ _kdm_server_url->Bind (wxEVT_TEXT, bind(&PlayerGeneralPage::kdm_server_url_changed, this));
#endif
}
if (config->player_background_image()) {
checked_set (_background_image, *config->player_background_image());
}
+ checked_set (_kdm_server_url, config->kdm_server_url());
#endif
}
{
Config::instance()->set_player_background_image(wx_to_std(_background_image->GetPath()));
}
+
+ void kdm_server_url_changed ()
+ {
+ Config::instance()->set_kdm_server_url(wx_to_std(_kdm_server_url->GetValue()));
+ }
#endif
wxChoice* _player_mode;
wxDirPickerCtrl* _kdm_directory;
#ifdef DCPOMATIC_VARIANT_SWAROOP
FilePickerCtrl* _background_image;
+ wxTextCtrl* _kdm_server_url;
#endif
};