[Spice-commits] 5 commits - spice/Makefile.am spice/stream-device.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu Oct 12 12:58:03 UTC 2017


 spice/Makefile.am     |    1 
 spice/stream-device.h |  211 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 212 insertions(+)

New commits:
commit c05cc9197221ab4568250dc7bb100529626adffa
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Aug 17 10:26:29 2017 +0100

    Add support for mouse movement
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe de Dinechin <cdupontd at redhat.com>

diff --git a/spice/stream-device.h b/spice/stream-device.h
index d8612a4..bf919ed 100644
--- a/spice/stream-device.h
+++ b/spice/stream-device.h
@@ -87,6 +87,8 @@ typedef enum StreamMsgType {
     STREAM_TYPE_NOTIFY_ERROR,
     /* guest cursor */
     STREAM_TYPE_CURSOR_SET,
+    /* guest cursor position */
+    STREAM_TYPE_CURSOR_MOVE,
 } StreamMsgType;
 
 /* Generic extension capabilities.
@@ -196,5 +198,14 @@ typedef struct StreamMsgCursorSet {
     uint8_t data[0];
 } StreamMsgCursorSet;
 
+/* Guest cursor position
+ * This message is sent by the guest to the host.
+ *
+ * States allowed: Streaming
+ */
+typedef struct StreamMsgCursorMove {
+    int32_t x;
+    int32_t y;
+} StreamMsgCursorMove;
 
 #endif /* SPICE_STREAM_DEVICE_H_ */
commit a419692ea9f62cd32f0a211ff578e536c15a496d
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Jun 6 10:39:09 2017 +0100

    Add support for setting cursor shape from guest
    
    This allows to better support client mouse using streaming device
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe de Dinechin <cdupontd at redhat.com>

diff --git a/spice/stream-device.h b/spice/stream-device.h
index 67d70e1..d8612a4 100644
--- a/spice/stream-device.h
+++ b/spice/stream-device.h
@@ -85,6 +85,8 @@ typedef enum StreamMsgType {
     STREAM_TYPE_START_STOP,
     /* server notify errors to guest */
     STREAM_TYPE_NOTIFY_ERROR,
+    /* guest cursor */
+    STREAM_TYPE_CURSOR_SET,
 } StreamMsgType;
 
 /* Generic extension capabilities.
@@ -164,4 +166,35 @@ typedef struct StreamMsgNotifyError {
     uint8_t msg[0];
 } StreamMsgNotifyError;
 
+#define STREAM_MSG_CURSOR_SET_MAX_WIDTH  1024
+#define STREAM_MSG_CURSOR_SET_MAX_HEIGHT 1024
+
+/* Guest cursor.
+ * This message is sent by the guest to the host.
+ *
+ * States allowed: Streaming
+ */
+typedef struct StreamMsgCursorSet {
+    /* basic cursor information */
+    /* for security reasons width and height should
+     * be limited to STREAM_MSG_CURSOR_SET_MAX_WIDTH and
+     * STREAM_MSG_CURSOR_SET_MAX_HEIGHT */
+    uint16_t width;
+    uint16_t height;
+    uint16_t hot_spot_x;
+    uint16_t hot_spot_y;
+    /* Cursor type, as defined by SpiceCursorType.
+     * Only ALPHA, COLOR24 and COLOR32 are allowed by this protocol
+     */
+    uint8_t type;
+
+    uint8_t padding1[3];
+
+    /* cursor data.
+     * Format and size depends on cursor_header type and size
+     */
+    uint8_t data[0];
+} StreamMsgCursorSet;
+
+
 #endif /* SPICE_STREAM_DEVICE_H_ */
commit 909da449e3bd62ef33ac2ca2ae59a9d4603af59c
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Mar 14 11:55:28 2017 +0000

    Add error reports from server to guest
    
    Acked-by: Christophe de Dinechin <cdupontd at redhat.com>

