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
35 #define THUMB_SOCK_BLOCK_SIZE 512
37 static __thread GQueue *g_request_queue = NULL;
42 thumbUserData *userData;
49 thumbRawUserData *userData;
54 int _media_thumb_get_error()
56 if (errno == EWOULDBLOCK) {
57 thumb_err("Timeout. Can't try any more");
58 return MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT;
60 thumb_err("recvfrom failed : %s", strerror(errno));
61 return MS_MEDIA_ERR_SOCKET_RECEIVE;
65 int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel)
69 if (g_request_queue == NULL) return MS_MEDIA_ERR_INVALID_PARAMETER;
70 req_len = g_queue_get_length(g_request_queue);
73 // thumb_dbg("There is no request in the queue");
76 for (i = 0; i < req_len; i++) {
78 req = (thumbReq *)g_queue_peek_nth(g_request_queue, i);
79 if (req == NULL) continue;
81 if (strncmp(path, req->path, strlen(path)) == 0) {
82 if (shutdown_channel) {
83 GSource *source_id = g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id);
84 if (source_id != NULL) {
85 g_source_destroy(source_id);
87 thumb_err("G_SOURCE_ID is NULL");
90 g_io_channel_shutdown(req->channel, TRUE, NULL);
91 g_io_channel_unref(req->channel);
93 g_queue_pop_nth(g_request_queue, i);
96 SAFE_FREE(req->userData);
103 // thumb_dbg("There's no %s in the queue", path);
107 return MS_MEDIA_ERR_NONE;
110 int __media_thumb_pop_raw_data_req_queue(int request_id, 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 thumbRawReq *req = NULL;
123 req = (thumbRawReq *)g_queue_peek_nth(g_request_queue, i);
124 if (req == NULL) continue;
126 if (request_id == req->request_id) {
127 if (shutdown_channel) {
128 GSource *source_id = g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id);
129 if (source_id != NULL) {
130 g_source_destroy(source_id);
132 thumb_err("G_SOURCE_ID is NULL");
135 g_io_channel_shutdown(req->channel, TRUE, NULL);
136 g_io_channel_unref(req->channel);
138 g_queue_pop_nth(g_request_queue, i);
140 SAFE_FREE(req->userData);
147 // thumb_dbg("There's no %s in the queue", path);
151 return MS_MEDIA_ERR_NONE;
154 int __media_thumb_check_req_queue(const char *path)
158 req_len = g_queue_get_length(g_request_queue);
160 // thumb_dbg("Queue length : %d", req_len);
161 // thumb_dbg("Queue path : %s", path);
164 // thumb_dbg("There is no request in the queue");
167 for (i = 0; i < req_len; i++) {
168 thumbReq *req = NULL;
169 req = (thumbReq *)g_queue_peek_nth(g_request_queue, i);
170 if (req == NULL) continue;
172 if (strncmp(path, req->path, strlen(path)) == 0) {
173 //thumb_dbg("Same Request - %s", path);
174 return MS_MEDIA_ERR_INVALID_PARAMETER;
181 return MS_MEDIA_ERR_NONE;
185 _media_thumb_recv_msg(int sock, int header_size, thumbMsg *msg)
187 int recv_msg_len = 0;
189 int block_size = THUMB_SOCK_BLOCK_SIZE;
191 unsigned char *buf = NULL;
192 unsigned char *block_buf = NULL;
194 buf = (unsigned char*)malloc(header_size * sizeof(unsigned char));
195 block_buf = (unsigned char*)malloc(THUMB_SOCK_BLOCK_SIZE * sizeof(unsigned char));
196 if (buf == NULL || block_buf == NULL) {
197 thumb_err("memory allocation failed");
199 SAFE_FREE(block_buf);
200 return MS_MEDIA_ERR_OUT_OF_MEMORY;
203 if ((recv_msg_len = recv(sock, buf, header_size, 0)) <= 0) {
204 thumb_stderror("recv failed");
206 return _media_thumb_get_error();
209 memcpy(msg, buf, header_size);
210 //thumb_dbg("origin_path_size : %d, dest_path_size : %d, thumb_size : %d", msg->origin_path_size, msg->dest_path_size, msg->thumb_size);
214 remain_size = msg->origin_path_size + msg->dest_path_size + msg->thumb_size;
215 buf = malloc(remain_size * sizeof(unsigned char));
216 memset(buf, 0, remain_size * sizeof(unsigned char));
218 while(remain_size > 0) {
219 if(remain_size < THUMB_SOCK_BLOCK_SIZE) {
220 block_size = remain_size;
222 if ((recv_msg_len = recv(sock, block_buf, block_size, 0)) < 0) {
223 thumb_err("recv failed : %s", strerror(errno));
225 SAFE_FREE(block_buf);
226 return _media_thumb_get_error();
228 memcpy(buf+recv_block, block_buf, block_size);
229 recv_block += block_size;
230 remain_size -= block_size;
233 strncpy(msg->org_path, (char *)buf, msg->origin_path_size);
234 strncpy(msg->dst_path, (char *)buf + msg->origin_path_size, msg->dest_path_size);
236 SAFE_FREE(msg->thumb_data);
237 msg->thumb_data = malloc(msg->thumb_size);
238 memset(msg->thumb_data, 0, msg->thumb_size);
239 memcpy(msg->thumb_data, buf + msg->origin_path_size + msg->dest_path_size, msg->thumb_size);
242 SAFE_FREE(block_buf);
244 return MS_MEDIA_ERR_NONE;
248 _media_thumb_recv_udp_msg(int sock, int header_size, thumbMsg *msg, struct sockaddr_un *from_addr, unsigned int *from_size)
250 int recv_msg_len = 0;
251 unsigned int from_addr_size = sizeof(struct sockaddr_un);
252 unsigned char *buf = NULL;
254 buf = (unsigned char*)malloc(sizeof(thumbMsg));
256 if ((recv_msg_len = recvfrom(sock, buf, sizeof(thumbMsg), 0, (struct sockaddr *)from_addr, &from_addr_size)) < 0) {
257 thumb_stderror("recvform failed");
259 return _media_thumb_get_error();
262 memcpy(msg, buf, header_size);
264 if (msg->origin_path_size <= 0 || msg->origin_path_size > MAX_PATH_SIZE) {
266 thumb_err("msg->origin_path_size is invalid %d", msg->origin_path_size );
267 return MS_MEDIA_ERR_INVALID_PARAMETER;
270 strncpy(msg->org_path, (char*)buf + header_size, msg->origin_path_size);
272 if (msg->dest_path_size <= 0 || msg->dest_path_size > MAX_PATH_SIZE) {
274 thumb_err("msg->origin_path_size is invalid %d", msg->dest_path_size );
275 return MS_MEDIA_ERR_INVALID_PARAMETER;
278 strncpy(msg->dst_path, (char*)buf + header_size + msg->origin_path_size, msg->dest_path_size);
281 *from_size = from_addr_size;
283 return MS_MEDIA_ERR_NONE;
287 _media_thumb_set_buffer(thumbMsg *req_msg, unsigned char **buf, int *buf_size)
289 if (req_msg == NULL || buf == NULL) {
290 return MS_MEDIA_ERR_INVALID_PARAMETER;
293 int org_path_len = 0;
294 int dst_path_len = 0;
295 int thumb_data_len = 0;
299 header_size = sizeof(thumbMsg) -(MAX_FILEPATH_LEN * 2) - sizeof(unsigned char *);
300 org_path_len = req_msg->origin_path_size;
301 dst_path_len = req_msg->dest_path_size;
302 thumb_data_len = req_msg->thumb_size;
304 //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);
306 size = header_size + org_path_len + dst_path_len + thumb_data_len;
313 memcpy(*buf, req_msg, header_size);
314 memcpy((*buf)+header_size, req_msg->org_path, org_path_len);
315 memcpy((*buf)+header_size + org_path_len, req_msg->dst_path, dst_path_len);
316 if(thumb_data_len > 0)
317 memcpy((*buf)+header_size + org_path_len + dst_path_len, req_msg->thumb_data, thumb_data_len);
321 return MS_MEDIA_ERR_NONE;
325 _media_thumb_request(int msg_type, const char *origin_path, char *thumb_path, int max_length, media_thumb_info *thumb_info, uid_t uid)
328 struct sockaddr_un serv_addr;
329 ms_sock_info_s sock_info;
330 int recv_str_len = 0;
331 int err = MS_MEDIA_ERR_NONE;
333 sock_info.port = MS_THUMB_CREATOR_PORT;
335 err = ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock_info);
336 if (err != MS_MEDIA_ERR_NONE) {
337 thumb_err("ms_ipc_create_client_socket failed");
341 memset(&serv_addr, 0, sizeof(serv_addr));
342 sock = sock_info.sock_fd;
343 serv_addr.sun_family = AF_UNIX;
344 strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
346 /* Connecting to the thumbnail server */
347 if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
348 thumb_stderror("connect");
349 ms_ipc_delete_client_socket(&sock_info);
350 return MS_MEDIA_ERR_SOCKET_CONN;
356 memset((void *)&req_msg, 0, sizeof(thumbMsg));
357 memset((void *)&recv_msg, 0, sizeof(thumbMsg));
359 /* Get PID of client*/
363 /* Set requset message */
364 req_msg.msg_type = msg_type;
366 strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
367 req_msg.org_path[strlen(req_msg.org_path)] = '\0';
369 if (msg_type == THUMB_REQUEST_SAVE_FILE) {
370 strncpy(req_msg.dst_path, thumb_path, sizeof(req_msg.dst_path));
371 req_msg.dst_path[strlen(req_msg.dst_path)] = '\0';
374 req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
375 req_msg.dest_path_size = strlen(req_msg.dst_path) + 1;
376 req_msg.thumb_size = 0;
378 if (req_msg.origin_path_size > MAX_PATH_SIZE || req_msg.dest_path_size > MAX_PATH_SIZE) {
379 thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
380 ms_ipc_delete_client_socket(&sock_info);
381 return MS_MEDIA_ERR_INVALID_PARAMETER;
384 unsigned char *buf = NULL;
388 header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2 - sizeof(unsigned char *);
389 _media_thumb_set_buffer(&req_msg, &buf, &buf_size);
391 if (send(sock, buf, buf_size, 0) != buf_size) {
392 thumb_err("sendto failed: %d", errno);
394 ms_ipc_delete_client_socket(&sock_info);
395 return MS_MEDIA_ERR_SOCKET_SEND;
398 thumb_dbg("Sending msg to thumbnail daemon is successful");
402 if(msg_type != THUMB_REQUEST_CANCEL_ALL_RAW_DATA && msg_type != THUMB_REQUEST_CANCEL_ALL) { //No response..
403 if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
404 thumb_err("_media_thumb_recv_msg failed ");
405 ms_ipc_delete_client_socket(&sock_info);
409 recv_str_len = strlen(recv_msg.org_path);
410 thumb_dbg_slog("recv %s(%d) from thumb daemon is successful", recv_msg.org_path, recv_str_len);
412 ms_ipc_delete_client_socket(&sock_info);
414 if (recv_str_len > max_length) {
415 thumb_err("user buffer is too small. Output's length is %d", recv_str_len);
416 return MS_MEDIA_ERR_INVALID_PARAMETER;
419 if (recv_msg.status == THUMB_FAIL) {
420 thumb_err("Failed to make thumbnail");
421 return MS_MEDIA_ERR_INVALID_PARAMETER;
424 if (msg_type != THUMB_REQUEST_SAVE_FILE) {
425 strncpy(thumb_path, recv_msg.dst_path, max_length);
428 thumb_info->origin_width = recv_msg.origin_width;
429 thumb_info->origin_height = recv_msg.origin_height;
431 thumb_dbg("No response msg_type:[%d]", msg_type);
433 return MS_MEDIA_ERR_NONE;
436 gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpointer data)
441 int err = MS_MEDIA_ERR_NONE;
443 memset((void *)&recv_msg, 0, sizeof(thumbMsg));
444 sock = g_io_channel_unix_get_fd(src);
446 header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2 - sizeof(unsigned char *);
448 thumb_err("_media_thumb_write_socket socket : %d", sock);
450 if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
451 thumb_err("_media_thumb_recv_msg failed ");
452 if (recv_msg.origin_path_size > 0) {
453 __media_thumb_pop_req_queue(recv_msg.org_path, TRUE);
455 thumb_err("origin path size is wrong.");
461 g_io_channel_shutdown(src, TRUE, NULL);
462 g_io_channel_unref(src);
463 //thumb_dbg("Completed..%s", recv_msg.org_path);
465 if (recv_msg.status == THUMB_FAIL) {
466 thumb_err("Failed to make thumbnail");
467 err = MS_MEDIA_ERR_INTERNAL;
471 thumbUserData* cb = (thumbUserData*)data;
472 if (cb->func != NULL)
473 cb->func(err, recv_msg.dst_path, cb->user_data);
476 __media_thumb_pop_req_queue(recv_msg.org_path, FALSE);
482 gboolean _media_thumb_raw_data_write_socket(GIOChannel *src, GIOCondition condition, gpointer data)
487 int err = MS_MEDIA_ERR_NONE;
489 memset((void *)&recv_msg, 0, sizeof(thumbMsg));
490 sock = g_io_channel_unix_get_fd(src);
492 header_size = sizeof(thumbMsg) - MAX_PATH_SIZE*2 - sizeof(unsigned char *);
494 thumb_err("_media_thumb_write_socket socket : %d", sock);
496 if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) {
497 thumb_err("_media_thumb_recv_msg failed ");
498 if (recv_msg.request_id > 0) {
499 __media_thumb_pop_raw_data_req_queue(recv_msg.request_id, TRUE);
501 thumb_err("origin path size is wrong.");
507 g_io_channel_shutdown(src, TRUE, NULL);
508 g_io_channel_unref(src);
510 if (recv_msg.status == THUMB_FAIL) {
511 thumb_err("Failed to make thumbnail");
512 err = MS_MEDIA_ERR_INTERNAL;
516 thumbRawUserData* cb = (thumbRawUserData*)data;
517 if (cb->func != NULL)
518 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);
521 __media_thumb_pop_raw_data_req_queue(recv_msg.request_id, FALSE);
525 SAFE_FREE(recv_msg.thumb_data);
530 int _media_thumb_request_async(int msg_type, const char *origin_path, thumbUserData *userData, uid_t uid)
532 int err = MS_MEDIA_ERR_NONE;
534 struct sockaddr_un serv_addr;
535 ms_sock_info_s sock_info;
537 sock_info.port = MS_THUMB_CREATOR_PORT;
539 if ((msg_type == THUMB_REQUEST_DB_INSERT) && (__media_thumb_check_req_queue(origin_path) < 0)) {
540 return MS_MEDIA_ERR_THUMB_DUPLICATED_REQUEST;
543 err = ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock_info);
544 if(err != MS_MEDIA_ERR_NONE)
546 thumb_err("ms_ipc_create_client_socket failed");
550 memset(&serv_addr, 0, sizeof(serv_addr));
551 sock = sock_info.sock_fd;
552 serv_addr.sun_family = AF_UNIX;
553 strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
555 GIOChannel *channel = NULL;
556 channel = g_io_channel_unix_new(sock);
559 /* Connecting to the thumbnail server */
560 if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
561 thumb_stderror("connect");
562 g_io_channel_shutdown(channel, TRUE, NULL);
563 g_io_channel_unref(channel);
564 return MS_MEDIA_ERR_SOCKET_CONN;
567 if (msg_type != THUMB_REQUEST_CANCEL_MEDIA) {
568 /* Create new channel to watch udp socket */
569 GSource *source = NULL;
570 source = g_io_create_watch(channel, G_IO_IN);
572 /* Set callback to be called when socket is readable */
573 g_source_set_callback(source, (GSourceFunc)_media_thumb_write_socket, userData, NULL);
574 source_id = g_source_attach(source, g_main_context_get_thread_default());
578 memset((void *)&req_msg, 0, sizeof(thumbMsg));
582 req_msg.msg_type = msg_type;
585 strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
586 req_msg.org_path[strlen(req_msg.org_path)] = '\0';
587 req_msg.dst_path[0] = '\0';
588 req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
589 req_msg.dest_path_size = 1;
590 req_msg.thumb_size = 0;
592 if (req_msg.origin_path_size > MAX_PATH_SIZE || req_msg.dest_path_size > MAX_PATH_SIZE) {
593 thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
594 g_io_channel_shutdown(channel, TRUE, NULL);
595 g_io_channel_unref(channel);
596 ms_ipc_delete_client_socket(&sock_info);
597 return MS_MEDIA_ERR_INVALID_PARAMETER;
600 unsigned char *buf = NULL;
602 _media_thumb_set_buffer(&req_msg, &buf, &buf_size);
604 if (send(sock, buf, buf_size, 0) != buf_size) {
605 thumb_err("sendto failed: %d", errno);
607 g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), source_id));
608 g_io_channel_shutdown(channel, TRUE, NULL);
609 g_io_channel_unref(channel);
610 ms_ipc_delete_client_socket(&sock_info);
611 return MS_MEDIA_ERR_SOCKET_SEND;
615 thumb_dbg("Sending msg to thumbnail daemon is successful");
617 if (msg_type == THUMB_REQUEST_CANCEL_MEDIA) {
618 g_io_channel_shutdown(channel, TRUE, NULL);
619 __media_thumb_pop_req_queue(origin_path, TRUE);
620 } else if (msg_type == THUMB_REQUEST_DB_INSERT) {
621 if (g_request_queue == NULL) {
622 g_request_queue = g_queue_new();
625 thumbReq *thumb_req = NULL;
626 thumb_req = calloc(1, sizeof(thumbReq));
627 if (thumb_req == NULL) {
628 thumb_err("Failed to create request element");
629 return MS_MEDIA_ERR_INVALID_PARAMETER;
632 thumb_req->channel = channel;
633 thumb_req->path = strdup(origin_path);
634 thumb_req->source_id = source_id;
635 thumb_req->userData = userData;
637 g_queue_push_tail(g_request_queue, (gpointer)thumb_req);
640 return MS_MEDIA_ERR_NONE;
643 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)
645 int err = MS_MEDIA_ERR_NONE;
647 struct sockaddr_un serv_addr;
648 ms_sock_info_s sock_info;
650 sock_info.port = MS_THUMB_CREATOR_PORT;
652 err = ms_ipc_create_client_socket(MS_PROTOCOL_TCP, MS_TIMEOUT_SEC_10, &sock_info);
653 if(err != MS_MEDIA_ERR_NONE)
655 thumb_err("ms_ipc_create_client_socket failed");
659 memset(&serv_addr, 0, sizeof(serv_addr));
660 sock = sock_info.sock_fd;
661 serv_addr.sun_family = AF_UNIX;
662 strcpy(serv_addr.sun_path, "/var/run/media-server/media_ipc_thumbcreator.socket");
664 GIOChannel *channel = NULL;
665 channel = g_io_channel_unix_new(sock);
668 /* Connecting to the thumbnail server */
669 if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
670 thumb_err("connect error : %s", strerror(errno));
671 g_io_channel_shutdown(channel, TRUE, NULL);
672 g_io_channel_unref(channel);
673 return MS_MEDIA_ERR_SOCKET_CONN;
676 if (msg_type != THUMB_REQUEST_CANCEL_RAW_DATA) {
677 /* Create new channel to watch udp socket */
678 GSource *source = NULL;
679 source = g_io_create_watch(channel, G_IO_IN);
681 /* Set callback to be called when socket is readable */
682 /*NEED UPDATE SOCKET FILE DELETE*/
683 g_source_set_callback(source, (GSourceFunc)_media_thumb_raw_data_write_socket, userData, NULL);
684 source_id = g_source_attach(source, g_main_context_get_thread_default());
688 memset((void *)&req_msg, 0, sizeof(thumbMsg));
692 req_msg.msg_type = msg_type;
693 req_msg.request_id = request_id;
694 req_msg.thumb_width = width;
695 req_msg.thumb_height = height;
698 strncpy(req_msg.org_path, origin_path, sizeof(req_msg.org_path));
699 req_msg.org_path[strlen(req_msg.org_path)] = '\0';
700 req_msg.dst_path[0] = '\0';
702 req_msg.origin_path_size = strlen(req_msg.org_path) + 1;
703 req_msg.dest_path_size = 1;
704 req_msg.thumb_size = 0;
706 if (req_msg.origin_path_size > MAX_PATH_SIZE) {
707 thumb_err("path's length exceeds %d", MAX_PATH_SIZE);
708 g_io_channel_shutdown(channel, TRUE, NULL);
709 g_io_channel_unref(channel);
710 return MS_MEDIA_ERR_INVALID_PARAMETER;
713 unsigned char *buf = NULL;
715 _media_thumb_set_buffer(&req_msg, &buf, &buf_size);
717 if (send(sock, buf, buf_size, 0) != buf_size) {
718 thumb_err("sendto failed: %d", errno);
720 g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), source_id));
721 g_io_channel_shutdown(channel, TRUE, NULL);
722 g_io_channel_unref(channel);
723 return MS_MEDIA_ERR_SOCKET_SEND;
727 thumb_dbg("Sending msg to thumbnail daemon is successful");
729 if (msg_type == THUMB_REQUEST_CANCEL_RAW_DATA) {
730 g_io_channel_shutdown(channel, TRUE, NULL);
731 __media_thumb_pop_raw_data_req_queue(request_id, TRUE);
732 } else if (msg_type == THUMB_REQUEST_RAW_DATA) {
733 if (g_request_queue == NULL) {
734 g_request_queue = g_queue_new();
736 thumbRawReq *thumb_req = NULL;
737 thumb_req = calloc(1, sizeof(thumbReq));
738 if (thumb_req == NULL) {
739 thumb_err("Failed to create request element");
740 return MS_MEDIA_ERR_INVALID_PARAMETER;
742 thumb_req->channel = channel;
743 thumb_req->request_id = request_id;
744 thumb_req->source_id = source_id;
745 thumb_req->userData = userData;
747 g_queue_push_tail(g_request_queue, (gpointer)thumb_req);
749 return MS_MEDIA_ERR_NONE;