[Spice-commits] 3 commits - spice-common src/channel-display.c src/spice-option.c src/spice-session.c
Christophe Fergau
teuf at kemper.freedesktop.org
Tue Jun 30 07:43:47 PDT 2015
spice-common | 2 -
src/channel-display.c | 11 +++++++++
src/spice-option.c | 37 +++++++++++++++++++++++++++++++
src/spice-session.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 107 insertions(+), 1 deletion(-)
New commits:
commit dca252cf622ffe38ede19bfe44bbc81c2a4ef289
Author: Javier Celaya <javier.celaya at flexvdi.com>
Date: Wed Jun 3 17:07:52 2015 +0200
Display: Send a preferred compression message on init.
If the user prefers a specific compression algorithm, report it when
setting up the display channel.
diff --git a/src/channel-display.c b/src/channel-display.c
index efe2259..5dd3f71 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -789,12 +789,15 @@ 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;
+ SpiceImageCompress preferred_compression = SPICE_IMAGE_COMPRESS_INVALID;
g_object_get(s,
"cache-size", &cache_size,
"glz-window-size", &glz_window_size,
+ "preferred-compression", &preferred_compression,
NULL);
CHANNEL_DEBUG(channel, "%s: cache_size %d, glz_window_size %d (bytes)", __FUNCTION__,
cache_size, glz_window_size);
@@ -810,6 +813,14 @@ static void spice_display_channel_up(SpiceChannel *channel)
this monitor */
if (channel->priv->channel_id != 0)
g_coroutine_object_notify(G_OBJECT(channel), "monitors");
+
+ if (spice_channel_test_capability(channel, SPICE_DISPLAY_CAP_PREF_COMPRESSION) &&
+ preferred_compression > SPICE_IMAGE_COMPRESS_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);
+ }
}
#define DRAW(type) { \
commit f3803e0ad12f05b8f3da941c19cda3e153da1ea1
Author: Javier Celaya <javier.celaya at flexvdi.com>
Date: Wed Jun 3 16:58:18 2015 +0200
Add a preferred-compression program option
diff --git a/src/spice-option.c b/src/spice-option.c
index 958e03c..463a3e3 100644
--- a/src/spice-option.c
+++ b/src/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);
}
commit 3910be9089e9af946d4bc79b7b8f25aff0c5d5c1
Author: Javier Celaya <javier.celaya at flexvdi.com>
Date: Mon Jun 1 16:48:46 2015 +0200
Spice-session: Add preferred-compression property.
Also, depend on the spice-common commit that introduces the
SpiceImageCompress enum.
diff --git a/spice-common b/spice-common
index 1b5edbe..dcebede 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 1b5edbe49e5c36c4f35453de448b54f770e1c1be
+Subproject commit dcebede0ca3d012786b9ab8fd95961c637b0b4a7
diff --git a/src/spice-session.c b/src/spice-session.c
index 778d82a..0edfa42 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -117,6 +117,7 @@ struct _SpiceSessionPrivate {
uint32_t n_display_channels;
guint8 uuid[16];
gchar *name;
+ SpiceImageCompress preferred_compression;
/* associated objects */
SpiceAudio *audio_manager;
@@ -203,6 +204,7 @@ enum {
PROP_SHARE_DIR_RO,
PROP_USERNAME,
PROP_UNIX_PATH,
+ PROP_PREF_COMPRESS,
};
/* signals */
@@ -213,6 +215,38 @@ enum {
SPICE_SESSION_LAST_SIGNAL,
};
+/* Register SpiceImageCompress */
+#define SPICE_TYPE_IMAGE_COMPRESS spice_image_compress_get_type()
+GType spice_image_compress_get_type (void);
+
+static const GEnumValue _spice_image_compress_values[] = {
+ { SPICE_IMAGE_COMPRESS_INVALID, "SPICE_IMAGE_COMPRESS_INVALID", "invalid" },
+ { SPICE_IMAGE_COMPRESS_OFF, "SPICE_IMAGE_COMPRESS_OFF", "off" },
+ { SPICE_IMAGE_COMPRESS_AUTO_GLZ, "SPICE_IMAGE_COMPRESS_AUTO_GLZ", "auto-glz" },
+ { SPICE_IMAGE_COMPRESS_AUTO_LZ, "SPICE_IMAGE_COMPRESS_AUTO_LZ", "auto-lz" },
+ { SPICE_IMAGE_COMPRESS_QUIC, "SPICE_IMAGE_COMPRESS_QUIC", "quic" },
+ { SPICE_IMAGE_COMPRESS_GLZ, "SPICE_IMAGE_COMPRESS_GLZ", "glz" },
+ { SPICE_IMAGE_COMPRESS_LZ, "SPICE_IMAGE_COMPRESS_LZ", "lz" },
+ { SPICE_IMAGE_COMPRESS_LZ4, "SPICE_IMAGE_COMPRESS_LZ4", "lz4" },
+ { 0, NULL, NULL }
+};
+
+G_STATIC_ASSERT(G_N_ELEMENTS(_spice_image_compress_values) == SPICE_IMAGE_COMPRESS_ENUM_END + 1);
+
+GType
+spice_image_compress_get_type (void)
+{
+ static GType type = 0;
+ static volatile gsize type_volatile = 0;
+
+ if (g_once_init_enter(&type_volatile)) {
+ type = g_enum_register_static ("SpiceImageCompress", _spice_image_compress_values);
+ g_once_init_leave(&type_volatile, type);
+ }
+
+ return type;
+}
+
static guint signals[SPICE_SESSION_LAST_SIGNAL];
static void spice_session_channel_destroy(SpiceSession *session, SpiceChannel *channel);
@@ -658,6 +692,9 @@ static void spice_session_get_property(GObject *gobject,
case PROP_SHARE_DIR_RO:
g_value_set_boolean(value, s->share_dir_ro);
break;
+ case PROP_PREF_COMPRESS:
+ g_value_set_enum(value, s->preferred_compression);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
break;
@@ -794,6 +831,9 @@ static void spice_session_set_property(GObject *gobject,
case PROP_SHARE_DIR_RO:
s->share_dir_ro = g_value_get_boolean(value);
break;
+ case PROP_PREF_COMPRESS:
+ s->preferred_compression = g_value_get_enum(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
break;
@@ -1403,6 +1443,24 @@ static void spice_session_class_init(SpiceSessionClass *klass)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
+ /**
+ * SpiceSession:preferred-compression:
+ *
+ * The image compression algorithm the client prefers to use. It is
+ * reported to the server.
+ *
+ * Since: 0.29
+ **/
+ g_object_class_install_property
+ (gobject_class, PROP_PREF_COMPRESS,
+ g_param_spec_enum("preferred-compression",
+ "Preferred image compression algorithm",
+ "Preferred image compression algorithm",
+ SPICE_TYPE_IMAGE_COMPRESS,
+ SPICE_IMAGE_COMPRESS_INVALID,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
g_type_class_add_private(klass, sizeof(SpiceSessionPrivate));
}
More information about the Spice-commits
mailing list