server/test: update the test server to show a background color.
This commit is contained in:
parent
5c49ba7ba5
commit
ebe94ce0b6
@ -3,6 +3,7 @@
|
||||
* FreeRDP Test Server
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
* Copyright 2011 Vic Lee
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -34,91 +35,91 @@ static const unsigned int test_quantization_values[] =
|
||||
6, 6, 6, 6, 7, 7, 8, 8, 8, 9
|
||||
};
|
||||
|
||||
static const uint8 rgb_scanline_data[] =
|
||||
struct test_peer_info
|
||||
{
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00,
|
||||
0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF,
|
||||
0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF
|
||||
RFX_CONTEXT* context;
|
||||
STREAM* s;
|
||||
};
|
||||
typedef struct test_peer_info testPeerInfo;
|
||||
|
||||
#define WIDTH 64
|
||||
#define HEIGHT 48
|
||||
|
||||
void test_peer_init_desktop(freerdp_peer* client)
|
||||
static void test_peer_init(freerdp_peer* client)
|
||||
{
|
||||
testPeerInfo* info;
|
||||
|
||||
info = xnew(testPeerInfo);
|
||||
|
||||
info->context = rfx_context_new();
|
||||
info->context->mode = RLGR3;
|
||||
info->context->width = client->settings->width;
|
||||
info->context->height = client->settings->height;
|
||||
rfx_context_set_pixel_format(info->context, RFX_PIXEL_FORMAT_RGB);
|
||||
|
||||
info->s = stream_new(65536);
|
||||
|
||||
client->param1 = info;
|
||||
}
|
||||
|
||||
static void test_peer_uninit(freerdp_peer* client)
|
||||
{
|
||||
testPeerInfo* info = (testPeerInfo*)client->param1;
|
||||
|
||||
if (info)
|
||||
{
|
||||
stream_free(info->s);
|
||||
rfx_context_free(info->context);
|
||||
xfree(info);
|
||||
}
|
||||
}
|
||||
|
||||
static STREAM* test_peer_stream_init(testPeerInfo* info)
|
||||
{
|
||||
stream_clear(info->s);
|
||||
stream_set_pos(info->s, 0);
|
||||
return info->s;
|
||||
}
|
||||
|
||||
static void test_peer_draw_background(freerdp_peer* client)
|
||||
{
|
||||
testPeerInfo* info = (testPeerInfo*)client->param1;
|
||||
rdpUpdate* update = client->update;
|
||||
SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command;
|
||||
RFX_CONTEXT* context;
|
||||
uint8* rgb_data;
|
||||
STREAM* s;
|
||||
int i;
|
||||
RFX_RECT rect = {0, 0, WIDTH, HEIGHT};
|
||||
RFX_RECT rect;
|
||||
uint8* rgb_data;
|
||||
int size;
|
||||
|
||||
if (!client->settings->rfx_codec)
|
||||
return;
|
||||
|
||||
rgb_data = (uint8*) xmalloc(128 * 128 * 3);
|
||||
for (i = 0; i < 128; i++)
|
||||
memcpy(rgb_data + i * 128 * 3, rgb_scanline_data, 128 * 3);
|
||||
s = test_peer_stream_init(info);
|
||||
|
||||
s = stream_new(65536);
|
||||
stream_clear(s);
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = client->settings->width;
|
||||
rect.height = client->settings->height;
|
||||
|
||||
context = rfx_context_new();
|
||||
context->mode = RLGR3;
|
||||
context->width = client->settings->width;
|
||||
context->height = client->settings->height;
|
||||
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
|
||||
size = rect.width * rect.height * 3;
|
||||
rgb_data = xmalloc(size);
|
||||
memset(rgb_data, 0xA0, size);
|
||||
|
||||
/* In Video mode, the RemoteFX header should only be sent once */
|
||||
rfx_compose_message_header(context, s);
|
||||
rfx_compose_message_header(info->context, s);
|
||||
|
||||
rfx_compose_message_data(info->context, s,
|
||||
&rect, 1, rgb_data, rect.width, rect.height, rect.width * 3);
|
||||
|
||||
rfx_compose_message_data(context, s,
|
||||
&rect, 1, rgb_data, WIDTH, HEIGHT, 128 * 3);
|
||||
cmd->destLeft = 0;
|
||||
cmd->destTop = 0;
|
||||
cmd->destRight = WIDTH;
|
||||
cmd->destBottom = HEIGHT;
|
||||
cmd->destRight = rect.width;
|
||||
cmd->destBottom = rect.height;
|
||||
cmd->bpp = 32;
|
||||
cmd->codecID = client->settings->rfx_codec_id;
|
||||
cmd->width = WIDTH;
|
||||
cmd->height = HEIGHT;
|
||||
cmd->width = rect.width;
|
||||
cmd->height = rect.height;
|
||||
cmd->bitmapDataLength = stream_get_length(s);
|
||||
cmd->bitmapData = stream_get_head(s);
|
||||
update->SurfaceBits(update, cmd);
|
||||
|
||||
stream_free(s);
|
||||
rfx_context_free(context);
|
||||
xfree(rgb_data);
|
||||
}
|
||||
|
||||
@ -145,7 +146,8 @@ boolean test_peer_post_connect(freerdp_peer* client)
|
||||
client->settings->width, client->settings->height, client->settings->color_depth);
|
||||
|
||||
/* A real server should tag the peer as activated here and start sending updates in mainloop. */
|
||||
test_peer_init_desktop(client);
|
||||
test_peer_init(client);
|
||||
test_peer_draw_background(client);
|
||||
|
||||
/* Return False here would stop the execution of the peer mainloop. */
|
||||
return True;
|
||||
@ -253,6 +255,7 @@ static void* test_peer_mainloop(void* arg)
|
||||
printf("Client %s disconnected.\n", client->settings->hostname);
|
||||
|
||||
client->Disconnect(client);
|
||||
test_peer_uninit(client);
|
||||
freerdp_peer_free(client);
|
||||
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user