summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinclude/media-thumbnail.h13
-rwxr-xr-xserver/thumb-server-internal.c68
-rwxr-xr-xsrc/include/ipc/media-thumb-ipc.h20
-rwxr-xr-xsrc/include/media-thumb-internal.h8
-rwxr-xr-xsrc/include/util/media-thumb-util.h8
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c498
-rwxr-xr-xsrc/media-thumb-internal.c36
-rwxr-xr-xsrc/media-thumbnail.c60
-rwxr-xr-xsrc/util/media-thumb-util.c64
-rwxr-xr-xtest/test-thumb.c3
10 files changed, 682 insertions, 96 deletions
diff --git a/include/media-thumbnail.h b/include/media-thumbnail.h
index 8983e76..4ad5690 100755
--- a/include/media-thumbnail.h
+++ b/include/media-thumbnail.h
@@ -36,24 +36,25 @@ extern "C" {
typedef int (*ThumbFunc) (int error_code, char* path, void* data);
+typedef void (*ThumbRawFunc) (int error_code, int request_id, const char* org_path, int thumb_width, int thumb_height, unsigned char* thumb_data, int thumb_size, void* data);
+
int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max_length, uid_t uid);
int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, void *user_data, uid_t uid);
-int thumbnail_request_save_to_file(const char *origin_path,
- media_thumb_type thumb_type,
- const char *thumb_path, uid_t uid);
+int thumbnail_request_extract_raw_data_async(int request_id, const char *origin_path, int width, int height, ThumbRawFunc func, void *user_data, uid_t uid);
+int thumbnail_request_save_to_file(const char *origin_path, media_thumb_type thumb_type, const char *thumb_path, uid_t uid);
int thumbnail_request_extract_all_thumbs(uid_t uid);
int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *origin_width, int *origin_height, uid_t uid);
-/* Cancel APIs that a request to extract thumbnail */
int thumbnail_request_cancel_media(const char *origin_path, uid_t uid);
-/* Cancel APIs that all requests to extract thumbnail of a process */
-int thumbnail_request_cancel_all();
+int thumbnail_request_cancel_raw_data(int request_id, uid_t uid);
+
+int thumbnail_request_cancel_all(bool is_raw_data, uid_t uid);
#ifdef __cplusplus
}
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index c739251..9e21727 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -166,6 +166,26 @@ int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
return err;
}
+static int __thumb_daemon_process_job_raw(thumbMsg *req_msg, thumbMsg *res_msg, thumbRawAddMsg *res_raw_msg, uid_t uid)
+{
+ int err = MS_MEDIA_ERR_NONE;
+
+ err = _media_thumb_process_raw(req_msg, res_msg, res_raw_msg, uid);
+ if (err != MS_MEDIA_ERR_NONE) {
+ if (err != MS_MEDIA_ERR_FILE_NOT_EXIST) {
+ thumb_warn("_media_thumb_process is failed: %d, So use default thumb", err);
+ res_msg->status = THUMB_SUCCESS;
+ } else {
+ thumb_warn("_media_thumb_process is failed: %d, (file not exist) ", err);
+ res_msg->status = THUMB_FAIL;
+ }
+ } else {
+ res_msg->status = THUMB_SUCCESS;
+ }
+
+ return err;
+}
+
int _thumb_daemon_all_extract(uid_t uid)
{
int err = MS_MEDIA_ERR_NONE;
@@ -302,12 +322,14 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
int client_sock;
thumbMsg recv_msg;
thumbMsg res_msg;
+ thumbRawAddMsg res_raw_msg;
int sock = -1;
int header_size = 0;
memset((void *)&recv_msg, 0, sizeof(recv_msg));
memset((void *)&res_msg, 0, sizeof(res_msg));
+ memset((void *)&res_raw_msg, 0, sizeof(res_raw_msg));
sock = g_io_channel_unix_get_fd(src);
if (sock < 0) {
@@ -315,11 +337,11 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
return TRUE;
}
- header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2;
+ header_size = sizeof(thumbMsg) - MAX_PATH_SIZE * 2 - sizeof(unsigned char *);
if (_media_thumb_recv_udp_msg(sock, header_size, &recv_msg, &client_addr, &client_addr_len) < 0) {
thumb_err("_media_thumb_recv_udp_msg failed");
- return FALSE;
+ return TRUE;
}
thumb_warn("Received [%d] %s(%d) from PID(%d) \n", recv_msg.msg_type, recv_msg.org_path, strlen(recv_msg.org_path), recv_msg.pid);
@@ -328,6 +350,8 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
thumb_dbg("All thumbnails are being extracted now");
_thumb_daemon_all_extract(recv_msg.uid);
g_idle_add(_thumb_daemon_process_queue_jobs, NULL);
+ } else if(recv_msg.msg_type == THUMB_REQUEST_RAW_DATA) {
+ __thumb_daemon_process_job_raw(&recv_msg, &res_msg, &res_raw_msg, recv_msg.uid);
} else if(recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
thumb_warn("received KILL msg from thumbnail agent.");
} else {
@@ -339,25 +363,57 @@ gboolean _thumb_server_read_socket(GIOChannel *src,
thumb_dbg("Time : %f (%s)", ((double)(end - start) / (double)CLOCKS_PER_SEC), recv_msg.org_path);
}
- res_msg.msg_type = recv_msg.msg_type;
+ if(res_msg.msg_type == 0)
+ res_msg.msg_type = recv_msg.msg_type;
+ res_msg.request_id = recv_msg.request_id;
strncpy(res_msg.org_path, recv_msg.org_path, recv_msg.origin_path_size);
res_msg.origin_path_size = recv_msg.origin_path_size;
- res_msg.dest_path_size = strlen(res_msg.dst_path) + 1;
+ res_msg.thumb_data = (unsigned char *)"\0";
+ if(res_msg.msg_type != THUMB_RESPONSE_RAW_DATA) {
+ res_msg.dest_path_size = strlen(res_msg.dst_path) + 1;
+ res_msg.thumb_size = 1;
+ } else {
+ res_msg.dest_path_size = 1;
+ res_msg.dst_path[0] = '\0';
+ }
int buf_size = 0;
+ int block_size = 0;
+ int sent_size = 0;
unsigned char *buf = NULL;
- _media_thumb_set_buffer(&res_msg, &buf, &buf_size);
+ _media_thumb_set_buffer_for_response(&res_msg, &buf, &buf_size);
if (sendto(sock, buf, buf_size, 0, (struct sockaddr *)&client_addr, sizeof(client_addr)) != buf_size) {
thumb_stderror("sendto failed");
SAFE_FREE(buf);
- return FALSE;
+ return TRUE;
}
thumb_warn("Sent %s(%d)", res_msg.dst_path, strlen(res_msg.dst_path));
SAFE_FREE(buf);
+ //Add sendto_raw_data
+ if(recv_msg.msg_type == THUMB_REQUEST_RAW_DATA) {
+ _media_thumb_set_add_raw_data_buffer(&res_raw_msg, &buf, &buf_size);
+ block_size = 512;
+ while(buf_size > 0) {
+ if (buf_size < 512) {
+ block_size = buf_size;
+ }
+ if (sendto(sock, buf + sent_size, block_size, 0, (struct sockaddr *)&client_addr, sizeof(client_addr)) != block_size) {
+ thumb_err("sendto failed: %s", strerror(errno));
+ SAFE_FREE(buf);
+ return TRUE;
+ }
+ sent_size += block_size;
+ buf_size -= block_size;
+ }
+ thumb_warn_slog("Sent [%s] additional data[%d]", res_msg.org_path, sent_size);
+ }
+
+ SAFE_FREE(buf);
+
if(recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
thumb_warn("Shutting down...");
g_main_loop_quit(g_thumb_server_mainloop);
diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h
index cc3cabf..ea07e5e 100755
--- a/src/include/ipc/media-thumb-ipc.h
+++ b/src/include/ipc/media-thumb-ipc.h
@@ -48,7 +48,11 @@ enum {
THUMB_REQUEST_CANCEL_MEDIA,
THUMB_REQUEST_CANCEL_ALL,
THUMB_REQUEST_KILL_SERVER,
- THUMB_RESPONSE
+ THUMB_RESPONSE,
+ THUMB_REQUEST_RAW_DATA,
+ THUMB_REQUEST_CANCEL_RAW_DATA,
+ THUMB_REQUEST_CANCEL_ALL_RAW_DATA,
+ THUMB_RESPONSE_RAW_DATA,
};
enum {
@@ -67,6 +71,10 @@ int _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct s
int _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size);
+int _media_thumb_set_buffer_for_response(thumbMsg *req_msg, unsigned char **buf, int *buf_size);
+
+int _media_thumb_set_add_raw_data_buffer(thumbRawAddMsg *req_msg, unsigned char **buf, int *buf_size);
+
int _media_thumb_request(int msg_type,
media_thumb_type thumb_type,
const char *origin_path,
@@ -81,6 +89,16 @@ int _media_thumb_request_async(int msg_type,
thumbUserData *userData,
uid_t uid);
+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 _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 f101f52..151836a 100755
--- a/src/include/media-thumb-internal.h
+++ b/src/include/media-thumb-internal.h
@@ -66,11 +66,17 @@ typedef struct {
void *user_data;
} thumbUserData;
+typedef struct {
+ ThumbRawFunc func;
+ void *user_data;
+} thumbRawUserData;
+
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);
int _media_thumb_video(const char *origin_path,
diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h
index 41e48f4..fdda9ee 100755
--- a/src/include/util/media-thumb-util.h
+++ b/src/include/util/media-thumb-util.h
@@ -90,5 +90,13 @@ int _thumbnail_get_data(const char *origin_path,
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 7f4c381..4e1d305 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -32,14 +32,23 @@
#include <pwd.h>
#define GLOBAL_USER 0 //#define tzplatform_getenv(TZ_GLOBAL) //TODO
+#define THUMB_SOCK_BLOCK_SIZE 512
static __thread GQueue *g_request_queue = NULL;
typedef struct {
GIOChannel *channel;
char *path;
int source_id;
+ thumbUserData *userData;
} thumbReq;
+typedef struct {
+ GIOChannel *channel;
+ int request_id;
+ int source_id;
+ thumbRawUserData *userData;
+} thumbRawReq;
+
int _media_thumb_create_socket(int sock_type, int *sock)
{
int sock_fd = 0;
@@ -125,7 +134,12 @@ int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
if (strncmp(path, req->path, strlen(path)) == 0) {
if (shutdown_channel) {
- g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id));
+ GSource *source_id = g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id);
+ if (source_id != NULL) {
+ g_source_destroy(source_id);
+ } else {
+ thumb_err("G_SOURCE_ID is NULL");
+ }
g_io_channel_shutdown(req->channel, TRUE, NULL);
g_io_channel_unref(req->channel);
@@ -133,6 +147,51 @@ int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
g_queue_pop_nth(g_request_queue, i);
SAFE_FREE(req->path);
+ SAFE_FREE(req->userData);
+ SAFE_FREE(req);
+
+ break;
+ }
+ }
+ if (i == req_len) {
+// thumb_dbg("There's no %s in the queue", path);
+ }
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int __media_thumb_pop_raw_data_req_queue(int request_id, bool shutdown_channel)
+{
+ int req_len = 0, i;
+
+ if (g_request_queue == NULL) return MS_MEDIA_ERR_INVALID_PARAMETER;
+ req_len = g_queue_get_length(g_request_queue);
+
+ if (req_len <= 0) {
+// thumb_dbg("There is no request in the queue");
+ } else {
+
+ for (i = 0; i < req_len; i++) {
+ thumbRawReq *req = NULL;
+ req = (thumbRawReq *)g_queue_peek_nth(g_request_queue, i);
+ if (req == NULL) continue;
+
+ if (request_id == req->request_id) {
+ if (shutdown_channel) {
+ GSource *source_id = g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id);
+ if (source_id != NULL) {
+ g_source_destroy(source_id);
+ } else {
+ thumb_err("G_SOURCE_ID is NULL");
+ }
+
+ g_io_channel_shutdown(req->channel, TRUE, NULL);
+ g_io_channel_unref(req->channel);
+ }
+ g_queue_pop_nth(g_request_queue, i);
+
+ SAFE_FREE(req->userData);
SAFE_FREE(req);
break;
@@ -181,9 +240,21 @@ int
_media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
{
int recv_msg_len = 0;
+ int remain_size = 0;
+ int block_size = THUMB_SOCK_BLOCK_SIZE;
+ int recv_block = 0;
unsigned char *buf = NULL;
+ unsigned char *block_buf = NULL;
- buf = (unsigned char*)malloc(header_size);
+ 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);
+ SAFE_FREE(block_buf);
+ return MS_MEDIA_ERR_OUT_OF_MEMORY;
+ }
if ((recv_msg_len = recv(sock, buf, header_size, 0)) <= 0) {
thumb_stderror("recv failed");
@@ -192,34 +263,39 @@ _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
}
memcpy(msg, buf, header_size);
- //thumb_dbg("origin_path_size : %d, dest_path_size : %d", msg->origin_path_size, msg->dest_path_size);
+ //thumb_dbg("origin_path_size : %d, dest_path_size : %d, thumb_size : %d", msg->origin_path_size, msg->dest_path_size, msg->thumb_size);
SAFE_FREE(buf);
- buf = (unsigned char*)malloc(msg->origin_path_size);
+ remain_size = msg->origin_path_size + msg->dest_path_size + msg->thumb_size + 2;
+ buf = malloc(remain_size * sizeof(unsigned char));
+ memset(buf, 0, remain_size * sizeof(unsigned char));
- if ((recv_msg_len = recv(sock, buf, msg->origin_path_size, 0)) < 0) {
- thumb_err("recvfrom failed : %s", strerror(errno));
- SAFE_FREE(buf);
- return _media_thumb_get_error();
+ while(remain_size > 0) {
+ if(remain_size < THUMB_SOCK_BLOCK_SIZE) {
+ block_size = remain_size;
+ }
+ if ((recv_msg_len = recv(sock, block_buf, block_size, 0)) < 0) {
+ thumb_err("recv failed : %s", strerror(errno));
+ SAFE_FREE(buf);
+ SAFE_FREE(block_buf);
+ return _media_thumb_get_error();
+ }
+ memcpy(buf+recv_block, block_buf, block_size);
+ recv_block += block_size;
+ remain_size -= block_size;
}
- strncpy(msg->org_path, (char*)buf, msg->origin_path_size);
- //thumb_dbg("original path : %s", msg->org_path);
+ strncpy(msg->org_path, (char *)buf, msg->origin_path_size);
+ strncpy(msg->dst_path, (char *)buf + msg->origin_path_size + 1, msg->dest_path_size);
+ SAFE_FREE(msg->thumb_data);
+ msg->thumb_data = malloc(msg->thumb_size);
+ memset(msg->thumb_data, 0, msg->thumb_size);
+ memcpy(msg->thumb_data, buf + msg->origin_path_size + msg->dest_path_size + 2, msg->thumb_size);
SAFE_FREE(buf);
- buf = (unsigned char*)malloc(msg->dest_path_size);
+ SAFE_FREE(block_buf);
- if ((recv_msg_len = recv(sock, buf, msg->dest_path_size, 0)) < 0) {
- thumb_err("recvfrom failed : %s", strerror(errno));
- SAFE_FREE(buf);
- return _media_thumb_get_error();
- }
-
- strncpy(msg->dst_path, (char*)buf, msg->dest_path_size);
- //thumb_dbg("destination path : %s", msg->dst_path);
-
- SAFE_FREE(buf);
return MS_MEDIA_ERR_NONE;
}
@@ -273,20 +349,89 @@ _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
int org_path_len = 0;
int dst_path_len = 0;
+ int thumb_data_len = 0;
int size = 0;
int header_size = 0;
- header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2;
- org_path_len = strlen(req_msg->org_path) + 1;
- dst_path_len = strlen(req_msg->dst_path) + 1;
+ header_size = sizeof(thumbMsg) -(MAX_FILEPATH_LEN * 2) - sizeof(unsigned char *);
+ org_path_len = req_msg->origin_path_size + 1;
+ dst_path_len = req_msg->dest_path_size + 1;
+ thumb_data_len = req_msg->thumb_size;
- //thumb_dbg("Basic Size : %d, org_path : %s[%d], dst_path : %s[%d]", header_size, req_msg->org_path, org_path_len, req_msg->dst_path, dst_path_len);
+ //thumb_dbg("Basic Size : %d, org_path : %s[%d], dst_path : %s[%d], thumb_data_len : %d", header_size, req_msg->org_path, org_path_len, req_msg->dst_path, dst_path_len, thumb_data_len);
- size = header_size + org_path_len + dst_path_len;
+ size = header_size + org_path_len + dst_path_len + thumb_data_len;
*buf = malloc(size);
+
+ if (*buf == NULL) {
+ *buf_size = 0;
+ return 0;
+ }
memcpy(*buf, req_msg, header_size);
memcpy((*buf)+header_size, req_msg->org_path, org_path_len);
memcpy((*buf)+header_size + org_path_len, req_msg->dst_path, dst_path_len);
+ memcpy((*buf)+header_size + org_path_len + dst_path_len, req_msg->thumb_data, thumb_data_len);
+
+ *buf_size = size;
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int
+_media_thumb_set_buffer_for_response(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
+{
+ if (req_msg == NULL || buf == NULL) {
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ int org_path_len = 0;
+ int dst_path_len = 0;
+ int thumb_data_len = 0;
+ int size = 0;
+ int header_size = 0;
+
+ header_size = sizeof(thumbMsg) -(MAX_FILEPATH_LEN * 2) - sizeof(unsigned char *);
+ org_path_len = req_msg->origin_path_size + 1;
+ dst_path_len = req_msg->dest_path_size + 1;
+ thumb_data_len = 1;
+
+ thumb_dbg("Basic Size : %d, org_path : %s[%d], dst_path : %s[%d], thumb_data_len : %d", header_size, req_msg->org_path, org_path_len, req_msg->dst_path, dst_path_len, thumb_data_len);
+
+ size = header_size + org_path_len + dst_path_len + thumb_data_len;
+ *buf = malloc(size);
+
+ if (*buf == NULL) {
+ *buf_size = 0;
+ return 0;
+ }
+ memcpy(*buf, req_msg, header_size);
+ memcpy((*buf)+header_size, req_msg->org_path, org_path_len);
+ memcpy((*buf)+header_size + org_path_len, req_msg->dst_path, dst_path_len);
+ memcpy((*buf)+header_size + org_path_len + dst_path_len, req_msg->thumb_data, thumb_data_len);
+
+ *buf_size = size;
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+
+int
+_media_thumb_set_add_raw_data_buffer(thumbRawAddMsg *req_msg, unsigned char **buf, int *buf_size)
+{
+ if (req_msg == NULL || buf == NULL) {
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+ int thumb_len = 0;
+ int size = 0;
+ int header_size = 0;
+
+ header_size = sizeof(thumbRawAddMsg);
+ thumb_len = req_msg->thumb_size;
+
+ size = header_size + thumb_len;
+ *buf = malloc(size);
+ memcpy(*buf, req_msg, header_size);
+ memcpy((*buf)+header_size, req_msg->thumb_data, thumb_len);
*buf_size = size;
@@ -339,8 +484,11 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
req_msg.dst_path[strlen(req_msg.dst_path)] = '\0';
}
+ req_msg.thumb_data = (unsigned char *) "\0";
+
req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
req_msg.dest_path_size = strlen(req_msg.dst_path) + 1;
+ req_msg.thumb_size = 1;
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);
@@ -352,7 +500,7 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
int buf_size = 0;
int header_size = 0;
- header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2;
+ header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2 - sizeof(unsigned char *);
_media_thumb_set_buffer(&req_msg, &buf, &buf_size);
if (send(sock, buf, buf_size, 0) != buf_size) {
@@ -366,34 +514,37 @@ _media_thumb_request(int msg_type, media_thumb_type thumb_type, const char *orig
SAFE_FREE(buf);
- if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
- thumb_err("_media_thumb_recv_msg failed ");
- close(sock);
- 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);
+ 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);
+ return err;
+ }
- close(sock);
+ 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);
- if (recv_str_len > max_length) {
- thumb_err("user buffer is too small. Output's length is %d", recv_str_len);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
+ close(sock);
- if (recv_msg.status == THUMB_FAIL) {
- thumb_err("Failed to make thumbnail");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
+ if (recv_str_len > max_length) {
+ thumb_err("user buffer is too small. Output's length is %d", recv_str_len);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
- if (msg_type != THUMB_REQUEST_SAVE_FILE) {
- strncpy(thumb_path, recv_msg.dst_path, max_length);
- }
+ if (recv_msg.status == THUMB_FAIL) {
+ thumb_err("Failed to make thumbnail");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
- thumb_info->origin_width = recv_msg.origin_width;
- thumb_info->origin_height = recv_msg.origin_height;
+ if (msg_type != THUMB_REQUEST_SAVE_FILE) {
+ strncpy(thumb_path, recv_msg.dst_path, max_length);
+ }
+ thumb_info->origin_width = recv_msg.origin_width;
+ thumb_info->origin_height = recv_msg.origin_height;
+ }else {
+ thumb_dbg("No response msg_type:[%d]", msg_type);
+ }
return MS_MEDIA_ERR_NONE;
}
@@ -612,55 +763,148 @@ int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
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;
int header_size = 0;
- int recv_str_len = 0;
int sock = 0;
int err = MS_MEDIA_ERR_NONE;
memset((void *)&recv_msg, 0, sizeof(thumbMsg));
sock = g_io_channel_unix_get_fd(src);
- header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2;
+ header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2 - sizeof(unsigned char *);
thumb_err("_media_thumb_write_socket socket : %d", sock);
if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
thumb_err("_media_thumb_recv_msg failed ");
- g_io_channel_shutdown(src, TRUE, NULL);
+ if (recv_msg.origin_path_size > 0) {
+ __media_thumb_pop_req_queue(recv_msg.org_path, TRUE);
+ } else {
+ thumb_err("origin path size is wrong.");
+ }
+
return FALSE;
}
- recv_str_len = strlen(recv_msg.dst_path);
- thumb_dbg("recv %s(%d) in [ %s ] from thumb daemon is successful", recv_msg.dst_path, recv_str_len, recv_msg.org_path);
-
g_io_channel_shutdown(src, TRUE, NULL);
-
+ g_io_channel_unref(src);
//thumb_dbg("Completed..%s", recv_msg.org_path);
- __media_thumb_pop_req_queue(recv_msg.org_path, FALSE);
if (recv_msg.status == THUMB_FAIL) {
thumb_err("Failed to make thumbnail");
err = MS_MEDIA_ERR_INTERNAL;
- goto callback;
}
-callback:
if (data) {
thumbUserData* cb = (thumbUserData*)data;
- cb->func(err, recv_msg.dst_path, cb->user_data);
- free(cb);
- cb = NULL;
+ if (cb->func != NULL)
+ cb->func(err, recv_msg.dst_path, cb->user_data);
}
+ __media_thumb_pop_req_queue(recv_msg.org_path, FALSE);
+
thumb_dbg("Done");
return FALSE;
}
-int
-_media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char *origin_path, thumbUserData *userData, uid_t uid)
+gboolean _media_thumb_raw_data_write_socket(GIOChannel *src, GIOCondition condition, gpointer data)
+{
+ thumbMsg recv_msg;
+ int header_size = 0;
+ int sock = 0;
+ int err = MS_MEDIA_ERR_NONE;
+
+ memset((void *)&recv_msg, 0, sizeof(thumbMsg));
+ sock = g_io_channel_unix_get_fd(src);
+
+ header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2 - sizeof(unsigned char *);
+
+ thumb_err("_media_thumb_write_socket socket : %d", sock);
+
+ if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
+ thumb_err("_media_thumb_recv_msg failed ");
+ if (recv_msg.request_id > 0) {
+ __media_thumb_pop_raw_data_req_queue(recv_msg.request_id, TRUE);
+ } else {
+ thumb_err("origin path size is wrong.");
+ }
+
+ return FALSE;
+ }
+
+ g_io_channel_shutdown(src, TRUE, NULL);
+ g_io_channel_unref(src);
+
+ if (recv_msg.status == THUMB_FAIL) {
+ thumb_err("Failed to make thumbnail");
+ err = MS_MEDIA_ERR_INTERNAL;
+ }
+
+ if (data) {
+ thumbRawUserData* cb = (thumbRawUserData*)data;
+ if (cb->func != NULL)
+ cb->func(err, recv_msg.request_id, recv_msg.org_path, recv_msg.thumb_width, recv_msg.thumb_height, recv_msg.thumb_data, recv_msg.thumb_size, cb->user_data);
+ }
+
+ __media_thumb_pop_raw_data_req_queue(recv_msg.request_id, FALSE);
+
+ thumb_dbg("Done");
+
+ SAFE_FREE(recv_msg.thumb_data);
+
+ return FALSE;
+}
+
+int _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char *origin_path, thumbUserData *userData, uid_t uid)
{
int sock;
struct sockaddr_un serv_addr;
@@ -688,6 +932,7 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
thumb_err("connect error : %s", strerror(errno));
g_io_channel_shutdown(channel, TRUE, NULL);
+ g_io_channel_unref(channel);
return MS_MEDIA_ERR_SOCKET_CONN;
}
@@ -714,13 +959,17 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
req_msg.org_path[strlen(req_msg.org_path)] = '\0';
+ req_msg.dst_path[0] = '\0';
+ req_msg.thumb_data = (unsigned char *)"\0";
- req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
- req_msg.dest_path_size = strlen(req_msg.dst_path) + 1;
+ req_msg.origin_path_size = strlen(req_msg.org_path);
+ req_msg.dest_path_size = 1;
+ req_msg.thumb_size = 1;
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);
g_io_channel_shutdown(channel, TRUE, NULL);
+ g_io_channel_unref(channel);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
@@ -733,17 +982,13 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
SAFE_FREE(buf);
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);
return MS_MEDIA_ERR_SOCKET_SEND;
}
SAFE_FREE(buf);
thumb_dbg("Sending msg to thumbnail daemon is successful");
-#if 0
- if (msg_type == THUMB_REQUEST_CANCEL_MEDIA) {
- g_io_channel_shutdown(channel, TRUE, NULL);
- }
-#else
if (msg_type == THUMB_REQUEST_CANCEL_MEDIA) {
g_io_channel_shutdown(channel, TRUE, NULL);
@@ -758,17 +1003,122 @@ _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char
thumb_req = calloc(1, sizeof(thumbReq));
if (thumb_req == NULL) {
thumb_err("Failed to create request element");
- return MS_MEDIA_ERR_NONE;
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
}
thumb_req->channel = channel;
thumb_req->path = strdup(origin_path);
thumb_req->source_id = source_id;
+ thumb_req->userData = userData;
- //thumb_dbg("Push : %s [%d]", origin_path, sock);
g_queue_push_tail(g_request_queue, (gpointer)thumb_req);
}
-#endif
return MS_MEDIA_ERR_NONE;
}
+
+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 sock;
+ struct sockaddr_un serv_addr;
+ int pid;
+
+ if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
+ thumb_err("ms_ipc_create_client_socket failed");
+ return MS_MEDIA_ERR_SOCKET_CONN;
+ }
+ GIOChannel *channel = NULL;
+ channel = g_io_channel_unix_new(sock);
+ int source_id = -1;
+
+
+ memset(&serv_addr, 0, sizeof(serv_addr));
+ 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));
+ g_io_channel_shutdown(channel, TRUE, NULL);
+ g_io_channel_unref(channel);
+ return MS_MEDIA_ERR_SOCKET_CONN;
+ }
+
+ if (msg_type != THUMB_REQUEST_CANCEL_RAW_DATA) {
+ /* Create new channel to watch udp socket */
+ GSource *source = NULL;
+ source = g_io_create_watch(channel, G_IO_IN);
+
+ /* Set callback to be called when socket is readable */
+ /*NEED UPDATE SOCKET FILE DELETE*/
+ g_source_set_callback(source, (GSourceFunc)_media_thumb_raw_data_write_socket, userData, NULL);
+ source_id = g_source_attach(source, g_main_context_get_thread_default());
+ }
+
+ thumbMsg req_msg;
+ memset((void *)&req_msg, 0, sizeof(thumbMsg));
+
+ pid = getpid();
+ req_msg.pid = pid;
+ req_msg.msg_type = msg_type;
+ req_msg.thumb_type = MEDIA_THUMB_LARGE;
+ req_msg.request_id = request_id;
+ req_msg.thumb_width = width;
+ req_msg.thumb_height = height;
+ req_msg.uid = uid;
+
+ strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
+ req_msg.org_path[strlen(req_msg.org_path)] = '\0';
+ req_msg.dst_path[0] = '\0';
+ req_msg.thumb_data = (unsigned char *)"\0";
+
+ req_msg.origin_path_size = strlen(req_msg.org_path);
+ req_msg.dest_path_size = 1;
+ req_msg.thumb_size = 1;
+
+ if (req_msg.origin_path_size > MAX_PATH_SIZE) {
+ thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
+ g_io_channel_shutdown(channel, TRUE, NULL);
+ g_io_channel_unref(channel);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ unsigned char *buf = NULL;
+ int buf_size = 0;
+ _media_thumb_set_buffer(&req_msg, &buf, &buf_size);
+
+ if (send(sock, buf, buf_size, 0) != buf_size) {
+ thumb_err("sendto failed: %d", errno);
+ SAFE_FREE(buf);
+ 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);
+ return MS_MEDIA_ERR_SOCKET_SEND;
+ }
+
+ SAFE_FREE(buf);
+ thumb_dbg("Sending msg to thumbnail daemon is successful");
+
+ if (msg_type == THUMB_REQUEST_CANCEL_RAW_DATA) {
+ g_io_channel_shutdown(channel, TRUE, NULL);
+ __media_thumb_pop_raw_data_req_queue(request_id, TRUE);
+ } else if (msg_type == THUMB_REQUEST_RAW_DATA) {
+ if (g_request_queue == NULL) {
+ g_request_queue = g_queue_new();
+ }
+ thumbRawReq *thumb_req = NULL;
+ thumb_req = calloc(1, sizeof(thumbReq));
+ if (thumb_req == NULL) {
+ thumb_err("Failed to create request element");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+ thumb_req->channel = channel;
+ thumb_req->request_id = request_id;
+ thumb_req->source_id = source_id;
+ thumb_req->userData = userData;
+
+ g_queue_push_tail(g_request_queue, (gpointer)thumb_req);
+ }
+ return MS_MEDIA_ERR_NONE;
+}
diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c
index f7b764f..30e6f6b 100755
--- a/src/media-thumb-internal.c
+++ b/src/media-thumb-internal.c
@@ -887,11 +887,39 @@ int _media_thumb_jpeg(const char *origin_path,
return err;
}
+int _media_thumb_jpeg_for_raw(const char *origin_path,
+ int thumb_width,
+ int thumb_height,
+ media_thumb_format format,
+ media_thumb_info *thumb_info,
+ uid_t uid)
+{
+ int err = MS_MEDIA_ERR_NONE;
+ int orientation = NORMAL;
+
+ err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, orientation);
+
+ if (err != MS_MEDIA_ERR_NONE) {
+ thumb_err("decode_with_gdk failed : %d", err);
+ return err;
+ }
+
+ err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_RGB888, format);
+ if (err != MS_MEDIA_ERR_NONE) {
+ thumb_err("_media_thumb_convert_format falied: %d", err);
+ SAFE_FREE(thumb_info->data);
+ return err;
+ }
+ return err;
+}
+
int _media_thumb_image(const char *origin_path,
int thumb_width,
int thumb_height,
media_thumb_format format,
- media_thumb_info *thumb_info, uid_t uid)
+ media_thumb_info *thumb_info,
+ bool is_raw,
+ uid_t uid)
{
int err = MS_MEDIA_ERR_NONE;
int image_type = 0;
@@ -915,7 +943,11 @@ int _media_thumb_image(const char *origin_path,
if (image_type == IMG_CODEC_AGIF) {
err = _media_thumb_agif(origin_path, &image_info, thumb_width, thumb_height, format, thumb_info);
} else if (image_type == IMG_CODEC_JPEG) {
- err = _media_thumb_jpeg(origin_path, thumb_width, thumb_height, format, thumb_info, uid);
+ if(is_raw) {
+ err = _media_thumb_jpeg_for_raw(origin_path, thumb_width, thumb_height, format, thumb_info, uid);
+ } else {
+ err = _media_thumb_jpeg(origin_path, thumb_width, thumb_height, format, thumb_info, uid);
+ }
} else if (image_type == IMG_CODEC_PNG) {
err = _media_thumb_png(origin_path, thumb_width, thumb_height, format, thumb_info);
} else if (image_type == IMG_CODEC_GIF) {
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c
index 1099cb5..39d2ebf 100755
--- a/src/media-thumbnail.c
+++ b/src/media-thumbnail.c
@@ -204,6 +204,36 @@ int thumbnail_request_from_db_async(const char *origin_path, ThumbFunc func, voi
return MS_MEDIA_ERR_NONE;
}
+int thumbnail_request_extract_raw_data_async(int request_id, const char *origin_path, int width, int height, ThumbRawFunc func, void *user_data, uid_t uid)
+{
+ int err = MS_MEDIA_ERR_NONE;
+
+ if (origin_path == NULL || request_id == 0) {
+ thumb_err("Invalid parameter");
+ 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) doesn't exist.", origin_path);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+ thumb_dbg_slog("Path : %s", origin_path);
+
+ thumbRawUserData *userData = (thumbRawUserData*)malloc(sizeof(thumbRawUserData));
+ userData->func = func;
+ userData->user_data = user_data;
+
+ err = _media_thumb_request_raw_data_async(THUMB_REQUEST_RAW_DATA, request_id, origin_path, width, height, userData, uid);
+ if (err != MS_MEDIA_ERR_NONE) {
+ thumb_err("_media_raw_thumb_request failed : %d", err);
+ SAFE_FREE(userData);
+ return err;
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
int _media_thumbnail_cancel_cb(int error_code, char* path, void* data)
{
thumb_dbg("Error code : %d", error_code);
@@ -232,21 +262,43 @@ int thumbnail_request_cancel_media(const char *origin_path, uid_t uid)
return MS_MEDIA_ERR_NONE;
}
-int thumbnail_request_cancel_all(uid_t uid)
+int thumbnail_request_cancel_raw_data(int request_id, uid_t uid)
+{
+ int err = MS_MEDIA_ERR_NONE;
+ const char *dummy_str = "dummy";
+
+ if (request_id == 0) {
+ thumb_err("Invalid parameter");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ err = _media_thumb_request_raw_data_async(THUMB_REQUEST_CANCEL_RAW_DATA, request_id, dummy_str, 0, 0, NULL, uid);
+ if (err != MS_MEDIA_ERR_NONE) {
+ thumb_err("_media_thumb_request failed : %d", err);
+ return err;
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int thumbnail_request_cancel_all(bool is_raw_data, uid_t uid)
{
int err = MS_MEDIA_ERR_NONE;
media_thumb_info thumb_info;
- media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
char tmp_origin_path[MAX_PATH_SIZE] = {0,};
char tmp_thumb_path[MAX_PATH_SIZE] = {0,};
/* Request for thumb file to the daemon "Thumbnail generator" */
- err = _media_thumb_request(THUMB_REQUEST_CANCEL_ALL, thumb_type, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid);
+ if(is_raw_data) {
+ err = _media_thumb_request(THUMB_REQUEST_CANCEL_ALL_RAW_DATA, MEDIA_THUMB_LARGE, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid);
+ } else {
+ err = _media_thumb_request(THUMB_REQUEST_CANCEL_ALL, MEDIA_THUMB_LARGE, tmp_origin_path, tmp_thumb_path, sizeof(tmp_thumb_path), &thumb_info, uid);
+ }
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_request failed : %d", err);
return err;
}
- return err;
+ return MS_MEDIA_ERR_NONE;
}
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
index 5d98222..6dd2282 100755
--- a/src/util/media-thumb-util.c
+++ b/src/util/media-thumb-util.c
@@ -373,7 +373,7 @@ int _thumbnail_get_data(const char *origin_path,
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, uid);
+ 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;
@@ -399,4 +399,66 @@ int _thumbnail_get_data(const char *origin_path,
*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
diff --git a/test/test-thumb.c b/test/test-thumb.c
index 7fdc77b..eea85ac 100755
--- a/test/test-thumb.c
+++ b/test/test-thumb.c
@@ -25,6 +25,7 @@
#include <pthread.h>
#include <mm_util_imgp.h>
#include <mm_util_jpeg.h>
+#include <stdbool.h>
#include "media-thumbnail.h"
#include "media-thumb-debug.h"
@@ -158,7 +159,7 @@ int main(int argc, char *argv[])
} else if (mode == 7) {
printf("Test thumbnail_request_cancel_all\n");
- err = thumbnail_request_cancel_all();
+ err = thumbnail_request_cancel_all(true, tzplatform_getuid(TZ_USER_NAME));
if (err < 0) {
printf("thumbnail_request_cancel_all failed : %d\n", err);
return -1;