summaryrefslogtreecommitdiffstats
path: root/common/red.h
blob: 44cef46074c0f8a60761fa940b1334da418efdc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
/*
   Copyright (C) 2009 Red Hat, Inc.

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are
   met:

       * Redistributions of source code must retain the above copyright
         notice, this list of conditions and the following disclaimer.
       * Redistributions in binary form must reproduce the above copyright
         notice, this list of conditions and the following disclaimer in
         the documentation and/or other materials provided with the
         distribution.
       * Neither the name of the copyright holder nor the names of its
         contributors may be used to endorse or promote products derived
         from this software without specific prior written permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
   IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
   PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _H_RED
#define _H_RED

#include <stdint.h>
#ifdef _WIN32
#include <basetsd.h>
#endif
#include "draw.h"
#ifdef __GNUC__
#define ATTR_PACKED __attribute__ ((__packed__))
#else
#pragma pack(push)
#pragma pack(1)
#define ATTR_PACKED
#endif

#define RED_MAGIC (*(uint32_t*)"REDQ")
#define RED_VERSION_MAJOR 1
#define RED_VERSION_MINOR 2

// Encryption & Ticketing Parameters
#define RED_MAX_PASSWORD_LENGTH 60
#define RED_TICKET_KEY_PAIR_LENGTH 1024
#define RED_TICKET_PUBKEY_BYTES (RED_TICKET_KEY_PAIR_LENGTH / 8 + 34)

enum {
    RED_CHANNEL_MAIN = 1,
    RED_CHANNEL_DISPLAY,
    RED_CHANNEL_INPUTS,
    RED_CHANNEL_CURSOR,
    RED_CHANNEL_PLAYBACK,
    RED_CHANNEL_RECORD,

    RED_CHANNEL_END
};

enum {
    RED_ERR_OK,
    RED_ERR_ERROR,
    RED_ERR_INVALID_MAGIC,
    RED_ERR_INVALID_DATA,
    RED_ERR_VERSION_MISMATCH,
    RED_ERR_NEED_SECURED,
    RED_ERR_NEED_UNSECURED,
    RED_ERR_PERMISSION_DENIED,
    RED_ERR_BAD_CONNECTION_ID,
    RED_ERR_CHANNEL_NOT_AVAILABLE,
};

enum {
    RED_WARN_GENERAL,
};

enum {
    RED_INFO_GENERAL,
};

typedef struct ATTR_PACKED RedLinkHeader {
    uint32_t magic;
    uint32_t major_version;
    uint32_t minor_version;
    uint32_t size;
} RedLinkHeader;

typedef struct ATTR_PACKED RedLinkMess {
    uint32_t connection_id;
    uint8_t channel_type;
    uint8_t channel_id;
    uint32_t num_common_caps;
    uint32_t num_channel_caps;
    uint32_t caps_offset;
} RedLinkMess;

typedef struct ATTR_PACKED RedLinkReply {
    uint32_t error;
    uint8_t pub_key[RED_TICKET_PUBKEY_BYTES];
    uint32_t num_common_caps;
    uint32_t num_channel_caps;
    uint32_t caps_offset;
} RedLinkReply;

typedef struct ATTR_PACKED RedLinkEncryptedTicket {
    uint8_t encrypted_data[RED_TICKET_KEY_PAIR_LENGTH / 8];
} RedLinkEncryptedTicket;

typedef struct ATTR_PACKED RedDataHeader {
    uint64_t serial;
    uint16_t type;
    uint32_t size;
    uint32_t sub_list; //offset to RedSubMessageList[]
} RedDataHeader;

typedef struct ATTR_PACKED RedSubMessage {
    uint16_t type;
    uint32_t size;
} RedSubMessage;

typedef struct ATTR_PACKED RedSubMessageList {
    uint16_t size;
    uint32_t sub_messages[0]; //offsets to RedSubMessage
} RedSubMessageList;

enum {
    RED_MIGRATE = 1,
    RED_MIGRATE_DATA,
    RED_SET_ACK,
    RED_PING,
    RED_WAIT_FOR_CHANNELS,
    RED_DISCONNECTING,
    RED_NOTIFY,

    RED_FIRST_AVAIL_MESSAGE = 101
};

enum {
    REDC_ACK_SYNC = 1,
    REDC_ACK,
    REDC_PONG,
    REDC_MIGRATE_FLUSH_MARK,
    REDC_MIGRATE_DATA,
    REDC_DISCONNECTING,

    REDC_FIRST_AVAIL_MESSAGE = 101,
};

enum {
    RED_MIGRATE_BEGIN = RED_FIRST_AVAIL_MESSAGE,
    RED_MIGRATE_CANCEL,
    RED_INIT,
    RED_CHANNELS_LIST,
    RED_MOUSE_MODE,
    RED_MULTI_MEDIA_TIME,

    RED_AGENT_CONNECTED,
    RED_AGENT_DISCONNECTED,
    RED_AGENT_DATA,
    RED_AGENT_TOKEN,

    RED_MIGRATE_SWITCH_HOST,

    RED_MESSAGES_END,
};

enum {
    REDC_CLIENT_INFO = REDC_FIRST_AVAIL_MESSAGE,
    REDC_MIGRATE_CONNECTED,
    REDC_MIGRATE_CONNECT_ERROR,
    REDC_ATTACH_CHANNELS,
    REDC_MOUSE_MODE_REQUEST,

    REDC_AGENT_START,
    REDC_AGENT_DATA,
    REDC_AGENT_TOKEN,
};

#define RED_MOTION_ACK_BUNCH 4

enum {
    RED_INPUTS_INIT = RED_FIRST_AVAIL_MESSAGE,
    RED_INPUTS_KEY_MODIFAIERS,

    RED_INPUTS_MOUSE_MOTION_ACK = RED_FIRST_AVAIL_MESSAGE + 10,

    RED_INPUTS_MESSAGES_END,
};

#define RED_SCROLL_LOCK_MODIFIER (1 << 0)
#define RED_NUM_LOCK_MODIFIER (1 << 1)
#define RED_CAPS_LOCK_MODIFIER (1 << 2)

typedef struct ATTR_PACKED RedInputsInit {
    uint32_t keyboard_modifiers;
} RedInputsInit;

typedef struct ATTR_PACKED RedKeyModifiers {
    uint32_t modifiers;
} RedKeyModifiers;

typedef struct ATTR_PACKED RedMultiMediaTime {
    uint32_t time;
} RedMultiMediaTime;

enum {
    RED_PUBKEY_TYPE_INVALID,
    RED_PUBKEY_TYPE_RSA,
    RED_PUBKEY_TYPE_RSA2,
    RED_PUBKEY_TYPE_DSA,
    RED_PUBKEY_TYPE_DSA1,
    RED_PUBKEY_TYPE_DSA2,
    RED_PUBKEY_TYPE_DSA3,
    RED_PUBKEY_TYPE_DSA4,
    RED_PUBKEY_TYPE_DH,
    RED_PUBKEY_TYPE_EC,
};

typedef struct ATTR_PACKED RedMigrationBegin {
    uint16_t port;
    uint16_t sport;
    uint32_t host_offset;
    uint32_t host_size;
    uint16_t pub_key_type;
    uint32_t pub_key_offset;
    uint32_t pub_key_size;
} RedMigrationBegin;

typedef struct ATTR_PACKED RedMigrationSwitchHost {
    uint16_t port;
    uint16_t sport;
    uint32_t host_offset;
    uint32_t host_size;
    uint32_t cert_subject_offset;
    uint32_t cert_subject_size;
} RedMigrationSwitchHost;

enum {
    RED_MIGRATE_NEED_FLUSH = (1 << 0),
    RED_MIGRATE_NEED_DATA_TRANSFER = (1 << 1),
};

typedef struct ATTR_PACKED RedMigrate {
    uint32_t flags;
} RedMigrate;

enum {
    RED_RES_TYPE_INVALID,
    RED_RES_TYPE_PIXMAP,
};

typedef struct ATTR_PACKED RedResorceID {
    uint8_t type;
    uint64_t id;
} RedResorceID;

typedef struct ATTR_PACKED RedResorceList {
    uint16_t count;
    RedResorceID resorces[0];
} RedResorceList;

typedef struct ATTR_PACKED RedSetAck {
    uint32_t generation;
    uint32_t window;
} RedSetAck;

typedef struct ATTR_PACKED RedWaitForChannel {
    uint8_t channel_type;
    uint8_t channel_id;
    uint64_t message_serial;
} RedWaitForChannel;

typedef struct ATTR_PACKED RedWaitForChannels {
    uint8_t wait_count;
    RedWaitForChannel wait_list[0];
} RedWaitForChannels;

typedef struct ATTR_PACKED RedChannelInit {
    uint8_t type;
    uint8_t id;
} RedChannelInit;

typedef struct ATTR_PACKED RedInit {
    uint32_t session_id;
    uint32_t display_channels_hint;
    uint32_t supported_mouse_modes;
    uint32_t current_mouse_mode;
    uint32_t agent_connected;
    uint32_t agent_tokens;
    uint32_t multi_media_time;
    uint32_t ram_hint;
} RedInit;

typedef struct ATTR_PACKED RedDisconnect {
    uint64_t time_stamp;
    uint32_t reason; // RED_ERR_?
} RedDisconnect;

enum {
    RED_NOTIFY_SEVERITY_INFO,
    RED_NOTIFY_SEVERITY_WARN,
    RED_NOTIFY_SEVERITY_ERROR,
};

enum {
    RED_NOTIFY_VISIBILITY_LOW,
    RED_NOTIFY_VISIBILITY_MEDIUM,
    RED_NOTIFY_VISIBILITY_HIGH,
};

typedef struct ATTR_PACKED RedNotify {
    uint64_t time_stamp;
    uint32_t severty;
    uint32_t visibilty;
    uint32_t what;
    uint32_t message_len;
    uint8_t message[0];
} RedNotify;

typedef struct ATTR_PACKED RedChannels {
    uint32_t num_of_channels;
    RedChannelInit channels[0];
} RedChannels;

typedef struct ATTR_PACKED RedMouseMode {
    uint32_t supported_modes;
    uint32_t current_mode;
} RedMouseMode;

typedef struct ATTR_PACKED RedPing {
    uint32_t id;
    uint64_t timestamp;
} RedPing;

typedef struct ATTR_PACKED RedAgentDisconnect {
    uint32_t error_code; // RED_ERR_?
} RedAgentDisconnect;

#define RED_AGENT_MAX_DATA_SIZE 2048

typedef struct ATTR_PACKED RedAgentTokens {
    uint32_t num_tokens;
} RedAgentTokens, RedcAgentTokens, RedcAgentStart;

typedef struct ATTR_PACKED RedcClientInfo {
    uint64_t cache_size;
} RedcClientInfo;

typedef struct ATTR_PACKED RedcMouseModeRequest {
    uint32_t mode;
} RedcMouseModeRequest;

enum {
    RED_DISPLAY_MODE = RED_FIRST_AVAIL_MESSAGE,
    RED_DISPLAY_MARK,
    RED_DISPLAY_RESET,
    RED_DISPLAY_COPY_BITS,

    RED_DISPLAY_INVAL_LIST,
    RED_DISPLAY_INVAL_ALL_PIXMAPS,
    RED_DISPLAY_INVAL_PALETTE,
    RED_DISPLAY_INVAL_ALL_PALETTES,

    RED_DISPLAY_STREAM_CREATE = RED_FIRST_AVAIL_MESSAGE + 21,
    RED_DISPLAY_STREAM_DATA,
    RED_DISPLAY_STREAM_CLIP,
    RED_DISPLAY_STREAM_DESTROY,
    RED_DISPLAY_STREAM_DESTROY_ALL,

    RED_DISPLAY_DRAW_FILL = RED_FIRST_AVAIL_MESSAGE + 201,
    RED_DISPLAY_DRAW_OPAQUE,
    RED_DISPLAY_DRAW_COPY,
    RED_DISPLAY_DRAW_BLEND,
    RED_DISPLAY_DRAW_BLACKNESS,
    RED_DISPLAY_DRAW_WHITENESS,
    RED_DISPLAY_DRAW_INVERS,
    RED_DISPLAY_DRAW_ROP3,
    RED_DISPLAY_DRAW_STROKE,
    RED_DISPLAY_DRAW_TEXT,
    RED_DISPLAY_DRAW_TRANSPARENT,
    RED_DISPLAY_DRAW_ALPHA_BLEND,

    RED_DISPLAY_MESSAGES_END,
};

enum {
    RED_CURSOR_NONE = (1 << 0),
    RED_CURSOR_CACHE_ME = (1 << 1),
    RED_CURSOR_FROM_CACHE = (1 << 2),
};

typedef struct ATTR_PACKED RedCursor {
    uint32_t flags;
    CursorHeader header;
    uint8_t data[0];
} RedCursor;

typedef struct ATTR_PACKED RedMode {
    uint32_t x_res;
    uint32_t y_res;
    uint32_t bits;
} RedMode;

typedef struct ATTR_PACKED RedDrawBase {
    Rect box;
    Clip clip;
} RedDrawBase;

typedef struct ATTR_PACKED RedFill {
    RedDrawBase base;
    Fill data;
} RedFill;

typedef struct ATTR_PACKED RedOpaque {
    RedDrawBase base;
    Opaque data;
} RedOpaque;

typedef struct ATTR_PACKED RedCopy {
    RedDrawBase base;
    Copy data;
} RedCopy;

typedef struct ATTR_PACKED RedTransparent {
    RedDrawBase base;
    Transparent data;
} RedTransparent;

typedef struct ATTR_PACKED RedAlphaBlend {
    RedDrawBase base;
    AlphaBlnd data;
} RedAlphaBlend;

typedef struct ATTR_PACKED RedCopyBits {
    RedDrawBase base;
    Point src_pos;
} RedCopyBits;

typedef RedCopy RedBlend;

typedef struct ATTR_PACKED RedRop3 {
    RedDrawBase base;
    Rop3 data;
} RedRop3;

typedef struct ATTR_PACKED RedBlackness {
    RedDrawBase base;
    Blackness data;
} RedBlackness;

typedef struct ATTR_PACKED RedWhiteness {
    RedDrawBase base;
    Whiteness data;
} RedWhiteness;

typedef struct ATTR_PACKED RedInvers {
    RedDrawBase base;
    Invers data;
} RedInvers;

typedef struct ATTR_PACKED RedStroke {
    RedDrawBase base;
    Stroke data;
} RedStroke;

typedef struct ATTR_PACKED RedText {
    RedDrawBase base;
    Text data;
} RedText;

typedef struct ATTR_PACKED RedInvalOne {
    uint64_t id;
} RedInvalOne;

enum {
    RED_VIDEO_CODEC_TYPE_MJPEG = 1,
};

enum {
    STREAM_TOP_DOWN = (1 << 0),
};

typedef struct ATTR_PACKED RedStreamCreate {
    uint32_t id;
    uint32_t flags;
    uint32_t codec_type;
    uint64_t stamp;
    uint32_t stream_width;
    uint32_t stream_height;
    uint32_t src_width;
    uint32_t src_height;
    Rect dest;
    Clip clip;
} RedStreamCreate;

typedef struct ATTR_PACKED RedStreamData {
    uint32_t id;
    uint32_t multi_media_time;
    uint32_t data_size;
    uint32_t ped_size;
    uint8_t data[0];
} RedStreamData;

typedef struct ATTR_PACKED RedStreamClip {
    uint32_t id;
    Clip clip;
} RedStreamClip;

typedef struct ATTR_PACKED RedStreamDestroy {
    uint32_t id;
} RedStreamDestroy;

enum {
    RED_CURSOR_INIT = RED_FIRST_AVAIL_MESSAGE,
    RED_CURSOR_RESET,
    RED_CURSOR_SET,
    RED_CURSOR_MOVE,
    RED_CURSOR_HIDE,
    RED_CURSOR_TRAIL,
    RED_CURSOR_INVAL_ONE,
    RED_CURSOR_INVAL_ALL,

    RED_CURSOR_MESSAGES_END,
};

typedef struct ATTR_PACKED RedCursorInit {
    Point16 position;
    uint16_t trail_length;
    uint16_t trail_frequency;
    uint8_t visible;
    RedCursor cursor;
} RedCursorInit;

typedef struct ATTR_PACKED RedCursorSet {
    Point16 postition;
    uint8_t visible;
    RedCursor cursor;
} RedCursorSet;

typedef struct ATTR_PACKED RedCursorMove {
    Point16 postition;
} RedCursorMove;

typedef struct ATTR_PACKED RedCursorTrail {
    uint16_t length;
    uint16_t frequency;
} RedCursorTrail;

enum {
    REDC_DISPLAY_INIT = REDC_FIRST_AVAIL_MESSAGE,

    REDC_DISPLAY_MESSGES_END,
};

typedef struct ATTR_PACKED RedcDisplayInit {
    uint8_t pixmap_cache_id;
    int64_t pixmap_cache_size; //in pixels
    uint8_t glz_dictionary_id;
    int glz_dictionary_window_size;       // in pixels
} RedcDisplayInit;

enum {
    REDC_INPUTS_KEY_DOWN = REDC_FIRST_AVAIL_MESSAGE,
    REDC_INPUTS_KEY_UP,
    REDC_INPUTS_KEY_MODIFAIERS,

    REDC_INPUTS_MOUSE_MOTION = REDC_FIRST_AVAIL_MESSAGE + 10,
    REDC_INPUTS_MOUSE_POSITION,
    REDC_INPUTS_MOUSE_PRESS,
    REDC_INPUTS_MOUSE_RELEASE,

    REDC_INPUTS_MESSGES_END,
};

typedef struct ATTR_PACKED RedcKeyDown {
    uint32_t code;
} RedcKeyDown;

typedef struct ATTR_PACKED RedcKeyUp {
    uint32_t code;
} RedcKeyUp;

enum {
    RED_MOUSE_MODE_SERVER = (1 << 0),
    RED_MOUSE_MODE_CLIENT = (1 << 1),
};

typedef struct ATTR_PACKED RedcKeyModifiers {
    uint32_t modifiers;
} RedcKeyModifiers;

enum RedButton {
    REDC_MOUSE_INVALID_BUTTON,
    REDC_MOUSE_LBUTTON,
    REDC_MOUSE_MBUTTON,
    REDC_MOUSE_RBUTTON,
    REDC_MOUSE_UBUTTON,
    REDC_MOUSE_DBUTTON,
};

#define REDC_LBUTTON_MASK (1 << (REDC_MOUSE_LBUTTON - 1))
#define REDC_MBUTTON_MASK (1 << (REDC_MOUSE_MBUTTON - 1))
#define REDC_RBUTTON_MASK (1 << (REDC_MOUSE_RBUTTON - 1))

typedef struct ATTR_PACKED RedcMouseMotion {
    int32_t dx;
    int32_t dy;
    uint32_t buttons_state;
} RedcMouseMotion;

typedef struct ATTR_PACKED RedcMousePosition {
    uint32_t x;
    uint32_t y;
    uint32_t buttons_state;
    uint8_t display_id;
} RedcMousePosition;

typedef struct ATTR_PACKED RedcMousePress {
    int32_t button;
    int32_t buttons_state;
} RedcMousePress;

typedef struct ATTR_PACKED RedcMouseRelease {
    int32_t button;
    int32_t buttons_state;
} RedcMouseRelease;

enum {
    RED_AUDIO_FMT_INVALD,
    RED_AUDIO_FMT_S16,
};

enum {
    RED_AUDIO_DATA_MODE_INVALD,
    RED_AUDIO_DATA_MODE_RAW,
    RED_AUDIO_DATA_MODE_CELT_0_5_1,
};

enum {
    RED_PLAYBACK_DATA = RED_FIRST_AVAIL_MESSAGE,
    RED_PLAYBACK_MODE,
    RED_PLAYBACK_START,
    RED_PLAYBACK_STOP,

    RED_PLAYBACK_MESSAGES_END,
};

enum {
    RED_PLAYBACK_CAP_CELT_0_5_1,
};

enum {
    RED_RECORD_START = RED_FIRST_AVAIL_MESSAGE,
    RED_RECORD_STOP,

    RED_RECORD_MESSAGES_END,
};

enum {
    REDC_RECORD_DATA = RED_FIRST_AVAIL_MESSAGE,
    REDC_RECORD_MODE,
    REDC_RECORD_START_MARK,

    REDC_RECORD_MESSAGES_END,
};

enum {
    RED_RECORD_CAP_CELT_0_5_1,
};

typedef struct ATTR_PACKED RedPlaybackMode {
    uint32_t time;
    uint32_t mode; //RED_AUDIO_DATA_MODE_?
    uint8_t data[0];
} RedPlaybackMode, RedcRecordMode;

typedef struct ATTR_PACKED RedPlaybackStart {
    uint32_t channels;
    uint32_t format; //RED_AUDIO_FMT_?
    uint32_t frequency;
    uint32_t time;
} RedPlaybackStart;

typedef struct ATTR_PACKED RedPlaybackPacket {
    uint32_t time;
    uint8_t data[0];
} RedPlaybackPacket, RedcRecordPacket;

typedef struct ATTR_PACKED RedRecordStart {
    uint32_t channels;
    uint32_t format; //RED_AUDIO_FMT_?
    uint32_t frequency;
} RedRecordStart;

typedef struct ATTR_PACKED RedcRecordStartMark {
    uint32_t time;
} RedcRecordStartMark;

#undef ATTR_PACKED

#ifndef __GNUC__
#pragma pack(pop)
#endif

#endif