static void test_peer_draw_icon(freerdp_peer* client, int x, int y) { testPeerContext* context = (testPeerContext*) client->context; rdpUpdate* update = client->update; SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command; RFX_RECT rect; STREAM* s; if (client->update->dump_rfx) return; if (!client->settings->rfx_codec || !context) return; if (context->icon_width < 1 || !context->activated) return; rect.x = 0; rect.y = 0; rect.width = context->icon_width; rect.height = context->icon_height; if (context->icon_x >= 0) { s = test_peer_stream_init(context); rfx_compose_message(context->rfx_context, s, &rect, 1, context->bg_data, rect.width, rect.height, rect.width * 3); cmd->destLeft = context->icon_x; cmd->destTop = context->icon_y; cmd->destRight = context->icon_x + context->icon_width; cmd->destBottom = context->icon_y + context->icon_height; cmd->bpp = 32; cmd->codecID = client->settings->rfx_codec_id; cmd->width = context->icon_width; cmd->height = context->icon_height; cmd->bitmapDataLength = stream_get_length(s); cmd->bitmapData = stream_get_head(s); update->SurfaceBits(update->context, cmd); } s = test_peer_stream_init(context); rfx_compose_message(context->rfx_context, s, &rect, 1, context->icon_data, rect.width, rect.height, rect.width * 3); cmd->destLeft = x; cmd->destTop = y; cmd->destRight = x + context->icon_width; cmd->destBottom = y + context->icon_height; cmd->bpp = 32; cmd->codecID = client->settings->rfx_codec_id; cmd->width = context->icon_width; cmd->height = context->icon_height; cmd->bitmapDataLength = stream_get_length(s); cmd->bitmapData = stream_get_head(s); update->SurfaceBits(update->context, cmd); context->icon_x = x; context->icon_y = y; }
static void test_peer_draw_background(freerdp_peer* client) { int size; wStream* s; RFX_RECT rect; BYTE* rgb_data; rdpUpdate* update = client->update; SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command; testPeerContext* context = (testPeerContext*) client->context; if (!client->settings->RemoteFxCodec && !client->settings->NSCodec) return; s = test_peer_stream_init(context); rect.x = 0; rect.y = 0; rect.width = client->settings->DesktopWidth; rect.height = client->settings->DesktopHeight; size = rect.width * rect.height * 3; if (!(rgb_data = malloc(size))) return; memset(rgb_data, 0xA0, size); if (client->settings->RemoteFxCodec) { if (!rfx_compose_message(context->rfx_context, s, &rect, 1, rgb_data, rect.width, rect.height, rect.width * 3)) { goto out; } cmd->codecID = client->settings->RemoteFxCodecId; } else { nsc_compose_message(context->nsc_context, s, rgb_data, rect.width, rect.height, rect.width * 3); cmd->codecID = client->settings->NSCodecId; } cmd->destLeft = 0; cmd->destTop = 0; cmd->destRight = rect.width; cmd->destBottom = rect.height; cmd->bpp = 32; cmd->width = rect.width; cmd->height = rect.height; cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapData = Stream_Buffer(s); test_peer_begin_frame(client); update->SurfaceBits(update->context, cmd); test_peer_end_frame(client); out: free(rgb_data); }
static void test_peer_draw_background(freerdp_peer* client) { testPeerContext* context = (testPeerContext*) client->context; rdpUpdate* update = client->update; SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command; STREAM* s; RFX_RECT rect; uint8* rgb_data; int size; if (!client->settings->rfx_codec && !client->settings->ns_codec) return; test_peer_begin_frame(client); s = test_peer_stream_init(context); rect.x = 0; rect.y = 0; rect.width = client->settings->width; rect.height = client->settings->height; size = rect.width * rect.height * 3; rgb_data = xmalloc(size); memset(rgb_data, 0xA0, size); if (client->settings->rfx_codec) { rfx_compose_message(context->rfx_context, s, &rect, 1, rgb_data, rect.width, rect.height, rect.width * 3); cmd->codecID = client->settings->rfx_codec_id; } else { nsc_compose_message(context->nsc_context, s, rgb_data, rect.width, rect.height, rect.width * 3); cmd->codecID = client->settings->ns_codec_id; } cmd->destLeft = 0; cmd->destTop = 0; cmd->destRight = rect.width; cmd->destBottom = rect.height; cmd->bpp = 32; cmd->width = rect.width; cmd->height = rect.height; cmd->bitmapDataLength = stream_get_length(s); cmd->bitmapData = stream_get_head(s); update->SurfaceBits(update->context, cmd); xfree(rgb_data); test_peer_end_frame(client); }
void test_message(void) { RFX_CONTEXT* context; STREAM* s; int i, j; RFX_RECT rect = {0, 0, 100, 80}; RFX_MESSAGE * message; rgb_data = (BYTE *) malloc(100 * 80 * 3); for (i = 0; i < 80; i++) memcpy(rgb_data + i * 100 * 3, rgb_scanline_data, 100 * 3); s = stream_new(65536); stream_clear(s); context = rfx_context_new(); context->mode = RLGR3; context->width = 800; context->height = 600; rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8); for (i = 0; i < 1000; i++) { s = stream_new(65536); stream_clear(s); rfx_compose_message(context, s, &rect, 1, rgb_data, 100, 80, 100 * 3); stream_seal(s); /*hexdump(buffer, size);*/ stream_set_pos(s, 0); message = rfx_process_message(context, s->p, s->size); if (i == 0) { for (j = 0; j < message->num_tiles; j++) { dump_ppm_image(message->tiles[j]->data); } } rfx_message_free(context, message); stream_free(s); } rfx_context_free(context); free(rgb_data); }
void wf_update_encode(wfInfo* wfi) { RFX_RECT rect; long height, width; BYTE* pDataBits = NULL; int stride; SURFACE_BITS_COMMAND* cmd; wf_info_find_invalid_region(wfi); cmd = &wfi->cmd; stream_set_pos(wfi->s, 0); wf_info_getScreenData(wfi, &width, &height, &pDataBits, &stride); rect.x = 0; rect.y = 0; rect.width = (UINT16) width; rect.height = (UINT16) height; //printf("x:%d y:%d w:%d h:%d\n", wfi->invalid.left, wfi->invalid.top, width, height); stream_clear(wfi->s); rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1, pDataBits, width, height, stride); wfi->frame_idx = wfi->rfx_context->frame_idx; cmd->destLeft = wfi->invalid.left; cmd->destTop = wfi->invalid.top; cmd->destRight = wfi->invalid.left + width; cmd->destBottom = wfi->invalid.top + height; cmd->bpp = 32; cmd->codecID = 3; cmd->width = width; cmd->height = height; cmd->bitmapDataLength = stream_get_length(wfi->s); cmd->bitmapData = stream_get_head(wfi->s); }
void wf_update_encode(wfInfo* wfi) { long offset; RFX_RECT rect; long height, width; GETCHANGESBUF* changes; SURFACE_BITS_COMMAND* cmd; wf_info_find_invalid_region(wfi); cmd = &wfi->cmd; changes = (GETCHANGESBUF*) wfi->changeBuffer; width = (wfi->invalid.right - wfi->invalid.left) + 1; height = (wfi->invalid.bottom - wfi->invalid.top) + 1; stream_clear(wfi->s); stream_set_pos(wfi->s, 0); rect.x = 0; rect.y = 0; rect.width = (uint16) width; rect.height = (uint16) height; offset = (4 * wfi->invalid.left) + (wfi->invalid.top * wfi->width * 4); rfx_compose_message(wfi->rfx_context, wfi->s, &rect, 1, ((uint8*) (changes->Userbuffer)) + offset, width, height, wfi->width * 4); cmd->destLeft = wfi->invalid.left; cmd->destTop = wfi->invalid.top; cmd->destRight = wfi->invalid.left + width; cmd->destBottom = wfi->invalid.top + height; cmd->bpp = 32; cmd->codecID = 3; cmd->width = width; cmd->height = height; cmd->bitmapDataLength = stream_get_length(wfi->s); cmd->bitmapData = stream_get_head(wfi->s); }
static void test_peer_draw_icon(freerdp_peer* client, int x, int y) { wStream* s; RFX_RECT rect; rdpUpdate* update = client->update; SURFACE_BITS_COMMAND* cmd = &update->surface_bits_command; testPeerContext* context = (testPeerContext*) client->context; if (client->update->dump_rfx) return; if (!context) return; if (context->icon_width < 1 || !context->activated) return; test_peer_begin_frame(client); rect.x = 0; rect.y = 0; rect.width = context->icon_width; rect.height = context->icon_height; if (context->icon_x >= 0) { s = test_peer_stream_init(context); if (client->settings->RemoteFxCodec) { rfx_compose_message(context->rfx_context, s, &rect, 1, context->bg_data, rect.width, rect.height, rect.width * 3); cmd->codecID = client->settings->RemoteFxCodecId; } else { nsc_compose_message(context->nsc_context, s, context->bg_data, rect.width, rect.height, rect.width * 3); cmd->codecID = client->settings->NSCodecId; } cmd->destLeft = context->icon_x; cmd->destTop = context->icon_y; cmd->destRight = context->icon_x + context->icon_width; cmd->destBottom = context->icon_y + context->icon_height; cmd->bpp = 32; cmd->width = context->icon_width; cmd->height = context->icon_height; cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapData = Stream_Buffer(s); update->SurfaceBits(update->context, cmd); } s = test_peer_stream_init(context); if (client->settings->RemoteFxCodec) { rfx_compose_message(context->rfx_context, s, &rect, 1, context->icon_data, rect.width, rect.height, rect.width * 3); cmd->codecID = client->settings->RemoteFxCodecId; } else { nsc_compose_message(context->nsc_context, s, context->icon_data, rect.width, rect.height, rect.width * 3); cmd->codecID = client->settings->NSCodecId; } cmd->destLeft = x; cmd->destTop = y; cmd->destRight = x + context->icon_width; cmd->destBottom = y + context->icon_height; cmd->bpp = 32; cmd->width = context->icon_width; cmd->height = context->icon_height; cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapData = Stream_Buffer(s); update->SurfaceBits(update->context, cmd); context->icon_x = x; context->icon_y = y; test_peer_end_frame(client); }
void mf_peer_rfx_update(freerdp_peer* client) { //check mfInfo* mfi = mf_info_get_instance(); mf_info_find_invalid_region(mfi); if (mf_info_have_invalid_region(mfi) == false) { return; } long width; long height; int pitch; BYTE* dataBits = NULL; mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch); mf_info_clear_invalid_region(mfi); //encode wStream* s; RFX_RECT rect; rdpUpdate* update; mfPeerContext* mfp; SURFACE_BITS_COMMAND* cmd; update = client->update; mfp = (mfPeerContext*) client->context; cmd = &update->surface_bits_command; s = mfp->s; Stream_Clear(s); Stream_SetPosition(s, 0); UINT32 x = mfi->invalid.x / mfi->scale; UINT32 y = mfi->invalid.y / mfi->scale; rect.x = 0; rect.y = 0; rect.width = width; rect.height = height; mfp->rfx_context->width = mfi->servscreen_width; mfp->rfx_context->height = mfi->servscreen_height; if (!(rfx_compose_message(mfp->rfx_context, s, &rect, 1, (BYTE*) dataBits, rect.width, rect.height, pitch))) { return; } cmd->destLeft = x; cmd->destTop = y; cmd->destRight = x + rect.width; cmd->destBottom = y + rect.height; cmd->bpp = 32; cmd->codecID = 3; cmd->width = rect.width; cmd->height = rect.height; cmd->bitmapDataLength = Stream_GetPosition(s); cmd->bitmapData = Stream_Buffer(s); //send update->SurfaceBits(update->context, cmd); //clean up... maybe? }
void mf_peer_rfx_update(freerdp_peer* client) { //check mfInfo* mfi = mf_info_get_instance(); mf_info_find_invalid_region(mfi); if (mf_info_have_invalid_region(mfi) == false) { return; } long width; long height; int pitch; BYTE* dataBits = NULL; mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch); mf_info_clear_invalid_region(mfi); //encode STREAM* s; RFX_RECT rect; rdpUpdate* update; mfPeerContext* mfp; SURFACE_BITS_COMMAND* cmd; update = client->update; mfp = (mfPeerContext*) client->context; cmd = &update->surface_bits_command; s = mfp->s; stream_clear(s); stream_set_pos(s, 0); UINT32 x = mfi->invalid.x / mfi->scale; UINT32 y = mfi->invalid.y / mfi->scale; rect.x = 0; rect.y = 0; rect.width = width; rect.height = height; mfp->rfx_context->width = mfi->servscreen_width; mfp->rfx_context->height = mfi->servscreen_height; rfx_compose_message(mfp->rfx_context, s, &rect, 1, (BYTE*) dataBits, rect.width, rect.height, pitch); cmd->destLeft = x; cmd->destTop = y; cmd->destRight = x + rect.width; cmd->destBottom = y + rect.height; cmd->bpp = 32; cmd->codecID = 3; cmd->width = rect.width; cmd->height = rect.height; cmd->bitmapDataLength = stream_get_length(s); cmd->bitmapData = stream_get_head(s); //send update->SurfaceBits(update->context, cmd); //clean up // note: need to stop getting new dirty rects until here /* CGColorSpaceRelease(rgbColorSpace); CGImageRelease(image); CGContextRelease(context); CVPixelBufferUnlockBaseAddress(pxbuffer, 0); CVPixelBufferRelease(pxbuffer); */ }