[0.6.164] Apply tizen coding rule
[platform/core/multimedia/libmm-player.git] / src / mm_player_utils.c
index c59d9a5..1f03baf 100644 (file)
@@ -73,7 +73,7 @@ __get_state_name(int state)
 }
 
 gboolean
-__is_rtsp_streaming(mm_player_tplayer)
+__is_rtsp_streaming(mm_player_t *player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
@@ -81,7 +81,7 @@ __is_rtsp_streaming(mm_player_t* player)
 }
 
 gboolean
-__is_http_streaming(mm_player_tplayer)
+__is_http_streaming(mm_player_t *player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
@@ -89,7 +89,7 @@ __is_http_streaming(mm_player_t* player)
 }
 
 gboolean
-__is_streaming(mm_player_tplayer)
+__is_streaming(mm_player_t *player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
@@ -98,7 +98,7 @@ __is_streaming(mm_player_t* player)
 }
 
 gboolean
-__is_live_streaming(mm_player_tplayer)
+__is_live_streaming(mm_player_t *player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
@@ -106,7 +106,7 @@ __is_live_streaming(mm_player_t* player)
 }
 
 gboolean
-__is_http_live_streaming(mm_player_tplayer)
+__is_http_live_streaming(mm_player_t *player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
@@ -114,7 +114,7 @@ __is_http_live_streaming(mm_player_t* player)
 }
 
 gboolean
-__is_dash_streaming(mm_player_tplayer)
+__is_dash_streaming(mm_player_t *player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
@@ -122,7 +122,7 @@ __is_dash_streaming(mm_player_t* player)
 }
 
 gboolean
-__is_smooth_streaming(mm_player_tplayer)
+__is_smooth_streaming(mm_player_t *player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
@@ -130,7 +130,7 @@ __is_smooth_streaming(mm_player_t* player)
 }
 
 gboolean
-__is_ms_buff_src(mm_player_tplayer)
+__is_ms_buff_src(mm_player_t *player)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
@@ -138,14 +138,14 @@ __is_ms_buff_src(mm_player_t* player)
 }
 
 gboolean
-__has_suffix(mm_player_t* player, const gchar* suffix)
+__has_suffix(mm_player_t *player, const gchar *suffix)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
        MMPLAYER_RETURN_VAL_IF_FAIL(suffix, FALSE);
 
        gboolean ret = FALSE;
-       gchart_url = g_ascii_strdown(player->profile.uri, -1);
-       gchart_suffix = g_ascii_strdown(suffix, -1);
+       gchar *t_url = g_ascii_strdown(player->profile.uri, -1);
+       gchar *t_suffix = g_ascii_strdown(suffix, -1);
 
        if (g_str_has_suffix(player->profile.uri, suffix))
                ret = TRUE;
@@ -157,14 +157,14 @@ __has_suffix(mm_player_t* player, const gchar* suffix)
 }
 
 gboolean
-__mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype, MMMessageParamType* param)
+__mmplayer_post_message(mm_player_t *player, enum MMMessageType msgtype, MMMessageParamType *param)
 {
        MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
        if (!player->msg_cb)
                return FALSE;
 
-       //LOGD("Message (type : %d)  will be posted using msg-cb(%p). \n", msgtype, player->msg_cb);
+       //LOGD("Message (type : %d)  will be posted using msg-cb(%p).", msgtype, player->msg_cb);
 
        player->msg_cb(msgtype, param, player->msg_cb_param);
 
@@ -172,9 +172,9 @@ __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype, MMMessa
 }
 
 gboolean
