Remove libmedia-utils dependency 22/304822/5
authorminje.ahn <minje.ahn@samsung.com>
Wed, 24 Jan 2024 04:36:17 +0000 (13:36 +0900)
committerminje.ahn <minje.ahn@samsung.com>
Fri, 26 Jan 2024 05:30:42 +0000 (14:30 +0900)
Change-Id: Ie55e139042f1a3508f58ddc769bfaadf2724d671
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
CMakeLists.txt
include/media-thumbnail-debug.h
include/media-thumbnail.h
packaging/libmedia-thumbnail.spec
src/media-thumbnail.c

index 41534a0..6b0f10e 100644 (file)
@@ -28,10 +28,10 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 
 IF(WITH_DA_PROFILE)
 INCLUDE(FindPkgConfig)
-       pkg_check_modules(pkgs REQUIRED glib-2.0 dlog mm-fileinfo aul libmedia-utils libtzplatform-config mmutil-common mmutil-magick mmutil-gif mmutil-jpeg libexif)
+       pkg_check_modules(pkgs REQUIRED glib-2.0 dlog mm-fileinfo aul mmutil-common mmutil-magick mmutil-gif mmutil-jpeg libexif)
 ELSE(WITH_DA_PROFILE)
 INCLUDE(FindPkgConfig)
-       pkg_check_modules(pkgs REQUIRED glib-2.0 dlog mm-fileinfo aul libmedia-utils libtzplatform-config mmutil-common mmutil-magick)
+       pkg_check_modules(pkgs REQUIRED glib-2.0 dlog mm-fileinfo aul mmutil-common mmutil-magick)
 ENDIF(WITH_DA_PROFILE)
 
 FOREACH(flag ${pkgs_CFLAGS})
index d26971e..4bdbd45 100755 (executable)
@@ -20,8 +20,6 @@
 #ifndef _MEDIA_THUMBNAIL_DEBUG_H_
 #define _MEDIA_THUMBNAIL_DEBUG_H_
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <dlog.h>
 #include <unistd.h>
 
 #define FONT_COLOR_RESET    "\033[0m"
 #define FONT_COLOR_RED      "\033[31m"
 #define FONT_COLOR_GREEN    "\033[32m"
-#define FONT_COLOR_YELLOW   "\033[33m"
-#define FONT_COLOR_BLUE     "\033[34m"
-#define FONT_COLOR_PURPLE   "\033[35m"
-#define FONT_COLOR_CYAN     "\033[36m"
-#define FONT_COLOR_GRAY     "\033[37m"
 
 #define thumb_dbg(fmt, arg...) do { \
                LOGD(FONT_COLOR_RESET fmt "\n", ##arg); \
                 LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
                } while (0)
 
-#define thumb_dbg_slog(fmt, arg...)    do { \
-               SECURE_LOGD(FONT_COLOR_CYAN""fmt""FONT_COLOR_RESET, ##arg); \
-               } while (0)
-
-#define thumb_warn_slog(fmt, arg...)   do { \
-               SECURE_LOGW(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
-               } while (0)
-
-#define thumb_err_slog(fmt, arg...) do { \
-               SECURE_LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
-               } while (0)
-
 #define thumb_retm_if(expr, fmt, arg...) do { \
                                if (expr) { \
                                        LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
index f90f8a1..af87ff7 100755 (executable)
 #ifndef _MEDIA_THUMBNAIL_H_
 #define _MEDIA_THUMBNAIL_H_
 
-#include <sys/types.h>
 #include <stdbool.h>
-#include <fcntl.h>
+#include <stddef.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define THUMB_STRING_VALID(str)        ((str != NULL && strlen(str) > 0) ? true : false)
+/* media-thumbnail error */
+#define THUMB_OK 0
+#define THUMB_FAIL -1
+#define THUMB_PERM -2
+#define THUMB_UNSUPPORTED -3
 
 int create_video_thumbnail_to_file(const char *path, unsigned int width, unsigned int height, const char *thumb_path, bool auto_rotate);
 int create_video_thumbnail_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height);
index 11a1f2d..5c10e70 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmedia-thumbnail
 Summary:    Media thumbnail service library for multimedia applications
