2013-10-22 06:53:55 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* Graphics Pipeline Extension
|
|
|
|
*
|
2014-06-04 04:51:28 +04:00
|
|
|
* Copyright 2013-2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2013-10-22 06:53:55 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
2013-10-22 07:33:25 +04:00
|
|
|
#include <winpr/wlog.h>
|
2014-06-03 21:38:10 +04:00
|
|
|
#include <winpr/print.h>
|
2013-10-22 06:53:55 +04:00
|
|
|
#include <winpr/synch.h>
|
|
|
|
#include <winpr/thread.h>
|
|
|
|
#include <winpr/stream.h>
|
|
|
|
#include <winpr/sysinfo.h>
|
|
|
|
#include <winpr/cmdline.h>
|
|
|
|
#include <winpr/collections.h>
|
|
|
|
|
|
|
|
#include <freerdp/addin.h>
|
|
|
|
|
|
|
|
#include "rdpgfx_common.h"
|
2014-06-04 04:51:28 +04:00
|
|
|
#include "rdpgfx_codec.h"
|
2013-10-22 06:53:55 +04:00
|
|
|
|
|
|
|
#include "rdpgfx_main.h"
|
|
|
|
|
2014-06-03 08:05:43 +04:00
|
|
|
int rdpgfx_send_caps_advertise_pdu(RDPGFX_CHANNEL_CALLBACK* callback)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
wStream* s;
|
|
|
|
UINT16 index;
|
|
|
|
RDPGFX_PLUGIN* gfx;
|
|
|
|
RDPGFX_HEADER header;
|
|
|
|
RDPGFX_CAPSET* capsSet;
|
2014-06-04 03:48:47 +04:00
|
|
|
RDPGFX_CAPSET capsSets[2];
|
2014-06-03 08:05:43 +04:00
|
|
|
RDPGFX_CAPS_ADVERTISE_PDU pdu;
|
|
|
|
|
|
|
|
gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
|
2014-06-04 04:51:28 +04:00
|
|
|
gfx->ThinClient = TRUE;
|
|
|
|
gfx->SmallCache = FALSE;
|
2014-07-02 07:28:09 +04:00
|
|
|
|
|
|
|
#ifdef WITH_OPENH264
|
|
|
|
gfx->H264 = TRUE;
|
|
|
|
#else
|
2014-06-04 04:51:28 +04:00
|
|
|
gfx->H264 = FALSE;
|
2014-07-02 07:28:09 +04:00
|
|
|
#endif
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-06-13 16:36:09 +04:00
|
|
|
gfx->MaxCacheSlot = (gfx->ThinClient) ? 4096 : 25600;
|
|
|
|
|
2014-06-03 08:05:43 +04:00
|
|
|
header.flags = 0;
|
2014-06-04 03:48:47 +04:00
|
|
|
header.cmdId = RDPGFX_CMDID_CAPSADVERTISE;
|
|
|
|
|
2014-07-02 07:28:09 +04:00
|
|
|
pdu.capsSetCount = 2;
|
2014-06-04 03:48:47 +04:00
|
|
|
pdu.capsSets = (RDPGFX_CAPSET*) capsSets;
|
|
|
|
|
|
|
|
capsSet = &capsSets[0];
|
|
|
|
|
|
|
|
capsSet->version = RDPGFX_CAPVERSION_8;
|
|
|
|
capsSet->flags = 0;
|
|
|
|
|
|
|
|
if (gfx->ThinClient)
|
|
|
|
capsSet->flags |= RDPGFX_CAPS_FLAG_THINCLIENT;
|
2014-06-03 08:05:43 +04:00
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
if (gfx->SmallCache)
|
|
|
|
capsSet->flags |= RDPGFX_CAPS_FLAG_SMALL_CACHE;
|
2014-06-03 08:05:43 +04:00
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
capsSet = &capsSets[1];
|
2014-06-03 08:05:43 +04:00
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
capsSet->version = RDPGFX_CAPVERSION_81;
|
|
|
|
capsSet->flags = 0;
|
2014-06-03 08:05:43 +04:00
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
if (gfx->ThinClient)
|
|
|
|
capsSet->flags |= RDPGFX_CAPS_FLAG_THINCLIENT;
|
2014-06-03 08:05:43 +04:00
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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);
|
2014-06-03 08:05:43 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "SendCapsAdvertisePdu");
|
2014-06-03 08:05:43 +04:00
|
|
|
|
|
|
|
s = Stream_New(NULL, header.pduLength);
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
rdpgfx_write_header(s, &header);
|
2014-06-03 08:05:43 +04:00
|
|
|
|
|
|
|
/* RDPGFX_CAPS_ADVERTISE_PDU */
|
|
|
|
|
|
|
|
Stream_Write_UINT16(s, pdu.capsSetCount); /* capsSetCount (2 bytes) */
|
|
|
|
|
|
|
|
for (index = 0; index < pdu.capsSetCount; index++)
|
|
|
|
{
|
2014-06-04 03:48:47 +04:00
|
|
|
capsSet = &(pdu.capsSets[index]);
|
2014-06-03 08:05:43 +04:00
|
|
|
Stream_Write_UINT32(s, capsSet->version); /* version (4 bytes) */
|
2014-06-04 03:48:47 +04:00
|
|
|
Stream_Write_UINT32(s, 4); /* capsDataLength (4 bytes) */
|
|
|
|
Stream_Write_UINT32(s, capsSet->flags); /* capsData (4 bytes) */
|
2014-06-03 08:05:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
Stream_SealLength(s);
|
|
|
|
|
|
|
|
status = callback->channel->Write(callback->channel, (UINT32) Stream_Length(s), Stream_Buffer(s), NULL);
|
|
|
|
|
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
int rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_CAPSET capsSet;
|
2014-06-04 03:48:47 +04:00
|
|
|
UINT32 capsDataLength;
|
2014-06-03 23:32:03 +04:00
|
|
|
RDPGFX_CAPS_CONFIRM_PDU pdu;
|
2014-06-05 06:06:29 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2014-06-03 23:32:03 +04:00
|
|
|
|
|
|
|
pdu.capsSet = &capsSet;
|
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 12)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
Stream_Read_UINT32(s, capsSet.version); /* version (4 bytes) */
|
2014-06-04 03:48:47 +04:00
|
|
|
Stream_Read_UINT32(s, capsDataLength); /* capsDataLength (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, capsSet.flags); /* capsData (4 bytes) */
|
2014-06-03 23:32:03 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvCapsConfirmPdu: version: 0x%04X flags: 0x%04X",
|
2014-06-04 03:48:47 +04:00
|
|
|
capsSet.version, capsSet.flags);
|
2014-06-03 23:32:03 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
int rdpgfx_send_frame_acknowledge_pdu(RDPGFX_CHANNEL_CALLBACK* callback, RDPGFX_FRAME_ACKNOWLEDGE_PDU* pdu)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
wStream* s;
|
|
|
|
RDPGFX_HEADER header;
|
2014-06-05 06:06:29 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
|
|
|
header.flags = 0;
|
|
|
|
header.cmdId = RDPGFX_CMDID_FRAMEACKNOWLEDGE;
|
|
|
|
header.pduLength = RDPGFX_HEADER_SIZE + 12;
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "SendFrameAcknowledgePdu: %d", pdu->frameId);
|
2014-06-04 03:48:47 +04:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
int rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
2014-06-05 05:35:31 +04:00
|
|
|
int pad;
|
2014-06-03 23:32:03 +04:00
|
|
|
UINT32 index;
|
|
|
|
MONITOR_DEF* monitor;
|
|
|
|
RDPGFX_RESET_GRAPHICS_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-03 23:32:03 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 12)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
Stream_Read_UINT32(s, pdu.width); /* width (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, pdu.height); /* height (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, pdu.monitorCount); /* monitorCount (4 bytes) */
|
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (pdu.monitorCount * 20))
|
|
|
|
return -1;
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
pdu.monitorDefArray = (MONITOR_DEF*) calloc(pdu.monitorCount, sizeof(MONITOR_DEF));
|
|
|
|
|
|
|
|
if (!pdu.monitorDefArray)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (index = 0; index < pdu.monitorCount; index++)
|
|
|
|
{
|
|
|
|
monitor = &(pdu.monitorDefArray[index]);
|
|
|
|
Stream_Read_UINT32(s, monitor->left); /* left (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, monitor->top); /* top (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, monitor->right); /* right (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, monitor->bottom); /* bottom (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, monitor->flags); /* flags (4 bytes) */
|
|
|
|
}
|
|
|
|
|
2014-06-05 05:35:31 +04:00
|
|
|
pad = 340 - (RDPGFX_HEADER_SIZE + 12 + (pdu.monitorCount * 20));
|
2014-07-01 19:33:35 +04:00
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < pad)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-05 05:35:31 +04:00
|
|
|
Stream_Seek(s, pad); /* pad (total size is 340 bytes) */
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvResetGraphicsPdu: width: %d height: %d count: %d",
|
2014-06-03 23:32:03 +04:00
|
|
|
pdu.width, pdu.height, pdu.monitorCount);
|
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->ResetGraphics)
|
|
|
|
{
|
|
|
|
context->ResetGraphics(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-20 21:52:13 +04:00
|
|
|
free(pdu.monitorDefArray);
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
int rdpgfx_recv_evict_cache_entry_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_EVICT_CACHE_ENTRY_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 2)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvEvictCacheEntryPdu: cacheSlot: %d", pdu.cacheSlot);
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->EvictCacheEntry)
|
|
|
|
{
|
|
|
|
context->EvictCacheEntry(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
UINT16 index;
|
|
|
|
RDPGFX_CACHE_IMPORT_REPLY_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 2)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
Stream_Read_UINT16(s, pdu.importedEntriesCount); /* cacheSlot (2 bytes) */
|
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (pdu.importedEntriesCount * 2))
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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) */
|
|
|
|
}
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvCacheImportReplyPdu: importedEntriesCount: %d",
|
2014-06-04 03:48:47 +04:00
|
|
|
pdu.importedEntriesCount);
|
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->CacheImportReply)
|
|
|
|
{
|
|
|
|
context->CacheImportReply(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
free(pdu.cacheSlots);
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
int rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_CREATE_SURFACE_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-03 23:32:03 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 7)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, pdu.width); /* width (2 bytes) */
|
|
|
|
Stream_Read_UINT16(s, pdu.height); /* height (2 bytes) */
|
|
|
|
Stream_Read_UINT8(s, pdu.pixelFormat); /* RDPGFX_PIXELFORMAT (1 byte) */
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvCreateSurfacePdu: surfaceId: %d width: %d height: %d pixelFormat: 0x%02X",
|
2014-06-03 23:32:03 +04:00
|
|
|
pdu.surfaceId, pdu.width, pdu.height, pdu.pixelFormat);
|
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->CreateSurface)
|
|
|
|
{
|
|
|
|
context->CreateSurface(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
int rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_DELETE_SURFACE_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 2)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvDeleteSurfacePdu: surfaceId: %d", pdu.surfaceId);
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->DeleteSurface)
|
|
|
|
{
|
|
|
|
context->DeleteSurface(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
int rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_START_FRAME_PDU pdu;
|
2014-06-04 03:48:47 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2014-06-04 23:18:02 +04:00
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-03 23:32:03 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 8)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
Stream_Read_UINT32(s, pdu.timestamp); /* timestamp (4 bytes) */
|
|
|
|
Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvStartFramePdu: frameId: %d timestamp: 0x%04X\n",
|
2014-06-03 23:32:03 +04:00
|
|
|
pdu.frameId, pdu.timestamp);
|
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->StartFrame)
|
|
|
|
{
|
|
|
|
context->StartFrame(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
gfx->UnacknowledgedFrames++;
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_END_FRAME_PDU pdu;
|
2014-06-04 03:48:47 +04:00
|
|
|
RDPGFX_FRAME_ACKNOWLEDGE_PDU ack;
|
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2014-06-04 23:18:02 +04:00
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-03 23:32:03 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvEndFramePdu: frameId: %d\n", pdu.frameId);
|
2014-06-03 23:32:03 +04:00
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->EndFrame)
|
|
|
|
{
|
|
|
|
context->EndFrame(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
gfx->UnacknowledgedFrames--;
|
|
|
|
gfx->TotalDecodedFrames++;
|
|
|
|
|
|
|
|
ack.frameId = pdu.frameId;
|
|
|
|
ack.totalFramesDecoded = gfx->TotalDecodedFrames;
|
|
|
|
|
2014-06-05 20:36:01 +04:00
|
|
|
//ack.queueDepth = SUSPEND_FRAME_ACKNOWLEDGEMENT;
|
|
|
|
ack.queueDepth = QUEUE_DEPTH_UNAVAILABLE;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
|
|
|
rdpgfx_send_frame_acknowledge_pdu(callback, &ack);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
2014-06-04 04:51:28 +04:00
|
|
|
RDPGFX_SURFACE_COMMAND cmd;
|
2014-06-04 03:48:47 +04:00
|
|
|
RDPGFX_WIRE_TO_SURFACE_PDU_1 pdu;
|
2014-06-04 04:51:28 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2014-06-04 23:18:02 +04:00
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 17)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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) */
|
|
|
|
|
2014-06-04 04:51:28 +04:00
|
|
|
rdpgfx_read_rect16(s, &(pdu.destRect)); /* destRect (8 bytes) */
|
2014-06-04 03:48:47 +04:00
|
|
|
|
|
|
|
Stream_Read_UINT32(s, pdu.bitmapDataLength); /* bitmapDataLength (4 bytes) */
|
|
|
|
|
2014-06-13 05:02:25 +04:00
|
|
|
if (pdu.bitmapDataLength > Stream_GetRemainingLength(s))
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
pdu.bitmapData = Stream_Pointer(s);
|
2014-06-05 05:35:31 +04:00
|
|
|
Stream_Seek(s, pdu.bitmapDataLength);
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvWireToSurface1Pdu: surfaceId: %d codecId: %s (0x%04X) pixelFormat: 0x%04X "
|
|
|
|
"destRect: left: %d top: %d right: %d bottom: %d bitmapDataLength: %d",
|
2014-06-04 23:18:02 +04:00
|
|
|
(int) pdu.surfaceId, rdpgfx_get_codec_id_string(pdu.codecId), pdu.codecId, pdu.pixelFormat,
|
2014-06-04 03:48:47 +04:00
|
|
|
pdu.destRect.left, pdu.destRect.top, pdu.destRect.right, pdu.destRect.bottom,
|
|
|
|
pdu.bitmapDataLength);
|
|
|
|
|
2014-06-04 04:51:28 +04:00
|
|
|
cmd.surfaceId = pdu.surfaceId;
|
|
|
|
cmd.codecId = pdu.codecId;
|
2014-06-05 05:35:31 +04:00
|
|
|
cmd.contextId = 0;
|
|
|
|
cmd.format = pdu.pixelFormat;
|
|
|
|
cmd.left = pdu.destRect.left;
|
|
|
|
cmd.top = pdu.destRect.top;
|
|
|
|
cmd.right = pdu.destRect.right;
|
|
|
|
cmd.bottom = pdu.destRect.bottom;
|
2014-06-13 05:02:25 +04:00
|
|
|
cmd.width = cmd.right - cmd.left;
|
|
|
|
cmd.height = cmd.bottom - cmd.top;
|
2014-06-05 05:35:31 +04:00
|
|
|
cmd.length = pdu.bitmapDataLength;
|
|
|
|
cmd.data = pdu.bitmapData;
|
2014-06-04 04:51:28 +04:00
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->SurfaceCommand)
|
|
|
|
{
|
|
|
|
context->SurfaceCommand(context, &cmd);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
2014-06-04 04:51:28 +04:00
|
|
|
RDPGFX_SURFACE_COMMAND cmd;
|
2014-06-04 03:48:47 +04:00
|
|
|
RDPGFX_WIRE_TO_SURFACE_PDU_2 pdu;
|
2014-06-04 04:51:28 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2014-06-04 23:18:02 +04:00
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 13)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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) */
|
2014-06-04 04:51:28 +04:00
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
Stream_Read_UINT32(s, pdu.bitmapDataLength); /* bitmapDataLength (4 bytes) */
|
|
|
|
|
|
|
|
pdu.bitmapData = Stream_Pointer(s);
|
2014-06-05 05:35:31 +04:00
|
|
|
Stream_Seek(s, pdu.bitmapDataLength);
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvWireToSurface2Pdu: surfaceId: %d codecId: 0x%04X "
|
|
|
|
"codecContextId: %d pixelFormat: 0x%04X bitmapDataLength: %d",
|
2014-06-04 23:18:02 +04:00
|
|
|
(int) pdu.surfaceId, pdu.codecId, pdu.codecContextId, pdu.pixelFormat, pdu.bitmapDataLength);
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-06-04 04:51:28 +04:00
|
|
|
cmd.surfaceId = pdu.surfaceId;
|
|
|
|
cmd.codecId = pdu.codecId;
|
2014-06-05 05:35:31 +04:00
|
|
|
cmd.contextId = pdu.codecContextId;
|
|
|
|
cmd.format = pdu.pixelFormat;
|
|
|
|
cmd.left = 0;
|
|
|
|
cmd.top = 0;
|
|
|
|
cmd.right = 0;
|
|
|
|
cmd.bottom = 0;
|
|
|
|
cmd.width = 0;
|
|
|
|
cmd.height = 0;
|
|
|
|
cmd.length = pdu.bitmapDataLength;
|
|
|
|
cmd.data = pdu.bitmapData;
|
2014-06-04 04:51:28 +04:00
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->SurfaceCommand)
|
|
|
|
{
|
|
|
|
context->SurfaceCommand(context, &cmd);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdpgfx_recv_delete_encoding_context_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_DELETE_ENCODING_CONTEXT_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 6)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
|
|
|
|
Stream_Read_UINT32(s, pdu.codecContextId); /* codecContextId (4 bytes) */
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvDeleteEncodingContextPdu: surfaceId: %d codecContextId: %d",
|
2014-06-04 03:48:47 +04:00
|
|
|
pdu.surfaceId, pdu.codecContextId);
|
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->DeleteEncodingContext)
|
|
|
|
{
|
|
|
|
context->DeleteEncodingContext(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
UINT16 index;
|
|
|
|
RDPGFX_RECT16* fillRect;
|
|
|
|
RDPGFX_SOLID_FILL_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 8)
|
|
|
|
return -1;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
|
2014-06-04 03:48:47 +04:00
|
|
|
rdpgfx_read_color32(s, &(pdu.fillPixel)); /* fillPixel (4 bytes) */
|
|
|
|
Stream_Read_UINT16(s, pdu.fillRectCount); /* fillRectCount (2 bytes) */
|
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (pdu.fillRectCount * 8))
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvSolidFillPdu: surfaceId: %d fillRectCount: %d",
|
2014-06-04 03:48:47 +04:00
|
|
|
pdu.surfaceId, pdu.fillRectCount);
|
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->SolidFill)
|
|
|
|
{
|
|
|
|
context->SolidFill(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 14)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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) */
|
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (pdu.destPtsCount * 4))
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvSurfaceToSurfacePdu: surfaceIdSrc: %d surfaceIdDest: %d "
|
|
|
|
"left: %d top: %d right: %d bottom: %d destPtsCount: %d",
|
2014-06-04 03:48:47 +04:00
|
|
|
pdu.surfaceIdSrc, pdu.surfaceIdDest,
|
|
|
|
pdu.rectSrc.left, pdu.rectSrc.top, pdu.rectSrc.right, pdu.rectSrc.bottom,
|
|
|
|
pdu.destPtsCount);
|
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->SurfaceToSurface)
|
|
|
|
{
|
|
|
|
context->SurfaceToSurface(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_SURFACE_TO_CACHE_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 20)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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 ) */
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvSurfaceToCachePdu: surfaceId: %d cacheKey: 0x%08X cacheSlot: %d "
|
|
|
|
"left: %d top: %d right: %d bottom: %d",
|
2014-06-04 23:18:02 +04:00
|
|
|
pdu.surfaceId, (int) pdu.cacheKey, pdu.cacheSlot,
|
2014-06-04 03:48:47 +04:00
|
|
|
pdu.rectSrc.left, pdu.rectSrc.top,
|
|
|
|
pdu.rectSrc.right, pdu.rectSrc.bottom);
|
|
|
|
|
2014-06-04 23:18:02 +04:00
|
|
|
if (context && context->SurfaceToCache)
|
|
|
|
{
|
|
|
|
context->SurfaceToCache(context, &pdu);
|
|
|
|
}
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 6)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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) */
|
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < (pdu.destPtsCount * 4))
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RdpGfxRecvCacheToSurfacePdu: cacheSlot: %d surfaceId: %d destPtsCount: %d",
|
2014-06-04 23:18:02 +04:00
|
|
|
pdu.cacheSlot, (int) pdu.surfaceId, pdu.destPtsCount);
|
|
|
|
|
|
|
|
if (context && context->CacheToSurface)
|
|
|
|
{
|
|
|
|
context->CacheToSurface(context, &pdu);
|
|
|
|
}
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-06-20 21:52:13 +04:00
|
|
|
free(pdu.destPts);
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdpgfx_recv_map_surface_to_output_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 12)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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) */
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvMapSurfaceToOutputPdu: surfaceId: %d outputOriginX: %d outputOriginY: %d",
|
2014-06-04 23:18:02 +04:00
|
|
|
(int) pdu.surfaceId, pdu.outputOriginX, pdu.outputOriginY);
|
|
|
|
|
|
|
|
if (context && context->MapSurfaceToOutput)
|
|
|
|
{
|
|
|
|
context->MapSurfaceToOutput(context, &pdu);
|
|
|
|
}
|
2014-06-04 03:48:47 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
|
|
|
RDPGFX_MAP_SURFACE_TO_WINDOW_PDU pdu;
|
2014-06-04 23:18:02 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (Stream_GetRemainingLength(s) < 18)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
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) */
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "RecvMapSurfaceToWindowPdu: surfaceId: %d windowId: 0x%04X mappedWidth: %d mappedHeight: %d",
|
2014-06-04 23:18:02 +04:00
|
|
|
pdu.surfaceId, (int) pdu.windowId, pdu.mappedWidth, pdu.mappedHeight);
|
|
|
|
|
|
|
|
if (context && context->MapSurfaceToWindow)
|
|
|
|
{
|
|
|
|
context->MapSurfaceToWindow(context, &pdu);
|
|
|
|
}
|
2014-06-04 03:48:47 +04:00
|
|
|
|
2014-06-03 23:32:03 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2013-10-22 06:53:55 +04:00
|
|
|
int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
|
|
|
|
{
|
2014-06-03 23:32:03 +04:00
|
|
|
int status;
|
2014-06-05 05:35:31 +04:00
|
|
|
int beg, end;
|
2014-06-03 21:38:10 +04:00
|
|
|
RDPGFX_HEADER header;
|
2014-06-05 06:06:29 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2014-06-03 21:38:10 +04:00
|
|
|
|
2014-06-05 05:35:31 +04:00
|
|
|
beg = Stream_GetPosition(s);
|
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
status = rdpgfx_read_header(s, &header);
|
|
|
|
|
|
|
|
if (status < 0)
|
|
|
|
return -1;
|
2014-06-03 21:38:10 +04:00
|
|
|
|
2014-06-04 03:48:47 +04:00
|
|
|
#if 1
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "cmdId: %s (0x%04X) flags: 0x%04X pduLength: %d",
|
2014-06-04 04:51:28 +04:00
|
|
|
rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId, header.flags, header.pduLength);
|
2014-06-03 23:32:03 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (header.cmdId)
|
|
|
|
{
|
|
|
|
case RDPGFX_CMDID_WIRETOSURFACE_1:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_wire_to_surface_1_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_WIRETOSURFACE_2:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_wire_to_surface_2_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_DELETEENCODINGCONTEXT:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_delete_encoding_context_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_SOLIDFILL:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_solid_fill_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_SURFACETOSURFACE:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_surface_to_surface_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_SURFACETOCACHE:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_surface_to_cache_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_CACHETOSURFACE:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_cache_to_surface_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_EVICTCACHEENTRY:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_evict_cache_entry_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_CREATESURFACE:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_create_surface_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_DELETESURFACE:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_delete_surface_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_STARTFRAME:
|
|
|
|
status = rdpgfx_recv_start_frame_pdu(callback, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_ENDFRAME:
|
|
|
|
status = rdpgfx_recv_end_frame_pdu(callback, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_RESETGRAPHICS:
|
|
|
|
status = rdpgfx_recv_reset_graphics_pdu(callback, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_MAPSURFACETOOUTPUT:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_map_surface_to_output_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_CACHEIMPORTREPLY:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_cache_import_reply_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_CAPSCONFIRM:
|
|
|
|
status = rdpgfx_recv_caps_confirm_pdu(callback, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RDPGFX_CMDID_MAPSURFACETOWINDOW:
|
2014-06-04 03:48:47 +04:00
|
|
|
status = rdpgfx_recv_map_surface_to_window_pdu(callback, s);
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-07-01 19:33:35 +04:00
|
|
|
status = -1;
|
2014-06-03 23:32:03 +04:00
|
|
|
break;
|
|
|
|
}
|
2014-06-03 21:38:10 +04:00
|
|
|
|
2014-07-01 19:33:35 +04:00
|
|
|
if (status < 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error while parsing GFX cmdId: %s (0x%04X)\n",
|
|
|
|
rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-06-05 05:35:31 +04:00
|
|
|
end = Stream_GetPosition(s);
|
|
|
|
|
|
|
|
if (end != (beg + header.pduLength))
|
|
|
|
{
|
2014-06-05 06:06:29 +04:00
|
|
|
fprintf(stderr, "Unexpected gfx pdu end: Actual: %d, Expected: %d\n",
|
2014-06-05 05:35:31 +04:00
|
|
|
end, (beg + header.pduLength));
|
|
|
|
|
|
|
|
Stream_SetPosition(s, (beg + header.pduLength));
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
2013-10-22 06:53:55 +04:00
|
|
|
}
|
|
|
|
|
2014-06-11 21:06:19 +04:00
|
|
|
static int rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
|
2013-10-22 06:53:55 +04:00
|
|
|
{
|
|
|
|
wStream* s;
|
|
|
|
int status = 0;
|
2014-06-03 22:29:55 +04:00
|
|
|
UINT32 DstSize = 0;
|
|
|
|
BYTE* pDstData = NULL;
|
2013-10-22 06:53:55 +04:00
|
|
|
RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
|
2014-06-05 06:06:29 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2014-06-03 22:29:55 +04:00
|
|
|
|
2014-06-11 22:31:46 +04:00
|
|
|
status = zgfx_decompress(gfx->zgfx, Stream_Pointer(data), Stream_GetRemainingLength(data), &pDstData, &DstSize, 0);
|
2014-06-03 22:29:55 +04:00
|
|
|
|
|
|
|
if (status < 0)
|
|
|
|
{
|
|
|
|
printf("zgfx_decompress failure! status: %d\n", status);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = Stream_New(pDstData, DstSize);
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 05:35:31 +04:00
|
|
|
while (Stream_GetPosition(s) < Stream_Length(s))
|
|
|
|
{
|
|
|
|
status = rdpgfx_recv_pdu(callback, s);
|
2014-07-01 19:33:35 +04:00
|
|
|
|
|
|
|
if (status < 0)
|
|
|
|
break;
|
2014-06-05 05:35:31 +04:00
|
|
|
}
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-03 22:29:55 +04:00
|
|
|
Stream_Free(s, TRUE);
|
2013-10-22 06:53:55 +04:00
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2014-06-03 17:49:00 +04:00
|
|
|
static int rdpgfx_on_open(IWTSVirtualChannelCallback* pChannelCallback)
|
|
|
|
{
|
|
|
|
RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
|
2014-06-05 06:06:29 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2014-06-03 17:49:00 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "OnOpen");
|
2014-06-03 17:49:00 +04:00
|
|
|
|
|
|
|
rdpgfx_send_caps_advertise_pdu(callback);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-22 06:53:55 +04:00
|
|
|
static int rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback)
|
|
|
|
{
|
|
|
|
RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
|
2014-06-05 06:06:29 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "OnClose");
|
2014-06-03 08:05:43 +04:00
|
|
|
|
2013-10-22 06:53:55 +04:00
|
|
|
free(callback);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rdpgfx_on_new_channel_connection(IWTSListenerCallback* pListenerCallback,
|
|
|
|
IWTSVirtualChannel* pChannel, BYTE* Data, int* pbAccept,
|
|
|
|
IWTSVirtualChannelCallback** ppCallback)
|
|
|
|
{
|
|
|
|
RDPGFX_CHANNEL_CALLBACK* callback;
|
|
|
|
RDPGFX_LISTENER_CALLBACK* listener_callback = (RDPGFX_LISTENER_CALLBACK*) pListenerCallback;
|
|
|
|
|
2014-06-03 08:05:43 +04:00
|
|
|
callback = (RDPGFX_CHANNEL_CALLBACK*) calloc(1, sizeof(RDPGFX_CHANNEL_CALLBACK));
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
if (!callback)
|
|
|
|
return -1;
|
|
|
|
|
2013-10-22 06:53:55 +04:00
|
|
|
callback->iface.OnDataReceived = rdpgfx_on_data_received;
|
2014-06-03 17:49:00 +04:00
|
|
|
callback->iface.OnOpen = rdpgfx_on_open;
|
2013-10-22 06:53:55 +04:00
|
|
|
callback->iface.OnClose = rdpgfx_on_close;
|
|
|
|
callback->plugin = listener_callback->plugin;
|
|
|
|
callback->channel_mgr = listener_callback->channel_mgr;
|
|
|
|
callback->channel = pChannel;
|
|
|
|
listener_callback->channel_callback = callback;
|
|
|
|
|
|
|
|
*ppCallback = (IWTSVirtualChannelCallback*) callback;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rdpgfx_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr)
|
|
|
|
{
|
|
|
|
int status;
|
2014-06-05 06:06:29 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) pPlugin;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
gfx->listener_callback = (RDPGFX_LISTENER_CALLBACK*) calloc(1, sizeof(RDPGFX_LISTENER_CALLBACK));
|
2014-06-03 08:05:43 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
if (!gfx->listener_callback)
|
2014-06-03 08:05:43 +04:00
|
|
|
return -1;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
gfx->listener_callback->iface.OnNewChannelConnection = rdpgfx_on_new_channel_connection;
|
|
|
|
gfx->listener_callback->plugin = pPlugin;
|
|
|
|
gfx->listener_callback->channel_mgr = pChannelMgr;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
|
|
|
status = pChannelMgr->CreateListener(pChannelMgr, RDPGFX_DVC_CHANNEL_NAME, 0,
|
2014-06-05 06:06:29 +04:00
|
|
|
(IWTSListenerCallback*) gfx->listener_callback, &(gfx->listener));
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
gfx->listener->pInterface = gfx->iface.pInterface;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "Initialize");
|
2013-10-22 07:33:25 +04:00
|
|
|
|
2013-10-22 06:53:55 +04:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rdpgfx_plugin_terminated(IWTSPlugin* pPlugin)
|
|
|
|
{
|
2014-06-20 21:52:13 +04:00
|
|
|
int count;
|
|
|
|
int index;
|
|
|
|
ULONG_PTR* pKeys = NULL;
|
2014-06-05 06:06:29 +04:00
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) pPlugin;
|
2014-06-20 21:52:13 +04:00
|
|
|
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
WLog_Print(gfx->log, WLOG_DEBUG, "Terminated");
|
2014-06-03 22:29:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
if (gfx->listener_callback)
|
|
|
|
free(gfx->listener_callback);
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
zgfx_context_free(gfx->zgfx);
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-20 21:52:13 +04:00
|
|
|
count = HashTable_GetKeys(gfx->SurfaceTable, &pKeys);
|
|
|
|
|
|
|
|
for (index = 0; index < count; index++)
|
|
|
|
{
|
|
|
|
RDPGFX_DELETE_SURFACE_PDU pdu;
|
|
|
|
|
|
|
|
pdu.surfaceId = ((UINT16) pKeys[index]) - 1;
|
|
|
|
|
|
|
|
if (context && context->DeleteSurface)
|
|
|
|
{
|
|
|
|
context->DeleteSurface(context, &pdu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(pKeys);
|
|
|
|
|
2014-06-12 01:48:04 +04:00
|
|
|
HashTable_Free(gfx->SurfaceTable);
|
|
|
|
|
2014-06-20 21:52:13 +04:00
|
|
|
for (index = 0; index < gfx->MaxCacheSlot; index++)
|
|
|
|
{
|
|
|
|
if (gfx->CacheSlots[index])
|
|
|
|
{
|
|
|
|
RDPGFX_EVICT_CACHE_ENTRY_PDU pdu;
|
|
|
|
|
|
|
|
pdu.cacheSlot = (UINT16) index;
|
|
|
|
|
|
|
|
if (context && context->EvictCacheEntry)
|
|
|
|
{
|
|
|
|
context->EvictCacheEntry(context, &pdu);
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx->CacheSlots[index] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
free(gfx);
|
2013-10-22 06:53:55 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-06-12 01:48:04 +04:00
|
|
|
int rdpgfx_set_surface_data(RdpgfxClientContext* context, UINT16 surfaceId, void* pData)
|
|
|
|
{
|
|
|
|
ULONG_PTR key;
|
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle;
|
|
|
|
|
|
|
|
key = ((ULONG_PTR) surfaceId) + 1;
|
|
|
|
|
|
|
|
if (pData)
|
|
|
|
HashTable_Add(gfx->SurfaceTable, (void*) key, pData);
|
|
|
|
else
|
|
|
|
HashTable_Remove(gfx->SurfaceTable, (void*) key);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* rdpgfx_get_surface_data(RdpgfxClientContext* context, UINT16 surfaceId)
|
|
|
|
{
|
|
|
|
ULONG_PTR key;
|
|
|
|
void* pData = NULL;
|
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle;
|
|
|
|
|
|
|
|
key = ((ULONG_PTR) surfaceId) + 1;
|
|
|
|
|
|
|
|
pData = HashTable_GetItemValue(gfx->SurfaceTable, (void*) key);
|
|
|
|
|
|
|
|
return pData;
|
|
|
|
}
|
|
|
|
|
2014-06-13 16:36:09 +04:00
|
|
|
int rdpgfx_set_cache_slot_data(RdpgfxClientContext* context, UINT16 cacheSlot, void* pData)
|
|
|
|
{
|
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle;
|
|
|
|
|
|
|
|
if (cacheSlot >= gfx->MaxCacheSlot)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
gfx->CacheSlots[cacheSlot] = pData;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* rdpgfx_get_cache_slot_data(RdpgfxClientContext* context, UINT16 cacheSlot)
|
|
|
|
{
|
|
|
|
void* pData = NULL;
|
|
|
|
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) context->handle;
|
|
|
|
|
|
|
|
if (cacheSlot >= gfx->MaxCacheSlot)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pData = gfx->CacheSlots[cacheSlot];
|
|
|
|
|
|
|
|
return pData;
|
|
|
|
}
|
|
|
|
|
2013-10-22 06:53:55 +04:00
|
|
|
#ifdef STATIC_CHANNELS
|
|
|
|
#define DVCPluginEntry rdpgfx_DVCPluginEntry
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
|
|
|
|
{
|
2014-06-05 06:06:29 +04:00
|
|
|
int status = 0;
|
|
|
|
RDPGFX_PLUGIN* gfx;
|
2013-10-22 06:53:55 +04:00
|
|
|
RdpgfxClientContext* context;
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
gfx = (RDPGFX_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "rdpgfx");
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
if (!gfx)
|
2013-10-22 06:53:55 +04:00
|
|
|
{
|
2014-06-05 06:06:29 +04:00
|
|
|
gfx = (RDPGFX_PLUGIN*) calloc(1, sizeof(RDPGFX_PLUGIN));
|
2014-06-03 08:05:43 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
if (!gfx)
|
2014-06-03 08:05:43 +04:00
|
|
|
return -1;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
gfx->log = WLog_Get("com.freerdp.gfx.client");
|
|
|
|
|
|
|
|
gfx->iface.Initialize = rdpgfx_plugin_initialize;
|
|
|
|
gfx->iface.Connected = NULL;
|
|
|
|
gfx->iface.Disconnected = NULL;
|
|
|
|
gfx->iface.Terminated = rdpgfx_plugin_terminated;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-12 01:48:04 +04:00
|
|
|
gfx->SurfaceTable = HashTable_New(TRUE);
|
|
|
|
|
|
|
|
if (!gfx->SurfaceTable)
|
|
|
|
return -1;
|
|
|
|
|
2014-06-13 16:36:09 +04:00
|
|
|
gfx->ThinClient = TRUE;
|
|
|
|
gfx->MaxCacheSlot = (gfx->ThinClient) ? 4096 : 25600;
|
|
|
|
|
2014-06-03 08:05:43 +04:00
|
|
|
context = (RdpgfxClientContext*) calloc(1, sizeof(RdpgfxClientContext));
|
|
|
|
|
|
|
|
if (!context)
|
|
|
|
return -1;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
context->handle = (void*) gfx;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-12 01:48:04 +04:00
|
|
|
context->SetSurfaceData = rdpgfx_set_surface_data;
|
|
|
|
context->GetSurfaceData = rdpgfx_get_surface_data;
|
2014-06-13 16:36:09 +04:00
|
|
|
context->SetCacheSlotData = rdpgfx_set_cache_slot_data;
|
|
|
|
context->GetCacheSlotData = rdpgfx_get_cache_slot_data;
|
2014-06-12 01:48:04 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
gfx->iface.pInterface = (void*) context;
|
2013-10-22 06:53:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
gfx->zgfx = zgfx_context_new(FALSE);
|
2014-06-03 22:29:55 +04:00
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
status = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpgfx", (IWTSPlugin*) gfx);
|
2013-10-22 06:53:55 +04:00
|
|
|
}
|
|
|
|
|
2014-06-05 06:06:29 +04:00
|
|
|
return status;
|
2013-10-22 06:53:55 +04:00
|
|
|
}
|