[client v12 25/26] spice-gtk: Probe GStreamer before advertising support for a codec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 95841bd..5e6bd57 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -399,8 +399,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) {
@@ -435,3 +434,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 3989899..e27c499 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 4ea1ba7..e5a298e 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");
     }
 }
 
-- 
2.8.0.rc3

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]