[Spice-commits] 3 commits - src/channel-display.c tools/spicy.c

Victor Toso de Carvalho victortoso at kemper.freedesktop.org
Mon Mar 13 10:34:08 UTC 2017


 src/channel-display.c |   29 ++++++++++++++++++++++++++
 tools/spicy.c         |   55 +++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 77 insertions(+), 7 deletions(-)

New commits:
commit 9a7ae78aa94f4eada3fa85e9fd7dfac681aadd6d
Author: Victor Toso <me at victortoso.com>
Date:   Mon Jan 30 11:39:34 2017 +0100

    spicy: improve status label with stream information
    
    By using stream-video-codec-type property, we can display which
    video-codec is being used.
    
    Signed-off-by: Victor Toso <victortoso at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/tools/spicy.c b/tools/spicy.c
index eeb640d..a41a1a3 100644
--- a/tools/spicy.c
+++ b/tools/spicy.c
@@ -71,6 +71,7 @@ struct _SpiceWindow {
     bool             fullscreen;
     bool             mouse_grabbed;
     SpiceChannel     *display_channel;
+    gint             video_codec;
 #ifdef G_OS_WIN32
     gint             win_x;
     gint             win_y;
@@ -180,6 +181,15 @@ static int ask_user(GtkWidget *parent, char *title, char *message,
     return retval;
 }
 
+static const gchar *video_codec_enum_to_str[] = {
+    [0] = "none",
+    [SPICE_VIDEO_CODEC_TYPE_MJPEG] = "mjpeg",
+    [SPICE_VIDEO_CODEC_TYPE_VP8] = "vp8",
+    [SPICE_VIDEO_CODEC_TYPE_H264] = "h264",
+    [SPICE_VIDEO_CODEC_TYPE_VP9] = "vp9",
+    [SPICE_VIDEO_CODEC_TYPE_ENUM_END] = "error",
+};
+
 static void update_status_window(SpiceWindow *win)
 {
     GString *status;
@@ -188,9 +198,10 @@ static void update_status_window(SpiceWindow *win)
         return;
 
     status = g_string_new(NULL);
-    g_string_printf(status, "mouse: %6s, agent: %3s",
+    g_string_printf(status, "mouse: %6s, agent: %3s, streaming: %5s",
                     win->conn->mouse_state,
-                    win->conn->agent_state);
+                    win->conn->agent_state,
+                    video_codec_enum_to_str[win->video_codec]);
 
     if (win->mouse_grabbed) {
         SpiceGrabSequence *sequence = spice_display_get_grab_keys(SPICE_DISPLAY(win->spice));
@@ -1442,6 +1453,32 @@ static void del_window(spice_connection *conn, SpiceWindow *win)
     destroy_spice_window(win);
 }
 
+static void display_stream_changes(SpiceChannel *display, GParamSpec *pspec,
+                                   spice_connection *conn)
+{
+    gint i;
+    gint id, codec_type;
+    GArray *monitors;
+
+    g_object_get(display,
+                 "channel-id", &id,
+                 "monitors", &monitors,
+                 "stream-video-codec-type", &codec_type,
+                 NULL);
+
+    for (i = 0; i < monitors->len; i++) {
+        SpiceWindow *win = get_window(conn, id, i);
+
+        if (win == NULL)
+            continue;
+
+        win->video_codec = codec_type;
+        update_status_window(win);
+    }
+
+    g_clear_pointer(&monitors, g_array_unref);
+}
+
 static void display_monitors(SpiceChannel *display, GParamSpec *pspec,
                              spice_connection *conn)
 {
@@ -1752,6 +1789,8 @@ static void channel_new(SpiceSession *s, SpiceChannel *channel, gpointer data)
         SPICE_DEBUG("new display channel (#%d)", id);
         g_signal_connect(channel, "notify::monitors",
                          G_CALLBACK(display_monitors), conn);
+        g_signal_connect(channel, "notify::stream-video-codec-type",
+                         G_CALLBACK(display_stream_changes), conn);
         spice_channel_connect(channel);
     }
 
commit d4fb0faf1bec02386ab7732013cd836359ed62b1
Author: Victor Toso <me at victortoso.com>
Date:   Mon Jan 30 11:50:56 2017 +0100

    spicy: keep status of mouse/agent on server mode
    
    So we can still check the agent status even in server mode.
    
    Signed-off-by: Victor Toso <victortoso at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/tools/spicy.c b/tools/spicy.c
index 2772cfa..eeb640d 100644
--- a/tools/spicy.c
+++ b/tools/spicy.c
@@ -182,23 +182,25 @@ static int ask_user(GtkWidget *parent, char *title, char *message,
 
 static void update_status_window(SpiceWindow *win)
 {
-    gchar *status;
+    GString *status;
 
     if (win == NULL)
         return;
 
+    status = g_string_new(NULL);
+    g_string_printf(status, "mouse: %6s, agent: %3s",
+                    win->conn->mouse_state,
+                    win->conn->agent_state);
+
     if (win->mouse_grabbed) {
         SpiceGrabSequence *sequence = spice_display_get_grab_keys(SPICE_DISPLAY(win->spice));
         gchar *seq = spice_grab_sequence_as_string(sequence);
-        status = g_strdup_printf("Use %s to ungrab mouse.", seq);
+        g_string_append_printf(status, "\tUse %s to ungrab mouse", seq);
         g_free(seq);
-    } else {
-        status = g_strdup_printf("mouse: %s, agent: %s",
-                 win->conn->mouse_state, win->conn->agent_state);
     }
 
-    gtk_label_set_text(GTK_LABEL(win->status), status);
-    g_free(status);
+    gtk_label_set_text(GTK_LABEL(win->status), status->str);
+    g_string_free(status, TRUE);
 }
 
 static void update_status(struct spice_connection *conn)
commit 00f56647a97a95342f235ef6d107ac8216aa9e49
Author: Victor Toso <me at victortoso.com>
Date:   Mon Jan 30 08:37:30 2017 +0100

    channel-display: new stream-video-codec-type property
    
    This is a per channel-display property that stores and notifies the
    video-codec type being used if a stream is being used or 0 if there is
    no ongoing stream.
    
    Signed-off-by: Victor Toso <victortoso at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/src/channel-display.c b/src/channel-display.c
index 7a5a23b..f30c7ed 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -70,6 +70,7 @@ struct _SpiceDisplayChannelPrivate {
     GArray                      *monitors;
     guint                       monitors_max;
     gboolean                    enable_adaptive_streaming;
+    SpiceVideoCodecType         stream_video_codec_type;
 #ifdef G_OS_WIN32
     HDC dc;
 #endif
@@ -86,6 +87,7 @@ enum {
     PROP_MONITORS,
     PROP_MONITORS_MAX,
     PROP_GL_SCANOUT,
+    PROP_STREAM_VIDEO_CODEC_TYPE,
 };
 
 enum {
@@ -222,6 +224,10 @@ static void spice_display_get_property(GObject    *object,
         g_value_set_static_boxed(value, spice_display_get_gl_scanout(channel));
         break;
     }
+    case PROP_STREAM_VIDEO_CODEC_TYPE: {
+        g_value_set_int(value, c->stream_video_codec_type);
+        break;
+    }
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
         break;
@@ -335,6 +341,23 @@ static void spice_display_channel_class_init(SpiceDisplayChannelClass *klass)
                             G_PARAM_STATIC_STRINGS));
 
     /**
+     * SpiceDisplayChannel:stream-video-codec-type
+     *
+     * The SpiceVideoCodecType enum value for the video-codec being used in the
+     * current stream or 0 when there is no ongoing streaming.
+     *
+     * Since: 0.34
+     */
+    g_object_class_install_property
+        (gobject_class, PROP_STREAM_VIDEO_CODEC_TYPE,
+         g_param_spec_int("stream-video-codec-type",
+                          "Stream Video Codec Type",
+                          "The Video Codec Type from current Stream",
+                          0, SPICE_VIDEO_CODEC_TYPE_ENUM_END, 0,
+                          G_PARAM_READABLE |
+                          G_PARAM_STATIC_STRINGS));
+
+    /**
      * SpiceDisplayChannel::display-primary-create:
      * @display: the #SpiceDisplayChannel that emitted the signal
      * @format: %SPICE_SURFACE_FMT_32_xRGB or %SPICE_SURFACE_FMT_16_555;
@@ -1218,6 +1241,10 @@ static void display_handle_stream_create(SpiceChannel *channel, SpiceMsgIn *in)
         spice_printerr("could not create a video decoder for codec %u", op->codec_type);
         destroy_stream(channel, op->id);
         report_invalid_stream(channel, op->id);
+    } else {
+        spice_debug("New stream created of type: %u", op->codec_type);
+        c->stream_video_codec_type = op->codec_type;
+        g_coroutine_object_notify(G_OBJECT(channel), "stream-video-codec-type");
     }
 }
 
@@ -1567,6 +1594,8 @@ static void destroy_stream(SpiceChannel *channel, int id)
 
     g_free(st);
     c->streams[id] = NULL;
+    c->stream_video_codec_type = 0;
+    g_coroutine_object_notify(G_OBJECT(channel), "stream-video-codec-type");
 }
 
 static void clear_streams(SpiceChannel *channel)


More information about the Spice-commits mailing list