Signed-off-by: Francois Gouget <fgou...@codeweavers.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 c5ad2e9..7b7d0eb 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -204,8 +204,7 @@ static uint8_t* gst_decoder_decode_frame(VideoDecoder 
*video_decoder,
     return NULL;
 }
 
-G_GNUC_INTERNAL
-gboolean gstvideo_init(void)
+static gboolean gstvideo_init(void)
 {
     static int success = 0;
     if (!success) {
@@ -236,3 +235,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 2c64eb4..fee1047 100644
--- a/src/channel-display-priv.h
+++ b/src/channel-display-priv.h
@@ -70,9 +70,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 193f177..4a998b4 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -632,10 +632,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.6.4

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to