4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include "media-thumbnail.h"
23 #include "media-thumb-ipc.h"
24 #include "media-thumb-util.h"
25 #include "media-thumb-db.h"
26 #include "media-thumb-debug.h"
34 #define GLOBAL_USER 0 //#define tzplatform_getenv(TZ_GLOBAL) //TODO
36 static __thread GQueue *g_request_queue = NULL;
43 int _media_thumb_create_socket(int sock_type, int *sock)
47 if ((sock_fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
48 thumb_err("socket failed: %s", strerror(errno));
49 return MS_MEDIA_ERR_SOCKET_CONN;
52 if (sock_type == CLIENT_SOCKET) {
53 struct timeval tv_timeout = { MS_TIMEOUT_SEC_10, 0 };
55 if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) {
56 thumb_err("setsockopt failed: %s", strerror(errno));
58 return MS_MEDIA_ERR_SOCKET_CONN;
60 } else if (sock_type == SERVER_SOCKET) {
64 if (setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &n_reuse, sizeof(n_reuse)) == -1) {
65 thumb_err("setsockopt failed: %s", strerror(errno));
67 return MS_MEDIA_ERR_SOCKET_CONN;
73 return MS_MEDIA_ERR_NONE;
77 int _media_thumb_create_udp_socket(int *sock)
81 if ((sock_fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
82 thumb_err("socket failed: %s", strerror(errno));
83 return MS_MEDIA_ERR_SOCKET_CONN;
86 struct timeval tv_timeout = { MS_TIMEOUT_SEC_10, 0 };
88 if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) {
89 thumb_err("setsockopt failed: %s", strerror(errno));
91 return MS_MEDIA_ERR_SOCKET_CONN;
96 return MS_MEDIA_ERR_NONE;
99 int _media_thumb_get_error()
101 if (errno == EWOULDBLOCK) {
102 thumb_err("Timeout. Can't try any more");
103 return MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT;
105 thumb_err("recvfrom failed : %s", strerror(errno));
106 return MS_MEDIA_ERR_SOCKET_RECEIVE;
110 int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
114 if (g_request_queue == NULL) return MS_MEDIA_ERR_INVALID_PARAMETER;
115 req_len = g_queue_get_length(g_request_queue);
118 // thumb_dbg("There is no request in the queue");
121 for (i = 0; i < req_len; i++) {
122 thumbReq *req = NULL;
123 req = (thumbReq *)g_queue_peek_nth(g_request_queue, i);
124 if (req == NULL) continue;
126 if (strncmp(path, req->path, strlen(path)) == 0) {
127 if (shutdown_channel) {
128 g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id));
130 g_io_channel_shutdown(req->channel, TRUE, NULL);
131 g_io_channel_unref(req->channel);
133 g_queue_pop_nth(g_request_queue, i);
135 SAFE_FREE(req->path);
142 // thumb_dbg("There's no %s in the queue", path);
146 return MS_MEDIA_ERR_NONE;
149 int __media_thumb_check_req_queue(const char *path)
153 if (g_request_queue == NULL) return MS_MEDIA_ERR_NONE;
154 req_len = g_queue_get_length(g_request_queue);
156 // thumb_dbg("Queue length : %d", req_len);
157 // thumb_dbg("Queue path : %s", path);
160 // thumb_dbg("There is no request in the queue");
163 for (i = 0; i < req_len; i++) {
164 thumbReq *req = NULL;
165 req = (thumbReq *)g_queue_peek_nth(g_request_queue, i);
166 if (req == NULL) continue;
168 if (strncmp(path, req->path, strlen(path)) == 0) {
169 //thumb_dbg("Same Request - %s", path);
170 return MS_MEDIA_ERR_INVALID_PARAMETER;
177 return MS_MEDIA_ERR_NONE;
181 _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
183 int recv_msg_len = 0;
184 unsigned char *buf = NULL;
186 buf = (unsigned char*)malloc(header_size);
188 if ((recv_msg_len = recv(sock, buf, header_size, 0)) <= 0) {
189 thumb_stderror("recv failed");
191 return _media_thumb_get_error();
194 memcpy(msg, buf, header_size);
195 //thumb_dbg("origin_path_size : %d, dest_path_size : %d", msg->origin_path_size, msg->dest_path_size);
199 buf = (unsigned char*)malloc(msg->origin_path_size);
201 if ((recv_msg_len = recv(sock, buf, msg->origin_path_size, 0)) < 0) {
202 thumb_err("recvfrom failed : %s", strerror(errno));
204 return _media_thumb_get_error();
207 strncpy(msg->org_path, (char*)buf, msg->origin_path_size);
208 //thumb_dbg("original path : %s", msg->org_path);
211 buf = (unsigned char*)malloc(msg->dest_path_size);
213 if ((recv_msg_len = recv(sock, buf, msg->dest_path_size, 0)) < 0) {
214 thumb_err("recvfrom failed : %s", strerror(errno));
216 return _media_thumb_get_error();
219 strncpy(msg->dst_path, (char*)buf, msg->dest_path_size);
220 //thumb_dbg("destination path : %s", msg->dst_path);
223 return MS_MEDIA_ERR_NONE;
227 _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_un *from_addr, unsigned int *from_size)
229 int recv_msg_len = 0;
230 unsigned int from_addr_size = sizeof(struct sockaddr_un);
231 unsigned char *buf = NULL;
233 buf = (unsigned char*)malloc(sizeof(thumbMsg));
235 if ((recv_msg_len = recvfrom(sock, buf, sizeof(thumbMsg), 0, (struct sockaddr *)from_addr, &from_addr_size)) < 0) {
236 thumb_stderror("recvform failed");
238 return _media_thumb_get_error();
241 memcpy(msg, buf, header_size);
243 if (msg->origin_path_size <= 0 || msg->origin_path_size > MAX_PATH_SIZE) {
245 thumb_err("msg->origin_path_size is invalid %d", msg->origin_path_size );
246 return MS_MEDIA_ERR_INVALID_PARAMETER;
249 strncpy(msg->org_path, (char*)buf + header_size, msg->origin_path_size);
250 //thumb_dbg("original path : %s", msg->org_path);
252 if (msg->dest_path_size <= 0 || msg->dest_path_size > MAX_PATH_SIZE) {
254 thumb_err("msg->origin_path_size is invalid %d", msg->dest_path_size );
255 return MS_MEDIA_ERR_INVALID_PARAMETER;
258 strncpy(msg->dst_path, (char*)buf + header_size + msg->origin_path_size, msg->dest_path_size);
259 //thumb_dbg("destination path : %s", msg->dst_path);
262 *from_size = from_addr_size;
264 return MS_MEDIA_ERR_NONE;
268 _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
270 if (req_msg == NULL || buf == NULL) {
271 return MS_MEDIA_ERR_INVALID_PARAMETER;
274 int org_path_len = 0;
275 int dst_path_len = 0;
279 header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2;
280 org_path_len = strlen(req_msg->org_path) + 1;
281 dst_path_len = strlen(req_msg->dst_path) + 1;
283 //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);
285 size = header_size + org_path_len + dst_path_len;
287 memcpy(*buf, req_msg, header_size);
288 memcpy((*buf)+header_size, req_msg->org_path, org_path_len);
289 memcpy((*buf)+header_size + org_path_len, req_msg->dst_path, dst_path_len);
293 return MS_MEDIA_ERR_NONE;
297 _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)
300 struct sockaddr_un serv_addr;
301 int recv_str_len = 0;
302 int err = MS_MEDIA_ERR_NONE;
305 if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
306 thumb_err("ms_ipc_create_client_socket failed");
307 return MS_MEDIA_ERR_SOCKET_CONN;
310 memset(&serv_addr, 0, sizeof(serv_addr));
311 serv_addr.sun_family = AF_UNIX;
312 strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
314 /* Connecting to the thumbnail server */
315 if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
316 thumb_stderror("connect");
317 return MS_MEDIA_ERR_SOCKET_CONN;
323 memset((void *)&req_msg, 0, sizeof(thumbMsg));
324 memset((void *)&recv_msg, 0, sizeof(thumbMsg));
326 /* Get PID of client*/
330 /* Set requset message */
331 req_msg.msg_type = msg_type;
332 req_msg.thumb_type = thumb_type;
334 strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
335 req_msg.org_path[strlen(req_msg.org_path)] = '\0';
337 if (msg_type == THUMB_REQUEST_SAVE_FILE) {
338 strncpy(req_msg.dst_path, thumb_path, sizeof(req_msg.dst_path));
339 req_msg.dst_path[strlen(req_msg.dst_path)] = '\0';
342 req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
343 req_msg.dest_path_size = strlen(req_msg.dst_path) + 1;
345 if (req_msg.origin_path_size > MAX_PATH_SIZE || req_msg.dest_path_size > MAX_PATH_SIZE) {
346 thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
348 return MS_MEDIA_ERR_INVALID_PARAMETER;
351 unsigned char *buf = NULL;
355 header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2;
356 _media_thumb_set_buffer(&req_msg, &buf, &buf_size);
358 if (send(sock, buf, buf_size, 0) != buf_size) {
359 thumb_err("sendto failed: %d", errno);
362 return MS_MEDIA_ERR_SOCKET_SEND;
365 thumb_dbg("Sending msg to thumbnail daemon is successful");
369 if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
370 thumb_err("_media_thumb_recv_msg failed ");
375 recv_str_len = strlen(recv_msg.org_path);
376 thumb_dbg_slog("recv %s(%d) from thumb daemon is successful", recv_msg.org_path, recv_str_len);
380 if (recv_str_len > max_length) {
381 thumb_err("user buffer is too small. Output's length is %d", recv_str_len);
382 return MS_MEDIA_ERR_INVALID_PARAMETER;
385 if (recv_msg.status == THUMB_FAIL) {
386 thumb_err("Failed to make thumbnail");
387 return MS_MEDIA_ERR_INVALID_PARAMETER;
390 if (msg_type != THUMB_REQUEST_SAVE_FILE) {
391 strncpy(thumb_path, recv_msg.dst_path, max_length);
394 thumb_info->origin_width = recv_msg.origin_width;
395 thumb_info->origin_height = recv_msg.origin_height;
397 return MS_MEDIA_ERR_NONE;
400 static int _mkdir(const char *dir, mode_t mode) {
405 snprintf(tmp, sizeof(tmp),"%s",dir);
407 if(tmp[len - 1] == '/')
409 for(p = tmp + 1; *p; p++)
415 return mkdir(tmp, mode);
418 static char* _media_thumb_get_default_path(uid_t uid)
420 char *result_psswd = NULL;
421 struct group *grpinfo = NULL;
424 result_psswd = strdup(THUMB_DEFAULT_PATH);
425 grpinfo = getgrnam("users");
426 if(grpinfo == NULL) {
427 thumb_err("getgrnam(users) returns NULL !");
433 struct passwd *userinfo = getpwuid(uid);
434 if(userinfo == NULL) {
435 thumb_err("getpwuid(%d) returns NULL !", uid);
438 grpinfo = getgrnam("users");
439 if(grpinfo == NULL) {
440 thumb_err("getgrnam(users) returns NULL !");
443 // Compare git_t type and not group name
444 if (grpinfo->gr_gid != userinfo->pw_gid) {
445 thumb_err("UID [%d] does not belong to 'users' group!", uid);
448 asprintf(&result_psswd, "%s/data/file-manager-service/.thumb/phone", userinfo->pw_dir);
452 _mkdir(result_psswd,S_IRWXU | S_IRWXG | S_IRWXO);
457 int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
460 GdkPixbuf *gdkdata = NULL;
467 char *thumb_path = NULL;
468 int need_update_db = 0;
471 if (req_msg == NULL || res_msg == NULL) {
472 thumb_err("Invalid msg!");
473 return MS_MEDIA_ERR_INVALID_PARAMETER;
476 int msg_type = req_msg->msg_type;
477 media_thumb_type thumb_type = req_msg->thumb_type;
478 const char *origin_path = req_msg->org_path;
480 // Currently, The color space that is supported by the gdk-pixbuf is only RGB.
481 media_thumb_format thumb_format = MEDIA_THUMB_RGB888;
483 thumb_path = res_msg->dst_path;
484 thumb_path[0] = '\0';
485 max_length = sizeof(res_msg->dst_path);
487 err = _media_thumb_db_connect(uid);
488 if (err != MS_MEDIA_ERR_NONE) {
489 thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
490 return MS_MEDIA_ERR_DB_CONNECT_FAIL;
493 if (msg_type == THUMB_REQUEST_DB_INSERT) {
494 err = _media_thumb_get_thumb_from_db_with_size(origin_path, thumb_path, max_length, &need_update_db, &origin_w, &origin_h);
495 if (err == MS_MEDIA_ERR_NONE) {
496 res_msg->origin_width = origin_w;
497 res_msg->origin_height = origin_h;
498 _media_thumb_db_disconnect();
499 return MS_MEDIA_ERR_NONE;
501 if (strlen(thumb_path) == 0) {
502 err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length,uid);
503 if (err != MS_MEDIA_ERR_NONE) {
504 thumb_err("_media_thumb_get_hash_name failed - %d\n", err);
505 strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
506 _media_thumb_db_disconnect();
510 thumb_path[strlen(thumb_path)] = '\0';
514 } else if (msg_type == THUMB_REQUEST_SAVE_FILE) {
515 strncpy(thumb_path, req_msg->dst_path, max_length);
517 } else if (msg_type == THUMB_REQUEST_ALL_MEDIA) {
518 err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length,uid);
520 thumb_err("_media_thumb_get_hash_name failed - %d\n", err);
521 strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
522 _media_thumb_db_disconnect();
526 thumb_path[strlen(thumb_path)] = '\0';
529 if (g_file_test(thumb_path,
530 G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
531 thumb_warn("thumb path already exists in file system.. remove the existed file");
532 _media_thumb_remove_file(thumb_path);
535 err = _thumbnail_get_data(origin_path, thumb_type, thumb_format, &gdkdata, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, uid);
536 if (err != MS_MEDIA_ERR_NONE) {
537 thumb_err("_thumbnail_get_data failed - %d\n", err);
538 if ( gdkdata != NULL ){
539 g_object_unref(gdkdata);
541 strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
542 _media_thumb_db_disconnect();
546 //thumb_dbg("Size : %d, W:%d, H:%d", thumb_size, thumb_w, thumb_h);
547 //thumb_dbg("Origin W:%d, Origin H:%d\n", origin_w, origin_h);
548 //thumb_dbg("Thumb : %s", thumb_path);
550 res_msg->msg_type = THUMB_RESPONSE;
551 res_msg->thumb_size = thumb_size;
552 res_msg->thumb_width = thumb_w;
553 res_msg->thumb_height = thumb_h;
554 res_msg->origin_width = origin_w;
555 res_msg->origin_height = origin_h;
557 /* If the image is transparent PNG format, make png file as thumbnail of this image */
560 err = _media_thumb_get_file_ext(origin_path, file_ext, sizeof(file_ext));
561 if (strncasecmp(file_ext, "png", 3) == 0) {
562 int len = strlen(thumb_path);
563 thumb_path[len - 3] = 'p';
564 thumb_path[len - 2] = 'n';
565 thumb_path[len - 1] = 'g';
567 thumb_dbg("Thumb path is changed : %s", thumb_path);
570 err = _media_thumb_save_to_file_with_gdk(gdkdata, thumb_w, thumb_h, alpha, thumb_path);
572 thumb_err("save_to_file_with_gdk failed - %d\n", err);
573 if ( gdkdata != NULL ){
574 g_object_unref(gdkdata);
577 if (msg_type == THUMB_REQUEST_DB_INSERT || msg_type == THUMB_REQUEST_ALL_MEDIA)
578 strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
580 _media_thumb_db_disconnect();
583 thumb_dbg("file save success\n");
588 fd = open(thumb_path, O_WRONLY);
590 thumb_warn("open failed");
594 thumb_warn("fsync failed");
600 g_object_unref(gdkdata);
602 /* DB update if needed */
603 if (need_update_db == 1) {
604 err = _media_thumb_update_db(origin_path, thumb_path, res_msg->origin_width, res_msg->origin_height, uid);
605 if (err != MS_MEDIA_ERR_NONE) {
606 thumb_err("_media_thumb_update_db failed : %d", err);
610 _media_thumb_db_disconnect();
612 return MS_MEDIA_ERR_NONE;
615 gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpointer data)
619 int recv_str_len = 0;
621 int err = MS_MEDIA_ERR_NONE;
623 memset((void *)&recv_msg, 0, sizeof(thumbMsg));
624 sock = g_io_channel_unix_get_fd(src);
626 header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2;
628 thumb_err("_media_thumb_write_socket socket : %d", sock);
630 if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
631 thumb_err("_media_thumb_recv_msg failed ");
632 g_io_channel_shutdown(src, TRUE, NULL);
636 recv_str_len = strlen(recv_msg.dst_path);
637 thumb_dbg("recv %s(%d) in [ %s ] from thumb daemon is successful", recv_msg.dst_path, recv_str_len, recv_msg.org_path);
639 g_io_channel_shutdown(src, TRUE, NULL);
641 //thumb_dbg("Completed..%s", recv_msg.org_path);
642 __media_thumb_pop_req_queue(recv_msg.org_path, FALSE);
644 if (recv_msg.status == THUMB_FAIL) {
645 thumb_err("Failed to make thumbnail");
646 err = MS_MEDIA_ERR_INTERNAL;
652 thumbUserData* cb = (thumbUserData*)data;
653 cb->func(err, recv_msg.dst_path, cb->user_data);
663 _media_thumb_request_async(int msg_type, media_thumb_type thumb_type, const char *origin_path, thumbUserData *userData, uid_t uid)
666 struct sockaddr_un serv_addr;
669 if ((msg_type == THUMB_REQUEST_DB_INSERT) && (__media_thumb_check_req_queue(origin_path) < 0)) {
670 return MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST;
673 if (ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock, MS_THUMB_CREATOR_PORT) < 0) {
674 thumb_err("ms_ipc_create_client_socket failed");
675 return MS_MEDIA_ERR_SOCKET_CONN;
677 GIOChannel *channel = NULL;
678 channel = g_io_channel_unix_new(sock);
682 memset(&serv_addr, 0, sizeof(serv_addr));
683 serv_addr.sun_family = AF_UNIX;
685 strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
687 /* Connecting to the thumbnail server */
688 if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
689 thumb_err("connect error : %s", strerror(errno));
690 g_io_channel_shutdown(channel, TRUE, NULL);
691 return MS_MEDIA_ERR_SOCKET_CONN;
694 if (msg_type != THUMB_REQUEST_CANCEL_MEDIA) {
695 //source_id = g_io_add_watch(channel, G_IO_IN, _media_thumb_write_socket, userData );
697 /* Create new channel to watch udp socket */
698 GSource *source = NULL;
699 source = g_io_create_watch(channel, G_IO_IN);
701 /* Set callback to be called when socket is readable */
702 g_source_set_callback(source, (GSourceFunc)_media_thumb_write_socket, userData, NULL);
703 source_id = g_source_attach(source, g_main_context_get_thread_default());
707 memset((void *)&req_msg, 0, sizeof(thumbMsg));
711 req_msg.msg_type = msg_type;
712 req_msg.thumb_type = thumb_type;
715 strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
716 req_msg.org_path[strlen(req_msg.org_path)] = '\0';
718 req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
719 req_msg.dest_path_size = strlen(req_msg.dst_path) + 1;
721 if (req_msg.origin_path_size > MAX_PATH_SIZE || req_msg.dest_path_size > MAX_PATH_SIZE) {
722 thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
723 g_io_channel_shutdown(channel, TRUE, NULL);
724 return MS_MEDIA_ERR_INVALID_PARAMETER;
727 unsigned char *buf = NULL;
729 _media_thumb_set_buffer(&req_msg, &buf, &buf_size);
731 if (send(sock, buf, buf_size, 0) != buf_size) {
732 thumb_err("sendto failed: %d", errno);
734 g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), source_id));
735 g_io_channel_shutdown(channel, TRUE, NULL);
736 return MS_MEDIA_ERR_SOCKET_SEND;
740 thumb_dbg("Sending msg to thumbnail daemon is successful");
743 if (msg_type == THUMB_REQUEST_CANCEL_MEDIA) {
744 g_io_channel_shutdown(channel, TRUE, NULL);
747 if (msg_type == THUMB_REQUEST_CANCEL_MEDIA) {
748 g_io_channel_shutdown(channel, TRUE, NULL);
750 //thumb_dbg("Cancel : %s[%d]", origin_path, sock);
751 __media_thumb_pop_req_queue(origin_path, TRUE);
752 } else if (msg_type == THUMB_REQUEST_DB_INSERT) {
753 if (g_request_queue == NULL) {
754 g_request_queue = g_queue_new();
757 thumbReq *thumb_req = NULL;
758 thumb_req = calloc(1, sizeof(thumbReq));
759 if (thumb_req == NULL) {
760 thumb_err("Failed to create request element");
761 return MS_MEDIA_ERR_NONE;
764 thumb_req->channel = channel;
765 thumb_req->path = strdup(origin_path);
766 thumb_req->source_id = source_id;
768 //thumb_dbg("Push : %s [%d]", origin_path, sock);
769 g_queue_push_tail(g_request_queue, (gpointer)thumb_req);
773 return MS_MEDIA_ERR_NONE;