GUAC-236: Implement blob, end, and img instructions.

This commit is contained in:
Michael Jumper 2016-02-27 19:28:11 -08:00
parent d29d5bbc99
commit 3661cadf4e
3 changed files with 27 additions and 14 deletions

View File

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

View File

@ -22,6 +22,7 @@
#include "config.h"
#include "display.h"
#include "image-stream.h"
#include "log.h"
#include <guacamole/client.h>
@ -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);
}

View File

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