diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index 66a405410..a6ba91486 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -70,7 +70,13 @@ struct _RDPGFX_PLUGIN IWTSListener* listener; RDPGFX_LISTENER_CALLBACK* listener_callback; + BOOL ThinClient; + BOOL SmallCache; + BOOL H264; + ZGFX_CONTEXT* zgfx; + UINT32 UnacknowledgedFrames; + UINT32 TotalDecodedFrames; }; typedef struct _RDPGFX_PLUGIN RDPGFX_PLUGIN; @@ -108,6 +114,80 @@ const char* rdpgfx_get_cmdid_string(UINT16 cmdId) return "RDPGFX_CMDID_UNKNOWN"; } +int rdpgfx_read_header(wStream* s, RDPGFX_HEADER* header) +{ + Stream_Read_UINT16(s, header->cmdId); /* cmdId (2 bytes) */ + Stream_Read_UINT16(s, header->flags); /* flags (2 bytes) */ + Stream_Read_UINT32(s, header->pduLength); /* pduLength (4 bytes) */ + + return 1; +} + +int rdpgfx_write_header(wStream* s, RDPGFX_HEADER* header) +{ + Stream_Write_UINT16(s, header->cmdId); /* cmdId (2 bytes) */ + Stream_Write_UINT16(s, header->flags); /* flags (2 bytes) */ + Stream_Write_UINT32(s, header->pduLength); /* pduLength (4 bytes) */ + + return 1; +} + +int rdpgfx_read_point16(wStream* s, RDPGFX_POINT16* pt16) +{ + Stream_Read_UINT16(s, pt16->x); /* x (2 bytes) */ + Stream_Read_UINT16(s, pt16->y); /* y (2 bytes) */ + + return 1; +} + +int rdpgfx_write_point16(wStream* s, RDPGFX_POINT16* point16) +{ + Stream_Write_UINT16(s, point16->x); /* x (2 bytes) */ + Stream_Write_UINT16(s, point16->y); /* y (2 bytes) */ + + return 1; +} + +int rdpgfx_read_rect16(wStream* s, RDPGFX_RECT16* rect16) +{ + Stream_Read_UINT16(s, rect16->left); /* left (2 bytes) */ + Stream_Read_UINT16(s, rect16->top); /* top (2 bytes) */ + Stream_Read_UINT16(s, rect16->right); /* right (2 bytes) */ + Stream_Read_UINT16(s, rect16->bottom); /* bottom (2 bytes) */ + + return 1; +} + +int rdpgfx_write_rect16(wStream* s, RDPGFX_RECT16* rect16) +{ + Stream_Write_UINT16(s, rect16->left); /* left (2 bytes) */ + Stream_Write_UINT16(s, rect16->top); /* top (2 bytes) */ + Stream_Write_UINT16(s, rect16->right); /* right (2 bytes) */ + Stream_Write_UINT16(s, rect16->bottom); /* bottom (2 bytes) */ + + return 1; +} + +int rdpgfx_read_color32(wStream* s, RDPGFX_COLOR32* color32) +{ + Stream_Read_UINT8(s, color32->B); /* B (1 byte) */ + Stream_Read_UINT8(s, color32->G); /* G (1 byte) */ + Stream_Read_UINT8(s, color32->R); /* R (1 byte) */ + Stream_Read_UINT8(s, color32->XA); /* XA (1 byte) */ + + return 1; +} + +int rdpgfx_write_color32(wStream* s, RDPGFX_COLOR32* color32) +{ + Stream_Write_UINT8(s, color32->B); /* B (1 byte) */ + Stream_Write_UINT8(s, color32->G); /* G (1 byte) */ + Stream_Write_UINT8(s, color32->R); /* R (1 byte) */ + Stream_Write_UINT8(s, color32->XA); /* XA (1 byte) */ + + return 1; +} + int rdpgfx_send_caps_advertise_pdu(RDPGFX_CHANNEL_CALLBACK* callback) { int status; @@ -116,47 +196,53 @@ int rdpgfx_send_caps_advertise_pdu(RDPGFX_CHANNEL_CALLBACK* callback) RDPGFX_PLUGIN* gfx; RDPGFX_HEADER header; RDPGFX_CAPSET* capsSet; - RDPGFX_CAPSET* capsSets[2]; + RDPGFX_CAPSET capsSets[2]; RDPGFX_CAPS_ADVERTISE_PDU pdu; - RDPGFX_CAPSET_VERSION8 capset8; - RDPGFX_CAPSET_VERSION81 capset81; gfx = (RDPGFX_PLUGIN*) callback->plugin; - header.cmdId = RDPGFX_CMDID_CAPSADVERTISE; + gfx->ThinClient = FALSE; + gfx->SmallCache = TRUE; + gfx->H264 = TRUE; + header.flags = 0; + header.cmdId = RDPGFX_CMDID_CAPSADVERTISE; - capset8.version = RDPGFX_CAPVERSION_8; - capset8.capsDataLength = 4; - capset8.flags = 0; - capset8.flags |= RDPGFX_CAPS_FLAG_THINCLIENT; - //capset8.flags |= RDPGFX_CAPS_FLAG_SMALL_CACHE; + pdu.capsSetCount = 2; + pdu.capsSets = (RDPGFX_CAPSET*) capsSets; - capset81.version = RDPGFX_CAPVERSION_81; - //capset81.version = 0x00080103; - capset81.capsDataLength = 4; - capset81.flags = 0; - capset81.flags |= RDPGFX_CAPS_FLAG_THINCLIENT; - //capset81.flags |= RDPGFX_CAPS_FLAG_SMALL_CACHE; - //capset81.flags |= RDPGFX_CAPS_FLAG_H264ENABLED; + capsSet = &capsSets[0]; - pdu.capsSetCount = 0; - pdu.capsSets = (RDPGFX_CAPSET**) capsSets; + capsSet->version = RDPGFX_CAPVERSION_8; + capsSet->flags = 0; - capsSets[pdu.capsSetCount++] = (RDPGFX_CAPSET*) &capset81; - capsSets[pdu.capsSetCount++] = (RDPGFX_CAPSET*) &capset8; + if (gfx->ThinClient) + capsSet->flags |= RDPGFX_CAPS_FLAG_THINCLIENT; - header.pduLength = 8 + 2 + (pdu.capsSetCount * 12); + if (gfx->SmallCache) + capsSet->flags |= RDPGFX_CAPS_FLAG_SMALL_CACHE; + + capsSet = &capsSets[1]; + + capsSet->version = RDPGFX_CAPVERSION_81; + capsSet->flags = 0; + + if (gfx->ThinClient) + capsSet->flags |= RDPGFX_CAPS_FLAG_THINCLIENT; + + if (gfx->SmallCache) + capsSet->flags |= RDPGFX_CAPS_FLAG_SMALL_CACHE; + + if (gfx->H264) + capsSet->flags |= RDPGFX_CAPS_FLAG_H264ENABLED; + + header.pduLength = RDPGFX_HEADER_SIZE + 2 + (pdu.capsSetCount * RDPGFX_CAPSET_SIZE); fprintf(stderr, "RdpGfxSendCapsAdvertisePdu: %d\n", header.pduLength); s = Stream_New(NULL, header.pduLength); - /* RDPGFX_HEADER */ - - Stream_Write_UINT16(s, header.cmdId); /* cmdId (2 bytes) */ - Stream_Write_UINT16(s, header.flags); /* flags (2 bytes) */ - Stream_Write_UINT32(s, header.pduLength); /* pduLength (4 bytes) */ + rdpgfx_write_header(s, &header); /* RDPGFX_CAPS_ADVERTISE_PDU */ @@ -164,11 +250,10 @@ int rdpgfx_send_caps_advertise_pdu(RDPGFX_CHANNEL_CALLBACK* callback) for (index = 0; index < pdu.capsSetCount; index++) { - capsSet = pdu.capsSets[index]; - + capsSet = &(pdu.capsSets[index]); Stream_Write_UINT32(s, capsSet->version); /* version (4 bytes) */ - Stream_Write_UINT32(s, capsSet->capsDataLength); /* capsDataLength (4 bytes) */ - Stream_Write_UINT32(s, capsSet->capsData); /* capsData (4 bytes) */ + Stream_Write_UINT32(s, 4); /* capsDataLength (4 bytes) */ + Stream_Write_UINT32(s, capsSet->flags); /* capsData (4 bytes) */ } Stream_SealLength(s); @@ -183,20 +268,53 @@ int rdpgfx_send_caps_advertise_pdu(RDPGFX_CHANNEL_CALLBACK* callback) int rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_CAPSET capsSet; + UINT32 capsDataLength; RDPGFX_CAPS_CONFIRM_PDU pdu; pdu.capsSet = &capsSet; Stream_Read_UINT32(s, capsSet.version); /* version (4 bytes) */ - Stream_Read_UINT32(s, capsSet.capsDataLength); /* capsDataLength (4 bytes) */ - Stream_Read_UINT32(s, capsSet.capsData); /* capsData (4 bytes) */ + Stream_Read_UINT32(s, capsDataLength); /* capsDataLength (4 bytes) */ + Stream_Read_UINT32(s, capsSet.flags); /* capsData (4 bytes) */ - fprintf(stderr, "RdpGfxRecvCapsConfirmPdu: version: 0x%04X capsDataLength: %d capsData: 0x%04X\n", - capsSet.version, capsSet.capsDataLength, capsSet.capsData); + fprintf(stderr, "RdpGfxRecvCapsConfirmPdu: version: 0x%04X flags: 0x%04X\n", + capsSet.version, capsSet.flags); return 1; } +int rdpgfx_send_frame_acknowledge_pdu(RDPGFX_CHANNEL_CALLBACK* callback, RDPGFX_FRAME_ACKNOWLEDGE_PDU* pdu) +{ + int status; + wStream* s; + RDPGFX_PLUGIN* gfx; + RDPGFX_HEADER header; + + gfx = (RDPGFX_PLUGIN*) callback->plugin; + + header.flags = 0; + header.cmdId = RDPGFX_CMDID_FRAMEACKNOWLEDGE; + header.pduLength = RDPGFX_HEADER_SIZE + 12; + + fprintf(stderr, "RdpGfxSendFrameAcknowledgePdu: %d\n", pdu->frameId); + + s = Stream_New(NULL, header.pduLength); + + rdpgfx_write_header(s, &header); + + /* RDPGFX_FRAME_ACKNOWLEDGE_PDU */ + + Stream_Write_UINT32(s, pdu->queueDepth); /* queueDepth (4 bytes) */ + Stream_Write_UINT32(s, pdu->frameId); /* frameId (4 bytes) */ + Stream_Write_UINT32(s, pdu->totalFramesDecoded); /* totalFramesDecoded (4 bytes) */ + + status = callback->channel->Write(callback->channel, (UINT32) Stream_Length(s), Stream_Buffer(s), NULL); + + Stream_Free(s, TRUE); + + return status; +} + int rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) { UINT32 index; @@ -222,12 +340,48 @@ int rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s Stream_Read_UINT32(s, monitor->flags); /* flags (4 bytes) */ } + /* pad (total size is 340 bytes) */ + fprintf(stderr, "RdpGfxRecvResetGraphicsPdu: width: %d height: %d count: %d\n", pdu.width, pdu.height, pdu.monitorCount); return 1; } +int rdpgfx_recv_evict_cache_entry_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + RDPGFX_EVICT_CACHE_ENTRY_PDU pdu; + + Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */ + + fprintf(stderr, "RdpGfxRecvEvictCacheEntryPdu: cacheSlot: %d\n", pdu.cacheSlot); + + return 1; +} + +int rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + UINT16 index; + RDPGFX_CACHE_IMPORT_REPLY_PDU pdu; + + Stream_Read_UINT16(s, pdu.importedEntriesCount); /* cacheSlot (2 bytes) */ + + pdu.cacheSlots = (UINT16*) calloc(pdu.importedEntriesCount, sizeof(UINT16)); + + if (!pdu.cacheSlots) + return -1; + + for (index = 0; index < pdu.importedEntriesCount; index++) + { + Stream_Read_UINT16(s, pdu.cacheSlots[index]); /* cacheSlot (2 bytes) */ + } + + fprintf(stderr, "RdpGfxRecvCacheImportReplyPdu: importedEntriesCount: %d\n", + pdu.importedEntriesCount); + + return 1; +} + int rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_CREATE_SURFACE_PDU pdu; @@ -243,9 +397,21 @@ int rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s return 1; } +int rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + RDPGFX_DELETE_SURFACE_PDU pdu; + + Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ + + fprintf(stderr, "RdpGfxRecvDeleteSurfacePdu: surfaceId: %d\n", pdu.surfaceId); + + return 1; +} + int rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_START_FRAME_PDU pdu; + RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin; Stream_Read_UINT32(s, pdu.timestamp); /* timestamp (4 bytes) */ Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */ @@ -253,17 +419,228 @@ int rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) fprintf(stderr, "RdpGfxRecvStartFramePdu: frameId: %d timestamp: 0x%04X\n", pdu.frameId, pdu.timestamp); + gfx->UnacknowledgedFrames++; + return 1; } int rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) { RDPGFX_END_FRAME_PDU pdu; + RDPGFX_FRAME_ACKNOWLEDGE_PDU ack; + RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin; Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */ fprintf(stderr, "RdpGfxRecvEndFramePdu: frameId: %d\n", pdu.frameId); + gfx->UnacknowledgedFrames--; + gfx->TotalDecodedFrames++; + + ack.frameId = pdu.frameId; + ack.totalFramesDecoded = gfx->TotalDecodedFrames; + + ack.queueDepth = SUSPEND_FRAME_ACKNOWLEDGEMENT; + //ack.queueDepth = QUEUE_DEPTH_UNAVAILABLE; + //ack.queueDepth = gfx->UnacknowledgedFrames; + + rdpgfx_send_frame_acknowledge_pdu(callback, &ack); + + return 1; +} + +int rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + RDPGFX_WIRE_TO_SURFACE_PDU_1 pdu; + + Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ + Stream_Read_UINT16(s, pdu.codecId); /* codecId (2 bytes) */ + Stream_Read_UINT8(s, pdu.pixelFormat); /* pixelFormat (1 byte) */ + + Stream_Read_UINT16(s, pdu.destRect.left); /* left (2 bytes) */ + Stream_Read_UINT16(s, pdu.destRect.top); /* top (2 bytes) */ + Stream_Read_UINT16(s, pdu.destRect.right); /* right (2 bytes) */ + Stream_Read_UINT16(s, pdu.destRect.bottom); /* bottom (2 bytes) */ + + Stream_Read_UINT32(s, pdu.bitmapDataLength); /* bitmapDataLength (4 bytes) */ + + pdu.bitmapData = Stream_Pointer(s); + + fprintf(stderr, "RdpGfxRecvWireToSurface1Pdu: surfaceId: %d codecId: 0x%04X pixelFormat: 0x%04X " + "destRect: left: %d top: %d right: %d bottom: %d bitmapDataLength: %d\n", + pdu.surfaceId, pdu.codecId, pdu.pixelFormat, + pdu.destRect.left, pdu.destRect.top, pdu.destRect.right, pdu.destRect.bottom, + pdu.bitmapDataLength); + + return 1; +} + +int rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + RDPGFX_WIRE_TO_SURFACE_PDU_2 pdu; + + Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ + Stream_Read_UINT16(s, pdu.codecId); /* codecId (2 bytes) */ + Stream_Read_UINT32(s, pdu.codecContextId); /* codecContextId (4 bytes) */ + Stream_Read_UINT8(s, pdu.pixelFormat); /* pixelFormat (1 byte) */ + Stream_Read_UINT32(s, pdu.bitmapDataLength); /* bitmapDataLength (4 bytes) */ + + pdu.bitmapData = Stream_Pointer(s); + + fprintf(stderr, "RdpGfxRecvWireToSurface2Pdu: surfaceId: %d codecId: 0x%04X " + "codecContextId: %d pixelFormat: 0x%04X bitmapDataLength: %d\n", + pdu.surfaceId, pdu.codecId, pdu.codecContextId, pdu.pixelFormat, pdu.bitmapDataLength); + + return 1; +} + +int rdpgfx_recv_delete_encoding_context_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + RDPGFX_DELETE_ENCODING_CONTEXT_PDU pdu; + + Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ + Stream_Read_UINT32(s, pdu.codecContextId); /* codecContextId (4 bytes) */ + + fprintf(stderr, "RdpGfxRecvDeleteEncodingContextPdu: surfaceId: %d codecContextId: %d\n", + pdu.surfaceId, pdu.codecContextId); + + return 1; +} + +int rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + UINT16 index; + RDPGFX_RECT16* fillRect; + RDPGFX_SOLID_FILL_PDU pdu; + + Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ + + rdpgfx_read_color32(s, &(pdu.fillPixel)); /* fillPixel (4 bytes) */ + + Stream_Read_UINT16(s, pdu.fillRectCount); /* fillRectCount (2 bytes) */ + + pdu.fillRects = (RDPGFX_RECT16*) calloc(pdu.fillRectCount, sizeof(RDPGFX_RECT16)); + + if (!pdu.fillRects) + return -1; + + for (index = 0; index < pdu.fillRectCount; index++) + { + fillRect = &(pdu.fillRects[index]); + rdpgfx_read_rect16(s, fillRect); + } + + fprintf(stderr, "RdpGfxRecvSolidFillPdu: surfaceId: %d fillRectCount: %d\n", + pdu.surfaceId, pdu.fillRectCount); + + return 1; +} + +int rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + UINT16 index; + RDPGFX_POINT16* destPt; + RDPGFX_SURFACE_TO_SURFACE_PDU pdu; + + Stream_Read_UINT16(s, pdu.surfaceIdSrc); /* surfaceIdSrc (2 bytes) */ + Stream_Read_UINT16(s, pdu.surfaceIdDest); /* surfaceIdDest (2 bytes) */ + + rdpgfx_read_rect16(s, &(pdu.rectSrc)); /* rectSrc (8 bytes ) */ + + Stream_Read_UINT16(s, pdu.destPtsCount); /* destPtsCount (2 bytes) */ + + pdu.destPts = (RDPGFX_POINT16*) calloc(pdu.destPtsCount, sizeof(RDPGFX_POINT16)); + + if (!pdu.destPts) + return -1; + + for (index = 0; index < pdu.destPtsCount; index++) + { + destPt = &(pdu.destPts[index]); + rdpgfx_read_point16(s, destPt); + } + + fprintf(stderr, "RdpGfxRecvSurfaceToSurfacePdu: surfaceIdSrc: %d surfaceIdDest: %d " + "left: %d top: %d right: %d bottom: %d destPtsCount: %d\n", + pdu.surfaceIdSrc, pdu.surfaceIdDest, + pdu.rectSrc.left, pdu.rectSrc.top, pdu.rectSrc.right, pdu.rectSrc.bottom, + pdu.destPtsCount); + + return 1; +} + +int rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + RDPGFX_SURFACE_TO_CACHE_PDU pdu; + + Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ + Stream_Read_UINT64(s, pdu.cacheKey); /* cacheKey (8 bytes) */ + Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */ + rdpgfx_read_rect16(s, &(pdu.rectSrc)); /* rectSrc (8 bytes ) */ + + fprintf(stderr, "RdpGfxRecvSurfaceToCachePdu: surfaceId: %d cacheKey: 0x%08X cacheSlot: %d " + "left: %d top: %d right: %d bottom: %d\n", + pdu.surfaceId, pdu.cacheKey, pdu.cacheSlot, + pdu.rectSrc.left, pdu.rectSrc.top, + pdu.rectSrc.right, pdu.rectSrc.bottom); + + return 1; +} + +int rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + UINT16 index; + RDPGFX_POINT16* destPt; + RDPGFX_CACHE_TO_SURFACE_PDU pdu; + + Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */ + Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ + Stream_Read_UINT16(s, pdu.destPtsCount); /* destPtsCount (2 bytes) */ + + pdu.destPts = (RDPGFX_POINT16*) calloc(pdu.destPtsCount, sizeof(RDPGFX_POINT16)); + + if (!pdu.destPts) + return -1; + + for (index = 0; index < pdu.destPtsCount; index++) + { + destPt = &(pdu.destPts[index]); + rdpgfx_read_point16(s, destPt); + } + + fprintf(stderr, "RdpGfxRecvCacheToSurfacePdu: cacheSlot: %d surfaceId: %d destPtsCount: %d\n", + pdu.cacheSlot, pdu.surfaceId, pdu.destPtsCount); + + return 1; +} + +int rdpgfx_recv_map_surface_to_output_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU pdu; + + Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ + Stream_Read_UINT16(s, pdu.reserved); /* reserved (2 bytes) */ + Stream_Read_UINT32(s, pdu.outputOriginX); /* outputOriginX (4 bytes) */ + Stream_Read_UINT32(s, pdu.outputOriginY); /* outputOriginY (4 bytes) */ + + fprintf(stderr, "RdpGfxRecvMapSurfaceToOutputPdu: surfaceId: %d outputOriginX: %d outputOriginY: %d\n", + pdu.surfaceId, pdu.outputOriginX, pdu.outputOriginY); + + return 1; +} + +int rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + RDPGFX_MAP_SURFACE_TO_WINDOW_PDU pdu; + + Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ + Stream_Read_UINT64(s, pdu.windowId); /* windowId (8 bytes) */ + Stream_Read_UINT32(s, pdu.mappedWidth); /* mappedWidth (4 bytes) */ + Stream_Read_UINT32(s, pdu.mappedHeight); /* mappedHeight (4 bytes) */ + + fprintf(stderr, "RdpGfxRecvMapSurfaceToWindowPdu: surfaceId: %d windowId: 0x%04X mappedWidth: %d mappedHeight: %d\n", + pdu.surfaceId, pdu.windowId, pdu.mappedWidth, pdu.mappedHeight); + return 1; } @@ -272,13 +649,9 @@ int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) int status; RDPGFX_HEADER header; - /* RDPGFX_HEADER */ + rdpgfx_read_header(s, &header); - Stream_Read_UINT16(s, header.cmdId); /* cmdId (2 bytes) */ - Stream_Read_UINT16(s, header.flags); /* flags (2 bytes) */ - Stream_Read_UINT32(s, header.pduLength); /* pduLength (4 bytes) */ - -#if 0 +#if 1 printf("cmdId: %s (0x%04X) flags: 0x%04X pduLength: %d\n", rdpgfx_get_cmdid_string(header.cmdId), header.cmdId, header.flags, header.pduLength); #endif @@ -286,33 +659,43 @@ int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) switch (header.cmdId) { case RDPGFX_CMDID_WIRETOSURFACE_1: + status = rdpgfx_recv_wire_to_surface_1_pdu(callback, s); break; case RDPGFX_CMDID_WIRETOSURFACE_2: + status = rdpgfx_recv_wire_to_surface_2_pdu(callback, s); break; case RDPGFX_CMDID_DELETEENCODINGCONTEXT: + status = rdpgfx_recv_delete_encoding_context_pdu(callback, s); break; case RDPGFX_CMDID_SOLIDFILL: + status = rdpgfx_recv_solid_fill_pdu(callback, s); break; case RDPGFX_CMDID_SURFACETOSURFACE: + status = rdpgfx_recv_surface_to_surface_pdu(callback, s); break; case RDPGFX_CMDID_SURFACETOCACHE: + status = rdpgfx_recv_surface_to_cache_pdu(callback, s); break; case RDPGFX_CMDID_CACHETOSURFACE: + status = rdpgfx_recv_cache_to_surface_pdu(callback, s); break; case RDPGFX_CMDID_EVICTCACHEENTRY: + status = rdpgfx_recv_evict_cache_entry_pdu(callback, s); break; case RDPGFX_CMDID_CREATESURFACE: + status = rdpgfx_recv_create_surface_pdu(callback, s); break; case RDPGFX_CMDID_DELETESURFACE: + status = rdpgfx_recv_delete_surface_pdu(callback, s); break; case RDPGFX_CMDID_STARTFRAME: @@ -328,12 +711,11 @@ int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) break; case RDPGFX_CMDID_MAPSURFACETOOUTPUT: - break; - - case RDPGFX_CMDID_CACHEIMPORTOFFER: + status = rdpgfx_recv_map_surface_to_output_pdu(callback, s); break; case RDPGFX_CMDID_CACHEIMPORTREPLY: + status = rdpgfx_recv_cache_import_reply_pdu(callback, s); break; case RDPGFX_CMDID_CAPSCONFIRM: @@ -341,6 +723,7 @@ int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) break; case RDPGFX_CMDID_MAPSURFACETOWINDOW: + status = rdpgfx_recv_map_surface_to_window_pdu(callback, s); break; default: diff --git a/include/freerdp/channels/rdpgfx.h b/include/freerdp/channels/rdpgfx.h index 05d18ed37..25c650712 100644 --- a/include/freerdp/channels/rdpgfx.h +++ b/include/freerdp/channels/rdpgfx.h @@ -83,6 +83,8 @@ typedef BYTE RDPGFX_PIXELFORMAT; #define RDPGFX_CMDID_UNUSED_0014 0x0014 #define RDPGFX_CMDID_MAPSURFACETOWINDOW 0x0015 +#define RDPGFX_HEADER_SIZE 8 + struct _RDPGFX_HEADER { UINT16 cmdId; @@ -98,11 +100,12 @@ typedef struct _RDPGFX_HEADER RDPGFX_HEADER; #define RDPGFX_CAPVERSION_8 0x00080004 #define RDPGFX_CAPVERSION_81 0x00080105 +#define RDPGFX_CAPSET_SIZE 12 + struct _RDPGFX_CAPSET { UINT32 version; - UINT32 capsDataLength; - UINT32 capsData; + UINT32 flags; }; typedef struct _RDPGFX_CAPSET RDPGFX_CAPSET; @@ -169,14 +172,14 @@ struct _RDPGFX_DELETE_ENCODING_CONTEXT_PDU }; typedef struct _RDPGFX_DELETE_ENCODING_CONTEXT_PDU RDPGFX_DELETE_ENCODING_CONTEXT_PDU; -struct _RDPGFX_SOLIDFILL_PDU +struct _RDPGFX_SOLID_FILL_PDU { UINT16 surfaceId; RDPGFX_COLOR32 fillPixel; UINT16 fillRectCount; RDPGFX_RECT16* fillRects; }; -typedef struct _RDPGFX_SOLIDFILL_PDU RDPGFX_SOLIDFILL_PDU; +typedef struct _RDPGFX_SOLID_FILL_PDU RDPGFX_SOLID_FILL_PDU; struct _RDPGFX_SURFACE_TO_SURFACE_PDU { @@ -293,7 +296,7 @@ typedef struct _RDPGFX_CACHE_IMPORT_REPLY_PDU RDPGFX_CACHE_IMPORT_REPLY_PDU; struct _RDPGFX_CAPS_ADVERTISE_PDU { UINT16 capsSetCount; - RDPGFX_CAPSET** capsSets; + RDPGFX_CAPSET* capsSets; }; typedef struct _RDPGFX_CAPS_ADVERTISE_PDU RDPGFX_CAPS_ADVERTISE_PDU;