[PATCH spice-gtk v4 2/3] Add a preferred-compression program option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 gtk/spice-option.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/gtk/spice-option.c b/gtk/spice-option.c
index 958e03c..463a3e3 100644
--- a/gtk/spice-option.c
+++ b/gtk/spice-option.c
@@ -41,6 +41,7 @@ static gint cache_size = 0;
 static gint glz_window_size = 0;
 static gchar *secure_channels = NULL;
 static gchar *shared_dir = NULL;
+static SpiceImageCompress preferred_compression = SPICE_IMAGE_COMPRESS_INVALID;
 
 G_GNUC_NORETURN
 static void option_version(void)
@@ -149,6 +150,33 @@ static gboolean parse_usbredir_filter(const gchar *option_name,
     return TRUE;
 }
 
+static gboolean parse_preferred_compression(const gchar *option_name, const gchar *value,
+                                            gpointer data, GError **error)
+{
+    if (!strcmp(value, "auto-glz")) {
+        preferred_compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
+    } else if (!strcmp(value, "auto-lz")) {
+        preferred_compression = SPICE_IMAGE_COMPRESS_AUTO_LZ;
+    } else if (!strcmp(value, "quic")) {
+        preferred_compression = SPICE_IMAGE_COMPRESS_QUIC;
+    } else if (!strcmp(value, "glz")) {
+        preferred_compression = SPICE_IMAGE_COMPRESS_GLZ;
+    } else if (!strcmp(value, "lz")) {
+        preferred_compression = SPICE_IMAGE_COMPRESS_LZ;
+#ifdef USE_LZ4
+    } else if (!strcmp(value, "lz4")) {
+        preferred_compression = SPICE_IMAGE_COMPRESS_LZ4;
+#endif
+    } else if (!strcmp(value, "off")) {
+        preferred_compression = SPICE_IMAGE_COMPRESS_OFF;
+    } else {
+        preferred_compression = SPICE_IMAGE_COMPRESS_INVALID;
+        g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
+                    _("Image compression algorithm %s not supported"), value);
+        return FALSE;
+    }
+    return TRUE;
+}
 
 /**
  * spice_get_option_group: (skip)
@@ -194,6 +222,13 @@ GOptionGroup* spice_get_option_group(void)
           N_("Glz compression history size"), N_("<bytes>") },
         { "spice-shared-dir", '\0', 0, G_OPTION_ARG_FILENAME, &shared_dir,
           N_("Shared directory"), N_("<dir>") },
+        { "spice-preferred-compression", '\0', 0, G_OPTION_ARG_CALLBACK, parse_preferred_compression,
+          N_("Preferred image compression algorithm"),
+#ifdef USE_LZ4
+          "<auto-glz,auto-lz,quic,glz,lz,lz4,off>" },
+#else
+          "<auto-glz,auto-lz,quic,glz,lz,off>" },
+#endif
 
         { "spice-debug", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, option_debug,
           N_("Enable Spice-GTK debugging"), NULL },
@@ -281,4 +316,6 @@ void spice_set_session_option(SpiceSession *session)
         g_object_set(session, "glz-window-size", glz_window_size, NULL);
     if (shared_dir)
         g_object_set(session, "shared-dir", shared_dir, NULL);
+    if (preferred_compression != SPICE_IMAGE_COMPRESS_INVALID)
+        g_object_set(session, "preferred-compression", preferred_compression, NULL);
 }
-- 
1.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]