full screen vicon view popup
[goodguy/cinelerra.git] / cinelerra-5.1 / 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 // After a socket times out, kill the render node.
50         void kill_client();
51
52         int port;
53         char *deamon_path;
54 // PID to be returned to background render object
55         int this_pid;
56 // The plugin paths must be known before any threads are started
57         BC_Hash *boot_defaults;
58         Preferences *boot_preferences;
59 };
60
61 class RenderFarmClientThread : public Thread
62 {
63 public:
64         RenderFarmClientThread(RenderFarmClient *client);
65         ~RenderFarmClientThread();
66
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,
70                 int len);
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);
75 // Return 1 if error
76         int write_int64(int64_t number);
77         int64_t read_int64(int *error = 0);
78         void read_string(char* &string);
79         void abort();
80 // Lock access to the socket during complete transactions
81         void lock(const char *location);
82         void unlock();
83         static void trap_hook(FILE *fp, void *vp);
84
85         void do_tuner(int socket_fd);
86         void do_packages(int socket_fd);
87
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);
95         void ping_server();
96         void init_client_keepalive(int timeout_secs);
97
98         void main_loop(int socket_fd);
99         void run();
100
101         EDL *edl;
102 // Everything must be contained in run()
103         int socket_fd;
104 // Read only
105         RenderFarmClient *client;
106 //      RenderFarmFSClient *fs_client;
107         double frames_per_second;
108         Mutex *mutex_lock;
109         RenderFarmWatchdog *watchdog;
110         RenderFarmKeepalive *keep_alive;
111 // pid of forked process
112         int pid;
113 };
114
115
116
117
118
119
120
121 class FarmPackageRenderer : public PackageRenderer
122 {
123 public:
124         FarmPackageRenderer(RenderFarmClientThread *thread,
125                 int socket_fd);
126         ~FarmPackageRenderer();
127
128
129         int get_result();
130         void set_result(int value);
131         void set_progress(int64_t total_samples);
132         int set_video_map(int64_t position, int value);
133
134
135         int socket_fd;
136         RenderFarmClientThread *thread;
137 };
138
139
140
141
142
143
144
145
146 class RenderFarmKeepalive : public Thread
147 {
148 public:
149         RenderFarmKeepalive(RenderFarmClientThread *client_thread);
150         ~RenderFarmKeepalive();
151
152         void run();
153
154         RenderFarmClientThread *client_thread;
155         int done;
156 };
157
158
159
160
161
162
163
164 #endif