[Spice-devel] [client v14 28/29] spice-gtk: Probe GStreamer before advertising support for a codec

Pavel Grunt pgrunt at redhat.com
Tue May 17 07:20:07 UTC 2016


On Wed, 2016-05-04 at 11:44 +0200, Francois Gouget wrote:
> Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Acked-by: Pavel Grunt <pgrunt at redhat.com>
> ---
>  src/channel-display-gst.c  | 17 +++++++++++++++--
>  src/channel-display-priv.h |  4 ++--
>  src/channel-display.c      | 21 +++++++++++++++++----
>  3 files changed, 34 insertions(+), 8 deletions(-)
> 
> diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
> index c139c5e..8934371 100644
> --- a/src/channel-display-gst.c
> +++ b/src/channel-display-gst.c
> @@ -395,8 +395,7 @@ static void spice_gst_decoder_queue_frame(VideoDecoder
> *video_decoder,
>      }
>  }
>  
> -G_GNUC_INTERNAL
> -gboolean gstvideo_init(void)
> +static gboolean gstvideo_init(void)
>  {
>      static int success = 0;
>      if (!success) {
> @@ -431,3 +430,17 @@ VideoDecoder* create_gstreamer_decoder(int codec_type,
> display_stream *stream)
>  
>      return (VideoDecoder*)decoder;
>  }
> +
> +G_GNUC_INTERNAL
> +gboolean gstvideo_has_codec(int codec_type)
> +{
> +    gboolean has_codec = FALSE;
> +
> +    VideoDecoder *decoder = create_gstreamer_decoder(codec_type, NULL);
> +    if (decoder) {
> +        has_codec = create_pipeline((SpiceGstDecoder*)decoder);
> +        decoder->destroy(decoder);
> +    }
> +
> +    return has_codec;
> +}
> diff --git a/src/channel-display-priv.h b/src/channel-display-priv.h
> index b504691..94a90e6 100644
> --- a/src/channel-display-priv.h
> +++ b/src/channel-display-priv.h
> @@ -73,9 +73,9 @@ VideoDecoder* create_mjpeg_decoder(int codec_type,
> display_stream *stream);
>  #endif
>  #ifdef HAVE_GSTVIDEO
>  VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream
> *stream);
> -gboolean gstvideo_init(void);
> +gboolean gstvideo_has_codec(int codec_type);
>  #else
> -# define gstvideo_init() FALSE
> +# define gstvideo_has_codec(codec_type) FALSE
>  #endif
>  
>  
> diff --git a/src/channel-display.c b/src/channel-display.c
> index 67ee111..25b0964 100644
> --- a/src/channel-display.c
> +++ b/src/channel-display.c
> @@ -720,10 +720,23 @@ static void
> spice_display_channel_reset_capabilities(SpiceChannel *channel)
>  #ifdef HAVE_BUILTIN_MJPEG
>      spice_channel_set_capability(SPICE_CHANNEL(channel),
> SPICE_DISPLAY_CAP_CODEC_MJPEG);
>  #endif
> -    if (gstvideo_init()) {
> -        spice_channel_set_capability(SPICE_CHANNEL(channel),
> SPICE_DISPLAY_CAP_CODEC_MJPEG);
> -        spice_channel_set_capability(SPICE_CHANNEL(channel),
> SPICE_DISPLAY_CAP_CODEC_VP8);
> -        spice_channel_set_capability(SPICE_CHANNEL(channel),
> SPICE_DISPLAY_CAP_CODEC_H264);
> +    if (gstvideo_has_codec(SPICE_VIDEO_CODEC_TYPE_MJPEG)) {
> +        spice_channel_set_capability(SPICE_CHANNEL(channel),
> +                                     SPICE_DISPLAY_CAP_CODEC_MJPEG);
> +    } else {
> +        spice_info("GStreamer does not support the mjpeg codec");
> +    }
> +    if (gstvideo_has_codec(SPICE_VIDEO_CODEC_TYPE_VP8)) {
> +        spice_channel_set_capability(SPICE_CHANNEL(channel),
> +                                     SPICE_DISPLAY_CAP_CODEC_VP8);
> +    } else {
> +        spice_info("GStreamer does not support the vp8 codec");
> +    }
> +    if (gstvideo_has_codec(SPICE_VIDEO_CODEC_TYPE_H264)) {
> +        spice_channel_set_capability(SPICE_CHANNEL(channel),
> +                                     SPICE_DISPLAY_CAP_CODEC_H264);
> +    } else {
> +        spice_info("GStreamer does not support the h264 codec");
>      }
>  }
>  


More information about the Spice-devel mailing list