[Spice-devel] [spice-gtk v7 2/3] channel-display: implement preferred video codec msgc

Victor Toso victortoso at redhat.com
Wed Feb 8 07:58:42 UTC 2017


Hi,

On Tue, Feb 07, 2017 at 11:11:42AM +0100, Pavel Grunt wrote:
> On Mon, 2017-02-06 at 12:06 +0100, Victor Toso wrote:
> > From: Victor Toso <me at victortoso.com>
> > 
> > * SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE
> > 
> > This message was introduced in protocol 0.12.13 to establish client
> > side preference on video codec to be used in streams.
> > 
> > At this moment, we only introduce a new API [0] to select *the*
> > preferred video codec for client; In a later time, it should be
> > possible to use this message upon connection in order to to give
> > higher priority for video codecs with better performance and with
> > hardware decoding capabilities.
> > 
> > [0] spice_display_change_preferred_video_codec_type()
> > 
> > Note that host preference for encoding is expected to be considered
> > first then the client's preference.
> > 
> > Signed-off-by: Victor Toso <victortoso at redhat.com>
> > ---
> >  doc/reference/spice-gtk-sections.txt |  1 +
> >  src/channel-display.c                | 55
> > ++++++++++++++++++++++++++++++++++++
> >  src/channel-display.h                |  1 +
> >  src/map-file                         |  1 +
> >  src/spice-glib-sym-file              |  1 +
> >  5 files changed, 59 insertions(+)
> > 
> > diff --git a/doc/reference/spice-gtk-sections.txt
> > b/doc/reference/spice-gtk-sections.txt
> > index f2235e8..6f49df3 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 06d433b..0677ac2 100644
> > --- a/src/channel-display.c
> > +++ b/src/channel-display.c
> > @@ -524,6 +524,61 @@ void
> > spice_display_change_preferred_compression(SpiceChannel *channel,
> > gint comp
> >      spice_msg_out_send_internal(out);
> >  }
> >  
> > +static void
> > spice_display_send_client_preferred_video_codecs(SpiceChannel
> > *channel,
> > +                                                             const
> > GArray *codecs)
> > +{
> > +    guint i;
> > +    SpiceMsgOut *out;
> > +    SpiceMsgcDisplayPreferredVideoCodecType *msg;
> > +
> > +    msg = g_malloc0(sizeof(SpiceMsgcDisplayPreferredVideoCodecType)
> > +
> > +                    (sizeof(SpiceVideoCodecType) * codecs->len));
> > +    msg->num_of_codecs = codecs->len;
> > +    for (i = 0; i < codecs->len; i++) {
> > +        msg->codecs[i] = g_array_index(codecs, gint, i);
>
> would be good to check if client is capable of handling the codec (if
> it has the cap) - some g_warn_if... (can be done in an extra patch)

Yeah, let's move out that array you introduced in 9eac89e5 and make this
check here. If possible, we might try to use it in spicy too as Frediano
suggested.

>
> > +    }
> > +
> > +    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_change_preferred_video_codec:
> > + * @channel: a #SpiceDisplayChannel
> > + * @codec_type: 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 per
> > + * display channel.
> > + *
> > + * Since: 0.34
> > + */
> > +void spice_display_change_preferred_video_codec_type(SpiceChannel
> > *channel, gint codec_type)
> > +{
> > +    GArray *codecs;
> > +
> > +    g_return_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel));
> > +    g_return_if_fail(codec_type >= SPICE_VIDEO_CODEC_TYPE_MJPEG &&
> > +                     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;
> > +    }
> > +
> > +    /* FIXME: We should detect video codecs that client machine can
> > do hw
> > +     * decoding, store this information (as GArray) and send it to
> > the server.
> > +     * This array can be rearranged to have @codec_type in the
> > front (which is
> > +     * the preferred for the client side) */
> > +    CHANNEL_DEBUG(channel, "changing preferred video codec type to
> > %d", codec_type);
> > +    codecs = g_array_new(FALSE, FALSE, sizeof(gint));
> > +    g_array_append_val(codecs, codec_type);
> > +    spice_display_send_client_preferred_video_codecs(channel,
> > codecs);
> > +    g_array_unref(codecs);
> > +}
> > +
> >  /**
> >   * 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
>
> Looks good to me,
>
> Ack

Thanks, I'll be pushing this one shortly.

>
> Pavel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170208/b31b7f20/attachment.sig>


More information about the Spice-devel mailing list