wfreerdp-server: added optional back buffer

This commit is contained in:
C-o-r-E 2012-08-28 19:28:04 -04:00
parent 49e97852b4
commit fdfc5f8f1c
3 changed files with 89 additions and 1 deletions

View File

@ -29,6 +29,45 @@
#include "wf_info.h"
#include "wf_mirage.h"
extern wfInfo * wfInfoSingleton;
int wf_info_lock()
{
DWORD dRes;
dRes = WaitForSingleObject(wfInfoSingleton->mutex, INFINITE);
switch(dRes)
{
case WAIT_ABANDONED:
//complain and proceed as normal
printf("Got ownership of abandoned mutex... resuming...\n");
case WAIT_OBJECT_0:
break;
case WAIT_TIMEOUT:
return 1;
break;
case WAIT_FAILED:
printf("WAIT FAILED code %#X\n", GetLastError());
return -1;
break;
}
return 0;
}
int wf_info_unlock()
{
if(ReleaseMutex(wfInfoSingleton->mutex) == 0)
return 0;
return 1;
}
wfInfo* wf_info_init(wfInfo * wfi)
{
if (!wfi)
@ -89,6 +128,8 @@ void wf_info_mirror_init(wfInfo* wfi, wfPeerContext* context)
rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
context->s = stream_new(65536);
context->wfInfo->roflbuffer = (BYTE*)malloc( (context->wfInfo->width) * (context->wfInfo->height) * 4);
printf("Start Encoder\n");
ReleaseMutex(wfi->encodeMutex);
}
@ -137,6 +178,8 @@ void wf_info_subscriber_release(wfInfo* wfi, wfPeerContext* context)
stream_free(context->s);
rfx_context_free(context->rfx_context);
free(context->wfInfo->roflbuffer);
printf("Stop encoder\n");
break;

View File

@ -48,9 +48,14 @@ struct wf_info
long invalid_y2;
BOOL enc_data;
BYTE* roflbuffer;
};
typedef struct wf_info wfInfo;
int wf_info_lock();
int wf_info_unlock();
wfInfo* wf_info_init(wfInfo* wfi);
void wf_info_mirror_init(wfInfo* wfi, wfPeerContext* context);
void wf_info_subscriber_release(wfInfo* wfi, wfPeerContext* context);

View File

@ -51,7 +51,7 @@ static DWORD WINAPI wf_peer_mirror_monitor(LPVOID lpParam)
DWORD diff, rate;
freerdp_peer* client;
fps = 30;
fps = 24;
rate = 1000 / fps;
client = (freerdp_peer*) lpParam;
@ -100,6 +100,13 @@ void wf_rfx_encode(freerdp_peer* client)
GETCHANGESBUF* buf;
SURFACE_BITS_COMMAND* cmd;
#ifdef ROFLBUFFER
uint16 i;
int delta;
int scanline;
BYTE* srcp;
BYTE* dstp;
#endif
wfp = (wfPeerContext*) client->context;
dRes = WaitForSingleObject(wfInfoSingleton->encodeMutex, INFINITE);
@ -145,10 +152,43 @@ void wf_rfx_encode(freerdp_peer* client)
//printf("Encoding: left:%d top:%d right:%d bottom:%d width:%d height:%d\n",
// wfi->invalid_x1, wfi->invalid_y1, wfi->invalid_x2, wfi->invalid_y2, width, height);
#ifndef ROFLBUFFER
offset = (4 * wfi->invalid_x1) + (wfi->invalid_y1 * wfi->width * 4);
rfx_compose_message(wfp->rfx_context, s, &rect, 1,
((uint8*) (buf->Userbuffer)) + offset, width, height, wfi->width * 4);
#else
//memcpy(wfi->roflbuffer, ((uint8*) (buf->Userbuffer)) + offset, 4 * width * height);
//to copy the region we must copy HxWxB bytes per line and skip 4*(screen_w - x2)
/*delta = 0;
for(i = 0; i < height; ++i)
{
memcpy(wfi->roflbuffer + offset + delta, ((uint8*) (buf->Userbuffer)) + offset + delta, 4 * width);
delta += (4 * width) + (4 * (wfi->width - wfi->invalid_x2) + (4 * wfi->invalid_x1));
}*/
scanline = (wfi->width * 4);
offset = (wfi->invalid_y1 * scanline) + (wfi->invalid_x1 * 4);
srcp = (BYTE*) buf->Userbuffer + offset;
dstp = (BYTE*) wfi->roflbuffer + offset;
Sleep(100);
for (i = 0; i < height; i++)
{
memcpy(dstp, srcp, width * 4);
dstp += scanline;
srcp += scanline;
}
rfx_compose_message(wfp->rfx_context, s, &rect, 1,
wfi->roflbuffer + offset, width, height, wfi->width * 4);
#endif
cmd->destLeft = wfi->invalid_x1;
cmd->destTop = wfi->invalid_y1;