diff --git a/spice/stream-device.h b/spice/stream-device.h
index 0185fbd..67d70e1 100644
--- a/spice/stream-device.h
+++ b/spice/stream-device.h
@@ -83,6 +83,8 @@ typedef enum StreamMsgType {
     STREAM_TYPE_DATA,
     /* server ask to start a new stream */
     STREAM_TYPE_START_STOP,
+    /* server notify errors to guest */
+    STREAM_TYPE_NOTIFY_ERROR,
 } StreamMsgType;
 
 /* Generic extension capabilities.
@@ -144,4 +146,22 @@ typedef struct StreamMsgStartStop {
     uint8_t codecs[0];
 } StreamMsgStartStop;
 
+/* Tell guest about invalid protocol.
+ * This message is sent by the host to the guest.
+ * The server will stop processing data from the guest.
+ *
+ * States allowed: any
+ */
+typedef struct StreamMsgNotifyError {
+    /* numeric error code.
+     * Currently not defined, set to 0.
+     */
+    uint32_t error_code;
+    /* String message, UTF-8 encoded.
+     * This field terminate with the message.
+     * Not necessary NUL-terminated.
+     */
+    uint8_t msg[0];
+} StreamMsgNotifyError;
+
 #endif /* SPICE_STREAM_DEVICE_H_ */
commit 02b12e66de572ea4d51f24bb6d9ac407f273c27f
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Jan 19 12:36:27 2017 +0000

    Add a message to control guest streaming
    
    Allows server to tell codec and start/stop the streaming
    
    Acked-by: Christophe de Dinechin <cdupontd at redhat.com>

diff --git a/spice/stream-device.h b/spice/stream-device.h
index 427095b..0185fbd 100644
--- a/spice/stream-device.h
+++ b/spice/stream-device.h
@@ -81,6 +81,8 @@ typedef enum StreamMsgType {
     STREAM_TYPE_FORMAT,
     /* stream data */
     STREAM_TYPE_DATA,
+    /* server ask to start a new stream */
+    STREAM_TYPE_START_STOP,
 } StreamMsgType;
 
 /* Generic extension capabilities.
@@ -125,4 +127,21 @@ typedef struct StreamMsgData {
     uint8_t data[0];
 } StreamMsgData;
 
+/* Tell to stop current stream and possibly start a new one.
+ * This message is sent by the host to the guest.
+ * Allows to communicate the codecs supported by the clients.
+ * The agent should stop the old stream and if any codec in the
+ * list is supported start streaming (as Mjpeg is always supported
+ * agent should stop only on a real stop request).
+ *
+ * States allowed: any
+ *   state will change to Idle (no codecs) or Ready
+ */
+typedef struct StreamMsgStartStop {
+    /* supported codecs, 0 to stop streaming */
+    uint8_t num_codecs;
+    /* as defined in SpiceVideoCodecType enumeration */
+    uint8_t codecs[0];
+} StreamMsgStartStop;
+
 #endif /* SPICE_STREAM_DEVICE_H_ */
commit a1d8ccabbfd29f2773a82089b7929d622f79b35e
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Apr 19 16:16:07 2017 +0100

    Add protocol to send streams to server
    
    This protocol allows a guest to send a video stream to the server.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe de Dinechin <cdupontd at redhat.com>

diff --git a/spice/Makefile.am b/spice/Makefile.am
index a54ae89..4f9a607 100644
--- a/spice/Makefile.am
+++ b/spice/Makefile.am
@@ -19,6 +19,7 @@ spice_protocol_include_HEADERS =		\
 	types.h					\
 	vd_agent.h				\
 	vdi_dev.h				\
+	stream-device.h				\
 	$(NULL)
 
 -include $(top_srcdir)/git.mk
