[Spice-devel] [spice-gtk v6 6/9] spicy: improve status label with stream information

Victor Toso victortoso at redhat.com
Tue Jan 31 11:08:19 UTC 2017


From: Victor Toso <me at victortoso.com>

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>
---
 tools/spicy.c | 43 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)

diff --git a/tools/spicy.c b/tools/spicy.c
index 4712db6..5bb95f2 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,9 +181,18 @@ static int ask_user(GtkWidget *parent, char *title, char *message,
     return retval;
 }
 
-#define SPICY_STATUS_LABEL "mouse: %6s, agent: %3s"
+#define SPICY_STATUS_LABEL "mouse: %6s, agent: %3s, streaming: %5s"
 #define SPICY_UNGRAB_INFO "Use %s to ungrab mouse"
 
+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;
@@ -193,7 +203,8 @@ static void update_status_window(SpiceWindow *win)
     status = g_string_new(NULL);
     g_string_printf(status, SPICY_STATUS_LABEL,
                     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));
@@ -1391,6 +1402,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)
 {
@@ -1691,6 +1728,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);
     }
 
-- 
2.9.3



More information about the Spice-devel mailing list