Unified RFX server color format.

This commit is contained in:
Armin Novak 2016-10-04 16:54:11 +02:00
parent ddced3f3ca
commit 9a1c60885c
3 changed files with 99 additions and 156 deletions

View File

@ -63,10 +63,9 @@ BOOL mf_peer_get_fds(freerdp_peer* client, void** rfds, int* rcount)
{ {
if (info_event_queue->pipe_fd[0] == -1) if (info_event_queue->pipe_fd[0] == -1)
return TRUE; return TRUE;
rfds[*rcount] = (void *)(long) info_event_queue->pipe_fd[0]; rfds[*rcount] = (void*)(long) info_event_queue->pipe_fd[0];
(*rcount)++; (*rcount)++;
return TRUE; return TRUE;
} }
@ -74,28 +73,25 @@ BOOL mf_peer_check_fds(freerdp_peer* client)
{ {
mfPeerContext* context = (mfPeerContext*) client->context; mfPeerContext* context = (mfPeerContext*) client->context;
mfEvent* event; mfEvent* event;
if (context->activated == FALSE) if (context->activated == FALSE)
return TRUE; return TRUE;
event = mf_event_peek(info_event_queue); event = mf_event_peek(info_event_queue);
if (event != NULL) if (event != NULL)
{ {
if (event->type == MF_EVENT_TYPE_REGION) if (event->type == MF_EVENT_TYPE_REGION)
{ {
} }
else if (event->type == MF_EVENT_TYPE_FRAME_TICK) else if (event->type == MF_EVENT_TYPE_FRAME_TICK)
{ {
event = mf_event_pop(info_event_queue); event = mf_event_pop(info_event_queue);
mf_peer_rfx_update(client); mf_peer_rfx_update(client);
mf_event_free(event); mf_event_free(event);
} }
} }
return TRUE; return TRUE;
} }
@ -103,76 +99,59 @@ void mf_peer_rfx_update(freerdp_peer* client)
{ {
//check //check
mfInfo* mfi = mf_info_get_instance(); mfInfo* mfi = mf_info_get_instance();
mf_info_find_invalid_region(mfi); mf_info_find_invalid_region(mfi);
if (mf_info_have_invalid_region(mfi) == false) { if (mf_info_have_invalid_region(mfi) == false)
{
return; return;
} }
long width; long width;
long height; long height;
int pitch; int pitch;
BYTE* dataBits = NULL; BYTE* dataBits = NULL;
mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch); mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch);
mf_info_clear_invalid_region(mfi); mf_info_clear_invalid_region(mfi);
//encode //encode
wStream* s; wStream* s;
RFX_RECT rect; RFX_RECT rect;
rdpUpdate* update; rdpUpdate* update;
mfPeerContext* mfp; mfPeerContext* mfp;
SURFACE_BITS_COMMAND* cmd; SURFACE_BITS_COMMAND* cmd;
update = client->update; update = client->update;
mfp = (mfPeerContext*) client->context; mfp = (mfPeerContext*) client->context;
cmd = &update->surface_bits_command; cmd = &update->surface_bits_command;
s = mfp->s; s = mfp->s;
Stream_Clear(s); Stream_Clear(s);
Stream_SetPosition(s, 0); Stream_SetPosition(s, 0);
UINT32 x = mfi->invalid.x / mfi->scale; UINT32 x = mfi->invalid.x / mfi->scale;
UINT32 y = mfi->invalid.y / mfi->scale; UINT32 y = mfi->invalid.y / mfi->scale;
rect.x = 0; rect.x = 0;
rect.y = 0; rect.y = 0;
rect.width = width; rect.width = width;
rect.height = height; rect.height = height;
mfp->rfx_context->width = mfi->servscreen_width; mfp->rfx_context->width = mfi->servscreen_width;
mfp->rfx_context->height = mfi->servscreen_height; mfp->rfx_context->height = mfi->servscreen_height;
if (!(rfx_compose_message(mfp->rfx_context, s, &rect, 1, if (!(rfx_compose_message(mfp->rfx_context, s, &rect, 1,
(BYTE*) dataBits, rect.width, rect.height, pitch))) (BYTE*) dataBits, rect.width, rect.height, pitch)))
{ {
return; return;
} }
cmd->destLeft = x; cmd->destLeft = x;
cmd->destTop = y; cmd->destTop = y;
cmd->destRight = x + rect.width; cmd->destRight = x + rect.width;
cmd->destBottom = y + rect.height; cmd->destBottom = y + rect.height;
cmd->bpp = 32; cmd->bpp = 32;
cmd->codecID = 3; cmd->codecID = 3;
cmd->width = rect.width; cmd->width = rect.width;
cmd->height = rect.height; cmd->height = rect.height;
cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapDataLength = Stream_GetPosition(s);
cmd->bitmapData = Stream_Buffer(s); cmd->bitmapData = Stream_Buffer(s);
//send //send
update->SurfaceBits(update->context, cmd); update->SurfaceBits(update->context, cmd);
//clean up... maybe? //clean up... maybe?
} }
/* Called when we have a new peer connecting */ /* Called when we have a new peer connecting */
@ -187,24 +166,18 @@ BOOL mf_peer_context_new(freerdp_peer* client, mfPeerContext* context)
context->rfx_context->mode = RLGR3; context->rfx_context->mode = RLGR3;
context->rfx_context->width = client->settings->DesktopWidth; context->rfx_context->width = client->settings->DesktopWidth;
context->rfx_context->height = client->settings->DesktopHeight; context->rfx_context->height = client->settings->DesktopHeight;
rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_BGRA32);
//if (!(context->nsc_context = nsc_context_new()))
// goto fail_nsc_context;
//nsc_context_set_pixel_format(context->nsc_context, RDP_PIXEL_FORMAT_B8G8R8A8);
if (!(context->s = Stream_New(NULL, 0xFFFF))) if (!(context->s = Stream_New(NULL, 0xFFFF)))
goto fail_stream_new; goto fail_stream_new;
context->vcm = WTSOpenServerA((LPSTR) client->context); context->vcm = WTSOpenServerA((LPSTR) client->context);
if (!context->vcm || context->vcm == INVALID_HANDLE_VALUE) if (!context->vcm || context->vcm == INVALID_HANDLE_VALUE)
goto fail_open_server; goto fail_open_server;
mf_info_peer_register(context->info, context); mf_info_peer_register(context->info, context);
return TRUE; return TRUE;
fail_open_server: fail_open_server:
Stream_Free(context->s, TRUE); Stream_Free(context->s, TRUE);
context->s = NULL; context->s = NULL;
@ -212,7 +185,6 @@ fail_stream_new:
rfx_context_free(context->rfx_context); rfx_context_free(context->rfx_context);
context->rfx_context = NULL; context->rfx_context = NULL;
fail_rfx_context: fail_rfx_context:
return FALSE; return FALSE;
} }
@ -222,25 +194,23 @@ void mf_peer_context_free(freerdp_peer* client, mfPeerContext* context)
if (context) if (context)
{ {
mf_info_peer_unregister(context->info, context); mf_info_peer_unregister(context->info, context);
dispatch_suspend(info_timer); dispatch_suspend(info_timer);
Stream_Free(context->s, TRUE); Stream_Free(context->s, TRUE);
rfx_context_free(context->rfx_context); rfx_context_free(context->rfx_context);
//nsc_context_free(context->nsc_context); //nsc_context_free(context->nsc_context);
#ifdef CHANNEL_AUDIN_SERVER #ifdef CHANNEL_AUDIN_SERVER
if (context->audin) if (context->audin)
audin_server_context_free(context->audin); audin_server_context_free(context->audin);
#endif #endif
//#ifdef CHANNEL_RDPSND_SERVER //#ifdef CHANNEL_RDPSND_SERVER
mf_peer_rdpsnd_stop(); mf_peer_rdpsnd_stop();
if (context->rdpsnd) if (context->rdpsnd)
rdpsnd_server_context_free(context->rdpsnd); rdpsnd_server_context_free(context->rdpsnd);
//#endif //#endif
WTSCloseServer(context->vcm); WTSCloseServer(context->vcm);
} }
} }
@ -254,21 +224,25 @@ BOOL mf_peer_init(freerdp_peer* client)
if (!freerdp_peer_context_new(client)) if (!freerdp_peer_context_new(client))
return FALSE; return FALSE;
info_event_queue = mf_event_queue_new(); info_event_queue = mf_event_queue_new();
info_queue = dispatch_queue_create("FreeRDP.update.timer",
info_queue = dispatch_queue_create("FreeRDP.update.timer", DISPATCH_QUEUE_SERIAL); DISPATCH_QUEUE_SERIAL);
info_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, info_queue); info_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,
info_queue);
if(info_timer)
if (info_timer)
{ {
//DEBUG_WARN( "created timer\n"); //DEBUG_WARN( "created timer\n");
dispatch_source_set_timer(info_timer, DISPATCH_TIME_NOW, 42ull * NSEC_PER_MSEC, 100ull * NSEC_PER_MSEC); dispatch_source_set_timer(info_timer, DISPATCH_TIME_NOW, 42ull * NSEC_PER_MSEC,
dispatch_source_set_event_handler(info_timer, ^{ 100ull * NSEC_PER_MSEC);
dispatch_source_set_event_handler(info_timer, ^
{
//DEBUG_WARN( "dispatch\n"); //DEBUG_WARN( "dispatch\n");
mfEvent* event = mf_event_new(MF_EVENT_TYPE_FRAME_TICK); mfEvent* event = mf_event_new(MF_EVENT_TYPE_FRAME_TICK);
mf_event_push(info_event_queue, (mfEvent*) event);} mf_event_push(info_event_queue, (mfEvent*) event);
); }
);
dispatch_resume(info_timer); dispatch_resume(info_timer);
} }
@ -279,25 +253,21 @@ BOOL mf_peer_post_connect(freerdp_peer* client)
{ {
mfPeerContext* context = (mfPeerContext*) client->context; mfPeerContext* context = (mfPeerContext*) client->context;
rdpSettings* settings = client->settings; rdpSettings* settings = client->settings;
mfInfo* mfi = mf_info_get_instance(); mfInfo* mfi = mf_info_get_instance();
mfi->scale = 1; mfi->scale = 1;
//mfi->servscreen_width = 2880 / mfi->scale; //mfi->servscreen_width = 2880 / mfi->scale;
//mfi->servscreen_height = 1800 / mfi->scale; //mfi->servscreen_height = 1800 / mfi->scale;
UINT32 bitsPerPixel = 32; UINT32 bitsPerPixel = 32;
if ((settings->DesktopWidth != mfi->servscreen_width) || (settings->DesktopHeight != mfi->servscreen_height))
{
if ((settings->DesktopWidth != mfi->servscreen_width)
|| (settings->DesktopHeight != mfi->servscreen_height))
{
} }
settings->DesktopWidth = mfi->servscreen_width; settings->DesktopWidth = mfi->servscreen_width;
settings->DesktopHeight = mfi->servscreen_height; settings->DesktopHeight = mfi->servscreen_height;
settings->ColorDepth = bitsPerPixel; settings->ColorDepth = bitsPerPixel;
client->update->DesktopResize(client->update->context); client->update->DesktopResize(client->update->context);
mfi->mouse_down_left = FALSE; mfi->mouse_down_left = FALSE;
mfi->mouse_down_right = FALSE; mfi->mouse_down_right = FALSE;
mfi->mouse_down_other = FALSE; mfi->mouse_down_other = FALSE;
@ -306,38 +276,32 @@ BOOL mf_peer_post_connect(freerdp_peer* client)
{ {
mf_peer_rdpsnd_init(context); /* Audio Output */ mf_peer_rdpsnd_init(context); /* Audio Output */
} }
/* Dynamic Virtual Channels */ /* Dynamic Virtual Channels */
#ifdef CHANNEL_AUDIN_SERVER #ifdef CHANNEL_AUDIN_SERVER
mf_peer_audin_init(context); /* Audio Input */ mf_peer_audin_init(context); /* Audio Input */
#endif #endif
return TRUE; return TRUE;
} }
BOOL mf_peer_activate(freerdp_peer* client) BOOL mf_peer_activate(freerdp_peer* client)
{ {
mfPeerContext* context = (mfPeerContext*) client->context; mfPeerContext* context = (mfPeerContext*) client->context;
rfx_context_reset(context->rfx_context); rfx_context_reset(context->rfx_context);
context->activated = TRUE; context->activated = TRUE;
return TRUE; return TRUE;
} }
void mf_peer_synchronize_event(rdpInput* input, UINT32 flags) void mf_peer_synchronize_event(rdpInput* input, UINT32 flags)
{ {
} }
void mf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) void mf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{ {
UINT16 down = 0x4000; UINT16 down = 0x4000;
//UINT16 up = 0x8000; //UINT16 up = 0x8000;
bool state_down = FALSE; bool state_down = FALSE;
if (flags == down) if (flags == down)
{ {
state_down = TRUE; state_down = TRUE;
@ -346,18 +310,17 @@ void mf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
void mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) void mf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{ {
} }
static void mf_peer_suppress_output(rdpContext* context, BYTE allow, RECTANGLE_16* area) static void mf_peer_suppress_output(rdpContext* context, BYTE allow,
RECTANGLE_16* area)
{ {
} }
BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
{ {
pthread_t th; pthread_t th;
if (pthread_create(&th, 0, mf_peer_main_loop, client) == 0) if (pthread_create(&th, 0, mf_peer_main_loop, client) == 0)
{ {
pthread_detach(th); pthread_detach(th);
@ -377,79 +340,72 @@ void* mf_peer_main_loop(void* arg)
fd_set rfds_set; fd_set rfds_set;
mfPeerContext* context; mfPeerContext* context;
freerdp_peer* client = (freerdp_peer*) arg; freerdp_peer* client = (freerdp_peer*) arg;
memset(rfds, 0, sizeof(rfds)); memset(rfds, 0, sizeof(rfds));
if (!mf_peer_init(client)) if (!mf_peer_init(client))
{ {
freerdp_peer_free(client); freerdp_peer_free(client);
return NULL; return NULL;
} }
/* Initialize the real server settings here */ /* Initialize the real server settings here */
client->settings->CertificateFile = _strdup("server.crt"); client->settings->CertificateFile = _strdup("server.crt");
client->settings->PrivateKeyFile = _strdup("server.key"); client->settings->PrivateKeyFile = _strdup("server.key");
if (!client->settings->CertificateFile || !client->settings->PrivateKeyFile) if (!client->settings->CertificateFile || !client->settings->PrivateKeyFile)
{ {
freerdp_peer_free(client); freerdp_peer_free(client);
return NULL; return NULL;
} }
client->settings->NlaSecurity = FALSE; client->settings->NlaSecurity = FALSE;
client->settings->RemoteFxCodec = TRUE; client->settings->RemoteFxCodec = TRUE;
client->settings->ColorDepth = 32; client->settings->ColorDepth = 32;
client->settings->SuppressOutput = TRUE; client->settings->SuppressOutput = TRUE;
client->settings->RefreshRect = FALSE; client->settings->RefreshRect = FALSE;
client->PostConnect = mf_peer_post_connect; client->PostConnect = mf_peer_post_connect;
client->Activate = mf_peer_activate; client->Activate = mf_peer_activate;
client->input->SynchronizeEvent = mf_peer_synchronize_event; client->input->SynchronizeEvent = mf_peer_synchronize_event;
client->input->KeyboardEvent = mf_input_keyboard_event;//mf_peer_keyboard_event; client->input->KeyboardEvent = mf_input_keyboard_event;//mf_peer_keyboard_event;
client->input->UnicodeKeyboardEvent = mf_peer_unicode_keyboard_event; client->input->UnicodeKeyboardEvent = mf_peer_unicode_keyboard_event;
client->input->MouseEvent = mf_input_mouse_event; client->input->MouseEvent = mf_input_mouse_event;
client->input->ExtendedMouseEvent = mf_input_extended_mouse_event; client->input->ExtendedMouseEvent = mf_input_extended_mouse_event;
//client->update->RefreshRect = mf_peer_refresh_rect; //client->update->RefreshRect = mf_peer_refresh_rect;
client->update->SuppressOutput = mf_peer_suppress_output; client->update->SuppressOutput = mf_peer_suppress_output;
client->Initialize(client); client->Initialize(client);
context = (mfPeerContext*) client->context; context = (mfPeerContext*) client->context;
while (1) while (1)
{ {
rcount = 0; rcount = 0;
if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE) if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE)
{ {
break; break;
} }
if (mf_peer_get_fds(client, rfds, &rcount) != TRUE) if (mf_peer_get_fds(client, rfds, &rcount) != TRUE)
{ {
break; break;
} }
WTSVirtualChannelManagerGetFileDescriptor(context->vcm, rfds, &rcount); WTSVirtualChannelManagerGetFileDescriptor(context->vcm, rfds, &rcount);
max_fds = 0; max_fds = 0;
FD_ZERO(&rfds_set); FD_ZERO(&rfds_set);
for (i = 0; i < rcount; i++) for (i = 0; i < rcount; i++)
{ {
fds = (int)(long)(rfds[i]); fds = (int)(long)(rfds[i]);
if (fds > max_fds) if (fds > max_fds)
max_fds = fds; max_fds = fds;
FD_SET(fds, &rfds_set); FD_SET(fds, &rfds_set);
} }
if (max_fds == 0) if (max_fds == 0)
break; break;
if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1) if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1)
{ {
/* these are not really errors */ /* these are not really errors */
@ -461,26 +417,25 @@ void* mf_peer_main_loop(void* arg)
break; break;
} }
} }
if (client->CheckFileDescriptor(client) != TRUE) if (client->CheckFileDescriptor(client) != TRUE)
{ {
break; break;
} }
if ((mf_peer_check_fds(client)) != TRUE) if ((mf_peer_check_fds(client)) != TRUE)
{ {
break; break;
} }
if (WTSVirtualChannelManagerCheckFileDescriptor(context->vcm) != TRUE) if (WTSVirtualChannelManagerCheckFileDescriptor(context->vcm) != TRUE)
{ {
break; break;
} }
} }
client->Disconnect(client); client->Disconnect(client);
freerdp_peer_context_free(client); freerdp_peer_context_free(client);
freerdp_peer_free(client); freerdp_peer_free(client);
return NULL; return NULL;
} }

View File

@ -60,11 +60,11 @@ BOOL test_peer_context_new(freerdp_peer* client, testPeerContext* context)
goto fail_rfx_context; goto fail_rfx_context;
if (!rfx_context_reset(context->rfx_context, SAMPLE_SERVER_DEFAULT_WIDTH, if (!rfx_context_reset(context->rfx_context, SAMPLE_SERVER_DEFAULT_WIDTH,
SAMPLE_SERVER_DEFAULT_HEIGHT)) SAMPLE_SERVER_DEFAULT_HEIGHT))
goto fail_rfx_context; goto fail_rfx_context;
context->rfx_context->mode = RLGR3; context->rfx_context->mode = RLGR3;
rfx_context_set_pixel_format(context->rfx_context, PIXEL_FORMAT_RGB24); rfx_context_set_pixel_format(context->rfx_context, PIXEL_FORMAT_BGRX32);
if (!(context->nsc_context = nsc_context_new())) if (!(context->nsc_context = nsc_context_new()))
goto fail_nsc_context; goto fail_nsc_context;
@ -197,7 +197,7 @@ static BOOL test_peer_draw_background(freerdp_peer* client)
if (client->settings->RemoteFxCodec) if (client->settings->RemoteFxCodec)
{ {
if (!rfx_compose_message(context->rfx_context, s, if (!rfx_compose_message(context->rfx_context, s,
&rect, 1, rgb_data, rect.width, rect.height, rect.width * 3)) &rect, 1, rgb_data, rect.width, rect.height, rect.width * 3))
{ {
goto out; goto out;
} }
@ -207,7 +207,7 @@ static BOOL test_peer_draw_background(freerdp_peer* client)
else else
{ {
nsc_compose_message(context->nsc_context, s, nsc_compose_message(context->nsc_context, s,
rgb_data, rect.width, rect.height, rect.width * 3); rgb_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->NSCodecId; cmd->codecID = client->settings->NSCodecId;
} }
@ -279,7 +279,7 @@ static BOOL test_peer_load_icon(freerdp_peer* client)
/* background with same size, which will be used to erase the icon from old position */ /* background with same size, which will be used to erase the icon from old position */
if (!(context->bg_data = malloc(context->icon_width * context->icon_height * if (!(context->bg_data = malloc(context->icon_width * context->icon_height *
3))) 3)))
goto out_fail; goto out_fail;
memset(context->bg_data, 0xA0, context->icon_width * context->icon_height * 3); memset(context->bg_data, 0xA0, context->icon_width * context->icon_height * 3);
@ -323,13 +323,13 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
if (client->settings->RemoteFxCodec) if (client->settings->RemoteFxCodec)
{ {
rfx_compose_message(context->rfx_context, s, rfx_compose_message(context->rfx_context, s,
&rect, 1, context->bg_data, rect.width, rect.height, rect.width * 3); &rect, 1, context->bg_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->RemoteFxCodecId; cmd->codecID = client->settings->RemoteFxCodecId;
} }
else else
{ {
nsc_compose_message(context->nsc_context, s, nsc_compose_message(context->nsc_context, s,
context->bg_data, rect.width, rect.height, rect.width * 3); context->bg_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->NSCodecId; cmd->codecID = client->settings->NSCodecId;
} }
@ -350,13 +350,13 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
if (client->settings->RemoteFxCodec) if (client->settings->RemoteFxCodec)
{ {
rfx_compose_message(context->rfx_context, s, rfx_compose_message(context->rfx_context, s,
&rect, 1, context->icon_data, rect.width, rect.height, rect.width * 3); &rect, 1, context->icon_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->RemoteFxCodecId; cmd->codecID = client->settings->RemoteFxCodecId;
} }
else else
{ {
nsc_compose_message(context->nsc_context, s, nsc_compose_message(context->nsc_context, s,
context->icon_data, rect.width, rect.height, rect.width * 3); context->icon_data, rect.width, rect.height, rect.width * 3);
cmd->codecID = client->settings->NSCodecId; cmd->codecID = client->settings->NSCodecId;
} }
@ -376,7 +376,7 @@ static void test_peer_draw_icon(freerdp_peer* client, int x, int y)
} }
static BOOL test_sleep_tsdiff(UINT32* old_sec, UINT32* old_usec, UINT32 new_sec, static BOOL test_sleep_tsdiff(UINT32* old_sec, UINT32* old_usec, UINT32 new_sec,
UINT32 new_usec) UINT32 new_usec)
{ {
INT32 sec, usec; INT32 sec, usec;
@ -448,7 +448,7 @@ BOOL tf_peer_dump_rfx(freerdp_peer* client)
if (test_dump_rfx_realtime if (test_dump_rfx_realtime
&& test_sleep_tsdiff(&prev_seconds, &prev_useconds, record.header.ts_sec, && test_sleep_tsdiff(&prev_seconds, &prev_useconds, record.header.ts_sec,
record.header.ts_usec) == FALSE) record.header.ts_usec) == FALSE)
break; break;
update->SurfaceCommand(update->context, s); update->SurfaceCommand(update->context, s);
@ -472,7 +472,7 @@ static void* tf_debug_channel_thread_func(void* arg)
testPeerContext* context = (testPeerContext*) arg; testPeerContext* context = (testPeerContext*) arg;
if (WTSVirtualChannelQuery(context->debug_channel, WTSVirtualFileHandle, if (WTSVirtualChannelQuery(context->debug_channel, WTSVirtualFileHandle,
&buffer, &BytesReturned) == TRUE) &buffer, &BytesReturned) == TRUE)
{ {
fd = *((void**) buffer); fd = *((void**) buffer);
WTSFreeMemory(buffer); WTSFreeMemory(buffer);
@ -494,7 +494,7 @@ static void* tf_debug_channel_thread_func(void* arg)
Stream_SetPosition(s, 0); Stream_SetPosition(s, 0);
if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR) Stream_Buffer(s), if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR) Stream_Buffer(s),
Stream_Capacity(s), &BytesReturned) == FALSE) Stream_Capacity(s), &BytesReturned) == FALSE)
{ {
if (BytesReturned == 0) if (BytesReturned == 0)
break; break;
@ -502,7 +502,7 @@ static void* tf_debug_channel_thread_func(void* arg)
Stream_EnsureRemainingCapacity(s, BytesReturned); Stream_EnsureRemainingCapacity(s, BytesReturned);
if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR) Stream_Buffer(s), if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR) Stream_Buffer(s),
Stream_Capacity(s), &BytesReturned) == FALSE) Stream_Capacity(s), &BytesReturned) == FALSE)
{ {
/* should not happen */ /* should not happen */
break; break;
@ -527,25 +527,25 @@ BOOL tf_peer_post_connect(freerdp_peer* client)
* callback returns. * callback returns.
*/ */
WLog_DBG(TAG, "Client %s is activated (osMajorType %d osMinorType %d)", WLog_DBG(TAG, "Client %s is activated (osMajorType %d osMinorType %d)",
client->local ? "(local)" : client->hostname, client->local ? "(local)" : client->hostname,
client->settings->OsMajorType, client->settings->OsMinorType); client->settings->OsMajorType, client->settings->OsMinorType);
if (client->settings->AutoLogonEnabled) if (client->settings->AutoLogonEnabled)
{ {
WLog_DBG(TAG, " and wants to login automatically as %s\\%s", WLog_DBG(TAG, " and wants to login automatically as %s\\%s",
client->settings->Domain ? client->settings->Domain : "", client->settings->Domain ? client->settings->Domain : "",
client->settings->Username); client->settings->Username);
/* A real server may perform OS login here if NLA is not executed previously. */ /* A real server may perform OS login here if NLA is not executed previously. */
} }
WLog_DBG(TAG, ""); WLog_DBG(TAG, "");
WLog_DBG(TAG, "Client requested desktop: %dx%dx%d", WLog_DBG(TAG, "Client requested desktop: %dx%dx%d",
client->settings->DesktopWidth, client->settings->DesktopHeight, client->settings->DesktopWidth, client->settings->DesktopHeight,
client->settings->ColorDepth); client->settings->ColorDepth);
#if (SAMPLE_SERVER_USE_CLIENT_RESOLUTION == 1) #if (SAMPLE_SERVER_USE_CLIENT_RESOLUTION == 1)
if (!rfx_context_reset(context->rfx_context, client->settings->DesktopWidth, if (!rfx_context_reset(context->rfx_context, client->settings->DesktopWidth,
client->settings->DesktopHeight)) client->settings->DesktopHeight))
return FALSE; return FALSE;
WLog_DBG(TAG, "Using resolution requested by client."); WLog_DBG(TAG, "Using resolution requested by client.");
@ -553,7 +553,7 @@ BOOL tf_peer_post_connect(freerdp_peer* client)
client->settings->DesktopWidth = context->rfx_context->width; client->settings->DesktopWidth = context->rfx_context->width;
client->settings->DesktopHeight = context->rfx_context->height; client->settings->DesktopHeight = context->rfx_context->height;
WLog_DBG(TAG, "Resizing client to %dx%d", client->settings->DesktopWidth, WLog_DBG(TAG, "Resizing client to %dx%d", client->settings->DesktopWidth,
client->settings->DesktopHeight); client->settings->DesktopHeight);
client->update->DesktopResize(client->update->context); client->update->DesktopResize(client->update->context);
#endif #endif
@ -567,7 +567,7 @@ BOOL tf_peer_post_connect(freerdp_peer* client)
if (WTSVirtualChannelManagerIsChannelJoined(context->vcm, "rdpdbg")) if (WTSVirtualChannelManagerIsChannelJoined(context->vcm, "rdpdbg"))
{ {
context->debug_channel = WTSVirtualChannelOpen(context->vcm, context->debug_channel = WTSVirtualChannelOpen(context->vcm,
WTS_CURRENT_SESSION, "rdpdbg"); WTS_CURRENT_SESSION, "rdpdbg");
if (context->debug_channel != NULL) if (context->debug_channel != NULL)
{ {
@ -580,8 +580,8 @@ BOOL tf_peer_post_connect(freerdp_peer* client)
} }
if (!(context->debug_channel_thread = CreateThread(NULL, 0, if (!(context->debug_channel_thread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) tf_debug_channel_thread_func, (void*) context, 0, (LPTHREAD_START_ROUTINE) tf_debug_channel_thread_func, (void*) context, 0,
NULL))) NULL)))
{ {
WLog_ERR(TAG, "Failed to create debug channel thread"); WLog_ERR(TAG, "Failed to create debug channel thread");
CloseHandle(context->stopEvent); CloseHandle(context->stopEvent);
@ -641,7 +641,7 @@ BOOL tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
rdpUpdate* update = client->update; rdpUpdate* update = client->update;
testPeerContext* context = (testPeerContext*) input->context; testPeerContext* context = (testPeerContext*) input->context;
WLog_DBG(TAG, "Client sent a keyboard event (flags:0x%X code:0x%X)", flags, WLog_DBG(TAG, "Client sent a keyboard event (flags:0x%X code:0x%X)", flags,
code); code);
if ((flags & 0x4000) && code == 0x22) /* 'g' key */ if ((flags & 0x4000) && code == 0x22) /* 'g' key */
{ {
@ -657,7 +657,7 @@ BOOL tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
} }
if (!rfx_context_reset(context->rfx_context, client->settings->DesktopWidth, if (!rfx_context_reset(context->rfx_context, client->settings->DesktopWidth,
client->settings->DesktopHeight)) client->settings->DesktopHeight))
return FALSE; return FALSE;
update->DesktopResize(update->context); update->DesktopResize(update->context);
@ -698,7 +698,7 @@ BOOL tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
BOOL tf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) BOOL tf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{ {
WLog_DBG(TAG, "Client sent a unicode keyboard event (flags:0x%X code:0x%X)", WLog_DBG(TAG, "Client sent a unicode keyboard event (flags:0x%X code:0x%X)",
flags, code); flags, code);
return TRUE; return TRUE;
} }
@ -710,14 +710,14 @@ BOOL tf_peer_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
} }
BOOL tf_peer_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, BOOL tf_peer_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x,
UINT16 y) UINT16 y)
{ {
//WLog_DBG(TAG, "Client sent an extended mouse event (flags:0x%X pos:%d,%d)", flags, x, y); //WLog_DBG(TAG, "Client sent an extended mouse event (flags:0x%X pos:%d,%d)", flags, x, y);
return TRUE; return TRUE;
} }
static BOOL tf_peer_refresh_rect(rdpContext* context, BYTE count, static BOOL tf_peer_refresh_rect(rdpContext* context, BYTE count,
const RECTANGLE_16* areas) const RECTANGLE_16* areas)
{ {
BYTE i; BYTE i;
WLog_DBG(TAG, "Client requested to refresh:"); WLog_DBG(TAG, "Client requested to refresh:");
@ -725,19 +725,19 @@ static BOOL tf_peer_refresh_rect(rdpContext* context, BYTE count,
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
WLog_DBG(TAG, " (%d, %d) (%d, %d)", areas[i].left, areas[i].top, WLog_DBG(TAG, " (%d, %d) (%d, %d)", areas[i].left, areas[i].top,
areas[i].right, areas[i].bottom); areas[i].right, areas[i].bottom);
} }
return TRUE; return TRUE;
} }
static BOOL tf_peer_suppress_output(rdpContext* context, BYTE allow, static BOOL tf_peer_suppress_output(rdpContext* context, BYTE allow,
const RECTANGLE_16* area) const RECTANGLE_16* area)
{ {
if (allow > 0) if (allow > 0)
{ {
WLog_DBG(TAG, "Client restore output (%d, %d) (%d, %d).", area->left, area->top, WLog_DBG(TAG, "Client restore output (%d, %d) (%d, %d).", area->left, area->top,
area->right, area->bottom); area->right, area->bottom);
} }
else else
{ {
@ -798,7 +798,7 @@ static void* test_peer_mainloop(void* arg)
client->Initialize(client); client->Initialize(client);
context = (testPeerContext*) client->context; context = (testPeerContext*) client->context;
WLog_INFO(TAG, "We've got a client %s", WLog_INFO(TAG, "We've got a client %s",
client->local ? "(local)" : client->hostname); client->local ? "(local)" : client->hostname);
while (1) while (1)
{ {
@ -821,7 +821,7 @@ static void* test_peer_mainloop(void* arg)
} }
WLog_INFO(TAG, "Client %s disconnected.", WLog_INFO(TAG, "Client %s disconnected.",
client->local ? "(local)" : client->hostname); client->local ? "(local)" : client->hostname);
client->Disconnect(client); client->Disconnect(client);
freerdp_peer_context_free(client); freerdp_peer_context_free(client);
freerdp_peer_free(client); freerdp_peer_free(client);
@ -833,7 +833,7 @@ static BOOL test_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
HANDLE hThread; HANDLE hThread;
if (!(hThread = CreateThread(NULL, 0, if (!(hThread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE) test_peer_mainloop, (void*) client, 0, NULL))) (LPTHREAD_START_ROUTINE) test_peer_mainloop, (void*) client, 0, NULL)))
return FALSE; return FALSE;
CloseHandle(hThread); CloseHandle(hThread);

View File

@ -43,9 +43,7 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam)
wfInfo* wfi; wfInfo* wfi;
DWORD beg, end; DWORD beg, end;
DWORD diff, rate; DWORD diff, rate;
wfi = (wfInfo*) lpParam; wfi = (wfInfo*) lpParam;
fps = wfi->framesPerSecond; fps = wfi->framesPerSecond;
rate = 1000 / fps; rate = 1000 / fps;
@ -64,6 +62,7 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam)
wf_update_encode(wfi); wf_update_encode(wfi);
//WLog_DBG(TAG, "Start of parallel sending"); //WLog_DBG(TAG, "Start of parallel sending");
index = 0; index = 0;
for (peerindex = 0; peerindex < wfi->peerCount; peerindex++) for (peerindex = 0; peerindex < wfi->peerCount; peerindex++)
{ {
for (; index < WF_INFO_MAXPEERS; index++) for (; index < WF_INFO_MAXPEERS; index++)
@ -74,7 +73,6 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam)
SetEvent(((wfPeerContext*) wfi->peers[index]->context)->updateEvent); SetEvent(((wfPeerContext*) wfi->peers[index]->context)->updateEvent);
} }
} }
} }
for (index = 0; index < wfi->activePeerCount; index++) for (index = 0; index < wfi->activePeerCount; index++)
@ -111,17 +109,11 @@ void wf_update_encode(wfInfo* wfi)
long height, width; long height, width;
BYTE* pDataBits = NULL; BYTE* pDataBits = NULL;
int stride; int stride;
SURFACE_BITS_COMMAND* cmd; SURFACE_BITS_COMMAND* cmd;
wf_info_find_invalid_region(wfi); wf_info_find_invalid_region(wfi);
cmd = &wfi->cmd; cmd = &wfi->cmd;
Stream_SetPosition(wfi->s, 0); Stream_SetPosition(wfi->s, 0);
wf_info_getScreenData(wfi, &width, &height, &pDataBits, &stride); wf_info_getScreenData(wfi, &width, &height, &pDataBits, &stride);
rect.x = 0; rect.x = 0;
rect.y = 0; rect.y = 0;
rect.width = (UINT16) width; rect.width = (UINT16) width;
@ -130,18 +122,16 @@ void wf_update_encode(wfInfo* wfi)
Stream_Clear(wfi->s); Stream_Clear(wfi->s);
if (!(rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1, if (!(rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1,
pDataBits, width, height, stride))) pDataBits, width, height, stride)))
{ {
return; return;
} }
wfi->frame_idx = wfi->rfx_context->frameIdx; wfi->frame_idx = wfi->rfx_context->frameIdx;
cmd->destLeft = wfi->invalid.left; cmd->destLeft = wfi->invalid.left;
cmd->destTop = wfi->invalid.top; cmd->destTop = wfi->invalid.top;
cmd->destRight = wfi->invalid.left + width; cmd->destRight = wfi->invalid.left + width;
cmd->destBottom = wfi->invalid.top + height; cmd->destBottom = wfi->invalid.top + height;
cmd->bpp = 32; cmd->bpp = 32;
cmd->codecID = 3; cmd->codecID = 3;
cmd->width = width; cmd->width = width;
@ -168,13 +158,12 @@ void wf_update_peer_send(wfInfo* wfi, wfPeerContext* context)
if ((context->frame_idx + 1) != wfi->frame_idx) if ((context->frame_idx + 1) != wfi->frame_idx)
{ {
/* This frame is meant to be discarded */ /* This frame is meant to be discarded */
if (context->frame_idx == 0) if (context->frame_idx == 0)
return; return;
/* This is an unexpected error condition */ /* This is an unexpected error condition */
WLog_DBG(TAG, "Unexpected Frame Index: Actual: %d Expected: %d", WLog_DBG(TAG, "Unexpected Frame Index: Actual: %d Expected: %d",
wfi->frame_idx, context->frame_idx + 1); wfi->frame_idx, context->frame_idx + 1);
} }
wfi->cmd.codecID = client->settings->RemoteFxCodecId; wfi->cmd.codecID = client->settings->RemoteFxCodecId;
@ -198,12 +187,11 @@ void wf_update_encoder_reset(wfInfo* wfi)
wfi->rfx_context->mode = RLGR3; wfi->rfx_context->mode = RLGR3;
wfi->rfx_context->width = wfi->servscreen_width; wfi->rfx_context->width = wfi->servscreen_width;
wfi->rfx_context->height = wfi->servscreen_height; wfi->rfx_context->height = wfi->servscreen_height;
rfx_context_set_pixel_format(wfi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8); rfx_context_set_pixel_format(wfi->rfx_context, RDP_PIXEL_FORMAT_BGRA32);
wfi->s = Stream_New(NULL, 0xFFFF); wfi->s = Stream_New(NULL, 0xFFFF);
} }
wf_info_invalidate_full_screen(wfi); wf_info_invalidate_full_screen(wfi);
wf_info_unlock(wfi); wf_info_unlock(wfi);
} }
} }