summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-12-06 23:43:42 +0000
committerCarl Hetherington <cth@carlh.net>2015-12-11 11:56:50 +0000
commit9af73fe2b9ea2ef82d641d44a995c110f8e61693 (patch)
treeb688c996abce413184469d75d9e072e3b9bbaff3 /src/tools
parent18f65c026edc1ad49cf433f8b07db3a7c9838e9f (diff)
Basics of send-to-batch-converter; not tested on Windows nor OS X.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/dcpomatic.cc44
-rw-r--r--src/tools/dcpomatic_batch.cc58
2 files changed, 93 insertions, 9 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 0cd0bac33..16c7a08e5 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -55,7 +55,9 @@
#include "lib/content_factory.h"
#include "lib/compose.hpp"
#include "lib/cinema_kdms.h"
+#include "lib/dcpomatic_socket.h"
#include <dcp/exceptions.h>
+#include <dcp/raw_convert.h>
#include <wx/generic/aboutdlgg.h>
#include <wx/stdpaths.h>
#include <wx/cmdline.h>
@@ -88,6 +90,7 @@ using std::list;
using std::exception;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
+using dcp::raw_convert;
class FilmChangedDialog
{
@@ -138,6 +141,7 @@ enum {
ID_content_scale_to_fit_width = 100,
ID_content_scale_to_fit_height,
ID_jobs_make_dcp,
+ ID_jobs_make_dcp_batch,
ID_jobs_make_kdms,
ID_jobs_make_self_dkdm,
ID_jobs_send_dcp_to_tms,
@@ -204,6 +208,7 @@ public:
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::content_scale_to_fit_height, this), ID_content_scale_to_fit_height);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_make_dcp, this), ID_jobs_make_dcp);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_make_kdms, this), ID_jobs_make_kdms);
+ Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_make_dcp_batch, this), ID_jobs_make_dcp_batch);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_make_self_dkdm, this), ID_jobs_make_self_dkdm);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_send_dcp_to_tms, this), ID_jobs_send_dcp_to_tms);
Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::jobs_show_dcp, this), ID_jobs_show_dcp);
@@ -482,6 +487,44 @@ private:
d->Destroy ();
}
+ void jobs_make_dcp_batch ()
+ {
+ if (!_film) {
+ return;
+ }
+
+ _film->write_metadata ();
+
+ /* i = 0; try to connect via socket
+ i = 1; try again, and then try to start the batch converter
+ i = 2; try again.
+ i = 3; try again.
+ */
+ for (int i = 0; i < 4; ++i) {
+ try {
+ boost::asio::io_service io_service;
+ boost::asio::ip::tcp::resolver resolver (io_service);
+ boost::asio::ip::tcp::resolver::query query ("localhost", raw_convert<string> (Config::instance()->server_port_base() + 2));
+ boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve (query);
+ Socket socket (1);
+ socket.connect (*endpoint_iterator);
+ string s = _film->directory().string ();
+ socket.write (s.length() + 1);
+ socket.write ((uint8_t *) s.c_str(), s.length() + 1);
+ return;
+ } catch (...) {
+ }
+
+ if (i == 1) {
+ start_batch_converter (wx_to_std (wxStandardPaths::Get().GetExecutablePath()));
+ }
+
+ dcpomatic_sleep (1);
+ }
+
+ error_dialog (this, _("Could not find batch converter."));
+ }
+
void jobs_make_self_dkdm ()
{
if (!_film) {
@@ -750,6 +793,7 @@ private:
wxMenu* jobs_menu = new wxMenu;
add_item (jobs_menu, _("&Make DCP\tCtrl-M"), ID_jobs_make_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION);
+ add_item (jobs_menu, _("Make DCP in &batch converter\tCtrl-B"), ID_jobs_make_dcp_batch, NEEDS_FILM | NOT_DURING_DCP_CREATION);
add_item (jobs_menu, _("Make &KDMs...\tCtrl-K"), ID_jobs_make_kdms, NEEDS_FILM);
add_item (jobs_menu, _("Make DKDM for DCP-o-matic..."), ID_jobs_make_self_dkdm, NEEDS_FILM);
add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL);
diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc
index 7db05c0dd..677861c3d 100644
--- a/src/tools/dcpomatic_batch.cc
+++ b/src/tools/dcpomatic_batch.cc
@@ -29,14 +29,20 @@
#include "lib/util.h"
#include "lib/film.h"
#include "lib/job_manager.h"
+#include "lib/dcpomatic_socket.h"
#include <wx/aboutdlg.h>
#include <wx/stdpaths.h>
#include <wx/cmdline.h>
#include <wx/preferences.h>
#include <wx/wx.h>
+#include <iostream>
using std::exception;
+using std::string;
+using std::cout;
using boost::shared_ptr;
+using boost::thread;
+using boost::scoped_array;
static std::string film_to_load;
@@ -118,6 +124,19 @@ public:
Bind (wxEVT_SIZE, boost::bind (&DOMFrame::sized, this, _1));
}
+ void start_job (boost::filesystem::path path)
+ {
+ try {
+ shared_ptr<Film> film (new Film (path));
+ film->read_metadata ();
+ film->make_dcp ();
+ } catch (std::exception& e) {
+ wxString p = std_to_wx (path.string ());
+ wxCharBuffer b = p.ToUTF8 ();
+ error_dialog (this, wxString::Format (_("Could not open film at %s (%s)"), p.data(), std_to_wx (e.what()).data()));
+ }
+ }
+
private:
void sized (wxSizeEvent& ev)
{
@@ -207,15 +226,7 @@ private:
}
if (r == wxID_OK) {
- try {
- shared_ptr<Film> film (new Film (wx_to_std (c->GetPath ())));
- film->read_metadata ();
- film->make_dcp ();
- } catch (std::exception& e) {
- wxString p = c->GetPath ();
- wxCharBuffer b = p.ToUTF8 ();
- error_dialog (this, wxString::Format (_("Could not open film at %s (%s)"), p.data(), std_to_wx (e.what()).data()));
- }
+ start_job (wx_to_std (c->GetPath ()));
}
_last_parent = boost::filesystem::path (wx_to_std (c->GetPath ())).parent_path ();
@@ -234,6 +245,32 @@ static const wxCmdLineEntryDesc command_line_description[] = {
{ wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
};
+class JobServer : public Server
+{
+public:
+ JobServer (DOMFrame* frame)
+ : Server (Config::instance()->server_port_base() + 2)
+ , _frame (frame)
+ {}
+
+ void handle (shared_ptr<Socket> socket)
+ {
+ try {
+ int const length = socket->read_uint32 ();
+ cout << "len=" << length << "\n";
+ scoped_array<char> buffer (new char[length]);
+ socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
+ string s (buffer.get());
+ _frame->start_job (s);
+ } catch (...) {
+
+ }
+ }
+
+private:
+ DOMFrame* _frame;
+};
+
class App : public wxApp
{
bool OnInit ()
@@ -273,6 +310,9 @@ class App : public wxApp
f->Maximize ();
f->Show ();
+ JobServer* server = new JobServer (f);
+ new thread (boost::bind (&JobServer::run, server));
+
signal_manager = new wxSignalManager (this);
this->Bind (wxEVT_IDLE, boost::bind (&App::idle, this));