-Version:    0.4.5
+Version:    0.4.6
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
@@ -12,8 +12,6 @@ BuildRequires: cmake
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(mm-fileinfo)
 BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(libmedia-utils)
-BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(mmutil-common)
 BuildRequires: pkgconfig(mmutil-magick)
 %if 0%{?gtests:1}
index 88d80fe..4473f59 100755 (executable)
  *
  */
 
-#include <mm_file.h>
-#include <mm_util_magick.h>
-#include <media-util.h>
 #include "media-thumbnail.h"
 #include "media-thumbnail-debug.h"
+
 #include <aul.h>
+#include <mm_file.h>
+#include <mm_util_magick.h>
 #if defined(USE_MEMORY_USAGE_REDUCTION)
 #include <mm_util_gif.h>
 #include <mm_util_jpeg.h>
 #include <libexif/exif-data.h>
 #endif
 
-
 #define MAX_THUMB_SIZE 2000
 #define MIME_TYPE_TIFF "image/tiff"
 #define MIME_TYPE_ASF "application/vnd.ms-asf"
@@ -43,7 +42,7 @@ typedef enum {
 
 static void __get_rotation(const char *path, mm_util_rotate_type_e *rot_type)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = FILEINFO_ERROR_NONE;
        MMHandleType tag = (MMHandleType) NULL;
        char *p = NULL;
        int size = 0;
@@ -75,7 +74,7 @@ static void __get_rotation(const char *path, mm_util_rotate_type_e *rot_type)
 
 static int __get_video_meta(const char *path, int *video_track_num, unsigned int *width, unsigned int *height, void **frame, size_t *frame_size)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = FILEINFO_ERROR_NONE;
        MMHandleType content = (MMHandleType) NULL;
        int _video_track_num = 0;
        unsigned int _width = 0;
@@ -84,7 +83,7 @@ static int __get_video_meta(const char *path, int *video_track_num, unsigned int
        void *_frame = NULL;
 
        err = mm_file_create_content_attrs(&content, path);
-       thumb_retvm_if(err != FILEINFO_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_file_create_content_attrs fails : %d", err);
+       thumb_retvm_if(err != FILEINFO_ERROR_NONE, THUMB_FAIL, "mm_file_create_content_attrs fails : %d", err);
 
        err = mm_file_get_attrs(content,
                                MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &_video_track_num,
@@ -96,20 +95,20 @@ static int __get_video_meta(const char *path, int *video_track_num, unsigned int
        if (err != FILEINFO_ERROR_NONE) {
                thumb_err("mm_file_get_attrs fails : %d", err);
                mm_file_destroy_content_attrs(content);
-               return MS_MEDIA_ERR_INTERNAL;
+               return THUMB_FAIL;
        }
 
        *video_track_num = _video_track_num;
 
        if (_video_track_num == 0) {
                mm_file_destroy_content_attrs(content);
-               return MS_MEDIA_ERR_NONE;
+               return THUMB_OK;
        }
 
        if (!_frame || !_width || !_height) {
                thumb_err("wrong video info W[%d] H[%d] Size[%zu] Frame[%p]", _width, _height, _frame_size, _frame);
                mm_file_destroy_content_attrs(content);
-               return MS_MEDIA_ERR_INTERNAL;
+               return THUMB_FAIL;
        }
 
        *width = _width;
@@ -119,13 +118,12 @@ static int __get_video_meta(const char *path, int *video_track_num, unsigned int
 
        mm_file_destroy_content_attrs(content);
 
-       return MS_MEDIA_ERR_NONE;
+       return THUMB_OK;
 }
 
-
 static int __get_video_info(const char *path, int *video_track_num, unsigned int *width, unsigned int *height, void **frame, size_t *frame_size, mm_util_rotate_type_e *rot_type)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = THUMB_OK;
        mm_util_rotate_type_e _rot_type = MM_UTIL_ROTATE_0;
 
        __get_rotation(path, &_rot_type);
@@ -166,19 +164,19 @@ static void __media_thumb_get_proper_thumb_size(unsigned int origin_width, unsig
 
 static int __get_video_thumb_to_file(unsigned int width, unsigned int height, void *frame, size_t frame_size, mm_util_rotate_type_e rot_type, const char *thumb_path, unsigned int thumb_width, unsigned int thumb_height)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = MM_UTIL_ERROR_NONE;
        mm_util_image_h img = NULL;
        mm_util_image_h resize_img = NULL;
        unsigned int thumb_w = thumb_width;
        unsigned int thumb_h = thumb_height;
 
-       thumb_retvm_if(!thumb_path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid thumb_path");
+       thumb_retvm_if(!thumb_path, THUMB_FAIL, "Invalid thumb_path");
 
        __media_thumb_get_proper_thumb_size(width, height, &thumb_w, &thumb_h);
-       thumb_retv_if(thumb_w == 0 || thumb_h == 0, MS_MEDIA_ERR_INTERNAL);
+       thumb_retv_if(thumb_w == 0 || thumb_h == 0, THUMB_FAIL);
 
        err = mm_image_create_image(width, height, MM_UTIL_COLOR_RGB24, (unsigned char *)frame, frame_size, &img);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, err, "fail to mm_image_create_image [%d]", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "fail to mm_image_create_image [%d]", err);
 
        if (width > thumb_w || height > thumb_h) {
                if (rot_type != MM_UTIL_ROTATE_0) {
@@ -202,21 +200,21 @@ ERROR:
        mm_image_destroy_image(img);
        mm_image_destroy_image(resize_img);
 
-       return (err == MM_UTIL_ERROR_NONE) ? MS_MEDIA_ERR_NONE : MS_MEDIA_ERR_INTERNAL;
+       return (err == MM_UTIL_ERROR_NONE) ? THUMB_OK : THUMB_FAIL;
 }
 
 static int __get_video_thumb_to_buffer(unsigned int width, unsigned int height, void *frame, size_t frame_size, unsigned int thumb_width, unsigned int thumb_height, mm_util_image_h *dst_img)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = MM_UTIL_ERROR_NONE;
        mm_util_image_h img = NULL;
        unsigned int thumb_w = thumb_width;
        unsigned int thumb_h = thumb_height;
 
        __media_thumb_get_proper_thumb_size(width, height, &thumb_w, &thumb_h);
-       thumb_retv_if(thumb_w == 0 || thumb_h == 0, MS_MEDIA_ERR_INTERNAL);
+       thumb_retv_if(thumb_w == 0 || thumb_h == 0, THUMB_FAIL);
 
        err = mm_image_create_image(width, height, MM_UTIL_COLOR_RGB24, (unsigned char *)frame, frame_size, &img);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, err, "fail to mm_image_create_image [%d]", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "fail to mm_image_create_image [%d]", err);
 
        if (width > thumb_w || height > thumb_h)
                err = mm_util_resize_B_B(img, thumb_w, thumb_h, dst_img);
@@ -224,42 +222,45 @@ static int __get_video_thumb_to_buffer(unsigned int width, unsigned int height,
                err = mm_image_clone_image(img, dst_img);
        mm_image_destroy_image(img);
 
-       return (err == MM_UTIL_ERROR_NONE) ? MS_MEDIA_ERR_NONE : MS_MEDIA_ERR_INTERNAL;
+       return (err == MM_UTIL_ERROR_NONE) ? THUMB_OK : THUMB_FAIL;
 }
 
 static int __check_path_validity(const char *path)
 {
-       thumb_retvm_if(!path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
+       thumb_retvm_if(!path, THUMB_FAIL, "Invalid path");
 
        if (access(path, R_OK) < 0) {
                if (errno == EACCES || errno == EPERM) {
                        thumb_err("Fail to open path: Permission Denied [%s]", path);
-                       return  MS_MEDIA_ERR_PERMISSION_DENIED;
+                       return  THUMB_PERM;
                } else {
                        thumb_err("Fail to open path: Invalid Path [%s]", path);
-                       return MS_MEDIA_ERR_INVALID_PARAMETER;
+                       return THUMB_FAIL;
                }
        }
 
-       return MS_MEDIA_ERR_NONE;
+       return THUMB_OK;
 }
 
 static int __check_thumb_path_validity(const char *path)
 {
        char *dir_name = NULL;
-       int ret = MS_MEDIA_ERR_NONE;
+       int ret = THUMB_OK;
 
-       thumb_retvm_if(!THUMB_STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
+       if (!path || strlen(path) == 0) {
+               thumb_err("Invalid path");
+               return THUMB_FAIL;
+       }
 
        dir_name = g_path_get_dirname(path);
 
        if (access(dir_name, W_OK) != 0) {
                if (errno == EACCES || errno == EPERM) {
                        thumb_err("No permission to write[%s]", dir_name);
-                       ret = MS_MEDIA_ERR_PERMISSION_DENIED;
+                       ret = THUMB_PERM;
                } else {
                        thumb_err("Does not exists[%s]", dir_name);
-                       ret = MS_MEDIA_ERR_INVALID_PARAMETER;
+                       ret = THUMB_FAIL;
                }
        }
 
@@ -270,27 +271,27 @@ static int __check_thumb_path_validity(const char *path)
 
 static int __check_parameter_validity_for_file(const char *path, unsigned int width, unsigned int height, const char *thumb_path)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = THUMB_OK;
 
-       thumb_retvm_if((width > MAX_THUMB_SIZE || width == 0), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid width[%d]", width);
-       thumb_retvm_if((height > MAX_THUMB_SIZE || height == 0), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid height[%d]", height);
+       thumb_retvm_if((width > MAX_THUMB_SIZE || width == 0), THUMB_FAIL, "Invalid width[%d]", width);
+       thumb_retvm_if((height > MAX_THUMB_SIZE || height == 0), THUMB_FAIL, "Invalid height[%d]", height);
 
        /* Check path is accessible */
        err = __check_path_validity(path);
-       thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "Invalid path");
+       thumb_retvm_if(err != THUMB_OK, err, "Invalid path");
 
        /* Check thumbnail path is writable */
        err = __check_thumb_path_validity(thumb_path);
-       thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "Invalid thumb_path");
+       thumb_retvm_if(err != THUMB_OK, err, "Invalid thumb_path");
 
-       return MS_MEDIA_ERR_NONE;
+       return THUMB_OK;
 }
 
 static int __check_parameter_validity_for_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height)
 {
-       thumb_retvm_if((width > MAX_THUMB_SIZE || width == 0), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid width[%d]", width);
-       thumb_retvm_if((height > MAX_THUMB_SIZE || height == 0), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid height[%d]", height);
-       thumb_retvm_if(!thumb_buffer || !thumb_size || !thumb_width || !thumb_height, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid out param");
+       thumb_retvm_if((width > MAX_THUMB_SIZE || width == 0), THUMB_FAIL, "Invalid width[%d]", width);
+       thumb_retvm_if((height > MAX_THUMB_SIZE || height == 0), THUMB_FAIL, "Invalid height[%d]", height);
+       thumb_retvm_if(!thumb_buffer || !thumb_size || !thumb_width || !thumb_height, THUMB_FAIL, "Invalid out param");
 
        //Check path is accessible
        return __check_path_validity(path);
@@ -298,7 +299,7 @@ static int __check_parameter_validity_for_buffer(const char *path, unsigned int
 
 int create_video_thumbnail_to_file(const char *path, unsigned int width, unsigned int height, const char *thumb_path, bool auto_rotate)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = THUMB_OK;
        int video_track_num = 0;
        unsigned int video_width = 0;
        unsigned int video_height = 0;
@@ -307,12 +308,12 @@ int create_video_thumbnail_to_file(const char *path, unsigned int width, unsigne
        mm_util_rotate_type_e rot_type = MM_UTIL_ROTATE_NUM;
 
        err = __check_parameter_validity_for_file(path, width, height, thumb_path);
-       thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "Invalid parameter");
+       thumb_retvm_if(err != THUMB_OK, err, "Invalid parameter");
 
        //Get video info
        err = __get_video_info(path, &video_track_num, &video_width, &video_height, &frame, &frame_size, &rot_type);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, err, "fail to __get_video_info [%d]", err);
-       thumb_retvm_if(video_track_num == 0, MM_UTIL_ERROR_NONE, "No video track");
+       thumb_retvm_if(err != THUMB_OK, err, "fail to __get_video_info [%d]", err);
+       thumb_retvm_if(video_track_num == 0, THUMB_OK, "No video track");
 
        if (!auto_rotate)
                rot_type = MM_UTIL_ROTATE_0;
@@ -332,7 +333,7 @@ int create_video_thumbnail_to_buffer(const char *path,
                                                                unsigned int *thumb_width,
                                                                unsigned int *thumb_height)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = THUMB_OK;
        int video_track_num = 0;
        unsigned int video_w = 0;
        unsigned int video_h = 0;
@@ -341,29 +342,29 @@ int create_video_thumbnail_to_buffer(const char *path,
        mm_util_image_h img = NULL;
 
        err = __check_parameter_validity_for_buffer(path, width, height, thumb_buffer, thumb_size, thumb_width, thumb_height);
-       thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "Invalid parameter");
+       thumb_retvm_if(err != THUMB_OK, err, "Invalid parameter");
 
        //Get video info
        err = __get_video_info(path, &video_track_num, &video_w, &video_h, &frame, &frame_size, NULL);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, err, "fail to __get_video_info [%d]", err);
-       thumb_retvm_if(video_track_num == 0, MM_UTIL_ERROR_NONE, "No video track");
+       thumb_retvm_if(err != THUMB_OK, err, "fail to __get_video_info [%d]", err);
+       thumb_retvm_if(video_track_num == 0, THUMB_OK, "No video track");
 
        //Extract thumbnail
        err = __get_video_thumb_to_buffer(video_w, video_h, frame, frame_size, width, height, &img);
        g_free(frame);
-       if (err != MS_MEDIA_ERR_NONE)
+       if (err != THUMB_OK)
                return err;
 
        err = mm_image_get_image(img, thumb_width, thumb_height, NULL, thumb_buffer, thumb_size);
        mm_image_destroy_image(img);
 
-       return err;
+       return (err == MM_UTIL_ERROR_NONE) ? THUMB_OK : THUMB_FAIL;
 }
 
 static int __adjust_thumb_ratio(const char *path, unsigned int *width, unsigned int *height,
                                unsigned int *image_w, unsigned int *image_h, mm_util_img_codec_type *image_type)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = MM_UTIL_ERROR_NONE;
 #if defined(ENABLE_IMAGE_SIZE_LIMITATION)
        const size_t image_size_limit[IMG_CODEC_UNKNOWN_TYPE] = {
                [IMG_CODEC_JPEG] = (4096 * 4096),
@@ -373,8 +374,8 @@ static int __adjust_thumb_ratio(const char *path, unsigned int *width, unsigned
 #endif
 
        err = mm_util_extract_image_info(path, image_type, image_w, image_h);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_extract_image_info: %d", err);
-       thumb_retvm_if(*image_type == IMG_CODEC_UNKNOWN_TYPE, MS_MEDIA_ERR_THUMB_UNSUPPORTED, "Unsupported image codec");
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_extract_image_info: %d", err);
+       thumb_retvm_if(*image_type == IMG_CODEC_UNKNOWN_TYPE, THUMB_UNSUPPORTED, "Unsupported image codec");
 
 #if defined(ENABLE_IMAGE_SIZE_LIMITATION)
        if ((*image_type == IMG_CODEC_JPEG) ||
@@ -382,12 +383,12 @@ static int __adjust_thumb_ratio(const char *path, unsigned int *width, unsigned
                (*image_type == IMG_CODEC_GIF))
                if ((size_t)((*image_w) * (*image_h)) > image_size_limit[*image_type]) {
                        thumb_err("Unsupported image size [%u x %u] limit [%zu]", *image_w, *image_h, image_size_limit[*image_type]);
-                       return MS_MEDIA_ERR_UNSUPPORTED_CONTENT;
+                       return THUMB_UNSUPPORTED;
                }
 #endif
        __media_thumb_get_proper_thumb_size(*image_w, *image_h, width, height);
 
-       return MS_MEDIA_ERR_NONE;
+       return THUMB_OK;
 }
 
 #if defined(USE_MEMORY_USAGE_REDUCTION)
@@ -438,37 +439,37 @@ static mm_util_rotate_type_e __get_image_orientation(const char *path)
 
 static int __create_gif_thumbnail_to_file(const char *path, unsigned int thumb_w, unsigned int thumb_h, const char *thumb_path)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = MM_UTIL_ERROR_NONE;
        mm_util_image_h decode_image = NULL;
 
        err = mm_util_decode_from_gif_file(path, &decode_image);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_decode_from_gif_file failed : %d", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_decode_from_gif_file failed : %d", err);
 
        err = mm_util_resize_B_P(decode_image, thumb_w, thumb_h, thumb_path);
        mm_image_destroy_image(decode_image);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_resize_B_P failed : %d", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_resize_B_P failed : %d", err);
 
-       return MS_MEDIA_ERR_NONE;
+       return THUMB_OK;
 }
 
 static int __create_gif_thumbnail_to_buffer(const char *path, unsigned int thumb_w, unsigned int thumb_h, mm_util_image_h *thumbnail)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = MM_UTIL_ERROR_NONE;
        mm_util_image_h decode_image = NULL;
        mm_util_image_h rgba_thumbnail = NULL;
 
        err = mm_util_decode_from_gif_file(path, &decode_image);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_decode_from_gif_file failed : %d", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_decode_from_gif_file failed : %d", err);
 
        err = mm_util_resize_B_B(decode_image, thumb_w, thumb_h, &rgba_thumbnail);
        mm_image_destroy_image(decode_image);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_resize_B_B failed : %d", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_resize_B_B failed : %d", err);
 
        err = mm_util_convert_B_B(rgba_thumbnail, MM_UTIL_COLOR_BGRA, thumbnail);
        mm_image_destroy_image(rgba_thumbnail);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_convert_B_B failed : %d", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_convert_B_B failed : %d", err);
 
-       return MS_MEDIA_ERR_NONE;
+       return THUMB_OK;
 }
 
 static int __decode_jpeg_with_downscale(const char *path, size_t image_size, size_t thumb_size, mm_util_image_h *decode_image)
@@ -490,50 +491,50 @@ static int __decode_jpeg_with_downscale(const char *path, size_t image_size, siz
 
 static int __create_jpeg_thumbnail_to_file(const char *path, size_t image_size, unsigned int thumb_w, unsigned int thumb_h, const char *thumb_path, bool auto_rotate)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = MM_UTIL_ERROR_NONE;
        mm_util_image_h decode_image = NULL;
        mm_util_image_h resize_image = NULL;
        mm_util_rotate_type_e rotation = __get_image_orientation(path);
 
        err = __decode_jpeg_with_downscale(path, image_size, (size_t)(thumb_w * thumb_h), &decode_image);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_decode_from_jpeg_file failed : %d", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_decode_from_jpeg_file failed : %d", err);
 
        if (auto_rotate && (rotation != MM_UTIL_ROTATE_0)) {
                err = mm_util_resize_B_B(decode_image, thumb_w, thumb_h, &resize_image);
                mm_image_destroy_image(decode_image);
-               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_resize_B_B failed : %d", err);
+               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_resize_B_B failed : %d", err);
 
                err = mm_util_rotate_B_P(resize_image, rotation, thumb_path);
                mm_image_destroy_image(resize_image);
-               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_rotate_B_P failed : %d", err);
+               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_rotate_B_P failed : %d", err);
        } else {
                err = mm_util_resize_B_P(decode_image, thumb_w, thumb_h, thumb_path);
                mm_image_destroy_image(decode_image);
-               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_resize_B_P failed : %d", err);
+               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_resize_B_P failed : %d", err);
        }
 
-       return MS_MEDIA_ERR_NONE;
+       return THUMB_OK;
 }
 
 static int __create_jpeg_thumbnail_to_buffer(const char *path, size_t image_size, unsigned int thumb_w, unsigned int thumb_h, mm_util_image_h *thumbnail)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = MM_UTIL_ERROR_NONE;
        mm_util_image_h decode_image = NULL;
 
        err = __decode_jpeg_with_downscale(path, image_size, (size_t)(thumb_w * thumb_h), &decode_image);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_decode_from_jpeg_file failed : %d", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_decode_from_jpeg_file failed : %d", err);
 
        err = mm_util_resize_B_B(decode_image, thumb_w, thumb_h, thumbnail);
        mm_image_destroy_image(decode_image);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_resize_B_B failed : %d", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_resize_B_B failed : %d", err);
 
-       return MS_MEDIA_ERR_NONE;
+       return THUMB_OK;
 }
 #endif
 
 int create_image_thumbnail_to_file(const char *path, unsigned int width, unsigned int height, const char *thumb_path, bool auto_rotate)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = THUMB_OK;
        unsigned int image_w = 0;
        unsigned int image_h = 0;
        unsigned int thumb_w = width;
