From 9af73fe2b9ea2ef82d641d44a995c110f8e61693 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 6 Dec 2015 23:43:42 +0000 Subject: Basics of send-to-batch-converter; not tested on Windows nor OS X. --- src/tools/dcpomatic_batch.cc | 58 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 9 deletions(-) (limited to 'src/tools/dcpomatic_batch.cc') 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 #include #include #include #include +#include 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 (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 (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) + { + try { + int const length = socket->read_uint32 (); + cout << "len=" << length << "\n"; + scoped_array buffer (new char[length]); + socket->read (reinterpret_cast (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)); -- cgit v1.2.3