update code by Tizen coding convention 08/41008/1
authorji.yong.seo <ji.yong.seo@samsung.com>
Thu, 11 Jun 2015 00:53:21 +0000 (09:53 +0900)
committerji.yong.seo <ji.yong.seo@samsung.com>
Thu, 11 Jun 2015 00:53:55 +0000 (09:53 +0900)
Change-Id: Id832e3e10a4161133f7a27b8100b84d17d88e90d

include/thumbnail_util_private.h
packaging/capi-media-thumbnail-util.spec
src/thumbnail_util.c
test/thumbnail_util_test.c

index 2295401..f2de470 100755 (executable)
@@ -45,8 +45,7 @@ extern "C" {
 #define SAFE_FREE(src)         {if(src) {free(src); src = NULL;}}
 #define STRING_VALID(str)              ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
 
-typedef struct
-{
+typedef struct {
        int request_id;
        char *file_path;
        int dst_width;
@@ -55,8 +54,7 @@ typedef struct
        unsigned char *thumb_data;
 }thumbnail_s;
 
-typedef struct
-{
+typedef struct {
        thumbnail_s *handle;
        thumbnail_extracted_cb thumb_extract_cb;
        void *user_data;
@@ -74,39 +72,39 @@ typedef struct
 #define thumbnail_util_gettid() syscall(__NR_gettid)
 
 #define thumbnail_util_retv_if(expr, val) do { \
-                       if(expr) { \
-                               LOGE(FONT_COLOR_RED"[%d]", media_content_gettid());    \
-                               return (val); \
-                       } \
-               } while (0)
+               if(expr) { \
+                       LOGE(FONT_COLOR_RED"[%d]", media_content_gettid());    \
+                       return (val); \
+               } \
+       } while (0)
 
 #define thumbnail_util_debug(fmt, arg...) do { \
-                       LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg);     \
-               } while (0)
+               LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg);     \
+       } while (0)
 
 #define thumbnail_util_info(fmt, arg...) do { \
-                       LOGI(FONT_COLOR_GREEN"[%d]"fmt"", thumbnail_util_gettid() ,##arg);     \
-               } while (0)
+               LOGI(FONT_COLOR_GREEN"[%d]"fmt"", thumbnail_util_gettid() ,##arg);     \
+       } while (0)
 
 #define thumbnail_util_error(fmt, arg...) do { \
-                       LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
-               } while (0)
+               LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
+       } while (0)
 
 #define thumbnail_util_debug_func() do { \
-                       LOGD(FONT_COLOR_RESET"[%d]", thumbnail_util_gettid());     \
-               } while (0)
+               LOGD(FONT_COLOR_RESET"[%d]", thumbnail_util_gettid());     \
+       } while (0)
 
 #define thumbnail_util_sec_debug(fmt, arg...) do { \
-                       SECURE_LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg);     \
-               } while (0)
+               SECURE_LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg);     \
+       } while (0)
 
 #define thumbnail_util_sec_warn(fmt, arg...) do { \
-                       SECURE_LOGW(FONT_COLOR_GREEN"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
-               } while (0)
+               SECURE_LOGW(FONT_COLOR_GREEN"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
+       } while (0)
 
 #define thumbnail_util_sec_error(fmt, arg...) do { \
-                       SECURE_LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
-               } while (0)
+               SECURE_LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
+       } while (0)
 
 #ifdef __cplusplus
 }
index a8e7510..cb2945c 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-thumbnail-util
 Summary:    A media thumbnail util library in SLP C API
