uploaded original spice-server-0.12.4 and celt-0.5.1.3
[sdk/emulator/libs/spice-server.git] / spice-common / spice1.proto
1 /* built in types:
2    int8, uint8, 16, 32, 64
3 */
4
5 typedef fixed28_4 int32 @ctype(SPICE_FIXED28_4);
6
7 struct Point {
8     int32 x;
9     int32 y;
10 };
11
12 struct Point16 {
13     int16 x;
14     int16 y;
15 };
16
17 struct PointFix {
18     fixed28_4 x;
19     fixed28_4 y;
20 };
21
22 struct Rect {
23     int32 top;
24     int32 left;
25     int32 bottom;
26     int32 right;
27 };
28
29 enum32 link_err {
30     OK,
31     ERROR,
32     INVALID_MAGIC,
33     INVALID_DATA,
34     VERSION_MISMATCH,
35     NEED_SECURED,
36     NEED_UNSECURED,
37     PERMISSION_DENIED,
38     BAD_CONNECTION_ID,
39     CHANNEL_NOT_AVAILABLE
40 };
41
42 enum32 warn_code {
43     WARN_GENERAL
44 } @prefix(SPICE_);
45
46 enum32 info_code {
47     INFO_GENERAL
48 } @prefix(SPICE_);
49
50 flags32 migrate_flags {
51     NEED_FLUSH,
52     NEED_DATA_TRANSFER
53 } @prefix(SPICE_MIGRATE_);
54
55 enum32 notify_severity {
56     INFO,
57     WARN,
58     ERROR,
59 };
60
61 enum32 notify_visibility {
62     LOW,
63     MEDIUM,
64     HIGH,
65 };
66
67 flags32 mouse_mode {
68     SERVER,
69     CLIENT,
70 };
71
72 enum16 pubkey_type {
73     INVALID,
74     RSA,
75     RSA2,
76     DSA,
77     DSA1,
78     DSA2,
79     DSA3,
80     DSA4,
81     DH,
82     EC,
83 };
84
85 message Empty {
86 };
87
88 message Data {
89     uint8 data[] @end @ctype(uint8_t);
90 } @nocopy;
91
92 struct ChannelWait {
93     uint8 channel_type;
94     uint8 channel_id;
95     uint64 message_serial;
96 } @ctype(SpiceWaitForChannel);
97
98 channel BaseChannel {
99  server:
100     message {
101         migrate_flags flags;
102     } migrate;
103
104     Data migrate_data;
105
106     message {
107         uint32 generation;
108         uint32 window;
109     } set_ack;
110
111     message {
112         uint32 id;
113         uint64 timestamp;
114         uint8 data[] @ctype(uint8_t) @as_ptr(data_len);
115     } ping;
116
117     message {
118         uint8 wait_count;
119         ChannelWait wait_list[wait_count] @end;
120     } wait_for_channels;
121
122     message {
123         uint64 time_stamp;
124         link_err reason;
125     } @ctype(SpiceMsgDisconnect) disconnecting;
126
127     message {
128         uint64 time_stamp;
129         notify_severity severity;
130         notify_visibility visibilty;
131         uint32 what; /* error_code/warn_code/info_code */
132         uint32 message_len;
133         uint8 message[message_len] @end @nomarshal;
134         uint8 zero @end @ctype(uint8_t) @nomarshal;
135     } notify;
136
137  client:
138     message {
139         uint32 generation;
140     } ack_sync;
141
142     Empty ack;
143
144     message {
145         uint32 id;
146         uint64 timestamp;
147     } @ctype(SpiceMsgPing) pong;
148
149     Empty migrate_flush_mark;
150
151     Data migrate_data;
152
153     message {
154         uint64 time_stamp;
155         link_err reason;
156     } @ctype(SpiceMsgDisconnect) disconnecting;
157 };
158
159 struct ChannelId {
160     uint8 type;
161     uint8 id;
162 };
163
164 struct DstInfo {
165         uint16 port;
166         uint16 sport;
167         uint32 host_offset @zero;
168         uint32 host_size;
169         pubkey_type pub_key_type @minor(1);
170         uint32 pub_key_offset @minor(1) @zero;
171         uint32 pub_key_size @minor(1);
172         uint8 host_data[host_size] @as_ptr @zero_terminated;
173         uint8 pub_key_data[pub_key_size] @minor(1) @as_ptr @zero_terminated;
174 } @ctype(SpiceMigrationDstInfo);
175
176 channel MainChannel : BaseChannel {
177  server:
178      message {
179         DstInfo dst_info;
180     } @ctype(SpiceMsgMainMigrationBegin) migrate_begin = 101;
181
182     Empty migrate_cancel;
183
184     message {
185         uint32 session_id;
186         uint32 display_channels_hint;
187         uint32 supported_mouse_modes;
188         uint32 current_mouse_mode;
189         uint32 agent_connected;
190         uint32 agent_tokens;
191         uint32 multi_media_time;
192         uint32 ram_hint;
193     } init;
194
195     message {
196         uint32 num_of_channels;
197         ChannelId channels[num_of_channels] @end;
198     } @ctype(SpiceMsgChannels) channels_list;
199
200     message {
201         mouse_mode supported_modes;
202         mouse_mode current_mode @unique_flag;
203     } mouse_mode;
204
205     message {
206         uint32 time;
207     } @ctype(SpiceMsgMainMultiMediaTime) multi_media_time;
208
209     Empty agent_connected;
210
211     message {
212         link_err error_code;
213     } @ctype(SpiceMsgMainAgentDisconnect) agent_disconnected;
214
215     Data agent_data;
216
217     message {
218         uint32 num_tokens;
219     } @ctype(SpiceMsgMainAgentTokens) agent_token;
220
221     message {
222       uint16 port;
223       uint16 sport;
224       uint32 host_offset @zero;
225       uint32 host_size;
226       uint32 cert_subject_offset @zero;
227       uint32 cert_subject_size;
228       uint8 host_data[host_size] @as_ptr @zero_terminated;
229       uint8 cert_subject_data[cert_subject_size] @as_ptr @zero_terminated;
230     } @ctype(SpiceMsgMainMigrationSwitchHost) migrate_switch_host;
231
232  client:
233     message {
234         uint64 cache_size;
235     } @ctype(SpiceMsgcClientInfo) client_info = 101;
236
237     Empty migrate_connected;
238
239     Empty migrate_connect_error;
240
241     Empty attach_channels;
242
243     message {
244         mouse_mode mode;
245     } mouse_mode_request;
246
247     message {
248         uint32 num_tokens;
249     } agent_start;
250
251     Data agent_data;
252
253     message {
254         uint32 num_tokens;
255     } @ctype(SpiceMsgcMainAgentTokens) agent_token;
256 };
257
258 enum32 clip_type {
259     NONE,
260     RECTS
261 };
262
263 flags32 path_flags { /* TODO: C enum names changes */
264     BEGIN = 0,
265     END = 1,
266     CLOSE = 3,
267     BEZIER = 4,
268 } @prefix(SPICE_PATH_);
269
270 enum32 video_codec_type {
271     MJPEG = 1,
272 };
273
274 flags32 stream_flags {
275     TOP_DOWN = 0,
276 };
277
278 enum32 brush_type {
279     NONE,
280     SOLID,
281     PATTERN,
282 };
283
284 flags8 mask_flags {
285     INVERS,
286 };
287
288 enum8 image_type {
289     BITMAP,
290     QUIC,
291     RESERVED,
292     LZ_PLT = 100,
293     LZ_RGB,
294     GLZ_RGB,
295     FROM_CACHE,
296 };
297
298 flags8 image_flags {
299     CACHE_ME,
300 };
301
302 enum8 bitmap_fmt {
303     INVALID,
304     1BIT_LE,
305     1BIT_BE,
306     4BIT_LE,
307     4BIT_BE,
308     8BIT /* 8bit indexed mode */,
309     16BIT, /* 0555 mode */
310     24BIT /* 3 byte, brg */,
311     32BIT /* 4 byte, xrgb in little endian format */,
312     RGBA /* 4 byte, argb in little endian format */
313 };
314
315 flags8 bitmap_flags {
316     PAL_CACHE_ME,
317     PAL_FROM_CACHE,
318     TOP_DOWN,
319 };
320
321 enum8 image_scale_mode {
322     INTERPOLATE,
323     NEAREST,
324 };
325
326 flags16 ropd {
327     INVERS_SRC,
328     INVERS_BRUSH,
329     INVERS_DEST,
330     OP_PUT,
331     OP_OR,
332     OP_AND,
333     OP_XOR,
334     OP_BLACKNESS,
335     OP_WHITENESS,
336     OP_INVERS,
337     INVERS_RES,
338 };
339
340 flags8 line_flags {
341     STYLED = 3,
342     START_WITH_GAP = 2,
343 };
344
345 enum8 line_cap {
346     ROUND,
347     SQUARE,
348     BUTT,
349 };
350
351 enum8 line_join {
352     ROUND,
353     BEVEL,
354     MITER,
355 };
356
357 flags16 string_flags {
358     RASTER_A1,
359     RASTER_A4,
360     RASTER_A8,
361     RASTER_TOP_DOWN,
362 };
363
364 enum8 resource_type {
365       INVALID,
366       PIXMAP
367 } @prefix(SPICE_RES_TYPE_);
368
369 struct ClipRects {
370     uint32 num_rects;
371     Rect rects[num_rects] @end;
372 };
373
374 struct PathSegment {
375     path_flags flags;
376     uint32 count;
377     PointFix points[count] @end;
378 }  @ctype(SpicePathSeg);
379
380 struct Path {
381     uint32 segments_size @bytes_count(num_segments);
382     PathSegment segments[bytes(segments_size, num_segments)] @ptr_array;
383 };
384
385 struct Clip {
386     clip_type type;
387     switch (type) {
388     case RECTS:
389         ClipRects *rects @outvar(cliprects);
390     default:
391         uint64 data @zero;
392     } u @anon;
393 };
394
395 struct DisplayBase {
396     uint32 surface_id @virtual(0);
397     Rect box;
398     Clip clip;
399 } @ctype(SpiceMsgDisplayBase);
400
401 struct ResourceID {
402     uint8 type;
403     uint64 id;
404 };
405
406 struct WaitForChannel {
407     uint8 channel_type;
408     uint8 channel_id;
409     uint64 message_serial;
410 };
411
412 struct Palette {
413     uint64 unique;
414     uint16 num_ents;
415     uint32 ents[num_ents] @end;
416 };
417
418 struct BitmapData {
419     bitmap_fmt format;
420     bitmap_flags flags;
421     uint32 x;
422     uint32 y;
423     uint32 stride;
424     switch (flags) {
425     case PAL_FROM_CACHE:
426         uint64 palette_id;
427     default:
428         Palette *palette @outvar(bitmap);
429     } pal @anon;
430     uint8 *data[image_size(8, stride, y)] @chunk; /* pointer to array, not array of pointers as in C */
431 } @ctype(SpiceBitmap);
432
433 struct BinaryData {
434     uint32 data_size;
435     uint8 data[data_size] @nomarshal @chunk;
436 } @ctype(SpiceQUICData);
437
438 struct LZPLTData {
439     bitmap_flags flags;
440     uint32 data_size;
441     switch (flags) {
442     case PAL_FROM_CACHE:
443         uint64 palette_id;
444     default:
445         Palette *palette @nonnull @outvar(lzplt);
446     } pal @anon;
447     uint8 data[data_size] @nomarshal @chunk;
448 };
449
450 struct Image {
451     struct ImageDescriptor {
452         uint64 id;
453         image_type type;
454         image_flags flags;
455         uint32 width;
456         uint32 height;
457     } descriptor;
458
459     switch (descriptor.type) {
460     case BITMAP:
461         BitmapData bitmap;
462     case QUIC:
463         BinaryData quic;
464     case LZ_RGB:
465     case GLZ_RGB:
466         BinaryData lz_rgb;
467     case LZ_PLT:
468         LZPLTData lz_plt;
469     } u;
470 };
471
472 struct Pattern {
473     Image *pat @nonnull;
474     Point pos;
475 };
476
477 struct Brush {
478     brush_type type;
479     switch (type) {
480     case SOLID:
481         uint32 color;
482     case PATTERN:
483         Pattern pattern;
484     } u @fixedsize;
485 };
486
487 struct QMask {
488     mask_flags flags;
489     Point pos;
490     Image *bitmap;
491 };
492
493 struct LineAttr {
494     line_flags flags;
495     line_join join_style @zero;
496     line_cap end_style @zero;
497     uint8 style_nseg;
498     fixed28_4 width @zero;
499     fixed28_4 miter_limit @zero;
500     fixed28_4 *style[style_nseg];
501 };
502
503 struct RasterGlyphA1 {
504     Point render_pos;
505     Point glyph_origin;
506     uint16 width;
507     uint16 height;
508     uint8 data[image_size(1, width, height)] @end;
509 } @ctype(SpiceRasterGlyph);
510
511 struct RasterGlyphA4 {
512     Point render_pos;
513     Point glyph_origin;
514     uint16 width;
515     uint16 height;
516     uint8 data[image_size(4, width, height)] @end;
517 } @ctype(SpiceRasterGlyph);
518
519 struct RasterGlyphA8 {
520     Point render_pos;
521     Point glyph_origin;
522     uint16 width;
523     uint16 height;
524     uint8 data[image_size(8, width, height)] @end;
525 } @ctype(SpiceRasterGlyph);
526
527 struct String {
528     uint16 length;
529     string_flags flags; /* Special: Only one of a1/a4/a8 set */
530     switch (flags) {
531     case RASTER_A1:
532         RasterGlyphA1 glyphs[length] @ctype(SpiceRasterGlyph) @ptr_array;
533     case RASTER_A4:
534         RasterGlyphA4 glyphs[length] @ctype(SpiceRasterGlyph) @ptr_array;
535     case RASTER_A8:
536         RasterGlyphA8 glyphs[length] @ctype(SpiceRasterGlyph) @ptr_array;
537     } u @anon;
538 };
539
540 struct StreamDataHeader {
541         uint32 id;
542         uint32 multi_media_time;
543 };
544
545 channel DisplayChannel : BaseChannel {
546  server:
547     message {
548         uint32 x_res;
549         uint32 y_res;
550         uint32 bits;
551     } mode = 101;
552
553     Empty mark;
554     Empty reset;
555
556     message {
557         DisplayBase base;
558         Point src_pos;
559     } copy_bits;
560
561     message {
562         uint16 count;
563         ResourceID resources[count] @end;
564     } @ctype(SpiceResourceList) inval_list;
565
566     message {
567         uint8 wait_count;
568         WaitForChannel wait_list[wait_count] @end;
569     } @ctype(SpiceMsgWaitForChannels) inval_all_pixmaps;
570
571     message {
572         uint64 id;
573     } @ctype(SpiceMsgDisplayInvalOne) inval_palette;
574
575     Empty inval_all_palettes;
576
577     message {
578         uint32 surface_id @virtual(0);
579         uint32 id;
580         stream_flags flags;
581         video_codec_type codec_type;
582         uint64 stamp;
583         uint32 stream_width;
584         uint32 stream_height;
585         uint32 src_width;
586         uint32 src_height;
587         Rect dest;
588         Clip clip;
589     } stream_create = 122;
590
591     message {
592         StreamDataHeader base;
593         uint32 data_size;
594         uint32 pad_size @zero;
595         uint8 data[data_size] @end  @nomarshal;
596         /* Ignore: uint8 padding[pad_size] */
597     } stream_data;
598
599     message {
600         uint32 id;
601         Clip clip;
602     } stream_clip;
603
604     message {
605         uint32 id;
606     } stream_destroy;
607
608     Empty stream_destroy_all;
609
610     message {
611         DisplayBase base;
612         struct Fill {
613             Brush brush @outvar(brush);
614             uint16 rop_descriptor;
615             QMask mask @outvar(mask);
616         } data;
617     } draw_fill = 302;
618
619     message {
620         DisplayBase base;
621         struct Opaque {
622             Image *src_bitmap;
623             Rect src_area;
624             Brush brush;
625             ropd rop_descriptor;
626             image_scale_mode scale_mode;
627             QMask mask @outvar(mask);
628         } data;
629     } draw_opaque;
630
631     message {
632         DisplayBase base;
633         struct Copy {
634             Image *src_bitmap;
635             Rect src_area;
636             ropd rop_descriptor;
637             image_scale_mode scale_mode;
638             QMask mask @outvar(mask);
639         } data;
640     } draw_copy;
641
642     message {
643         DisplayBase base;
644         struct Blend {
645             Image *src_bitmap;
646             Rect src_area;
647             ropd rop_descriptor;
648             image_scale_mode scale_mode;
649             QMask mask @outvar(mask);
650         } @ctype(SpiceCopy) data;
651     } draw_blend;
652
653     message {
654         DisplayBase base;
655         struct Blackness {
656             QMask mask @outvar(mask);
657         } data;
658     } draw_blackness;
659
660     message {
661         DisplayBase base;
662         struct Whiteness {
663             QMask mask @outvar(mask);
664         } data;
665     } draw_whiteness;
666
667     message {
668         DisplayBase base;
669         struct Invers {
670             QMask mask @outvar(mask);
671         } data;
672     } draw_invers;
673
674     message {
675         DisplayBase base;
676         struct Rop3 {
677             Image *src_bitmap;
678             Rect src_area;
679             Brush brush;
680             uint8 rop3;
681             image_scale_mode scale_mode;
682             QMask mask @outvar(mask);
683         } data;
684     } draw_rop3;
685
686     message {
687         DisplayBase base;
688         struct Stroke {
689             Path *path;
690             LineAttr attr;
691             Brush brush;
692             uint16 fore_mode;
693             uint16 back_mode;
694         } data;
695     } draw_stroke;
696
697     message {
698         DisplayBase base;
699         struct Text {
700             String *str;
701             Rect back_area;
702             Brush fore_brush @outvar(fore_brush);
703             Brush back_brush @outvar(back_brush);
704             uint16 fore_mode;
705             uint16 back_mode;
706         } data;
707     } draw_text;
708
709     message {
710         DisplayBase base;
711         struct Transparent {
712             Image *src_bitmap;
713             Rect src_area;
714             uint32 src_color;
715             uint32 true_color;
716         } data;
717     } draw_transparent;
718
719     message {
720         DisplayBase base;
721         struct AlphaBlend {
722             int8 alpha_flags @virtual(0);
723             uint8 alpha;
724             Image *src_bitmap;
725             Rect src_area;
726         } data;
727     } draw_alpha_blend;
728
729  client:
730     message {
731         uint8 pixmap_cache_id;
732         int64 pixmap_cache_size; //in pixels
733         uint8 glz_dictionary_id;
734         int32 glz_dictionary_window_size;  // in pixels
735     } init = 101;
736 };
737
738 flags32 keyboard_modifier_flags {
739     SCROLL_LOCK,
740     NUM_LOCK,
741     CAPS_LOCK
742 };
743
744 enum32 mouse_button {
745     INVALID,
746     LEFT,
747     MIDDLE,
748     RIGHT,
749     UP,
750     DOWN,
751 };
752
753 flags32 mouse_button_mask {
754     LEFT,
755     MIDDLE,
756     RIGHT
757 };
758
759 channel InputsChannel : BaseChannel {
760  client:
761     message {
762         uint32 code;
763     } @ctype(SpiceMsgcKeyDown) key_down = 101;
764
765     message {
766         uint32 code;
767     } @ctype(SpiceMsgcKeyUp) key_up;
768
769     message {
770         keyboard_modifier_flags modifiers;
771     } @ctype(SpiceMsgcKeyModifiers) key_modifiers;
772
773     message {
774         int32 dx;
775         int32 dy;
776         mouse_button_mask buttons_state;
777     } @ctype(SpiceMsgcMouseMotion) mouse_motion = 111;
778
779     message {
780         uint32 x;
781         uint32 y;
782         mouse_button_mask buttons_state;
783         uint8 display_id;
784     } @ctype(SpiceMsgcMousePosition) mouse_position;
785
786     message {
787         mouse_button button;
788         mouse_button_mask buttons_state;
789     } @ctype(SpiceMsgcMousePress) mouse_press;
790
791     message {
792         mouse_button button;
793         mouse_button_mask buttons_state;
794     } @ctype(SpiceMsgcMouseRelease) mouse_release;
795
796  server:
797     message {
798         keyboard_modifier_flags keyboard_modifiers;
799     } init = 101;
800
801     message {
802         keyboard_modifier_flags modifiers;
803     } key_modifiers;
804
805     Empty mouse_motion_ack = 111;
806 };
807
808 enum16 cursor_type {
809     ALPHA,
810     MONO,
811     COLOR4,
812     COLOR8,
813     COLOR16,
814     COLOR24,
815     COLOR32,
816 };
817
818 flags32 cursor_flags {
819     NONE, /* Means no cursor */
820     CACHE_ME,
821     FROM_CACHE,
822 };
823
824 struct CursorHeader {
825     uint64 unique;
826     cursor_type type;
827     uint16 width;
828     uint16 height;
829     uint16 hot_spot_x;
830     uint16 hot_spot_y;
831 };
832
833 struct Cursor {
834     cursor_flags flags;
835     CursorHeader header;
836     uint8 data[] @as_ptr(data_size);
837 };
838
839 channel CursorChannel : BaseChannel {
840  server:
841     message {
842         Point16 position;
843         uint16 trail_length;
844         uint16 trail_frequency;
845         uint8 visible;
846         Cursor cursor;
847     } init = 101;
848
849     Empty reset;
850
851     message {
852         Point16 position;
853         uint8 visible;
854         Cursor cursor;
855     } set;
856
857     message {
858         Point16 position;
859     } move;
860
861     Empty hide;
862
863     message {
864         uint16 length;
865         uint16 frequency;
866     } trail;
867
868     message {
869         uint64 id;
870     } @ctype(SpiceMsgDisplayInvalOne) inval_one;
871
872     Empty inval_all;
873 };
874
875 enum32 audio_data_mode {
876     INVALID,
877     RAW,
878     CELT_0_5_1,
879 };
880
881 enum32 audio_fmt {
882     INVALID,
883     S16,
884 };
885
886 channel PlaybackChannel : BaseChannel {
887  server:
888     message {
889         uint32 time;
890         uint8 data[] @as_ptr(data_size);
891     } @ctype(SpiceMsgPlaybackPacket) data = 101;
892
893     message {
894         uint32 time;
895         audio_data_mode mode;
896         uint8 data[] @as_ptr(data_size);
897     } mode;
898
899     message {
900        uint32 channels;
901        audio_fmt format;
902        uint32 frequency;
903        uint32 time;
904     } start;
905
906     Empty stop;
907 };
908
909 channel RecordChannel : BaseChannel {
910  server:
911     message {
912         uint32 channels;
913         audio_fmt format;
914         uint32 frequency;
915     } start = 101;
916
917     Empty stop;
918  client:
919     message {
920         uint32 time;
921         uint8 data[] @nomarshal @as_ptr(data_size);
922     } @ctype(SpiceMsgcRecordPacket) data = 101;
923
924     message {
925         uint32 time;
926         audio_data_mode mode;
927         uint8 data[] @as_ptr(data_size);
928     } mode;
929
930     message {
931         uint32 time;
932     } start_mark;
933 };
934
935 protocol Spice {
936     MainChannel main = 1;
937     DisplayChannel display;
938     InputsChannel inputs;
939     CursorChannel cursor;
940     PlaybackChannel playback;
941     RecordChannel record;
942 };