[Spice-commits] server/red_dispatcher.c server/reds.c server/red_worker.c server/red_worker.h server/spice.h

Yonit Halperin yhalperi at kemper.freedesktop.org
Wed Jul 14 02:32:35 PDT 2010


 server/red_dispatcher.c |    4 ++++
 server/red_worker.c     |   27 ++++++++++++++++++++++++---
 server/red_worker.h     |    2 ++
 server/reds.c           |   26 ++++++++++++++++++++++++++
 server/spice.h          |   10 ++++++++++
 5 files changed, 66 insertions(+), 3 deletions(-)

New commits:
commit c90183da944001e466f60acb58a5052c353995ca
Author: Yonit Halperin <yhalperi at redhat.com>
Date:   Mon Jul 12 14:16:31 2010 +0300

    server: enabling/disabling jpeg and zlib-over-glz via spice command line args

diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index 426a381..2a3c297 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -66,6 +66,8 @@ typedef struct RedWorkeState {
 
 extern uint32_t streaming_video;
 extern spice_image_compression_t image_compression;
+extern spice_wan_compression_t jpeg_state;
+extern spice_wan_compression_t zlib_glz_state;
 
 static RedDispatcher *dispatchers = NULL;
 
@@ -509,6 +511,8 @@ RedDispatcher *red_dispatcher_init(QXLInstance *qxl)
     memcpy(init_data.renderers, renderers, sizeof(init_data.renderers));
 
     init_data.image_compression = image_compression;
+    init_data.jpeg_state = jpeg_state;
+    init_data.zlib_glz_state = zlib_glz_state;
     init_data.streaming_video = streaming_video;
 
     dispatcher->base.major_version = SPICE_INTERFACE_QXL_MAJOR;
diff --git a/server/red_worker.c b/server/red_worker.c
index 4701ba0..bfb4560 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -919,6 +919,8 @@ typedef struct RedWorker {
     ImageCache image_cache;
 
     spice_image_compression_t image_compression;
+    spice_wan_compression_t jpeg_state;
+    spice_wan_compression_t zlib_glz_state;
 
     uint32_t mouse_mode;
 
@@ -8795,6 +8797,7 @@ static void cursor_channel_push(RedWorker *worker)
             free(pipe_item);
             break;
         case PIPE_ITEM_TYPE_CURSOR_INIT:
+            red_reset_cursor_cache(cursor_channel);
             red_send_cursor_init(cursor_channel);
             free(pipe_item);
             break;
@@ -9865,10 +9868,26 @@ static void handle_new_display_channel(RedWorker *worker, RedsStreamContext *pee
                      DISPLAY_FREE_LIST_DEFAULT_SIZE * sizeof(SpiceResourceID));
     display_channel->send_data.free_list.res_size = DISPLAY_FREE_LIST_DEFAULT_SIZE;
 
-    display_channel->enable_jpeg = IS_LOW_BANDWIDTH();
+    if (worker->jpeg_state == SPICE_WAN_COMPRESSION_AUTO) {
+        display_channel->enable_jpeg = IS_LOW_BANDWIDTH();
+    } else {
+        display_channel->enable_jpeg = (worker->jpeg_state == SPICE_WAN_COMPRESSION_ALWAYS);
+    }
+
+    // todo: tune quality according to bandwidth
     display_channel->jpeg_quality = 85;
 
-    display_channel->enable_zlib_glz_wrap = IS_LOW_BANDWIDTH();
+    if (worker->zlib_glz_state == SPICE_WAN_COMPRESSION_AUTO) {
+        display_channel->enable_zlib_glz_wrap = IS_LOW_BANDWIDTH();
+    } else {
+        display_channel->enable_zlib_glz_wrap = (worker->zlib_glz_state == 
+                                                 SPICE_WAN_COMPRESSION_ALWAYS);
+    }
+
+    red_printf("jpeg %s", display_channel->enable_jpeg ? "enabled" : "disabled");
+    red_printf("zlib-over-glz %s", display_channel->enable_zlib_glz_wrap ? "enabled" : "disabled");
+
+    // todo: tune level according to bandwidth
     display_channel->zlib_level = ZLIB_DEFAULT_COMPRESSION_LEVEL;
 
     red_ref_channel((RedChannel*)display_channel);
@@ -10151,7 +10170,7 @@ static inline void handle_dev_destroy_surfaces(RedWorker *worker)
 {
     int i;
     RedWorkerMessage message;
-
+    red_printf("");
     flush_all_qxl_commands(worker);
     //to handle better
     if (worker->surfaces[0].context.canvas) {
@@ -10530,6 +10549,8 @@ static void red_init(RedWorker *worker, WorkerInitData *init_data)
     worker->renderer = RED_RENDERER_INVALID;
     worker->mouse_mode = SPICE_MOUSE_MODE_SERVER;
     worker->image_compression = init_data->image_compression;
+    worker->jpeg_state = init_data->jpeg_state;
+    worker->zlib_glz_state = init_data->zlib_glz_state;
     worker->streaming_video = init_data->streaming_video;
     ring_init(&worker->current_list);
     image_cache_init(&worker->image_cache);
diff --git a/server/red_worker.h b/server/red_worker.h
index 6f87471..ae2eaee 100644
--- a/server/red_worker.h
+++ b/server/red_worker.h
@@ -89,6 +89,8 @@ typedef struct WorkerInitData {
     uint32_t num_renderers;
     uint32_t renderers[RED_MAX_RENDERERS];
     spice_image_compression_t image_compression;
+    spice_wan_compression_t jpeg_state;
+    spice_wan_compression_t zlib_glz_state;
     int streaming_video;
     uint32_t num_memslots;
     uint32_t num_memslots_groups;
diff --git a/server/reds.c b/server/reds.c
index df82f19..b244371 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -92,6 +92,8 @@ static pthread_mutex_t *lock_cs;
 static long *lock_count;
 uint32_t streaming_video = STREAM_VIDEO_FILTER;
 spice_image_compression_t image_compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
+spice_wan_compression_t jpeg_state = SPICE_WAN_COMPRESSION_AUTO;
+spice_wan_compression_t zlib_glz_state = SPICE_WAN_COMPRESSION_AUTO;
 #ifdef USE_TUNNEL
 void *red_tunnel = NULL;
 #endif
@@ -3787,6 +3789,30 @@ __visible__ spice_image_compression_t spice_server_get_image_compression(SpiceSe
     return image_compression;
 }
 
+__visible__ int spice_server_set_jpeg_compression(SpiceServer *s, spice_wan_compression_t comp)
+{
+    ASSERT(reds == s);
+    if (comp == SPICE_WAN_COMPRESSION_INVALID) {
+        red_printf("invalid jpeg state");
+        return -1;
+    }
+    // todo: support dynamically changing the state
+    jpeg_state = comp;
+    return 0;
+}
+
+__visible__ int spice_server_set_zlib_glz_compression(SpiceServer *s, spice_wan_compression_t comp)
+{
+    ASSERT(reds == s);
+    if (comp == SPICE_WAN_COMPRESSION_INVALID) {
+        red_printf("invalid zlib_glz state");
+        return -1;
+    }
+    // todo: support dynamically changing the state
+    zlib_glz_state = comp;
+    return 0;
+}
+
 __visible__ int spice_server_set_channel_security(SpiceServer *s, const char *channel, int security)
 {
     static const char *names[] = {
diff --git a/server/spice.h b/server/spice.h
index 3c2c32e..2cb8a75 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -341,6 +341,16 @@ int spice_server_set_image_compression(SpiceServer *s,
                                        spice_image_compression_t comp);
 spice_image_compression_t spice_server_get_image_compression(SpiceServer *s);
 
+typedef enum {
+    SPICE_WAN_COMPRESSION_INVALID,
+    SPICE_WAN_COMPRESSION_AUTO,
+    SPICE_WAN_COMPRESSION_ALWAYS,
+    SPICE_WAN_COMPRESSION_NEVER,
+} spice_wan_compression_t;
+
+int spice_server_set_jpeg_compression(SpiceServer *s, spice_wan_compression_t comp);
+int spice_server_set_zlib_glz_compression(SpiceServer *s, spice_wan_compression_t comp);
+
 #define SPICE_CHANNEL_SECURITY_NONE (1 << 0)
 #define SPICE_CHANNEL_SECURITY_SSL (1 << 1)
 


More information about the Spice-commits mailing list