-Version: 0.1.0
+Version: 0.1.1
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0
index 181d372..65c7de1 100755 (executable)
@@ -34,11 +34,10 @@ void __thumbnail_util_extract_completed_cb(int error, int request_id, const char
        thumbnail_extract_cb_s *_thumb_cb = (thumbnail_extract_cb_s *)user_data;
        char *request_id_str = NULL;
 
-       if(_thumb_cb != NULL)
-       {
-               //media_content_debug("error [%d], thumbnail_size [%d]", error, thumb_size);
+       if (_thumb_cb != NULL) {
+               /*media_content_debug("error [%d], thumbnail_size [%d]", error, thumb_size); */
                __thumbnail_util_convert_itoa(request_id, &request_id_str);
-               if (_thumb_cb->thumb_extract_cb){
+               if (_thumb_cb->thumb_extract_cb) {
                        _thumb_cb->thumb_extract_cb(error, request_id_str, thumb_width, thumb_height, thumb_data, thumb_size, _thumb_cb->user_data);
                }
        }
@@ -49,15 +48,13 @@ int thumbnail_util_create(thumbnail_h *thumb)
 {
        int ret = THUMBNAIL_UTIL_ERROR_NONE;
 
-       if(thumb == NULL)
-       {
+       if (thumb == NULL) {
                thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
                return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
        }
 
-       thumbnail_s *_thumb = (thumbnail_s*)malloc(sizeof(thumbnail_s));
-       if(_thumb == NULL)
-       {
+       thumbnail_s *_thumb = (thumbnail_s *)malloc(sizeof(thumbnail_s));
+       if (_thumb == NULL) {
                thumbnail_util_error("OUT_OF_MEMORY(0x%08x)", THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY);
                return THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY;
        }
@@ -78,28 +75,24 @@ int thumbnail_util_extract(thumbnail_h thumb, thumbnail_extracted_cb callback, v
 {
        int ret = THUMBNAIL_UTIL_ERROR_NONE;
        static int g_thumbnail_req_id = 0;
-       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+       thumbnail_s *_thumb = (thumbnail_s *)thumb;
 
-       if(_thumb != NULL && STRING_VALID(_thumb->file_path))
-       {
+       if (_thumb != NULL && STRING_VALID(_thumb->file_path)) {
                g_thumbnail_req_id++;
                _thumb->request_id = g_thumbnail_req_id;
                __thumbnail_util_convert_itoa(_thumb->request_id, request_id);
-               thumbnail_extract_cb_s *_thumb_cb = (thumbnail_extract_cb_s*)calloc(1, sizeof(thumbnail_extract_cb_s));
+               thumbnail_extract_cb_s *_thumb_cb = (thumbnail_extract_cb_s *)calloc(1, sizeof(thumbnail_extract_cb_s));
                _thumb_cb->handle = _thumb;
                _thumb_cb->user_data = user_data;
-               _thumb_cb->thumb_extract_cb= callback;
+               _thumb_cb->thumb_extract_cb = callback;
 
-               if(_thumb->dst_width == 0 || _thumb->dst_height == 0)
-               {
+               if (_thumb->dst_width == 0 || _thumb->dst_height == 0) {
                        _thumb->dst_width = 320;
                        _thumb->dst_height = 240;
                }
 
                ret = thumbnail_request_extract_raw_data_async(_thumb->request_id, _thumb->file_path, _thumb->dst_width, _thumb->dst_height, (ThumbRawFunc)__thumbnail_util_extract_completed_cb, (void *)_thumb_cb);
-       }
-       else
-       {
+       } else {
                thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
                ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -110,16 +103,13 @@ int thumbnail_util_extract(thumbnail_h thumb, thumbnail_extracted_cb callback, v
 int thumbnail_util_set_path(thumbnail_h thumb, const char *path)
 {
        int ret = THUMBNAIL_UTIL_ERROR_NONE;
-       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+       thumbnail_s *_thumb = (thumbnail_s *)thumb;
 
-       if(_thumb != NULL && path != NULL)
-       {
-               if(_thumb->file_path)
+       if (_thumb != NULL && path != NULL) {
+               if (_thumb->file_path)
                        SAFE_FREE(_thumb->file_path);
                _thumb->file_path = strndup(path, strlen(path));
-       }
-       else
-       {
+       } else {
                thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
                ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -130,15 +120,12 @@ int thumbnail_util_set_path(thumbnail_h thumb, const char *path)
 int thumbnail_util_set_size(thumbnail_h thumb, int width, int height)
 {
        int ret = THUMBNAIL_UTIL_ERROR_NONE;
-       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+       thumbnail_s *_thumb = (thumbnail_s *)thumb;
 
-       if(_thumb != NULL && width > 0 && height > 0)
-       {
+       if (_thumb != NULL && width > 0 && height > 0) {
                _thumb->dst_width = width;
                _thumb->dst_height = height;
-       }
-       else
-       {
+       } else {
                thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
                ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -149,15 +136,12 @@ int thumbnail_util_set_size(thumbnail_h thumb, int width, int height)
 int thumbnail_util_cancel(thumbnail_h thumb, const char *request_id)
 {
        int ret = THUMBNAIL_UTIL_ERROR_NONE;
-       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+       thumbnail_s *_thumb = (thumbnail_s *)thumb;
 
-       if(_thumb != NULL && STRING_VALID(request_id))
-       {
+       if (_thumb != NULL && STRING_VALID(request_id)) {
                unsigned int request_id_integer = atoi(request_id);
                ret = thumbnail_request_cancel_raw_data(request_id_integer);
-       }
-       else
-       {
+       } else {
                thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
                ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -168,14 +152,11 @@ int thumbnail_util_cancel(thumbnail_h thumb, const char *request_id)
 int thumbnail_util_cancel_all(thumbnail_h thumb)
 {
        int ret = THUMBNAIL_UTIL_ERROR_NONE;
-       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+       thumbnail_s *_thumb = (thumbnail_s *)thumb;
 
-       if(_thumb != NULL)
-       {
+       if (_thumb != NULL) {
                ret = thumbnail_request_cancel_all(true);
-       }
-       else
-       {
+       } else {
                thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
                ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
        }
@@ -187,16 +168,13 @@ int thumbnail_util_cancel_all(thumbnail_h thumb)
 int thumbnail_util_destroy(thumbnail_h thumb)
 {
        int ret = THUMBNAIL_UTIL_ERROR_NONE;
-       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+       thumbnail_s *_thumb = (thumbnail_s *)thumb;
 
-       if(_thumb)
-       {
+       if (_thumb) {
                SAFE_FREE(_thumb->file_path);
                SAFE_FREE(_thumb->thumb_data);
                SAFE_FREE(_thumb);
-       }
-       else
-       {
+       } else {
                thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
                ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
        }
index babc915..4caecd7 100755 (executable)
 GMainLoop *g_loop = NULL;
 char *g_id = NULL;
 
-void thumbnail_completed_cb(thumbnail_util_error_e error, const char *request_id, int raw_width, int raw_height, unsigned char *raw_data, int raw_size, void*user_data)
+void thumbnail_completed_cb(thumbnail_util_error_e error, const char *request_id, int raw_width, int raw_height, unsigned char *raw_data, int raw_size, void *user_data)
 {
 #if 0
        FILE *fp;
-       fp = fopen( "test.raw", "w");
-    fwrite(raw_data, 1, raw_size, fp);
+       fp = fopen("test.raw", "w");
+       fwrite(raw_data, 1, raw_size, fp);
        fclose(fp);
 #endif
        thumbnail_util_debug("=================[RESULT]");
@@ -41,7 +41,7 @@ void thumbnail_completed_cb(thumbnail_util_error_e error, const char *request_id
        thumbnail_util_debug("width [%d], height [%d]", raw_width, raw_height);
        thumbnail_util_debug("raw_data [0x%x], size [%d]", *raw_data, raw_size);
 
-       if(strncmp(request_id, "50", 2) == 0)
+       if (strncmp(request_id, "50", 2) == 0)
                g_main_loop_quit(g_loop);
 }
 
@@ -65,7 +65,7 @@ gboolean extract_thumbnail_start(gpointer data)
 
        for (i = 0; i < 50; i++) {
                char filepath[255] = {0,};
-               snprintf(filepath, sizeof(filepath), "%s%d.jpg", "/opt/usr/media/Images/test_image", i+1);
+               snprintf(filepath, sizeof(filepath), "%s%d.jpg", "/opt/usr/media/Images/test_image", i + 1);
                thumbnail_util_debug("File : %s\n", filepath);
                thumbnail_util_set_path(test_info, filepath);
                ret = thumbnail_util_extract(test_info, thumbnail_completed_cb, test_info, &g_id);
@@ -75,12 +75,12 @@ gboolean extract_thumbnail_start(gpointer data)
        thumbnail_h test_info;
        thumbnail_util_create(&test_info);
        thumbnail_util_set_path(test_info, "/opt/usr/media/Images/test_image1.jpg");
-       //thumbnail_util_set_size(test_info, 511, 288);
+       /*thumbnail_util_set_size(test_info, 511, 288); */
        ret = thumbnail_util_extract(test_info, thumbnail_completed_cb, test_info, &g_id);
 #endif
        thumbnail_util_destroy(test_info);
 
-       if(ret == THUMBNAIL_UTIL_ERROR_NONE)
+       if (ret == THUMBNAIL_UTIL_ERROR_NONE)
                thumbnail_util_debug("extract raw data is success");
        else
                thumbnail_util_error("extract raw data is failed");
@@ -97,7 +97,7 @@ gboolean cancel_all(gpointer data)
 #if 0
        ret = thumbnail_util_cancel_all(_media_thumb);
 
-       if(ret == THUMBNAIL_UTIL_ERROR_NONE)
+       if (ret == THUMBNAIL_UTIL_ERROR_NONE)
                thumbnail_util_debug("thumbnail_util_cancel_all is success");
        else
                thumbnail_util_error("thumbnail_util_cancel_all is failed");
@@ -108,7 +108,7 @@ gboolean cancel_all(gpointer data)
        for (i = num - 20; i < num; i++) {
                __convert_i_to_a(i, &req_str);
                ret = thumbnail_util_cancel(_media_thumb, req_str);
-               if(ret == THUMBNAIL_UTIL_ERROR_NONE)
+               if (ret == THUMBNAIL_UTIL_ERROR_NONE)
                        thumbnail_util_debug("thumbnail_util_cancel[%d] is success", i);
                else
                        thumbnail_util_error("thumbnail_util_cancel[%d] is failed", i);
@@ -128,15 +128,15 @@ int test_extract_thumbnail(bool cancel)
        g_loop = g_main_loop_new(NULL, false);
        context = g_main_loop_get_context(g_loop);
        source = g_idle_source_new();
-       g_source_set_callback (source, extract_thumbnail_start, NULL, NULL);
-       g_source_attach (source, context);
+       g_source_set_callback(source, extract_thumbnail_start, NULL, NULL);
+       g_source_attach(source, context);
 
        /* Logic to cancel */
        if (cancel) {
                GSource *cancel_src = NULL;
                cancel_src = g_idle_source_new();
-               g_source_set_callback (cancel_src, cancel_all, NULL, NULL);
-               g_source_attach (cancel_src, context);
+               g_source_set_callback(cancel_src, cancel_all, NULL, NULL);
+               g_source_attach(cancel_src, context);
        }
 
        g_main_loop_run(g_loop);
@@ -152,7 +152,7 @@ int main(int argc, char *argv[])
        thumbnail_util_debug("--- Thumbnail util test start ---\n\n");
 
        ret = test_extract_thumbnail(false);
-       if(ret != THUMBNAIL_UTIL_ERROR_NONE)
+       if (ret != THUMBNAIL_UTIL_ERROR_NONE)
                return ret;
 
        thumbnail_util_debug("--- Thumbnail util test end ---\n");