Blob Blame History Raw
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Wed, 7 Jun 2017 13:13:21 +0100
Subject: [spice-server] stream-channel: Activate streaming report from client

Setting the capability is not enough, each stream must be enabled
so do so if client support them.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
---
 server/stream-channel.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/server/stream-channel.c b/server/stream-channel.c
index ec4bf021d..7e15dd363 100644
--- a/server/stream-channel.c
+++ b/server/stream-channel.c
@@ -27,6 +27,7 @@
 #include "reds.h"
 #include "common-graphics-channel.h"
 #include "display-limits.h"
+#include "stream.h" // TODO remove, put common stuff
 
 #define TYPE_STREAM_CHANNEL_CLIENT stream_channel_client_get_type()
 
@@ -95,6 +96,7 @@ enum {
     RED_PIPE_ITEM_TYPE_STREAM_CREATE,
     RED_PIPE_ITEM_TYPE_STREAM_DATA,
     RED_PIPE_ITEM_TYPE_STREAM_DESTROY,
+    RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT,
 };
 
 typedef struct StreamCreateItem {
@@ -230,6 +232,20 @@ stream_channel_send_item(RedChannelClient *rcc, RedPipeItem *pipe_item)
         spice_marshall_msg_display_stream_create(m, &item->stream_create);
         break;
     }
+    case RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT: {
+        if (client->stream_id < 0
+            || !red_channel_client_test_remote_cap(rcc, SPICE_DISPLAY_CAP_STREAM_REPORT)) {
+            return;
+        }
+        SpiceMsgDisplayStreamActivateReport msg;
+        msg.stream_id = client->stream_id;
+        msg.unique_id = 1; // TODO useful ?
+        msg.max_window_size = RED_STREAM_CLIENT_REPORT_WINDOW;
+        msg.timeout_ms = RED_STREAM_CLIENT_REPORT_TIMEOUT;
+        red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT);
+        spice_marshall_msg_display_stream_activate_report(m, &msg);
+        break;
+    }
     case RED_PIPE_ITEM_TYPE_STREAM_DATA: {
         StreamDataItem *item = SPICE_UPCAST(StreamDataItem, pipe_item);
         red_channel_client_init_send_data(rcc, SPICE_MSG_DISPLAY_STREAM_DATA);
@@ -459,6 +475,9 @@ stream_channel_change_format(StreamChannel *channel, const StreamMsgFormat *fmt)
     item->stream_create.dest = (SpiceRect) { 0, 0, fmt->width, fmt->height };
     item->stream_create.clip = (SpiceClip) { SPICE_CLIP_TYPE_NONE, NULL };
     red_channel_pipes_add(red_channel, &item->base);
+
+    // activate stream report if possible
+    red_channel_pipes_add_type(red_channel, RED_PIPE_ITEM_TYPE_STREAM_ACTIVATE_REPORT);
 }
 
 static inline void