4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef RENDERFARMCLIENT_H
23 #define RENDERFARMCLIENT_H
25 #include "arraylist.h"
30 #include "packagerenderer.h"
31 #include "pluginserver.inc"
32 #include "preferences.inc"
33 #include "renderfarm.inc"
34 #include "renderfarmclient.inc"
35 //#include "renderfarmfsclient.inc"
38 class RenderFarmClient
41 RenderFarmClient(int port,
49 // After a socket times out, kill the render node.
54 // PID to be returned to background render object
56 // The plugin paths must be known before any threads are started
57 BC_Hash *boot_defaults;
58 Preferences *boot_preferences;
61 class RenderFarmClientThread : public Thread
64 RenderFarmClientThread(RenderFarmClient *client);
65 ~RenderFarmClientThread();
67 // Commands call this to send the request packet.
68 // The ID of the request followed by the size of the data that follows is sent.
69 int send_request_header(int request,
71 // These are local functions to handle errors the right way for a client.
72 // They simply call the RenderFarmServerThread functions and abort if error.
73 int write_socket(char *data, int len);
74 int read_socket(char *data, int len);
76 int write_int64(int64_t number);
77 int64_t read_int64(int *error = 0);
78 void read_string(char* &string);
80 // Lock access to the socket during complete transactions
81 void lock(const char *location);
83 static void trap_hook(FILE *fp, void *vp);
85 void do_tuner(int socket_fd);
86 void do_packages(int socket_fd);
88 void get_command(int socket_fd, int *command);
89 void read_preferences(int socket_fd,
90 Preferences *preferences);
91 void read_asset(int socket_fd, Asset *asset);
92 void read_edl(int socket_fd, EDL *edl, Preferences *preferences);
93 int read_package(int socket_fd, RenderPackage *package);
94 int send_completion(int socket_fd);
96 void init_client_keepalive(int timeout_secs);
98 void main_loop(int socket_fd);
102 // Everything must be contained in run()
105 RenderFarmClient *client;
106 // RenderFarmFSClient *fs_client;
107 double frames_per_second;
109 RenderFarmWatchdog *watchdog;
110 RenderFarmKeepalive *keep_alive;
111 // pid of forked process
121 class FarmPackageRenderer : public PackageRenderer
124 FarmPackageRenderer(RenderFarmClientThread *thread,
126 ~FarmPackageRenderer();
130 void set_result(int value);
131 void set_progress(int64_t total_samples);
132 int set_video_map(int64_t position, int value);
136 RenderFarmClientThread *thread;
146 class RenderFarmKeepalive : public Thread
149 RenderFarmKeepalive(RenderFarmClientThread *client_thread);
150 ~RenderFarmKeepalive();
154 RenderFarmClientThread *client_thread;