+2014-02-19 Carl Hetherington <cth@carlh.net>
+
+ * Add some basic JSON stuff.
+
2014-02-18 Carl Hetherington <cth@carlh.net>
* Version 1.64.14 released.
return _("Analyse audio");
}
+string
+AnalyseAudioJob::json_name () const
+{
+ return N_("analyse_audio");
+}
+
void
AnalyseAudioJob::run ()
{
AnalyseAudioJob (boost::shared_ptr<const Film>, boost::shared_ptr<AudioContent>);
std::string name () const;
+ std::string json_name () const;
void run ();
private:
return _("Examine content");
}
+string
+ExamineContentJob::json_name () const
+{
+ return N_("examine_content");
+}
+
void
ExamineContentJob::run ()
{
~ExamineContentJob ();
std::string name () const;
+ std::string json_name () const;
void run ();
private:
}
}
-/** @return fractional progress of this sub-job, or -1 if not known */
+/** @return fractional progress of the current sub-job, or -1 if not known */
float
Job::progress () 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
/** @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;
int elapsed_time () const;
virtual std::string status () const;
+ std::string json_status () const;
std::string sub_name () const {
return _sub_name;
}
return _("Copy DCP to TMS");
}
+string
+SCPDCPJob::json_name () const
+{
+ return N_("scp_dcp");
+}
+
void
SCPDCPJob::run ()
{
boost::mutex::scoped_lock lm (_status_mutex);
_status = s;
}
-
SCPDCPJob (boost::shared_ptr<const Film>);
std::string name () const;
+ std::string json_name () const;
void run ();
std::string status () const;
return String::compose (_("Email KDMs for %1"), _film->name());
}
+string
+SendKDMEmailJob::json_name () const
+{
+ return N_("send_kdm_email");
+}
+
void
SendKDMEmailJob::run ()
{
);
std::string name () const;
+ std::string json_name () const;
void run ();
private:
return String::compose (_("Transcode %1"), _film->name());
}
+string
+TranscodeJob::json_name () const
+{
+ return N_("transcode");
+}
+
void
TranscodeJob::run ()
{
TranscodeJob (boost::shared_ptr<const Film> f);
std::string name () const;
+ std::string json_name () const;
void run ();
std::string status () const;
using std::max;
using std::list;
using std::multimap;
+using std::map;
using std::istream;
using std::numeric_limits;
using std::pair;
return shared_ptr<const libdcp::Signer> (new libdcp::Signer (chain, signer_key));
}
+map<string, string>
+split_get_request (string url)
+{
+ enum {
+ AWAITING_QUESTION_MARK,
+ KEY,
+ VALUE
+ } state = AWAITING_QUESTION_MARK;
+
+ map<string, string> r;
+ string k;
+ string v;
+ for (size_t i = 0; i < url.length(); ++i) {
+ switch (state) {
+ case AWAITING_QUESTION_MARK:
+ if (url[i] == '?') {
+ state = KEY;
+ }
+ break;
+ case KEY:
+ if (url[i] == '=') {
+ v.clear ();
+ state = VALUE;
+ } else {
+ k += url[i];
+ }
+ break;
+ case VALUE:
+ if (url[i] == '&') {
+ r.insert (make_pair (k, v));
+ k.clear ();
+ state = KEY;
+ } else {
+ v += url[i];
+ }
+ break;
+ }
+ }
+
+ if (state == VALUE) {
+ r.insert (make_pair (k, v));
+ }
+
+ return r;
+}
+
libdcp::Size
fit_ratio_within (float ratio, libdcp::Size full_frame)
{
return p;
}
+string
+entities_to_text (string e)
+{
+ boost::algorithm::replace_all (e, "%3A", ":");
+ boost::algorithm::replace_all (e, "%2F", "/");
+ return e;
+}
extern std::string tidy_for_filename (std::string);
extern boost::shared_ptr<const libdcp::Signer> make_signer ();
extern libdcp::Size fit_ratio_within (float ratio, libdcp::Size);
+extern std::string entities_to_text (std::string e);
+extern std::map<std::string, std::string> split_get_request (std::string url);
struct FrameRateConversion
{
job.cc
job_manager.cc
kdm.cc
+ json_server.cc
log.cc
player.cc
playlist.cc
#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;
<< " -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";
}
bool progress = true;
bool no_remote = false;
int log_level = 0;
+ int json_port = 0;
+ bool keep_going = false;
int option_index = 0;
while (1) {
{ "no-progress", no_argument, 0, 'n'},
{ "no-remote", no_argument, 0, 'r'},
{ "log-level", required_argument, 0, 'l' },
+ { "json", required_argument, 0, 'j' },
+ { "keep-going", no_argument, 0, 'k' },
{ 0, 0, 0, 0 }
};
- int c = getopt_long (argc, argv, "vhdfnrl:", long_options, &option_index);
+ int c = getopt_long (argc, argv, "vhdfnrl:j:k", long_options, &option_index);
if (c == -1) {
break;
case 'l':
log_level = atoi (optarg);
break;
+ case 'j':
+ json_port = atoi (optarg);
+ break;
+ case 'k':
+ keep_going = true;
+ break;
}
}
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) {
}
}
+ if (keep_going) {
+ while (1) {
+ dcpomatic_sleep (3600);
+ }
+ }
+
/* This is just to stop valgrind reporting leaks due to JobManager
indirectly holding onto codecs.
*/
string name () const {
return "";
}
+
+ string json_name () const {
+ return "";
+ }
};
BOOST_AUTO_TEST_CASE (job_manager_test)