rdpgfx.h (11121B)
1/** 2 * FreeRDP: A Remote Desktop Protocol Implementation 3 * Graphics Pipeline Extension 4 * 5 * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com> 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20#ifndef FREERDP_CHANNEL_RDPGFX_H 21#define FREERDP_CHANNEL_RDPGFX_H 22 23#include <freerdp/api.h> 24#include <freerdp/dvc.h> 25#include <freerdp/types.h> 26 27#define RDPGFX_DVC_CHANNEL_NAME "Microsoft::Windows::RDS::Graphics" 28 29/** 30 * Common Data Types 31 */ 32 33struct _RDPGFX_POINT16 34{ 35 UINT16 x; 36 UINT16 y; 37}; 38typedef struct _RDPGFX_POINT16 RDPGFX_POINT16; 39 40struct _RDPGFX_COLOR32 41{ 42 BYTE B; 43 BYTE G; 44 BYTE R; 45 BYTE XA; 46}; 47typedef struct _RDPGFX_COLOR32 RDPGFX_COLOR32; 48 49#define GFX_PIXEL_FORMAT_XRGB_8888 0x20 50#define GFX_PIXEL_FORMAT_ARGB_8888 0x21 51 52typedef BYTE RDPGFX_PIXELFORMAT; 53 54#define RDPGFX_CMDID_UNUSED_0000 0x0000 55#define RDPGFX_CMDID_WIRETOSURFACE_1 0x0001 56#define RDPGFX_CMDID_WIRETOSURFACE_2 0x0002 57#define RDPGFX_CMDID_DELETEENCODINGCONTEXT 0x0003 58#define RDPGFX_CMDID_SOLIDFILL 0x0004 59#define RDPGFX_CMDID_SURFACETOSURFACE 0x0005 60#define RDPGFX_CMDID_SURFACETOCACHE 0x0006 61#define RDPGFX_CMDID_CACHETOSURFACE 0x0007 62#define RDPGFX_CMDID_EVICTCACHEENTRY 0x0008 63#define RDPGFX_CMDID_CREATESURFACE 0x0009 64#define RDPGFX_CMDID_DELETESURFACE 0x000A 65#define RDPGFX_CMDID_STARTFRAME 0x000B 66#define RDPGFX_CMDID_ENDFRAME 0x000C 67#define RDPGFX_CMDID_FRAMEACKNOWLEDGE 0x000D 68#define RDPGFX_CMDID_RESETGRAPHICS 0x000E 69#define RDPGFX_CMDID_MAPSURFACETOOUTPUT 0x000F 70#define RDPGFX_CMDID_CACHEIMPORTOFFER 0x0010 71#define RDPGFX_CMDID_CACHEIMPORTREPLY 0x0011 72#define RDPGFX_CMDID_CAPSADVERTISE 0x0012 73#define RDPGFX_CMDID_CAPSCONFIRM 0x0013 74#define RDPGFX_CMDID_UNUSED_0014 0x0014 75#define RDPGFX_CMDID_MAPSURFACETOWINDOW 0x0015 76#define RDPGFX_CMDID_QOEFRAMEACKNOWLEDGE 0x0016 77#define RDPGFX_CMDID_MAPSURFACETOSCALEDOUTPUT 0x0017 78#define RDPGFX_CMDID_MAPSURFACETOSCALEDWINDOW 0x0018 79 80#define RDPGFX_HEADER_SIZE 8 81 82struct _RDPGFX_HEADER 83{ 84 UINT16 cmdId; 85 UINT16 flags; 86 UINT32 pduLength; 87}; 88typedef struct _RDPGFX_HEADER RDPGFX_HEADER; 89 90/** 91 * Capability Sets [MS-RDPEGFX] 2.2.3 92 */ 93 94#define RDPGFX_CAPVERSION_8 0x00080004 /** [MS-RDPEGFX] 2.2.3.1 */ 95#define RDPGFX_CAPVERSION_81 0x00080105 /** [MS-RDPEGFX] 2.2.3.2 */ 96#define RDPGFX_CAPVERSION_10 0x000A0002 /** [MS-RDPEGFX] 2.2.3.3 */ 97#define RDPGFX_CAPVERSION_101 0x000A0100 /** [MS-RDPEGFX] 2.2.3.4 */ 98#define RDPGFX_CAPVERSION_102 0x000A0200 /** [MS-RDPEGFX] 2.2.3.5 */ 99#define RDPGFX_CAPVERSION_103 0x000A0301 /** [MS-RDPEGFX] 2.2.3.6 */ 100#define RDPGFX_CAPVERSION_104 0x000A0400 /** [MS-RDPEGFX] 2.2.3.7 */ 101#define RDPGFX_CAPVERSION_105 0x000A0502 /** [MS-RDPEGFX] 2.2.3.8 */ 102#define RDPGFX_CAPVERSION_106 \ 103 0x000A0600 /** [MS-RDPEGFX] 2.2.3.9 (the value in the doc is wrong, see \ 104 * [MS-RDPEGFX]-180912-errata] \ 105 * Since this is/was documented for a long time, also define \ 106 * the incorrect value in case some server actually uses it. \ 107 */ 108#define RDPGFX_CAPVERSION_106_ERR 0x000A0601 109#define RDPGFX_CAPVERSION_107 0x000A0701 /** [MS-RDPEGFX] 2.2.3.10 */ 110 111#define RDPGFX_NUMBER_CAPSETS 11 112#define RDPGFX_CAPSET_BASE_SIZE 8 113 114struct _RDPGFX_CAPSET 115{ 116 UINT32 version; 117 UINT32 length; 118 UINT32 flags; 119}; 120typedef struct _RDPGFX_CAPSET RDPGFX_CAPSET; 121 122#define RDPGFX_CAPS_FLAG_THINCLIENT 0x00000001U /* 8.0+ */ 123#define RDPGFX_CAPS_FLAG_SMALL_CACHE 0x00000002U /* 8.0+ */ 124#define RDPGFX_CAPS_FLAG_AVC420_ENABLED 0x00000010U /* 8.1+ */ 125#define RDPGFX_CAPS_FLAG_AVC_DISABLED 0x00000020U /* 10.0+ */ 126#define RDPGFX_CAPS_FLAG_AVC_THINCLIENT 0x00000040U /* 10.3+ */ 127#define RDPGFX_CAPS_FLAG_SCALEDMAP_DISABLE 0x00000080U /* 10.7+ */ 128 129struct _RDPGFX_CAPSET_VERSION8 130{ 131 UINT32 version; 132 UINT32 capsDataLength; 133 UINT32 flags; 134}; 135typedef struct _RDPGFX_CAPSET_VERSION8 RDPGFX_CAPSET_VERSION8; 136 137struct _RDPGFX_CAPSET_VERSION81 138{ 139 UINT32 version; 140 UINT32 capsDataLength; 141 UINT32 flags; 142}; 143typedef struct _RDPGFX_CAPSET_VERSION81 RDPGFX_CAPSET_VERSION81; 144 145struct _RDPGFX_CAPSET_VERSION10 146{ 147 UINT32 version; 148 UINT32 capsDataLength; 149 UINT32 flags; 150}; 151typedef struct _RDPGFX_CAPSET_VERSION10 RDPGFX_CAPSET_VERSION10; 152 153/** 154 * Graphics Messages 155 */ 156 157#define RDPGFX_CODECID_UNCOMPRESSED 0x0000 158#define RDPGFX_CODECID_CAVIDEO 0x0003 159#define RDPGFX_CODECID_CLEARCODEC 0x0008 160#define RDPGFX_CODECID_PLANAR 0x000A 161#define RDPGFX_CODECID_AVC420 0x000B 162#define RDPGFX_CODECID_ALPHA 0x000C 163#define RDPGFX_CODECID_AVC444 0x000E 164#define RDPGFX_CODECID_AVC444v2 0x000F 165 166#define RDPGFX_WIRE_TO_SURFACE_PDU_1_SIZE 17 167 168struct _RDPGFX_WIRE_TO_SURFACE_PDU_1 169{ 170 UINT16 surfaceId; 171 UINT16 codecId; 172 RDPGFX_PIXELFORMAT pixelFormat; 173 RECTANGLE_16 destRect; 174 UINT32 bitmapDataLength; 175 BYTE* bitmapData; 176}; 177typedef struct _RDPGFX_WIRE_TO_SURFACE_PDU_1 RDPGFX_WIRE_TO_SURFACE_PDU_1; 178 179#define RDPGFX_CODECID_CAPROGRESSIVE 0x0009 180#define RDPGFX_CODECID_CAPROGRESSIVE_V2 0x000D 181 182#define RDPGFX_WIRE_TO_SURFACE_PDU_2_SIZE 13 183 184struct _RDPGFX_WIRE_TO_SURFACE_PDU_2 185{ 186 UINT16 surfaceId; 187 UINT16 codecId; 188 UINT32 codecContextId; 189 RDPGFX_PIXELFORMAT pixelFormat; 190 UINT32 bitmapDataLength; 191 BYTE* bitmapData; 192}; 193typedef struct _RDPGFX_WIRE_TO_SURFACE_PDU_2 RDPGFX_WIRE_TO_SURFACE_PDU_2; 194 195struct _RDPGFX_SURFACE_COMMAND 196{ 197 UINT32 surfaceId; 198 UINT32 codecId; 199 UINT32 contextId; 200 UINT32 format; /* FreeRDP color format. @see freerdp/codec/color.h */ 201 UINT32 left; 202 UINT32 top; 203 UINT32 right; 204 UINT32 bottom; 205 UINT32 width; 206 UINT32 height; 207 UINT32 length; 208 BYTE* data; 209 void* extra; 210}; 211typedef struct _RDPGFX_SURFACE_COMMAND RDPGFX_SURFACE_COMMAND; 212 213struct _RDPGFX_DELETE_ENCODING_CONTEXT_PDU 214{ 215 UINT16 surfaceId; 216 UINT32 codecContextId; 217}; 218typedef struct _RDPGFX_DELETE_ENCODING_CONTEXT_PDU RDPGFX_DELETE_ENCODING_CONTEXT_PDU; 219 220struct _RDPGFX_SOLID_FILL_PDU 221{ 222 UINT16 surfaceId; 223 RDPGFX_COLOR32 fillPixel; 224 UINT16 fillRectCount; 225 RECTANGLE_16* fillRects; 226}; 227typedef struct _RDPGFX_SOLID_FILL_PDU RDPGFX_SOLID_FILL_PDU; 228 229struct _RDPGFX_SURFACE_TO_SURFACE_PDU 230{ 231 UINT16 surfaceIdSrc; 232 UINT16 surfaceIdDest; 233 RECTANGLE_16 rectSrc; 234 UINT16 destPtsCount; 235 RDPGFX_POINT16* destPts; 236}; 237typedef struct _RDPGFX_SURFACE_TO_SURFACE_PDU RDPGFX_SURFACE_TO_SURFACE_PDU; 238 239struct _RDPGFX_SURFACE_TO_CACHE_PDU 240{ 241 UINT16 surfaceId; 242 UINT64 cacheKey; 243 UINT16 cacheSlot; 244 RECTANGLE_16 rectSrc; 245}; 246typedef struct _RDPGFX_SURFACE_TO_CACHE_PDU RDPGFX_SURFACE_TO_CACHE_PDU; 247 248struct _RDPGFX_CACHE_TO_SURFACE_PDU 249{ 250 UINT16 cacheSlot; 251 UINT16 surfaceId; 252 UINT16 destPtsCount; 253 RDPGFX_POINT16* destPts; 254}; 255typedef struct _RDPGFX_CACHE_TO_SURFACE_PDU RDPGFX_CACHE_TO_SURFACE_PDU; 256 257struct _RDPGFX_EVICT_CACHE_ENTRY_PDU 258{ 259 UINT16 cacheSlot; 260}; 261typedef struct _RDPGFX_EVICT_CACHE_ENTRY_PDU RDPGFX_EVICT_CACHE_ENTRY_PDU; 262 263struct _RDPGFX_CREATE_SURFACE_PDU 264{ 265 UINT16 surfaceId; 266 UINT16 width; 267 UINT16 height; 268 RDPGFX_PIXELFORMAT pixelFormat; 269}; 270typedef struct _RDPGFX_CREATE_SURFACE_PDU RDPGFX_CREATE_SURFACE_PDU; 271 272struct _RDPGFX_DELETE_SURFACE_PDU 273{ 274 UINT16 surfaceId; 275}; 276typedef struct _RDPGFX_DELETE_SURFACE_PDU RDPGFX_DELETE_SURFACE_PDU; 277 278#define RDPGFX_START_FRAME_PDU_SIZE 8 279 280struct _RDPGFX_START_FRAME_PDU 281{ 282 UINT32 timestamp; 283 UINT32 frameId; 284}; 285typedef struct _RDPGFX_START_FRAME_PDU RDPGFX_START_FRAME_PDU; 286 287#define RDPGFX_END_FRAME_PDU_SIZE 4 288 289struct _RDPGFX_END_FRAME_PDU 290{ 291 UINT32 frameId; 292}; 293typedef struct _RDPGFX_END_FRAME_PDU RDPGFX_END_FRAME_PDU; 294 295#define QUEUE_DEPTH_UNAVAILABLE 0x00000000 296#define SUSPEND_FRAME_ACKNOWLEDGEMENT 0xFFFFFFFF 297 298struct _RDPGFX_FRAME_ACKNOWLEDGE_PDU 299{ 300 UINT32 queueDepth; 301 UINT32 frameId; 302 UINT32 totalFramesDecoded; 303}; 304typedef struct _RDPGFX_FRAME_ACKNOWLEDGE_PDU RDPGFX_FRAME_ACKNOWLEDGE_PDU; 305 306struct _RDPGFX_RESET_GRAPHICS_PDU 307{ 308 UINT32 width; 309 UINT32 height; 310 UINT32 monitorCount; 311 MONITOR_DEF* monitorDefArray; 312}; 313typedef struct _RDPGFX_RESET_GRAPHICS_PDU RDPGFX_RESET_GRAPHICS_PDU; 314 315struct _RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU 316{ 317 UINT16 surfaceId; 318 UINT16 reserved; 319 UINT32 outputOriginX; 320 UINT32 outputOriginY; 321}; 322typedef struct _RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU; 323 324struct _RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU 325{ 326 UINT16 surfaceId; 327 UINT16 reserved; 328 UINT32 outputOriginX; 329 UINT32 outputOriginY; 330 UINT32 targetWidth; 331 UINT32 targetHeight; 332}; 333typedef struct _RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU RDPGFX_MAP_SURFACE_TO_SCALED_OUTPUT_PDU; 334 335struct _RDPGFX_CACHE_ENTRY_METADATA 336{ 337 UINT64 cacheKey; 338 UINT32 bitmapLength; 339}; 340typedef struct _RDPGFX_CACHE_ENTRY_METADATA RDPGFX_CACHE_ENTRY_METADATA; 341 342struct _RDPGFX_CACHE_IMPORT_OFFER_PDU 343{ 344 UINT16 cacheEntriesCount; 345 RDPGFX_CACHE_ENTRY_METADATA* cacheEntries; 346}; 347typedef struct _RDPGFX_CACHE_IMPORT_OFFER_PDU RDPGFX_CACHE_IMPORT_OFFER_PDU; 348 349struct _RDPGFX_CACHE_IMPORT_REPLY_PDU 350{ 351 UINT16 importedEntriesCount; 352 UINT16* cacheSlots; 353}; 354typedef struct _RDPGFX_CACHE_IMPORT_REPLY_PDU RDPGFX_CACHE_IMPORT_REPLY_PDU; 355 356struct _RDPGFX_CAPS_ADVERTISE_PDU 357{ 358 UINT16 capsSetCount; 359 RDPGFX_CAPSET* capsSets; 360}; 361typedef struct _RDPGFX_CAPS_ADVERTISE_PDU RDPGFX_CAPS_ADVERTISE_PDU; 362 363struct _RDPGFX_CAPS_CONFIRM_PDU 364{ 365 RDPGFX_CAPSET* capsSet; 366}; 367typedef struct _RDPGFX_CAPS_CONFIRM_PDU RDPGFX_CAPS_CONFIRM_PDU; 368 369struct _RDPGFX_MAP_SURFACE_TO_WINDOW_PDU 370{ 371 UINT16 surfaceId; 372 UINT64 windowId; 373 UINT32 mappedWidth; 374 UINT32 mappedHeight; 375}; 376typedef struct _RDPGFX_MAP_SURFACE_TO_WINDOW_PDU RDPGFX_MAP_SURFACE_TO_WINDOW_PDU; 377 378struct _RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU 379{ 380 UINT16 surfaceId; 381 UINT64 windowId; 382 UINT32 mappedWidth; 383 UINT32 mappedHeight; 384 UINT32 targetWidth; 385 UINT32 targetHeight; 386}; 387typedef struct _RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU RDPGFX_MAP_SURFACE_TO_SCALED_WINDOW_PDU; 388 389/* H264 */ 390 391struct _RDPGFX_H264_QUANT_QUALITY 392{ 393 BYTE qpVal; 394 BYTE qualityVal; 395 396 BYTE qp; 397 BYTE r; 398 BYTE p; 399}; 400typedef struct _RDPGFX_H264_QUANT_QUALITY RDPGFX_H264_QUANT_QUALITY; 401 402struct _RDPGFX_H264_METABLOCK 403{ 404 UINT32 numRegionRects; 405 RECTANGLE_16* regionRects; 406 RDPGFX_H264_QUANT_QUALITY* quantQualityVals; 407}; 408typedef struct _RDPGFX_H264_METABLOCK RDPGFX_H264_METABLOCK; 409 410struct _RDPGFX_AVC420_BITMAP_STREAM 411{ 412 RDPGFX_H264_METABLOCK meta; 413 UINT32 length; 414 BYTE* data; 415}; 416typedef struct _RDPGFX_AVC420_BITMAP_STREAM RDPGFX_AVC420_BITMAP_STREAM; 417 418struct _RDPGFX_AVC444_BITMAP_STREAM 419{ 420 UINT32 cbAvc420EncodedBitstream1; 421 BYTE LC; 422 RDPGFX_AVC420_BITMAP_STREAM bitstream[2]; 423}; 424typedef struct _RDPGFX_AVC444_BITMAP_STREAM RDPGFX_AVC444_BITMAP_STREAM; 425 426struct _RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU 427{ 428 UINT32 frameId; 429 UINT32 timestamp; 430 UINT16 timeDiffSE; 431 UINT16 timeDiffEDR; 432}; 433typedef struct _RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU; 434 435#endif /* FREERDP_CHANNEL_RDPGFX_H */