Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

renderfarmclient.h

Go to the documentation of this file.
00001 #ifndef RENDERFARMCLIENT_H
00002 #define RENDERFARMCLIENT_H
00003 
00004 #include "arraylist.h"
00005 #include "asset.inc"
00006 #include "defaults.inc"
00007 #include "edl.inc"
00008 #include "packagerenderer.h"
00009 #include "pluginserver.inc"
00010 #include "preferences.inc"
00011 #include "renderfarmclient.inc"
00012 //#include "renderfarmfsclient.inc"
00013 #include "thread.h"
00014 
00015 // The render client waits for connections from the server.
00016 // Then it starts a thread for each connection.
00017 class RenderFarmClient
00018 {
00019 public:
00020         RenderFarmClient(int port, 
00021                 char *deamon_path, 
00022                 int nice_value,
00023                 char *config_path);
00024         ~RenderFarmClient();
00025         
00026         void main_loop();
00027         
00028 
00029 // After a socket times out, kill the render node.
00030         void kill_client();
00031         
00032         RenderFarmClientThread *thread;
00033         
00034         int port;
00035         char *deamon_path;
00036 // PID to be returned to background render object
00037         int this_pid;
00038 // The plugin paths must be known before any threads are started
00039         Defaults *boot_defaults;
00040         Preferences *boot_preferences;
00041         ArrayList<PluginServer*> *plugindb;
00042 };
00043 
00044 // When a connection is opened, the thread forks to handle the rendering session.
00045 // A fork instead of a thread is used to avoid reentrancy problems with the
00046 // codecs, but we still need a thread to join the process.
00047 //
00048 // The fork requests jobs from the server until the job table is empty
00049 // or the server reports an error.  This fork must poll the server
00050 // after every frame for the error status.
00051 // Detaches when finished.
00052 class RenderFarmClientThread : Thread
00053 {
00054 public:
00055         RenderFarmClientThread(RenderFarmClient *client);
00056         ~RenderFarmClientThread();
00057 
00058 // Commands call this to send the request packet.
00059 // The ID of the request followed by the size of the data that follows is sent.
00060         int send_request_header(int request, 
00061                 int len);
00062         int write_socket(char *data, int len, int timeout);
00063         int read_socket(char *data, int len, int timeout);
00064         void abort();
00065         void read_string(int socket_fd, char* &string);
00066         void lock(char *location);
00067         void unlock();
00068 
00069 
00070 
00071 
00072 
00073         void RenderFarmClientThread::read_preferences(int socket_fd, 
00074                 Preferences *preferences);
00075         void read_asset(int socket_fd, Asset *asset);
00076         void read_edl(int socket_fd, 
00077                 EDL *edl, 
00078                 Preferences *preferences);
00079         int read_package(int socket_fd, RenderPackage *package);
00080         int send_completion(int socket_fd);
00081 
00082         void main_loop(int socket_fd);
00083         void run();
00084 
00085 // Everything must be contained in run()
00086         int socket_fd;
00087 // Read only
00088         RenderFarmClient *client;
00089 //      RenderFarmFSClient *fs_client;
00090         double frames_per_second;
00091         Mutex *mutex_lock;
00092 };
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 class FarmPackageRenderer : public PackageRenderer
00106 {
00107 public:
00108         FarmPackageRenderer(RenderFarmClientThread *thread,
00109                 int socket_fd);
00110         ~FarmPackageRenderer();
00111         
00112         
00113         int get_result();
00114         void set_result(int value);
00115         void set_progress(int64_t total_samples);
00116         int set_video_map(int64_t position, int value);
00117 
00118         
00119         int socket_fd;
00120         RenderFarmClientThread *thread;
00121 };
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 #endif

Generated on Sun Jan 8 13:39:00 2006 for Cinelerra-svn by  doxygen 1.4.4