summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2015-06-23 17:30:45 +0900
committerMinje Ahn <minje.ahn@samsung.com>2015-07-02 19:13:49 +0900
commit51e31533b89929b6aed1a1727c0500cb01ce2d9f (patch)
treed95641ae327e40d334e56dcfb285ae0467baed23 /src
parentf608c86507c0899ee874217f3a223e40c643aff8 (diff)
downloadlibmedia-thumbnail-51e31533b89929b6aed1a1727c0500cb01ce2d9f.tar.gz
libmedia-thumbnail-51e31533b89929b6aed1a1727c0500cb01ce2d9f.tar.bz2
libmedia-thumbnail-51e31533b89929b6aed1a1727c0500cb01ce2d9f.zip
Change-Id: Ia54e4466ca6665b27cca316f9553ad15cef764be Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/include/util/media-thumb-db.h9
-rwxr-xr-xsrc/include/util/media-thumb-debug.h4
-rwxr-xr-xsrc/include/util/media-thumb-util.h6
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c45
-rwxr-xr-xsrc/util/media-thumb-util.c2
5 files changed, 33 insertions, 33 deletions
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
index 5302fa6..fcd284f 100755
--- a/src/include/util/media-thumb-db.h
+++ b/src/include/util/media-thumb-db.h
@@ -29,14 +29,6 @@
#define MEDIA_DATABASE_NAME MEDIA_DB_NAME /* defined in media-util.h */
-#ifndef _USE_NEW_MEDIA_DB_
-#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from visual_media where thumbnail_path='' and valid=1;"
-#define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM visual_media WHERE path='%q';"
-#define SELECT_TYPE_BY_PATH "SELECT content_type FROM visual_media WHERE path='%q';"
-#define UPDATE_THUMB_BY_PATH "UPDATE visual_media SET thumbnail_path = '%q' WHERE path='%q';"
-#define UPDATE_WH_BY_PATH "UPDATE image_meta SET width=%d,height=%d WHERE visual_uuid=(SELECT visual_uuid FROM visual_media WHERE path='%q');"
-
-#else
#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from media where thumbnail_path is null and validity=1 and (media_type=0 or media_type=1);"
#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_INTERNAL_MEDIA "SELECT path from media where thumbnail_path is null and validity=1 and (media_type=0 or media_type=1) and storage_type=0;"
#define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM media WHERE path='%q';"
@@ -45,7 +37,6 @@
#define UPDATE_THUMB_BY_PATH "UPDATE media SET thumbnail_path = '%q' WHERE path='%q';"
#define UPDATE_WH_BY_PATH "UPDATE media SET width=%d,height=%d WHERE path='%q';"
#define UPDATE_THUMB_WH_BY_PATH "UPDATE media SET thumbnail_path = '%q', width=%d,height=%d WHERE path='%q';"
-#endif
sqlite3 *_media_thumb_db_get_handle();
diff --git a/src/include/util/media-thumb-debug.h b/src/include/util/media-thumb-debug.h
index 3c0c21b..f14ea11 100755
--- a/src/include/util/media-thumb-debug.h
+++ b/src/include/util/media-thumb-debug.h
@@ -34,10 +34,6 @@
#undef LOG_TAG
#endif
-
-#define _PERFORMANCE_CHECK_
-
-
#define LOG_TAG "MEDIA_THUMBNAIL"
static pid_t gettid(void)
diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h
index fdda9ee..cb93115 100755
--- a/src/include/util/media-thumb-util.h
+++ b/src/include/util/media-thumb-util.h
@@ -30,15 +30,9 @@
#define SAFE_FREE(src) { if(src) {free(src); src = NULL;}}
-#ifndef _USE_NEW_MEDIA_DB_
-#define THUMB_NONE_TYPE 0x00000000 /* None */
-#define THUMB_IMAGE_TYPE 0x00000001 /* Image */
-#define THUMB_VIDEO_TYPE 0x00000002 /* Video */
-#else
#define THUMB_NONE_TYPE -1 /* None */
#define THUMB_IMAGE_TYPE 0 /* Image */
#define THUMB_VIDEO_TYPE 1 /* Video */
-#endif
#define THUMB_PATH_PHONE MEDIA_ROOT_PATH_INTERNAL /**< File path prefix of files stored in phone */
#define THUMB_PATH_MMC MEDIA_ROOT_PATH_SDCARD /**< File path prefix of files stored in mmc card */
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 4e1d305..add4ba3 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -441,24 +441,29 @@ _media_thumb_set_add_raw_data_buffer(thumbRawAddMsg *req_msg, unsigned char **bu
int
_media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *origin_path, char *thumb_path, int max_length, media_thumb_info *thumb_info, uid_t uid)
{
- int sock;
+ int sock = -1;
struct sockaddr_un serv_addr;
+ ms_sock_info_s sock_info;
int recv_str_len = 0;
int err = MS_MEDIA_ERR_NONE;
int pid;
+ sock_info.port = MS_THUMB_CREATOR_PORT;
- if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
+ err = ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock_info);
+ if (err != MS_MEDIA_ERR_NONE) {
thumb_err("ms_ipc_create_client_socket failed");
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return err;
}
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");
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
thumb_stderror("connect");
+ ms_ipc_delete_client_socket(&sock_info);
return MS_MEDIA_ERR_SOCKET_CONN;
}
@@ -492,7 +497,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
if (req_msg.origin_path_size > MAX_PATH_SIZE || req_msg.dest_path_size > MAX_PATH_SIZE) {
thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
- close(sock);
+ ms_ipc_delete_client_socket(&sock_info);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
@@ -506,7 +511,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
if (send(sock, buf, buf_size, 0) != buf_size) {
thumb_err("sendto failed: %d", errno);
SAFE_FREE(buf);
- close(sock);
+ ms_ipc_delete_client_socket(&sock_info);
return MS_MEDIA_ERR_SOCKET_SEND;
}
@@ -517,14 +522,14 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
if(msg_type != THUMB_REQUEST_CANCEL_ALL_RAW_DATA && msg_type != THUMB_REQUEST_CANCEL_ALL) { //No response..
if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
thumb_err("_media_thumb_recv_msg failed ");
- close(sock);
+ ms_ipc_delete_client_socket(&sock_info);
return err;
}
recv_str_len = strlen(recv_msg.org_path);
thumb_dbg_slog("recv %s(%d) from thumb daemon is successful", recv_msg.org_path, recv_str_len);
- close(sock);
+ ms_ipc_delete_client_socket(&sock_info);
if (recv_str_len > max_length) {
thumb_err("user buffer is too small. Output's length is %d", recv_str_len);
@@ -906,17 +911,22 @@ gboolean _media_thumb_raw_data_write_socket(GIOChannel *src, GIOCondition condit
int _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char *origin_path, thumbUserData *userData, uid_t uid)
{
- int sock;
+ int err = MS_MEDIA_ERR_NONE;
+ int sock = -1;
struct sockaddr_un serv_addr;
+ ms_sock_info_s sock_info;
int pid;
+ sock_info.port = MS_THUMB_CREATOR_PORT;
if ((msg_type == THUMB_REQUEST_DB_INSERT) && (__media_thumb_check_req_queue(origin_path) < 0)) {
return MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST;
}
- if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
+ err = ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock_info);
+ if(err != MS_MEDIA_ERR_NONE)
+ {
thumb_err("ms_ipc_create_client_socket failed");
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return err;
}
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(sock);
@@ -924,13 +934,14 @@ int _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const
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");
/* Connecting to the thumbnail server */
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
- thumb_err("connect error : %s", strerror(errno));
+ thumb_stderror("connect");
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
return MS_MEDIA_ERR_SOCKET_CONN;
@@ -970,6 +981,7 @@ int _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const
thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
+ ms_ipc_delete_client_socket(&sock_info);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
@@ -983,6 +995,7 @@ int _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const
g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), source_id));
g_io_channel_shutdown(channel, TRUE, NULL);
g_io_channel_unref(channel);
+ ms_ipc_delete_client_socket(&sock_info);
return MS_MEDIA_ERR_SOCKET_SEND;
}
@@ -1019,13 +1032,18 @@ 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;
struct sockaddr_un serv_addr;
+ ms_sock_info_s sock_info;
int pid;
+ sock_info.port = MS_THUMB_CREATOR_PORT;
- if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
+ err = ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock_info);
+ if(err != MS_MEDIA_ERR_NONE)
+ {
thumb_err("ms_ipc_create_client_socket failed");
- return MS_MEDIA_ERR_SOCKET_CONN;
+ return err;
}
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(sock);
@@ -1033,6 +1051,7 @@ int _media_thumb_request_raw_data_async(int msg_type, int request_id, const char
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");
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
index 6dd2282..485d13a 100755
--- a/src/util/media-thumb-util.c
+++ b/src/util/media-thumb-util.c
@@ -413,7 +413,7 @@ int _thumbnail_get_raw_data(const char *origin_path,
int thumb_width = -1;
int thumb_height = -1;
- if (origin_path == NULL || * width >= 0 || *height >= 0) {
+ if (origin_path == NULL || * width <= 0 || *height <= 0) {
thumb_err("Invalid parameter");
return MS_MEDIA_ERR_INVALID_PARAMETER;
}