X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_batch.cc;h=677861c3d4ae688dd58da8d759ae38c6583f3f4d;hp=7db05c0ddde0182489b889bdb88a99a64d3e0719;hb=9af73fe2b9ea2ef82d641d44a995c110f8e61693;hpb=18f65c026edc1ad49cf433f8b07db3a7c9838e9f 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));