libguac  0.9.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
protocol.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Glyptodon LLC
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 
24 #ifndef _GUAC_PROTOCOL_H
25 #define _GUAC_PROTOCOL_H
26 
35 #include "layer.h"
36 #include "socket.h"
37 #include "stream.h"
38 #include "timestamp.h"
39 
40 #include <stdarg.h>
41 
42 #include <cairo/cairo.h>
43 
59 typedef enum guac_protocol_status {
60 
65 
70 
75 
80 
86 
92 
98 
104 
110 
116 
122 
127 
132 
137 
143 
145 
150 typedef enum guac_composite_mode {
151 
152  /*
153  * A: Source where destination transparent = S n D'
154  * B: Source where destination opaque = S n D
155  * C: Destination where source transparent = D n S'
156  * D: Destination where source opaque = D n S
157  *
158  * 0 = Active, 1 = Inactive
159  */
160  /* ABCD */
161  GUAC_COMP_ROUT = 0x2, /* 0010 - Clears destination where source opaque */
162  GUAC_COMP_ATOP = 0x6, /* 0110 - Fill where destination opaque only */
163  GUAC_COMP_XOR = 0xA, /* 1010 - XOR */
164  GUAC_COMP_ROVER = 0xB, /* 1011 - Fill where destination transparent only */
165  GUAC_COMP_OVER = 0xE, /* 1110 - Draw normally */
166  GUAC_COMP_PLUS = 0xF, /* 1111 - Add */
167 
168  /* Unimplemented in client: */
169  /* NOT IMPLEMENTED: 0000 - Clear */
170  /* NOT IMPLEMENTED: 0011 - No operation */
171  /* NOT IMPLEMENTED: 0101 - Additive IN */
172  /* NOT IMPLEMENTED: 0111 - Additive ATOP */
173  /* NOT IMPLEMENTED: 1101 - Additive RATOP */
174 
175  /* Buggy in webkit browsers, as they keep channel C on in all cases: */
176  GUAC_COMP_RIN = 0x1, /* 0001 */
177  GUAC_COMP_IN = 0x4, /* 0100 */
178  GUAC_COMP_OUT = 0x8, /* 1000 */
179  GUAC_COMP_RATOP = 0x9, /* 1001 */
180  GUAC_COMP_SRC = 0xC /* 1100 */
181 
182  /* Bitwise composite operations (binary) */
183 
184  /*
185  * A: S' & D'
186  * B: S' & D
187  * C: S & D'
188  * D: S & D
189  *
190  * 0 = Active, 1 = Inactive
191  */
192 
194 
200 
201  /* Constant functions */ /* ABCD */
202  GUAC_TRANSFER_BINARY_BLACK = 0x0, /* 0000 */
203  GUAC_TRANSFER_BINARY_WHITE = 0xF, /* 1111 */
204 
205  /* Copy functions */
206  GUAC_TRANSFER_BINARY_SRC = 0x3, /* 0011 */
207  GUAC_TRANSFER_BINARY_DEST = 0x5, /* 0101 */
208  GUAC_TRANSFER_BINARY_NSRC = 0xC, /* 1100 */
209  GUAC_TRANSFER_BINARY_NDEST = 0xA, /* 1010 */
210 
211  /* AND / NAND */
212  GUAC_TRANSFER_BINARY_AND = 0x1, /* 0001 */
213  GUAC_TRANSFER_BINARY_NAND = 0xE, /* 1110 */
214 
215  /* OR / NOR */
216  GUAC_TRANSFER_BINARY_OR = 0x7, /* 0111 */
217  GUAC_TRANSFER_BINARY_NOR = 0x8, /* 1000 */
218 
219  /* XOR / XNOR */
220  GUAC_TRANSFER_BINARY_XOR = 0x6, /* 0110 */
221  GUAC_TRANSFER_BINARY_XNOR = 0x9, /* 1001 */
222 
223  /* AND / NAND with inverted source */
224  GUAC_TRANSFER_BINARY_NSRC_AND = 0x4, /* 0100 */
225  GUAC_TRANSFER_BINARY_NSRC_NAND = 0xB, /* 1011 */
226 
227  /* OR / NOR with inverted source */
228  GUAC_TRANSFER_BINARY_NSRC_OR = 0xD, /* 1101 */
229  GUAC_TRANSFER_BINARY_NSRC_NOR = 0x2, /* 0010 */
230 
231  /* AND / NAND with inverted destination */
232  GUAC_TRANSFER_BINARY_NDEST_AND = 0x2, /* 0010 */
233  GUAC_TRANSFER_BINARY_NDEST_NAND = 0xD, /* 1101 */
234 
235  /* OR / NOR with inverted destination */
236  GUAC_TRANSFER_BINARY_NDEST_OR = 0xB, /* 1011 */
237  GUAC_TRANSFER_BINARY_NDEST_NOR = 0x4 /* 0100 */
238 
240 
244 typedef enum guac_line_cap_style {
245  GUAC_LINE_CAP_BUTT = 0x0,
246  GUAC_LINE_CAP_ROUND = 0x1,
247  GUAC_LINE_CAP_SQUARE = 0x2
249 
253 typedef enum guac_line_join_style {
254  GUAC_LINE_JOIN_BEVEL = 0x0,
255  GUAC_LINE_JOIN_MITER = 0x1,
256  GUAC_LINE_JOIN_ROUND = 0x2
258 
259 /* CONTROL INSTRUCTIONS */
260 
275 int guac_protocol_send_ack(guac_socket* socket, guac_stream* stream,
276  const char* error, guac_protocol_status status);
277 
288 int guac_protocol_send_args(guac_socket* socket, const char** args);
289 
300 int guac_protocol_send_connect(guac_socket* socket, const char** args);
301 
312 
324 int guac_protocol_send_error(guac_socket* socket, const char* error,
325  guac_protocol_status status);
326 
339 int guac_protocol_send_log(guac_socket* socket, const char* format, ...);
340 
353 int vguac_protocol_send_log(guac_socket* socket, const char* format,
354  va_list args);
355 
369 int guac_protocol_send_nest(guac_socket* socket, int index,
370  const char* data);
371 
383 
396 int guac_protocol_send_set(guac_socket* socket, const guac_layer* layer,
397  const char* name, const char* value);
398 
409 int guac_protocol_send_select(guac_socket* socket, const char* protocol);
410 
422 int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp);
423 
424 /* MEDIA INSTRUCTIONS */
425 
439 int guac_protocol_send_audio(guac_socket* socket, const guac_stream* stream,
440  int channel, const char* mimetype, double duration);
441 
454 int guac_protocol_send_file(guac_socket* socket, const guac_stream* stream,
455  const char* mimetype, const char* name);
456 
469 int guac_protocol_send_pipe(guac_socket* socket, const guac_stream* stream,
470  const char* mimetype, const char* name);
471 
486 int guac_protocol_send_blob(guac_socket* socket, const guac_stream* stream,
487  void* data, int count);
488 
499 int guac_protocol_send_end(guac_socket* socket, const guac_stream* stream);
500 
514 int guac_protocol_send_video(guac_socket* socket, const guac_stream* stream,
515  const guac_layer* layer, const char* mimetype, double duration);
516 
517 /* DRAWING INSTRUCTIONS */
518 
536 int guac_protocol_send_arc(guac_socket* socket, const guac_layer* layer,
537  int x, int y, int radius, double startAngle, double endAngle,
538  int negative);
539 
556  guac_composite_mode mode, const guac_layer* layer,
557  int r, int g, int b, int a);
558 
569 int guac_protocol_send_clip(guac_socket* socket, const guac_layer* layer);
570 
581 int guac_protocol_send_close(guac_socket* socket, const guac_layer* layer);
582 
604  const guac_layer* srcl, int srcx, int srcy, int w, int h,
605  guac_composite_mode mode, const guac_layer* dstl, int dstx, int dsty);
606 
626  guac_composite_mode mode, const guac_layer* layer,
627  guac_line_cap_style cap, guac_line_join_style join, int thickness,
628  int r, int g, int b, int a);
629 
646 int guac_protocol_send_cursor(guac_socket* socket, int x, int y,
647  const guac_layer* srcl, int srcx, int srcy, int w, int h);
648 
665 int guac_protocol_send_curve(guac_socket* socket, const guac_layer* layer,
666  int cp1x, int cp1y, int cp2x, int cp2y, int x, int y);
667 
678 int guac_protocol_send_identity(guac_socket* socket, const guac_layer* layer);
679 
693  guac_composite_mode mode, const guac_layer* layer,
694  const guac_layer* srcl);
695 
708 int guac_protocol_send_line(guac_socket* socket, const guac_layer* layer,
709  int x, int y);
710 
727  guac_composite_mode mode, const guac_layer* layer,
728  guac_line_cap_style cap, guac_line_join_style join, int thickness,
729  const guac_layer* srcl);
730 
747  const guac_layer* layer, int x, int y, cairo_surface_t* surface);
748 
759 int guac_protocol_send_pop(guac_socket* socket, const guac_layer* layer);
760 
771 int guac_protocol_send_push(guac_socket* socket, const guac_layer* layer);
772 
787 int guac_protocol_send_rect(guac_socket* socket, const guac_layer* layer,
788  int x, int y, int width, int height);
789 
800 int guac_protocol_send_reset(guac_socket* socket, const guac_layer* layer);
801 
814 int guac_protocol_send_start(guac_socket* socket, const guac_layer* layer,
815  int x, int y);
816 
838  const guac_layer* srcl, int srcx, int srcy, int w, int h,
839  guac_transfer_function fn, const guac_layer* dstl, int dstx, int dsty);
840 
858  const guac_layer* layer,
859  double a, double b, double c,
860  double d, double e, double f);
861 
862 /* LAYER INSTRUCTIONS */
863 
874 int guac_protocol_send_dispose(guac_socket* socket, const guac_layer* layer);
875 
893  const guac_layer* layer,
894  double a, double b, double c,
895  double d, double e, double f);
896 
912 int guac_protocol_send_move(guac_socket* socket, const guac_layer* layer,
913  const guac_layer* parent, int x, int y, int z);
914 
926 int guac_protocol_send_shade(guac_socket* socket, const guac_layer* layer,
927  int a);
928 
941 int guac_protocol_send_size(guac_socket* socket, const guac_layer* layer,
942  int w, int h);
943 
944 /* TEXT INSTRUCTIONS */
945 
956 int guac_protocol_send_clipboard(guac_socket* socket, const char* data);
957 
965 int guac_protocol_send_name(guac_socket* socket, const char* name);
966 
974 int guac_protocol_decode_base64(char* base64);
975 
976 #endif
977