Add logic to skip h/w video decoder element in __ms_feature_node_filter()
[platform/core/api/mediastreamer.git] / src / media_streamer_gst.c
index aa65883..3513db9 100644 (file)
@@ -627,6 +627,29 @@ GstElement *ms_combine_next_element(GstElement *previous_element, GstPad *prev_e
        return found_element;
 }
 
+static gboolean __need_to_skip_hw_video_decoder_klass(const gchar *klass)
+{
+       gchar **zerocopy_node_names = NULL;
+       gboolean found = false;
+
+       if (g_strcmp0(klass, "Codec/Decoder/Video/Hardware") == 0) {
+               if (!ms_ini_get_boolean("general:use zerocopy", DEFAULT_USE_ZEROCOPY)) {
+                       ms_debug("Skipping [%s] because use zerocopy is false", MEDIASTREAMER_DECODEBIN_TYPE_DECODER);
+                       return TRUE;
+               }
+               ms_ini_read_list("general:zerocopy node names", &zerocopy_node_names);
+               found = (zerocopy_node_names && g_strv_contains((const gchar * const *)zerocopy_node_names, MEDIASTREAMER_DECODEBIN_TYPE_DECODER));
+               g_strfreev(zerocopy_node_names);
+               if (!found) {
+                       ms_debug("Skipping [%s] which is not specified in zerocopy node names", MEDIASTREAMER_DECODEBIN_TYPE_DECODER);
+                       return TRUE;
+               }
+               ms_debug("[%s] can be used", MEDIASTREAMER_DECODEBIN_TYPE_DECODER);
+       }
+
+       return FALSE;
+}
+
 static gint __decodebin_autoplug_select_cb(GstElement *bin, GstPad *pad, GstCaps *caps, GstElementFactory *factory, gpointer data)
 {
        /* NOTE : GstAutoplugSelectResult is defined in gstplay-enum.h but not exposed */
@@ -661,21 +684,9 @@ static gint __decodebin_autoplug_select_cb(GstElement *bin, GstPad *pad, GstCaps
                }
        }
 
-       if (g_strcmp0(klass, "Codec/Decoder/Video/Hardware") == 0) {
-               gchar **zerocopy_node_names = NULL;
-               gboolean found = false;
-               if (!ms_ini_get_boolean("general:use zerocopy", DEFAULT_USE_ZEROCOPY)) {
-                       ms_debug("Skipping [%s] because use zerocopy is false", factory_name);
-                       return GST_AUTOPLUG_SELECT_SKIP;
-               }
-               ms_ini_read_list("general:zerocopy node names", &zerocopy_node_names);
-               found = (zerocopy_node_names && g_strv_contains((const gchar * const *)zerocopy_node_names, MEDIASTREAMER_DECODEBIN_TYPE_DECODER));
-               g_strfreev(zerocopy_node_names);
-               if (!found) {
-                       ms_debug("Skipping [%s] which is not specified in zerocopy node names", factory_name);
-                       return GST_AUTOPLUG_SELECT_SKIP;
-               }
-               ms_debug("[%s] can be used", factory_name);
+       if (__need_to_skip_hw_video_decoder_klass(klass)) {
+               ms_debug("Skipping [%s]", factory_name);
+               return GST_AUTOPLUG_SELECT_SKIP;
        }
 
        if (ms_streamer->ini.resource_required_elem_names) {
@@ -1249,6 +1260,11 @@ static gboolean __ms_feature_node_filter(GstPluginFeature *feature, gpointer dat
                                }
                        }
 
+                       if (__need_to_skip_hw_video_decoder_klass(factory_klass)) {
+                               ms_debug("Skipping [%s]", GST_OBJECT_NAME(factory));
+                               return FALSE;
+                       }
+
                        ms_info("[INFO] Found compatible factory [%s] for klass [%s]",
                                GST_OBJECT_NAME(factory), factory_klass);
                        return TRUE;