<div dir="ltr">ping<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 4, 2019 at 12:29 PM Kevin Pouget <<a href="mailto:kpouget@redhat.com">kpouget@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">spice_display_channel_change_preferred_video_codec_types: new function<br>
for sending an array of video codecs instead of only one.<br>
<br>
Signed-off-by: Kevin Pouget <<a href="mailto:kpouget@redhat.com" target="_blank">kpouget@redhat.com</a>><br>
---<br>
doc/reference/spice-gtk-sections.txt | 1 +<br>
src/channel-display.c | 76 +++++++++++++++++++++++-----<br>
src/channel-display.h | 2 +<br>
src/map-file | 1 +<br>
src/spice-glib-sym-file | 1 +<br>
5 files changed, 68 insertions(+), 13 deletions(-)<br>
<br>
diff --git a/doc/reference/spice-gtk-sections.txt b/doc/reference/spice-gtk-sections.txt<br>
index a0336aa..33f4038 100644<br>
--- a/doc/reference/spice-gtk-sections.txt<br>
+++ b/doc/reference/spice-gtk-sections.txt<br>
@@ -185,6 +185,7 @@ spice_display_change_preferred_compression<br>
spice_display_channel_change_preferred_compression<br>
spice_display_change_preferred_video_codec_type<br>
spice_display_channel_change_preferred_video_codec_type<br>
+spice_display_channel_change_preferred_video_codec_types<br>
spice_gl_scanout_free<br>
<SUBSECTION Standard><br>
SPICE_DISPLAY_CHANNEL<br>
diff --git a/src/channel-display.c b/src/channel-display.c<br>
index 9a83c53..4558a56 100644<br>
--- a/src/channel-display.c<br>
+++ b/src/channel-display.c<br>
@@ -20,6 +20,7 @@<br>
#ifdef HAVE_SYS_TYPES_H<br>
#include <sys/types.h><br>
#endif<br>
+#include <glib/gi18n-lib.h><br>
<br>
#include "spice-client.h"<br>
#include "spice-common.h"<br>
@@ -610,18 +611,15 @@ void spice_display_channel_change_preferred_compression(SpiceChannel *channel, g<br>
}<br>
<br>
static void spice_display_send_client_preferred_video_codecs(SpiceChannel *channel,<br>
- const GArray *codecs)<br>
+ const gint *codecs, gsize ncodecs)<br>
{<br>
- guint i;<br>
SpiceMsgOut *out;<br>
SpiceMsgcDisplayPreferredVideoCodecType *msg;<br>
<br>
msg = g_malloc0(sizeof(SpiceMsgcDisplayPreferredVideoCodecType) +<br>
- (sizeof(SpiceVideoCodecType) * codecs->len));<br>
- msg->num_of_codecs = codecs->len;<br>
- for (i = 0; i < codecs->len; i++) {<br>
- msg->codecs[i] = g_array_index(codecs, gint, i);<br>
- }<br>
+ (sizeof(SpiceVideoCodecType) * ncodecs));<br>
+ msg->num_of_codecs = ncodecs;<br>
+ memcpy(msg->codecs, codecs, sizeof(*codecs) * ncodecs);<br>
<br>
out = spice_msg_out_new(channel, SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE);<br>
out->marshallers->msgc_display_preferred_video_codec_type(out->marshaller, msg);<br>
@@ -659,8 +657,6 @@ void spice_display_change_preferred_video_codec_type(SpiceChannel *channel, gint<br>
*/<br>
void spice_display_channel_change_preferred_video_codec_type(SpiceChannel *channel, gint codec_type)<br>
{<br>
- GArray *codecs;<br>
-<br>
g_return_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel));<br>
g_return_if_fail(codec_type >= SPICE_VIDEO_CODEC_TYPE_MJPEG &&<br>
codec_type < SPICE_VIDEO_CODEC_TYPE_ENUM_END);<br>
@@ -675,10 +671,64 @@ void spice_display_channel_change_preferred_video_codec_type(SpiceChannel *chann<br>
* This array can be rearranged to have @codec_type in the front (which is<br>
* the preferred for the client side) */<br>
CHANNEL_DEBUG(channel, "changing preferred video codec type to %s", gst_opts[codec_type].name);<br>
- codecs = g_array_new(FALSE, FALSE, sizeof(gint));<br>
- g_array_append_val(codecs, codec_type);<br>
- spice_display_send_client_preferred_video_codecs(channel, codecs);<br>
- g_array_unref(codecs);<br>
+ spice_display_send_client_preferred_video_codecs(channel, &codec_type, 1);<br>
+}<br>
+<br>
+/**<br>
+ * spice_display_channel_change_preferred_video_codecs_types:<br>
+ * @channel: a #SpiceDisplayChannel<br>
+ * @codecs: an array of @ncodecs #SpiceVideoCodecType types<br>
+ * @ncodecs: the number of codec types in the @codecs array<br>
+ * @err: #GError describing the reason why the change failed<br>
+ *<br>
+ * Tells the spice server the ordered preferred video codec types to<br>
+ * use for streaming in @channel.<br>
+ *<br>
+ * Returns: %TRUE if the preferred codec list was successfully changed, and %FALSE<br>
+ * otherwise.<br>
+ *<br>
+ * Since: 0.38<br>
+ */<br>
+gboolean spice_display_channel_change_preferred_video_codec_types(SpiceChannel *channel,<br>
+ const gint *codecs, gsize ncodecs,<br>
+ GError **err)<br>
+{<br>
+ gsize i;<br>
+ GString *msg;<br>
+<br>
+ g_return_val_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel), FALSE);<br>
+<br>
+ if (!spice_channel_test_capability(channel, SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE)) {<br>
+ CHANNEL_DEBUG(channel, "does not have capability to change the preferred video codec type");<br>
+ g_set_error_literal(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,<br>
+ _("Channel does not have capability to change the preferred video codec type"));<br>
+<br>
+ return FALSE;<br>
+ }<br>
+<br>
+ msg = g_string_new("changing preferred video codec type to: ");<br>
+ for (i = 0; i < ncodecs; i++) {<br>
+ gint codec_type = codecs[i];<br>
+<br>
+ if (codec_type < SPICE_VIDEO_CODEC_TYPE_MJPEG ||<br>
+ codec_type >= SPICE_VIDEO_CODEC_TYPE_ENUM_END)<br>
+ {<br>
+ g_string_free(msg, TRUE);<br>
+ g_set_error(err, SPICE_CLIENT_ERROR, SPICE_CLIENT_ERROR_FAILED,<br>
+ _("Invalid codec-type found (%d) ... "), codec_type);<br>
+<br>
+ return FALSE;<br>
+ }<br>
+<br>
+ g_string_append_printf(msg, "%s ", gst_opts[codec_type].name);<br>
+<br>
+ }<br>
+ CHANNEL_DEBUG(channel, "%s", msg->str);<br>
+ g_string_free(msg, TRUE);<br>
+<br>
+ spice_display_send_client_preferred_video_codecs(channel, codecs, ncodecs);<br>
+<br>
+ return TRUE;<br>
}<br>
<br>
/**<br>
diff --git a/src/channel-display.h b/src/channel-display.h<br>
index 5b48d2f..cf18538 100644<br>
--- a/src/channel-display.h<br>
+++ b/src/channel-display.h<br>
@@ -150,6 +150,8 @@ gboolean spice_display_channel_get_primary(SpiceChannel *channel, guint32<br>
<br>
void spice_display_channel_change_preferred_compression(SpiceChannel *channel, gint compression);<br>
void spice_display_channel_change_preferred_video_codec_type(SpiceChannel *channel, gint codec_type);<br>
+gboolean spice_display_channel_change_preferred_video_codec_types(SpiceChannel *channel, const gint *codecs,<br>
+ gsize ncodecs, GError **err);<br>
<br>
GType spice_gl_scanout_get_type (void) G_GNUC_CONST;<br>
void spice_gl_scanout_free (SpiceGlScanout *scanout);<br>
diff --git a/src/map-file b/src/map-file<br>
index 500683c..3cb9873 100644<br>
--- a/src/map-file<br>
+++ b/src/map-file<br>
@@ -25,6 +25,7 @@ spice_display_change_preferred_compression;<br>
spice_display_change_preferred_video_codec_type;<br>
spice_display_channel_change_preferred_compression;<br>
spice_display_channel_change_preferred_video_codec_type;<br>
+spice_display_channel_change_preferred_video_codec_types;<br>
spice_display_channel_get_gl_scanout;<br>
spice_display_channel_get_primary;<br>
spice_display_channel_get_type;<br>
diff --git a/src/spice-glib-sym-file b/src/spice-glib-sym-file<br>
index 2df1cc0..c3b2561 100644<br>
--- a/src/spice-glib-sym-file<br>
+++ b/src/spice-glib-sym-file<br>
@@ -23,6 +23,7 @@ spice_display_change_preferred_compression<br>
spice_display_change_preferred_video_codec_type<br>
spice_display_channel_change_preferred_compression<br>
spice_display_channel_change_preferred_video_codec_type<br>
+spice_display_channel_change_preferred_video_codec_types<br>
spice_display_channel_get_gl_scanout<br>
spice_display_channel_get_primary<br>
spice_display_channel_get_type<br>
-- <br>
2.21.0<br>
<br>
</blockquote></div>