+2015-12-06 Carl Hetherington <cth@carlh.net>
+
+ * Add menu option to send a project to the
+ batch converter (#770).
+
2015-12-10 Carl Hetherington <cth@carlh.net>
* Put ISDCF name subtitle language in lower case if all subs are
/** default directory to put new films in */
boost::filesystem::path _default_directory;
/** base port number to use for J2K encoding servers;
- * this port and the one above it will be used.
+ * this port and the two above it will be used.
*/
int _server_port_base;
/** true to broadcast on the `any' address to look for servers */
IOPMAssertionRelease (_assertion_id);
#endif
}
+
+void
+start_batch_converter (boost::filesystem::path dcpomatic)
+{
+#if defined(DCPOMATIC_LINUX) || defined(DCPOMATIC_WINDOWS)
+ boost::filesystem::path batch = dcpomatic.parent_path() / "dcpomatic2_batch";
+#endif
+
+#ifdef DCPOMATIC_OSX
+ boost::filesystem::patch batch = dcpomatic.parent_path ();
+ batch = batch.parent_path (); // MacOS
+ batch = batch.parent_path (); // Contents
+ batch = batch.parent_path (); // DCP-o-matic.app
+ batch = batch.parent_path (); // Applications
+ batch /= "DCP-o-matic 2 Batch Converter.app" / "Contents" / "MacOS" / "dcpomatic2_batch";
+#endif
+
+#ifdef DCPOMATIC_LINUX
+ pid_t pid = fork ();
+ if (pid == 0) {
+ int const r = system (batch.string().c_str ());
+ exit (WEXITSTATUS (r));
+ }
+#endif
+
+}
extern boost::filesystem::path shared_path ();
extern FILE * fopen_boost (boost::filesystem::path, std::string);
extern int dcpomatic_fseek (FILE *, int64_t, int);
+extern void start_batch_converter (boost::filesystem::path dcpomatic);
/** @class Waker
* @brief A class which tries to keep the computer awake on various operating systems.
#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>
using std::exception;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
+using dcp::raw_convert;
class FilmChangedDialog
{
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,
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);
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) {
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);
#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;
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)
{
}
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 ();
{ 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 ()
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));