summaryrefslogtreecommitdiffstats
path: root/include/freerdp/channels/rdpgfx.h
blob: b608e0fef26d383889293c5cf46cc89b7c153d3a (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
/**
 * FreeRDP: A Remote Desktop Protocol Implementation
 * Graphics Pipeline Extension
 *
 * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FREERDP_CHANNEL_RDPGFX_H
#define FREERDP_CHANNEL_RDPGFX_H

#include <freerdp/api.h>
#include <freerdp/dvc.h>
#include <freerdp/types.h>

#define RDPGFX_CHANNEL_NAME "rdpgfx"
#define RDPGFX_DVC_CHANNEL_NAME "Microsoft::Windows::RDS::Graphics"

#ifdef __cplusplus
extern "C"
{
#endif
	/**
	 * Common Data Types
	 */

	typedef struct
	{
		UINT16 x;
		UINT16 y;
	} RDPGFX_POINT16;

	typedef struct
	{
		BYTE B;
		BYTE G;
		BYTE R;
		BYTE XA;
	} RDPGFX_COLOR32;

#define GFX_PIXEL_FORMAT_XRGB_8888 0x20
#define GFX_PIXEL_FORMAT_ARGB_8888 0x21

typedef BYTE RDPGFX_PIXELFORMAT;

#define RDPGFX_CMDID_UNUSED_0000 0x0000
#define RDPGFX_CMDID_WIRETOSURFACE_1 0x0001
#define RDPGFX_CMDID_WIRETOSURFACE_2 0x0002
#define RDPGFX_CMDID_DELETEENCODINGCONTEXT 0x0003
#define RDPGFX_CMDID_SOLIDFILL 0x0004
#define RDPGFX_CMDID_SURFACETOSURFACE 0x0005
#define RDPGFX_CMDID_SURFACETOCACHE 0x0006
#define RDPGFX_CMDID_CACHETOSURFACE 0x0007
#define RDPGFX_CMDID_EVICTCACHEENTRY 0x0008
#define RDPGFX_CMDID_CREATESURFACE 0x0009
#define RDPGFX_CMDID_DELETESURFACE 0x000A
#define RDPGFX_CMDID_STARTFRAME 0x000B
#define RDPGFX_CMDID_ENDFRAME 0x000C
#define RDPGFX_CMDID_FRAMEACKNOWLEDGE 0x000D
#define RDPGFX_CMDID_RESETGRAPHICS 0x000E
#define RDPGFX_CMDID_MAPSURFACETOOUTPUT 0x000F
#define RDPGFX_CMDID_CACHEIMPORTOFFER 0x0010
#define RDPGFX_CMDID_CACHEIMPORTREPLY 0x0011
#define RDPGFX_CMDID_CAPSADVERTISE 0x0012
#define RDPGFX_CMDID_CAPSCONFIRM 0x0013
#define RDPGFX_CMDID_UNUSED_0014 0x0014
#define RDPGFX_CMDID_MAPSURFACETOWINDOW 0x0015
#define RDPGFX_CMDID_QOEFRAMEACKNOWLEDGE 0x0016
#define RDPGFX_CMDID_MAPSURFACETOSCALEDOUTPUT 0x0017
#define RDPGFX_CMDID_MAPSURFACETOSCALEDWINDOW 0x0018

#define RDPGFX_HEADER_SIZE 8

typedef struct
{
	UINT16 cmdId;
	UINT16 flags;
	UINT32 pduLength;
} RDPGFX_HEADER;

/**
 * Capability Sets [MS-RDPEGFX] 2.2.3
 */

#define RDPGFX_CAPVERSION_8 0x00080004   /** [MS-RDPEGFX] 2.2.3.1 */
#define RDPGFX_CAPVERSION_81 0x00080105  /** [MS-RDPEGFX] 2.2.3.2 */
#define RDPGFX_CAPVERSION_10 0x000A0002  /** [MS-RDPEGFX] 2.2.3.3 */
#define RDPGFX_CAPVERSION_101 0x000A0100 /** [MS-RDPEGFX] 2.2.3.4 */
#define RDPGFX_CAPVERSION_102 0x000A0200 /** [MS-RDPEGFX] 2.2.3.5 */
#define RDPGFX_CAPVERSION_103 0x000A0301 /** [MS-RDPEGFX] 2.2.3.6 */
#define RDPGFX_CAPVERSION_104 0x000A0400 /** [MS-RDPEGFX] 2.2.3.7 */
#define RDPGFX_CAPVERSION_105 0x000A0502 /** [MS-RDPEGFX] 2.2.3.8 */
#define RDPGFX_CAPVERSION_106                                               \
	0x000A0600 /** [MS-RDPEGFX] 2.2.3.9 (the value in the doc is wrong, see \
	            * [MS-RDPEGFX]-180912-errata]                               \
	            * Since this is/was documented for a long time, also define \
	            * the incorrect value in case some server actually uses it. \
	            */
#define RDPGFX_CAPVERSION_106_ERR 0x000A0601
#define RDPGFX_CAPVERSION_107 0x000A0701 /** [MS-RDPEGFX] 2.2.3.10 */

#define RDPGFX_NUMBER_CAPSETS 11
#define RDPGFX_CAPSET_BASE_SIZE 8

typedef struct
{
	UINT32 version;
	UINT32 length;
	UINT32 flags;
} RDPGFX_CAPSET;

#define RDPGFX_CAPS_FLAG_THINCLIENT 0x00000001U        /* 8.0+ */
#define RDPGFX_CAPS_FLAG_SMALL_CACHE 0x00000002U       /* 8.0+ */
#define RDPGFX_CAPS_FLAG_AVC420_ENABLED 0x00000010U    /* 8.1+ */
#define RDPGFX_CAPS_FLAG_AVC_DISABLED 0x00000020U      /* 10.0+ */
#define RDPGFX_CAPS_FLAG_AVC_THINCLIENT 0x00000040U    /* 10.3+ */
#define RDPGFX_CAPS_FLAG_SCALEDMAP_DISABLE 0x00000080U /* 10.7+ */

typedef struct
{
	UINT32 version;
	UINT32 capsDataLength;
	UINT32 flags;
} RDPGFX_CAPSET_VERSION8;

typedef struct
{
	UINT32 version;
	UINT32 capsDataLength;
	UINT32 flags;
} RDPGFX_CAPSET_VERSION81;

typedef struct
{
	UINT32 version;
	UINT32 capsDataLength;
	UINT32 flags;
} RDPGFX_CAPSET_VERSION10;

/**
 * Graphics Messages
 */

#define RDPGFX_CODECID_UNCOMPRESSED 0x0000
#define RDPGFX_CODECID_CAVIDEO 0x0003
#define RDPGFX_CODECID_CLEARCODEC 0x0008
#define RDPGFX_CODECID_PLANAR 0x000A
#define RDPGFX_CODECID_AVC420 0x000B
#define RDPGFX_CODECID_ALPHA 0x000C
#define RDPGFX_CODECID_AVC444 0x000E
#define RDPGFX_CODECID_AVC444v2 0x000F

#define RDPGFX_WIRE_TO_SURFACE_PDU_1_SIZE 17

typedef struct
{
	UINT16 surfaceId;
	UINT16 codecId;
	RDPGFX_PIXELFORMAT pixelFormat;
	RECTANGLE_16 destRect;
	UINT32 bitmapDataLength;
	BYTE* bitmapData;
} RDPGFX_WIRE_TO_SURFACE_PDU_1;

#define RDPGFX_CODECID_CAPROGRESSIVE 0x0009
#define RDPGFX_CODECID_CAPROGRESSIVE_V2 0x000D

#define RDPGFX_WIRE_TO_SURFACE_PDU_2_SIZE 13

typedef struct
{
	UINT16 surfaceId;
	UINT16 codecId;
	UINT32 codecContextId;
	RDPGFX_PIXELFORMAT pixelFormat;
	UINT32 bitmapDataLength;
	BYTE* bitmapData;
} RDPGFX_WIRE_TO_SURFACE_PDU_2;

typedef struct
{
	UINT32 surfaceId;
	UINT32 codecId;
	UINT32 contextId;
	UINT32 format; /* FreeRDP color format. @see freerdp/codec/color.h */
	UINT32 left;
	UINT32 top;
	UINT32 right;
	UINT32 bottom;
	UINT32 width;
	UINT32 height;
	UINT32 length;
	BYTE* data;
	void* extra;
} RDPGFX_SURFACE_COMMAND;

typedef struct
{
	UINT16 surfaceId;
	UINT32 codecContextId;
} RDPGFX_DELETE_ENCODING_CONTEXT_PDU;

typedef struct
{
	UINT16 surfaceId;
	RDPGFX_COLOR32 fillPixel;
	UINT16 fillRectCount;
	RECTANGLE_16* fillRects;
} RDPGFX_SOLID_FILL_PDU;

typedef struct
{
	UINT16 surfaceIdSrc;
	UINT16 surfaceIdDest;
	RECTANGLE_16 rectSrc;
	UINT16 destPtsCount;
	RDPGFX_POINT16* destPts;
} RDPGFX_SURFACE_TO_SURFACE_PDU;

typedef struct
{
	UINT16 surfaceId;
	UINT64 cacheKey;
	UINT16 cacheSlot;
	RECTANGLE_16 rectSrc;
} RDPGFX_SURFACE_TO_CACHE_PDU;

typedef struct
{
	UINT16 cacheSlot;
	UINT16 surfaceId;
	UINT16 destPtsCount;
	RDPGFX_POINT16* destPts;
} RDPGFX_CACHE_TO_SURFACE_PDU;

typedef struct
{
	UINT16 cacheSlot;
} RDPGFX_EVICT_CACHE_ENTRY_PDU;

typedef struct
{
	UINT16 surfaceId;
	UINT16 width;
	UINT16 height;
	RDPGFX_PIXELFORMAT pixelFormat;
} RDPGFX_CREATE_SURFACE_PDU;

typedef struct
{
	UINT16 surfaceId;
} RDPGFX_DELETE_SURFACE_PDU;

#define RDPGFX_START_FRAME_PDU_SIZE 8

typedef struct
{
	UINT32 timestamp;
	UINT32 frameId;
} RDPGFX_START_FRAME_PDU;

#define RDPGFX_END_FRAME_PDU_SIZE 4

typedef struct
{
	UINT32 frameId;
} RDPGFX_END_FRAME_PDU;

#define QUEUE_DEPTH_UNAVAILABLE 0x00000000
#define SUSPEND_FRAME_ACKNOWLEDGEMENT 0xFFFFFFFF

typedef struct
{
	UINT32 queueDepth;
	UINT32 frameId;
	UINT32 totalFramesDecoded;
} RDPGFX_FRAME_ACKNOWLEDGE_PDU;

typedef struct
{
	UINT32 width;
	UINT32 height;
	UINT32 monitorCount;
	MONITOR_DEF* monitorDefArray;
} RDPGFX_RESET_GRAPHICS_PDU;

typedef struct
{
	UINT16 surfaceId;
	UINT16 reserved;
	UINT32 outputOriginX;
	UINT32 outputOriginY;
} RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU;

typedef struct
{
	UINT16 surfaceId;
	UINT16 reserved;
	UINT32 outputOriginX;
	UINT32 outputOriginY;
	UINT32 targetWidth;
	UINT32 targetHeight;
} RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU;

typedef struct
{
	UINT64 cacheKey;
	UINT32 bitmapLength;
} RDPGFX_CACHE_ENTRY_METADATA;

#define RDPGFX_CACHE_ENTRY_MAX_COUNT 5462

typedef struct
{
	UINT16 cacheEntriesCount;
	RDPGFX_CACHE_ENTRY_METADATA cacheEntries[RDPGFX_CACHE_ENTRY_MAX_COUNT];
} RDPGFX_CACHE_IMPORT_OFFER_PDU;

typedef struct
{
	UINT16 importedEntriesCount;
	UINT16 cacheSlots[RDPGFX_CACHE_ENTRY_MAX_COUNT];
} RDPGFX_CACHE_IMPORT_REPLY_PDU;

typedef struct
{
	UINT16 capsSetCount;
	RDPGFX_CAPSET* capsSets;
} RDPGFX_CAPS_ADVERTISE_PDU;

typedef struct
{
	RDPGFX_CAPSET* capsSet;
} RDPGFX_CAPS_CONFIRM_PDU;

typedef struct
{
	UINT16 surfaceId;
	UINT64 windowId;
	UINT32 mappedWidth;
	UINT32 mappedHeight;
} RDPGFX_MAP_SURFACE_TO_WINDOW_PDU;

typedef struct
{
	UINT16 surfaceId;
	UINT64 windowId;
	UINT32 mappedWidth;
	UINT32 mappedHeight;
	UINT32 targetWidth;
	UINT32 targetHeight;
} RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU;

/* H264 */

typedef struct
{
	BYTE qpVal;
	BYTE qualityVal;

	BYTE qp;
	BYTE r;
	BYTE p;
} RDPGFX_H264_QUANT_QUALITY;

typedef struct
{
	UINT32 numRegionRects;
	RECTANGLE_16* regionRects;
	RDPGFX_H264_QUANT_QUALITY* quantQualityVals;
} RDPGFX_H264_METABLOCK;

typedef struct
{
	RDPGFX_H264_METABLOCK meta;
	UINT32 length;
	BYTE* data;
} RDPGFX_AVC420_BITMAP_STREAM;

typedef struct
{
	UINT32 cbAvc420EncodedBitstream1;
	BYTE LC;
	RDPGFX_AVC420_BITMAP_STREAM bitstream[2];
} RDPGFX_AVC444_BITMAP_STREAM;

typedef struct
{
	UINT32 frameId;
	UINT32 timestamp;
	UINT16 timeDiffSE;
	UINT16 timeDiffEDR;
} RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU;

#ifdef __cplusplus
}
#endif
#endif /* FREERDP_CHANNEL_RDPGFX_H */