summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2010-07-12 14:16:31 +0300
committerYonit Halperin <yhalperi@redhat.com>2010-07-12 14:16:31 +0300
commit4b9304d54ac0b9a30d9009b2e7c145d048865871 (patch)
tree8bc7f3d28415b3a34fb59543f30f4b43c2bbe2db /server
parentf881a896a4999ae2eafb2e8ac86a9f317a47973c (diff)
downloadspice-4b9304d54ac0b9a30d9009b2e7c145d048865871.tar.gz
spice-4b9304d54ac0b9a30d9009b2e7c145d048865871.tar.xz
spice-4b9304d54ac0b9a30d9009b2e7c145d048865871.zip
server: enabling/disabling jpeg and zlib-over-glz via spice command line args
Diffstat (limited to 'server')
-rw-r--r--server/red_dispatcher.c4
-rw-r--r--server/red_worker.c27
-rw-r--r--server/red_worker.h2
-rw-r--r--server/reds.c26
-rw-r--r--server/spice.h10
5 files changed, 66 insertions, 3 deletions
diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index 426a3811..2a3c297c 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 1dd10b27..ce2c65d9 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;
@@ -8796,6 +8798,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;
@@ -9866,10 +9869,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);
@@ -10152,7 +10171,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) {
@@ -10531,6 +10550,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 6f87471b..ae2eaeec 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 df82f19a..b2443712 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 3c2c32e2..2cb8a752 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)