summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-08-11 22:39:20 +0100
committerCarl Hetherington <cth@carlh.net>2014-08-11 22:39:20 +0100
commitcc27c2716f755305d67f1e1ba828ecf37f8405dd (patch)
tree224d2b1c469bc671e6b826e8a535f61f6459bc81 /src
parent4ddf91dda7d84f169e4b905fd41cf747f4a0102c (diff)
parent491daf8790f35611052d8954d5d74df275dcda18 (diff)
Merge master.
Diffstat (limited to 'src')
-rw-r--r--src/lib/analyse_audio_job.cc6
-rw-r--r--src/lib/analyse_audio_job.h1
-rw-r--r--src/lib/audio_decoder.cc1
-rw-r--r--src/lib/colour_conversion.cc1
-rw-r--r--src/lib/encoder.cc1
-rw-r--r--src/lib/examine_content_job.cc6
-rw-r--r--src/lib/examine_content_job.h1
-rw-r--r--src/lib/ffmpeg.cc1
-rw-r--r--src/lib/ffmpeg_decoder.cc1
-rw-r--r--src/lib/frame_rate_change.cc10
-rw-r--r--src/lib/frame_rate_change.h2
-rw-r--r--src/lib/image_proxy.cc1
-rw-r--r--src/lib/job.cc23
-rw-r--r--src/lib/job.h2
-rw-r--r--src/lib/json_server.cc193
-rw-r--r--src/lib/json_server.h31
-rw-r--r--src/lib/playlist.cc1
-rw-r--r--src/lib/ratio.cc1
-rw-r--r--src/lib/scp_dcp_job.cc14
-rw-r--r--src/lib/scp_dcp_job.h1
-rw-r--r--src/lib/send_kdm_email_job.cc6
-rw-r--r--src/lib/send_kdm_email_job.h1
-rw-r--r--src/lib/transcode_job.cc6
-rw-r--r--src/lib/transcode_job.h1
-rw-r--r--src/lib/writer.cc1
-rw-r--r--src/lib/wscript1
-rw-r--r--src/tools/dcpomatic.cc7
-rw-r--r--src/tools/dcpomatic_cli.cc16
-rw-r--r--src/wx/dolby_certificate_dialog.cc1
-rw-r--r--src/wx/timecode.cc10
-rw-r--r--src/wx/timecode.h1
-rw-r--r--src/wx/timing_panel.cc161
-rw-r--r--src/wx/video_panel.cc2
33 files changed, 135 insertions, 377 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc
index af58e77ac..347cc0a0f 100644
--- a/src/lib/analyse_audio_job.cc
+++ b/src/lib/analyse_audio_job.cc
@@ -49,12 +49,6 @@ AnalyseAudioJob::name () const
return _("Analyse audio");
}
-string
-AnalyseAudioJob::json_name () const
-{
- return N_("analyse_audio");
-}
-
void
AnalyseAudioJob::run ()
{
diff --git a/src/lib/analyse_audio_job.h b/src/lib/analyse_audio_job.h
index 4d657951b..a218cb340 100644
--- a/src/lib/analyse_audio_job.h
+++ b/src/lib/analyse_audio_job.h
@@ -42,7 +42,6 @@ public:
AnalyseAudioJob (boost::shared_ptr<const Film>, boost::shared_ptr<AudioContent>);
std::string name () const;
- std::string json_name () const;
void run ();
private:
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc
index e4c82f64c..f425cf280 100644
--- a/src/lib/audio_decoder.cc
+++ b/src/lib/audio_decoder.cc
@@ -25,7 +25,6 @@
#include "i18n.h"
-using std::stringstream;
using std::list;
using std::pair;
using std::cout;
diff --git a/src/lib/colour_conversion.cc b/src/lib/colour_conversion.cc
index aacefaa05..c836cc271 100644
--- a/src/lib/colour_conversion.cc
+++ b/src/lib/colour_conversion.cc
@@ -30,7 +30,6 @@
using std::list;
using std::string;
-using std::stringstream;
using std::cout;
using std::vector;
using boost::shared_ptr;
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index e8ab5452b..8caa0190c 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -45,7 +45,6 @@
using std::pair;
using std::string;
-using std::stringstream;
using std::vector;
using std::list;
using std::cout;
diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc
index 8f16e2e5c..cbf180ffc 100644
--- a/src/lib/examine_content_job.cc
+++ b/src/lib/examine_content_job.cc
@@ -46,12 +46,6 @@ ExamineContentJob::name () const
return _("Examine content");
}
-string
-ExamineContentJob::json_name () const
-{
- return N_("examine_content");
-}
-
void
ExamineContentJob::run ()
{
diff --git a/src/lib/examine_content_job.h b/src/lib/examine_content_job.h
index c8037224f..b6903b86b 100644
--- a/src/lib/examine_content_job.h
+++ b/src/lib/examine_content_job.h
@@ -30,7 +30,6 @@ public:
~ExamineContentJob ();
std::string name () const;
- std::string json_name () const;
void run ();
private:
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc
index f5af239b0..fa369dda4 100644
--- a/src/lib/ffmpeg.cc
+++ b/src/lib/ffmpeg.cc
@@ -34,7 +34,6 @@ extern "C" {
using std::string;
using std::cout;
-using std::stringstream;
using boost::shared_ptr;
using dcp::raw_convert;
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 0f2c88fc9..4e5d9bb1e 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -56,7 +56,6 @@ extern "C" {
using std::cout;
using std::string;
using std::vector;
-using std::stringstream;
using std::list;
using std::min;
using std::pair;
diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc
index 454938ada..31fce6b6d 100644
--- a/src/lib/frame_rate_change.cc
+++ b/src/lib/frame_rate_change.cc
@@ -23,6 +23,8 @@
#include "i18n.h"
+using std::string;
+
static bool
about_equal (float a, float b)
{
@@ -73,7 +75,13 @@ FrameRateChange::FrameRateChange (float source_, int dcp_)
speed_up = dcp / (source * factor());
change_speed = !about_equal (speed_up, 1.0);
+}
+string
+FrameRateChange::description () const
+{
+ string description;
+
if (!skip && repeat == 1 && !change_speed) {
description = _("Content and DCP have the same rate.\n");
} else {
@@ -90,4 +98,6 @@ FrameRateChange::FrameRateChange (float source_, int dcp_)
description += String::compose (_("DCP will run at %1%% of the content speed.\n"), pc);
}
}
+
+ return description;
}
diff --git a/src/lib/frame_rate_change.h b/src/lib/frame_rate_change.h
index f53adc059..f5244fea2 100644
--- a/src/lib/frame_rate_change.h
+++ b/src/lib/frame_rate_change.h
@@ -60,7 +60,7 @@ struct FrameRateChange
*/
float speed_up;
- std::string description;
+ std::string description () const;
};
#endif
diff --git a/src/lib/image_proxy.cc b/src/lib/image_proxy.cc
index 233f47745..b6b387b76 100644
--- a/src/lib/image_proxy.cc
+++ b/src/lib/image_proxy.cc
@@ -34,7 +34,6 @@
using std::cout;
using std::string;
-using std::stringstream;
using boost::shared_ptr;
ImageProxy::ImageProxy (shared_ptr<Log> log)
diff --git a/src/lib/job.cc b/src/lib/job.cc
index 594c0da34..31a10a44b 100644
--- a/src/lib/job.cc
+++ b/src/lib/job.cc
@@ -328,29 +328,6 @@ Job::status () const
return s.str ();
}
-string
-Job::json_status () const
-{
- boost::mutex::scoped_lock lm (_state_mutex);
-
- switch (_state) {
- case NEW:
- return N_("new");
- case RUNNING:
- return N_("running");
- case PAUSED:
- return N_("paused");
- case FINISHED_OK:
- return N_("finished_ok");
- case FINISHED_ERROR:
- return N_("finished_error");
- case FINISHED_CANCELLED:
- return N_("finished_cancelled");
- }
-
- return "";
-}
-
/** @return An estimate of the remaining time for this sub-job, in seconds */
int
Job::remaining_time () const
diff --git a/src/lib/job.h b/src/lib/job.h
index 5e3127dc1..97e3fc296 100644
--- a/src/lib/job.h
+++ b/src/lib/job.h
@@ -43,7 +43,6 @@ public:
/** @return user-readable name of this job */
virtual std::string name () const = 0;
- virtual std::string json_name () const = 0;
/** Run this job in the current thread. */
virtual void run () = 0;
@@ -65,7 +64,6 @@ public:
int elapsed_time () const;
virtual std::string status () const;
- std::string json_status () const;
std::string sub_name () const {
return _sub_name;
}
diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc
deleted file mode 100644
index 1be3c7d0e..000000000
--- a/src/lib/json_server.cc
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <boost/asio.hpp>
-#include <boost/bind.hpp>
-#include <boost/thread.hpp>
-#include "json_server.h"
-#include "job_manager.h"
-#include "job.h"
-#include "util.h"
-#include "film.h"
-#include "transcode_job.h"
-
-using std::string;
-using std::stringstream;
-using std::cout;
-using std::map;
-using std::list;
-using boost::thread;
-using boost::shared_ptr;
-using boost::dynamic_pointer_cast;
-using boost::asio::ip::tcp;
-
-#define MAX_LENGTH 512
-
-enum State {
- AWAITING_G,
- AWAITING_E,
- AWAITING_T,
- AWAITING_SPACE,
- READING_URL,
-};
-
-JSONServer::JSONServer (int port)
-{
- new thread (boost::bind (&JSONServer::run, this, port));
-}
-
-void
-JSONServer::run (int port)
-try
-{
- boost::asio::io_service io_service;
- tcp::acceptor a (io_service, tcp::endpoint (tcp::v4 (), port));
- while (true) {
- try {
- shared_ptr<tcp::socket> s (new tcp::socket (io_service));
- a.accept (*s);
- handle (s);
- }
- catch (...) {
-
- }
- }
-}
-catch (...)
-{
-
-}
-
-void
-JSONServer::handle (shared_ptr<tcp::socket> socket)
-{
- string url;
- State state = AWAITING_G;
-
- while (true) {
- char data[MAX_LENGTH];
- boost::system::error_code error;
- size_t len = socket->read_some (boost::asio::buffer (data), error);
- if (error) {
- cout << "error.\n";
- break;
- }
-
- char* p = data;
- char* e = data + len;
- while (p != e) {
-
- State old_state = state;
- switch (state) {
- case AWAITING_G:
- if (*p == 'G') {
- state = AWAITING_E;
- }
- break;
- case AWAITING_E:
- if (*p == 'E') {
- state = AWAITING_T;
- }
- break;
- case AWAITING_T:
- if (*p == 'T') {
- state = AWAITING_SPACE;
- }
- break;
- case AWAITING_SPACE:
- if (*p == ' ') {
- state = READING_URL;
- }
- break;
- case READING_URL:
- if (*p == ' ') {
- request (url, socket);
- state = AWAITING_G;
- url = "";
- } else {
- url += *p;
- }
- break;
- }
-
- if (state == old_state && state != READING_URL) {
- state = AWAITING_G;
- }
-
- ++p;
- }
- }
-}
-
-void
-JSONServer::request (string url, shared_ptr<tcp::socket> socket)
-{
- cout << "request: " << url << "\n";
-
- map<string, string> r = split_get_request (url);
- for (map<string, string>::iterator i = r.begin(); i != r.end(); ++i) {
- cout << i->first << " => " << i->second << "\n";
- }
-
- string action;
- if (r.find ("action") != r.end ()) {
- action = r["action"];
- }
-
- stringstream json;
- if (action == "status") {
-
- list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
-
- json << "{ \"jobs\": [";
- for (list<shared_ptr<Job> >::iterator i = jobs.begin(); i != jobs.end(); ++i) {
-
- json << "{ ";
-
- if ((*i)->film()) {
- json << "\"dcp\": \"" << (*i)->film()->dcp_name() << "\", ";
- }
-
- json << "\"name\": \"" << (*i)->json_name() << "\", "
- << "\"progress\": " << (*i)->progress () << ", "
- << "\"status\": \"" << (*i)->json_status() << "\"";
- json << " }";
-
- list<shared_ptr<Job> >::iterator j = i;
- ++j;
- if (j != jobs.end ()) {
- json << ", ";
- }
- }
- json << "] }";
-
- if (json.str().empty ()) {
- json << "{ }";
- }
- }
-
- stringstream reply;
- reply << "HTTP/1.1 200 OK\r\n"
- << "Content-Length: " << json.str().length() << "\r\n"
- << "Content-Type: application/json\r\n"
- << "\r\n"
- << json.str () << "\r\n";
- cout << "reply: " << json.str() << "\n";
- boost::asio::write (*socket, boost::asio::buffer (reply.str().c_str(), reply.str().length()));
-}
diff --git a/src/lib/json_server.h b/src/lib/json_server.h
deleted file mode 100644
index 623067558..000000000
--- a/src/lib/json_server.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-class JSONServer
-{
-public:
- JSONServer (int port);
-
-private:
- void run (int port);
- void handle (boost::shared_ptr<boost::asio::ip::tcp::socket> socket);
- void request (std::string url, boost::shared_ptr<boost::asio::ip::tcp::socket> socket);
-};
-
-
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 16c740943..22412da4a 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -40,7 +40,6 @@ using std::vector;
using std::min;
using std::max;
using std::string;
-using std::stringstream;
using std::pair;
using boost::optional;
using boost::shared_ptr;
diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc
index fbd702232..bb6963658 100644
--- a/src/lib/ratio.cc
+++ b/src/lib/ratio.cc
@@ -24,7 +24,6 @@
#include "i18n.h"
using std::string;
-using std::stringstream;
using std::vector;
vector<Ratio const *> Ratio::_ratios;
diff --git a/src/lib/scp_dcp_job.cc b/src/lib/scp_dcp_job.cc
index 637840813..67a1fb802 100644
--- a/src/lib/scp_dcp_job.cc
+++ b/src/lib/scp_dcp_job.cc
@@ -40,7 +40,6 @@
#define LOG_GENERAL_NC(...) _film->log()->log (__VA_ARGS__, Log::TYPE_GENERAL);
using std::string;
-using std::stringstream;
using std::min;
using boost::shared_ptr;
@@ -112,12 +111,6 @@ SCPDCPJob::name () const
return _("Copy DCP to TMS");
}
-string
-SCPDCPJob::json_name () const
-{
- return N_("scp_dcp");
-}
-
void
SCPDCPJob::run ()
{
@@ -217,12 +210,11 @@ string
SCPDCPJob::status () const
{
boost::mutex::scoped_lock lm (_status_mutex);
- stringstream s;
- s << Job::status ();
+ string s = Job::status ();
if (!_status.empty ()) {
- s << N_("; ") << _status;
+ s += N_("; ") + _status;
}
- return s.str ();
+ return s;
}
void
diff --git a/src/lib/scp_dcp_job.h b/src/lib/scp_dcp_job.h
index e3960d73b..bdc83af18 100644
--- a/src/lib/scp_dcp_job.h
+++ b/src/lib/scp_dcp_job.h
@@ -29,7 +29,6 @@ public:
SCPDCPJob (boost::shared_ptr<const Film>);
std::string name () const;
- std::string json_name () const;
void run ();
std::string status () const;
diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc
index de0322272..541307f5a 100644
--- a/src/lib/send_kdm_email_job.cc
+++ b/src/lib/send_kdm_email_job.cc
@@ -52,12 +52,6 @@ SendKDMEmailJob::name () const
return String::compose (_("Email KDMs for %1"), _film->name());
}
-string
-SendKDMEmailJob::json_name () const
-{
- return N_("send_kdm_email");
-}
-
void
SendKDMEmailJob::run ()
{
diff --git a/src/lib/send_kdm_email_job.h b/src/lib/send_kdm_email_job.h
index 084836715..af84a13af 100644
--- a/src/lib/send_kdm_email_job.h
+++ b/src/lib/send_kdm_email_job.h
@@ -36,7 +36,6 @@ public:
);
std::string name () const;
- std::string json_name () const;
void run ();
private:
diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc
index 4a85fa18a..1a162b654 100644
--- a/src/lib/transcode_job.cc
+++ b/src/lib/transcode_job.cc
@@ -54,12 +54,6 @@ TranscodeJob::name () const
return String::compose (_("Transcode %1"), _film->name());
}
-string
-TranscodeJob::json_name () const
-{
- return N_("transcode");
-}
-
void
TranscodeJob::run ()
{
diff --git a/src/lib/transcode_job.h b/src/lib/transcode_job.h
index 6e3c1ead9..9128206d2 100644
--- a/src/lib/transcode_job.h
+++ b/src/lib/transcode_job.h
@@ -35,7 +35,6 @@ public:
TranscodeJob (boost::shared_ptr<const Film> f);
std::string name () const;
- std::string json_name () const;
void run ();
std::string status () const;
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index c594a6446..eda82f277 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -60,7 +60,6 @@ using std::pair;
using std::string;
using std::list;
using std::cout;
-using std::stringstream;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
diff --git a/src/lib/wscript b/src/lib/wscript
index f26529b84..15f26c34f 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -54,7 +54,6 @@ sources = """
job.cc
job_manager.cc
kdm.cc
- json_server.cc
log.cc
magick_image_proxy.cc
md5_digester.cc
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index e67703b22..8c7f09ae7 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -338,13 +338,12 @@ private:
void file_changed (boost::filesystem::path f)
{
- stringstream s;
- s << wx_to_std (_("DCP-o-matic"));
+ string s = wx_to_std (_("DCP-o-matic"));
if (!f.empty ()) {
- s << " - " << f.string ();
+ s += " - " + f.string ();
}
- SetTitle (std_to_wx (s.str()));
+ SetTitle (std_to_wx (s));
}
void file_new ()
diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc
index 7dd820b95..8c33b7d83 100644
--- a/src/tools/dcpomatic_cli.cc
+++ b/src/tools/dcpomatic_cli.cc
@@ -33,7 +33,6 @@
#include "lib/log.h"
#include "lib/ui_signaller.h"
#include "lib/server_finder.h"
-#include "lib/json_server.h"
using std::string;
using std::cerr;
@@ -53,7 +52,6 @@ help (string n)
<< " -f, --flags show flags passed to C++ compiler on build\n"
<< " -n, --no-progress do not print progress to stdout\n"
<< " -r, --no-remote do not use any remote servers\n"
- << " -j, --json <port> run a JSON server on the specified port\n"
<< " -k, --keep-going keep running even when the job is complete\n"
<< "\n"
<< "<FILM> is the film directory.\n";
@@ -65,7 +63,6 @@ main (int argc, char* argv[])
string film_dir;
bool progress = true;
bool no_remote = false;
- int json_port = 0;
bool keep_going = false;
int option_index = 0;
@@ -77,12 +74,11 @@ main (int argc, char* argv[])
{ "flags", no_argument, 0, 'f'},
{ "no-progress", no_argument, 0, 'n'},
{ "no-remote", no_argument, 0, 'r'},
- { "json", required_argument, 0, 'j' },
{ "keep-going", no_argument, 0, 'k' },
{ 0, 0, 0, 0 }
};
- int c = getopt_long (argc, argv, "vhdfnrj:k", long_options, &option_index);
+ int c = getopt_long (argc, argv, "vhdfnrk", long_options, &option_index);
if (c == -1) {
break;
@@ -107,9 +103,6 @@ main (int argc, char* argv[])
case 'r':
no_remote = true;
break;
- case 'j':
- json_port = atoi (optarg);
- break;
case 'k':
keep_going = true;
break;
@@ -130,10 +123,6 @@ main (int argc, char* argv[])
ServerFinder::instance()->disable ();
}
- if (json_port) {
- new JSONServer (json_port);
- }
-
cout << "DCP-o-matic " << dcpomatic_version << " git " << dcpomatic_git_commit;
char buf[256];
if (gethostname (buf, 256) == 0) {
@@ -151,9 +140,6 @@ main (int argc, char* argv[])
}
cout << "\nMaking DCP for " << film->name() << "\n";
-// cout << "Content: " << film->content() << "\n";
-// pair<string, string> const f = Filter::ffmpeg_strings (film->filters ());
-// cout << "Filters: " << f.first << " " << f.second << "\n";
film->make_dcp ();
diff --git a/src/wx/dolby_certificate_dialog.cc b/src/wx/dolby_certificate_dialog.cc
index e5bb18962..a05a3bbc7 100644
--- a/src/wx/dolby_certificate_dialog.cc
+++ b/src/wx/dolby_certificate_dialog.cc
@@ -27,7 +27,6 @@
using std::list;
using std::string;
using std::vector;
-using std::stringstream;
using std::cout;
using boost::optional;
using boost::algorithm::split;
diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc
index 86e1997e9..07cb0be65 100644
--- a/src/wx/timecode.cc
+++ b/src/wx/timecode.cc
@@ -116,6 +116,16 @@ Timecode::get (int fps) const
}
void
+Timecode::clear ()
+{
+ checked_set (_hours, "");
+ checked_set (_minutes, "");
+ checked_set (_seconds, "");
+ checked_set (_frames, "");
+ _fixed->SetLabel ("");
+}
+
+void
Timecode::changed ()
{
_set_button->Enable (true);
diff --git a/src/wx/timecode.h b/src/wx/timecode.h
index b13e8c3c0..72b00ddeb 100644
--- a/src/wx/timecode.h
+++ b/src/wx/timecode.h
@@ -28,6 +28,7 @@ public:
void set (DCPTime, int);
DCPTime get (int) const;
+ void clear ();
void set_editable (bool);
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
index 021ab6ab0..a0e1f8f8a 100644
--- a/src/wx/timing_panel.cc
+++ b/src/wx/timing_panel.cc
@@ -27,6 +27,7 @@
using std::cout;
using std::string;
+using std::set;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using dcp::raw_convert;
@@ -78,67 +79,117 @@ void
TimingPanel::film_content_changed (int property)
{
ContentList cl = _parent->selected ();
- shared_ptr<Content> content;
- if (cl.size() == 1) {
- content = cl.front ();
- }
-
int const film_video_frame_rate = _parent->film()->video_frame_rate ();
+
+ /* Here we check to see if we have exactly one different value of various
+ properties, and fill the controls with that value if so.
+ */
if (property == ContentProperty::POSITION) {
- if (content) {
- _position->set (content->position (), film_video_frame_rate);
+
+ set<DCPTime> check;
+ for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
+ check.insert ((*i)->position ());
+ }
+
+ if (check.size() == 1) {
+ _position->set (cl.front()->position(), film_video_frame_rate);
} else {
- _position->set (DCPTime () , 24);
+ _position->clear ();
}
+
} else if (
property == ContentProperty::LENGTH ||
property == VideoContentProperty::VIDEO_FRAME_RATE ||
property == VideoContentProperty::VIDEO_FRAME_TYPE
) {
- if (content) {
- _full_length->set (content->full_length (), film_video_frame_rate);
- _play_length->set (content->length_after_trim (), film_video_frame_rate);
+
+ set<DCPTime> check;
+ for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
+ check.insert ((*i)->full_length ());
+ }
+
+ if (check.size() == 1) {
+ _full_length->set (cl.front()->full_length (), film_video_frame_rate);
} else {
- _full_length->set (DCPTime (), 24);
- _play_length->set (DCPTime (), 24);
+ _full_length->clear ();
}
+
} else if (property == ContentProperty::TRIM_START) {
- if (content) {
- _trim_start->set (content->trim_start (), film_video_frame_rate);
- _play_length->set (content->length_after_trim (), film_video_frame_rate);
+
+ set<DCPTime> check;
+ for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
+ check.insert ((*i)->trim_start ());
+ }
+
+ if (check.size() == 1) {
+ _trim_start->set (cl.front()->trim_start (), film_video_frame_rate);
} else {
- _trim_start->set (DCPTime (), 24);
- _play_length->set (DCPTime (), 24);
+ _trim_start->clear ();
}
+
} else if (property == ContentProperty::TRIM_END) {
- if (content) {
- _trim_end->set (content->trim_end (), film_video_frame_rate);
- _play_length->set (content->length_after_trim (), film_video_frame_rate);
+
+ set<DCPTime> check;
+ for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
+ check.insert ((*i)->trim_end ());
+ }
+
+ if (check.size() == 1) {
+ _trim_end->set (cl.front()->trim_end (), film_video_frame_rate);
} else {
- _trim_end->set (DCPTime (), 24);
- _play_length->set (DCPTime (), 24);
+ _trim_end->clear ();
+ }
+ }
+
+ if (
+ property == ContentProperty::LENGTH ||
+ property == ContentProperty::TRIM_START ||
+ property == ContentProperty::TRIM_END ||
+ property == VideoContentProperty::VIDEO_FRAME_RATE ||
+ property == VideoContentProperty::VIDEO_FRAME_TYPE
+ ) {
+
+ set<DCPTime> check;
+ for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
+ check.insert ((*i)->length_after_trim ());
+ }
+
+ if (check.size() == 1) {
+ _play_length->set (cl.front()->length_after_trim (), film_video_frame_rate);
+ } else {
+ _play_length->clear ();
}
}
if (property == VideoContentProperty::VIDEO_FRAME_RATE) {
- if (content) {
- shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (content);
+ set<float> check;
+ shared_ptr<VideoContent> vc;
+ for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
+ vc = dynamic_pointer_cast<VideoContent> (*i);
if (vc) {
- _video_frame_rate->SetValue (std_to_wx (raw_convert<string> (vc->video_frame_rate (), 5)));
- } else {
- _video_frame_rate->SetValue ("24");
+ check.insert (vc->video_frame_rate ());
}
+ }
+ if (check.size() == 1) {
+ _video_frame_rate->SetValue (std_to_wx (raw_convert<string> (vc->video_frame_rate (), 5)));
+ _video_frame_rate->Enable (true);
} else {
- _video_frame_rate->SetValue ("24");
+ _video_frame_rate->SetValue ("");
+ _video_frame_rate->Enable (false);
}
}
- shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (content);
- shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (content);
- _full_length->set_editable (ic && ic->still ());
- _play_length->set_editable (!ic || !ic->still ());
- _video_frame_rate->Enable (vc);
+ bool have_still = false;
+ for (ContentList::const_iterator i = cl.begin (); i != cl.end(); ++i) {
+ shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (*i);
+ if (ic && ic->still ()) {
+ have_still = true;
+ }
+ }
+
+ _full_length->set_editable (have_still);
+ _play_length->set_editable (!have_still);
_set_video_frame_rate->Enable (false);
}
@@ -146,8 +197,8 @@ void
TimingPanel::position_changed ()
{
ContentList c = _parent->selected ();
- if (c.size() == 1) {
- c.front()->set_position (_position->get (_parent->film()->video_frame_rate ()));
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ (*i)->set_position (_position->get (_parent->film()->video_frame_rate ()));
}
}
@@ -155,8 +206,8 @@ void
TimingPanel::full_length_changed ()
{
ContentList c = _parent->selected ();
- if (c.size() == 1) {
- shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (c.front ());
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (*i);
if (ic && ic->still ()) {
/* XXX: No effective FRC here... is this right? */
ic->set_video_length (ContentTime (_full_length->get (_parent->film()->video_frame_rate()), FrameRateChange (1, 1)));
@@ -168,8 +219,8 @@ void
TimingPanel::trim_start_changed ()
{
ContentList c = _parent->selected ();
- if (c.size() == 1) {
- c.front()->set_trim_start (_trim_start->get (_parent->film()->video_frame_rate ()));
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ (*i)->set_trim_start (_trim_start->get (_parent->film()->video_frame_rate ()));
}
}
@@ -178,8 +229,8 @@ void
TimingPanel::trim_end_changed ()
{
ContentList c = _parent->selected ();
- if (c.size() == 1) {
- c.front()->set_trim_end (_trim_end->get (_parent->film()->video_frame_rate ()));
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ (*i)->set_trim_end (_trim_end->get (_parent->film()->video_frame_rate ()));
}
}
@@ -187,8 +238,8 @@ void
TimingPanel::play_length_changed ()
{
ContentList c = _parent->selected ();
- if (c.size() == 1) {
- c.front()->set_trim_end (c.front()->full_length() - _play_length->get (_parent->film()->video_frame_rate()) - c.front()->trim_start());
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ (*i)->set_trim_end ((*i)->full_length() - _play_length->get (_parent->film()->video_frame_rate()) - (*i)->trim_start());
}
}
@@ -202,8 +253,8 @@ void
TimingPanel::set_video_frame_rate ()
{
ContentList c = _parent->selected ();
- if (c.size() == 1) {
- shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c.front ());
+ for (ContentList::iterator i = c.begin(); i != c.end(); ++i) {
+ shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i);
if (vc) {
vc->set_video_frame_rate (raw_convert<float> (wx_to_std (_video_frame_rate->GetValue ())));
}
@@ -214,16 +265,14 @@ TimingPanel::set_video_frame_rate ()
void
TimingPanel::content_selection_changed ()
{
- ContentList sel = _parent->selected ();
- bool const single = sel.size() == 1;
-
- /* Things that are only allowed with single selections */
- _position->Enable (single);
- _full_length->Enable (single);
- _trim_start->Enable (single);
- _trim_end->Enable (single);
- _play_length->Enable (single);
- _video_frame_rate->Enable (single);
+ bool const e = !_parent->selected().empty ();
+
+ _position->Enable (e);
+ _full_length->Enable (e);
+ _trim_start->Enable (e);
+ _trim_end->Enable (e);
+ _play_length->Enable (e);
+ _video_frame_rate->Enable (e);
film_content_changed (ContentProperty::POSITION);
film_content_changed (ContentProperty::LENGTH);
diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc
index f00edd8ff..cd831baed 100644
--- a/src/wx/video_panel.cc
+++ b/src/wx/video_panel.cc
@@ -332,7 +332,7 @@ VideoPanel::setup_description ()
d << wxString::Format (_("Content frame rate %.4f\n"), vcs->video_frame_rate ());
++lines;
FrameRateChange frc (vcs->video_frame_rate(), _parent->film()->video_frame_rate ());
- d << std_to_wx (frc.description) << "\n";
+ d << std_to_wx (frc.description ()) << "\n";
++lines;
for (int i = lines; i < 6; ++i) {