GUAC-240: Add function for streaming PNG images via img instruction. Use for surface.
This commit is contained in:
parent
56fa7423f3
commit
9c2d7f56ce
@ -969,7 +969,8 @@ static void __guac_common_surface_flush_to_png(guac_common_surface* surface) {
|
||||
surface->stride);
|
||||
|
||||
/* Send PNG for rect */
|
||||
guac_protocol_send_png(socket, GUAC_COMP_OVER, layer, surface->dirty_rect.x, surface->dirty_rect.y, rect);
|
||||
guac_client_stream_png(surface->client, socket, GUAC_COMP_OVER,
|
||||
layer, surface->dirty_rect.x, surface->dirty_rect.y, rect);
|
||||
cairo_surface_destroy(rect);
|
||||
surface->realized = 1;
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "client.h"
|
||||
#include "client-handlers.h"
|
||||
#include "encode-png.h"
|
||||
#include "error.h"
|
||||
#include "instruction.h"
|
||||
#include "layer.h"
|
||||
@ -375,3 +376,24 @@ void guac_client_abort(guac_client* client, guac_protocol_status status,
|
||||
|
||||
}
|
||||
|
||||
void guac_client_stream_png(guac_client* client, guac_socket* socket,
|
||||
guac_composite_mode mode, const guac_layer* layer, int x, int y,
|
||||
cairo_surface_t* surface) {
|
||||
|
||||
/* Allocate new stream for image */
|
||||
guac_stream* stream = guac_client_alloc_stream(client);
|
||||
|
||||
/* Declare stream as containing image data */
|
||||
guac_protocol_send_img(socket, stream, mode, layer, "image/png", x, y);
|
||||
|
||||
/* Write PNG data */
|
||||
guac_png_write(socket, stream, surface);
|
||||
|
||||
/* Terminate stream */
|
||||
guac_protocol_send_end(socket, stream);
|
||||
|
||||
/* Free allocated stream */
|
||||
guac_client_free_stream(client, stream);
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "stream-types.h"
|
||||
#include "timestamp-types.h"
|
||||
|
||||
#include <cairo/cairo.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
struct guac_client_info {
|
||||
@ -627,6 +628,39 @@ guac_object* guac_client_alloc_object(guac_client* client);
|
||||
*/
|
||||
void guac_client_free_object(guac_client* client, guac_object* object);
|
||||
|
||||
/**
|
||||
* Streams the image data of the given surface over an image stream ("img"
|
||||
* instruction) as PNG-encoded data. The image stream will be automatically
|
||||
* allocated and freed.
|
||||
*
|
||||
* @param client
|
||||
* The Guacamole client from which the image stream should be allocated.
|
||||
*
|
||||
* @param socket
|
||||
* The socket over which instructions associated with the image stream
|
||||
* should be sent.
|
||||
*
|
||||
* @param mode
|
||||
* The composite mode to use when rendering the image over the given layer.
|
||||
*
|
||||
* @param layer
|
||||
* The destination layer.
|
||||
*
|
||||
* @param x
|
||||
* The X coordinate of the upper-left corner of the destination rectangle
|
||||
* within the given layer.
|
||||
*
|
||||
* @param y
|
||||
* The Y coordinate of the upper-left corner of the destination rectangle
|
||||
* within the given layer.
|
||||
*
|
||||
* @param surface
|
||||
* A Cairo surface containing the image data to be streamed.
|
||||
*/
|
||||
void guac_client_stream_png(guac_client* client, guac_socket* socket,
|
||||
guac_composite_mode mode, const guac_layer* layer, int x, int y,
|
||||
cairo_surface_t* surface);
|
||||
|
||||
/**
|
||||
* The default Guacamole client layer, layer 0.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user