diff --git a/spice/stream-device.h b/spice/stream-device.h
new file mode 100644
index 0000000..427095b
--- /dev/null
+++ b/spice/stream-device.h
@@ -0,0 +1,128 @@
+/*
+   Copyright (C) 2017 Red Hat, Inc.
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions are
+   met:
+
+       * Redistributions of source code must retain the above copyright
+         notice, this list of conditions and the following disclaimer.
+       * Redistributions in binary form must reproduce the above copyright
+         notice, this list of conditions and the following disclaimer in
+         the documentation and/or other materials provided with the
+         distribution.
+       * Neither the name of the copyright holder nor the names of its
+         contributors may be used to endorse or promote products derived
+         from this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
+   IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+   TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+   PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+ * This header contains definition for the device that
+ * allows to send streamed data to the server.
+ *
+ * The device is currently implemented as a VirtIO port inside the
+ * guest. The guest should open that device to use this protocol to
+ * communicate with the host.
+ * The name of the port is "com.redhat.stream.0".
+ */
+
+#ifndef SPICE_STREAM_DEVICE_H_
+#define SPICE_STREAM_DEVICE_H_
+
+#include <spice/types.h>
+
+/*
+ * Structures are all "naturally aligned"
+ * containing integers up to 64 bit.
+ * All numbers are in little endian format.
+ *
+ * The protocol can be defined by these states:
+ * - Initial. Device just opened. Guest should wait
+ *   for a message from the host;
+ * - Idle. No streaming allowed;
+ * - Ready. Server sent list of possible codecs;
+ * - Streaming. Stream active, enabled by the guest.
+ */
+
+/* version of the protocol */
+#define STREAM_DEVICE_PROTOCOL 1
+
+typedef struct StreamDevHeader {
+    /* should be STREAM_DEVICE_PROTOCOL */
+    uint8_t protocol_version;
+    /* reserved, should be set to 0 */
+    uint8_t padding;
+    /* as defined in StreamMsgType enumeration */
+    uint16_t type;
+    /* size of the following message.
+     * A message of type STREAM_TYPE_XXX_YYY is represented with a
+     * corresponding StreamMsgXxxYyy structure. */
+    uint32_t size;
+} StreamDevHeader;
+
+typedef enum StreamMsgType {
+    /* invalid, do not use */
+    STREAM_TYPE_INVALID = 0,
+    /* allows to send version information */
+    STREAM_TYPE_CAPABILITIES,
+    /* send screen resolution */
+    STREAM_TYPE_FORMAT,
+    /* stream data */
+    STREAM_TYPE_DATA,
+} StreamMsgType;
+
+/* Generic extension capabilities.
+ * This is a set of bits to specify which capabilities host and guest support.
+ * This message is sent by the host to the guest or by the guest to the host.
+ * Should be sent as first message.
+ * If it is not sent, it means that guest/host doesn't support any extension.
+ * Guest should send this as a reply from same type of message
+ * from the host.
+ * This message should be limited to 1024 bytes. This allows
+ * plenty of negotiations.
+ *
+ * States allowed: Initial(host), Idle(guest)
+ *   state will change to Idle.
+ */
+typedef struct StreamMsgCapabilities {
+    uint8_t capabilities[0];
+} StreamMsgCapabilities;
+
+/* Define the format of the stream, start a new stream.
+ * This message is sent by the guest to the host to
+ * tell the host the new stream format.
+ *
+ * States allowed: Ready
+ *   state will change to Streaming.
+ */
+typedef struct StreamMsgFormat {
+    /* screen resolution/stream size */
+    uint32_t width;
+    uint32_t height;
+    /* as defined in SpiceVideoCodecType enumeration */
+    uint8_t codec;
+    uint8_t padding1[3];
+} StreamMsgFormat;
+
+/* This message contains just raw data stream.
+ * This message is sent by the guest to the host.
+ *
+ * States allowed: Streaming
+ */
+typedef struct StreamMsgData {
+    uint8_t data[0];
+} StreamMsgData;
+
+#endif /* SPICE_STREAM_DEVICE_H_ */


More information about the Spice-commits mailing list