Blame SOURCES/0009-stream-channel-Start-implementing-DisplayChannel-pro.patch

ad1357
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
ad1357
From: Frediano Ziglio <fziglio@redhat.com>
ad1357
Date: Tue, 14 Mar 2017 12:12:22 +0000
ad1357
Subject: [spice-server] stream-channel: Start implementing DisplayChannel
ad1357
 properly
ad1357
ad1357
Handle messages from clients.
ad1357
Send some messages to clients.
ad1357
ad1357
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
ad1357
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
ad1357
---
ad1357
 server/stream-channel.c | 41 ++++++++++++++++++++++++++++++++++++++++-
ad1357
 1 file changed, 40 insertions(+), 1 deletion(-)
ad1357
ad1357
diff --git a/server/stream-channel.c b/server/stream-channel.c
ad1357
index fd735f562..df6936513 100644
ad1357
--- a/server/stream-channel.c
ad1357
+++ b/server/stream-channel.c
ad1357
@@ -113,6 +113,25 @@ stream_channel_send_item(RedChannelClient *rcc, RedPipeItem *pipe_item)
ad1357
     red_channel_client_begin_send_message(rcc);
ad1357
 }
ad1357
 
ad1357
+static bool
ad1357
+handle_message(RedChannelClient *rcc, uint16_t type, uint32_t size, void *msg)
ad1357
+{
ad1357
+    switch (type) {
ad1357
+    case SPICE_MSGC_DISPLAY_INIT:
ad1357
+    case SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION:
ad1357
+        return true;
ad1357
+    case SPICE_MSGC_DISPLAY_STREAM_REPORT:
ad1357
+        /* TODO these will help tune the streaming reducing/increasing quality */
ad1357
+        return true;
ad1357
+    case SPICE_MSGC_DISPLAY_GL_DRAW_DONE:
ad1357
+        /* client should not send this message */
ad1357
+        return false;
ad1357
+    default:
ad1357
+        return red_channel_client_handle_message(rcc, type, size, msg);
ad1357
+    }
ad1357
+}
ad1357
+
ad1357
+
ad1357
 StreamChannel*
ad1357
 stream_channel_new(RedsState *server, uint32_t id)
ad1357
 {
ad1357
@@ -138,6 +157,22 @@ stream_channel_connect(RedChannel *red_channel, RedClient *red_client, RedsStrea
ad1357
 
ad1357
     client = stream_channel_client_new(channel, red_client, stream, migration, caps);
ad1357
     spice_return_if_fail(client != NULL);
ad1357
+
ad1357
+    // TODO set capabilities like  SPICE_DISPLAY_CAP_MONITORS_CONFIG
ad1357
+    // see guest_set_client_capabilities
ad1357
+    RedChannelClient *rcc = RED_CHANNEL_CLIENT(client);
ad1357
+    red_channel_client_push_set_ack(rcc);
ad1357
+
ad1357
+    // TODO what should happen on migration, dcc return if on migration wait ??
ad1357
+    red_channel_client_ack_zero_messages_window(rcc);
ad1357
+
ad1357
+    // "emulate" dcc_start
ad1357
+    // TODO only if "surface"
ad1357
+    red_channel_client_pipe_add_empty_msg(rcc, SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES);
ad1357
+    // TODO red_surface_create_item_new
ad1357
+    // TODO surface data ??
ad1357
+    // TODO monitor configs ??
ad1357
+    red_channel_client_pipe_add_empty_msg(rcc, SPICE_MSG_DISPLAY_MARK);
ad1357
 }
ad1357
 
ad1357
 static void
ad1357
@@ -152,6 +187,10 @@ stream_channel_constructed(GObject *object)
ad1357
     client_cbs.connect = stream_channel_connect;
ad1357
     red_channel_register_client_cbs(red_channel, &client_cbs, NULL);
ad1357
 
ad1357
+    // TODO, send monitor to support multiple monitors in the future
ad1357
+//    red_channel_set_cap(red_channel, SPICE_DISPLAY_CAP_MONITORS_CONFIG);
ad1357
+    red_channel_set_cap(red_channel, SPICE_DISPLAY_CAP_STREAM_REPORT);
ad1357
+
ad1357
     reds_register_channel(reds, red_channel);
ad1357
 }
ad1357
 
ad1357
@@ -164,7 +203,7 @@ stream_channel_class_init(StreamChannelClass *klass)
ad1357
     object_class->constructed = stream_channel_constructed;
ad1357
 
ad1357
     channel_class->parser = spice_get_client_channel_parser(SPICE_CHANNEL_DISPLAY, NULL);
ad1357
-    channel_class->handle_message = red_channel_client_handle_message;
ad1357
+    channel_class->handle_message = handle_message;
ad1357
 
ad1357
     channel_class->send_item = stream_channel_send_item;
ad1357
 }