summaryrefslogtreecommitdiff
path: root/src/lib
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/lib
parent4ddf91dda7d84f169e4b905fd41cf747f4a0102c (diff)
parent491daf8790f35611052d8954d5d74df275dcda18 (diff)
Merge master.
Diffstat (limited to 'src/lib')
-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
26 files changed, 14 insertions, 300 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