diff options
author | Minje Ahn <minje.ahn@samsung.com> | 2015-07-20 18:47:25 +0900 |
---|---|---|
committer | Minje Ahn <minje.ahn@samsung.com> | 2015-07-20 18:47:25 +0900 |
commit | 318ec49c458b8f7acef0c192d046074250ebe231 (patch) | |
tree | c3f77b8f0a7ad2ce7ea6265656abdc3f72b0225b /src | |
parent | 64959fbc53fd5386a684928617353a9be4890439 (diff) | |
download | libmedia-thumbnail-318ec49c458b8f7acef0c192d046074250ebe231.tar.gz libmedia-thumbnail-318ec49c458b8f7acef0c192d046074250ebe231.tar.bz2 libmedia-thumbnail-318ec49c458b8f7acef0c192d046074250ebe231.zip |
Fix socket bind bug.submit/tizen/20150721.075626accepted/tizen/wearable/20150721.092419accepted/tizen/tv/20150721.092304accepted/tizen/mobile/20150721.092123
Fix gdkpixbuf issue.
replace some function.
Change-Id: I3176594d491f9ae1ef08cf7de46a0b791e09e231
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/include/ipc/media-thumb-ipc.h | 10 | ||||
-rwxr-xr-x | src/include/media-thumb-internal.h | 3 | ||||
-rwxr-xr-x | src/include/util/media-thumb-debug.h | 21 | ||||
-rwxr-xr-x | src/include/util/media-thumb-util.h | 20 | ||||
-rwxr-xr-x | src/ipc/media-thumb-ipc.c | 357 | ||||
-rwxr-xr-x | src/media-thumb-internal.c | 4 | ||||
-rwxr-xr-x | src/util/media-thumb-util.c | 142 |
7 files changed, 23 insertions, 534 deletions
diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h index ea07e5e..fcd4560 100755 --- a/src/include/ipc/media-thumb-ipc.h +++ b/src/include/ipc/media-thumb-ipc.h @@ -21,6 +21,7 @@ #include <sys/un.h> +#include <sys/stat.h> #include <arpa/inet.h> #include <stdlib.h> #include <string.h> @@ -60,11 +61,6 @@ enum { THUMB_FAIL }; - -int _media_thumb_create_socket(int sock_type, int *sock); - -int _media_thumb_create_udp_socket(int *sock); - int _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg); int _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_un *from_addr, unsigned int *from_size); @@ -97,8 +93,4 @@ int _media_thumb_request_raw_data_async(int msg_type, thumbRawUserData *userData, uid_t uid); -int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid); - -int _media_thumb_process_raw(thumbMsg *req_msg, thumbMsg *res_msg, thumbRawAddMsg *res_raw_msg, uid_t uid); - #endif /*_MEDIA_THUMB_IPC_H_*/ diff --git a/src/include/media-thumb-internal.h b/src/include/media-thumb-internal.h index 151836a..0ab9eb7 100755 --- a/src/include/media-thumb-internal.h +++ b/src/include/media-thumb-internal.h @@ -22,6 +22,7 @@ #include <stdbool.h> #include <media-util-err.h> #include "media-thumbnail.h" +#include "media-thumb-util.h" #include "media-thumb-types.h" #include "media-thumb-debug.h" #include <gdk-pixbuf/gdk-pixbuf.h> @@ -75,7 +76,7 @@ int _media_thumb_image(const char *origin_path, int thumb_width, int thumb_height, media_thumb_format format, - media_thumb_info *thumb_info, + media_thumb_info *thumb_info, bool is_raw, uid_t uid); diff --git a/src/include/util/media-thumb-debug.h b/src/include/util/media-thumb-debug.h index f14ea11..3044fc4 100755 --- a/src/include/util/media-thumb-debug.h +++ b/src/include/util/media-thumb-debug.h @@ -36,11 +36,6 @@ #define LOG_TAG "MEDIA_THUMBNAIL" -static pid_t gettid(void) -{ - return syscall(__NR_gettid); -} - #define FONT_COLOR_RESET "\033[0m" #define FONT_COLOR_RED "\033[31m" #define FONT_COLOR_GREEN "\033[32m" @@ -51,31 +46,31 @@ static pid_t gettid(void) #define FONT_COLOR_GRAY "\033[37m" #define thumb_dbg(fmt, arg...) do{ \ - LOGD(FONT_COLOR_RESET"[%d] " fmt "\n", gettid(), ##arg); \ + LOGD(FONT_COLOR_RESET fmt "\n", ##arg); \ } while(0) #define thumb_warn(fmt, arg...) do{ \ - LOGW(FONT_COLOR_GREEN"[%d] " fmt "\n", gettid(), ##arg); \ + LOGW(FONT_COLOR_GREEN fmt "\n", ##arg); \ } while(0) #define thumb_err(fmt, arg...) do{ \ - LOGE(FONT_COLOR_RED"[%d] " fmt "\n", gettid(), ##arg); \ + LOGE(FONT_COLOR_RED fmt "\n", ##arg); \ } while(0) #define thumb_dbg_slog(fmt, arg...) do{ \ - SECURE_LOGD(FONT_COLOR_RESET"[%d] " fmt "\n", gettid(), ##arg); \ + SECURE_LOGD(FONT_COLOR_RESET fmt "\n", ##arg); \ } while(0) #define thumb_warn_slog(fmt, arg...) do{ \ - SECURE_LOGW(FONT_COLOR_GREEN"[%d] " fmt "\n", gettid(), ##arg); \ + SECURE_LOGW(FONT_COLOR_GREEN fmt "\n", ##arg); \ } while(0) #define ERR_BUF_LENGHT 256 #define thumb_stderror(fmt) do { \ - char buf[ERR_BUF_LENGHT] = {0,}; \ - strerror_r(errno, buf, ERR_BUF_LENGHT); \ - LOGE(FONT_COLOR_RED fmt" : standard error [%s]", buf); \ + char thumb_stderror_buffer[ERR_BUF_LENGHT] = {0,}; \ + strerror_r(errno, thumb_stderror_buffer, ERR_BUF_LENGHT); \ + LOGE(FONT_COLOR_RED fmt" : standard error [%s]", thumb_stderror_buffer); \ } while (0) #ifdef _USE_LOG_FILE_ diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h index cb93115..bee3b44 100755 --- a/src/include/util/media-thumb-util.h +++ b/src/include/util/media-thumb-util.h @@ -72,25 +72,5 @@ int _media_thumb_get_width(media_thumb_type thumb_type); int _media_thumb_get_height(media_thumb_type thumb_type); -int _thumbnail_get_data(const char *origin_path, - media_thumb_type thumb_type, - media_thumb_format format, - unsigned char **data, - int *size, - int *width, - int *height, - int *origin_width, - int *origin_height, - int *alpha, - uid_t uid); - -int _thumbnail_get_raw_data(const char *origin_path, - media_thumb_format format, - unsigned char **data, - int *size, - int *width, - int *height, - uid_t uid); - #endif /*_MEDIA_THUMB_UTIL_H_*/ diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c index 64c4b46..e98d629 100755 --- a/src/ipc/media-thumb-ipc.c +++ b/src/ipc/media-thumb-ipc.c @@ -49,61 +49,7 @@ typedef struct { thumbRawUserData *userData; } thumbRawReq; -int _media_thumb_create_socket(int sock_type, int *sock) -{ - int sock_fd = 0; - - if ((sock_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - thumb_err("socket failed: %s", strerror(errno)); - return MS_MEDIA_ERR_SOCKET_CONN; - } - - if (sock_type == CLIENT_SOCKET) { - struct timeval tv_timeout = { MS_TIMEOUT_SEC_10, 0 }; - - if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) { - thumb_err("setsockopt failed: %s", strerror(errno)); - close(sock_fd); - return MS_MEDIA_ERR_SOCKET_CONN; - } - } else if (sock_type == SERVER_SOCKET) { - - int n_reuse = 1; - - if (setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &n_reuse, sizeof(n_reuse)) == -1) { - thumb_err("setsockopt failed: %s", strerror(errno)); - close(sock_fd); - return MS_MEDIA_ERR_SOCKET_CONN; - } - } - - *sock = sock_fd; - return MS_MEDIA_ERR_NONE; -} - - -int _media_thumb_create_udp_socket(int *sock) -{ - int sock_fd = 0; - - if ((sock_fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) { - thumb_err("socket failed: %s", strerror(errno)); - return MS_MEDIA_ERR_SOCKET_CONN; - } - - struct timeval tv_timeout = { MS_TIMEOUT_SEC_10, 0 }; - - if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) { - thumb_err("setsockopt failed: %s", strerror(errno)); - close(sock_fd); - return MS_MEDIA_ERR_SOCKET_CONN; - } - - *sock = sock_fd; - - return MS_MEDIA_ERR_NONE; -} int _media_thumb_get_error() { @@ -209,7 +155,6 @@ int __media_thumb_check_req_queue(const char *path) { int req_len = 0, i; - if (g_request_queue == NULL) return MS_MEDIA_ERR_NONE; req_len = g_queue_get_length(g_request_queue); // thumb_dbg("Queue length : %d", req_len); @@ -248,7 +193,6 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg) buf = (unsigned char*)malloc(header_size * sizeof(unsigned char)); block_buf = (unsigned char*)malloc(THUMB_SOCK_BLOCK_SIZE * sizeof(unsigned char)); - if (buf == NULL || block_buf == NULL) { thumb_err("memory allocation failed"); SAFE_FREE(buf); @@ -323,7 +267,6 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka } strncpy(msg->org_path, (char*)buf + header_size, msg->origin_path_size); - //thumb_dbg("original path : %s", msg->org_path); if (msg->dest_path_size <= 0 || msg->dest_path_size > MAX_PATH_SIZE) { SAFE_FREE(buf); @@ -332,7 +275,6 @@ _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct socka } strncpy(msg->dst_path, (char*)buf + header_size + msg->origin_path_size, msg->dest_path_size); - //thumb_dbg("destination path : %s", msg->dst_path); SAFE_FREE(buf); *from_size = from_addr_size; @@ -553,285 +495,6 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig return MS_MEDIA_ERR_NONE; } -static int _mkdir(const char *dir, mode_t mode) { - char tmp[256]; - char *p = NULL; - size_t len; - - snprintf(tmp, sizeof(tmp),"%s",dir); - len = strlen(tmp); - if(tmp[len - 1] == '/') - tmp[len - 1] = 0; - for(p = tmp + 1; *p; p++) - if(*p == '/') { - *p = 0; - mkdir(tmp, mode); - *p = '/'; - } - return mkdir(tmp, mode); -} - -static char* _media_thumb_get_default_path(uid_t uid) -{ - char *result_psswd = NULL; - struct group *grpinfo = NULL; - if(uid == getuid()) - { - result_psswd = strdup(THUMB_DEFAULT_PATH); - grpinfo = getgrnam("users"); - if(grpinfo == NULL) { - thumb_err("getgrnam(users) returns NULL !"); - if(result_psswd) - free(result_psswd); - return NULL; - } - } - else - { - struct passwd *userinfo = getpwuid(uid); - if(userinfo == NULL) { - thumb_err("getpwuid(%d) returns NULL !", uid); - return NULL; - } - grpinfo = getgrnam("users"); - if(grpinfo == NULL) { - thumb_err("getgrnam(users) returns NULL !"); - return NULL; - } - // Compare git_t type and not group name - if (grpinfo->gr_gid != userinfo->pw_gid) { - thumb_err("UID [%d] does not belong to 'users' group!", uid); - return NULL; - } - asprintf(&result_psswd, "%s/data/file-manager-service/.thumb/phone", userinfo->pw_dir); - } - - /* create dir */ - _mkdir(result_psswd,S_IRWXU | S_IRWXG | S_IRWXO); - - return result_psswd; -} - -int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid) -{ - int err = -1; - GdkPixbuf *gdkdata = NULL; - int thumb_size = 0; - int thumb_w = 0; - int thumb_h = 0; - int origin_w = 0; - int origin_h = 0; - int max_length = 0; - char *thumb_path = NULL; - int need_update_db = 0; - int alpha = 0; - - if (req_msg == NULL || res_msg == NULL) { - thumb_err("Invalid msg!"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - int msg_type = req_msg->msg_type; - media_thumb_type thumb_type = req_msg->thumb_type; - const char *origin_path = req_msg->org_path; - - // Currently, The color space that is supported by the gdk-pixbuf is only RGB. - media_thumb_format thumb_format = MEDIA_THUMB_RGB888; - - thumb_path = res_msg->dst_path; - thumb_path[0] = '\0'; - max_length = sizeof(res_msg->dst_path); - - err = _media_thumb_db_connect(uid); - if (err != MS_MEDIA_ERR_NONE) { - thumb_err("_media_thumb_mb_svc_connect failed: %d", err); - return MS_MEDIA_ERR_DB_CONNECT_FAIL; - } - - if (msg_type == THUMB_REQUEST_DB_INSERT) { - err = _media_thumb_get_thumb_from_db_with_size(origin_path, thumb_path, max_length, &need_update_db, &origin_w, &origin_h); - if (err == MS_MEDIA_ERR_NONE) { - res_msg->origin_width = origin_w; - res_msg->origin_height = origin_h; - _media_thumb_db_disconnect(); - return MS_MEDIA_ERR_NONE; - } else { - if (strlen(thumb_path) == 0) { - err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length,uid); - if (err != MS_MEDIA_ERR_NONE) { - char *default_path = _media_thumb_get_default_path(uid); - if(default_path) { - thumb_err("_media_thumb_get_hash_name failed - %d\n", err); - strncpy(thumb_path, default_path, max_length); - free(default_path); - } - _media_thumb_db_disconnect(); - return err; - } - - thumb_path[strlen(thumb_path)] = '\0'; - } - } - - } else if (msg_type == THUMB_REQUEST_SAVE_FILE) { - strncpy(thumb_path, req_msg->dst_path, max_length); - - } else if (msg_type == THUMB_REQUEST_ALL_MEDIA) { - err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length,uid); - if (err < 0) { - char *default_path = _media_thumb_get_default_path(uid); - if(default_path) { - thumb_err("_media_thumb_get_hash_name failed - %d\n", err); - strncpy(thumb_path, default_path, max_length); - free(default_path); - } - _media_thumb_db_disconnect(); - return err; - } - - thumb_path[strlen(thumb_path)] = '\0'; - } - - if (g_file_test(thumb_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - thumb_warn("thumb path already exists in file system.. remove the existed file"); - _media_thumb_remove_file(thumb_path); - } - - err = _thumbnail_get_data(origin_path, thumb_type, thumb_format, &gdkdata, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, uid); - if (err != MS_MEDIA_ERR_NONE) { - char *default_path = _media_thumb_get_default_path(uid); - thumb_err("_thumbnail_get_data failed - %d\n", err); - if ( gdkdata != NULL ){ - g_object_unref(gdkdata); - } - if(default_path) { - strncpy(thumb_path, default_path, max_length); - free(default_path); - } - _media_thumb_db_disconnect(); - return err; - } - - //thumb_dbg("Size : %d, W:%d, H:%d", thumb_size, thumb_w, thumb_h); - //thumb_dbg("Origin W:%d, Origin H:%d\n", origin_w, origin_h); - //thumb_dbg("Thumb : %s", thumb_path); - - res_msg->msg_type = THUMB_RESPONSE; - res_msg->thumb_size = thumb_size; - res_msg->thumb_width = thumb_w; - res_msg->thumb_height = thumb_h; - res_msg->origin_width = origin_w; - res_msg->origin_height = origin_h; - - /* If the image is transparent PNG format, make png file as thumbnail of this image */ - if (alpha) { - char file_ext[10]; - err = _media_thumb_get_file_ext(origin_path, file_ext, sizeof(file_ext)); - if (strncasecmp(file_ext, "png", 3) == 0) { - int len = strlen(thumb_path); - thumb_path[len - 3] = 'p'; - thumb_path[len - 2] = 'n'; - thumb_path[len - 1] = 'g'; - } - thumb_dbg("Thumb path is changed : %s", thumb_path); - } - - err = _media_thumb_save_to_file_with_gdk(gdkdata, thumb_w, thumb_h, alpha, thumb_path); - if (err < 0) { - char *default_path = _media_thumb_get_default_path(uid); - thumb_err("save_to_file_with_gdk failed - %d\n", err); - if ( gdkdata != NULL ){ - g_object_unref(gdkdata); - } - - if (msg_type == THUMB_REQUEST_DB_INSERT || msg_type == THUMB_REQUEST_ALL_MEDIA) { - if(default_path) { - strncpy(thumb_path, default_path, max_length); - free(default_path); - } - } - _media_thumb_db_disconnect(); - return err; - } else { - thumb_dbg("file save success\n"); - } - - /* fsync */ - int fd = 0; - fd = open(thumb_path, O_WRONLY); - if (fd < 0) { - thumb_warn("open failed"); - } else { - err = fsync(fd); - if (err == -1) { - thumb_warn("fsync failed"); - } - close(fd); - } - /* End of fsync */ - - g_object_unref(gdkdata); - - /* DB update if needed */ - if (need_update_db == 1) { - err = _media_thumb_update_db(origin_path, thumb_path, res_msg->origin_width, res_msg->origin_height, uid); - if (err != MS_MEDIA_ERR_NONE) { - thumb_err("_media_thumb_update_db failed : %d", err); - } - } - - _media_thumb_db_disconnect(); - - return MS_MEDIA_ERR_NONE; -} - -int -_media_thumb_process_raw(thumbMsg *req_msg, thumbMsg *res_msg, thumbRawAddMsg *res_raw_msg, uid_t uid) -{ - int err = MS_MEDIA_ERR_NONE; - unsigned char *data = NULL; - int thumb_size = 0; - int thumb_w = 0; - int thumb_h = 0; - - if (req_msg == NULL || res_msg == NULL) { - thumb_err("Invalid msg!"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - const char *origin_path = req_msg->org_path; - - media_thumb_format thumb_format = MEDIA_THUMB_BGRA; - thumb_w = req_msg->thumb_width; - thumb_h = req_msg->thumb_height; - - //thumb_dbg("origin_path : %s, thumb_w : %d, thumb_h : %d ", origin_path, thumb_w, thumb_h); - - if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - thumb_err("origin_path does not exist in file system."); - return MS_MEDIA_ERR_FILE_NOT_EXIST; - } - - err = _thumbnail_get_raw_data(origin_path, thumb_format, &data, &thumb_size, &thumb_w, &thumb_h, uid); - - if (err != MS_MEDIA_ERR_NONE) { - thumb_err("_thumbnail_get_data failed - %d", err); - SAFE_FREE(data); - } - - res_msg->msg_type = THUMB_RESPONSE_RAW_DATA; - res_msg->thumb_width = thumb_w; - res_msg->thumb_height = thumb_h; - res_raw_msg->thumb_size = thumb_size; - res_raw_msg->thumb_data = malloc(thumb_size * sizeof(unsigned char)); - memcpy(res_raw_msg->thumb_data, data, thumb_size); - res_msg->thumb_size = thumb_size + sizeof(thumbRawAddMsg) - sizeof(unsigned char*); - - //thumb_dbg("Size : %d, W:%d, H:%d", thumb_size, thumb_w, thumb_h); - - return MS_MEDIA_ERR_NONE; -} - gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpointer data) { thumbMsg recv_msg; @@ -945,17 +608,16 @@ int _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const thumb_err("ms_ipc_create_client_socket failed"); return err; } - GIOChannel *channel = NULL; - channel = g_io_channel_unix_new(sock); - int source_id = -1; - memset(&serv_addr, 0, sizeof(serv_addr)); sock = sock_info.sock_fd; serv_addr.sun_family = AF_UNIX; - strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket"); + GIOChannel *channel = NULL; + channel = g_io_channel_unix_new(sock); + int source_id = -1; + /* Connecting to the thumbnail server */ if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) { thumb_stderror("connect"); @@ -1050,7 +712,7 @@ int _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const int _media_thumb_request_raw_data_async(int msg_type, int request_id, const char *origin_path, int width, int height, thumbRawUserData *userData, uid_t uid) { int err = MS_MEDIA_ERR_NONE; - int sock; + int sock = -1; struct sockaddr_un serv_addr; ms_sock_info_s sock_info; int pid; @@ -1062,17 +724,16 @@ int _media_thumb_request_raw_data_async(int msg_type, int request_id, const char thumb_err("ms_ipc_create_client_socket failed"); return err; } - GIOChannel *channel = NULL; - channel = g_io_channel_unix_new(sock); - int source_id = -1; - memset(&serv_addr, 0, sizeof(serv_addr)); sock = sock_info.sock_fd; serv_addr.sun_family = AF_UNIX; - strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket"); + GIOChannel *channel = NULL; + channel = g_io_channel_unix_new(sock); + int source_id = -1; + /* Connecting to the thumbnail server */ if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) { thumb_err("connect error : %s", strerror(errno)); diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c index 30e6f6b..a8c7fd7 100755 --- a/src/media-thumb-internal.c +++ b/src/media-thumb-internal.c @@ -22,6 +22,7 @@ #include "media-thumb-debug.h" #include "media-thumb-util.h" #include "media-thumb-internal.h" +#include "media-thumb-ipc.h" #include "AGifFrameInfo.h" #include "IfegDecodeAGIF.h" @@ -903,6 +904,8 @@ int _media_thumb_jpeg_for_raw(const char *origin_path, thumb_err("decode_with_gdk failed : %d", err); return err; } + /* Temporary process */ + thumb_info->data = gdk_pixbuf_get_pixels(thumb_info->gdkdata); err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format); if (err != MS_MEDIA_ERR_NONE) { @@ -1009,7 +1012,6 @@ int _media_thumb_video(const char *origin_path, int size = 0; int width = 0; int height = 0; - int ret = 0; GdkPixbuf *pixbuf; bool drm_type = FALSE; diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c index 387a941..c86d55d 100755 --- a/src/util/media-thumb-util.c +++ b/src/util/media-thumb-util.c @@ -325,146 +325,4 @@ int _media_thumb_save_to_file_with_gdk(GdkPixbuf *data, } return 0; -} - -int _thumbnail_get_data(const char *origin_path, - media_thumb_type thumb_type, - media_thumb_format format, - unsigned char **data, - int *size, - int *width, - int *height, - int *origin_width, - int *origin_height, - int *alpha, - uid_t uid) -{ - int err = -1; - int thumb_width = -1; - int thumb_height = -1; - - if (origin_path == NULL || size == NULL - || width == NULL || height == NULL) { - thumb_err("Invalid parameter"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - if (format < MEDIA_THUMB_BGRA || format > MEDIA_THUMB_RGB888) { - thumb_err("parameter format is invalid"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - if (!g_file_test - (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - thumb_err("Original path (%s) does not exist", origin_path); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - thumb_width = _media_thumb_get_width(thumb_type); - if (thumb_width < 0) { - thumb_err("media_thumb_type is invalid"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - thumb_height = _media_thumb_get_height(thumb_type); - if (thumb_height < 0) { - thumb_err("media_thumb_type is invalid"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - thumb_dbg("Origin path : %s", origin_path); - - int file_type = THUMB_NONE_TYPE; - media_thumb_info thumb_info = {0,}; - file_type = _media_thumb_get_file_type(origin_path); - - if (file_type == THUMB_IMAGE_TYPE) { - err = _media_thumb_image(origin_path, thumb_width, thumb_height, format, &thumb_info, false, uid); - if (err < 0) { - thumb_err("_media_thumb_image failed"); - return err; - } - - } else if (file_type == THUMB_VIDEO_TYPE) { - err = _media_thumb_video(origin_path, thumb_width, thumb_height, format, &thumb_info,uid); - if (err < 0) { - thumb_err("_media_thumb_image failed"); - return err; - } - } - - if (size) *size = thumb_info.size; - if (width) *width = thumb_info.width; - if (height) *height = thumb_info.height; - *data = thumb_info.gdkdata; - if (origin_width) *origin_width = thumb_info.origin_width; - if (origin_height) *origin_height = thumb_info.origin_height; - if (alpha) *alpha = thumb_info.alpha; - - thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) 0x%x", - *size, *width, *height, *data); - - return MS_MEDIA_ERR_NONE; -} - -int _thumbnail_get_raw_data(const char *origin_path, - media_thumb_format format, - unsigned char **data, - int *size, - int *width, - int *height, - uid_t uid) -{ - int err = -1; - int thumb_width = -1; - int thumb_height = -1; - - if (origin_path == NULL || * width <= 0 || *height <= 0) { - thumb_err("Invalid parameter"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - if (format < MEDIA_THUMB_BGRA || format > MEDIA_THUMB_RGB888) { - thumb_err("parameter format is invalid"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - if (!g_file_test - (origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { - thumb_err("Original path (%s) does not exist", origin_path); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - thumb_dbg("Origin path : %s", origin_path); - - int file_type = THUMB_NONE_TYPE; - media_thumb_info thumb_info = {0,}; - file_type = _media_thumb_get_file_type(origin_path); - thumb_width = *width; - thumb_height = *height; - - if (file_type == THUMB_IMAGE_TYPE) { - err = _media_thumb_image(origin_path, thumb_width, thumb_height, format, &thumb_info, true, uid); - if (err < 0) { - thumb_err("_media_thumb_image failed"); - return err; - } - - } else if (file_type == THUMB_VIDEO_TYPE) { - err = _media_thumb_video(origin_path, thumb_width, thumb_height, format, &thumb_info,uid); - if (err < 0) { - thumb_err("_media_thumb_image failed"); - return err; - } - } - - if (size) *size = thumb_info.size; - if (width) *width = thumb_info.width; - if (height) *height = thumb_info.height; - *data = thumb_info.gdkdata; - - thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) 0x%x", - *size, *width, *height, *data); - - return MS_MEDIA_ERR_NONE; }
\ No newline at end of file |