Add video instruction.

This commit is contained in:
Michael Jumper 2012-10-25 10:54:30 -07:00
parent 872bb16872
commit ef9914cfdf
2 changed files with 36 additions and 0 deletions

View File

@ -290,6 +290,23 @@ int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp);
int guac_protocol_send_audio(guac_socket* socket, int channel,
const char* mimetype, int duration, void* data, int size);
/**
* Sends an video instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param layer The destination layer.
* @param mimetype The mimetype of the data being sent.
* @param duration The duration of the video being sent, in milliseconds.
* @param data The video data to be sent.
* @param size The number of bytes of video data to send.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_video(guac_socket* socket, const guac_layer* layer,
const char* mimetype, int duration, void* data, int size);
/* DRAWING INSTRUCTIONS */
/**

View File

@ -944,4 +944,23 @@ int guac_protocol_send_transform(guac_socket* socket, const guac_layer* layer,
}
int guac_protocol_send_video(guac_socket* socket, const guac_layer* layer,
const char* mimetype, int duration, void* data, int size) {
int base64_length = (size + 2) / 3 * 4;
return
guac_socket_write_string(socket, "5.video,")
|| __guac_socket_write_length_int(socket, layer->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_string(socket, mimetype)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, duration)
|| guac_socket_write_string(socket, ",")
|| guac_socket_write_int(socket, base64_length)
|| guac_socket_write_string(socket, ".")
|| guac_socket_write_base64(socket, data, size)
|| guac_socket_flush_base64(socket)
|| guac_socket_write_string(socket, ";");
}