summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-02-24 12:19:50 +0000
committerCarl Hetherington <cth@carlh.net>2014-02-24 12:19:50 +0000
commit85c65bd422742813992686c17a5e1b718cc3c449 (patch)
tree21750399bcb19e1fb6242bba7595773513a80912 /src/tools
parente2be8234013335379bd49a53854218039348c7a4 (diff)
parenteed40e4e5ca46bbc31a9833d2b766c96c11b0254 (diff)
Merge master; specify libdcp-1.0.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/dcpomatic.cc34
-rw-r--r--src/tools/dcpomatic_cli.cc25
-rw-r--r--src/tools/dcpomatic_create.cc82
3 files changed, 123 insertions, 18 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 70e675e40..715d42087 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -57,6 +57,7 @@
#include "lib/send_kdm_email_job.h"
#include "lib/server_finder.h"
#include "lib/update.h"
+#include "lib/content_factory.h"
using std::cout;
using std::string;
@@ -75,6 +76,7 @@ static shared_ptr<Film> film;
static std::string log_level;
static std::string film_to_load;
static std::string film_to_create;
+static std::string content_to_add;
static wxMenu* jobs_menu = 0;
static void set_menu_sensitivity ();
@@ -322,6 +324,17 @@ public:
overall_panel->SetSizer (main_sizer);
}
+ void check_film_state_version (int v)
+ {
+ if (v == 4) {
+ error_dialog (
+ this,
+ _("This film was created with an old version of DVD-o-matic and may not load correctly "
+ "in this version. Please check the film's settings carefully.")
+ );
+ }
+ }
+
private:
void set_film ()
@@ -403,6 +416,7 @@ private:
try {
film.reset (new Film (wx_to_std (c->GetPath ())));
film->read_metadata ();
+ check_film_state_version (film->state_version ());
film->log()->set_level (log_level);
set_film ();
} catch (std::exception& e) {
@@ -581,7 +595,8 @@ private:
static const wxCmdLineEntryDesc command_line_description[] = {
{ wxCMD_LINE_OPTION, "l", "log", "set log level (silent, verbose or timing)", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
- { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL },
+ { wxCMD_LINE_OPTION, "c", "content", "add content file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
+ { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
};
@@ -643,6 +658,10 @@ class App : public wxApp
film->set_name (boost::filesystem::path (film_to_create).filename().generic_string ());
}
+ if (!content_to_add.empty ()) {
+ film->examine_and_add_content (content_factory (film, content_to_add));
+ }
+
_frame = new Frame (_("DCP-o-matic"));
SetTopWindow (_frame);
_frame->Maximize ();
@@ -655,6 +674,10 @@ class App : public wxApp
_timer.reset (new wxTimer (this));
_timer->Start (1000);
+ if (film) {
+ _frame->check_film_state_version (film->state_version ());
+ }
+
UpdateChecker::instance()->StateChanged.connect (boost::bind (&App::update_checker_state_changed, this));
if (Config::instance()->check_for_updates ()) {
UpdateChecker::instance()->run ();
@@ -680,10 +703,15 @@ class App : public wxApp
if (parser.Found (wxT ("new"))) {
film_to_create = wx_to_std (parser.GetParam (0));
} else {
- film_to_load = wx_to_std (parser.GetParam(0));
+ film_to_load = wx_to_std (parser.GetParam (0));
}
}
+ wxString content;
+ if (parser.Found (wxT ("content"), &content)) {
+ content_to_add = wx_to_std (content);
+ }
+
wxString log;
if (parser.Found (wxT ("log"), &log)) {
log_level = wx_to_std (log);
@@ -734,7 +762,7 @@ class App : public wxApp
}
}
- wxFrame* _frame;
+ Frame* _frame;
shared_ptr<wxTimer> _timer;
};
diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc
index c40ea6662..a74ece149 100644
--- a/src/tools/dcpomatic_cli.cc
+++ b/src/tools/dcpomatic_cli.cc
@@ -33,6 +33,7 @@
#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;
@@ -52,6 +53,8 @@ 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";
}
@@ -63,6 +66,8 @@ main (int argc, char* argv[])
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) {
@@ -74,10 +79,12 @@ main (int argc, char* argv[])
{ "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;
@@ -105,6 +112,12 @@ main (int argc, char* argv[])
case 'l':
log_level = atoi (optarg);
break;
+ case 'j':
+ json_port = atoi (optarg);
+ break;
+ case 'k':
+ keep_going = true;
+ break;
}
}
@@ -122,6 +135,10 @@ 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) {
@@ -201,6 +218,12 @@ main (int argc, char* argv[])
}
}
+ if (keep_going) {
+ while (1) {
+ dcpomatic_sleep (3600);
+ }
+ }
+
/* This is just to stop valgrind reporting leaks due to JobManager
indirectly holding onto codecs.
*/
diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc
index 8dc4de50e..05121652a 100644
--- a/src/tools/dcpomatic_create.cc
+++ b/src/tools/dcpomatic_create.cc
@@ -30,6 +30,8 @@
#include "lib/job_manager.h"
#include "lib/ui_signaller.h"
#include "lib/job.h"
+#include "lib/dcp_content_type.h"
+#include "lib/ratio.h"
using std::string;
using std::cout;
@@ -37,22 +39,33 @@ using std::cerr;
using std::list;
using std::exception;
using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
static void
help (string n)
{
- cerr << "Create a film directory (ready for making a DCP) from some content files.\n"
+ cerr << "Create a film directory (ready for making a DCP) or metadata file from some content files.\n"
+ << "A film directory will be created if -o or --output is specified, otherwise a metadata file\n"
+ << "will be written to stdout.\n"
<< "Syntax: " << n << " [OPTION] <CONTENT> [<CONTENT> ...]\n"
- << " -v, --version show DCP-o-matic version\n"
- << " -h, --help show this help\n"
- << " -n, --name film name\n"
- << " -o, --output output directory (required)\n";
+ << " -v, --version show DCP-o-matic version\n"
+ << " -h, --help show this help\n"
+ << " -n, --name <name> film name\n"
+ << " -c, --dcp-content-type <type> FTR, SHR, TLR, TST, XSN, RTG, TSR, POL, PSA or ADV\n"
+ << " --container-ratio 119, 133, 137, 138, 166, 178, 185 or 239\n"
+ << " --content-ratio 119, 133, 137, 138, 166, 178, 185 or 239\n"
+ << " -o, --output <dir> output directory\n";
}
int
main (int argc, char* argv[])
{
+ dcpomatic_setup ();
+
string name;
+ DCPContentType const * dcp_content_type = DCPContentType::from_dci_name ("TST");
+ Ratio const * container_ratio = 0;
+ Ratio const * content_ratio = 0;
boost::filesystem::path output;
int option_index = 0;
@@ -61,11 +74,14 @@ main (int argc, char* argv[])
{ "version", no_argument, 0, 'v'},
{ "help", no_argument, 0, 'h'},
{ "name", required_argument, 0, 'n'},
+ { "dcp-content-type", required_argument, 0, 'c'},
+ { "container-ratio", required_argument, 0, 'A'},
+ { "content-ratio", required_argument, 0, 'B'},
{ "output", required_argument, 0, 'o'},
{ 0, 0, 0, 0}
};
- int c = getopt_long (argc, argv, "vhn:o:", long_options, &option_index);
+ int c = getopt_long (argc, argv, "vhn:c:A:B:o:", long_options, &option_index);
if (c == -1) {
break;
}
@@ -80,6 +96,30 @@ main (int argc, char* argv[])
case 'n':
name = optarg;
break;
+ case 'c':
+ dcp_content_type = DCPContentType::from_dci_name (optarg);
+ if (dcp_content_type == 0) {
+ cerr << "Bad DCP content type.\n";
+ help (argv[0]);
+ exit (EXIT_FAILURE);
+ }
+ break;
+ case 'A':
+ container_ratio = Ratio::from_id (optarg);
+ if (container_ratio == 0) {
+ cerr << "Bad container ratio.\n";
+ help (argv[0]);
+ exit (EXIT_FAILURE);
+ }
+ break;
+ case 'B':
+ content_ratio = Ratio::from_id (optarg);
+ if (content_ratio == 0) {
+ cerr << "Bad content ratio " << optarg << ".\n";
+ help (argv[0]);
+ exit (EXIT_FAILURE);
+ }
+ break;
case 'o':
output = optarg;
break;
@@ -91,23 +131,33 @@ main (int argc, char* argv[])
exit (EXIT_FAILURE);
}
- if (output.empty ()) {
- cerr << "Missing required option -o or --output.\n"
- << "Use " << argv[0] << " --help for help.\n";
+ if (!content_ratio) {
+ cerr << "Missing required option --content-ratio.\n";
+ help (argv[0]);
exit (EXIT_FAILURE);
}
- dcpomatic_setup ();
+ if (!container_ratio) {
+ container_ratio = content_ratio;
+ }
+
ui_signaller = new UISignaller ();
try {
- shared_ptr<Film> film (new Film (output));
+ shared_ptr<Film> film (new Film (output, false));
if (!name.empty ()) {
film->set_name (name);
}
+
+ film->set_container (container_ratio);
for (int i = optind; i < argc; ++i) {
- film->examine_and_add_content (content_factory (film, argv[i]));
+ shared_ptr<Content> c = content_factory (film, argv[i]);
+ shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (c);
+ if (vc) {
+ vc->set_ratio (content_ratio);
+ }
+ film->examine_and_add_content (c);
}
JobManager* jm = JobManager::instance ();
@@ -125,8 +175,12 @@ main (int argc, char* argv[])
}
exit (EXIT_FAILURE);
}
-
- film->write_metadata ();
+
+ if (!output.empty ()) {
+ film->write_metadata ();
+ } else {
+ film->metadata()->write_to_stream_formatted (cout);
+ }
} catch (exception& e) {
cerr << argv[0] << ": " << e.what() << "\n";
exit (EXIT_FAILURE);