diff --git a/cunit/test_librfx.c b/cunit/test_librfx.c index ff2edd1e1..7671b591a 100644 --- a/cunit/test_librfx.c +++ b/cunit/test_librfx.c @@ -282,6 +282,7 @@ static void dump_ppm_image(uint8* image_buf) snprintf(buf, sizeof(buf), "/tmp/FreeRDP_Frame_%d.ppm", frame_id); fp = fopen(buf, "wb"); fwrite("P6\n", 1, 3, fp); + fwrite("# Created by FreeRDP\n", 1, 21, fp); fwrite("64 64\n", 1, 6, fp); fwrite("255\n", 1, 4, fp); fwrite(image_buf, 1, 4096 * 3, fp); @@ -382,19 +383,11 @@ void test_message(void) context->height = 600; rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB); - rfx_compose_message_header(context, s); - /*hexdump(buffer, size);*/ - stream_seal(s); - stream_set_pos(s, 0); - message = rfx_process_message(context, s); - rfx_message_free(context, message); - stream_free(s); - for (i = 0; i < 1000; i++) { s = stream_new(65536); stream_clear(s); - rfx_compose_message_data(context, s, + rfx_compose_message(context, s, &rect, 1, rgb_data, 100, 80, 100 * 3); stream_seal(s); /*hexdump(buffer, size);*/ diff --git a/include/freerdp/rfx/rfx.h b/include/freerdp/rfx/rfx.h index 8ade4373f..21d5a1e76 100644 --- a/include/freerdp/rfx/rfx.h +++ b/include/freerdp/rfx/rfx.h @@ -124,8 +124,7 @@ FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, RFX_PIXEL_FO FREERDP_API RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, STREAM* data_in); FREERDP_API void rfx_message_free(RFX_CONTEXT* context, RFX_MESSAGE* message); -FREERDP_API void rfx_compose_message_header(RFX_CONTEXT* context, STREAM* data_out); -FREERDP_API void rfx_compose_message_data(RFX_CONTEXT* context, STREAM* data_out, +FREERDP_API void rfx_compose_message(RFX_CONTEXT* context, STREAM* data_out, const RFX_RECT* rects, int num_rects, uint8* image_data, int width, int height, int rowstride); #ifdef __cplusplus diff --git a/libfreerdp-rfx/librfx.c b/libfreerdp-rfx/librfx.c index 8304a3f9e..a400cf5a8 100644 --- a/libfreerdp-rfx/librfx.c +++ b/libfreerdp-rfx/librfx.c @@ -625,7 +625,7 @@ static void rfx_compose_message_context(RFX_CONTEXT* context, STREAM* data_out) context->properties = properties; } -void rfx_compose_message_header(RFX_CONTEXT* context, STREAM* data_out) +static void rfx_compose_message_header(RFX_CONTEXT* context, STREAM* data_out) { stream_check_size(data_out, 12 + 10 + 12 + 13); @@ -818,7 +818,7 @@ static void rfx_compose_message_frame_end(RFX_CONTEXT* context, STREAM* data_out stream_write_uint8(data_out, 0); /* CodecChannelT.channelId */ } -void rfx_compose_message_data(RFX_CONTEXT* context, STREAM* data_out, +static void rfx_compose_message_data(RFX_CONTEXT* context, STREAM* data_out, const RFX_RECT* rects, int num_rects, uint8* image_data, int width, int height, int rowstride) { rfx_compose_message_frame_begin(context, data_out); @@ -826,3 +826,14 @@ void rfx_compose_message_data(RFX_CONTEXT* context, STREAM* data_out, rfx_compose_message_tileset(context, data_out, image_data, width, height, rowstride); rfx_compose_message_frame_end(context, data_out); } + +FREERDP_API void rfx_compose_message(RFX_CONTEXT* context, STREAM* data_out, + const RFX_RECT* rects, int num_rects, uint8* image_data, int width, int height, int rowstride) +{ + /* Only the first frame should send the RemoteFX header */ + if (context->frame_idx == 0) + rfx_compose_message_header(context, data_out); + + rfx_compose_message_data(context, data_out, rects, num_rects, image_data, width, height, rowstride); +} +