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,
52 // After a socket times out, kill the render node.
55 // RenderFarmClientThread *thread;
59 // PID to be returned to background render object
61 // The plugin paths must be known before any threads are started
62 BC_Hash *boot_defaults;
63 Preferences *boot_preferences;
64 ArrayList<PluginServer*> *plugindb;
67 class RenderFarmClientThread : public Thread
70 RenderFarmClientThread(RenderFarmClient *client);
71 ~RenderFarmClientThread();
73 // Commands call this to send the request packet.
74 // The ID of the request followed by the size of the data that follows is sent.
75 int send_request_header(int request,
77 // These are local functions to handle errors the right way for a client.
78 // They simply call the RenderFarmServerThread functions and abort if error.
79 int write_socket(char *data, int len);
80 int read_socket(char *data, int len);
82 int write_int64(int64_t number);
83 int64_t read_int64(int *error = 0);
84 void read_string(char* &string);
86 // Lock access to the socket during complete transactions
87 void lock(const char *location);
92 void do_tuner(int socket_fd);
93 void do_packages(int socket_fd);
96 void get_command(int socket_fd, int *command);
97 void read_preferences(int socket_fd,
98 Preferences *preferences);
99 void read_asset(int socket_fd, Asset *asset);
100 void read_edl(int socket_fd,
102 Preferences *preferences);
103 int read_package(int socket_fd, RenderPackage *package);
104 int send_completion(int socket_fd);
106 void init_client_keepalive();
108 void main_loop(int socket_fd);
111 // Everything must be contained in run()
114 RenderFarmClient *client;
115 // RenderFarmFSClient *fs_client;
116 double frames_per_second;
118 RenderFarmWatchdog *watchdog;
119 RenderFarmKeepalive *keep_alive;
120 // pid of forked process
130 class FarmPackageRenderer : public PackageRenderer
133 FarmPackageRenderer(RenderFarmClientThread *thread,
135 ~FarmPackageRenderer();
139 void set_result(int value);
140 void set_progress(int64_t total_samples);
141 int set_video_map(int64_t position, int value);
145 RenderFarmClientThread *thread;
155 class RenderFarmKeepalive : public Thread
158 RenderFarmKeepalive(RenderFarmClientThread *client_thread);
159 ~RenderFarmKeepalive();
163 RenderFarmClientThread *client_thread;