terom@2: #ifndef RENDER_REMOTE_H terom@2: #define RENDER_REMOTE_H terom@2: terom@4: #include terom@4: #include terom@2: terom@2: #include "render.h" terom@2: terom@2: /* terom@2: * Execute a render_t operation on a remote render_node terom@2: */ terom@2: terom@2: terom@2: #define RENDER_PORT 6159 terom@2: terom@3: struct remote_render_ctx; terom@3: terom@2: /* terom@3: * Execute the given render operation on the render_node at the given remote address. terom@3: * terom@3: * The various callback functions must all be provided. terom@3: * terom@3: * cb_sent will be invoked after the request has succesfully been written, and before cb_data is called. terom@3: * cb_data is called whenever new data has been received. See also, render_remote_set_chunk_size terom@3: * cb_done is called when all the data has been passed to cb_data terom@3: * cb_fail is called when an error is encountered. This can (and will) happen at any time! terom@2: */ terom@3: struct remote_render_ctx *render_remote ( terom@2: render_t *render_ctx, // what to render terom@2: struct sockaddr_storage *remote, // what render node to use terom@2: void (*cb_sent)(void *arg), terom@2: void (*cb_data)(struct evbuffer *buf, void *arg), terom@2: void (*cb_done)(void *arg), terom@2: void (*cb_fail)(void *arg), terom@2: void *cb_arg; terom@2: ); terom@2: terom@3: /* terom@3: * Cancel the given request. No more callbacks will be called, buffered data is discarded and the remote render process will cancel asap. terom@3: */ terom@3: void render_remote_cancel (struct remote_render_ctx *ctx); terom@3: terom@3: /* terom@6: * Controls the behaviour of when cb_data is called, and how remote data is read in. terom@3: * terom@6: * recv_threshold, sets a threshold for calling cb_data - cb_data will only be called terom@6: * if the buffer contains at least recv_threshold, bytes. Note that cb_data is only terom@6: * ever called when new data has been receieved from the remote end - never terom@6: * otherwise. If cb_data doesn't drain the buffer, cb_data will be called again terom@6: * once more data has been received from the remote end. terom@3: * terom@6: * overflow_size can be used to control the amount of unread data in cb_data. If terom@6: * the buffer contains more than recv_threshold + unread_buffer bytes, we will stop terom@6: * accepting bytes from the remote end, and cb_data will not be called any more. terom@3: * terom@3: * Only call this once cb_sent has fired terom@3: */ terom@6: int render_remote_set_recv (struct remote_render_ctx *ctx, size_t recv_threshold, size_t unread_buffer); terom@6: terom@6: /* terom@6: * Call cb_data with the current set of buffered input data immediately, terom@6: * regardless of whether or not the buffer contains any data, or any new terom@6: * data has been received. terom@6: * terom@6: * Only call this after cb_sent and before cb_done/cb_fail. terom@6: */ terom@6: int render_remote_shake (struct remote_render_ctx *ctx); terom@3: terom@2: #endif /* RENDER_REMOTE_H */