4 #ifndef _ArnoldDISTRIBUTED_INTERFACE_H_
5 #define _ArnoldDISTRIBUTED_INTERFACE_H_
9 #include "LumiverseCoreConfig.h"
14 #include <curl_easy.h>
15 #include <curl_exception.h>
16 #include <curl_form.h>
21 #include "../lib/libjson/libjson.h"
25 #include <unordered_map>
29 #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
32 # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
34 # define SET_BINARY_MODE(file)
37 #define CHUNK (1 << 17)
38 #define WINDOW_BITS 15
39 #define GZIP_ENCODING 16
46 struct RequestBuffer {
48 size_t num_written = 0;
61 static size_t write_buffer_callback(
void *ptr,
size_t size,
size_t nmemb,
void *userdata);
70 class DistributedArnoldInterface :
public virtual ArnoldInterface
79 DistributedArnoldInterface(
string host,
int port,
string outputPath) :
83 m_file_output_path(outputPath),
84 m_remote_open(false) {}
92 DistributedArnoldInterface() :
94 m_host_name(
"localhost"),
96 m_file_output_path(
"./test.out"),
97 m_remote_open(false) {}
100 ~DistributedArnoldInterface() { }
110 void init(
const JSONNode jsonPatch);
119 void close()
override;
124 bool setDims(
int w,
int h)
override;
129 void setSamples(
int samples)
override;
136 virtual string getInterfaceType() {
return "DistributedArnoldInterface"; }
145 void setHostPort(
long hostPort) { m_host_port = hostPort; };
150 long getHostPort() {
return m_host_port; };
158 void setHostName(std::string hostName) { m_host_name = hostName; };
165 std::string getHostName() {
return m_host_name; };
175 int render(
const std::set<Device *> &devices);
194 curl::curl_easy getCurlConnection() {
return m_curl_connection; };
201 std::string getFileOutputPath() {
return m_file_output_path; };
208 void setFileOutputPath(std::string outputPath) { m_file_output_path = outputPath; };
218 void setOptionParameter(
const std::string ¶mName,
int val)
override;
219 void setOptionParameter(
const std::string ¶mName,
float val)
override;
224 bool isDistributedOpen()
override;
231 std::string m_host_name;
246 bool openConnection();
259 bool sendDistributedInitRequest(
const JSONNode jsonPatch);
269 bool closeConnection();
274 curl::curl_easy m_curl_connection;
282 std::string m_file_output_path;
299 void bindRequestBuffer(
struct RequestBuffer *buffer, curl::curl_easy &curl_request);
308 void bindRequestBuffer(
struct RequestBuffer *buffer);
313 bool remoteRequestSuccessful(JSONNode response);
322 const JSONNode getDevicesJSON(
const std::set<Device *> &devices);
330 const JSONNode getSettingsJSON();
333 std::unordered_map<std::string, float> float_options;
334 std::unordered_map<std::string, int> int_options;
343 #endif // USE_DUMIVERSE
345 #endif // _ArnoldDISTRIBUTED_INTERFACE_H_
void render()
Render a frame and pass it back to node.
Definition: Dumiverse.cpp:43
void interrupt()
Interrupt the current Arnold renderer.
Definition: Dumiverse.cpp:114
void close()
Close the connection to node.
Definition: Dumiverse.cpp:37
void init(const char *jsonPatchStr, const char *filename)
Initializes data structures.
Definition: Dumiverse.cpp:29
float getPercentage()
Gets the progress of current frame as a percentage.
Definition: Dumiverse.cpp:25
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
Implementation of a interface between ArnoldPatch and arnold.