prevent popup deactivation while button_down
[goodguy/history.git] / cinelerra-5.0 / cinelerra / renderfarmclient.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
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.
10  * 
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.
15  * 
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
19  * 
20  */
21
22 #ifndef RENDERFARMCLIENT_H
23 #define RENDERFARMCLIENT_H
24
25 #include "arraylist.h"
26 #include "asset.inc"
27 #include "bchash.inc"
28 #include "edl.inc"
29 #include "mutex.inc"
30 #include "packagerenderer.h"
31 #include "pluginserver.inc"
32 #include "preferences.inc"
33 #include "renderfarm.inc"
34 #include "renderfarmclient.inc"
35 //#include "renderfarmfsclient.inc"
36 #include "thread.h"
37
38 class RenderFarmClient
39 {
40 public:
41         RenderFarmClient(int port, 
42                 char *deamon_path, 
43                 int nice_value,
44                 char *config_path);
45         ~RenderFarmClient();
46         
47         void main_loop();
48
49
50
51
52 // After a socket times out, kill the render node.
53         void kill_client();
54         
55 //      RenderFarmClientThread *thread;
56         
57         int port;
58         char *deamon_path;
59 // PID to be returned to background render object
60         int this_pid;
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;
65 };
66
67 class RenderFarmClientThread : public Thread
68 {
69 public:
70         RenderFarmClientThread(RenderFarmClient *client);
71         ~RenderFarmClientThread();
72
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, 
76                 int len);
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);
81 // Return 1 if error
82         int write_int64(int64_t number);
83         int64_t read_int64(int *error = 0);
84         void read_string(char* &string);
85         void abort();
86 // Lock access to the socket during complete transactions
87         void lock(const char *location);
88         void unlock();
89
90
91
92         void do_tuner(int socket_fd);
93         void do_packages(int socket_fd);
94
95
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, 
101                 EDL *edl, 
102                 Preferences *preferences);
103         int read_package(int socket_fd, RenderPackage *package);
104         int send_completion(int socket_fd);
105         void ping_server();
106         void init_client_keepalive();
107
108         void main_loop(int socket_fd);
109         void run();
110
111 // Everything must be contained in run()
112         int socket_fd;
113 // Read only
114         RenderFarmClient *client;
115 //      RenderFarmFSClient *fs_client;
116         double frames_per_second;
117         Mutex *mutex_lock;
118         RenderFarmWatchdog *watchdog;
119         RenderFarmKeepalive *keep_alive;
120 // pid of forked process
121         int pid;
122 };
123
124
125
126
127
128
129
130 class FarmPackageRenderer : public PackageRenderer
131 {
132 public:
133         FarmPackageRenderer(RenderFarmClientThread *thread,
134                 int socket_fd);
135         ~FarmPackageRenderer();
136         
137         
138         int get_result();
139         void set_result(int value);
140         void set_progress(int64_t total_samples);
141         int set_video_map(int64_t position, int value);
142
143         
144         int socket_fd;
145         RenderFarmClientThread *thread;
146 };
147
148
149
150
151
152
153
154
155 class RenderFarmKeepalive : public Thread
156 {
157 public:
158         RenderFarmKeepalive(RenderFarmClientThread *client_thread);
159         ~RenderFarmKeepalive();
160
161         void run();
162
163         RenderFarmClientThread *client_thread;
164         int done;
165 };
166
167
168
169
170
171
172
173 #endif