@@ -541,10 +542,10 @@ int create_image_thumbnail_to_file(const char *path, unsigned int width, unsigne
        mm_util_img_codec_type image_type = 0;
 
        err = __check_parameter_validity_for_file(path, width, height, thumb_path);
-       thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "Invalid parameter");
+       thumb_retvm_if(err != THUMB_OK, err, "Invalid parameter");
 
        err = __adjust_thumb_ratio(path, &thumb_w, &thumb_h, &image_w, &image_h, &image_type);
-       thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "__adjust_thumb_ratio failed");
+       thumb_retvm_if(err != THUMB_OK, err, "__adjust_thumb_ratio failed");
 
 #if defined(USE_MEMORY_USAGE_REDUCTION)
        if (image_type == IMG_CODEC_GIF)
@@ -557,14 +558,14 @@ int create_image_thumbnail_to_file(const char *path, unsigned int width, unsigne
                err = mm_util_resize_and_rotate_P_P(path, thumb_w, thumb_h, thumb_path);
        else
                err = mm_util_resize_P_P(path, thumb_w, thumb_h, thumb_path);
-       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_resize_P_P failed : %d", err);
+       thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_resize_P_P failed : %d", err);
 
-       return MS_MEDIA_ERR_NONE;
+       return THUMB_OK;
 }
 
 int create_image_thumbnail_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height)
 {
-       int err = MS_MEDIA_ERR_NONE;
+       int err = THUMB_OK;
        unsigned int image_w = 0;
        unsigned int image_h = 0;
        unsigned int thumb_w = width;
@@ -573,71 +574,71 @@ int create_image_thumbnail_to_buffer(const char *path, unsigned int width, unsig
        mm_util_img_codec_type image_type = 0;
 
        err = __check_parameter_validity_for_buffer(path, width, height, thumb_buffer, thumb_size, thumb_width, thumb_height);
-       thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "Invalid parameter");
+       thumb_retvm_if(err != THUMB_OK, err, "Invalid parameter");
 
        err = __adjust_thumb_ratio(path, &thumb_w, &thumb_h, &image_w, &image_h, &image_type);
-       thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "__adjust_thumb_ratio failed");
+       thumb_retvm_if(err != THUMB_OK, err, "__adjust_thumb_ratio failed");
 
 #if defined(USE_MEMORY_USAGE_REDUCTION)
        if (image_type == IMG_CODEC_GIF) {
                err = __create_gif_thumbnail_to_buffer(path, thumb_w, thumb_h, &img);
-               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "__create_gif_thumbnail_to_buffer failed : %d", err);
+               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "__create_gif_thumbnail_to_buffer failed : %d", err);
        } else if (image_type == IMG_CODEC_JPEG) {
                err = __create_jpeg_thumbnail_to_buffer(path, (size_t)(image_w * image_h), thumb_w, thumb_h, &img);
-               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "__create_jpeg_thumbnail_to_buffer failed : %d", err);
+               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "__create_jpeg_thumbnail_to_buffer failed : %d", err);
        } else
 #endif
        {
                err = mm_util_resize_P_B(path, thumb_w, thumb_h, MM_UTIL_COLOR_BGRA, &img);
-               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, MS_MEDIA_ERR_INTERNAL, "mm_util_resize_P_B failed : %d", err);
+               thumb_retvm_if(err != MM_UTIL_ERROR_NONE, THUMB_FAIL, "mm_util_resize_P_B failed : %d", err);
        }
 
        err = mm_image_get_image(img, thumb_width, thumb_height, NULL, thumb_buffer, thumb_size);
 
        mm_image_destroy_image(img);
 
