libfreerdp-core: fix server-side color depth negotiation

This commit is contained in:
Marc-André Moreau 2013-01-27 17:17:04 -05:00
parent e1d0fad519
commit d8afffd3a8
5 changed files with 19 additions and 8 deletions

View File

@ -212,8 +212,9 @@ BOOL rdp_read_bitmap_capability_set(STREAM* s, UINT16 length, rdpSettings* setti
UINT16 desktopResizeFlag; UINT16 desktopResizeFlag;
UINT16 preferredBitsPerPixel; UINT16 preferredBitsPerPixel;
if(length < 28) if (length < 28)
return FALSE; return FALSE;
stream_read_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */ stream_read_UINT16(s, preferredBitsPerPixel); /* preferredBitsPerPixel (2 bytes) */
stream_seek_UINT16(s); /* receive1BitPerPixel (2 bytes) */ stream_seek_UINT16(s); /* receive1BitPerPixel (2 bytes) */
stream_seek_UINT16(s); /* receive4BitsPerPixel (2 bytes) */ stream_seek_UINT16(s); /* receive4BitsPerPixel (2 bytes) */
@ -228,7 +229,7 @@ BOOL rdp_read_bitmap_capability_set(STREAM* s, UINT16 length, rdpSettings* setti
stream_seek_UINT16(s); /* multipleRectangleSupport (2 bytes) */ stream_seek_UINT16(s); /* multipleRectangleSupport (2 bytes) */
stream_seek_UINT16(s); /* pad2OctetsB (2 bytes) */ stream_seek_UINT16(s); /* pad2OctetsB (2 bytes) */
if (!settings->ServerMode && preferredBitsPerPixel != settings->ColorDepth) if (!settings->ServerMode && (preferredBitsPerPixel != settings->ColorDepth))
{ {
/* The client must respect the actual color depth used by the server */ /* The client must respect the actual color depth used by the server */
settings->ColorDepth = preferredBitsPerPixel; settings->ColorDepth = preferredBitsPerPixel;
@ -243,6 +244,7 @@ BOOL rdp_read_bitmap_capability_set(STREAM* s, UINT16 length, rdpSettings* setti
settings->DesktopWidth = desktopWidth; settings->DesktopWidth = desktopWidth;
settings->DesktopHeight = desktopHeight; settings->DesktopHeight = desktopHeight;
} }
return TRUE; return TRUE;
} }
@ -1546,8 +1548,9 @@ BOOL rdp_read_bitmap_codecs_capability_set(STREAM* s, UINT16 length, rdpSettings
UINT16 codecPropertiesLength; UINT16 codecPropertiesLength;
UINT16 remainingLength; UINT16 remainingLength;
if(length < 5) if (length < 5)
return FALSE; return FALSE;
stream_read_BYTE(s, bitmapCodecCount); /* bitmapCodecCount (1 byte) */ stream_read_BYTE(s, bitmapCodecCount); /* bitmapCodecCount (1 byte) */
remainingLength = length - 5; remainingLength = length - 5;
@ -1560,8 +1563,9 @@ BOOL rdp_read_bitmap_codecs_capability_set(STREAM* s, UINT16 length, rdpSettings
while (bitmapCodecCount > 0) while (bitmapCodecCount > 0)
{ {
if(remainingLength < 19) if (remainingLength < 19)
return FALSE; return FALSE;
if (settings->ServerMode && strncmp((char*) stream_get_tail(s), CODEC_GUID_REMOTEFX, 16) == 0) if (settings->ServerMode && strncmp((char*) stream_get_tail(s), CODEC_GUID_REMOTEFX, 16) == 0)
{ {
stream_seek(s, 16); /* codecGUID (16 bytes) */ stream_seek(s, 16); /* codecGUID (16 bytes) */
@ -1582,7 +1586,8 @@ BOOL rdp_read_bitmap_codecs_capability_set(STREAM* s, UINT16 length, rdpSettings
stream_read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */ stream_read_UINT16(s, codecPropertiesLength); /* codecPropertiesLength (2 bytes) */
remainingLength -= 19; remainingLength -= 19;
if(remainingLength < codecPropertiesLength)
if (remainingLength < codecPropertiesLength)
return FALSE; return FALSE;
stream_seek(s, codecPropertiesLength); /* codecProperties */ stream_seek(s, codecPropertiesLength); /* codecProperties */

View File

@ -597,7 +597,10 @@ BOOL gcc_read_client_core_data(STREAM* s, rdpSettings* settings, UINT16 blockLen
if (highColorDepth > 0) if (highColorDepth > 0)
{ {
color_depth = highColorDepth; if (earlyCapabilityFlags & RNS_UD_CS_WANT_32BPP_SESSION)
color_depth = 32;
else
color_depth = highColorDepth;
} }
else if (postBeta2ColorDepth > 0) else if (postBeta2ColorDepth > 0)
{ {
@ -641,7 +644,7 @@ BOOL gcc_read_client_core_data(STREAM* s, rdpSettings* settings, UINT16 blockLen
* If we are in server mode, accept client's color depth only if * If we are in server mode, accept client's color depth only if
* it is smaller than ours. This is what Windows server does. * it is smaller than ours. This is what Windows server does.
*/ */
if (color_depth < settings->ColorDepth || !settings->ServerMode) if ((color_depth < settings->ColorDepth) || !settings->ServerMode)
settings->ColorDepth = color_depth; settings->ColorDepth = color_depth;
return TRUE; return TRUE;

View File

@ -511,6 +511,7 @@ void* mf_peer_main_loop(void* arg)
client->settings->PrivateKeyFile = _strdup("server.key"); client->settings->PrivateKeyFile = _strdup("server.key");
client->settings->NlaSecurity = FALSE; client->settings->NlaSecurity = FALSE;
client->settings->RemoteFxCodec = TRUE; client->settings->RemoteFxCodec = TRUE;
client->settings->ColorDepth = 32;
client->settings->SuppressOutput = TRUE; client->settings->SuppressOutput = TRUE;
client->settings->RefreshRect = FALSE; client->settings->RefreshRect = FALSE;

View File

@ -235,6 +235,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam)
settings = client->settings; settings = client->settings;
settings->RemoteFxCodec = TRUE; settings->RemoteFxCodec = TRUE;
settings->ColorDepth = 32;
settings->NSCodec = FALSE; settings->NSCodec = FALSE;
settings->JpegCodec = FALSE; settings->JpegCodec = FALSE;
wf_peer_read_settings(client); wf_peer_read_settings(client);

View File

@ -647,6 +647,7 @@ void* xf_peer_main_loop(void* arg)
settings->PrivateKeyFile = freerdp_construct_path(server_file_path, "server.key"); settings->PrivateKeyFile = freerdp_construct_path(server_file_path, "server.key");
settings->RemoteFxCodec = TRUE; settings->RemoteFxCodec = TRUE;
settings->ColorDepth = 32;
client->Capabilities = xf_peer_capabilities; client->Capabilities = xf_peer_capabilities;
client->PostConnect = xf_peer_post_connect; client->PostConnect = xf_peer_post_connect;