typedef int (*pfnShadowEnumMonitors)(MONITOR_DEF* monitors, int maxMonitors);
-typedef int (*pfnShadowAuthenticate)(rdpShadowSubsystem* subsystem, rdpShadowClient* client,
- const char* user, const char* domain, const char* password);
-typedef BOOL (*pfnShadowClientConnect)(rdpShadowSubsystem* subsystem, rdpShadowClient* client);
-typedef void (*pfnShadowClientDisconnect)(rdpShadowSubsystem* subsystem, rdpShadowClient* client);
-typedef BOOL (*pfnShadowClientCapabilities)(rdpShadowSubsystem* subsystem, rdpShadowClient* client);
-
-typedef int (*pfnShadowSynchronizeEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client, UINT32 flags);
-typedef int (*pfnShadowKeyboardEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 code);
-typedef int (*pfnShadowUnicodeKeyboardEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 code);
-typedef int (*pfnShadowMouseEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y);
-typedef int (*pfnShadowExtendedMouseEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y);
-
-typedef void (*pfnShadowChannelAudinServerReceiveSamples)(rdpShadowSubsystem* subsystem, rdpShadowClient* client, const void* buf, int nframes);
+typedef int (*pfnShadowAuthenticate)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client,
+ const char* user, const char* domain, const char* password);
+typedef BOOL (*pfnShadowClientConnect)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client);
+typedef void (*pfnShadowClientDisconnect)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client);
+typedef BOOL (*pfnShadowClientCapabilities)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client);
+
+typedef int (*pfnShadowSynchronizeEvent)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT32 flags);
+typedef int (*pfnShadowKeyboardEvent)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 code);
+typedef int (*pfnShadowUnicodeKeyboardEvent)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 code);
+typedef int (*pfnShadowMouseEvent)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y);
+typedef int (*pfnShadowExtendedMouseEvent)(rdpShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y);
+
+typedef void (*pfnShadowChannelAudinServerReceiveSamples)(
+ rdpShadowSubsystem* subsystem, rdpShadowClient* client, const void* buf,
+ int nframes);
struct rdp_shadow_client
{
int width;
int height;
int scanline;
+ DWORD format;
BYTE* data;
CRITICAL_SECTION lock;
#define SHADOW_MSG_IN_REFRESH_REQUEST_ID 1001
typedef struct _SHADOW_MSG_OUT SHADOW_MSG_OUT;
-typedef void (*MSG_OUT_FREE_FN)(UINT32 id, SHADOW_MSG_OUT* msg); /* function to free SHADOW_MSG_OUT */
+typedef void (*MSG_OUT_FREE_FN)(UINT32 id,
+ SHADOW_MSG_OUT* msg); /* function to free SHADOW_MSG_OUT */
#define RDP_SHADOW_MSG_OUT_COMMON() \
int refCount; \
MSG_OUT_FREE_FN Free
UINT32 xPos;
UINT32 yPos;
};
-typedef struct _SHADOW_MSG_OUT_POINTER_POSITION_UPDATE SHADOW_MSG_OUT_POINTER_POSITION_UPDATE;
+typedef struct _SHADOW_MSG_OUT_POINTER_POSITION_UPDATE
+ SHADOW_MSG_OUT_POINTER_POSITION_UPDATE;
struct _SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE
{
BYTE* xorMaskData;
BYTE* andMaskData;
};
-typedef struct _SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE;
+typedef struct _SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE
+ SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE;
struct _SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES
{
int nFrames;
UINT16 wTimestamp;
};
-typedef struct _SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES;
+typedef struct _SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES
+ SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES;
struct _SHADOW_MSG_OUT_AUDIO_OUT_VOLUME
{
FREERDP_API void shadow_subsystem_set_entry_builtin(const char* name);
FREERDP_API void shadow_subsystem_set_entry(pfnShadowSubsystemEntry pEntry);
-FREERDP_API int shadow_subsystem_pointer_convert_alpha_pointer_data(BYTE* pixels, BOOL premultiplied,
- UINT32 width, UINT32 height, SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* pointerColor);
+FREERDP_API int shadow_subsystem_pointer_convert_alpha_pointer_data(
+ BYTE* pixels, BOOL premultiplied,
+ UINT32 width, UINT32 height, SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* pointerColor);
-FREERDP_API int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** argv);
-FREERDP_API int shadow_server_command_line_status_print(rdpShadowServer* server, int argc, char** argv, int status);
+FREERDP_API int shadow_server_parse_command_line(rdpShadowServer* server,
+ int argc, char** argv);
+FREERDP_API int shadow_server_command_line_status_print(rdpShadowServer* server,
+ int argc, char** argv, int status);
FREERDP_API int shadow_server_start(rdpShadowServer* server);
FREERDP_API int shadow_server_stop(rdpShadowServer* server);
FREERDP_API rdpShadowServer* shadow_server_new();
FREERDP_API void shadow_server_free(rdpShadowServer* server);
-FREERDP_API int shadow_capture_align_clip_rect(RECTANGLE_16* rect, RECTANGLE_16* clip);
-FREERDP_API int shadow_capture_compare(BYTE* pData1, int nStep1, int nWidth, int nHeight, BYTE* pData2, int nStep2, RECTANGLE_16* rect);
+FREERDP_API int shadow_capture_align_clip_rect(RECTANGLE_16* rect,
+ RECTANGLE_16* clip);
+FREERDP_API int shadow_capture_compare(BYTE* pData1, int nStep1, int nWidth,
+ int nHeight, BYTE* pData2, int nStep2, RECTANGLE_16* rect);
FREERDP_API void shadow_subsystem_frame_update(rdpShadowSubsystem* subsystem);
-FREERDP_API BOOL shadow_client_post_msg(rdpShadowClient* client, void* context, UINT32 type, SHADOW_MSG_OUT* msg, void* lParam);
-FREERDP_API int shadow_client_boardcast_msg(rdpShadowServer* server, void* context, UINT32 type, SHADOW_MSG_OUT* msg, void* lParam);
-FREERDP_API int shadow_client_boardcast_quit(rdpShadowServer* server, int nExitCode);
+FREERDP_API BOOL shadow_client_post_msg(rdpShadowClient* client, void* context,
+ UINT32 type, SHADOW_MSG_OUT* msg, void* lParam);
+FREERDP_API int shadow_client_boardcast_msg(rdpShadowServer* server,
+ void* context, UINT32 type, SHADOW_MSG_OUT* msg, void* lParam);
+FREERDP_API int shadow_client_boardcast_quit(rdpShadowServer* server,
+ int nExitCode);
FREERDP_API int shadow_encoder_preferred_fps(rdpShadowEncoder* encoder);
FREERDP_API UINT32 shadow_encoder_inflight_frames(rdpShadowEncoder* encoder);
{
PROFILER_CREATE(context->priv->prof_rfx_decode_rgb, "rfx_decode_rgb");
PROFILER_CREATE(context->priv->prof_rfx_decode_component,
- "rfx_decode_component");
+ "rfx_decode_component");
PROFILER_CREATE(context->priv->prof_rfx_rlgr_decode, "rfx_rlgr_decode");
PROFILER_CREATE(context->priv->prof_rfx_differential_decode,
- "rfx_differential_decode");
+ "rfx_differential_decode");
PROFILER_CREATE(context->priv->prof_rfx_quantization_decode,
- "rfx_quantization_decode");
+ "rfx_quantization_decode");
PROFILER_CREATE(context->priv->prof_rfx_dwt_2d_decode, "rfx_dwt_2d_decode");
PROFILER_CREATE(context->priv->prof_rfx_ycbcr_to_rgb, "prims->yCbCrToRGB");
PROFILER_CREATE(context->priv->prof_rfx_decode_format_rgb,
- "rfx_decode_format_rgb");
+ "rfx_decode_format_rgb");
PROFILER_CREATE(context->priv->prof_rfx_encode_rgb, "rfx_encode_rgb");
PROFILER_CREATE(context->priv->prof_rfx_encode_component,
- "rfx_encode_component");
+ "rfx_encode_component");
PROFILER_CREATE(context->priv->prof_rfx_rlgr_encode, "rfx_rlgr_encode");
PROFILER_CREATE(context->priv->prof_rfx_differential_encode,
- "rfx_differential_encode");
+ "rfx_differential_encode");
PROFILER_CREATE(context->priv->prof_rfx_quantization_encode,
- "rfx_quantization_encode");
+ "rfx_quantization_encode");
PROFILER_CREATE(context->priv->prof_rfx_dwt_2d_encode, "rfx_dwt_2d_encode");
PROFILER_CREATE(context->priv->prof_rfx_rgb_to_ycbcr, "prims->RGBToYCbCr");
PROFILER_CREATE(context->priv->prof_rfx_encode_format_rgb,
- "rfx_encode_format_rgb");
+ "rfx_encode_format_rgb");
}
static void rfx_profiler_free(RFX_CONTEXT* context)
verinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
GetVersionExA(&verinfo);
isVistaOrLater = ((verinfo.dwMajorVersion >= 6)
- && (verinfo.dwMinorVersion >= 0)) ? TRUE : FALSE;
+ && (verinfo.dwMinorVersion >= 0)) ? TRUE : FALSE;
priv->UseThreads = isVistaOrLater;
}
#else
priv->MinThreadCount = sysinfo.dwNumberOfProcessors;
priv->MaxThreadCount = 0;
status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, RFX_KEY, 0,
- KEY_READ | KEY_WOW64_64KEY, &hKey);
+ KEY_READ | KEY_WOW64_64KEY, &hKey);
if (status == ERROR_SUCCESS)
{
dwSize = sizeof(dwValue);
if (RegQueryValueEx(hKey, _T("UseThreads"), NULL, &dwType, (BYTE*) &dwValue,
- &dwSize) == ERROR_SUCCESS)
+ &dwSize) == ERROR_SUCCESS)
priv->UseThreads = dwValue ? 1 : 0;
if (RegQueryValueEx(hKey, _T("MinThreadCount"), NULL, &dwType, (BYTE*) &dwValue,
- &dwSize) == ERROR_SUCCESS)
+ &dwSize) == ERROR_SUCCESS)
priv->MinThreadCount = dwValue;
if (RegQueryValueEx(hKey, _T("MaxThreadCount"), NULL, &dwType, (BYTE*) &dwValue,
- &dwSize) == ERROR_SUCCESS)
+ &dwSize) == ERROR_SUCCESS)
priv->MaxThreadCount = dwValue;
RegCloseKey(hKey);
free(priv->tileWorkParams);
#ifdef WITH_PROFILER
WLog_VRB(TAG,
- "WARNING: Profiling results probably unusable with multithreaded RemoteFX codec!");
+ "WARNING: Profiling results probably unusable with multithreaded RemoteFX codec!");
#endif
}
}
Stream_Read_UINT16(s,
- context->version); /* version (2 bytes), WF_VERSION_1_0 (0x0100) */
+ context->version); /* version (2 bytes), WF_VERSION_1_0 (0x0100) */
if (context->version != WF_VERSION_1_0)
{
Stream_Read_UINT8(s, numCodecs); /* numCodecs (1 byte), must be set to 0x01 */
Stream_Read_UINT8(s,
- context->codec_id); /* codecId (1 byte), must be set to 0x01 */
+ context->codec_id); /* codecId (1 byte), must be set to 0x01 */
Stream_Read_UINT16(s,
- context->codec_version); /* version (2 bytes), must be set to WF_VERSION_1_0 (0x0100) */
+ context->codec_version); /* version (2 bytes), must be set to WF_VERSION_1_0 (0x0100) */
if (numCodecs != 1)
{
if (context->codec_version != WF_VERSION_1_0)
{
WLog_ERR(TAG, "%s: invalid codec version (0x%04X)", __FUNCTION__,
- context->codec_version);
+ context->codec_version);
return FALSE;
}
WLog_Print(context->priv->log, WLOG_DEBUG, "id %d version 0x%X.",
- context->codec_id, context->codec_version);
+ context->codec_id, context->codec_version);
context->decodedHeaderBlocks |= _RFX_DECODED_VERSIONS;
return TRUE;
}
}
Stream_Read_UINT8(s,
- numChannels); /* numChannels (1 byte), must bet set to 0x01 */
+ numChannels); /* numChannels (1 byte), must bet set to 0x01 */
/* In RDVH sessions, numChannels will represent the number of virtual monitors
* configured and does not always be set to 0x01 as [MS-RDPRFX] said.
if (Stream_GetRemainingLength(s) < (size_t)(numChannels * 5))
{
WLog_ERR(TAG, "RfxMessageChannels packet too small for numChannels=%d",
- numChannels);
+ numChannels);
return FALSE;
}
if (!context->width || !context->height)
{
WLog_ERR(TAG, "%s: invalid channel with/height: %ux%u", __FUNCTION__,
- context->width, context->height);
+ context->width, context->height);
return FALSE;
}
/* Now, only the first monitor can be used, therefore the other channels will be ignored. */
Stream_Seek(s, 5 * (numChannels - 1));
WLog_Print(context->priv->log, WLOG_DEBUG, "numChannels %d id %d, %dx%d.",
- numChannels, channelId, context->width, context->height);
+ numChannels, channelId, context->width, context->height);
context->decodedHeaderBlocks |= _RFX_DECODED_CHANNELS;
return TRUE;
}
Stream_Read_UINT8(s, ctxId); /* ctxId (1 byte), must be set to 0x00 */
Stream_Read_UINT16(s,
- tileSize); /* tileSize (2 bytes), must be set to CT_TILE_64x64 (0x0040) */
+ tileSize); /* tileSize (2 bytes), must be set to CT_TILE_64x64 (0x0040) */
Stream_Read_UINT16(s, properties); /* properties (2 bytes) */
WLog_Print(context->priv->log, WLOG_DEBUG,
- "ctxId %d tileSize %d properties 0x%X.",
- ctxId, tileSize, properties);
+ "ctxId %d tileSize %d properties 0x%X.",
+ ctxId, tileSize, properties);
context->properties = properties;
context->flags = (properties & 0x0007);
}
static BOOL rfx_process_message_frame_begin(RFX_CONTEXT* context,
- RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
+ RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
{
UINT32 frameIdx;
UINT16 numRegions;
}
Stream_Read_UINT32(s,
- frameIdx); /* frameIdx (4 bytes), if codec is in video mode, must be ignored */
+ frameIdx); /* frameIdx (4 bytes), if codec is in video mode, must be ignored */
Stream_Read_UINT16(s, numRegions); /* numRegions (2 bytes) */
WLog_Print(context->priv->log, WLOG_DEBUG,
- "RFX_FRAME_BEGIN: frameIdx: %d numRegions: %d", frameIdx, numRegions);
+ "RFX_FRAME_BEGIN: frameIdx: %d numRegions: %d", frameIdx, numRegions);
return TRUE;
}
static BOOL rfx_process_message_frame_end(RFX_CONTEXT* context,
- RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
+ RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
{
if (*pExpectedBlockType != WBT_FRAME_END)
{
}
static BOOL rfx_process_message_region(RFX_CONTEXT* context,
- RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
+ RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
{
int i;
UINT16 regionType;
if (Stream_GetRemainingLength(s) < (size_t)(8 * message->numRects))
{
WLog_ERR(TAG, "%s: packet too small for num_rects=%d", __FUNCTION__,
- message->numRects);
+ message->numRects);
return FALSE;
}
for (i = 0; i < message->numRects; i++)
{
RFX_RECT* rect = rfx_message_get_rect(message, i);
-
/* RFX_RECT */
Stream_Read_UINT16(s, rect->x); /* x (2 bytes) */
Stream_Read_UINT16(s, rect->y); /* y (2 bytes) */
Stream_Read_UINT16(s, rect->width); /* width (2 bytes) */
Stream_Read_UINT16(s, rect->height); /* height (2 bytes) */
WLog_Print(context->priv->log, WLOG_DEBUG, "rect %d (x,y=%d,%d w,h=%d %d).", i,
- rect->x, rect->y,
- rect->width, rect->height);
+ rect->x, rect->y,
+ rect->width, rect->height);
}
if (Stream_GetRemainingLength(s) < 4)
}
Stream_Read_UINT16(s,
- regionType); /* regionType (2 bytes): MUST be set to CBT_REGION (0xCAC1) */
+ regionType); /* regionType (2 bytes): MUST be set to CBT_REGION (0xCAC1) */
Stream_Read_UINT16(s,
- numTileSets); /* numTilesets (2 bytes): MUST be set to 0x0001. */
+ numTileSets); /* numTilesets (2 bytes): MUST be set to 0x0001. */
if (regionType != CBT_REGION)
{
}
static BOOL rfx_process_message_tileset(RFX_CONTEXT* context,
- RFX_MESSAGE* message, wStream* s, UINT16* pExpecedBlockType)
+ RFX_MESSAGE* message, wStream* s, UINT16* pExpecedBlockType)
{
BOOL rc;
int i, close_cnt;
}
Stream_Read_UINT16(s,
- subtype); /* subtype (2 bytes) must be set to CBT_TILESET (0xCAC2) */
+ subtype); /* subtype (2 bytes) must be set to CBT_TILESET (0xCAC2) */
if (subtype != CBT_TILESET)
{
Stream_Read_UINT32(s, tilesDataSize); /* tilesDataSize (4 bytes) */
if (!(pmem = realloc((void*) context->quants,
- context->numQuant * 10 * sizeof(UINT32))))
+ context->numQuant * 10 * sizeof(UINT32))))
return FALSE;
quants = context->quants = (UINT32*) pmem;
if (Stream_GetRemainingLength(s) < (size_t)(context->numQuant * 5))
{
WLog_ERR(TAG, "RfxMessageTileSet packet too small for num_quants=%d",
- context->numQuant);
+ context->numQuant);
return FALSE;
}
*quants++ = (quant & 0x0F);
*quants++ = (quant >> 4);
WLog_Print(context->priv->log, WLOG_DEBUG,
- "quant %d (%d %d %d %d %d %d %d %d %d %d).",
- i, context->quants[i * 10], context->quants[i * 10 + 1],
- context->quants[i * 10 + 2], context->quants[i * 10 + 3],
- context->quants[i * 10 + 4], context->quants[i * 10 + 5],
- context->quants[i * 10 + 6], context->quants[i * 10 + 7],
- context->quants[i * 10 + 8], context->quants[i * 10 + 9]);
+ "quant %d (%d %d %d %d %d %d %d %d %d %d).",
+ i, context->quants[i * 10], context->quants[i * 10 + 1],
+ context->quants[i * 10 + 2], context->quants[i * 10 + 3],
+ context->quants[i * 10 + 4], context->quants[i * 10 + 5],
+ context->quants[i * 10 + 6], context->quants[i * 10 + 7],
+ context->quants[i * 10 + 8], context->quants[i * 10 + 9]);
}
if (!(message->tiles = (RFX_TILE**) calloc(message->numTiles,
- sizeof(RFX_TILE*))))
+ sizeof(RFX_TILE*))))
{
message->numTiles = 0;
return FALSE;
{
work_objects = (PTP_WORK*) calloc(message->numTiles, sizeof(PTP_WORK));
params = (RFX_TILE_PROCESS_WORK_PARAM*) calloc(message->numTiles,
- sizeof(RFX_TILE_PROCESS_WORK_PARAM));
+ sizeof(RFX_TILE_PROCESS_WORK_PARAM));
if (!work_objects)
{
if (Stream_GetRemainingLength(s) < 6)
{
WLog_ERR(TAG, "RfxMessageTileSet packet too small to read tile %d/%d", i,
- message->numTiles);
+ message->numTiles);
rc = FALSE;
break;
}
Stream_Read_UINT16(s,
- blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */
+ blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */
Stream_Read_UINT32(s, blockLen); /* blockLen (4 bytes) */
if (Stream_GetRemainingLength(s) < blockLen - 6)
{
WLog_ERR(TAG,
- "RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d",
- i, message->numTiles, blockLen);
+ "RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d",
+ i, message->numTiles, blockLen);
rc = FALSE;
break;
}
if (blockType != CBT_TILE)
{
WLog_ERR(TAG, "unknown block type 0x%X, expected CBT_TILE (0xCAC3).",
- blockType);
+ blockType);
rc = FALSE;
break;
}
params[i].tile = message->tiles[i];
if (!(work_objects[i] = CreateThreadpoolWork((PTP_WORK_CALLBACK)
- rfx_process_message_tile_work_callback,
- (void*) ¶ms[i], &context->priv->ThreadPoolEnv)))
+ rfx_process_message_tile_work_callback,
+ (void*) ¶ms[i], &context->priv->ThreadPoolEnv)))
{
WLog_ERR(TAG, "CreateThreadpoolWork failed.");
rc = FALSE;
}
BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data,
- UINT32 format, UINT32 length,
- UINT32 left, UINT32 top,
- BYTE* dst, UINT32 dstFormat,
- UINT32 dstStride, UINT32 dstHeight,
- REGION16* invalidRegion)
+ UINT32 format, UINT32 length,
+ UINT32 left, UINT32 top,
+ BYTE* dst, UINT32 dstFormat,
+ UINT32 dstStride, UINT32 dstHeight,
+ REGION16* invalidRegion)
{
int pos;
REGION16 updateRegion;
Stream_Read_UINT16(s, blockType); /* blockType (2 bytes) */
Stream_Read_UINT32(s, blockLen); /* blockLen (4 bytes) */
WLog_Print(context->priv->log, WLOG_DEBUG, "blockType 0x%X blockLen %d",
- blockType, blockLen);
+ blockType, blockLen);
if (blockLen == 0)
{
Stream_Read_UINT8(s, codecId); /* codecId (1 byte) must be set to 0x01 */
Stream_Read_UINT8(s,
- channelId); /* channelId (1 byte) 0xFF or 0x00, see below */
+ channelId); /* channelId (1 byte) 0xFF or 0x00, see below */
if (codecId != 0x01)
{
if (channelId != 0xFF)
{
WLog_ERR(TAG, "%s: invalid channelId 0x%02X for blockType 0x%04X", __FUNCTION__,
- channelId, blockType);
+ channelId, blockType);
goto fail;
}
}
if (channelId != 0x00)
{
WLog_ERR(TAG, "%s: invalid channelId 0x%02X for blockType WBT_CONTEXT",
- __FUNCTION__, channelId);
+ __FUNCTION__, channelId);
goto fail;
}
}
case WBT_FRAME_BEGIN:
ok = rfx_process_message_frame_begin(context, message, s,
- &expectedDataBlockType);
+ &expectedDataBlockType);
break;
case WBT_REGION:
UINT32 nbUpdateRects;
REGION16 clippingRects;
const RECTANGLE_16* updateRects;
-
region16_init(&clippingRects);
for (i = 0; i < message->numRects; i++)
{
RECTANGLE_16 updateRect;
const RFX_TILE* tile = rfx_message_get_tile(message, i);
-
updateRect.left = left + tile->x;
updateRect.top = top + tile->y;
updateRect.right = updateRect.left + 64;
UINT32 nYDst = updateRects[j].top;
UINT32 nWidth = updateRects[j].right - updateRects[j].left;
UINT32 nHeight = updateRects[j].bottom - updateRects[j].top;
+
if (!freerdp_image_copy(dst, dstFormat, dstStride,
- nXDst, nYDst, nWidth, nHeight,
- tile->data, format, 64 * GetBytesPerPixel(format), 0, 0, NULL))
+ nXDst, nYDst, nWidth, nHeight,
+ tile->data, format, 64 * GetBytesPerPixel(format), 0, 0, NULL))
goto fail;
if (invalidRegion)
properties |= (COL_CONV_ICT << 4); /* cct */
properties |= (CLW_XFORM_DWT_53_A << 6); /* xft */
properties |= ((context->mode == RLGR1 ? CLW_ENTROPY_RLGR1 : CLW_ENTROPY_RLGR3)
- << 10); /* et */
+ << 10); /* et */
properties |= (SCALAR_QUANTIZATION << 14); /* qt */
context->properties = properties;
}
properties |= (COL_CONV_ICT << 3); /* cct */
properties |= (CLW_XFORM_DWT_53_A << 5); /* xft */
properties |= ((context->mode == RLGR1 ? CLW_ENTROPY_RLGR1 : CLW_ENTROPY_RLGR3)
- << 9); /* et */
+ << 9); /* et */
properties |= (SCALAR_QUANTIZATION << 13); /* qt */
Stream_Write_UINT16(s, properties); /* properties (2 bytes) */
rfx_update_context_properties(context);
};
void CALLBACK rfx_compose_message_tile_work_callback(PTP_CALLBACK_INSTANCE
- instance, void* context, PTP_WORK work)
+ instance, void* context, PTP_WORK work)
{
RFX_TILE_COMPOSE_WORK_PARAM* param = (RFX_TILE_COMPOSE_WORK_PARAM*) context;
rfx_encode_rgb(param->context, param->tile);
static BOOL computeRegion(const RFX_RECT* rects, int numRects, REGION16* region,
- int width, int height)
+ int width, int height)
{
int i;
const RFX_RECT* rect = rects;
priv->workObjects = (PTP_WORK*) pmem;
if (!(pmem = realloc((void*) priv->tileWorkParams,
- sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * nbTiles)))
+ sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * nbTiles)))
return FALSE;
priv->tileWorkParams = (RFX_TILE_COMPOSE_WORK_PARAM*) pmem;
}
RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
- int numRects,
- BYTE* data, int width, int height, int scanline)
+ int numRects,
+ BYTE* data, int width, int height, int scanline)
{
UINT32 i, maxNbTiles, maxTilesX, maxTilesY;
UINT32 xIdx, yIdx, regionNbRects;
if (!context->numQuant)
{
if (!(context->quants = (UINT32*) malloc(sizeof(
- rfx_default_quantization_values))))
+ rfx_default_quantization_values))))
goto skip_encoding_loop;
CopyMemory(context->quants, &rfx_default_quantization_values,
- sizeof(rfx_default_quantization_values));
+ sizeof(rfx_default_quantization_values));
context->numQuant = 1;
context->quantIdxY = 0;
context->quantIdxCb = 0;
workParam->tile = tile;
if (!(*workObject = CreateThreadpoolWork(
- (PTP_WORK_CALLBACK)rfx_compose_message_tile_work_callback,
- (void*) workParam,
- &context->priv->ThreadPoolEnv)))
+ (PTP_WORK_CALLBACK)rfx_compose_message_tile_work_callback,
+ (void*) workParam,
+ &context->priv->ThreadPoolEnv)))
{
goto skip_encoding_loop;
}
if (message->numTiles > 0)
{
void* pmem = realloc((void*) message->tiles,
- sizeof(RFX_TILE*) * message->numTiles);
+ sizeof(RFX_TILE*) * message->numTiles);
if (pmem)
message->tiles = (RFX_TILE**) pmem;
}
RFX_MESSAGE* rfx_split_message(RFX_CONTEXT* context, RFX_MESSAGE* message,
- int* numMessages, int maxDataSize)
+ int* numMessages, int maxDataSize)
{
int i, j;
UINT32 tileDataSize;
messages[j].freeArray = TRUE;
if (!(messages[j].tiles = (RFX_TILE**) calloc(message->numTiles,
- sizeof(RFX_TILE*))))
+ sizeof(RFX_TILE*))))
goto free_messages;
}
}
RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects,
- int numRects,
- BYTE* data, int width, int height, int scanline, int* numMessages,
- int maxDataSize)
+ int numRects,
+ BYTE* data, int width, int height, int scanline, int* numMessages,
+ int maxDataSize)
{
RFX_MESSAGE* message;
RFX_MESSAGE* messageList;
if (!(message = rfx_encode_message(context, rects, numRects, data, width,
- height, scanline)))
+ height, scanline)))
return NULL;
if (!(messageList = rfx_split_message(context, message, numMessages,
- maxDataSize)))
+ maxDataSize)))
{
message->freeRects = TRUE;
rfx_message_free(context, message);
}
static BOOL rfx_write_message_tileset(RFX_CONTEXT* context, wStream* s,
- RFX_MESSAGE* message)
+ RFX_MESSAGE* message)
{
int i;
RFX_TILE* tile;
#ifdef WITH_DEBUG_RFX
WLog_Print(context->priv->log, WLOG_DEBUG,
- "numQuant: %d numTiles: %d tilesDataSize: %d",
- message->numQuant, message->numTiles, message->tilesDataSize);
+ "numQuant: %d numTiles: %d tilesDataSize: %d",
+ message->numQuant, message->numTiles, message->tilesDataSize);
#endif
return TRUE;
}
static BOOL rfx_write_message_frame_begin(RFX_CONTEXT* context, wStream* s,
- RFX_MESSAGE* message)
+ RFX_MESSAGE* message)
{
if (!Stream_EnsureRemainingCapacity(s, 14))
return FALSE;
}
static BOOL rfx_write_message_region(RFX_CONTEXT* context, wStream* s,
- RFX_MESSAGE* message)
+ RFX_MESSAGE* message)
{
int i;
UINT32 blockLen;
for (i = 0; i < message->numRects; i++)
{
const RFX_RECT* rect = rfx_message_get_rect(message, i);
-
/* Clipping rectangles are relative to destLeft, destTop */
Stream_Write_UINT16(s, rect->x); /* x (2 bytes) */
Stream_Write_UINT16(s, rect->y); /* y (2 bytes) */
}
BOOL rfx_write_message_frame_end(RFX_CONTEXT* context, wStream* s,
- RFX_MESSAGE* message)
+ RFX_MESSAGE* message)
{
if (!Stream_EnsureRemainingCapacity(s, 8))
return FALSE;
}
BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s,
- const RFX_RECT* rects, int numRects, BYTE* data, int width, int height,
- int scanline)
+ const RFX_RECT* rects, int numRects, BYTE* data, int width, int height,
+ int scanline)
{
RFX_MESSAGE* message;
BOOL ret = TRUE;
if (!(message = rfx_encode_message(context, rects, numRects, data, width,
- height, scanline)))
+ height, scanline)))
return FALSE;
ret = rfx_write_message(context, s, message);
static void mac_shadow_input_synchronize_event(macShadowSubsystem* subsystem,
rdpShadowClient* client, UINT32 flags)
{
-
}
static void mac_shadow_input_keyboard_event(macShadowSubsystem* subsystem,
BOOL extended;
CGEventRef kbdEvent;
CGEventSourceRef source;
-
extended = (flags & KBD_FLAGS_EXTENDED) ? TRUE : FALSE;
-
+
if (extended)
code |= KBDEXT;
-
+
vkcode = GetVirtualKeyCodeFromVirtualScanCode(code, 4);
-
+
if (extended)
vkcode |= KBDEXT;
-
+
keycode = GetKeycodeFromVirtualKeyCode(vkcode, KEYCODE_TYPE_APPLE);
-
+
if (keycode < 8)
return;
-
- keycode -= 8;
+ keycode -= 8;
source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
-
+
if (flags & KBD_FLAGS_DOWN)
{
kbdEvent = CGEventCreateKeyboardEvent(source, (CGKeyCode) keycode, TRUE);
CGEventPost(kCGHIDEventTap, kbdEvent);
CFRelease(kbdEvent);
}
-
+
CFRelease(source);
}
static void mac_shadow_input_unicode_keyboard_event(macShadowSubsystem*
subsystem, rdpShadowClient* client, UINT16 flags, UINT16 code)
{
-
}
static void mac_shadow_input_mouse_event(macShadowSubsystem* subsystem,
UINT32 scrollX = 0;
UINT32 scrollY = 0;
CGWheelCount wheelCount = 2;
-
+
if (flags & PTR_FLAGS_WHEEL)
{
scrollY = flags & WheelRotationMask;
-
+
if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
{
scrollY = -(flags & WheelRotationMask) / 392;
{
scrollY = (flags & WheelRotationMask) / 120;
}
-
- CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
- CGEventRef scroll = CGEventCreateScrollWheelEvent(source, kCGScrollEventUnitLine,
- wheelCount, scrollY, scrollX);
+
+ CGEventSourceRef source = CGEventSourceCreate(
+ kCGEventSourceStateHIDSystemState);
+ CGEventRef scroll = CGEventCreateScrollWheelEvent(source,
+ kCGScrollEventUnitLine,
+ wheelCount, scrollY, scrollX);
CGEventPost(kCGHIDEventTap, scroll);
-
CFRelease(scroll);
CFRelease(source);
}
else
{
- CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
+ CGEventSourceRef source = CGEventSourceCreate(
+ kCGEventSourceStateHIDSystemState);
CGEventType mouseType = kCGEventNull;
CGMouseButton mouseButton = kCGMouseButtonLeft;
-
+
if (flags & PTR_FLAGS_MOVE)
{
if (subsystem->mouseDownLeft)
mouseType = kCGEventOtherMouseDragged;
else
mouseType = kCGEventMouseMoved;
-
- CGEventRef move = CGEventCreateMouseEvent(source, mouseType, CGPointMake(x, y), mouseButton);
+
+ CGEventRef move = CGEventCreateMouseEvent(source, mouseType, CGPointMake(x, y),
+ mouseButton);
CGEventPost(kCGHIDEventTap, move);
CFRelease(move);
}
-
+
if (flags & PTR_FLAGS_BUTTON1)
{
mouseButton = kCGMouseButtonLeft;
-
+
if (flags & PTR_FLAGS_DOWN)
{
mouseType = kCGEventLeftMouseDown;
else if (flags & PTR_FLAGS_BUTTON2)
{
mouseButton = kCGMouseButtonRight;
-
+
if (flags & PTR_FLAGS_DOWN)
{
mouseType = kCGEventRightMouseDown;
mouseType = kCGEventRightMouseUp;
subsystem->mouseDownRight = FALSE;
}
-
}
else if (flags & PTR_FLAGS_BUTTON3)
{
mouseButton = kCGMouseButtonCenter;
-
+
if (flags & PTR_FLAGS_DOWN)
{
mouseType = kCGEventOtherMouseDown;
subsystem->mouseDownOther = FALSE;
}
}
-
- CGEventRef mouseEvent = CGEventCreateMouseEvent(source, mouseType, CGPointMake(x, y), mouseButton);
+
+ CGEventRef mouseEvent = CGEventCreateMouseEvent(source, mouseType,
+ CGPointMake(x, y), mouseButton);
CGEventPost(kCGHIDEventTap, mouseEvent);
-
CFRelease(mouseEvent);
CFRelease(source);
}
static void mac_shadow_input_extended_mouse_event(macShadowSubsystem* subsystem,
rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
{
-
}
static int mac_shadow_detect_monitors(macShadowSubsystem* subsystem)
size_t wide, high;
MONITOR_DEF* monitor;
CGDirectDisplayID displayId;
-
displayId = CGMainDisplayID();
-
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayId);
-
subsystem->pixelWidth = CGDisplayModeGetPixelWidth(mode);
subsystem->pixelHeight = CGDisplayModeGetPixelHeight(mode);
-
wide = CGDisplayPixelsWide(displayId);
high = CGDisplayPixelsHigh(displayId);
-
CGDisplayModeRelease(mode);
-
subsystem->retina = ((subsystem->pixelWidth / wide) == 2) ? TRUE : FALSE;
-
+
if (subsystem->retina)
{
subsystem->width = wide;
subsystem->width = subsystem->pixelWidth;
subsystem->height = subsystem->pixelHeight;
}
-
+
subsystem->numMonitors = 1;
-
monitor = &(subsystem->monitors[0]);
-
monitor->left = 0;
monitor->top = 0;
monitor->right = subsystem->width;
monitor->bottom = subsystem->height;
monitor->flags = 1;
-
return 1;
}
static int mac_shadow_capture_start(macShadowSubsystem* subsystem)
{
CGError err;
-
err = CGDisplayStreamStart(subsystem->stream);
-
+
if (err != kCGErrorSuccess)
return -1;
-
+
return 1;
}
static int mac_shadow_capture_stop(macShadowSubsystem* subsystem)
{
CGError err;
-
err = CGDisplayStreamStop(subsystem->stream);
-
+
if (err != kCGErrorSuccess)
return -1;
-
+
return 1;
}
const CGRect* rects;
RECTANGLE_16 invalidRect;
rdpShadowSurface* surface = subsystem->server->surface;
-
- rects = CGDisplayStreamUpdateGetRects(subsystem->lastUpdate, kCGDisplayStreamUpdateDirtyRects, &numRects);
-
+ rects = CGDisplayStreamUpdateGetRects(subsystem->lastUpdate,
+ kCGDisplayStreamUpdateDirtyRects, &numRects);
+
if (!numRects)
return -1;
-
+
for (index = 0; index < numRects; index++)
{
invalidRect.left = (UINT16) rects[index].origin.x;
invalidRect.top = (UINT16) rects[index].origin.y;
invalidRect.right = invalidRect.left + (UINT16) rects[index].size.width;
invalidRect.bottom = invalidRect.top + (UINT16) rects[index].size.height;
-
+
if (subsystem->retina)
{
/* scale invalid rect */
invalidRect.right /= 2;
invalidRect.bottom /= 2;
}
-
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
+
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &invalidRect);
}
-
+
return 0;
}
macShadowSubsystem* subsystem = g_Subsystem;
rdpShadowServer* server = subsystem->server;
rdpShadowSurface* surface = server->surface;
-
count = ArrayList_Count(server->clients);
-
+
if (count < 1)
return;
mac_shadow_capture_get_dirty_region(subsystem);
-
surfaceRect.left = 0;
surfaceRect.top = 0;
surfaceRect.right = surface->width;
surfaceRect.bottom = surface->height;
-
- region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion), &surfaceRect);
-
+ region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &surfaceRect);
+
if (!region16_is_empty(&(surface->invalidRegion)))
{
extents = region16_extents(&(surface->invalidRegion));
-
x = extents->left;
y = extents->top;
width = extents->right - extents->left;
height = extents->bottom - extents->top;
-
IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, NULL);
-
pSrcData = (BYTE*) IOSurfaceGetBaseAddress(frameSurface);
nSrcStep = (int) IOSurfaceGetBytesPerRow(frameSurface);
if (subsystem->retina)
{
- freerdp_image_copy_from_retina(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline,
- x, y, width, height, pSrcData, nSrcStep, x, y);
+ freerdp_image_copy_from_retina(surface->data, surface->format,
+ surface->scanline,
+ x, y, width, height, pSrcData, nSrcStep, x, y);
}
else
{
- freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline,
- x, y, width, height, pSrcData, PIXEL_FORMAT_XRGB32, nSrcStep, x, y, NULL);
+ freerdp_image_copy(surface->data, surface->format, surface->scanline,
+ x, y, width, height, pSrcData, PIXEL_FORMAT_BGRX32, nSrcStep, x, y, NULL);
}
-
+
IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, NULL);
-
ArrayList_Lock(server->clients);
-
count = ArrayList_Count(server->clients);
-
EnterCriticalSection(&(surface->lock));
- shadow_subsystem_frame_update((rdpShadowSubsystem *)subsystem);
+ shadow_subsystem_frame_update((rdpShadowSubsystem*)subsystem);
LeaveCriticalSection(&(surface->lock));
-
+
if (count == 1)
{
rdpShadowClient* client;
-
client = (rdpShadowClient*) ArrayList_GetItem(server->clients, 0);
-
+
if (client)
{
subsystem->captureFrameRate = shadow_encoder_preferred_fps(client->encoder);
}
}
-
+
ArrayList_Unlock(server->clients);
-
region16_clear(&(surface->invalidRegion));
}
-
+
if (status != kCGDisplayStreamFrameStatusFrameComplete)
{
switch (status)
{
case kCGDisplayStreamFrameStatusFrameIdle:
break;
-
+
case kCGDisplayStreamFrameStatusStopped:
break;
-
+
case kCGDisplayStreamFrameStatusFrameBlank:
break;
-
+
default:
break;
}
else
{
CGDisplayStreamUpdateRef tmpRef = subsystem->lastUpdate;
- subsystem->lastUpdate = CGDisplayStreamUpdateCreateMergedUpdate(tmpRef, updateRef);
+ subsystem->lastUpdate = CGDisplayStreamUpdateCreateMergedUpdate(tmpRef,
+ updateRef);
CFRelease(tmpRef);
}
};
void* values[2];
CFDictionaryRef opts;
CGDirectDisplayID displayId;
-
displayId = CGMainDisplayID();
-
- subsystem->updateBuffer = (BYTE*) malloc(subsystem->pixelWidth * subsystem->pixelHeight * 4);
-
+ subsystem->updateBuffer = (BYTE*) malloc(subsystem->pixelWidth *
+ subsystem->pixelHeight * 4);
+
if (!subsystem->updateBuffer)
return -1;
-
+
subsystem->captureQueue = dispatch_queue_create("mac.shadow.capture", NULL);
-
keys[0] = (void*) kCGDisplayStreamShowCursor;
values[0] = (void*) kCFBooleanFalse;
-
- opts = CFDictionaryCreate(kCFAllocatorDefault, (const void**) keys, (const void**) values, 1, NULL, NULL);
-
- subsystem->stream = CGDisplayStreamCreateWithDispatchQueue(displayId, subsystem->pixelWidth, subsystem->pixelHeight,
- 'BGRA', opts, subsystem->captureQueue, mac_capture_stream_handler);
-
+ opts = CFDictionaryCreate(kCFAllocatorDefault, (const void**) keys,
+ (const void**) values, 1, NULL, NULL);
+ subsystem->stream = CGDisplayStreamCreateWithDispatchQueue(displayId,
+ subsystem->pixelWidth, subsystem->pixelHeight,
+ 'BGRA', opts, subsystem->captureQueue, mac_capture_stream_handler);
CFRelease(opts);
-
return 1;
}
static int mac_shadow_subsystem_process_message(macShadowSubsystem* subsystem,
wMessage* message)
{
- switch(message->id)
+ switch (message->id)
{
case SHADOW_MSG_IN_REFRESH_REQUEST_ID:
EnterCriticalSection(&(surface->lock));
- shadow_subsystem_frame_update((rdpShadowSubsystem *)subsystem);
+ shadow_subsystem_frame_update((rdpShadowSubsystem*)subsystem);
LeaveCriticalSection(&(surface->lock));
break;
+
default:
WLog_ERR(TAG, "Unknown message id: %u", message->id);
break;
HANDLE events[32];
wMessage message;
wMessagePipe* MsgPipe;
-
MsgPipe = subsystem->MsgPipe;
-
nCount = 0;
events[nCount++] = MessageQueue_Event(MsgPipe->In);
-
subsystem->captureFrameRate = 16;
dwInterval = 1000 / subsystem->captureFrameRate;
frameTime = GetTickCount64() + dwInterval;
-
+
while (1)
{
cTime = GetTickCount64();
dwTimeout = (cTime > frameTime) ? 0 : frameTime - cTime;
-
status = WaitForMultipleObjects(nCount, events, FALSE, dwTimeout);
-
+
if (WaitForSingleObject(MessageQueue_Event(MsgPipe->In), 0) == WAIT_OBJECT_0)
{
if (MessageQueue_Peek(MsgPipe->In, &message, TRUE))
{
if (message.id == WMQ_QUIT)
break;
-
+
mac_shadow_subsystem_process_message(subsystem, &message);
}
}
-
+
if ((status == WAIT_TIMEOUT) || (GetTickCount64() > frameTime))
{
mac_shadow_screen_grab(subsystem);
-
dwInterval = 1000 / subsystem->captureFrameRate;
frameTime += dwInterval;
}
}
-
+
ExitThread(0);
return NULL;
}
int numMonitors = 0;
MONITOR_DEF* monitor;
CGDirectDisplayID displayId;
-
displayId = CGMainDisplayID();
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displayId);
-
wide = CGDisplayPixelsWide(displayId);
high = CGDisplayPixelsHigh(displayId);
-
CGDisplayModeRelease(mode);
-
index = 0;
numMonitors = 1;
-
monitor = &monitors[index];
-
monitor->left = 0;
monitor->top = 0;
monitor->right = (int) wide;
monitor->bottom = (int) high;
monitor->flags = 1;
-
return numMonitors;
}
static int mac_shadow_subsystem_init(macShadowSubsystem* subsystem)
{
g_Subsystem = subsystem;
-
mac_shadow_detect_monitors(subsystem);
-
mac_shadow_capture_init(subsystem);
-
return 1;
}
{
if (!subsystem)
return -1;
-
+
if (subsystem->lastUpdate)
{
CFRelease(subsystem->lastUpdate);
return -1;
mac_shadow_capture_start(subsystem);
-
+
if (!(thread = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE) mac_shadow_subsystem_thread,
- (void*) subsystem, 0, NULL)))
+ (LPTHREAD_START_ROUTINE) mac_shadow_subsystem_thread,
+ (void*) subsystem, 0, NULL)))
{
WLog_ERR(TAG, "Failed to create thread");
return -1;
return;
mac_shadow_subsystem_uninit(subsystem);
-
free(subsystem);
}
static macShadowSubsystem* mac_shadow_subsystem_new(void)
{
macShadowSubsystem* subsystem;
-
subsystem = (macShadowSubsystem*) calloc(1, sizeof(macShadowSubsystem));
if (!subsystem)
return NULL;
- subsystem->SynchronizeEvent = (pfnShadowSynchronizeEvent) mac_shadow_input_synchronize_event;
- subsystem->KeyboardEvent = (pfnShadowKeyboardEvent) mac_shadow_input_keyboard_event;
- subsystem->UnicodeKeyboardEvent = (pfnShadowUnicodeKeyboardEvent) mac_shadow_input_unicode_keyboard_event;
+ subsystem->SynchronizeEvent = (pfnShadowSynchronizeEvent)
+ mac_shadow_input_synchronize_event;
+ subsystem->KeyboardEvent = (pfnShadowKeyboardEvent)
+ mac_shadow_input_keyboard_event;
+ subsystem->UnicodeKeyboardEvent = (pfnShadowUnicodeKeyboardEvent)
+ mac_shadow_input_unicode_keyboard_event;
subsystem->MouseEvent = (pfnShadowMouseEvent) mac_shadow_input_mouse_event;
- subsystem->ExtendedMouseEvent = (pfnShadowExtendedMouseEvent) mac_shadow_input_extended_mouse_event;
-
+ subsystem->ExtendedMouseEvent = (pfnShadowExtendedMouseEvent)
+ mac_shadow_input_extended_mouse_event;
return subsystem;
}
{
pEntryPoints->New = (pfnShadowSubsystemNew) mac_shadow_subsystem_new;
pEntryPoints->Free = (pfnShadowSubsystemFree) mac_shadow_subsystem_free;
-
pEntryPoints->Init = (pfnShadowSubsystemInit) mac_shadow_subsystem_init;
pEntryPoints->Uninit = (pfnShadowSubsystemInit) mac_shadow_subsystem_uninit;
-
pEntryPoints->Start = (pfnShadowSubsystemStart) mac_shadow_subsystem_start;
pEntryPoints->Stop = (pfnShadowSubsystemStop) mac_shadow_subsystem_stop;
-
pEntryPoints->EnumMonitors = (pfnShadowEnumMonitors) mac_shadow_enum_monitors;
-
return 1;
}
#define TAG SERVER_TAG("shadow.win")
-void win_shadow_input_synchronize_event(winShadowSubsystem* subsystem, rdpShadowClient* client, UINT32 flags)
+void win_shadow_input_synchronize_event(winShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT32 flags)
{
-
}
-void win_shadow_input_keyboard_event(winShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 code)
+void win_shadow_input_keyboard_event(winShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 code)
{
INPUT event;
-
event.type = INPUT_KEYBOARD;
event.ki.wVk = 0;
event.ki.wScan = code;
SendInput(1, &event, sizeof(INPUT));
}
-void win_shadow_input_unicode_keyboard_event(winShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 code)
+void win_shadow_input_unicode_keyboard_event(winShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 code)
{
INPUT event;
-
event.type = INPUT_KEYBOARD;
event.ki.wVk = 0;
event.ki.wScan = code;
SendInput(1, &event, sizeof(INPUT));
}
-void win_shadow_input_mouse_event(winShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
+void win_shadow_input_mouse_event(winShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
{
INPUT event;
float width;
float height;
-
ZeroMemory(&event, sizeof(INPUT));
-
event.type = INPUT_MOUSE;
if (flags & PTR_FLAGS_WHEEL)
{
width = (float) GetSystemMetrics(SM_CXSCREEN);
height = (float) GetSystemMetrics(SM_CYSCREEN);
-
- event.mi.dx = (LONG) ((float) x * (65535.0f / width));
- event.mi.dy = (LONG) ((float) y * (65535.0f / height));
+ event.mi.dx = (LONG)((float) x * (65535.0f / width));
+ event.mi.dy = (LONG)((float) y * (65535.0f / height));
event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
if (flags & PTR_FLAGS_MOVE)
}
}
-void win_shadow_input_extended_mouse_event(winShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
+void win_shadow_input_extended_mouse_event(winShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
{
INPUT event;
float width;
float height;
-
ZeroMemory(&event, sizeof(INPUT));
if ((flags & PTR_XFLAGS_BUTTON1) || (flags & PTR_XFLAGS_BUTTON2))
{
width = (float) GetSystemMetrics(SM_CXSCREEN);
height = (float) GetSystemMetrics(SM_CYSCREEN);
-
event.mi.dx = (LONG)((float) x * (65535.0f / width));
event.mi.dy = (LONG)((float) y * (65535.0f / height));
event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
-
SendInput(1, &event, sizeof(INPUT));
}
}
-int win_shadow_invalidate_region(winShadowSubsystem* subsystem, int x, int y, int width, int height)
+int win_shadow_invalidate_region(winShadowSubsystem* subsystem, int x, int y,
+ int width, int height)
{
rdpShadowServer* server;
rdpShadowSurface* surface;
RECTANGLE_16 invalidRect;
-
server = subsystem->server;
surface = server->surface;
-
invalidRect.left = x;
invalidRect.top = y;
invalidRect.right = x + width;
invalidRect.bottom = y + height;
-
EnterCriticalSection(&(surface->lock));
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &invalidRect);
LeaveCriticalSection(&(surface->lock));
-
return 1;
}
int count;
int status = 1;
int nDstStep = 0;
+ DWORD DstFormat;
BYTE* pDstData = NULL;
rdpShadowServer* server;
rdpShadowSurface* surface;
RECTANGLE_16 surfaceRect;
RECTANGLE_16 invalidRect;
const RECTANGLE_16* extents;
-
server = subsystem->server;
surface = server->surface;
surfaceRect.top = surface->y;
surfaceRect.right = surface->x + surface->width;
surfaceRect.bottom = surface->y + surface->height;
-
- region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion), &surfaceRect);
+ region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &surfaceRect);
if (region16_is_empty(&(surface->invalidRegion)))
return 1;
extents = region16_extents(&(surface->invalidRegion));
CopyMemory(&invalidRect, extents, sizeof(RECTANGLE_16));
-
shadow_capture_align_clip_rect(&invalidRect, &surfaceRect);
-
x = invalidRect.left;
y = invalidRect.top;
width = invalidRect.right - invalidRect.left;
height = surface->height;
}
- WLog_INFO(TAG, "SurfaceCopy x: %d y: %d width: %d height: %d right: %d bottom: %d",
- x, y, width, height, x + width, y + height);
-
+ WLog_INFO(TAG,
+ "SurfaceCopy x: %d y: %d width: %d height: %d right: %d bottom: %d",
+ x, y, width, height, x + width, y + height);
#if defined(WITH_WDS_API)
{
rdpGdi* gdi;
shwContext* shw;
rdpContext* context;
-
shw = subsystem->shw;
context = (rdpContext*) shw;
gdi = context->gdi;
-
pDstData = gdi->primary_buffer;
nDstStep = gdi->width * 4;
+ DstFormat = gdi->dstFormat;
}
#elif defined(WITH_DXGI_1_2)
- status = win_shadow_dxgi_fetch_frame_data(subsystem, &pDstData, &nDstStep, x, y, width, height);
+ DstFormat = PIXEL_FORMAT_BGRX32;
+ status = win_shadow_dxgi_fetch_frame_data(subsystem, &pDstData, &nDstStep, x, y,
+ width, height);
#endif
if (status <= 0)
return status;
- freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32,
- surface->scanline, x - surface->x, y - surface->y, width, height,
- pDstData, PIXEL_FORMAT_XRGB32, nDstStep, 0, 0, NULL);
-
+ freerdp_image_copy(surface->data, surface->format,
+ surface->scanline, x - surface->x, y - surface->y, width, height,
+ pDstData, DstFormat, nDstStep, 0, 0, NULL);
ArrayList_Lock(server->clients);
-
count = ArrayList_Count(server->clients);
-
- shadow_subsystem_frame_update((rdpShadowSubsystem *)subsystem);
-
+ shadow_subsystem_frame_update((rdpShadowSubsystem*)subsystem);
ArrayList_Unlock(server->clients);
-
region16_clear(&(surface->invalidRegion));
-
return 1;
}
DWORD nCount;
HANDLE events[32];
HANDLE StopEvent;
-
StopEvent = subsystem->server->StopEvent;
-
nCount = 0;
events[nCount++] = StopEvent;
events[nCount++] = subsystem->RdpUpdateEnterEvent;
UINT64 frameTime;
HANDLE events[32];
HANDLE StopEvent;
-
StopEvent = subsystem->server->StopEvent;
-
nCount = 0;
events[nCount++] = StopEvent;
-
fps = 16;
dwInterval = 1000 / fps;
frameTime = GetTickCount64() + dwInterval;
while (1)
{
dwTimeout = INFINITE;
-
cTime = GetTickCount64();
- dwTimeout = (DWORD) ((cTime > frameTime) ? 0 : frameTime - cTime);
-
+ dwTimeout = (DWORD)((cTime > frameTime) ? 0 : frameTime - cTime);
status = WaitForMultipleObjects(nCount, events, FALSE, dwTimeout);
if (WaitForSingleObject(StopEvent, 0) == WAIT_OBJECT_0)
if ((status == WAIT_TIMEOUT) || (GetTickCount64() > frameTime))
{
int dxgi_status;
-
dxgi_status = win_shadow_dxgi_get_next_frame(subsystem);
-
+
if (dxgi_status > 0)
dxgi_status = win_shadow_dxgi_get_invalid_region(subsystem);
int numMonitors = 0;
MONITOR_DEF* monitor;
DISPLAY_DEVICE displayDevice;
-
ZeroMemory(&displayDevice, sizeof(DISPLAY_DEVICE));
displayDevice.cb = sizeof(DISPLAY_DEVICE);
if (EnumDisplayDevices(NULL, iDevNum, &displayDevice, 0))
{
hdc = CreateDC(displayDevice.DeviceName, NULL, NULL, NULL);
-
desktopWidth = GetDeviceCaps(hdc, HORZRES);
desktopHeight = GetDeviceCaps(hdc, VERTRES);
-
index = 0;
numMonitors = 1;
-
monitor = &monitors[index];
-
monitor->left = 0;
monitor->top = 0;
monitor->right = desktopWidth;
monitor->bottom = desktopHeight;
monitor->flags = 1;
-
DeleteDC(hdc);
}
{
int status;
MONITOR_DEF* virtualScreen;
-
subsystem->numMonitors = win_shadow_enum_monitors(subsystem->monitors, 16);
-
#if defined(WITH_WDS_API)
status = win_shadow_wds_init(subsystem);
#elif defined(WITH_DXGI_1_2)
status = win_shadow_dxgi_init(subsystem);
#endif
-
virtualScreen = &(subsystem->virtualScreen);
-
virtualScreen->left = 0;
virtualScreen->top = 0;
virtualScreen->right = subsystem->width;
virtualScreen->bottom = subsystem->height;
virtualScreen->flags = 1;
-
WLog_INFO(TAG, "width: %d height: %d", subsystem->width, subsystem->height);
-
return 1;
}
#elif defined(WITH_DXGI_1_2)
win_shadow_dxgi_uninit(subsystem);
#endif
-
return 1;
}
return -1;
if (!(thread = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE) win_shadow_subsystem_thread,
- (void*) subsystem, 0, NULL)))
+ (LPTHREAD_START_ROUTINE) win_shadow_subsystem_thread,
+ (void*) subsystem, 0, NULL)))
{
WLog_ERR(TAG, "Failed to create thread");
return -1;
return;
win_shadow_subsystem_uninit(subsystem);
-
free(subsystem);
}
winShadowSubsystem* win_shadow_subsystem_new()
{
winShadowSubsystem* subsystem;
-
subsystem = (winShadowSubsystem*) calloc(1, sizeof(winShadowSubsystem));
if (!subsystem)
return NULL;
- subsystem->SynchronizeEvent = (pfnShadowSynchronizeEvent) win_shadow_input_synchronize_event;
- subsystem->KeyboardEvent = (pfnShadowKeyboardEvent) win_shadow_input_keyboard_event;
- subsystem->UnicodeKeyboardEvent = (pfnShadowUnicodeKeyboardEvent) win_shadow_input_unicode_keyboard_event;
+ subsystem->SynchronizeEvent = (pfnShadowSynchronizeEvent)
+ win_shadow_input_synchronize_event;
+ subsystem->KeyboardEvent = (pfnShadowKeyboardEvent)
+ win_shadow_input_keyboard_event;
+ subsystem->UnicodeKeyboardEvent = (pfnShadowUnicodeKeyboardEvent)
+ win_shadow_input_unicode_keyboard_event;
subsystem->MouseEvent = (pfnShadowMouseEvent) win_shadow_input_mouse_event;
- subsystem->ExtendedMouseEvent = (pfnShadowExtendedMouseEvent) win_shadow_input_extended_mouse_event;
-
+ subsystem->ExtendedMouseEvent = (pfnShadowExtendedMouseEvent)
+ win_shadow_input_extended_mouse_event;
return subsystem;
}
{
pEntryPoints->New = (pfnShadowSubsystemNew) win_shadow_subsystem_new;
pEntryPoints->Free = (pfnShadowSubsystemFree) win_shadow_subsystem_free;
-
pEntryPoints->Init = (pfnShadowSubsystemInit) win_shadow_subsystem_init;
pEntryPoints->Uninit = (pfnShadowSubsystemInit) win_shadow_subsystem_uninit;
-
pEntryPoints->Start = (pfnShadowSubsystemStart) win_shadow_subsystem_start;
pEntryPoints->Stop = (pfnShadowSubsystemStop) win_shadow_subsystem_stop;
-
pEntryPoints->EnumMonitors = (pfnShadowEnumMonitors) win_shadow_enum_monitors;
-
return 1;
}
#define TAG SERVER_TAG("shadow.x11")
-int x11_shadow_enum_monitors(MONITOR_DEF* monitors, int maxMonitors);
+static int x11_shadow_enum_monitors(MONITOR_DEF* monitors, int maxMonitors);
#ifdef WITH_PAM
};
typedef struct _SHADOW_PAM_AUTH_INFO SHADOW_PAM_AUTH_INFO;
-int x11_shadow_pam_conv(int num_msg, const struct pam_message** msg, struct pam_response** resp, void* appdata_ptr)
+static int x11_shadow_pam_conv(int num_msg, const struct pam_message** msg,
+ struct pam_response** resp, void* appdata_ptr)
{
int index;
int pam_status = PAM_BUF_ERR;
SHADOW_PAM_AUTH_DATA* appdata;
struct pam_response* response;
-
appdata = (SHADOW_PAM_AUTH_DATA*) appdata_ptr;
- if (!(response = (struct pam_response*) calloc(num_msg, sizeof(struct pam_response))))
+ if (!(response = (struct pam_response*) calloc(num_msg,
+ sizeof(struct pam_response))))
return PAM_BUF_ERR;
for (index = 0; index < num_msg; index++)
{
case PAM_PROMPT_ECHO_ON:
response[index].resp = _strdup(appdata->user);
+
if (!response[index].resp)
goto out_fail;
+
response[index].resp_retcode = PAM_SUCCESS;
break;
case PAM_PROMPT_ECHO_OFF:
response[index].resp = _strdup(appdata->password);
+
if (!response[index].resp)
goto out_fail;
+
response[index].resp_retcode = PAM_SUCCESS;
break;
*resp = response;
return PAM_SUCCESS;
-
out_fail:
+
for (index = 0; index < num_msg; ++index)
{
if (response[index].resp)
free(response[index].resp);
}
}
+
memset(response, 0, sizeof(struct pam_response) * num_msg);
free(response);
*resp = NULL;
return PAM_CONV_ERR;
}
-int x11_shadow_pam_get_service_name(SHADOW_PAM_AUTH_INFO* info)
+static int x11_shadow_pam_get_service_name(SHADOW_PAM_AUTH_INFO* info)
{
if (PathFileExistsA("/etc/pam.d/lightdm"))
{
return 1;
}
-int x11_shadow_pam_authenticate(x11ShadowSubsystem* subsystem, rdpShadowClient* client, const char* user, const char* domain, const char* password)
+static int x11_shadow_pam_authenticate(x11ShadowSubsystem* subsystem,
+ rdpShadowClient* client, const char* user, const char* domain,
+ const char* password)
{
int pam_status;
SHADOW_PAM_AUTH_INFO* info;
-
info = calloc(1, sizeof(SHADOW_PAM_AUTH_INFO));
if (!info)
info->appdata.user = user;
info->appdata.domain = domain;
info->appdata.password = password;
-
info->pamc.conv = &x11_shadow_pam_conv;
info->pamc.appdata_ptr = &(info->appdata);
-
pam_status = pam_start(info->service_name, 0, &(info->pamc), &(info->handle));
if (pam_status != PAM_SUCCESS)
if (pam_status != PAM_SUCCESS)
{
- WLog_ERR(TAG, "pam_authenticate failure: %s", pam_strerror(info->handle, pam_status));
+ WLog_ERR(TAG, "pam_authenticate failure: %s", pam_strerror(info->handle,
+ pam_status));
free(info);
return -1;
}
if (pam_status != PAM_SUCCESS)
{
- WLog_ERR(TAG, "pam_acct_mgmt failure: %s", pam_strerror(info->handle, pam_status));
+ WLog_ERR(TAG, "pam_acct_mgmt failure: %s", pam_strerror(info->handle,
+ pam_status));
free(info);
return -1;
}
free(info);
-
return 1;
}
#endif
-void x11_shadow_input_synchronize_event(x11ShadowSubsystem* subsystem, rdpShadowClient* client, UINT32 flags)
+static void x11_shadow_input_synchronize_event(x11ShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT32 flags)
{
-
}
-void x11_shadow_input_keyboard_event(x11ShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 code)
+static void x11_shadow_input_keyboard_event(x11ShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 code)
{
#ifdef WITH_XTEST
DWORD vkcode;
if (keycode != 0)
{
XLockDisplay(subsystem->display);
-
XTestGrabControl(subsystem->display, True);
if (flags & KBD_FLAGS_DOWN)
XTestFakeKeyEvent(subsystem->display, keycode, False, CurrentTime);
XTestGrabControl(subsystem->display, False);
-
XFlush(subsystem->display);
-
XUnlockDisplay(subsystem->display);
}
+
#endif
}
-void x11_shadow_input_unicode_keyboard_event(x11ShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 code)
+static void x11_shadow_input_unicode_keyboard_event(x11ShadowSubsystem*
+ subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 code)
{
-
}
-void x11_shadow_input_mouse_event(x11ShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
+static void x11_shadow_input_mouse_event(x11ShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
{
#ifdef WITH_XTEST
int button = 0;
BOOL down = FALSE;
rdpShadowServer* server;
rdpShadowSurface* surface;
-
server = subsystem->server;
surface = server->surface;
subsystem->lastMouseClient = client;
-
x += surface->x;
y += surface->y;
-
XLockDisplay(subsystem->display);
-
XTestGrabControl(subsystem->display, True);
if (flags & PTR_FLAGS_WHEEL)
negative = TRUE;
button = (negative) ? 5 : 4;
-
XTestFakeButtonEvent(subsystem->display, button, True, CurrentTime);
XTestFakeButtonEvent(subsystem->display, button, False, CurrentTime);
}
}
XTestGrabControl(subsystem->display, False);
-
XFlush(subsystem->display);
-
XUnlockDisplay(subsystem->display);
#endif
}
-void x11_shadow_input_extended_mouse_event(x11ShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
+static void x11_shadow_input_extended_mouse_event(x11ShadowSubsystem* subsystem,
+ rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y)
{
#ifdef WITH_XTEST
int button = 0;
BOOL down = FALSE;
rdpShadowServer* server;
rdpShadowSurface* surface;
-
server = subsystem->server;
surface = server->surface;
subsystem->lastMouseClient = client;
-
x += surface->x;
y += surface->y;
-
XLockDisplay(subsystem->display);
-
XTestGrabControl(subsystem->display, True);
-
XTestFakeMotionEvent(subsystem->display, 0, x, y, CurrentTime);
if (flags & PTR_XFLAGS_BUTTON1)
XTestFakeButtonEvent(subsystem->display, button, down, CurrentTime);
XTestGrabControl(subsystem->display, False);
-
XFlush(subsystem->display);
-
XUnlockDisplay(subsystem->display);
#endif
}
static void x11_shadow_message_free(UINT32 id, SHADOW_MSG_OUT* msg)
{
- switch(id)
+ switch (id)
{
case SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID:
free(msg);
}
}
-int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem)
+static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem)
{
SHADOW_MSG_OUT_POINTER_POSITION_UPDATE* msg;
UINT32 msgId = SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID;
rdpShadowServer* server;
int count = 0;
int index = 0;
-
- msg = (SHADOW_MSG_OUT_POINTER_POSITION_UPDATE*) calloc(1, sizeof(SHADOW_MSG_OUT_POINTER_POSITION_UPDATE));
+ msg = (SHADOW_MSG_OUT_POINTER_POSITION_UPDATE*) calloc(1,
+ sizeof(SHADOW_MSG_OUT_POINTER_POSITION_UPDATE));
if (!msg)
return -1;
msg->xPos = subsystem->pointerX;
msg->yPos = subsystem->pointerY;
msg->Free = x11_shadow_message_free;
-
server = subsystem->server;
-
ArrayList_Lock(server->clients);
+
for (index = 0; index < ArrayList_Count(server->clients); index++)
{
client = (rdpShadowClient*)ArrayList_GetItem(server->clients, index);
/* Skip the client which send us the latest mouse event */
if (client == subsystem->lastMouseClient)
- continue;
+ continue;
if (shadow_client_post_msg(client, NULL, msgId, (SHADOW_MSG_OUT*) msg, NULL))
count++;
}
- ArrayList_Unlock(server->clients);
+ ArrayList_Unlock(server->clients);
return count;
}
-int x11_shadow_pointer_alpha_update(x11ShadowSubsystem* subsystem)
+static int x11_shadow_pointer_alpha_update(x11ShadowSubsystem* subsystem)
{
SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* msg;
UINT32 msgId = SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE_ID;
-
- msg = (SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE*) calloc(1, sizeof(SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE));
+ msg = (SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE*) calloc(1,
+ sizeof(SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE));
if (!msg)
return -1;
msg->width = subsystem->cursorWidth;
msg->height = subsystem->cursorHeight;
- if (shadow_subsystem_pointer_convert_alpha_pointer_data(subsystem->cursorPixels, TRUE,
- msg->width, msg->height, msg) < 0)
+ if (shadow_subsystem_pointer_convert_alpha_pointer_data(subsystem->cursorPixels,
+ TRUE,
+ msg->width, msg->height, msg) < 0)
{
- free (msg);
+ free(msg);
return -1;
}
msg->Free = x11_shadow_message_free;
-
- return shadow_client_boardcast_msg(subsystem->server, NULL, msgId, (SHADOW_MSG_OUT*) msg, NULL) ? 1 : -1;
+ return shadow_client_boardcast_msg(subsystem->server, NULL, msgId,
+ (SHADOW_MSG_OUT*) msg, NULL) ? 1 : -1;
}
-int x11_shadow_query_cursor(x11ShadowSubsystem* subsystem, BOOL getImage)
+static int x11_shadow_query_cursor(x11ShadowSubsystem* subsystem, BOOL getImage)
{
int x, y, n, k;
rdpShadowServer* server;
rdpShadowSurface* surface;
-
server = subsystem->server;
surface = server->surface;
#ifdef WITH_XFIXES
UINT32* pDstPixel;
XFixesCursorImage* ci;
-
XLockDisplay(subsystem->display);
ci = XFixesGetCursorImage(subsystem->display);
XUnlockDisplay(subsystem->display);
subsystem->cursorHotX = ci->xhot;
subsystem->cursorHotY = ci->yhot;
-
subsystem->cursorWidth = ci->width;
subsystem->cursorHeight = ci->height;
-
subsystem->cursorId = ci->cursor_serial;
-
n = ci->width * ci->height;
pDstPixel = (UINT32*) subsystem->cursorPixels;
}
XFree(ci);
-
x11_shadow_pointer_alpha_update(subsystem);
#endif
}
int win_x, win_y;
int root_x, root_y;
Window root, child;
-
XLockDisplay(subsystem->display);
if (!XQueryPointer(subsystem->display, subsystem->root_window,
- &root, &child, &root_x, &root_y, &win_x, &win_y, &mask))
+ &root, &child, &root_x, &root_y, &win_x, &win_y, &mask))
{
XUnlockDisplay(subsystem->display);
return -1;
}
XUnlockDisplay(subsystem->display);
-
x = root_x;
y = root_y;
}
{
subsystem->pointerX = x;
subsystem->pointerY = y;
-
x11_shadow_pointer_position_update(subsystem);
}
return 1;
}
-int x11_shadow_handle_xevent(x11ShadowSubsystem* subsystem, XEvent* xevent)
+static int x11_shadow_handle_xevent(x11ShadowSubsystem* subsystem,
+ XEvent* xevent)
{
if (xevent->type == MotionNotify)
{
-
}
+
#ifdef WITH_XFIXES
else if (xevent->type == subsystem->xfixes_cursor_notify_event)
{
x11_shadow_query_cursor(subsystem, TRUE);
}
+
#endif
else
{
-
}
return 1;
}
-void x11_shadow_validate_region(x11ShadowSubsystem* subsystem, int x, int y, int width, int height)
+static void x11_shadow_validate_region(x11ShadowSubsystem* subsystem, int x,
+ int y,
+ int width, int height)
{
XRectangle region;
region.y = y;
region.width = width;
region.height = height;
-
#ifdef WITH_XFIXES
XLockDisplay(subsystem->display);
XFixesSetRegion(subsystem->display, subsystem->xdamage_region, ®ion, 1);
- XDamageSubtract(subsystem->display, subsystem->xdamage, subsystem->xdamage_region, None);
+ XDamageSubtract(subsystem->display, subsystem->xdamage,
+ subsystem->xdamage_region, None);
XUnlockDisplay(subsystem->display);
#endif
}
-int x11_shadow_blend_cursor(x11ShadowSubsystem* subsystem)
+static int x11_shadow_blend_cursor(x11ShadowSubsystem* subsystem)
{
int x, y;
int nXSrc;
BYTE* pDstPixel;
BYTE A, R, G, B;
rdpShadowSurface* surface;
-
surface = subsystem->server->surface;
-
nXSrc = 0;
nYSrc = 0;
-
nWidth = subsystem->cursorWidth;
nHeight = subsystem->cursorHeight;
-
nXDst = subsystem->pointerX - subsystem->cursorHotX;
nYDst = subsystem->pointerY - subsystem->cursorHotY;
pSrcData = subsystem->cursorPixels;
nSrcStep = subsystem->cursorWidth * 4;
-
pDstData = surface->data;
nDstStep = surface->scanline;
-
nSrcPad = (nSrcStep - (nWidth * 4));
nDstPad = (nDstStep - (nWidth * 4));
-
pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)];
return 1;
}
-BOOL x11_shadow_check_resize(x11ShadowSubsystem* subsystem)
+static BOOL x11_shadow_check_resize(x11ShadowSubsystem* subsystem)
{
MONITOR_DEF* virtualScreen;
XWindowAttributes attr;
-
XLockDisplay(subsystem->display);
XGetWindowAttributes(subsystem->display, subsystem->root_window, &attr);
XUnlockDisplay(subsystem->display);
{
/* Screen size changed. Refresh monitor definitions and trigger screen resize */
subsystem->numMonitors = x11_shadow_enum_monitors(subsystem->monitors, 16);
-
shadow_screen_resize(subsystem->server->screen);
-
subsystem->width = attr.width;
subsystem->height = attr.height;
-
virtualScreen = &(subsystem->virtualScreen);
virtualScreen->left = 0;
virtualScreen->top = 0;
virtualScreen->right = subsystem->width;
virtualScreen->bottom = subsystem->height;
virtualScreen->flags = 1;
-
return TRUE;
}
return FALSE;
}
-static int x11_shadow_error_handler_for_capture(Display * display, XErrorEvent * event)
+static int x11_shadow_error_handler_for_capture(Display* display,
+ XErrorEvent* event)
{
- char msg[256];
- XGetErrorText(display, event->error_code, (char *) &msg, sizeof(msg));
- WLog_ERR(TAG, "X11 error: %s Error code: %x, request code: %x, minor code: %x",
- msg, event->error_code, event->request_code, event->minor_code);
+ char msg[256];
+ XGetErrorText(display, event->error_code, (char*) &msg, sizeof(msg));
+ WLog_ERR(TAG, "X11 error: %s Error code: %x, request code: %x, minor code: %x",
+ msg, event->error_code, event->request_code, event->minor_code);
/* Ignore BAD MATCH error during image capture. Abort in other case */
if (event->error_code != BadMatch)
return 0;
}
-int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem)
+static int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem)
{
int count;
int status;
rdpShadowSurface* surface;
RECTANGLE_16 invalidRect;
RECTANGLE_16 surfaceRect;
- const RECTANGLE_16 *extents;
-
+ const RECTANGLE_16* extents;
server = subsystem->server;
surface = server->surface;
screen = server->screen;
-
count = ArrayList_Count(server->clients);
if (count < 1)
surfaceRect.top = 0;
surfaceRect.right = surface->width;
surfaceRect.bottom = surface->height;
-
XLockDisplay(subsystem->display);
-
/*
- * Ignore BadMatch error during image capture. The screen size may be
+ * Ignore BadMatch error during image capture. The screen size may be
* changed outside. We will resize to correct resolution at next frame
*/
XSetErrorHandler(x11_shadow_error_handler_for_capture);
if (subsystem->use_xshm)
{
image = subsystem->fb_image;
-
XCopyArea(subsystem->display, subsystem->root_window, subsystem->fb_pixmap,
- subsystem->xshm_gc, 0, 0, subsystem->width, subsystem->height, 0, 0);
-
- status = shadow_capture_compare(surface->data, surface->scanline, surface->width, surface->height,
- (BYTE*) &(image->data[surface->width * 4]), image->bytes_per_line, &invalidRect);
+ subsystem->xshm_gc, 0, 0, subsystem->width, subsystem->height, 0, 0);
+ status = shadow_capture_compare(surface->data, surface->scanline,
+ surface->width, surface->height,
+ (BYTE*) & (image->data[surface->width * 4]), image->bytes_per_line,
+ &invalidRect);
}
else
{
image = XGetImage(subsystem->display, subsystem->root_window,
- surface->x, surface->y, surface->width, surface->height, AllPlanes, ZPixmap);
+ surface->x, surface->y, surface->width, surface->height, AllPlanes, ZPixmap);
if (!image)
{
/*
* BadMatch error happened. The size may have been changed again.
- * Give up this frame and we will resize again in next frame
+ * Give up this frame and we will resize again in next frame
*/
goto fail_capture;
}
- status = shadow_capture_compare(surface->data, surface->scanline, surface->width, surface->height,
- (BYTE*) image->data, image->bytes_per_line, &invalidRect);
+ status = shadow_capture_compare(surface->data, surface->scanline,
+ surface->width, surface->height,
+ (BYTE*) image->data, image->bytes_per_line, &invalidRect);
}
/* Restore the default error handler */
XSetErrorHandler(NULL);
-
XSync(subsystem->display, False);
-
XUnlockDisplay(subsystem->display);
-
- region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect);
- region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion), &surfaceRect);
+ region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &invalidRect);
+ region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion),
+ &surfaceRect);
if (!region16_is_empty(&(surface->invalidRegion)))
{
extents = region16_extents(&(surface->invalidRegion));
-
x = extents->left;
y = extents->top;
width = extents->right - extents->left;
height = extents->bottom - extents->top;
-
- freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32,
- surface->scanline, x, y, width, height,
- (BYTE*) image->data, PIXEL_FORMAT_XRGB32,
- image->bytes_per_line, x, y, NULL);
-
+ freerdp_image_copy(surface->data, surface->format,
+ surface->scanline, x, y, width, height,
+ (BYTE*) image->data, PIXEL_FORMAT_BGRX32,
+ image->bytes_per_line, x, y, NULL);
//x11_shadow_blend_cursor(subsystem);
-
count = ArrayList_Count(server->clients);
-
- shadow_subsystem_frame_update((rdpShadowSubsystem *)subsystem);
+ shadow_subsystem_frame_update((rdpShadowSubsystem*)subsystem);
if (count == 1)
{
rdpShadowClient* client;
-
client = (rdpShadowClient*) ArrayList_GetItem(server->clients, 0);
if (client)
XDestroyImage(image);
return 1;
-
fail_capture:
XSetErrorHandler(NULL);
XSync(subsystem->display, False);
return 0;
}
-int x11_shadow_subsystem_process_message(x11ShadowSubsystem* subsystem, wMessage* message)
+static int x11_shadow_subsystem_process_message(x11ShadowSubsystem* subsystem,
+ wMessage* message)
{
- switch(message->id)
+ switch (message->id)
{
case SHADOW_MSG_IN_REFRESH_REQUEST_ID:
- shadow_subsystem_frame_update((rdpShadowSubsystem *)subsystem);
+ shadow_subsystem_frame_update((rdpShadowSubsystem*)subsystem);
break;
+
default:
WLog_ERR(TAG, "Unknown message id: %u", message->id);
break;
return 1;
}
-void* x11_shadow_subsystem_thread(x11ShadowSubsystem* subsystem)
+static void* x11_shadow_subsystem_thread(x11ShadowSubsystem* subsystem)
{
XEvent xevent;
DWORD status;
HANDLE events[32];
wMessage message;
wMessagePipe* MsgPipe;
-
MsgPipe = subsystem->MsgPipe;
-
nCount = 0;
events[nCount++] = subsystem->event;
events[nCount++] = MessageQueue_Event(MsgPipe->In);
-
subsystem->captureFrameRate = 16;
dwInterval = 1000 / subsystem->captureFrameRate;
frameTime = GetTickCount64() + dwInterval;
{
cTime = GetTickCount64();
dwTimeout = (cTime > frameTime) ? 0 : frameTime - cTime;
-
status = WaitForMultipleObjects(nCount, events, FALSE, dwTimeout);
if (WaitForSingleObject(MessageQueue_Event(MsgPipe->In), 0) == WAIT_OBJECT_0)
x11_shadow_check_resize(subsystem);
x11_shadow_screen_grab(subsystem);
x11_shadow_query_cursor(subsystem, FALSE);
-
dwInterval = 1000 / subsystem->captureFrameRate;
frameTime += dwInterval;
}
return NULL;
}
-int x11_shadow_subsystem_base_init(x11ShadowSubsystem* subsystem)
+static int x11_shadow_subsystem_base_init(x11ShadowSubsystem* subsystem)
{
if (subsystem->display)
return 1; /* initialize once */
subsystem->width = WidthOfScreen(subsystem->screen);
subsystem->height = HeightOfScreen(subsystem->screen);
subsystem->root_window = RootWindow(subsystem->display, subsystem->number);
-
return 1;
}
return -1;
subsystem->xfixes_cursor_notify_event = xfixes_event + XFixesCursorNotify;
-
XFixesSelectCursorInput(subsystem->display, subsystem->root_window,
- XFixesDisplayCursorNotifyMask);
-
+ XFixesDisplayCursorNotifyMask);
return 1;
#else
return -1;
int major, minor;
int xinerama_event;
int xinerama_error;
-
x11_shadow_subsystem_base_init(subsystem);
- if (!XineramaQueryExtension(subsystem->display, &xinerama_event, &xinerama_error))
+ if (!XineramaQueryExtension(subsystem->display, &xinerama_event,
+ &xinerama_error))
return -1;
if (!XDamageQueryVersion(subsystem->display, &major, &minor))
return -1;
subsystem->xdamage_notify_event = damage_event + XDamageNotify;
- subsystem->xdamage = XDamageCreate(subsystem->display, subsystem->root_window, XDamageReportDeltaRectangles);
+ subsystem->xdamage = XDamageCreate(subsystem->display, subsystem->root_window,
+ XDamageReportDeltaRectangles);
if (!subsystem->xdamage)
return -1;
if (!subsystem->xdamage_region)
return -1;
-#endif
+#endif
return 1;
#else
return -1;
return -1;
subsystem->fb_shm_info.shmid = -1;
- subsystem->fb_shm_info.shmaddr = (char*) -1;
+ subsystem->fb_shm_info.shmaddr = (char*) - 1;
subsystem->fb_shm_info.readOnly = False;
-
- subsystem->fb_image = XShmCreateImage(subsystem->display, subsystem->visual, subsystem->depth,
- ZPixmap, NULL, &(subsystem->fb_shm_info), subsystem->width, subsystem->height);
+ subsystem->fb_image = XShmCreateImage(subsystem->display, subsystem->visual,
+ subsystem->depth,
+ ZPixmap, NULL, &(subsystem->fb_shm_info), subsystem->width, subsystem->height);
if (!subsystem->fb_image)
{
}
subsystem->fb_shm_info.shmid = shmget(IPC_PRIVATE,
- subsystem->fb_image->bytes_per_line * subsystem->fb_image->height, IPC_CREAT | 0600);
+ subsystem->fb_image->bytes_per_line * subsystem->fb_image->height,
+ IPC_CREAT | 0600);
if (subsystem->fb_shm_info.shmid == -1)
{
subsystem->fb_shm_info.shmaddr = shmat(subsystem->fb_shm_info.shmid, 0, 0);
subsystem->fb_image->data = subsystem->fb_shm_info.shmaddr;
- if (subsystem->fb_shm_info.shmaddr == ((char*) -1))
+ if (subsystem->fb_shm_info.shmaddr == ((char*) - 1))
{
WLog_ERR(TAG, "shmat failed");
return -1;
return -1;
XSync(subsystem->display, False);
-
shmctl(subsystem->fb_shm_info.shmid, IPC_RMID, 0);
-
subsystem->fb_pixmap = XShmCreatePixmap(subsystem->display,
- subsystem->root_window, subsystem->fb_image->data, &(subsystem->fb_shm_info),
- subsystem->fb_image->width, subsystem->fb_image->height, subsystem->fb_image->depth);
-
+ subsystem->root_window, subsystem->fb_image->data, &(subsystem->fb_shm_info),
+ subsystem->fb_image->width, subsystem->fb_image->height,
+ subsystem->fb_image->depth);
XSync(subsystem->display, False);
if (!subsystem->fb_pixmap)
values.subwindow_mode = IncludeInferiors;
values.graphics_exposures = False;
-
subsystem->xshm_gc = XCreateGC(subsystem->display, subsystem->root_window,
- GCSubwindowMode | GCGraphicsExposures, &values);
-
+ GCSubwindowMode | GCGraphicsExposures, &values);
XSetFunction(subsystem->display, subsystem->xshm_gc, GXcopy);
XSync(subsystem->display, False);
-
return 1;
}
displayWidth = WidthOfScreen(DefaultScreenOfDisplay(display));
displayHeight = HeightOfScreen(DefaultScreenOfDisplay(display));
-
#ifdef WITH_XINERAMA
{
int major, minor;
XineramaScreenInfo* screens;
if (XineramaQueryExtension(display, &xinerama_event, &xinerama_error) &&
- XDamageQueryVersion(display, &major, &minor) && XineramaIsActive(display))
+ XDamageQueryVersion(display, &major, &minor) && XineramaIsActive(display))
{
screens = XineramaQueryScreens(display, &numMonitors);
{
screen = &screens[index];
monitor = &monitors[index];
-
monitor->left = screen->x_org;
monitor->top = screen->y_org;
monitor->right = monitor->left + screen->width;
}
}
#endif
-
XCloseDisplay(display);
if (numMonitors < 1)
{
index = 0;
numMonitors = 1;
-
monitor = &monitors[index];
-
monitor->left = 0;
monitor->top = 0;
monitor->right = displayWidth;
return numMonitors;
}
-int x11_shadow_subsystem_init(x11ShadowSubsystem* subsystem)
+static int x11_shadow_subsystem_init(x11ShadowSubsystem* subsystem)
{
int i;
int pf_count;
XPixmapFormatValues* pf;
XPixmapFormatValues* pfs;
MONITOR_DEF* virtualScreen;
-
subsystem->numMonitors = x11_shadow_enum_monitors(subsystem->monitors, 16);
-
x11_shadow_subsystem_base_init(subsystem);
if ((subsystem->depth != 24) && (subsystem->depth != 32))
extensions = XListExtensions(subsystem->display, &nextensions);
if (!extensions || (nextensions < 0))
- return -1;
+ return -1;
for (i = 0; i < nextensions; i++)
{
break;
}
}
- XFree(pfs);
+ XFree(pfs);
ZeroMemory(&template, sizeof(template));
template.class = TrueColor;
template.screen = subsystem->number;
-
- vis = XGetVisualInfo(subsystem->display, VisualClassMask | VisualScreenMask, &template, &vi_count);
+ vis = XGetVisualInfo(subsystem->display, VisualClassMask | VisualScreenMask,
+ &template, &vi_count);
if (!vis)
{
break;
}
}
- XFree(vis);
-
- XSelectInput(subsystem->display, subsystem->root_window, SubstructureNotifyMask);
+ XFree(vis);
+ XSelectInput(subsystem->display, subsystem->root_window,
+ SubstructureNotifyMask);
subsystem->cursorMaxWidth = 256;
subsystem->cursorMaxHeight = 256;
- subsystem->cursorPixels = _aligned_malloc(subsystem->cursorMaxWidth * subsystem->cursorMaxHeight * 4, 16);
+ subsystem->cursorPixels = _aligned_malloc(subsystem->cursorMaxWidth *
+ subsystem->cursorMaxHeight * 4, 16);
if (!subsystem->cursorPixels)
return -1;
if (subsystem->use_xfixes)
{
if (x11_shadow_xfixes_init(subsystem) < 0)
- subsystem->use_xfixes = FALSE;
+ subsystem->use_xfixes = FALSE;
}
if (subsystem->use_xinerama)
{
if (x11_shadow_xinerama_init(subsystem) < 0)
- subsystem->use_xinerama = FALSE;
+ subsystem->use_xinerama = FALSE;
}
if (subsystem->use_xshm)
{
if (x11_shadow_xshm_init(subsystem) < 0)
- subsystem->use_xshm = FALSE;
+ subsystem->use_xshm = FALSE;
}
if (subsystem->use_xdamage)
{
if (x11_shadow_xdamage_init(subsystem) < 0)
- subsystem->use_xdamage = FALSE;
+ subsystem->use_xdamage = FALSE;
}
if (!(subsystem->event = CreateFileDescriptorEvent(NULL, FALSE, FALSE,
- subsystem->xfds, WINPR_FD_READ)))
+ subsystem->xfds, WINPR_FD_READ)))
return -1;
virtualScreen = &(subsystem->virtualScreen);
-
virtualScreen->left = 0;
virtualScreen->top = 0;
virtualScreen->right = subsystem->width;
virtualScreen->bottom = subsystem->height;
virtualScreen->flags = 1;
-
WLog_INFO(TAG, "X11 Extensions: XFixes: %d Xinerama: %d XDamage: %d XShm: %d",
- subsystem->use_xfixes, subsystem->use_xinerama, subsystem->use_xdamage, subsystem->use_xshm);
-
+ subsystem->use_xfixes, subsystem->use_xinerama, subsystem->use_xdamage,
+ subsystem->use_xshm);
return 1;
}
-int x11_shadow_subsystem_uninit(x11ShadowSubsystem* subsystem)
+static int x11_shadow_subsystem_uninit(x11ShadowSubsystem* subsystem)
{
if (!subsystem)
return -1;
return 1;
}
-int x11_shadow_subsystem_start(x11ShadowSubsystem* subsystem)
+static int x11_shadow_subsystem_start(x11ShadowSubsystem* subsystem)
{
if (!subsystem)
return -1;
if (!(subsystem->thread = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE) x11_shadow_subsystem_thread,
- (void*) subsystem, 0, NULL)))
+ (LPTHREAD_START_ROUTINE) x11_shadow_subsystem_thread,
+ (void*) subsystem, 0, NULL)))
{
WLog_ERR(TAG, "Failed to create thread");
return -1;
return 1;
}
-int x11_shadow_subsystem_stop(x11ShadowSubsystem* subsystem)
+static int x11_shadow_subsystem_stop(x11ShadowSubsystem* subsystem)
{
if (!subsystem)
return -1;
{
if (MessageQueue_PostQuit(subsystem->MsgPipe->In, 0))
WaitForSingleObject(subsystem->thread, INFINITE);
+
CloseHandle(subsystem->thread);
subsystem->thread = NULL;
}
return 1;
}
-x11ShadowSubsystem* x11_shadow_subsystem_new()
+static x11ShadowSubsystem* x11_shadow_subsystem_new(void)
{
x11ShadowSubsystem* subsystem;
-
subsystem = (x11ShadowSubsystem*) calloc(1, sizeof(x11ShadowSubsystem));
if (!subsystem)
#ifdef WITH_PAM
subsystem->Authenticate = (pfnShadowAuthenticate) x11_shadow_pam_authenticate;
#endif
-
- subsystem->SynchronizeEvent = (pfnShadowSynchronizeEvent) x11_shadow_input_synchronize_event;
- subsystem->KeyboardEvent = (pfnShadowKeyboardEvent) x11_shadow_input_keyboard_event;
- subsystem->UnicodeKeyboardEvent = (pfnShadowUnicodeKeyboardEvent) x11_shadow_input_unicode_keyboard_event;
+ subsystem->SynchronizeEvent = (pfnShadowSynchronizeEvent)
+ x11_shadow_input_synchronize_event;
+ subsystem->KeyboardEvent = (pfnShadowKeyboardEvent)
+ x11_shadow_input_keyboard_event;
+ subsystem->UnicodeKeyboardEvent = (pfnShadowUnicodeKeyboardEvent)
+ x11_shadow_input_unicode_keyboard_event;
subsystem->MouseEvent = (pfnShadowMouseEvent) x11_shadow_input_mouse_event;
- subsystem->ExtendedMouseEvent = (pfnShadowExtendedMouseEvent) x11_shadow_input_extended_mouse_event;
-
+ subsystem->ExtendedMouseEvent = (pfnShadowExtendedMouseEvent)
+ x11_shadow_input_extended_mouse_event;
subsystem->composite = FALSE;
subsystem->use_xshm = FALSE; /* temporarily disabled */
subsystem->use_xfixes = TRUE;
subsystem->use_xdamage = FALSE;
subsystem->use_xinerama = TRUE;
-
return subsystem;
}
-void x11_shadow_subsystem_free(x11ShadowSubsystem* subsystem)
+static void x11_shadow_subsystem_free(x11ShadowSubsystem* subsystem)
{
if (!subsystem)
return;
x11_shadow_subsystem_uninit(subsystem);
-
free(subsystem);
}
{
pEntryPoints->New = (pfnShadowSubsystemNew) x11_shadow_subsystem_new;
pEntryPoints->Free = (pfnShadowSubsystemFree) x11_shadow_subsystem_free;
-
pEntryPoints->Init = (pfnShadowSubsystemInit) x11_shadow_subsystem_init;
pEntryPoints->Uninit = (pfnShadowSubsystemInit) x11_shadow_subsystem_uninit;
-
pEntryPoints->Start = (pfnShadowSubsystemStart) x11_shadow_subsystem_start;
pEntryPoints->Stop = (pfnShadowSubsystemStop) x11_shadow_subsystem_stop;
-
pEntryPoints->EnumMonitors = (pfnShadowEnumMonitors) x11_shadow_enum_monitors;
-
return 1;
}
};
typedef struct _SHADOW_GFX_STATUS SHADOW_GFX_STATUS;
-static INLINE BOOL shadow_client_rdpgfx_new_surface(rdpShadowClient *client)
+static INLINE BOOL shadow_client_rdpgfx_new_surface(rdpShadowClient* client)
{
UINT error = CHANNEL_RC_OK;
RDPGFX_CREATE_SURFACE_PDU createSurface;
RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU surfaceToOutput;
RdpgfxServerContext* context = client->rdpgfx;
rdpSettings* settings = ((rdpContext*) client)->settings;
-
createSurface.width = settings->DesktopWidth;
createSurface.height = settings->DesktopHeight;
createSurface.pixelFormat = GFX_PIXEL_FORMAT_XRGB_8888;
createSurface.surfaceId = 0;
-
surfaceToOutput.outputOriginX = 0;
surfaceToOutput.outputOriginY = 0;
surfaceToOutput.surfaceId = 0;
surfaceToOutput.reserved = 0;
-
IFCALLRET(context->CreateSurface, error, context, &createSurface);
+
if (error)
{
WLog_ERR(TAG, "CreateSurface failed with error %lu", error);
}
IFCALLRET(context->MapSurfaceToOutput, error, context, &surfaceToOutput);
+
if (error)
{
WLog_ERR(TAG, "MapSurfaceToOutput failed with error %lu", error);
return TRUE;
}
-static INLINE BOOL shadow_client_rdpgfx_release_surface(rdpShadowClient *client)
+static INLINE BOOL shadow_client_rdpgfx_release_surface(rdpShadowClient* client)
{
UINT error = CHANNEL_RC_OK;
RDPGFX_DELETE_SURFACE_PDU pdu;
RdpgfxServerContext* context = client->rdpgfx;
-
pdu.surfaceId = 0;
IFCALLRET(context->DeleteSurface, error, context, &pdu);
+
if (error)
{
WLog_ERR(TAG, "DeleteSurface failed with error %lu", error);
return TRUE;
}
-static INLINE BOOL shadow_client_rdpgfx_reset_graphic(rdpShadowClient *client)
+static INLINE BOOL shadow_client_rdpgfx_reset_graphic(rdpShadowClient* client)
{
UINT error = CHANNEL_RC_OK;
RDPGFX_RESET_GRAPHICS_PDU pdu;
RdpgfxServerContext* context = client->rdpgfx;
rdpSettings* settings = ((rdpContext*) client)->settings;
-
pdu.width = settings->DesktopWidth;
pdu.height = settings->DesktopHeight;
pdu.monitorCount = client->subsystem->numMonitors;
pdu.monitorDefArray = client->subsystem->monitors;
-
IFCALLRET(context->ResetGraphics, error, context, &pdu);
+
if (error)
{
WLog_ERR(TAG, "ResetGraphics failed with error %lu", error);
return TRUE;
}
-static INLINE void shadow_client_free_queued_message(void *obj)
+static INLINE void shadow_client_free_queued_message(void* obj)
{
- wMessage *message = (wMessage*)obj;
+ wMessage* message = (wMessage*)obj;
+
if (message->Free)
{
message->Free(message);
}
}
-static BOOL shadow_client_context_new(freerdp_peer* peer, rdpShadowClient* client)
+static BOOL shadow_client_context_new(freerdp_peer* peer,
+ rdpShadowClient* client)
{
rdpSettings* settings;
rdpShadowServer* server;
const wObject cb = { NULL, NULL, NULL, shadow_client_free_queued_message, NULL };
-
server = (rdpShadowServer*) peer->ContextExtra;
client->server = server;
client->subsystem = server->subsystem;
-
settings = peer->settings;
-
settings->ColorDepth = 32;
settings->NSCodec = TRUE;
settings->RemoteFxCodec = TRUE;
settings->SurfaceFrameMarkerEnabled = TRUE;
settings->SupportGraphicsPipeline = TRUE;
settings->GfxH264 = FALSE;
-
settings->DrawAllowSkipAlpha = TRUE;
settings->DrawAllowColorSubsampling = TRUE;
settings->DrawAllowDynamicColorFidelity = TRUE;
-
settings->CompressionLevel = PACKET_COMPR_TYPE_RDP6;
if (!(settings->CertificateFile = _strdup(server->CertificateFile)))
goto fail_cert_file;
+
if (!(settings->PrivateKeyFile = _strdup(server->PrivateKeyFile)))
goto fail_privkey_file;
+
if (!(settings->RdpKeyFile = _strdup(settings->PrivateKeyFile)))
goto fail_rdpkey_file;
-
if (server->ipcSocket)
{
settings->LyncRdpMode = TRUE;
goto fail_client_lock;
region16_init(&(client->invalidRegion));
-
client->vcm = WTSOpenServerA((LPSTR) peer->context);
+
if (!client->vcm || client->vcm == INVALID_HANDLE_VALUE)
goto fail_open_server;
free(settings->CertificateFile);
settings->CertificateFile = NULL;
fail_cert_file:
-
return FALSE;
}
-static void shadow_client_context_free(freerdp_peer* peer, rdpShadowClient* client)
+static void shadow_client_context_free(freerdp_peer* peer,
+ rdpShadowClient* client)
{
rdpShadowServer* server = client->server;
-
ArrayList_Remove(server->clients, (void*) client);
if (client->encoder)
client->encoder = NULL;
}
- /* Clear queued messages and free resource */
+ /* Clear queued messages and free resource */
MessageQueue_Clear(client->MsgQueue);
MessageQueue_Free(client->MsgQueue);
-
WTSCloseServer((HANDLE) client->vcm);
client->vcm = NULL;
-
region16_uninit(&(client->invalidRegion));
-
DeleteCriticalSection(&(client->lock));
}
-void shadow_client_message_free(wMessage* message)
+static void shadow_client_message_free(wMessage* message)
{
- switch(message->id)
+ switch (message->id)
{
case SHADOW_MSG_IN_REFRESH_REQUEST_ID:
/* Refresh request do not have message to free */
}
}
-static INLINE void shadow_client_mark_invalid(rdpShadowClient* client, int numRects, const RECTANGLE_16* rects)
+static INLINE void shadow_client_mark_invalid(rdpShadowClient* client,
+ int numRects, const RECTANGLE_16* rects)
{
int index;
RECTANGLE_16 screenRegion;
rdpSettings* settings = ((rdpContext*) client)->settings;
-
EnterCriticalSection(&(client->lock));
/* Mark client invalid region. No rectangle means full screen */
{
for (index = 0; index < numRects; index++)
{
- region16_union_rect(&(client->invalidRegion), &(client->invalidRegion), &rects[index]);
+ region16_union_rect(&(client->invalidRegion), &(client->invalidRegion),
+ &rects[index]);
}
}
else
screenRegion.top = 0;
screenRegion.right = settings->DesktopWidth;
screenRegion.bottom = settings->DesktopHeight;
-
region16_union_rect(&(client->invalidRegion),
- &(client->invalidRegion), &screenRegion);
+ &(client->invalidRegion), &screenRegion);
}
LeaveCriticalSection(&(client->lock));
int width, height;
rdpShadowServer* server = client->server;
rdpSettings* settings = client->context.settings;
-
RECTANGLE_16 viewport = {0, 0, server->surface->width, server->surface->height};
if (server->shareSubRect)
width = viewport.right - viewport.left;
height = viewport.bottom - viewport.top;
- if (settings->DesktopWidth != (UINT32)width || settings->DesktopHeight != (UINT32)height)
+ if (settings->DesktopWidth != (UINT32)width
+ || settings->DesktopHeight != (UINT32)height)
{
settings->DesktopWidth = width;
settings->DesktopHeight = height;
rdpShadowSubsystem* subsystem;
rdpShadowClient* client;
BOOL ret = TRUE;
-
client = (rdpShadowClient*) peer->context;
subsystem = client->server->subsystem;
-
IFCALLRET(subsystem->ClientCapabilities, ret, subsystem, client);
+
if (!ret)
WLog_WARN(TAG, "subsystem->ClientCapabilities failed");
/* Recalculate desktop size regardless whether previous call fail
* or not. Make sure we send correct width/height to client */
(void)shadow_client_recalc_desktop_size(client);
-
return ret;
}
rdpShadowClient* client;
rdpShadowServer* server;
rdpShadowSubsystem* subsystem;
-
client = (rdpShadowClient*) peer->context;
settings = peer->settings;
server = client->server;
settings->ColorDepth = 16; /* disable 24bpp */
if (settings->MultifragMaxRequestSize < 0x3F0000)
- settings->NSCodec = FALSE; /* NSCodec compressor does not support fragmentation yet */
+ settings->NSCodec =
+ FALSE; /* NSCodec compressor does not support fragmentation yet */
WLog_INFO(TAG, "Client from %s is activated (%dx%d@%d)",
- peer->hostname, settings->DesktopWidth,
- settings->DesktopHeight, settings->ColorDepth);
+ peer->hostname, settings->DesktopWidth,
+ settings->DesktopHeight, settings->ColorDepth);
/* Resize client if necessary */
if (shadow_client_recalc_desktop_size(client))
{
peer->update->DesktopResize(peer->update->context);
WLog_INFO(TAG, "Client from %s is resized (%dx%d@%d)",
- peer->hostname, settings->DesktopWidth,
- settings->DesktopHeight, settings->ColorDepth);
+ peer->hostname, settings->DesktopWidth,
+ settings->DesktopHeight, settings->ColorDepth);
}
if (shadow_client_channels_post_connect(client) != CHANNEL_RC_OK)
return FALSE;
shadow_client_mark_invalid(client, 0, NULL);
-
authStatus = -1;
if (settings->Username && settings->Password)
if (subsystem->Authenticate)
{
authStatus = subsystem->Authenticate(subsystem, client,
- settings->Username, settings->Domain, settings->Password);
+ settings->Username, settings->Domain, settings->Password);
}
if (authStatus < 0)
/* Convert rects in sub rect coordinate to client/surface coordinate */
static INLINE void shadow_client_convert_rects(rdpShadowClient* client,
- RECTANGLE_16* dst, const RECTANGLE_16* src, UINT32 numRects)
+ RECTANGLE_16* dst, const RECTANGLE_16* src, UINT32 numRects)
{
if (client->server->shareSubRect)
{
{
wMessage message = { 0 };
wMessagePipe* MsgPipe = client->subsystem->MsgPipe;
-
message.id = SHADOW_MSG_IN_REFRESH_REQUEST_ID;
message.wParam = NULL;
message.lParam = NULL;
message.context = (void*) client;
message.Free = NULL;
-
return MessageQueue_Dispatch(MsgPipe->In, &message);
}
-static BOOL shadow_client_refresh_rect(rdpShadowClient* client, BYTE count, RECTANGLE_16* areas)
+static BOOL shadow_client_refresh_rect(rdpShadowClient* client, BYTE count,
+ RECTANGLE_16* areas)
{
RECTANGLE_16* rects;
}
shadow_client_convert_rects(client, rects, areas, count);
-
shadow_client_mark_invalid(client, count, rects);
-
free(rects);
}
else
return shadow_client_refresh_request(client);
}
-static BOOL shadow_client_suppress_output(rdpShadowClient* client, BYTE allow, RECTANGLE_16* area)
+static BOOL shadow_client_suppress_output(rdpShadowClient* client, BYTE allow,
+ RECTANGLE_16* area)
{
RECTANGLE_16 region;
-
client->suppressOutput = allow ? FALSE : TRUE;
+
if (allow)
{
if (area)
shadow_client_mark_invalid(client, 0, NULL);
}
}
+
return shadow_client_refresh_request(client);
}
if (settings->ClientDir && (strcmp(settings->ClientDir, "librdp") == 0))
{
/* Hack for Mac/iOS/Android Microsoft RDP clients */
-
settings->RemoteFxCodec = FALSE;
-
settings->NSCodec = FALSE;
settings->NSCodecAllowSubsampling = FALSE;
-
settings->SurfaceFrameMarkerEnabled = FALSE;
}
return shadow_client_refresh_rect(client, 0, NULL);
}
-BOOL shadow_client_logon(freerdp_peer* peer, SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic)
+static BOOL shadow_client_logon(freerdp_peer* peer,
+ SEC_WINNT_AUTH_IDENTITY* identity,
+ BOOL automatic)
{
char* user = NULL;
char* domain = NULL;
if (identity->Flags & SEC_WINNT_AUTH_IDENTITY_UNICODE)
{
if (identity->User)
- ConvertFromUnicode(CP_UTF8, 0, identity->User, identity->UserLength, &user, 0, NULL, NULL);
+ ConvertFromUnicode(CP_UTF8, 0, identity->User, identity->UserLength, &user, 0,
+ NULL, NULL);
if (identity->Domain)
- ConvertFromUnicode(CP_UTF8, 0, identity->Domain, identity->DomainLength, &domain, 0, NULL, NULL);
+ ConvertFromUnicode(CP_UTF8, 0, identity->Domain, identity->DomainLength,
+ &domain, 0, NULL, NULL);
if (identity->Password)
- ConvertFromUnicode(CP_UTF8, 0, identity->Password, identity->PasswordLength, &user, 0, NULL, NULL);
+ ConvertFromUnicode(CP_UTF8, 0, identity->Password, identity->PasswordLength,
+ &user, 0, NULL, NULL);
}
else
{
password = _strdup((char*) identity->Password);
}
- if ((identity->User && !user) || (identity->Domain && !domain) || (identity->Password && !password))
+ if ((identity->User && !user) || (identity->Domain && !domain)
+ || (identity->Password && !password))
return FALSE;
if (user)
free(user);
free(domain);
free(password);
-
return TRUE;
}
-static INLINE void shadow_client_common_frame_acknowledge(rdpShadowClient* client, UINT32 frameId)
+static INLINE void shadow_client_common_frame_acknowledge(
+ rdpShadowClient* client, UINT32 frameId)
{
/*
- * Record the last client acknowledged frame id to
+ * Record the last client acknowledged frame id to
* calculate how much frames are in progress.
* Some rdp clients (win7 mstsc) skips frame ACK if it is
* inactive, we should not expect ACK for each frame.
* So it is OK to calculate inflight frame count according to
* a latest acknowledged frame id.
- */
+ */
client->encoder->lastAckframeId = frameId;
}
-static BOOL shadow_client_surface_frame_acknowledge(rdpShadowClient* client, UINT32 frameId)
+static BOOL shadow_client_surface_frame_acknowledge(rdpShadowClient* client,
+ UINT32 frameId)
{
shadow_client_common_frame_acknowledge(client, frameId);
return TRUE;
}
-static UINT shadow_client_rdpgfx_frame_acknowledge(RdpgfxServerContext* context, RDPGFX_FRAME_ACKNOWLEDGE_PDU* frameAcknowledge)
+static UINT shadow_client_rdpgfx_frame_acknowledge(RdpgfxServerContext* context,
+ RDPGFX_FRAME_ACKNOWLEDGE_PDU* frameAcknowledge)
{
- shadow_client_common_frame_acknowledge((rdpShadowClient *)context->custom,
- frameAcknowledge->frameId);
+ shadow_client_common_frame_acknowledge((rdpShadowClient*)context->custom,
+ frameAcknowledge->frameId);
return CHANNEL_RC_OK;
}
-static UINT shadow_client_rdpgfx_qoe_frame_acknowledge(RdpgfxServerContext* context, RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU* qoeFrameAcknowledge)
+static UINT shadow_client_rdpgfx_qoe_frame_acknowledge(RdpgfxServerContext*
+ context, RDPGFX_QOE_FRAME_ACKNOWLEDGE_PDU* qoeFrameAcknowledge)
{
- shadow_client_common_frame_acknowledge((rdpShadowClient *)context->custom,
- qoeFrameAcknowledge->frameId);
+ shadow_client_common_frame_acknowledge((rdpShadowClient*)context->custom,
+ qoeFrameAcknowledge->frameId);
return CHANNEL_RC_OK;
}
* @return TRUE on success
*/
static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client,
- BYTE* pSrcData, int nSrcStep, int nXSrc, int nYSrc, int nWidth, int nHeight)
+ BYTE* pSrcData, int nSrcStep, int nXSrc, int nYSrc, int nWidth, int nHeight)
{
UINT error = CHANNEL_RC_OK;
rdpUpdate* update;
RDPGFX_START_FRAME_PDU cmdstart;
RDPGFX_END_FRAME_PDU cmdend;
SYSTEMTIME sTime;
-
context = (rdpContext*) client;
update = context->update;
settings = context->settings;
-
server = client->server;
encoder = client->encoder;
-
cmdstart.frameId = shadow_encoder_create_frame_id(encoder);
-
GetSystemTime(&sTime);
cmdstart.timestamp = sTime.wHour << 22 | sTime.wMinute << 16 |
- sTime.wSecond << 10 | sTime.wMilliseconds;
-
+ sTime.wSecond << 10 | sTime.wMilliseconds;
cmdend.frameId = cmdstart.frameId;
-
cmd.surfaceId = 0;
cmd.contextId = 0;
- cmd.format = PIXEL_FORMAT_XRGB32;
+ cmd.format = PIXEL_FORMAT_BGRX32;
cmd.left = nXSrc;
cmd.top = nYSrc;
cmd.right = cmd.left + nWidth;
return FALSE;
}
- avc420_compress(encoder->h264, pSrcData, PIXEL_FORMAT_XRGB32, nSrcStep,
- nWidth, nHeight, &avc420.data, &avc420.length);
-
+ avc420_compress(encoder->h264, pSrcData, cmd.format, nSrcStep,
+ nWidth, nHeight, &avc420.data, &avc420.length);
cmd.codecId = RDPGFX_CODECID_AVC420;
- cmd.extra = (void *)&avc420;
+ cmd.extra = (void*)&avc420;
regionRect.left = cmd.left;
regionRect.top = cmd.top;
regionRect.right = cmd.right;
avc420.meta.numRegionRects = 1;
avc420.meta.regionRects = ®ionRect;
avc420.meta.quantQualityVals = &quantQualityVal;
+ IFCALLRET(client->rdpgfx->SurfaceFrameCommand, error, client->rdpgfx, &cmd,
+ &cmdstart, &cmdend);
- IFCALLRET(client->rdpgfx->SurfaceFrameCommand, error, client->rdpgfx, &cmd, &cmdstart, &cmdend);
if (error)
{
WLog_ERR(TAG, "SurfaceFrameCommand failed with error %lu", error);
* @return TRUE on success
*/
static BOOL shadow_client_send_surface_bits(rdpShadowClient* client,
- BYTE* pSrcData, int nSrcStep, int nXSrc, int nYSrc, int nWidth, int nHeight)
+ BYTE* pSrcData, int nSrcStep, int nXSrc, int nYSrc, int nWidth, int nHeight)
{
BOOL ret = TRUE;
int i;
rdpShadowServer* server;
rdpShadowEncoder* encoder;
SURFACE_BITS_COMMAND cmd;
-
context = (rdpContext*) client;
update = context->update;
settings = context->settings;
-
server = client->server;
encoder = client->encoder;
{
RFX_RECT rect;
RFX_MESSAGE* messages;
- RFX_RECT *messageRects = NULL;
+ RFX_RECT* messageRects = NULL;
if (shadow_encoder_prepare(encoder, FREERDP_CODEC_REMOTEFX) < 0)
{
}
s = encoder->bs;
-
rect.x = nXSrc;
rect.y = nYSrc;
rect.width = nWidth;
rect.height = nHeight;
if (!(messages = rfx_encode_messages(encoder->rfx, &rect, 1, pSrcData,
- settings->DesktopWidth, settings->DesktopHeight, nSrcStep, &numMessages,
- settings->MultifragMaxRequestSize)))
+ settings->DesktopWidth, settings->DesktopHeight, nSrcStep, &numMessages,
+ settings->MultifragMaxRequestSize)))
{
WLog_ERR(TAG, "rfx_encode_messages failed");
return FALSE;
}
cmd.codecID = settings->RemoteFxCodecId;
-
cmd.destLeft = 0;
cmd.destTop = 0;
cmd.destRight = settings->DesktopWidth;
cmd.destBottom = settings->DesktopHeight;
-
cmd.bpp = 32;
cmd.width = settings->DesktopWidth;
cmd.height = settings->DesktopHeight;
for (i = 0; i < numMessages; i++)
{
Stream_SetPosition(s, 0);
+
if (!rfx_write_message(encoder->rfx, s, &messages[i]))
{
while (i < numMessages)
{
rfx_message_free(encoder->rfx, &messages[i++]);
}
+
WLog_ERR(TAG, "rfx_write_message failed");
ret = FALSE;
break;
}
- rfx_message_free(encoder->rfx, &messages[i]);
+ rfx_message_free(encoder->rfx, &messages[i]);
cmd.bitmapDataLength = Stream_GetPosition(s);
cmd.bitmapData = Stream_Buffer(s);
-
first = (i == 0) ? TRUE : FALSE;
last = ((i + 1) == numMessages) ? TRUE : FALSE;
if (!encoder->frameAck)
IFCALLRET(update->SurfaceBits, ret, update->context, &cmd);
else
- IFCALLRET(update->SurfaceFrameBits, ret, update->context, &cmd, first, last, frameId);
+ IFCALLRET(update->SurfaceFrameBits, ret, update->context, &cmd, first, last,
+ frameId);
if (!ret)
{
s = encoder->bs;
Stream_SetPosition(s, 0);
-
pSrcData = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)];
-
nsc_compose_message(encoder->nsc, s, pSrcData, nWidth, nHeight, nSrcStep);
-
cmd.bpp = 32;
cmd.codecID = settings->NSCodecId;
cmd.destLeft = nXSrc;
cmd.destBottom = cmd.destTop + nHeight;
cmd.width = nWidth;
cmd.height = nHeight;
-
cmd.bitmapDataLength = Stream_GetPosition(s);
cmd.bitmapData = Stream_Buffer(s);
-
first = TRUE;
last = TRUE;
if (!encoder->frameAck)
IFCALLRET(update->SurfaceBits, ret, update->context, &cmd);
else
- IFCALLRET(update->SurfaceFrameBits, ret, update->context, &cmd, first, last, frameId);
+ IFCALLRET(update->SurfaceFrameBits, ret, update->context, &cmd, first, last,
+ frameId);
if (!ret)
{
* @return TRUE on success
*/
static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client,
- BYTE* pSrcData, int nSrcStep, int nXSrc, int nYSrc, int nWidth, int nHeight)
+ BYTE* pSrcData, int nSrcStep, int nXSrc, int nYSrc, int nWidth, int nHeight)
{
BOOL ret = TRUE;
BYTE* data;
BITMAP_UPDATE bitmapUpdate;
rdpShadowServer* server;
rdpShadowEncoder* encoder;
-
context = (rdpContext*) client;
update = context->update;
settings = context->settings;
-
server = client->server;
encoder = client->encoder;
-
maxUpdateSize = settings->MultifragMaxRequestSize;
if (settings->ColorDepth < 32)
}
}
- SrcFormat = PIXEL_FORMAT_XRGB32;
+ SrcFormat = PIXEL_FORMAT_BGRX32;
if ((nXSrc % 4) != 0)
{
rows = (nHeight / 64) + ((nHeight % 64) ? 1 : 0);
cols = (nWidth / 64) + ((nWidth % 64) ? 1 : 0);
-
k = 0;
totalBitmapSize = 0;
-
bitmapUpdate.count = bitmapUpdate.number = rows * cols;
- if (!(bitmapData = (BITMAP_DATA*) malloc(sizeof(BITMAP_DATA) * bitmapUpdate.number)))
+
+ if (!(bitmapData = (BITMAP_DATA*) malloc(sizeof(BITMAP_DATA) *
+ bitmapUpdate.number)))
return FALSE;
+
bitmapUpdate.rectangles = bitmapData;
if ((nWidth % 4) != 0)
for (xIdx = 0; xIdx < cols; xIdx++)
{
bitmap = &bitmapData[k];
-
bitmap->width = 64;
bitmap->height = 64;
bitmap->destLeft = nXSrc + (xIdx * 64);
{
int bitsPerPixel = settings->ColorDepth;
int bytesPerPixel = (bitsPerPixel + 7) / 8;
-
DstSize = 64 * 64 * 4;
buffer = encoder->grid[k];
-
- interleaved_compress(encoder->interleaved, buffer, &DstSize, bitmap->width, bitmap->height,
- pSrcData, SrcFormat, nSrcStep, bitmap->destLeft, bitmap->destTop, NULL, bitsPerPixel);
-
+ interleaved_compress(encoder->interleaved, buffer, &DstSize, bitmap->width,
+ bitmap->height,
+ pSrcData, SrcFormat, nSrcStep, bitmap->destLeft, bitmap->destTop, NULL,
+ bitsPerPixel);
bitmap->bitmapDataStream = buffer;
bitmap->bitmapLength = DstSize;
bitmap->bitsPerPixel = bitsPerPixel;
else
{
UINT32 dstSize;
-
buffer = encoder->grid[k];
data = &pSrcData[(bitmap->destTop * nSrcStep) + (bitmap->destLeft * 4)];
-
buffer = freerdp_bitmap_compress_planar(encoder->planar, data, SrcFormat,
- bitmap->width, bitmap->height, nSrcStep, buffer, &dstSize);
-
+ bitmap->width, bitmap->height, nSrcStep, buffer, &dstSize);
bitmap->bitmapDataStream = buffer;
bitmap->bitmapLength = dstSize;
bitmap->bitsPerPixel = 32;
bitmap->cbCompFirstRowSize = 0;
bitmap->cbCompMainBodySize = bitmap->bitmapLength;
-
totalBitmapSize += bitmap->bitmapLength;
k++;
}
}
bitmapUpdate.count = bitmapUpdate.number = k;
-
updateSizeEstimate = totalBitmapSize + (k * bitmapUpdate.count) + 16;
if (updateSizeEstimate > maxUpdateSize)
ret = FALSE;
goto out;
}
- bitmapUpdate.rectangles = fragBitmapData;
+ bitmapUpdate.rectangles = fragBitmapData;
i = j = 0;
updateSize = 1024;
bitmapUpdate.count = bitmapUpdate.number = j;
IFCALLRET(update->BitmapUpdate, ret, context, &bitmapUpdate);
+
if (!ret)
{
WLog_ERR(TAG, "BitmapUpdate failed");
else
{
IFCALLRET(update->BitmapUpdate, ret, context, &bitmapUpdate);
+
if (!ret)
{
WLog_ERR(TAG, "BitmapUpdate failed");
out:
free(bitmapData);
-
return ret;
}
*
* @return TRUE on success (or nothing need to be updated)
*/
-static BOOL shadow_client_send_surface_update(rdpShadowClient* client, SHADOW_GFX_STATUS* pStatus)
+static BOOL shadow_client_send_surface_update(rdpShadowClient* client,
+ SHADOW_GFX_STATUS* pStatus)
{
BOOL ret = TRUE;
int nXSrc, nYSrc;
int index;
UINT32 numRects = 0;
const RECTANGLE_16* rects;
-
context = (rdpContext*) client;
settings = context->settings;
server = client->server;
encoder = client->encoder;
-
surface = client->inLobby ? server->lobby : server->surface;
-
EnterCriticalSection(&(client->lock));
-
region16_init(&invalidRegion);
region16_copy(&invalidRegion, &(client->invalidRegion));
region16_clear(&(client->invalidRegion));
-
LeaveCriticalSection(&(client->lock));
-
rects = region16_rects(&(surface->invalidRegion), &numRects);
+
for (index = 0; index < numRects; index++)
{
region16_union_rect(&invalidRegion, &invalidRegion, &rects[index]);
surfaceRect.top = 0;
surfaceRect.right = surface->width;
surfaceRect.bottom = surface->height;
-
region16_intersect_rect(&invalidRegion, &invalidRegion, &surfaceRect);
if (server->shareSubRect)
}
extents = region16_extents(&invalidRegion);
-
nXSrc = extents->left;
nYSrc = extents->top;
nWidth = extents->right - extents->left;
nHeight = extents->bottom - extents->top;
-
pSrcData = surface->data;
nSrcStep = surface->scanline;
if (server->shareSubRect)
{
int subX, subY;
-
subX = server->subRect.left;
subY = server->subRect.top;
-
nXSrc -= subX;
nYSrc -= subY;
pSrcData = &pSrcData[(subY * nSrcStep) + (subX * 4)];
pStatus->gfxSurfaceCreated = TRUE;
}
- ret = shadow_client_send_surface_gfx(client, pSrcData, nSrcStep, 0, 0, nWidth, nHeight);
+ ret = shadow_client_send_surface_gfx(client, pSrcData, nSrcStep, 0, 0, nWidth,
+ nHeight);
}
else if (settings->RemoteFxCodec || settings->NSCodec)
{
- ret = shadow_client_send_surface_bits(client, pSrcData, nSrcStep, nXSrc, nYSrc, nWidth, nHeight);
+ ret = shadow_client_send_surface_bits(client, pSrcData, nSrcStep, nXSrc, nYSrc,
+ nWidth, nHeight);
}
else
{
- ret = shadow_client_send_bitmap_update(client, pSrcData, nSrcStep, nXSrc, nYSrc, nWidth, nHeight);
+ ret = shadow_client_send_bitmap_update(client, pSrcData, nSrcStep, nXSrc, nYSrc,
+ nWidth, nHeight);
}
out:
region16_uninit(&invalidRegion);
-
return ret;
}
*
* @return TRUE on success
*/
-static BOOL shadow_client_send_resize(rdpShadowClient* client, SHADOW_GFX_STATUS* pStatus)
+static BOOL shadow_client_send_resize(rdpShadowClient* client,
+ SHADOW_GFX_STATUS* pStatus)
{
rdpContext* context;
rdpSettings* settings;
rdpShadowServer* server;
freerdp_peer* peer;
-
server = client->server;
context = (rdpContext*) client;
peer = context->peer;
settings = context->settings;
-
/**
* Unset client activated flag to avoid sending update message during
* resize. DesktopResize will reactive the client and
EnterCriticalSection(&(client->lock));
region16_clear(&(client->invalidRegion));
LeaveCriticalSection(&(client->lock));
-
WLog_INFO(TAG, "Client from %s is resized (%dx%d@%d)",
- peer->hostname, settings->DesktopWidth, settings->DesktopHeight, settings->ColorDepth);
-
+ peer->hostname, settings->DesktopWidth, settings->DesktopHeight,
+ settings->ColorDepth);
return TRUE;
}
{
UINT32 numRects = 0;
const RECTANGLE_16* rects;
-
rects = region16_rects(region, &numRects);
shadow_client_mark_invalid(client, numRects, rects);
-
return TRUE;
}
*
* @return TRUE on success
*/
-static INLINE BOOL shadow_client_no_surface_update(rdpShadowClient* client, SHADOW_GFX_STATUS* pStatus)
+static INLINE BOOL shadow_client_no_surface_update(rdpShadowClient* client,
+ SHADOW_GFX_STATUS* pStatus)
{
rdpShadowServer* server;
rdpShadowSurface* surface;
-
server = client->server;
surface = client->inLobby ? server->lobby : server->surface;
-
return shadow_client_surface_update(client, &(surface->invalidRegion));
}
-static int shadow_client_subsystem_process_message(rdpShadowClient* client, wMessage* message)
+static int shadow_client_subsystem_process_message(rdpShadowClient* client,
+ wMessage* message)
{
rdpContext* context = (rdpContext*) client;
rdpUpdate* update = context->update;
/* FIXME: the pointer updates appear to be broken when used with bulk compression and mstsc */
- switch(message->id)
+ switch (message->id)
{
case SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID:
- {
- POINTER_POSITION_UPDATE pointerPosition;
- SHADOW_MSG_OUT_POINTER_POSITION_UPDATE* msg = (SHADOW_MSG_OUT_POINTER_POSITION_UPDATE*) message->wParam;
-
- pointerPosition.xPos = msg->xPos;
- pointerPosition.yPos = msg->yPos;
-
- if (client->server->shareSubRect)
{
- pointerPosition.xPos -= client->server->subRect.left;
- pointerPosition.yPos -= client->server->subRect.top;
- }
+ POINTER_POSITION_UPDATE pointerPosition;
+ SHADOW_MSG_OUT_POINTER_POSITION_UPDATE* msg =
+ (SHADOW_MSG_OUT_POINTER_POSITION_UPDATE*) message->wParam;
+ pointerPosition.xPos = msg->xPos;
+ pointerPosition.yPos = msg->yPos;
- if (client->activated)
- {
- if ((msg->xPos != client->pointerX) || (msg->yPos != client->pointerY))
+ if (client->server->shareSubRect)
{
- IFCALL(update->pointer->PointerPosition, context, &pointerPosition);
-
- client->pointerX = msg->xPos;
- client->pointerY = msg->yPos;
+ pointerPosition.xPos -= client->server->subRect.left;
+ pointerPosition.yPos -= client->server->subRect.top;
}
- }
- break;
- }
- case SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE_ID:
- {
- POINTER_NEW_UPDATE pointerNew;
- POINTER_COLOR_UPDATE* pointerColor;
- POINTER_CACHED_UPDATE pointerCached;
- SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* msg = (SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE*) message->wParam;
- ZeroMemory(&pointerNew, sizeof(POINTER_NEW_UPDATE));
-
- pointerNew.xorBpp = 24;
- pointerColor = &(pointerNew.colorPtrAttr);
-
- pointerColor->cacheIndex = 0;
- pointerColor->xPos = msg->xHot;
- pointerColor->yPos = msg->yHot;
- pointerColor->width = msg->width;
- pointerColor->height = msg->height;
- pointerColor->lengthAndMask = msg->lengthAndMask;
- pointerColor->lengthXorMask = msg->lengthXorMask;
- pointerColor->xorMaskData = msg->xorMaskData;
- pointerColor->andMaskData = msg->andMaskData;
+ if (client->activated)
+ {
+ if ((msg->xPos != client->pointerX) || (msg->yPos != client->pointerY))
+ {
+ IFCALL(update->pointer->PointerPosition, context, &pointerPosition);
+ client->pointerX = msg->xPos;
+ client->pointerY = msg->yPos;
+ }
+ }
- pointerCached.cacheIndex = pointerColor->cacheIndex;
+ break;
+ }
- if (client->activated)
+ case SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE_ID:
{
- IFCALL(update->pointer->PointerNew, context, &pointerNew);
- IFCALL(update->pointer->PointerCached, context, &pointerCached);
+ POINTER_NEW_UPDATE pointerNew;
+ POINTER_COLOR_UPDATE* pointerColor;
+ POINTER_CACHED_UPDATE pointerCached;
+ SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* msg =
+ (SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE*) message->wParam;
+ ZeroMemory(&pointerNew, sizeof(POINTER_NEW_UPDATE));
+ pointerNew.xorBpp = 24;
+ pointerColor = &(pointerNew.colorPtrAttr);
+ pointerColor->cacheIndex = 0;
+ pointerColor->xPos = msg->xHot;
+ pointerColor->yPos = msg->yHot;
+ pointerColor->width = msg->width;
+ pointerColor->height = msg->height;
+ pointerColor->lengthAndMask = msg->lengthAndMask;
+ pointerColor->lengthXorMask = msg->lengthXorMask;
+ pointerColor->xorMaskData = msg->xorMaskData;
+ pointerColor->andMaskData = msg->andMaskData;
+ pointerCached.cacheIndex = pointerColor->cacheIndex;
+
+ if (client->activated)
+ {
+ IFCALL(update->pointer->PointerNew, context, &pointerNew);
+ IFCALL(update->pointer->PointerCached, context, &pointerCached);
+ }
+
+ break;
}
- break;
- }
+
case SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES_ID:
- {
- SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES* msg = (SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES*) message->wParam;
- if (client->activated && client->rdpsnd && client->rdpsnd->Activated)
{
- client->rdpsnd->src_format = msg->audio_format;
- IFCALL(client->rdpsnd->SendSamples, client->rdpsnd, msg->buf, msg->nFrames, msg->wTimestamp);
+ SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES* msg = (SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES*)
+ message->wParam;
+
+ if (client->activated && client->rdpsnd && client->rdpsnd->Activated)
+ {
+ client->rdpsnd->src_format = msg->audio_format;
+ IFCALL(client->rdpsnd->SendSamples, client->rdpsnd, msg->buf, msg->nFrames,
+ msg->wTimestamp);
+ }
+
+ break;
}
- break;
- }
+
case SHADOW_MSG_OUT_AUDIO_OUT_VOLUME_ID:
- {
- SHADOW_MSG_OUT_AUDIO_OUT_VOLUME* msg = (SHADOW_MSG_OUT_AUDIO_OUT_VOLUME*) message->wParam;
- if (client->activated && client->rdpsnd && client->rdpsnd->Activated)
{
- IFCALL(client->rdpsnd->SetVolume, client->rdpsnd, msg->left, msg->right);
+ SHADOW_MSG_OUT_AUDIO_OUT_VOLUME* msg = (SHADOW_MSG_OUT_AUDIO_OUT_VOLUME*)
+ message->wParam;
+
+ if (client->activated && client->rdpsnd && client->rdpsnd->Activated)
+ {
+ IFCALL(client->rdpsnd->SetVolume, client->rdpsnd, msg->left, msg->right);
+ }
+
+ break;
}
- break;
- }
+
default:
WLog_ERR(TAG, "Unknown message id: %u", message->id);
break;
}
shadow_client_free_queued_message(message);
-
return 1;
}
wMessageQueue* MsgQueue = client->MsgQueue;
/* This should only be visited in client thread */
SHADOW_GFX_STATUS gfxstatus;
-
gfxstatus.gfxOpened = FALSE;
gfxstatus.gfxSurfaceCreated = FALSE;
-
server = client->server;
screen = server->screen;
encoder = client->encoder;
subsystem = server->subsystem;
-
context = (rdpContext*) client;
peer = context->peer;
settings = peer->settings;
-
peer->Capabilities = shadow_client_capabilities;
peer->PostConnect = shadow_client_post_connect;
peer->Activate = shadow_client_activate;
peer->Logon = shadow_client_logon;
-
shadow_input_register_callbacks(peer->input);
-
peer->Initialize(peer);
-
peer->update->RefreshRect = (pRefreshRect)shadow_client_refresh_rect;
peer->update->SuppressOutput = (pSuppressOutput)shadow_client_suppress_output;
- peer->update->SurfaceFrameAcknowledge = (pSurfaceFrameAcknowledge)shadow_client_surface_frame_acknowledge;
+ peer->update->SurfaceFrameAcknowledge = (pSurfaceFrameAcknowledge)
+ shadow_client_surface_frame_acknowledge;
if ((!client->vcm) || (!subsystem->updateEvent))
goto out;
UpdateSubscriber = shadow_multiclient_get_subscriber(subsystem->updateEvent);
+
if (!UpdateSubscriber)
goto out;
events[nCount++] = ClientEvent;
events[nCount++] = ChannelEvent;
events[nCount++] = MessageQueue_Event(MsgQueue);
-
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
if (WaitForSingleObject(UpdateEvent, 0) == WAIT_OBJECT_0)
* (at shadow_multiclient_consume). As best practice, subsystem
* implementation should invoke shadow_subsystem_frame_update which
* triggers the event and then wait for completion */
-
if (client->activated && !client->suppressOutput)
{
/* Send screen update or resize to this client */
break;
}
}
- else if (WTSVirtualChannelManagerGetDrdynvcState(client->vcm) == DRDYNVC_STATE_READY)
+ else if (WTSVirtualChannelManagerGetDrdynvcState(client->vcm) ==
+ DRDYNVC_STATE_READY)
{
/* Init RDPGFX dynamic channel */
if (settings->SupportGraphicsPipeline && client->rdpgfx &&
}
client->rdpgfx->FrameAcknowledge = shadow_client_rdpgfx_frame_acknowledge;
- client->rdpgfx->QoeFrameAcknowledge = shadow_client_rdpgfx_qoe_frame_acknowledge;
-
+ client->rdpgfx->QoeFrameAcknowledge =
+ shadow_client_rdpgfx_qoe_frame_acknowledge;
gfxstatus.gfxOpened = TRUE;
WLog_INFO(TAG, "Gfx Pipeline Opened");
}
{
/* Drain messages. Pointer update could be accumulated. */
pointerPositionMsg.id = 0;
- pointerPositionMsg.Free= NULL;
+ pointerPositionMsg.Free = NULL;
pointerAlphaMsg.id = 0;
pointerAlphaMsg.Free = NULL;
audioVolumeMsg.id = 0;
audioVolumeMsg.Free = NULL;
+
while (MessageQueue_Peek(MsgQueue, &message, TRUE))
{
if (message.id == WMQ_QUIT)
break;
}
- switch(message.id)
+ switch (message.id)
{
case SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID:
/* Abandon previous message */
{
shadow_client_subsystem_process_message(client, &pointerPositionMsg);
}
+
if (pointerAlphaMsg.id)
{
shadow_client_subsystem_process_message(client, &pointerAlphaMsg);
}
+
if (audioVolumeMsg.id)
{
shadow_client_subsystem_process_message(client, &audioVolumeMsg);
if (!shadow_client_rdpgfx_release_surface(client))
WLog_WARN(TAG, "GFX release surface failure!");
}
+
(void)client->rdpgfx->Close(client->rdpgfx);
}
+
shadow_client_channels_free(client);
if (UpdateSubscriber)
out:
peer->Disconnect(peer);
-
freerdp_peer_context_free(peer);
freerdp_peer_free(peer);
ExitThread(0);
{
rdpShadowClient* client;
rdpShadowServer* server;
-
server = (rdpShadowServer*) listener->info;
-
peer->ContextExtra = (void*) server;
peer->ContextSize = sizeof(rdpShadowClient);
peer->ContextNew = (psPeerContextNew) shadow_client_context_new;
peer->ContextFree = (psPeerContextFree) shadow_client_context_free;
-
peer->settings = freerdp_settings_clone(server->settings);
if (!freerdp_peer_context_new(peer))
client = (rdpShadowClient*) peer->context;
if (!(client->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)
- shadow_client_thread, client, 0, NULL)))
+ shadow_client_thread, client, 0, NULL)))
{
freerdp_peer_context_free(peer);
return FALSE;
static void shadow_msg_out_addref(wMessage* message)
{
- SHADOW_MSG_OUT* msg = (SHADOW_MSG_OUT *)message->wParam;
+ SHADOW_MSG_OUT* msg = (SHADOW_MSG_OUT*)message->wParam;
InterlockedIncrement(&(msg->refCount));
}
static void shadow_msg_out_release(wMessage* message)
{
- SHADOW_MSG_OUT* msg = (SHADOW_MSG_OUT *)message->wParam;
+ SHADOW_MSG_OUT* msg = (SHADOW_MSG_OUT*)message->wParam;
+
if (InterlockedDecrement(&(msg->refCount)) <= 0)
{
if (msg->Free)
}
}
-static BOOL shadow_client_dispatch_msg(rdpShadowClient* client, wMessage* message)
+static BOOL shadow_client_dispatch_msg(rdpShadowClient* client,
+ wMessage* message)
{
/* Add reference when it is posted */
shadow_msg_out_addref(message);
+
if (MessageQueue_Dispatch(client->MsgQueue, message))
{
return TRUE;
}
}
-BOOL shadow_client_post_msg(rdpShadowClient* client, void* context, UINT32 type, SHADOW_MSG_OUT* msg, void* lParam)
+BOOL shadow_client_post_msg(rdpShadowClient* client, void* context, UINT32 type,
+ SHADOW_MSG_OUT* msg, void* lParam)
{
wMessage message = {0};
-
message.context = context;
message.id = type;
- message.wParam = (void *)msg;
+ message.wParam = (void*)msg;
message.lParam = lParam;
message.Free = shadow_msg_out_release;
-
return shadow_client_dispatch_msg(client, &message);
}
-int shadow_client_boardcast_msg(rdpShadowServer* server, void* context, UINT32 type, SHADOW_MSG_OUT* msg, void* lParam)
+int shadow_client_boardcast_msg(rdpShadowServer* server, void* context,
+ UINT32 type, SHADOW_MSG_OUT* msg, void* lParam)
{
wMessage message = {0};
rdpShadowClient* client = NULL;
int count = 0;
int index = 0;
-
message.context = context;
message.id = type;
- message.wParam = (void *)msg;
+ message.wParam = (void*)msg;
message.lParam = lParam;
message.Free = shadow_msg_out_release;
-
/* First add reference as we reference it in this function.
- * Therefore it would not be free'ed during post. */
+ * Therefore it would not be free'ed during post. */
shadow_msg_out_addref(&message);
-
ArrayList_Lock(server->clients);
+
for (index = 0; index < ArrayList_Count(server->clients); index++)
{
client = (rdpShadowClient*)ArrayList_GetItem(server->clients, index);
+
if (shadow_client_dispatch_msg(client, &message))
{
count++;
}
}
- ArrayList_Unlock(server->clients);
- /* Release the reference for this function */
+ ArrayList_Unlock(server->clients);
+ /* Release the reference for this function */
shadow_msg_out_release(&message);
-
return count;
}
wMessageQueue* queue = NULL;
int count = 0;
int index = 0;
-
ArrayList_Lock(server->clients);
+
for (index = 0; index < ArrayList_Count(server->clients); index++)
{
queue = ((rdpShadowClient*)ArrayList_GetItem(server->clients, index))->MsgQueue;
+
if (MessageQueue_PostQuit(queue, nExitCode))
{
count++;
}
}
- ArrayList_Unlock(server->clients);
+ ArrayList_Unlock(server->clients);
return count;
}
{
UINT32 frameId;
int inFlightFrames;
-
inFlightFrames = shadow_encoder_inflight_frames(encoder);
- /*
- * Calculate preferred fps according to how much frames are
+ /*
+ * Calculate preferred fps according to how much frames are
* in-progress. Note that it only works when subsytem implementation
* calls shadow_encoder_preferred_fps and takes the suggestion.
- */
+ */
if (inFlightFrames > 1)
{
encoder->fps = (100 / (inFlightFrames + 1) * encoder->maxFps) / 100;
encoder->fps = 1;
frameId = ++encoder->frameId;
-
return frameId;
}
-int shadow_encoder_init_grid(rdpShadowEncoder* encoder)
+static int shadow_encoder_init_grid(rdpShadowEncoder* encoder)
{
int i, j, k;
int tileSize;
int tileCount;
-
- encoder->gridWidth = ((encoder->width + (encoder->maxTileWidth - 1)) / encoder->maxTileWidth);
- encoder->gridHeight = ((encoder->height + (encoder->maxTileHeight - 1)) / encoder->maxTileHeight);
-
+ encoder->gridWidth = ((encoder->width + (encoder->maxTileWidth - 1)) /
+ encoder->maxTileWidth);
+ encoder->gridHeight = ((encoder->height + (encoder->maxTileHeight - 1)) /
+ encoder->maxTileHeight);
tileSize = encoder->maxTileWidth * encoder->maxTileHeight * 4;
tileCount = encoder->gridWidth * encoder->gridHeight;
-
encoder->gridBuffer = (BYTE*) malloc(tileSize * tileCount);
if (!encoder->gridBuffer)
return 0;
}
-int shadow_encoder_uninit_grid(rdpShadowEncoder* encoder)
+static int shadow_encoder_uninit_grid(rdpShadowEncoder* encoder)
{
if (encoder->gridBuffer)
{
encoder->gridWidth = 0;
encoder->gridHeight = 0;
-
return 0;
}
-int shadow_encoder_init_rfx(rdpShadowEncoder* encoder)
+static int shadow_encoder_init_rfx(rdpShadowEncoder* encoder)
{
if (!encoder->rfx)
encoder->rfx = rfx_context_new(TRUE);
goto fail;
encoder->rfx->mode = encoder->server->rfxMode;
-
- rfx_context_set_pixel_format(encoder->rfx, PIXEL_FORMAT_BGR24);
-
+ rfx_context_set_pixel_format(encoder->rfx, PIXEL_FORMAT_BGRX32);
encoder->codecs |= FREERDP_CODEC_REMOTEFX;
-
return 1;
-
fail:
rfx_context_free(encoder->rfx);
return -1;
}
-int shadow_encoder_init_nsc(rdpShadowEncoder* encoder)
+static int shadow_encoder_init_nsc(rdpShadowEncoder* encoder)
{
rdpContext* context = (rdpContext*) encoder->client;
rdpSettings* settings = context->settings;
goto fail;
encoder->nsc->ColorLossLevel = settings->NSCodecColorLossLevel;
- encoder->nsc->ChromaSubsamplingLevel = settings->NSCodecAllowSubsampling ? 1 : 0;
+ encoder->nsc->ChromaSubsamplingLevel = settings->NSCodecAllowSubsampling ? 1 :
+ 0;
encoder->nsc->DynamicColorFidelity = settings->NSCodecAllowDynamicColorFidelity;
-
- nsc_context_set_pixel_format(encoder->nsc, PIXEL_FORMAT_BGR24);
-
+ nsc_context_set_pixel_format(encoder->nsc, PIXEL_FORMAT_BGRX32);
encoder->codecs |= FREERDP_CODEC_NSCODEC;
-
return 1;
-
fail:
nsc_context_free(encoder->nsc);
return -1;
}
-int shadow_encoder_init_planar(rdpShadowEncoder* encoder)
+static int shadow_encoder_init_planar(rdpShadowEncoder* encoder)
{
DWORD planarFlags = 0;
rdpContext* context = (rdpContext*) encoder->client;
if (!encoder->planar)
{
encoder->planar = freerdp_bitmap_planar_context_new(planarFlags,
- encoder->maxTileWidth, encoder->maxTileHeight);
+ encoder->maxTileWidth, encoder->maxTileHeight);
}
if (!encoder->planar)
goto fail;
if (!freerdp_bitmap_planar_context_reset(encoder->planar,
- encoder->maxTileWidth,
- encoder->maxTileHeight))
+ encoder->maxTileWidth,
+ encoder->maxTileHeight))
goto fail;
encoder->codecs |= FREERDP_CODEC_PLANAR;
-
return 1;
-
fail:
freerdp_bitmap_planar_context_free(encoder->planar);
return -1;
}
-int shadow_encoder_init_interleaved(rdpShadowEncoder* encoder)
+static int shadow_encoder_init_interleaved(rdpShadowEncoder* encoder)
{
if (!encoder->interleaved)
encoder->interleaved = bitmap_interleaved_context_new(TRUE);
goto fail;
encoder->codecs |= FREERDP_CODEC_INTERLEAVED;
-
return 1;
-
fail:
bitmap_interleaved_context_free(encoder->interleaved);
return -1;
}
-int shadow_encoder_init_h264(rdpShadowEncoder* encoder)
+static int shadow_encoder_init_h264(rdpShadowEncoder* encoder)
{
if (!encoder->h264)
encoder->h264 = h264_context_new(TRUE);
encoder->h264->BitRate = encoder->server->h264BitRate;
encoder->h264->FrameRate = encoder->server->h264FrameRate;
encoder->h264->QP = encoder->server->h264QP;
-
encoder->codecs |= FREERDP_CODEC_AVC420;
-
return 1;
-
fail:
h264_context_free(encoder->h264);
return -1;
}
-int shadow_encoder_init(rdpShadowEncoder* encoder)
+static int shadow_encoder_init(rdpShadowEncoder* encoder)
{
encoder->width = encoder->server->screen->width;
encoder->height = encoder->server->screen->height;
-
encoder->maxTileWidth = 64;
encoder->maxTileHeight = 64;
-
shadow_encoder_init_grid(encoder);
if (!encoder->bs)
- encoder->bs = Stream_New(NULL, encoder->maxTileWidth * encoder->maxTileHeight * 4);
+ encoder->bs = Stream_New(NULL,
+ encoder->maxTileWidth * encoder->maxTileHeight * 4);
if (!encoder->bs)
return -1;
return 1;
}
-int shadow_encoder_uninit_rfx(rdpShadowEncoder* encoder)
+static int shadow_encoder_uninit_rfx(rdpShadowEncoder* encoder)
{
if (encoder->rfx)
{
}
encoder->codecs &= ~FREERDP_CODEC_REMOTEFX;
-
return 1;
}
-int shadow_encoder_uninit_nsc(rdpShadowEncoder* encoder)
+static int shadow_encoder_uninit_nsc(rdpShadowEncoder* encoder)
{
if (encoder->nsc)
{
}
encoder->codecs &= ~FREERDP_CODEC_NSCODEC;
-
return 1;
}
-int shadow_encoder_uninit_planar(rdpShadowEncoder* encoder)
+static int shadow_encoder_uninit_planar(rdpShadowEncoder* encoder)
{
if (encoder->planar)
{
}
encoder->codecs &= ~FREERDP_CODEC_PLANAR;
-
return 1;
}
-int shadow_encoder_uninit_interleaved(rdpShadowEncoder* encoder)
+static int shadow_encoder_uninit_interleaved(rdpShadowEncoder* encoder)
{
if (encoder->interleaved)
{
}
encoder->codecs &= ~FREERDP_CODEC_INTERLEAVED;
-
return 1;
}
-int shadow_encoder_uninit_h264(rdpShadowEncoder* encoder)
+static int shadow_encoder_uninit_h264(rdpShadowEncoder* encoder)
{
if (encoder->h264)
{
h264_context_free(encoder->h264);
- encoder->h264= NULL;
+ encoder->h264 = NULL;
}
encoder->codecs &= ~FREERDP_CODEC_AVC420;
-
return 1;
}
-int shadow_encoder_uninit(rdpShadowEncoder* encoder)
+static int shadow_encoder_uninit(rdpShadowEncoder* encoder)
{
shadow_encoder_uninit_grid(encoder);
UINT32 codecs = encoder->codecs;
rdpContext* context = (rdpContext*) encoder->client;
rdpSettings* settings = context->settings;
-
status = shadow_encoder_uninit(encoder);
if (status < 0)
encoder->frameId = 0;
encoder->lastAckframeId = 0;
encoder->frameAck = settings->SurfaceFrameMarkerEnabled;
-
return 1;
}
{
int status;
- if ((codecs & FREERDP_CODEC_REMOTEFX) && !(encoder->codecs & FREERDP_CODEC_REMOTEFX))
+ if ((codecs & FREERDP_CODEC_REMOTEFX)
+ && !(encoder->codecs & FREERDP_CODEC_REMOTEFX))
{
status = shadow_encoder_init_rfx(encoder);
return -1;
}
- if ((codecs & FREERDP_CODEC_NSCODEC) && !(encoder->codecs & FREERDP_CODEC_NSCODEC))
+ if ((codecs & FREERDP_CODEC_NSCODEC)
+ && !(encoder->codecs & FREERDP_CODEC_NSCODEC))
{
status = shadow_encoder_init_nsc(encoder);
return -1;
}
- if ((codecs & FREERDP_CODEC_PLANAR) && !(encoder->codecs & FREERDP_CODEC_PLANAR))
+ if ((codecs & FREERDP_CODEC_PLANAR)
+ && !(encoder->codecs & FREERDP_CODEC_PLANAR))
{
status = shadow_encoder_init_planar(encoder);
return -1;
}
- if ((codecs & FREERDP_CODEC_INTERLEAVED) && !(encoder->codecs & FREERDP_CODEC_INTERLEAVED))
+ if ((codecs & FREERDP_CODEC_INTERLEAVED)
+ && !(encoder->codecs & FREERDP_CODEC_INTERLEAVED))
{
status = shadow_encoder_init_interleaved(encoder);
return -1;
}
- if ((codecs & FREERDP_CODEC_AVC420) && !(encoder->codecs & FREERDP_CODEC_AVC420))
+ if ((codecs & FREERDP_CODEC_AVC420)
+ && !(encoder->codecs & FREERDP_CODEC_AVC420))
{
status = shadow_encoder_init_h264(encoder);
{
rdpShadowEncoder* encoder;
rdpShadowServer* server = client->server;
-
encoder = (rdpShadowEncoder*) calloc(1, sizeof(rdpShadowEncoder));
if (!encoder)
encoder->client = client;
encoder->server = server;
-
encoder->fps = 16;
encoder->maxFps = 32;
if (shadow_encoder_init(encoder) < 0)
{
- free (encoder);
+ free(encoder);
return NULL;
}
return;
shadow_encoder_uninit(encoder);
-
free(encoder);
}
#include "shadow_surface.h"
#define ALIGN_SCREEN_SIZE(size, align) ((size + align - 1) & (~(align - 1)))
-rdpShadowSurface* shadow_surface_new(rdpShadowServer* server, int x, int y, int width, int height)
+rdpShadowSurface* shadow_surface_new(rdpShadowServer* server, int x, int y,
+ int width, int height)
{
rdpShadowSurface* surface;
-
surface = (rdpShadowSurface*) calloc(1, sizeof(rdpShadowSurface));
if (!surface)
return NULL;
surface->server = server;
-
surface->x = x;
surface->y = y;
surface->width = width;
surface->height = height;
surface->scanline = ALIGN_SCREEN_SIZE(surface->width, 4) * 4;
+ surface->format = PIXEL_FORMAT_BGRX32;
+ surface->data = (BYTE*) calloc(1,
+ surface->scanline * ALIGN_SCREEN_SIZE(surface->height, 4));
- surface->data = (BYTE*) calloc(1, surface->scanline * ALIGN_SCREEN_SIZE(surface->height, 4));
if (!surface->data)
{
- free (surface);
+ free(surface);
return NULL;
}
if (!InitializeCriticalSectionAndSpinCount(&(surface->lock), 4000))
{
- free (surface->data);
- free (surface);
+ free(surface->data);
+ free(surface);
return NULL;
}
region16_init(&(surface->invalidRegion));
-
return surface;
}
return;
free(surface->data);
-
DeleteCriticalSection(&(surface->lock));
-
region16_uninit(&(surface->invalidRegion));
-
free(surface);
}
-BOOL shadow_surface_resize(rdpShadowSurface *surface, int x, int y, int width, int height)
+BOOL shadow_surface_resize(rdpShadowSurface* surface, int x, int y, int width,
+ int height)
{
BYTE* buffer = NULL;
int scanline = ALIGN_SCREEN_SIZE(width, 4) * 4;
return TRUE;
}
- buffer = (BYTE*) realloc(surface->data, scanline * ALIGN_SCREEN_SIZE(height, 4));
+ buffer = (BYTE*) realloc(surface->data, scanline * ALIGN_SCREEN_SIZE(height,
+ 4));
+
if (buffer)
{
surface->x = x;
surface->height = height;
surface->scanline = scanline;
surface->data = buffer;
-
return TRUE;
}