-__mmplayer_dump_pipeline_state(mm_player_tplayer)
+__mmplayer_dump_pipeline_state(mm_player_t *player)
 {
-       GstIterator*iter = NULL;
+       GstIterator *iter = NULL;
        gboolean done = FALSE;
 
        GValue item = {0, };
@@ -183,7 +183,7 @@ __mmplayer_dump_pipeline_state(mm_player_t* player)
 
        GstState state = GST_STATE_VOID_PENDING;
        GstState pending = GST_STATE_VOID_PENDING;
-       GstClockTime time = 200*GST_MSECOND;
+       GstClockTime time = 200 * GST_MSECOND;
 
        MMPLAYER_FENTER();
 
@@ -203,7 +203,7 @@ __mmplayer_dump_pipeline_state(mm_player_t* player)
 
                                factory = gst_element_get_factory(element) ;
                                if (factory)
-                                       LOGE("%s:%s : From:%s To:%s   refcount : %d\n", GST_OBJECT_NAME(factory) , GST_ELEMENT_NAME(element) ,
+                                       LOGE("%s:%s : From:%s To:%s   refcount : %d", GST_OBJECT_NAME(factory) , GST_ELEMENT_NAME(element) ,
                                                gst_element_state_get_name(state), gst_element_state_get_name(pending) , GST_OBJECT_REFCOUNT_VALUE(element));
                                g_value_reset(&item);
                                break;
@@ -227,7 +227,7 @@ __mmplayer_dump_pipeline_state(mm_player_t* player)
        factory = gst_element_get_factory(element) ;
 
        if (factory) {
-               LOGE("%s:%s : From:%s To:%s  refcount : %d\n",
+               LOGE("%s:%s : From:%s To:%s  refcount : %d",
                        GST_OBJECT_NAME(factory),
                        GST_ELEMENT_NAME(element),
                        gst_element_state_get_name(state),
@@ -245,7 +245,8 @@ __mmplayer_dump_pipeline_state(mm_player_t* player)
        return FALSE;
 }
 
-int util_exist_file_path(const char *file_path)
+int
+util_exist_file_path(const char *file_path)
 {
        int fd = 0;
        struct stat stat_results = {0, };
@@ -280,7 +281,7 @@ int util_exist_file_path(const char *file_path)
        return MM_ERROR_NONE;
 }
 
-char**
+char **
 util_get_cookie_list(const char *cookies)
 {
        char **cookie_list = NULL;
@@ -290,7 +291,7 @@ util_get_cookie_list(const char *cookies)
        if (!cookies || !strlen(cookies))
                return NULL;
 
-       SECURE_LOGD("cookies : %zu[bytes] - %s \n", strlen(cookies), cookies);
+       SECURE_LOGD("cookies : %zu[bytes] - %s", strlen(cookies), cookies);
 
        temp = g_strdup(cookies);
 
@@ -309,7 +310,7 @@ util_get_cookie_list(const char *cookies)
                if (cookie_list[i]) {
                        if (strlen(cookie_list[i])) {
                                g_strstrip(cookie_list[i]);
-                               SECURE_LOGD("cookie_list[%d] : %zu[bytes] - %s \n", i, strlen(cookie_list[i]), cookie_list[i]);
+                               SECURE_LOGD("cookie_list[%d] : %zu[bytes] - %s", i, strlen(cookie_list[i]), cookie_list[i]);
                        } else {
                                cookie_list[i][0] = '\0';
                        }
@@ -317,9 +318,7 @@ util_get_cookie_list(const char *cookies)
        }
 
 EXIT:
-       if (temp)
-               g_free(temp);
-       temp = NULL;
+       MMPLAYER_FREEIF(temp);
 
        return cookie_list;
 }
@@ -329,7 +328,7 @@ bool
 util_is_sdp_file(const char *path)
 {
        gboolean ret = FALSE;
-       gcharuri = NULL;
+       gchar *uri = NULL;
 
        MMPLAYER_FENTER();
 
@@ -345,8 +344,8 @@ util_is_sdp_file(const char *path)
 
        /* strlen(".sdp") == 4 */
        if (strlen(uri) <= 4) {
-               LOGW("path is too short.\n");
-               g_free(uri);
+               LOGW("path is too short.");
+               MMPLAYER_FREEIF(uri);
                return ret;
        }
 
@@ -358,41 +357,40 @@ util_is_sdp_file(const char *path)
                /* FIXIT : do it soon */
                LOGD("no suffix");
 
-       g_free(uri);
-       uri = NULL;
+       MMPLAYER_FREEIF(uri);
 
        return ret;
 }
 
-const char*
+const char *
 util_get_charset(const char *file_path)
 {
-       UCharsetDetectorucsd;
-       const UCharsetMatchucm;
+       UCharsetDetector *ucsd;
+       const UCharsetMatch *ucm;
        UErrorCode status = U_ZERO_ERROR;
 
-       const charcharset = NULL;
+       const char *charset = NULL;
        char *buf = NULL;
-       FILEfin = 0;
+       FILE *fin = 0;
        size_t n_size = 0;
 
        fin = fopen(file_path, "r");
        if (!fin) {
-               SECURE_LOGE("fail to open file %s\n", file_path);
+               SECURE_LOGE("fail to open file %s", file_path);
                return NULL;
        }
 
        ucsd = ucsdet_open(&status);
        if (U_FAILURE(status)) {
-               LOGE("fail to ucsdet_open\n");
+               LOGE("fail to ucsdet_open");
                goto done;
        }
 
        ucsdet_enableInputFilter(ucsd, TRUE);
 
-       buf = g_malloc(1024*1024);
+       buf = g_try_malloc(1024 * 1024);
        if (!buf) {
-               LOGE("fail to alloc\n");
+               LOGE("fail to alloc");
                goto done;
        }
 
@@ -403,19 +401,19 @@ util_get_charset(const char *file_path)
 
        ucsdet_setText(ucsd, buf, strlen(buf), &status);
        if (U_FAILURE(status)) {
-               LOGE("fail to ucsdet_setText\n");
+               LOGE("fail to ucsdet_setText");
                goto done;
        }
 
        ucm = ucsdet_detect(ucsd, &status);
        if (U_FAILURE(status)) {
-               LOGE("fail to ucsdet_detect\n");
+               LOGE("fail to ucsdet_detect");
                goto done;
        }
 
        charset = ucsdet_getName(ucm, &status);
        if (U_FAILURE(status)) {
-               LOGE("fail to ucsdet_getName\n");
+               LOGE("fail to ucsdet_getName");
                goto done;
        }
 
@@ -430,18 +428,18 @@ done:
        if (ucsd)
                ucsdet_close(ucsd);
 
-       if (buf)
-               g_free(buf);
+       MMPLAYER_FREEIF(buf);
 
        return charset;
 }
 
-int util_get_pixtype(unsigned int fourcc)
+int
+util_get_pixtype(unsigned int fourcc)
 {
        int pixtype = MM_PIXEL_FORMAT_INVALID;
 
     /*
-       char *pfourcc = (char*)&fourcc;
+       char *pfourcc = (char *)&fourcc;
 
        LOGD("fourcc(%c%c%c%c)",
                pfourcc[0], pfourcc[1], pfourcc[2], pfourcc[3]);
@@ -510,7 +508,8 @@ int util_get_pixtype(unsigned int fourcc)
        return pixtype;
 }
 
-static int _util_storage_supported_cb(int storage_id, storage_type_e type,
+static int
+_util_storage_supported_cb(int storage_id, storage_type_e type,
        storage_state_e state, const char *path, void *user_data)
 {
        MMPlayerStorageInfo *storage_info = (MMPlayerStorageInfo *)user_data;
@@ -526,7 +525,8 @@ static int _util_storage_supported_cb(int storage_id, storage_type_e type,
        return TRUE;
 }
 
-bool util_get_storage_info(const char *path, MMPlayerStorageInfo *storage_info)
+bool
+util_get_storage_info(const char *path, MMPlayerStorageInfo *storage_info)
 {
        int ret = 0;
        const char *file_path = path;
@@ -534,7 +534,7 @@ bool util_get_storage_info(const char *path, MMPlayerStorageInfo *storage_info)
        MMPLAYER_RETURN_VAL_IF_FAIL(file_path && storage_info, false);
 
        if (strncmp(file_path, "file://", strlen("file://")) == 0)
-               file_path = path+7; /* remove file prefix */
+               file_path = path + 7; /* remove file prefix */
 
        if (strncmp(file_path, MEDIA_PATH_EXTERNAL, strlen(MEDIA_PATH_EXTERNAL)) == 0) {
                storage_info->type = STORAGE_TYPE_EXTERNAL;