From 3661cadf4e24c1cc417e3ec49da1863d7267a804 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 27 Feb 2016 19:28:11 -0800 Subject: [PATCH] GUAC-236: Implement blob, end, and img instructions. --- src/guacenc/instruction-blob.c | 14 +++++++++----- src/guacenc/instruction-end.c | 18 +++++++++++++++--- src/guacenc/instruction-img.c | 9 +++------ 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/guacenc/instruction-blob.c b/src/guacenc/instruction-blob.c index 67b4fbb2..9e8ad3f6 100644 --- a/src/guacenc/instruction-blob.c +++ b/src/guacenc/instruction-blob.c @@ -40,12 +40,16 @@ int guacenc_handle_blob(guacenc_display* display, int argc, char** argv) { /* Parse arguments */ int index = atoi(argv[0]); char* data = argv[1]; - int data_length = guac_protocol_decode_base64(data); + int length = guac_protocol_decode_base64(data); - /* STUB */ - guacenc_log(GUAC_LOG_DEBUG, "blob: stream=%i data=[%i bytes]", - index, data_length); - return 0; + /* Retrieve image stream */ + guacenc_image_stream* stream = + guacenc_display_get_image_stream(display, index); + if (stream == NULL) + return 1; + + /* Send data to decoder within associated stream */ + return guacenc_image_stream_receive(stream, (unsigned char*) data, length); } diff --git a/src/guacenc/instruction-end.c b/src/guacenc/instruction-end.c index fbc9e284..749ead2a 100644 --- a/src/guacenc/instruction-end.c +++ b/src/guacenc/instruction-end.c @@ -22,6 +22,7 @@ #include "config.h" #include "display.h" +#include "image-stream.h" #include "log.h" #include @@ -39,9 +40,20 @@ int guacenc_handle_end(guacenc_display* display, int argc, char** argv) { /* Parse arguments */ int index = atoi(argv[0]); - /* STUB */ - guacenc_log(GUAC_LOG_DEBUG, "end: stream=%i", index); - return 0; + /* Retrieve image stream */ + guacenc_image_stream* stream = + guacenc_display_get_image_stream(display, index); + if (stream == NULL) + return 1; + + /* Retrieve destination buffer */ + guacenc_buffer* buffer = + guacenc_display_get_related_buffer(display, stream->index); + if (buffer == NULL) + return 1; + + /* End image stream, drawing final image to the buffer */ + return guacenc_image_stream_end(stream, buffer); } diff --git a/src/guacenc/instruction-img.c b/src/guacenc/instruction-img.c index bbd0c33f..e7c07188 100644 --- a/src/guacenc/instruction-img.c +++ b/src/guacenc/instruction-img.c @@ -44,12 +44,9 @@ int guacenc_handle_img(guacenc_display* display, int argc, char** argv) { int x = atoi(argv[4]); int y = atoi(argv[5]); - /* STUB */ - guacenc_log(GUAC_LOG_DEBUG, "img: stream=%i mask=0x%X layer=%i " - "mimetype=%s (%i, %i)", stream_index, mask, layer_index, - mimetype, x, y); - - return 0; + /* Create requested stream */ + return guacenc_display_create_image_stream(display, stream_index, + mask, layer_index, mimetype, x, y); }