Add checking null point and log 29/171029/5 submit/tizen/20180305.045352
authorHyunil <hyunil46.park@samsung.com>
Mon, 26 Feb 2018 04:36:41 +0000 (13:36 +0900)
committerHyunil <hyunil46.park@samsung.com>
Fri, 2 Mar 2018 00:06:13 +0000 (09:06 +0900)
Change-Id: Ida65ee996b54407a82f5fe20bc11a9629de15205
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
src/media_streamer_node.c

index f13824be53bd605170d61942b7fd493c4314ac3e..949f6134b24fb01c89ece26aa2a90b4cd2317779 100644 (file)
@@ -96,35 +96,56 @@ node_info_s nodes_info[] = {
 
 void __ms_get_state(media_streamer_s *ms_streamer)
 {
-       GstState state_old, state_new;
-       GstStateChangeReturn ret_state = gst_element_get_state(ms_streamer->pipeline, &state_old, &state_new, GST_CLOCK_TIME_NONE);
+       GstState state_old = GST_STATE_NULL, state_new = GST_STATE_NULL;
+       GstStateChangeReturn ret_state = -1;
+
+       ms_debug_fenter();
+
+       ms_retm_if(ms_streamer == NULL, "ms_streamer is NULL");
+       ms_retm_if(ms_streamer->pipeline == NULL, "ms_streamer->pipeline is NULL");
+
+       ret_state = gst_element_get_state(ms_streamer->pipeline, &state_old, &state_new, GST_CLOCK_TIME_NONE);
        if (ret_state == GST_STATE_CHANGE_SUCCESS)
                ms_info("Got state for [%s]: old [%s], new [%s]", GST_ELEMENT_NAME(ms_streamer->pipeline), gst_element_state_get_name(state_old), gst_element_state_get_name(state_new));
        else
                ms_error("Couldn`t get state for [%s]", GST_ELEMENT_NAME(ms_streamer->pipeline));
+
+       ms_debug_fleave();
 }
 
 static gboolean __ms_rtp_node_has_property(media_streamer_node_s *ms_node, const char *param_name)
 {
+       GValue *val = NULL;
+
+       ms_debug_fenter();
+
        ms_retvm_if(!ms_node || !ms_node->gst_element, FALSE, "Error: empty node");
        ms_retvm_if(!param_name, FALSE, "Error: invalid property parameter");
 
        if (ms_node->type != MEDIA_STREAMER_NODE_TYPE_RTP)
                return FALSE;
 
-       GValue *val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param_name);
+       val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param_name);
+
+       ms_debug_fleave();
+
        return val ? TRUE : FALSE;
 }
 
 static int __ms_rtp_node_get_property(media_streamer_node_s *ms_node, param_s *param, GValue *value)
 {
+       int ret = MEDIA_STREAMER_ERROR_NONE;
+       GValue *val = NULL;
+
+       ms_debug_fenter();
+
        ms_retvm_if(!ms_node || !ms_node->gst_element, FALSE, "Error: empty node");
        ms_retvm_if(ms_node->type != MEDIA_STREAMER_NODE_TYPE_RTP, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Invalid node type");
        ms_retvm_if(!param, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Error: invalid property parameter");
+       ms_retvm_if(!value, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "value is NULL");
 
-       int ret = MEDIA_STREAMER_ERROR_NONE;
 
-       GValue *val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param->param_name);
+       val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param->param_name);
        if (!strcmp(param->param_name, MEDIA_STREAMER_PARAM_VIDEO_IN_PORT) ||
                !strcmp(param->param_name, MEDIA_STREAMER_PARAM_AUDIO_IN_PORT) ||
                !strcmp(param->param_name, MEDIA_STREAMER_PARAM_VIDEO_OUT_PORT) ||
@@ -136,18 +157,25 @@ static int __ms_rtp_node_get_property(media_streamer_node_s *ms_node, param_s *p
                ret = MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
 
        g_value_copy(val, value);
+
+       ms_debug_fleave();
+
        return ret;
 }
 
 static int __ms_rtp_node_set_property(media_streamer_node_s *ms_node, param_s *param, const char *param_value)
 {
+       int ret = MEDIA_STREAMER_ERROR_NONE;
+       GValue *val = NULL;
+
+       ms_debug_fenter();
+
        ms_retvm_if(!ms_node || !ms_node->gst_element, MEDIA_STREAMER_ERROR_INVALID_OPERATION, "Error: empty node");
        ms_retvm_if(ms_node->type != MEDIA_STREAMER_NODE_TYPE_RTP, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Invalid node type");
        ms_retvm_if(!param, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Error: invalid property parameter");
+       ms_retvm_if(!param_value, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param_value is NULL");
 
-       int ret = MEDIA_STREAMER_ERROR_NONE;
-
-       GValue *val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param->param_name);
+       val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param->param_name);
        if (!val) {
                ms_error("fail to get [%s] val from [%s]", param->param_name, GST_ELEMENT_NAME(ms_node->gst_element));
                return MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
@@ -178,52 +206,74 @@ static int __ms_rtp_node_set_property(media_streamer_node_s *ms_node, param_s *p
                ret = MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
        }
 
+       ms_debug_fleave();
+
        return ret;
 }
 
 static gboolean __ms_adaptive_src_node_has_property(media_streamer_node_s *ms_node, const char * param_name)
 {
+       GValue *val = NULL;
+
+       ms_debug_fenter();
+
        ms_retvm_if(!ms_node || !ms_node->gst_element, FALSE, "Error: empty node");
        ms_retvm_if(!param_name, FALSE, "Error: invalid property parameter");
 
        if (ms_node->type == MEDIA_STREAMER_NODE_TYPE_SRC &&
                        ms_node->subtype == MEDIA_STREAMER_NODE_SRC_TYPE_ADAPTIVE) {
-               GValue *val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param_name);
+               val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param_name);
+
+               ms_debug_fleave();
+
                return val ? TRUE : FALSE;
        }
 
+       ms_debug_fleave();
+
        return FALSE;
 }
 
 static int __ms_adaptive_src_node_get_property(media_streamer_node_s *ms_node, param_s *param, GValue *value)
 {
+       int ret = MEDIA_STREAMER_ERROR_NONE;
+       GValue *val = NULL;
+
+       ms_debug_fenter();
+
        ms_retvm_if(!ms_node || !ms_node->gst_element, FALSE, "Error: empty node");
        ms_retvm_if(ms_node->type != MEDIA_STREAMER_NODE_TYPE_SRC &&
                        ms_node->subtype != MEDIA_STREAMER_NODE_SRC_TYPE_ADAPTIVE, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Invalid node type");
        ms_retvm_if(!param, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Error: invalid property parameter");
+       ms_retvm_if(!value, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "value is NULL");
 
-       int ret = MEDIA_STREAMER_ERROR_NONE;
-
-       GValue *val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param->param_name);
+       val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param->param_name);
        if (!strcmp(param->param_name, MEDIA_STREAMER_PARAM_URI))
                g_value_init(value, G_TYPE_STRING);
        else
                ret = MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
 
        g_value_copy(val, value);
+
+       ms_debug_fleave();
+
        return ret;
 }
 
 static int __ms_adaptive_src_node_set_property(media_streamer_node_s *ms_node, param_s *param, const char *param_value)
 {
+       int ret = MEDIA_STREAMER_ERROR_NONE;
+       GValue *val = NULL;
+
+       ms_debug_fenter();
+
        ms_retvm_if(!ms_node || !ms_node->gst_element, MEDIA_STREAMER_ERROR_INVALID_OPERATION, "Error: empty node");
        ms_retvm_if(ms_node->type != MEDIA_STREAMER_NODE_TYPE_SRC &&
                        ms_node->subtype != MEDIA_STREAMER_NODE_SRC_TYPE_ADAPTIVE, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Invalid node type");
        ms_retvm_if(!param, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Error: invalid property parameter");
+       ms_retvm_if(!param_value, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param_value is NULL");
 
-       int ret = MEDIA_STREAMER_ERROR_NONE;
-
-       GValue *val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param->param_name);
+       val = (GValue *)g_object_get_data(G_OBJECT(ms_node->gst_element), param->param_name);
        if (!val) {
                ms_error("fail to get [%s] val from [%s]", param->param_name, GST_ELEMENT_NAME(ms_node->gst_element));
                return MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
@@ -237,17 +287,24 @@ static int __ms_adaptive_src_node_set_property(media_streamer_node_s *ms_node, p
                ret = MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
        }
 
+       ms_debug_fleave();
+
        return ret;
 }
 
 int __ms_node_create(media_streamer_node_s *node, media_format_h in_fmt, media_format_h out_fmt)
 {
-       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
-
        int ret = MEDIA_STREAMER_ERROR_NONE;
+       GstCaps *sink_caps = NULL;
+       GstCaps *src_caps = NULL;
 
-       GstCaps *sink_caps = in_fmt ? __ms_create_caps_from_fmt(in_fmt) : NULL;
-       GstCaps *src_caps = out_fmt ? __ms_create_caps_from_fmt(out_fmt) : NULL;
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+       ms_retvm_if(out_fmt == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "out_fmt is NULL");
+
+       sink_caps = in_fmt ? __ms_create_caps_from_fmt(in_fmt) : NULL;
+       src_caps = out_fmt ? __ms_create_caps_from_fmt(out_fmt) : NULL;
 
        node_plug_s plug_info = {&(nodes_info[node->type]), src_caps, sink_caps, NULL};
 
@@ -266,6 +323,8 @@ int __ms_node_create(media_streamer_node_s *node, media_format_h in_fmt, media_f
        if (sink_caps)
                        gst_caps_unref(sink_caps);
 
+       ms_debug_fleave();
+
        return ret;
 }
 
@@ -274,13 +333,21 @@ int __ms_node_create(media_streamer_node_s *node, media_format_h in_fmt, media_f
 static void __ms_src_start_feed_cb(GstElement *pipeline, guint size, gpointer data)
 {
        media_streamer_node_s *ms_src = (media_streamer_node_s *) data;
-       ms_retm_if(ms_src == NULL, "Handle is NULL");
+       media_streamer_callback_s *src_callback = NULL;
+       media_streamer_custom_buffer_status_cb buffer_status_cb = NULL;
+
+       ms_debug_fenter();
+
+       ms_retm_if(ms_src == NULL, "data is NULL");
+       ms_retm_if(pipeline == NULL, "pipeline is NULL");
 
        if (ms_src->callbacks_structure != NULL) {
-               media_streamer_callback_s *src_callback = (media_streamer_callback_s *) ms_src->callbacks_structure;
-               media_streamer_custom_buffer_status_cb buffer_status_cb = (media_streamer_custom_buffer_status_cb) src_callback->callback;
+               src_callback = (media_streamer_callback_s *) ms_src->callbacks_structure;
+               buffer_status_cb = (media_streamer_custom_buffer_status_cb) src_callback->callback;
                buffer_status_cb((media_streamer_node_h) ms_src, MEDIA_STREAMER_CUSTOM_BUFFER_UNDERRUN, src_callback->user_data);
        }
+
+       ms_debug_fleave();
 }
 
 /* This callback is called when appsrc has enough data and we can stop sending.
@@ -288,13 +355,21 @@ static void __ms_src_start_feed_cb(GstElement *pipeline, guint size, gpointer da
 static void __ms_src_stop_feed_cb(GstElement *pipeline, gpointer data)
 {
        media_streamer_node_s *ms_src = (media_streamer_node_s *) data;
-       ms_retm_if(ms_src == NULL, "Handle is NULL");
+       media_streamer_callback_s *src_callback = NULL;
+       media_streamer_custom_buffer_status_cb buffer_status_cb = NULL;
+
+       ms_debug_fenter();
+
+       ms_retm_if(ms_src == NULL, "data is NULL");
+       ms_retm_if(pipeline == NULL, "pipeline is NULL");
 
        if (ms_src->callbacks_structure != NULL) {
-               media_streamer_callback_s *src_callback = (media_streamer_callback_s *) ms_src->callbacks_structure;
-               media_streamer_custom_buffer_status_cb buffer_status_cb = (media_streamer_custom_buffer_status_cb) src_callback->callback;
+               src_callback = (media_streamer_callback_s *) ms_src->callbacks_structure;
+               buffer_status_cb = (media_streamer_custom_buffer_status_cb) src_callback->callback;
                buffer_status_cb((media_streamer_node_h) ms_src, MEDIA_STREAMER_CUSTOM_BUFFER_OVERFLOW, src_callback->user_data);
        }
+
+       ms_debug_fleave();
 }
 
 static int __ms_node_check_priveleges(media_streamer_node_s *node)
@@ -302,6 +377,14 @@ static int __ms_node_check_priveleges(media_streamer_node_s *node)
        int ret = MEDIA_STREAMER_ERROR_NONE;
        int ret_val = 0;
        char *privilege = NULL;
+       FILE* opened_file;
+       char smackLabel[SMACK_LABEL_LEN + 1];
+       char uid[10];
+       cynara *cynara_h = NULL;
+
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
 
        if (node->type == MEDIA_STREAMER_NODE_TYPE_SRC) {
                switch (node->subtype) {
@@ -341,12 +424,6 @@ static int __ms_node_check_priveleges(media_streamer_node_s *node)
        if (privilege == NULL)
                return ret;
 
-       FILE* opened_file;
-
-       char smackLabel[SMACK_LABEL_LEN + 1];
-       char uid[10];
-       cynara *cynara_h = NULL;
-
        if (CYNARA_API_SUCCESS != cynara_initialize(&cynara_h, NULL)) {
                ms_error("Failed to initialize cynara structure\n");
                return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
@@ -387,6 +464,9 @@ static int __ms_node_check_priveleges(media_streamer_node_s *node)
        }
 
        cynara_finish(cynara_h);
+
+       ms_debug_fleave();
+
        return ret;
 }
 
@@ -402,6 +482,10 @@ static int __ms_node_check_feature(media_streamer_node_s *node)
        bool enabled = FALSE;
        bool supported = FALSE;
 
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+
        if (node->type == MEDIA_STREAMER_NODE_TYPE_SRC) {
                switch (node->subtype) {
                case MEDIA_STREAMER_NODE_SRC_TYPE_HTTP:
@@ -499,16 +583,20 @@ static int __ms_node_check_feature(media_streamer_node_s *node)
                }
        }
 
+       ms_debug_fleave();
+
        return ret;
 }
 
 int __ms_src_node_create(media_streamer_node_s *node)
 {
-       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
-
        int ret = MEDIA_STREAMER_ERROR_NONE;
        char *plugin_name = NULL;
 
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
        ret = __ms_node_check_priveleges(node);
        if (ret != MEDIA_STREAMER_ERROR_NONE) {
                ms_error("Error getting privileges for Src Node");
@@ -582,6 +670,8 @@ int __ms_src_node_create(media_streamer_node_s *node)
                return ret;
        }
 
+       ms_debug_fleave();
+
        return ret;
 }
 
@@ -589,39 +679,55 @@ int __ms_src_node_create(media_streamer_node_s *node)
 static void __ms_sink_new_buffer_cb(GstElement *sink, gpointer *data)
 {
        media_streamer_node_s *ms_sink = (media_streamer_node_s *) data;
-       ms_retm_if(ms_sink == NULL, "Handle is NULL");
+       media_streamer_sink_callbacks_s *sink_callbacks = NULL;
+       media_streamer_sink_data_ready_cb data_ready_cb = NULL;
+
+       ms_debug_fenter();
+
+       ms_retm_if(ms_sink == NULL, "data is NULL");
 
        if (ms_sink->callbacks_structure != NULL) {
-               media_streamer_sink_callbacks_s *sink_callbacks = (media_streamer_sink_callbacks_s *) ms_sink->callbacks_structure;
-               media_streamer_sink_data_ready_cb data_ready_cb = (media_streamer_sink_data_ready_cb) sink_callbacks->data_ready_cb.callback;
+               sink_callbacks = (media_streamer_sink_callbacks_s *) ms_sink->callbacks_structure;
+               data_ready_cb = (media_streamer_sink_data_ready_cb) sink_callbacks->data_ready_cb.callback;
 
                if (data_ready_cb)
                        data_ready_cb((media_streamer_node_h) ms_sink, sink_callbacks->data_ready_cb.user_data);
        }
+
+       ms_debug_fleave();
 }
 
 /* The appsink has got eos */
 static void sink_eos(GstElement *sink, gpointer *data)
 {
        media_streamer_node_s *ms_sink = (media_streamer_node_s *) data;
-       ms_retm_if(ms_sink == NULL, "Handle is NULL");
+       media_streamer_sink_callbacks_s *sink_callbacks = NULL;
+       media_streamer_sink_eos_cb eos_cb = NULL;
+
+       ms_debug_fenter();
+
+       ms_retm_if(ms_sink == NULL, "data is NULL");
 
        if (ms_sink->callbacks_structure != NULL) {
-               media_streamer_sink_callbacks_s *sink_callbacks = (media_streamer_sink_callbacks_s *) ms_sink->callbacks_structure;
-               media_streamer_sink_eos_cb eos_cb = (media_streamer_sink_eos_cb) sink_callbacks->eos_cb.callback;
+               sink_callbacks = (media_streamer_sink_callbacks_s *) ms_sink->callbacks_structure;
+               eos_cb = (media_streamer_sink_eos_cb) sink_callbacks->eos_cb.callback;
 
                if (eos_cb)
                        eos_cb((media_streamer_node_h) ms_sink, sink_callbacks->eos_cb.user_data);
        }
+
+       ms_debug_fleave();
 }
 
 int __ms_sink_node_create(media_streamer_node_s *node)
 {
-       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
-
        int ret = MEDIA_STREAMER_ERROR_NONE;
        char *plugin_name = NULL;
 
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+
        ret = __ms_node_check_priveleges(node);
        if (ret != MEDIA_STREAMER_ERROR_NONE) {
                ms_error("Error getting privileges for Sink Node");
@@ -690,12 +796,19 @@ int __ms_sink_node_create(media_streamer_node_s *node)
        else
                node->name = gst_element_get_name(node->gst_element);
 
+       ms_debug_fleave();
+
        return ret;
 }
 
 void __ms_node_destroy(media_streamer_node_s *node)
 {
-       gchar *node_name = g_strdup(node->name);
+       gchar *node_name = NULL;
+
+       ms_debug_fenter();
+
+       ms_retm_if(node == NULL, "node is NULL");
+       node_name = g_strdup(node->name);
 
        /* Disconnects and clean all node signals */
        g_list_free_full(node->sig_list, __ms_signal_destroy);
@@ -711,10 +824,17 @@ void __ms_node_destroy(media_streamer_node_s *node)
 
        ms_info("Node [%s] has been destroyed", node_name);
        MS_SAFE_GFREE(node_name);
+
+       ms_debug_fleave();
 }
 
 int __ms_node_insert_into_table(GHashTable *nodes_table, media_streamer_node_s *ms_node)
 {
+       ms_debug_fenter();
+
+       ms_retvm_if(nodes_table == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "nodes_table is NULL");
+       ms_retvm_if(ms_node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "ms_node is NULL");
+
        if (g_hash_table_contains(nodes_table, ms_node->name)) {
                ms_debug("Current Node [%s] already added into Media Streamer", ms_node->name);
                return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
@@ -725,13 +845,19 @@ int __ms_node_insert_into_table(GHashTable *nodes_table, media_streamer_node_s *
        }
 
        ms_info("Node [%s] added into streamer, node type/subtype [%d/%d]", ms_node->name, ms_node->type, ms_node->subtype);
+
+       ms_debug_fleave();
+
        return MEDIA_STREAMER_ERROR_NONE;
 }
 
 void __ms_node_remove_from_table(void *data)
 {
        media_streamer_node_s *ms_node = (media_streamer_node_s *) data;
-       ms_retm_if(ms_node == NULL, "Handle is NULL");
+
+       ms_debug_fenter();
+
+       ms_retm_if(ms_node == NULL, "data is NULL");
 
        if (__ms_element_unlink(ms_node->gst_element)) {
                ms_node->linked_by_user = FALSE;
@@ -741,12 +867,17 @@ void __ms_node_remove_from_table(void *data)
        } else {
                ms_error("Error: Node [%s] remove failed", ms_node->name);
        }
+
+       ms_debug_fleave();
+
 }
 
 static gboolean __ms_src_need_typefind(GstPad *src_pad)
 {
        gboolean ret = FALSE;
 
+       ms_debug_fenter();
+
        if (!src_pad || gst_pad_is_linked(src_pad))
                return FALSE;
 
@@ -755,12 +886,18 @@ static gboolean __ms_src_need_typefind(GstPad *src_pad)
                ret = TRUE;
 
        gst_caps_unref(src_caps);
+
+       ms_debug_fleave();
+
        return ret;
 }
 
 node_info_s * __ms_node_get_klass_by_its_type(media_streamer_node_type_e element_type)
 {
        int it_klass;
+
+       ms_debug_fenter();
+
        for (it_klass = 0; nodes_info[it_klass].klass_name != NULL; it_klass++) {
                if (it_klass == element_type) {
                        ms_info("Next node`s type klass is [%s]", nodes_info[it_klass].klass_name);
@@ -768,17 +905,30 @@ node_info_s * __ms_node_get_klass_by_its_type(media_streamer_node_type_e element
                }
        }
 
+       ms_debug_fleave();
+
        return &nodes_info[it_klass];
 }
 
 static gboolean _src_node_prepare(const GValue *item, GValue *ret, gpointer user_data)
 {
        media_streamer_s *ms_streamer = (media_streamer_s *) user_data;
-       GstElement *src_element = GST_ELEMENT(g_value_get_object(item));
+       GstElement *src_element = NULL;
+       GstElement *found_element = NULL;
+       media_streamer_node_s *found_node = NULL;
+       GstPad *src_pad = NULL;
+
+       ms_debug_fenter();
+
+       ms_retvm_if(item == NULL, FALSE, "item is NULL");
+       ms_retvm_if(ret == NULL, FALSE, "ret is NULL");
+       ms_retvm_if(ms_streamer == NULL, FALSE, "user_data is NULL");
+
+       src_element = GST_ELEMENT(g_value_get_object(item));
        g_object_ref(src_element);
        g_value_set_boolean(ret, FALSE);
 
-       media_streamer_node_s *found_node = (media_streamer_node_s *) g_hash_table_lookup(ms_streamer->nodes_table, GST_ELEMENT_NAME(src_element));
+       found_node = (media_streamer_node_s *) g_hash_table_lookup(ms_streamer->nodes_table, GST_ELEMENT_NAME(src_element));
        if (!found_node) {
                /* If we fail to found corresonding node inside streamer
                        then apprently this element doesn't require resources. */
@@ -789,8 +939,7 @@ static gboolean _src_node_prepare(const GValue *item, GValue *ret, gpointer user
 
        ms_debug("Autoplug: found src element [%s]", GST_ELEMENT_NAME(src_element));
 
-       GstPad *src_pad = gst_element_get_static_pad(src_element, "src");
-       GstElement *found_element = NULL;
+       src_pad = gst_element_get_static_pad(src_element, "src");
 
        if (__ms_src_need_typefind(src_pad)) {
                __ms_find_type(ms_streamer, src_element);
@@ -828,12 +977,26 @@ static gboolean _src_node_prepare(const GValue *item, GValue *ret, gpointer user
 
        g_value_set_boolean(ret, TRUE);
 
+       ms_debug_fleave();
+
        return TRUE;
 }
 
-static gboolean _sink_node_prepare(const GValue *item, GValue *ret, gpointer user_data)
+static gboolean _sink_node_prepare(const GValue *item, GValue *g_ret, gpointer user_data)
 {
-       return __ms_element_lock_state(item, ret, user_data);
+       gboolean ret = FALSE;
+
+       ms_retvm_if(item == NULL, FALSE, "item is NULL");
+       ms_retvm_if(g_ret == NULL, FALSE, "ret is NULL");
+       ms_retvm_if(user_data == NULL, FALSE, "user_data is NULL");
+
+       ms_debug_fenter();
+
+       ret = __ms_element_lock_state(item, g_ret, user_data);
+
+       ms_debug_fleave();
+
+       return ret;
 }
 
 static gboolean demux_find(gpointer key, gpointer value, gpointer user_data)
@@ -848,6 +1011,11 @@ static int __ms_adaptive_sink_http_server_prepare(media_streamer_s * ms_streamer
        char *playlist_dir = NULL;
        char *split = NULL;
 
+       ms_debug_fenter();
+
+       ms_retvm_if(ms_streamer == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "ms_streamer is NULL");
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+
        /* Create and start http server */
        err_code = __ms_http_server_create(&ms_streamer->http_server, NULL, DEFAULT_HTTP_PORT);
        if (MEDIA_STREAMER_ERROR_NONE != err_code) {
@@ -881,18 +1049,28 @@ static int __ms_adaptive_sink_http_server_prepare(media_streamer_s * ms_streamer
 
 _DONE:
 
+       ms_debug_fleave();
+
        return err_code;
 }
 
 int __ms_pipeline_prepare(media_streamer_s *ms_streamer)
 {
+       int ret = MEDIA_STREAMER_ERROR_NONE;
+       media_streamer_node_s *rtp_node = NULL;
+       media_streamer_node_s *demux = NULL;
+       media_streamer_node_s *adaptive_src = NULL;
+       media_streamer_node_s *adaptive_sink = NULL;
+
+       ms_debug_fenter();
+
        ms_retvm_if(ms_streamer == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
 
-       int ret = MEDIA_STREAMER_ERROR_NONE;
-       media_streamer_node_s *rtp_node = (media_streamer_node_s *)g_hash_table_lookup(ms_streamer->nodes_table, "rtp_container");
-       media_streamer_node_s *demux = (media_streamer_node_s *)g_hash_table_find(ms_streamer->nodes_table, (GHRFunc)demux_find, NULL);
-       media_streamer_node_s *adaptive_src = (media_streamer_node_s *)g_hash_table_lookup(ms_streamer->nodes_table, "adaptive_src");
-       media_streamer_node_s *adaptive_sink = (media_streamer_node_s *)g_hash_table_lookup(ms_streamer->nodes_table, "adaptive_sink");
+       rtp_node = (media_streamer_node_s *)g_hash_table_lookup(ms_streamer->nodes_table, "rtp_container");
+       demux = (media_streamer_node_s *)g_hash_table_find(ms_streamer->nodes_table, (GHRFunc)demux_find, NULL);
+       adaptive_src = (media_streamer_node_s *)g_hash_table_lookup(ms_streamer->nodes_table, "adaptive_src");
+       adaptive_sink = (media_streamer_node_s *)g_hash_table_lookup(ms_streamer->nodes_table, "adaptive_sink");
+
        if (rtp_node) {
                ret = __ms_rtp_element_prepare(rtp_node) ? MEDIA_STREAMER_ERROR_NONE : MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
        } else if (demux) {
@@ -941,6 +1119,8 @@ int __ms_pipeline_prepare(media_streamer_s *ms_streamer)
        if (ret != MEDIA_STREAMER_ERROR_NONE)
                goto prepare_fail;
 
+       ms_debug_fleave();
+
        return ret;
 
 prepare_fail:
@@ -951,18 +1131,25 @@ prepare_fail:
 static gboolean __ms_bin_remove_elements(media_streamer_s *ms_streamer, GstElement *bin)
 {
        GValue element = G_VALUE_INIT;
-       GstIterator *bin_iterator = gst_bin_iterate_elements(GST_BIN(bin));
+       GstIterator *bin_iterator = NULL;
+       gboolean ret = TRUE; /* If Bin doesn't have any elements function returns TRUE */
+       GstElement *found_element = NULL;
+       GstIteratorResult it_res = GST_ITERATOR_ERROR;
+       media_streamer_node_s *found_node = NULL;
 
-       /* If Bin doesn't have any elements function returns TRUE */
-       gboolean ret = TRUE;
+       ms_debug_fenter();
+
+       ms_retvm_if(ms_streamer == NULL, FALSE, "ms_streamer is NULL");
+       ms_retvm_if(bin == NULL, FALSE, "bin is NULL");
+
+       bin_iterator = gst_bin_iterate_elements(GST_BIN(bin));
+       it_res = gst_iterator_next(bin_iterator, &element);
 
-       GstElement *found_element = NULL;
-       GstIteratorResult it_res = gst_iterator_next(bin_iterator, &element);
        while (GST_ITERATOR_OK == it_res) {
                found_element = (GstElement *) g_value_get_object(&element);
 
                /* Get node of this element if it appears as node */
-               media_streamer_node_s *found_node = (media_streamer_node_s *) g_hash_table_lookup(ms_streamer->nodes_table, GST_ELEMENT_NAME(found_element));
+               found_node = (media_streamer_node_s *) g_hash_table_lookup(ms_streamer->nodes_table, GST_ELEMENT_NAME(found_element));
                if (found_node) {
                        if (!found_node->linked_by_user)
                                ret = ret && __ms_element_unlink(found_element);
@@ -985,20 +1172,33 @@ static gboolean __ms_bin_remove_elements(media_streamer_s *ms_streamer, GstEleme
        g_value_unset(&element);
        gst_iterator_free(bin_iterator);
 
+       ms_debug_fleave();
+
        return ret;
 }
 
 static void __ms_pending_pads_remove(void *data)
 {
-       GstPad *pad = GST_PAD(data);
+       GstPad *pad = NULL;
+
+       ms_debug_fenter();
+
+       ms_retm_if(data == NULL, "data is NULL");
+
+       pad = GST_PAD(data);
        MS_SAFE_UNREF(pad);
+
+       ms_debug_fleave();
 }
 
 int __ms_pipeline_unprepare(media_streamer_s *ms_streamer)
 {
-       ms_retvm_if(ms_streamer == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
        int ret = MEDIA_STREAMER_ERROR_NONE;
 
+       ms_debug_fenter();
+
+       ms_retvm_if(ms_streamer == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
+
        ret = __ms_state_change(ms_streamer, MEDIA_STREAMER_STATE_IDLE);
        if (ret != MEDIA_STREAMER_ERROR_NONE)
                ms_error("Failed to unprepare pipeline");
@@ -1040,6 +1240,8 @@ int __ms_pipeline_unprepare(media_streamer_s *ms_streamer)
        MS_BIN_UNPREPARE(ms_streamer->transform_bin);
        MS_BIN_UNPREPARE(ms_streamer->sink_bin);
 
+       ms_debug_fleave();
+
        return ret;
 }
 
@@ -1048,12 +1250,17 @@ int __ms_node_set_params_from_bundle(media_streamer_node_s *node, bundle *param_
        int ret = MEDIA_STREAMER_ERROR_NONE;
        GList *p_list = NULL;
        int written_count = 0;
+       param_s *param = NULL;
+       GList *list_iter = NULL;
+       char *string_val = NULL;
+
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+       ms_retvm_if(param_list == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param_list is NULL");
 
        ret = __ms_node_get_param_list(node, &p_list);
        if (ret == MEDIA_STREAMER_ERROR_NONE) {
-               param_s *param = NULL;
-               GList *list_iter = NULL;
-               char *string_val = NULL;
                for (list_iter = p_list; list_iter != NULL; list_iter = list_iter->next) {
                        param = (param_s *)list_iter->data;
                        if (bundle_get_str(param_list, param->param_name, &string_val) != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
@@ -1073,6 +1280,8 @@ int __ms_node_set_params_from_bundle(media_streamer_node_s *node, bundle *param_
        if (ret == MEDIA_STREAMER_ERROR_NONE && written_count == 0)
                ret = MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
 
+       ms_debug_fleave();
+
        return ret;
 }
 
@@ -1080,12 +1289,17 @@ int __ms_node_write_params_into_bundle(media_streamer_node_s *node, bundle *para
 {
        int ret = MEDIA_STREAMER_ERROR_NONE;
        GList *p_list = NULL;
+       param_s *param = NULL;
+       GList *list_iter = NULL;
+       char *string_val = NULL;
+
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+       ms_retvm_if(param_list == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param_list is NULL");
 
        ret = __ms_node_get_param_list(node, &p_list);
        if (ret == MEDIA_STREAMER_ERROR_NONE) {
-               param_s *param = NULL;
-               GList *list_iter = NULL;
-               char *string_val = NULL;
                for (list_iter = p_list; list_iter != NULL; list_iter = list_iter->next) {
                        param = (param_s *)list_iter->data;
 
@@ -1098,6 +1312,8 @@ int __ms_node_write_params_into_bundle(media_streamer_node_s *node, bundle *para
        if (p_list)
                g_list_free(p_list);
 
+       ms_debug_fleave();
+
        return ret;
 }
 
@@ -1107,6 +1323,12 @@ int __ms_node_get_param(media_streamer_node_s *node, const char *param_name, par
        gboolean found_param = FALSE;
        int it_param;
 
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+       ms_retvm_if(param_name == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param_name is NULL");
+       ms_retvm_if(param == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param is NULL");
+
        for (it_param = 0; param_table[it_param].param_name != NULL; it_param++) {
                if (!g_strcmp0(param_name, param_table[it_param].param_name)) {
                        param_spec = g_object_class_find_property(G_OBJECT_GET_CLASS(node->gst_element), param_table[it_param].origin_name);
@@ -1120,6 +1342,9 @@ int __ms_node_get_param(media_streamer_node_s *node, const char *param_name, par
                }
        }
        ms_retvm_if(!found_param, MEDIA_STREAMER_ERROR_INVALID_OPERATION, "Node [%s] doesn't have param [%s].", node->name, param_name);
+
+       ms_debug_fleave();
+
        return MEDIA_STREAMER_ERROR_NONE;
 }
 
@@ -1128,6 +1353,11 @@ int __ms_node_get_param_list(media_streamer_node_s *node, GList **param_list)
        GParamSpec *param_spec;
        int it_param;
 
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+       ms_retvm_if(param_list == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param_list is NULL");
+
        for (it_param = 0; param_table[it_param].param_name != NULL; it_param++) {
                param_spec = g_object_class_find_property(G_OBJECT_GET_CLASS(node->gst_element), param_table[it_param].origin_name);
                if (param_spec || __ms_rtp_node_has_property(node, param_table[it_param].origin_name) ||
@@ -1137,16 +1367,24 @@ int __ms_node_get_param_list(media_streamer_node_s *node, GList **param_list)
                }
        }
        ms_retvm_if(!(*param_list), MEDIA_STREAMER_ERROR_INVALID_OPERATION, "Node [%s] doesn't have any params.", node->name);
+
+       ms_debug_fleave();
+
        return MEDIA_STREAMER_ERROR_NONE;
 }
 
 int __ms_node_get_param_value(media_streamer_node_s *node, param_s *param, char **string_value)
 {
+       int ret = MEDIA_STREAMER_ERROR_NONE;
        char *string_val = NULL;
        GParamSpec *param_spec = NULL;
        GValue value = G_VALUE_INIT;
 
-       int ret = MEDIA_STREAMER_ERROR_NONE;
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+       ms_retvm_if(param == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param is NULL");
+       ms_retvm_if(string_value == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "string_value is NULL");
 
        if (node->type == MEDIA_STREAMER_NODE_TYPE_RTP)
                ret = __ms_rtp_node_get_property(node, param, &value);
@@ -1227,6 +1465,9 @@ int __ms_node_get_param_value(media_streamer_node_s *node, param_s *param, char
 
        g_value_reset(&value);
        g_value_unset(&value);
+
+       ms_debug_fleave();
+
        return ret;
 }
 
@@ -1442,18 +1683,25 @@ int __ms_node_set_display(media_streamer_node_s *ms_node, const char *param_valu
 
 int __ms_node_set_param_value(media_streamer_node_s *ms_node, param_s *param, const char *param_value)
 {
-       ms_retvm_if(!ms_node || !param || !param_value,  MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
 
        int ret = MEDIA_STREAMER_ERROR_NONE;
 
+       ms_debug_fenter();
+
+       ms_retvm_if(ms_node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "ms_node is NULL");
+       ms_retvm_if(param == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param is NULL");
+       ms_retvm_if(param_value == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "param_value is NULL");
+
        if (ms_node->type == MEDIA_STREAMER_NODE_TYPE_RTP) {
                ret = __ms_rtp_node_set_property(ms_node, param, param_value);
+               ms_debug_fleave();
                return ret;
        }
 
        if (ms_node->type == MEDIA_STREAMER_NODE_TYPE_SRC &&
                        ms_node->subtype == MEDIA_STREAMER_NODE_SRC_TYPE_ADAPTIVE) {
                ret = __ms_adaptive_src_node_set_property(ms_node, param, param_value);
+               ms_debug_fleave();
                return ret;
        }
 
@@ -1513,14 +1761,21 @@ int __ms_node_set_param_value(media_streamer_node_s *ms_node, param_s *param, co
                ret = MEDIA_STREAMER_ERROR_INVALID_PARAMETER;
        }
 
+       ms_debug_fleave();
+
        return ret;
 }
 
 int __ms_node_set_pad_format(media_streamer_node_s *node, const char *pad_name, media_format_h fmt)
 {
-       ms_retvm_if(!node || !pad_name || !fmt,  MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
-
        int ret = MEDIA_STREAMER_ERROR_NONE;
+
+       ms_debug_fenter();
+
+       ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "node is NULL");
+       ms_retvm_if(pad_name == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "pad_name is NULL");
+       ms_retvm_if(fmt == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "fmt is NULL");
+
        if (node->type == MEDIA_STREAMER_NODE_TYPE_RTP) {
                media_format_mimetype_e mime;
                gchar *rtp_caps_str = NULL;
@@ -1548,6 +1803,8 @@ int __ms_node_set_pad_format(media_streamer_node_s *node, const char *pad_name,
                ret = __ms_element_set_fmt(node, pad_name, fmt);
        }
 
+       ms_debug_fleave();
+
        return ret;
 }
 
@@ -1556,6 +1813,13 @@ gboolean _ms_node_resouces_acquire_iter(const GValue *item, GValue *ret, gpointe
        media_streamer_s *ms_streamer = (media_streamer_s *) user_data;
        media_streamer_node_s *node = NULL;
        GstElement *element = NULL;
+
+       ms_debug_fenter();
+
+       ms_retvm_if(item == NULL, FALSE, "item is NULL");
+       ms_retvm_if(ms_streamer == NULL, FALSE, "ms_streamer is NULL");
+       ms_retvm_if(ret == NULL, FALSE, "ret is NULL");
+
        g_value_set_boolean(ret, FALSE);
 
        element = GST_ELEMENT(g_value_get_object(item));
@@ -1582,6 +1846,8 @@ gboolean _ms_node_resouces_acquire_iter(const GValue *item, GValue *ret, gpointe
 
        g_object_unref(element);
 
+       ms_debug_fleave();
+
        return TRUE;
 }
 
@@ -1590,6 +1856,13 @@ gboolean _ms_node_resouces_release_iter(const GValue *item, GValue *ret, gpointe
        media_streamer_s *ms_streamer = (media_streamer_s *) user_data;
        media_streamer_node_s *node = NULL;
        GstElement *element = NULL;
+
+       ms_debug_fenter();
+
+       ms_retvm_if(item == NULL, FALSE, "item is NULL");
+       ms_retvm_if(ms_streamer == NULL, FALSE, "ms_streamer is NULL");
+       ms_retvm_if(ret == NULL, FALSE, "ret is NULL");
+
        g_value_set_boolean(ret, FALSE);
 
        element = GST_ELEMENT(g_value_get_object(item));
@@ -1616,6 +1889,8 @@ gboolean _ms_node_resouces_release_iter(const GValue *item, GValue *ret, gpointe
 
        g_object_unref(element);
 
+       ms_debug_fleave();
+
        return TRUE;
 }
 
@@ -1624,6 +1899,13 @@ gboolean _ms_node_policy_check_iter(const GValue *item, GValue *ret, gpointer us
        media_streamer_s *ms_streamer = (media_streamer_s *) user_data;
        media_streamer_node_s *node = NULL;
        GstElement *element = NULL;
+
+       ms_debug_fenter();
+
+       ms_retvm_if(item == NULL, FALSE, "item is NULL");
+       ms_retvm_if(ms_streamer == NULL, FALSE, "ms_streamer is NULL");
+       ms_retvm_if(ret == NULL, FALSE, "ret is NULL");
+
        g_value_set_boolean(ret, FALSE);
 
        element = GST_ELEMENT(g_value_get_object(item));
@@ -1650,5 +1932,7 @@ gboolean _ms_node_policy_check_iter(const GValue *item, GValue *ret, gpointer us
 
        g_object_unref(element);
 
+       ms_debug_fleave();
+
        return TRUE;
 }