-       return err;
+       return (err == MM_UTIL_ERROR_NONE) ? THUMB_OK : THUMB_FAIL;
 }
 
 static int __get_media_type(const char *path, thumbnail_media_type_e *media_type)
 {
-       int ret = MS_MEDIA_ERR_NONE;
+       int ret = THUMB_OK;
        char mime[MIME_MAX_LEN] = {0,};
 
        ret = __check_path_validity(path);
-       thumb_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+       thumb_retv_if(ret != THUMB_OK, ret);
 
        ret = aul_get_mime_from_file(path, mime, MIME_MAX_LEN);
-       thumb_retvm_if(ret < 0, MS_MEDIA_ERR_INTERNAL, "aul_get_mime_from_file failed");
+       thumb_retvm_if(ret < 0, THUMB_FAIL, "aul_get_mime_from_file failed");
 
        thumb_dbg("mime type : %s", mime);
 
        if (strstr(mime, "image") != NULL) {
-               thumb_retvm_if(!strcmp(mime, MIME_TYPE_TIFF), MS_MEDIA_ERR_THUMB_UNSUPPORTED, "Unsupported type");
+               thumb_retvm_if(!strcmp(mime, MIME_TYPE_TIFF), THUMB_UNSUPPORTED, "Unsupported type");
                *media_type = MEDIA_THUMB_IMAGE;
-               return MS_MEDIA_ERR_NONE;
+               return THUMB_OK;
        }
 
        if (strstr(mime, "video") != NULL) {
                *media_type = MEDIA_THUMB_VIDEO;
-               return MS_MEDIA_ERR_NONE;
+               return THUMB_OK;
        }
 
        if (strcmp(mime, MIME_TYPE_ASF) == 0) {
                *media_type = MEDIA_THUMB_VIDEO;
-               return MS_MEDIA_ERR_NONE;
+               return THUMB_OK;
        }
 
-       return MS_MEDIA_ERR_THUMB_UNSUPPORTED;
+       return THUMB_UNSUPPORTED;
 }
 
 int create_thumbnail_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height)
 {
-       int ret = MS_MEDIA_ERR_NONE;
+       int ret = THUMB_OK;
        thumbnail_media_type_e type = MEDIA_THUMB_INVALID;
 
        ret = __get_media_type(path, &type);
-       thumb_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "__get_media_type failed");
+       thumb_retvm_if(ret != THUMB_OK, ret, "__get_media_type failed");
 
        if (type == MEDIA_THUMB_IMAGE)
                return create_image_thumbnail_to_buffer(path, width, height, thumb_buffer, thumb_size, thumb_width, thumb_height);
@@ -647,18 +648,18 @@ int create_thumbnail_to_buffer(const char *path, unsigned int width, unsigned in
 
 int create_thumbnail_to_file(const char *path, unsigned int width, unsigned int height, const char *thumb_path)
 {
-       int ret = MS_MEDIA_ERR_NONE;
+       int ret = THUMB_OK;
        thumbnail_media_type_e type = MEDIA_THUMB_INVALID;
 
        ret = __get_media_type(path, &type);
-       thumb_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "__get_media_type failed");
+       thumb_retvm_if(ret != THUMB_OK, ret, "__get_media_type failed");
 
        if (type == MEDIA_THUMB_IMAGE)
                return create_image_thumbnail_to_file(path, width, height, thumb_path, false);
 
        if (!g_regex_match_simple("[^/]\\.jpe?g$", thumb_path, G_REGEX_CASELESS, 0)) {
                thumb_err("Unsupported path or extensions [%s]", thumb_path);
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
+               return THUMB_FAIL;
        }
 
        return create_video_thumbnail_to_file(path, width, height, thumb_path, false);