Remove useless if-else statement 74/242374/3
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 26 Aug 2020 01:21:21 +0000 (10:21 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 27 Aug 2020 09:23:28 +0000 (18:23 +0900)
[Version] 0.1.115
[Issue Type] Refactoring

Change-Id: Ie7cfe36452f0fec46e6ed4a378ea92156d55b9db
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-streamer.spec
src/media_streamer_gst.c

index 115b0f0..dc6c36b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-streamer
 Summary:    A Media Streamer API
-Version:    0.1.114
+Version:    0.1.115
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 64638c2..8165890 100644 (file)
@@ -1228,11 +1228,11 @@ GstElement *ms_adaptive_element_create(void)
 static gboolean __ms_feature_node_filter(GstPluginFeature *feature, gpointer data)
 {
        node_plug_s *plug_info = (node_plug_s*)data;
-       gboolean can_accept = FALSE;
        gboolean src_can_accept = FALSE;
        gboolean sink_can_accept = FALSE;
        GstElementFactory *factory = NULL;
        const gchar *factory_klass = NULL;
+       int index = 0;
 
        if (!GST_IS_ELEMENT_FACTORY(feature))
                return FALSE;
@@ -1240,41 +1240,37 @@ static gboolean __ms_feature_node_filter(GstPluginFeature *feature, gpointer dat
        factory = GST_ELEMENT_FACTORY(feature);
        factory_klass = gst_element_factory_get_klass(factory);
 
-       if (plug_info && g_strrstr(factory_klass, plug_info->info->klass_name)) {
-               if (GST_IS_CAPS(plug_info->src_caps))
-                       src_can_accept = gst_element_factory_can_src_any_caps(factory, plug_info->src_caps);
-
-               if (GST_IS_CAPS(plug_info->sink_caps))
-                       sink_can_accept = gst_element_factory_can_sink_any_caps(factory, plug_info->sink_caps);
-
-               if (GST_IS_CAPS(plug_info->src_caps) && GST_IS_CAPS(plug_info->sink_caps)) {
-                       if (src_can_accept && sink_can_accept)
-                               can_accept = TRUE;
-               } else if (src_can_accept || sink_can_accept)
-                       can_accept = TRUE;
-
-               if (can_accept) {
-                       int index = 0;
-                       for ( ; plug_info->exclude_names && plug_info->exclude_names[index]; ++index) {
-                               if (g_strrstr(GST_OBJECT_NAME(factory), plug_info->exclude_names[index])) {
-                                       ms_debug("Skipping compatible factory [%s] as excluded.", GST_OBJECT_NAME(factory));
-                                       return FALSE;
-                               }
-                       }
+       if (!plug_info || !g_strrstr(factory_klass, plug_info->info->klass_name))
+               return FALSE;
 
-                       if (__need_to_skip_hw_video_decoder_klass(factory_klass)) {
-                               ms_debug("Skipping [%s]", GST_OBJECT_NAME(factory));
-                               return FALSE;
-                       }
+       if (GST_IS_CAPS(plug_info->src_caps))
+               src_can_accept = gst_element_factory_can_src_any_caps(factory, plug_info->src_caps);
 
-                       ms_info("[INFO] Found compatible factory [%s] for klass [%s]",
-                               GST_OBJECT_NAME(factory), factory_klass);
-                       return TRUE;
+       if (GST_IS_CAPS(plug_info->sink_caps))
+               sink_can_accept = gst_element_factory_can_sink_any_caps(factory, plug_info->sink_caps);
+
+       if (GST_IS_CAPS(plug_info->src_caps) && GST_IS_CAPS(plug_info->sink_caps)) {
+               if (!src_can_accept || !sink_can_accept)
+                       return FALSE;
+       }
+
+       if (!src_can_accept && !sink_can_accept)
+               return FALSE;
+
+       for ( ; plug_info->exclude_names && plug_info->exclude_names[index]; ++index) {
+               if (g_strrstr(GST_OBJECT_NAME(factory), plug_info->exclude_names[index])) {
+                       ms_debug("Skipping compatible factory [%s] as excluded.", GST_OBJECT_NAME(factory));
+                       return FALSE;
                }
+       }
 
+       if (__need_to_skip_hw_video_decoder_klass(factory_klass)) {
+               ms_debug("Skipping [%s]", GST_OBJECT_NAME(factory));
+               return FALSE;
        }
 
-       return FALSE;
+       ms_info("Found compatible factory [%s] for klass [%s]", GST_OBJECT_NAME(factory), factory_klass);
+       return TRUE;
 }
 
 static GstElement *ms_element_create_from_ini(node_plug_s *plug_info, media_streamer_node_type_e type)