libfreerdp-rfx: enhance the encoder to deal with the header automatically.

This commit is contained in:
Vic Lee 2011-08-25 17:25:10 +08:00
parent 41f16251ed
commit 78b9e4d52c
3 changed files with 16 additions and 13 deletions

View File

@ -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);*/

View File

@ -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

View File

@ -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);
}