2018-09-14 Carl Hetherington <cth@carlh.net>
+ * Very basic logging in player.
+
* Basic dual-screen mode for player.
2018-09-11 Carl Hetherington <cth@carlh.net>
_interface_complexity = INTERFACE_SIMPLE;
_player_mode = PLAYER_MODE_WINDOW;
_respect_kdm_validity_periods = false;
+ _player_log_file = boost::none;
_allowed_dcp_frame_rates.clear ();
_allowed_dcp_frame_rates.push_back (24);
}
_respect_kdm_validity_periods = f.optional_bool_child("RespectKDMValidityPeriods").get_value_or(false);
+ _player_log_file = f.optional_string_child("PlayerLogFile");
/* Replace any cinemas from config.xml with those from the configured file */
if (boost::filesystem::exists (_cinemas_file)) {
}
root->add_child("RespectKDMValidityPeriods")->add_child_text(_respect_kdm_validity_periods ? "1" : "0");
+ if (_player_log_file) {
+ root->add_child("PlayerLogFile")->add_child_text(_player_log_file->string());
+ }
try {
doc.write_to_file_formatted(config_file().string());
return _respect_kdm_validity_periods;
}
+ boost::optional<boost::filesystem::path> player_log_file () const {
+ return _player_log_file;
+ }
+
/* SET (mostly) */
void set_master_encoding_threads (int n) {
maybe_set (_respect_kdm_validity_periods, r);
}
+ void set_player_log_file (boost::filesystem::path p) {
+ maybe_set (_player_log_file, p);
+ }
+
+ void unset_player_log_file () {
+ if (!_player_log_file) {
+ return;
+ }
+ _player_log_file = boost::none;
+ changed ();
+ }
+
void changed (Property p = OTHER);
boost::signals2::signal<void (Property)> Changed;
/** Emitted if read() failed on an existing Config file. There is nothing
Interface _interface_complexity;
PlayerMode _player_mode;
bool _respect_kdm_validity_periods;
+ boost::optional<boost::filesystem::path> _player_log_file;
static int const _current_version;
_controls = new Controls (_overall_panel, _viewer);
_viewer->set_dcp_decode_reduction (Config::instance()->decode_reduction ());
_viewer->PlaybackPermitted.connect (bind(&DOMFrame::playback_permitted, this));
+ _viewer->Started.connect (bind(&DOMFrame::playback_started, this));
+ _viewer->Stopped.connect (bind(&DOMFrame::playback_stopped, this));
_info = new PlayerInformation (_overall_panel, _viewer);
wxSizer* main_sizer = new wxBoxSizer (wxVERTICAL);
main_sizer->Add (_viewer->panel(), 1, wxEXPAND);
return ok;
}
+ void playback_started ()
+ {
+ optional<boost::filesystem::path> log = Config::instance()->player_log_file();
+ if (!log) {
+ return;
+ }
+
+ shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
+ DCPOMATIC_ASSERT (dcp);
+ DCPExaminer ex (dcp);
+ shared_ptr<dcp::CPL> playing_cpl;
+ BOOST_FOREACH (shared_ptr<dcp::CPL> i, ex.cpls()) {
+ if (!dcp->cpl() || i->id() == *dcp->cpl()) {
+ playing_cpl = i;
+ }
+ }
+ DCPOMATIC_ASSERT (playing_cpl)
+
+ FILE* f = fopen_boost(*log, "a");
+ fprintf (
+ f,
+ "%s playback-started %s %s\n",
+ dcp::LocalTime().as_string().c_str(),
+ dcp->directories().front().string().c_str(),
+ playing_cpl->annotation_text().c_str()
+ );
+ fclose (f);
+ }
+
+ void playback_stopped ()
+ {
+ optional<boost::filesystem::path> log = Config::instance()->player_log_file();
+ if (!log) {
+ return;
+ }
+
+ FILE* f = fopen_boost(*log, "a");
+ fprintf (f, "%s playback-stopped\n", dcp::LocalTime().as_string().c_str());
+ fclose (f);
+ }
+
void set_decode_reduction (optional<int> reduction)
{
_viewer->set_dcp_decode_reduction (reduction);
table->Add (_respect_kdm, wxGBPosition(r, 0), wxGBSpan(1, 2));
++r;
+ add_label_to_sizer (table, _panel, _("Log file"), true, wxGBPosition (r, 0));
+ _log_file = new FilePickerCtrl (_panel, _("Select log file"), "*", true);
+ table->Add (_log_file, wxGBPosition (r, 1));
+ ++r;
+
_player_mode->Bind (wxEVT_CHOICE, bind(&PlayerGeneralPage::player_mode_changed, this));
_respect_kdm->Bind (wxEVT_CHECKBOX, bind(&PlayerGeneralPage::respect_kdm_changed, this));
+ _log_file->Bind (wxEVT_FILEPICKER_CHANGED, bind(&PlayerGeneralPage::log_file_changed, this));
}
void config_changed ()
{
GeneralPage::config_changed ();
- switch (Config::instance()->player_mode()) {
+ Config* config = Config::instance ();
+
+ switch (config->player_mode()) {
case Config::PLAYER_MODE_WINDOW:
checked_set (_player_mode, 0);
break;
break;
}
- checked_set (_respect_kdm, Config::instance()->respect_kdm_validity_periods());
+ checked_set (_respect_kdm, config->respect_kdm_validity_periods());
+ if (config->player_log_file()) {
+ checked_set (_log_file, *config->player_log_file());
+ }
}
private:
Config::instance()->set_respect_kdm_validity_periods(_respect_kdm->GetValue());
}
+ void log_file_changed ()
+ {
+ Config::instance()->set_player_log_file(wx_to_std(_log_file->GetPath()));
+ }
+
wxChoice* _player_mode;
wxCheckBox* _respect_kdm;
+ FilePickerCtrl* _log_file;
};
wxPreferencesEditor*