1 #ifndef RENDERFARMCLIENT_H
2 #define RENDERFARMCLIENT_H
6 #include "defaults.inc"
8 #include "packagerenderer.h"
9 #include "pluginserver.inc"
10 #include "preferences.inc"
11 #include "renderfarmclient.inc"
12 #include "renderfarmfsclient.inc"
15 // The render client waits for connections from the server.
16 // Then it starts a thread for each connection.
17 class RenderFarmClient
20 RenderFarmClient(int port
, char *deamon_path
);
26 // After a socket times out, kill the render node.
29 RenderFarmClientThread
*thread
;
33 // PID to be returned to background render object
35 // The plugin paths must be known before any threads are started
36 Defaults
*boot_defaults
;
37 Preferences
*boot_preferences
;
38 ArrayList
<PluginServer
*> *plugindb
;
41 // When a connection is opened, the thread forks to handle the rendering session.
42 // A fork instead of a thread is used to avoid reentrancy problems with the
43 // codecs, but we still need a thread to join the process.
45 // The fork requests jobs from the server until the job table is empty
46 // or the server reports an error. This fork must poll the server
47 // after every frame for the error status.
48 // Detaches when finished.
49 class RenderFarmClientThread
: Thread
52 RenderFarmClientThread(RenderFarmClient
*client
);
53 ~RenderFarmClientThread();
55 // Commands call this to send the request packet.
56 // The ID of the request followed by the size of the data that follows is sent.
57 int send_request_header(int request
,
59 int write_socket(char *data
, int len
, int timeout
);
60 int read_socket(char *data
, int len
, int timeout
);
61 void read_string(int socket_fd
, char* &string
);
69 void RenderFarmClientThread::read_preferences(int socket_fd
,
70 Preferences
*preferences
);
71 void read_asset(int socket_fd
, Asset
*asset
);
72 void read_edl(int socket_fd
,
74 Preferences
*preferences
);
75 int read_package(int socket_fd
, RenderPackage
*package
);
76 int send_completion(int socket_fd
);
78 void main_loop(int socket_fd
);
81 // Everything must be contained in run()
84 RenderFarmClient
*client
;
85 RenderFarmFSClient
*fs_client
;
86 double frames_per_second
;
101 class FarmPackageRenderer
: public PackageRenderer
104 FarmPackageRenderer(RenderFarmClientThread
*thread
,
106 ~FarmPackageRenderer();
110 void set_result(int value
);
111 void set_progress(int64_t total_samples
);
112 void set_video_map(int64_t position
, int value
);
116 RenderFarmClientThread
*thread
;