[Spice-devel] [PATCH spice-gtk 1/2] channel-display: Add spice_display_change_preferred_compression

Pavel Grunt pgrunt at redhat.com
Tue Nov 10 08:44:06 PST 2015


---
 doc/reference/spice-gtk-sections.txt |  1 +
 src/channel-display.c                | 41 ++++++++++++++++++++++++++++++------
 src/channel-display.h                |  1 +
 src/map-file                         |  1 +
 src/spice-glib-sym-file              |  1 +
 5 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index d8c4c79..f156a3f 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -159,6 +159,7 @@ SpiceDisplayChannel
 SpiceDisplayChannelClass
 <SUBSECTION>
 spice_display_get_primary
+spice_display_change_preferred_compression
 <SUBSECTION Standard>
 SPICE_DISPLAY_CHANNEL
 SPICE_IS_DISPLAY_CHANNEL
diff --git a/src/channel-display.c b/src/channel-display.c
index 9e42dd9..dc73235 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -427,6 +427,38 @@ gboolean spice_display_get_primary(SpiceChannel *channel, guint32 surface_id,
     return TRUE;
 }
 
+/**
+ * spice_display_change_preferred_compression:
+ * @channel: a #SpiceDisplayChannel
+ * @compression: a #SpiceImageCompression
+ *
+ * Tells the spice server to change the preferred image compression
+ * for the @channel.
+ *
+ * Since: 0.31
+ */
+void spice_display_change_preferred_compression(SpiceChannel *channel, gint compression)
+{
+    SpiceMsgOut *out;
+    SpiceMsgcDisplayPreferredCompression pref_comp_msg;
+
+    g_return_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel));
+    g_return_if_fail(compression > SPICE_IMAGE_COMPRESSION_INVALID &&
+                     compression < SPICE_IMAGE_COMPRESSION_ENUM_END);
+
+    if (!spice_channel_test_capability(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION)) {
+        CHANNEL_DEBUG(channel, "does not have capability to change the preferred compression");
+        return;
+    }
+
+    CHANNEL_DEBUG(channel, "changing preferred compression to %d", compression);
+
+    pref_comp_msg.image_compression = compression;
+    out = spice_msg_out_new(channel, SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION);
+    out->marshallers->msgc_display_preferred_compression(out->marshaller, &pref_comp_msg);
+    spice_msg_out_send_internal(out);
+}
+
 /* ------------------------------------------------------------------ */
 
 static void image_put(SpiceImageCache *cache, uint64_t id, pixman_image_t *image)
@@ -789,7 +821,6 @@ static void spice_display_channel_up(SpiceChannel *channel)
     SpiceMsgOut *out;
     SpiceSession *s = spice_channel_get_session(channel);
     SpiceMsgcDisplayInit init;
-    SpiceMsgcDisplayPreferredCompression pref_comp_msg;
     int cache_size;
     int glz_window_size;
     SpiceImageCompression preferred_compression = SPICE_IMAGE_COMPRESSION_INVALID;
@@ -812,12 +843,8 @@ static void spice_display_channel_up(SpiceChannel *channel)
     /* notify of existence of this monitor */
     g_coroutine_object_notify(G_OBJECT(channel), "monitors");
 
-    if (spice_channel_test_capability(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION) &&
-            preferred_compression > SPICE_IMAGE_COMPRESSION_INVALID) {
-        pref_comp_msg.image_compression = preferred_compression;
-        out = spice_msg_out_new(channel, SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION);
-        out->marshallers->msgc_display_preferred_compression(out->marshaller, &pref_comp_msg);
-        spice_msg_out_send_internal(out);
+    if (preferred_compression != SPICE_IMAGE_COMPRESSION_INVALID) {
+        spice_display_change_preferred_compression(channel, preferred_compression);
     }
 }
 
diff --git a/src/channel-display.h b/src/channel-display.h
index 8e68b60..52d76f7 100644
--- a/src/channel-display.h
+++ b/src/channel-display.h
@@ -100,6 +100,7 @@ struct _SpiceDisplayChannelClass {
 GType	        spice_display_channel_get_type(void);
 gboolean        spice_display_get_primary(SpiceChannel *channel, guint32 surface_id,
                                           SpiceDisplayPrimary *primary);
+void spice_display_change_preferred_compression(SpiceChannel *channel, gint compression);
 
 G_END_DECLS
 
diff --git a/src/map-file b/src/map-file
index 786bbbf..62cdb51 100644
--- a/src/map-file
+++ b/src/map-file
@@ -20,6 +20,7 @@ spice_channel_test_common_capability;
 spice_channel_type_to_string;
 spice_client_error_quark;
 spice_cursor_channel_get_type;
+spice_display_change_preferred_compression;
 spice_display_channel_get_type;
 spice_display_copy_to_guest;
 spice_display_get_grab_keys;
diff --git a/src/spice-glib-sym-file b/src/spice-glib-sym-file
index 7d20a07..ae365cd 100644
--- a/src/spice-glib-sym-file
+++ b/src/spice-glib-sym-file
@@ -18,6 +18,7 @@ spice_channel_test_common_capability
 spice_channel_type_to_string
 spice_client_error_quark
 spice_cursor_channel_get_type
+spice_display_change_preferred_compression
 spice_display_channel_get_type
 spice_display_get_primary
 spice_file_transfer_task_cancel
-- 
2.5.0



More information about the Spice-devel mailing list