[Spice-devel] [RFC PATCH 07/16] stream-channel: Start implementing DisplayChannel properly

Frediano Ziglio fziglio at redhat.com
Wed Jan 25 12:42:30 UTC 2017


Handle messages from clients.
Some some messages to clients.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/stream-channel.c | 48 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 44 insertions(+), 4 deletions(-)

diff --git a/server/stream-channel.c b/server/stream-channel.c
index 8905c7f..71f2581 100644
--- a/server/stream-channel.c
+++ b/server/stream-channel.c
@@ -21,6 +21,7 @@
 
 #include "red-channel-client.h"
 #include "stream-channel.h"
+#include "common-graphics-channel.h"
 #include "reds.h"
 
 #define TYPE_STREAM_CHANNEL_CLIENT stream_channel_client_get_type()
@@ -52,14 +53,14 @@ GType stream_channel_client_get_type(void) G_GNUC_CONST;
 G_DEFINE_TYPE(StreamChannelClient, stream_channel_client, RED_TYPE_CHANNEL_CLIENT)
 
 struct StreamChannel {
-    RedChannel parent;
+    CommonGraphicsChannel parent;
 };
 
 struct StreamChannelClass {
-    RedChannelClass parent_class;
+    CommonGraphicsChannelClass parent_class;
 };
 
-G_DEFINE_TYPE(StreamChannel, stream_channel, RED_TYPE_CHANNEL)
+G_DEFINE_TYPE(StreamChannel, stream_channel, TYPE_COMMON_GRAPHICS_CHANNEL)
 
 static void
 stream_channel_client_class_init(StreamChannelClientClass *klass)
@@ -126,6 +127,25 @@ stream_channel_send_item(RedChannelClient *rcc, RedPipeItem *pipe_item)
     red_channel_client_begin_send_message(rcc);
 }
 
+static int
+handle_message(RedChannelClient *rcc, uint32_t size, uint16_t type, void *msg)
+{
+    switch (type) {
+    case SPICE_MSGC_DISPLAY_INIT:
+    case SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION:
+        return TRUE;
+    case SPICE_MSGC_DISPLAY_STREAM_REPORT:
+        /* TODO these will help tuning the streaming reducing/increasing quality */
+        return TRUE;
+    case SPICE_MSGC_DISPLAY_GL_DRAW_DONE:
+        /* client should not send this message */
+        return FALSE;
+    default:
+        return red_channel_client_handle_message(rcc, size, type, msg);
+    }
+}
+
+
 StreamChannel*
 stream_channel_new(RedsState *server)
 {
@@ -156,6 +176,22 @@ stream_channel_connect(RedChannel *red_channel, RedClient *red_client, RedsStrea
                                        common_caps, num_common_caps,
                                        caps, num_caps);
     spice_return_if_fail(client != NULL);
+
+    // TODO set capabilities like  SPICE_DISPLAY_CAP_MONITORS_CONFIG
+    // see guest_set_client_capabilities
+    RedChannelClient *rcc = RED_CHANNEL_CLIENT(client);
+    red_channel_client_push_set_ack(rcc);
+
+    // TODO what should happen on migration, dcc return if on migration wait ??
+    red_channel_client_ack_zero_messages_window(rcc);
+
+    // "emulate" dcc_start
+    // TODO only if "surface"
+    red_channel_client_pipe_add_empty_msg(rcc, SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES);
+    // TODO red_surface_create_item_new
+    // TODO surface data ??
+    // TODO monitor configs ??
+    red_channel_client_pipe_add_empty_msg(rcc, SPICE_MSG_DISPLAY_MARK);
 }
 
 static void
@@ -170,6 +206,10 @@ stream_channel_constructed(GObject *object)
     client_cbs.connect = stream_channel_connect;
     red_channel_register_client_cbs(red_channel, &client_cbs, NULL);
 
+    // TODO, send monitor to support multiple monitors in the future
+//    red_channel_set_cap(red_channel, SPICE_DISPLAY_CAP_MONITORS_CONFIG);
+    red_channel_set_cap(red_channel, SPICE_DISPLAY_CAP_STREAM_REPORT);
+
     reds_register_channel(reds, red_channel);
 }
 
@@ -182,7 +222,7 @@ stream_channel_class_init(StreamChannelClass *klass)
     object_class->constructed = stream_channel_constructed;
 
     channel_class->parser = spice_get_client_channel_parser(SPICE_CHANNEL_DISPLAY, NULL);
-    channel_class->handle_parsed = red_channel_client_handle_message;
+    channel_class->handle_parsed = handle_message;
 
     channel_class->on_disconnect = stream_channel_client_on_disconnect;
     channel_class->send_item = stream_channel_send_item;
-- 
git-series 0.9.1


More information about the Spice-devel mailing list