[Spice-devel,spice-gtk,v1,6/7] channel-display: implement preferred video codec msgc

Submitted by Victor Toso on Oct. 24, 2016, 1:28 p.m.

Details

Message ID 20161024132903.28884-7-victortoso@redhat.com
State New
Headers show
Series "protocol: add preferred video codec message" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Victor Toso Oct. 24, 2016, 1:28 p.m.
From: Victor Toso <me@victortoso.com>

* SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE

This message was introduced in spice-protocol v0.12.13 in order to
request to server to encode new video streams with specific
video-codec.

Signed-off-by: Victor Toso <victortoso@redhat.com>
---
 configure.ac                         |  2 +-
 doc/reference/spice-gtk-sections.txt |  1 +
 src/channel-display.c                | 38 ++++++++++++++++++++++++++++++++++++
 src/channel-display.h                |  1 +
 src/map-file                         |  1 +
 src/spice-glib-sym-file              |  1 +
 6 files changed, 43 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/configure.ac b/configure.ac
index f3e7f8d..aa60e91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,7 +69,7 @@  AC_CHECK_LIBM
 AC_SUBST(LIBM)
 
 AC_CONFIG_SUBDIRS([spice-common])
-PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.12])
+PKG_CHECK_MODULES([SPICE_PROTOCOL], [spice-protocol >= 0.12.13])
 
 COMMON_CFLAGS='-I${top_builddir}/spice-common/ -I${top_srcdir}/spice-common/ ${SPICE_PROTOCOL_CFLAGS}'
 AC_SUBST(COMMON_CFLAGS)
diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt
index 386e737..4e090f6 100644
--- a/doc/reference/spice-gtk-sections.txt
+++ b/doc/reference/spice-gtk-sections.txt
@@ -168,6 +168,7 @@  spice_display_get_gl_scanout
 spice_display_gl_draw_done
 spice_display_get_primary
 spice_display_change_preferred_compression
+spice_display_change_preferred_video_codec_type
 spice_gl_scanout_free
 <SUBSECTION Standard>
 SPICE_DISPLAY_CHANNEL
diff --git a/src/channel-display.c b/src/channel-display.c
index 709b3d2..03ea670 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -525,6 +525,44 @@  void spice_display_change_preferred_compression(SpiceChannel *channel, gint comp
 }
 
 /**
+ * spice_display_change_preferred_video_codec:
+ * @channel: a #SpiceDisplayChannel
+ * @compression: a #SpiceVideoCodecType
+ *
+ * Tells the spice server to change the preferred video codec type for
+ * streaming in @channel. Application can set only one preferred video codec.
+ *
+ * Since: 0.34
+ */
+void spice_display_change_preferred_video_codec_type(SpiceChannel *channel, gint codec_type)
+{
+    SpiceMsgOut *out;
+    SpiceMsgcDisplayPreferredVideoCodecType *msg;
+
+    g_return_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel));
+    g_return_if_fail(codec_type >= SPICE_VIDEO_CODEC_TYPE_MJPEG);
+    g_return_if_fail(codec_type < SPICE_VIDEO_CODEC_TYPE_ENUM_END);
+
+    if (!spice_channel_test_capability(channel, SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE)) {
+        CHANNEL_DEBUG(channel, "does not have capability to change the preferred video codec type");
+        return;
+    }
+
+    CHANNEL_DEBUG(channel, "changing preferred video codec type to %d", codec_type);
+
+    msg = g_malloc0(sizeof(SpiceMsgcDisplayPreferredVideoCodecType) +
+                    sizeof(SpiceVideoCodecPreferredRank));
+    msg->num_of_codecs = 1;
+    msg->codec_ranks[0].type = codec_type;
+    msg->codec_ranks[0].rank = SPICE_VIDEO_CODEC_RANK_PREFERRED;
+
+    out = spice_msg_out_new(channel, SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE);
+    out->marshallers->msgc_display_preferred_video_codec_type(out->marshaller, msg);
+    spice_msg_out_send_internal(out);
+    g_free(msg);
+}
+
+/**
  * spice_display_get_gl_scanout:
  * @channel: a #SpiceDisplayChannel
  *
diff --git a/src/channel-display.h b/src/channel-display.h
index ad82a16..fccf228 100644
--- a/src/channel-display.h
+++ b/src/channel-display.h
@@ -149,6 +149,7 @@  gboolean        spice_display_get_primary(SpiceChannel *channel, guint32 surface
                                           SpiceDisplayPrimary *primary);
 
 void spice_display_change_preferred_compression(SpiceChannel *channel, gint compression);
+void spice_display_change_preferred_video_codec_type(SpiceChannel *channel, gint codec_type);
 
 GType           spice_gl_scanout_get_type     (void) G_GNUC_CONST;
 void            spice_gl_scanout_free         (SpiceGlScanout *scanout);
diff --git a/src/map-file b/src/map-file
index 3d92153..31cafc2 100644
--- a/src/map-file
+++ b/src/map-file
@@ -21,6 +21,7 @@  spice_channel_type_to_string;
 spice_client_error_quark;
 spice_cursor_channel_get_type;
 spice_display_change_preferred_compression;
+spice_display_change_preferred_video_codec_type;
 spice_display_channel_get_type;
 spice_display_get_gl_scanout;
 spice_display_get_grab_keys;
diff --git a/src/spice-glib-sym-file b/src/spice-glib-sym-file
index 473c5ca..d73f799 100644
--- a/src/spice-glib-sym-file
+++ b/src/spice-glib-sym-file
@@ -19,6 +19,7 @@  spice_channel_type_to_string
 spice_client_error_quark
 spice_cursor_channel_get_type
 spice_display_change_preferred_compression
+spice_display_change_preferred_video_codec_type
 spice_display_channel_get_type
 spice_display_get_gl_scanout
 spice_display_get_primary