[Spice-devel] [PATCH v2 2/2] display-gst: change compile to runtime check of vaapisink element

Victor Toso victortoso at redhat.com
Sun Jan 27 15:49:02 UTC 2019


From: Victor Toso <me at victortoso.com>

Runtime check is better fit to enable/disable vaapisink. For that, use
spice_check_gst_plugin_version() from previous commit.

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 src/channel-display-gst.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 4272ade..c5add40 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -19,6 +19,7 @@
 
 #include "spice-client.h"
 #include "spice-common.h"
+#include "spice-util-priv.h"
 #include "spice-channel-priv.h"
 
 #include "channel-display-priv.h"
@@ -431,6 +432,8 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder)
     GstElement *playbin, *sink;
     SpiceGstPlayFlags flags;
     GstCaps *caps;
+    GError *err = NULL;
+    GstPluginFeature *vaapisink;
 
     playbin = gst_element_factory_make("playbin", "playbin");
     if (playbin == NULL) {
@@ -461,29 +464,23 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder)
                  NULL);
 
         decoder->appsink = GST_APP_SINK(sink);
-    } else {
-        /* handle has received, it means playbin will render directly into
-         * widget using the gstvideooverlay interface instead of app-sink.
-         */
-        SPICE_DEBUG("Video is presented using gstreamer's GstVideoOverlay interface");
-
-#if !GST_CHECK_VERSION(1,14,0)
-        /* Avoid using vaapisink if exist since vaapisink could be
-         * buggy when it is combined with playbin. changing its rank to
-         * none will make playbin to avoid of using it.
-         */
-        GstRegistry *registry = NULL;
-        GstPluginFeature *vaapisink = NULL;
+    } else if (!spice_check_gst_plugin_version("vaapisink", 1, 14, 0, &vaapisink, &err)) {
+        if (err == NULL) {
+            /* handle has received, it means playbin will render directly into
+             * widget using the gstvideooverlay interface instead of app-sink.
+             */
+            SPICE_DEBUG("Video is presented using gstreamer's GstVideoOverlay interface");
 
-        registry = gst_registry_get();
-        if (registry) {
-            vaapisink = gst_registry_lookup_feature(registry, "vaapisink");
-        }
-        if (vaapisink) {
+            /* Avoid using vaapisink if exist since vaapisink could be
+             * buggy when it is combined with playbin. changing its rank to
+             * none will make playbin to avoid of using it.
+             */
             gst_plugin_feature_set_rank(vaapisink, GST_RANK_NONE);
-            gst_object_unref(vaapisink);
+            g_clear_object(&vaapisink);
+        } else {
+            g_warning("Failure while checking vaapisink version: %s", err->message);
+            g_clear_error(&err);
         }
-#endif
     }
 
     g_signal_connect(playbin, "deep-element-added", G_CALLBACK(deep_element_added_cb), decoder);
-- 
2.20.1



More information about the Spice-devel mailing list