r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / renderfarmclient.h
bloba62caf7b87647b7a9665c7fd0bbafd0d1cbecf71
1 #ifndef RENDERFARMCLIENT_H
2 #define RENDERFARMCLIENT_H
4 #include "arraylist.h"
5 #include "assets.inc"
6 #include "defaults.inc"
7 #include "edl.inc"
8 #include "packagerenderer.h"
9 #include "pluginserver.inc"
10 #include "preferences.inc"
11 #include "renderfarmclient.inc"
12 #include "renderfarmfsclient.inc"
13 #include "thread.h"
15 // The render client waits for connections from the server.
16 // Then it starts a thread for each connection.
17 class RenderFarmClient
19 public:
20 RenderFarmClient(int port, char *deamon_path);
21 ~RenderFarmClient();
23 void main_loop();
26 // After a socket times out, kill the render node.
27 void kill_client();
29 RenderFarmClientThread *thread;
31 int port;
32 char *deamon_path;
33 // PID to be returned to background render object
34 int this_pid;
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
51 public:
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,
58 int len);
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);
62 void lock();
63 void unlock();
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,
73 EDL *edl,
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);
79 void run();
81 // Everything must be contained in run()
82 int socket_fd;
83 // Read only
84 RenderFarmClient *client;
85 RenderFarmFSClient *fs_client;
86 double frames_per_second;
87 Mutex *mutex_lock;
101 class FarmPackageRenderer : public PackageRenderer
103 public:
104 FarmPackageRenderer(RenderFarmClientThread *thread,
105 int socket_fd);
106 ~FarmPackageRenderer();
109 int get_result();
110 void set_result(int value);
111 void set_progress(int64_t total_samples);
112 void set_video_map(int64_t position, int value);
115 int socket_fd;
116 RenderFarmClientThread *thread;
127 #endif