[Spice-devel] [RFC PATCH 07/15] stream-channel: Implements initialization

Frediano Ziglio fziglio at redhat.com
Wed Apr 19 15:31:06 UTC 2017


Send proper messages to client to see the display.
Currently a blank display will be showed to the clients
connecting.

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

diff --git a/server/stream-channel.c b/server/stream-channel.c
index e2a6e56..7f4dad7 100644
--- a/server/stream-channel.c
+++ b/server/stream-channel.c
@@ -19,6 +19,8 @@
 #include <config.h>
 #endif
 
+#include <common/generated_server_marshallers.h>
+
 #include "red-channel-client.h"
 #include "stream-channel.h"
 #include "reds.h"
@@ -64,6 +66,11 @@ struct StreamChannelClass {
 
 G_DEFINE_TYPE(StreamChannel, stream_channel, RED_TYPE_CHANNEL)
 
+enum {
+    RED_PIPE_ITEM_TYPE_SURFACE_CREATE = RED_PIPE_ITEM_TYPE_COMMON_LAST,
+    RED_PIPE_ITEM_TYPE_FILL_SURFACE,
+};
+
 static void
 stream_channel_client_class_init(StreamChannelClientClass *klass)
 {
@@ -98,9 +105,42 @@ stream_channel_client_new(StreamChannel *channel, RedClient *client, RedsStream
 }
 
 static void
+fill_base(SpiceMarshaller *m)
+{
+    SpiceMsgDisplayBase base;
+
+    base.surface_id = 0;
+    base.box = (SpiceRect) { 0, 0, 1024, 768 };
+    base.clip = (SpiceClip) { SPICE_CLIP_TYPE_NONE, NULL };
+
+    spice_marshall_DisplayBase(m, &base);
+}
+
+static void
 stream_channel_send_item(RedChannelClient *rcc, RedPipeItem *pipe_item)
 {
+    SpiceMarshaller *m = red_channel_client_get_marshaller(rcc);
+
     switch (pipe_item->type) {
+    case RED_PIPE_ITEM_TYPE_SURFACE_CREATE: {
+        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_SURFACE_CREATE);
+        SpiceMsgSurfaceCreate surface_create = { 0, 1024, 768, SPICE_SURFACE_FMT_32_xRGB, SPICE_SURFACE_FLAGS_PRIMARY };
+        spice_marshall_msg_display_surface_create(m, &surface_create);
+        break;
+    }
+    case RED_PIPE_ITEM_TYPE_FILL_SURFACE: {
+        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_DRAW_FILL);
+
+        fill_base(m);
+
+        SpiceFill fill;
+        fill.brush = (SpiceBrush) { SPICE_BRUSH_TYPE_SOLID, { .color = 0 } };
+        fill.rop_descriptor = SPICE_ROPD_OP_PUT;
+        fill.mask = (SpiceQMask) { 0, { 0, 0 }, NULL };
+        SpiceMarshaller *brush_pat_out, *mask_bitmap_out;
+        spice_marshall_Fill(m, &fill, &brush_pat_out, &mask_bitmap_out);
+        break;
+    }
     default:
         spice_error("invalid pipe item type");
     }
@@ -164,8 +204,10 @@ stream_channel_connect(RedChannel *red_channel, RedClient *red_client, RedsStrea
     // "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 pass proper data
+    red_channel_client_pipe_add_type(rcc, RED_PIPE_ITEM_TYPE_SURFACE_CREATE);
+    // surface data
+    red_channel_client_pipe_add_type(rcc, RED_PIPE_ITEM_TYPE_FILL_SURFACE);
     // TODO monitor configs ??
     red_channel_client_pipe_add_empty_msg(rcc, SPICE_MSG_DISPLAY_MARK);
 }
-- 
2.9.3



More information about the Spice-devel mailing list