[Spice-devel] [PATCH spice-gtk] gst: Fix detection of h264 stream decoder

Pavel Grunt pgrunt at redhat.com
Wed Jul 19 12:59:00 UTC 2017


GStreamer's avdec_h264 needs h264parse to be able to process H264 video
streams. However the check for elements through GstRegistry does not
take into account the possible pipeline of elements (like "h264parse ! avdec_h264").

Fix that by checking for the elements by their name.
---
 src/channel-display-gst.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 5042fc8..a9a044a 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -666,6 +666,31 @@ gboolean gstvideo_has_codec(int codec_type)
     codec_decoders = gst_element_factory_list_filter(all_decoders, caps, GST_PAD_SINK, TRUE);
     gst_caps_unref(caps);
 
+    /* Check for the presence of decoding elements that could be filter out.
+     * TODO: Improve filtering to avoid this...
+     */
+    {
+        GList *decoder_elements = NULL;
+        gchar **decoders_by_names;
+        guint i = 0;
+        decoders_by_names = g_strsplit(gst_opts[codec_type].dec_name, "!", -1);
+        for (i = 0; decoders_by_names[i] != NULL; i++) {
+            GstElementFactory *element = gst_element_factory_find(g_strstrip(decoders_by_names[i]));
+            if (element == NULL) {
+                gst_plugin_feature_list_free(decoder_elements);
+                decoder_elements = NULL;
+                break;
+            }
+            if (g_list_find(codec_decoders, element)) {
+                gst_object_unref(element);
+            } else {
+                decoder_elements = g_list_append(decoder_elements, element);
+            }
+        }
+        codec_decoders = g_list_concat(codec_decoders, decoder_elements);
+        g_strfreev(decoders_by_names);
+    }
+
     if (codec_decoders == NULL) {
         spice_debug("From %u decoders, none can handle '%s'",
                     g_list_length(all_decoders), gst_opts[codec_type].dec_caps);
-- 
2.13.3



More information about the Spice-devel mailing list