Signed-off-by: Francois Gouget <fgouget@xxxxxxxxxxxxxxx> --- 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 1675371..e328260 100644 --- a/src/channel-display-gst.c +++ b/src/channel-display-gst.c @@ -396,8 +396,7 @@ static void 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) { @@ -430,3 +429,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 = construct_pipeline((SpiceGstDecoder*)decoder); + decoder->destroy(decoder); + } + + return has_codec; +} diff --git a/src/channel-display-priv.h b/src/channel-display-priv.h index fc85db1..36e8b38 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 f485a0e..b355ce5 100644 --- a/src/channel-display.c +++ b/src/channel-display.c @@ -725,10 +725,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"); } } -- 2.7.0 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel