From 240867a4323f6fa6029dab744ea34e2760d4d075 Mon Sep 17 00:00:00 2001 From: Frode Langelo Date: Fri, 31 Jul 2015 15:41:55 -0700 Subject: [PATCH] GUAC-240: Make JPEG quality a parameter to methods. Reorder JPEG_LIBS in LDFLAGS --- src/libguac/Makefile.am | 4 ++-- src/libguac/guacamole/protocol.h | 6 +++++- src/libguac/protocol.c | 12 ++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/libguac/Makefile.am b/src/libguac/Makefile.am index 8fc95a6d..e53e71a1 100644 --- a/src/libguac/Makefile.am +++ b/src/libguac/Makefile.am @@ -97,11 +97,11 @@ libguac_la_CFLAGS = \ libguac_la_LDFLAGS = \ -version-info 9:0:0 \ @CAIRO_LIBS@ \ + @JPEG_LIBS@ \ @PNG_LIBS@ \ @PTHREAD_LIBS@ \ @UUID_LIBS@ \ - @VORBIS_LIBS@ \ - @JPEG_LIBS@ + @VORBIS_LIBS@ libguac_la_LIBADD = \ @LIBADD_DLOPEN@ diff --git a/src/libguac/guacamole/protocol.h b/src/libguac/guacamole/protocol.h index be78ce33..16ea70a3 100644 --- a/src/libguac/guacamole/protocol.h +++ b/src/libguac/guacamole/protocol.h @@ -637,11 +637,15 @@ int guac_protocol_send_png(guac_socket* socket, guac_composite_mode mode, * @param surface * A cairo surface containing the image data to send. * + * @param quality + * JPEG image quality. + * * @return * Zero on success, non-zero on error. */ int guac_protocol_send_jpeg(guac_socket* socket, guac_composite_mode mode, - const guac_layer* layer, int x, int y, cairo_surface_t* surface); + const guac_layer* layer, int x, int y, cairo_surface_t* surface, + int quality); /** * Sends a pop instruction over the given guac_socket connection. diff --git a/src/libguac/protocol.c b/src/libguac/protocol.c index 6ea7e920..eec27d5a 100644 --- a/src/libguac/protocol.c +++ b/src/libguac/protocol.c @@ -85,10 +85,14 @@ ssize_t __guac_socket_write_length_double(guac_socket* socket, double d) { * @param surface *   A cairo surface containing the image data to send. * + * @param quality + * JPEG image quality. + * * @return * Zero on success, non-zero on error. */ -static int __guac_socket_write_length_jpeg(guac_socket* socket, cairo_surface_t* surface) { +static int __guac_socket_write_length_jpeg(guac_socket* socket, + cairo_surface_t* surface, int quality) { /* Get image surface properties and data */ cairo_format_t format = cairo_image_surface_get_format(surface); @@ -99,7 +103,6 @@ static int __guac_socket_write_length_jpeg(guac_socket* socket, cairo_surface_t* return -1; } - int quality = 80; /* JPEG compression quality setting */ int width = cairo_image_surface_get_width(surface); int height = cairo_image_surface_get_height(surface); int stride = cairo_image_surface_get_stride(surface); @@ -1181,7 +1184,8 @@ int guac_protocol_send_pipe(guac_socket* socket, const guac_stream* stream, } int guac_protocol_send_jpeg(guac_socket* socket, guac_composite_mode mode, - const guac_layer* layer, int x, int y, cairo_surface_t* surface) { + const guac_layer* layer, int x, int y, cairo_surface_t* surface, + int quality) { int ret_val; @@ -1196,7 +1200,7 @@ int guac_protocol_send_jpeg(guac_socket* socket, guac_composite_mode mode, || guac_socket_write_string(socket, ",") || __guac_socket_write_length_int(socket, y) || guac_socket_write_string(socket, ",") - || __guac_socket_write_length_jpeg(socket, surface) + || __guac_socket_write_length_jpeg(socket, surface, quality) || guac_socket_write_string(socket, ";"); guac_socket_instruction_end(socket);