#endif
}
-void* xf_frame_rate_thread(void* param)
-{
- xfInfo* xfi;
- HGDI_RGN region;
- xfPeerContext* xfp;
- freerdp_peer* client;
- UINT32 wait_interval;
-
- client = (freerdp_peer*) param;
- xfp = (xfPeerContext*) client->context;
- xfi = xfp->info;
-
- region = xfp->hdc->hwnd->invalid;
- wait_interval = 1000000 / xfp->fps;
-
- while (1)
- {
- /* check if we should terminate */
- pthread_testcancel();
-
- if (!region->null)
- {
- UINT32 xy, wh;
-
- pthread_mutex_lock(&(xfp->mutex));
-
- xy = (region->x << 16) | region->y;
- wh = (region->w << 16) | region->h;
- region->null = 1;
-
- pthread_mutex_unlock(&(xfp->mutex));
-
- MessageQueue_Post(xfp->queue, (void*) xfp,
- MakeMessageId(PeerEvent, EncodeRegion),
- (void*) (size_t) xy, (void*) (size_t) wh);
- }
-
- USleep(wait_interval);
- }
-
- return NULL;
-}
-
void* xf_monitor_updates(void* param)
{
int fds;
wait_interval = 1000000 / xfp->fps;
ZeroMemory(&timeout, sizeof(struct timeval));
- pthread_create(&(xfp->frame_rate_thread), 0, xf_frame_rate_thread, (void*) client);
-
while (1)
{
/* check if we should terminate */
BOOL xf_peer_check_fds(freerdp_peer* client)
{
xfInfo* xfi;
- wMessage message;
+ HGDI_RGN region;
xfPeerContext* xfp;
xfp = (xfPeerContext*) client->context;
xfi = xfp->info;
- if (xfp->activated == FALSE)
+ if (!xfp->activated)
return TRUE;
- if (MessageQueue_Peek(xfp->queue, &message, TRUE))
- {
- if (message.id == MakeMessageId(PeerEvent, EncodeRegion))
- {
- UINT32 xy, wh;
- UINT16 x, y, w, h;
+ region = xfp->hdc->hwnd->invalid;
- xy = (UINT32) (size_t) message.wParam;
- wh = (UINT32) (size_t) message.lParam;
+ pthread_mutex_lock(&(xfp->mutex));
- x = ((xy & 0xFFFF0000) >> 16);
- y = (xy & 0x0000FFFF);
+ if ((region->w * region->h) > 0)
+ xf_peer_rfx_update(client, region->x, region->y, region->w, region->h);
- w = ((wh & 0xFFFF0000) >> 16);
- h = (wh & 0x0000FFFF);
+ region->null = 1;
- if (w * h > 0)
- xf_peer_rfx_update(client, x, y, w, h);
- }
- }
+ pthread_mutex_unlock(&(xfp->mutex));
return TRUE;
}
rdpSettings* settings;
freerdp_peer* client = (freerdp_peer*) arg;
xfPeerContext* xfp;
+ struct timeval timeout;
ZeroMemory(rfds, sizeof(rfds));
+ ZeroMemory(&timeout, sizeof(struct timeval));
fprintf(stderr, "We've got a client %s\n", client->hostname);
xf_peer_init(client);
xfp = (xfPeerContext*) client->context;
-
settings = client->settings;
- /* Initialize the real server settings here */
-
xf_generate_certificate(settings);
settings->RemoteFxCodec = TRUE;
fprintf(stderr, "Failed to get FreeRDP file descriptor\n");
break;
}
+
if (xf_peer_get_fds(client, rfds, &rcount) != TRUE)
{
fprintf(stderr, "Failed to get xfreerdp file descriptor\n");
if (max_fds == 0)
break;
- if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1)
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 100;
+
+ if (select(max_fds + 1, &rfds_set, NULL, NULL, &timeout) == -1)
{
/* these are not really errors */
if (!((errno == EAGAIN) ||
fprintf(stderr, "Failed to check freerdp file descriptor\n");
break;
}
+
if ((xf_peer_check_fds(client)) != TRUE)
{
fprintf(stderr, "Failed to check xfreerdp file descriptor\n");
client->Disconnect(client);
pthread_cancel(xfp->thread);
- pthread_cancel(xfp->frame_rate_thread);
pthread_join(xfp->thread, NULL);
- pthread_join(xfp->frame_rate_thread, NULL);
freerdp_peer_context_free(client);
freerdp_peer_free(client);
#include "xf_peer.h"
#include "xfreerdp.h"
-char* xf_pcap_file = NULL;
-BOOL xf_pcap_dump_realtime = TRUE;
-
void xf_server_main_loop(freerdp_listener* instance)
{
int i;
instance = freerdp_listener_new();
instance->PeerAccepted = xf_peer_accepted;
- if (argc > 1)
- xf_pcap_file = argv[1];
-
- if (argc > 2 && !strcmp(argv[2], "--fast"))
- xf_pcap_dump_realtime = FALSE;
-
/* Open the server socket and start listening. */
if (instance->Open(instance, NULL, 3389))
{