Add new command dispatcher(current NULL) and modify return value for dispatcher
[platform/core/multimedia/mmsvc-camera.git] / muse / src / muse_camera_dispatcher.c
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <stdlib.h>
18 #include <string.h>
19 #include <errno.h>
20 #include <sys/types.h>
21 #include <sys/socket.h>
22 #include <sys/un.h>
23 #include <stdio.h>
24 #include <dlog.h>
25 #include "muse_camera_msg.h"
26 #include "muse_camera_internal.h"
27 #include <mm_types.h>
28 #include <muse_core_security.h>
29 #include <gst/gst.h>
30
31 #ifdef LOG_TAG
32 #undef LOG_TAG
33 #endif
34 #define LOG_TAG "MUSED_CAMERA"
35 #define KEY_LENGTH 24
36
37 #define CAMERA_PRIVILEGE_NAME "http://tizen.org/privilege/camera"
38 #define MUSED_KEY_DEVICE_STATE_CHECK  "camera_get_device_state_is_called"
39 #define MUSED_KEY_DEVICE_STATE_RETURN "camera_get_device_state_return"
40 #define MUSED_KEY_FLASH_STATE_CHECK   "camera_get_flash_state_is_called"
41 #define MUSED_KEY_FLASH_STATE_RETURN  "camera_get_flash_state_return"
42 #define MUSED_KEY_FLASH_STATE_COUNT   "camera_get_flash_state_count"
43
44 static int _camera_remove_export_data(muse_module_h module, int key, int remove_all);
45
46 static void __camera_dispatcher_send_msg(muse_module_h module, char *msg)
47 {
48         int len = 0;
49
50         if (!msg) {
51                 LOGE("NULL msg");
52                 return;
53         }
54
55         if (!module) {
56                 LOGE("NULL module");
57                 goto _DONE;
58         }
59
60         /*LOGD("msg [%s]", msg);*/
61
62         len = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), msg);
63         if (len <= 0)
64                 LOGE("sending message[%s] failed. errno %d", msg, errno);
65
66 _DONE:
67         muse_core_msg_json_factory_free(msg);
68
69         return;
70 }
71
72 static void muse_camera_msg_return(int api, int class, int ret, muse_module_h module)
73 {
74         char *send_msg = muse_core_msg_json_factory_new(api,
75                 MUSE_TYPE_INT, PARAM_API_CLASS, class,
76                 MUSE_TYPE_INT, PARAM_RET, ret,
77                 MUSE_TYPE_INT, PARAM_GET_TYPE, MUSE_CAMERA_GET_TYPE_NONE,
78                 0);
79
80         __camera_dispatcher_send_msg(module, send_msg);
81
82         return;
83 }
84
85 static void muse_camera_msg_return1(int api, int class, int ret, muse_module_h module,
86         int get_type, int index, const char *name, int value_int, void *value_pointer)
87 {
88         char *send_msg = NULL;
89
90         if (get_type == MUSE_CAMERA_GET_TYPE_INT) {
91                 send_msg = muse_core_msg_json_factory_new(api,
92                         MUSE_TYPE_INT, PARAM_API_CLASS, class,
93                         MUSE_TYPE_INT, PARAM_RET, ret,
94                         MUSE_TYPE_INT, PARAM_GET_TYPE, get_type,
95                         MUSE_TYPE_INT, PARAM_GET_INDEX, index,
96                         MUSE_TYPE_INT, name, value_int,
97                         0);
98         } else if (get_type == MUSE_CAMERA_GET_TYPE_STRING) {
99                 send_msg = muse_core_msg_json_factory_new(api,
100                         MUSE_TYPE_INT, PARAM_API_CLASS, class,
101                         MUSE_TYPE_INT, PARAM_RET, ret,
102                         MUSE_TYPE_INT, PARAM_GET_TYPE, get_type,
103                         MUSE_TYPE_INT, PARAM_GET_INDEX, index,
104                         MUSE_TYPE_STRING, name, value_pointer,
105                         0);
106         } else if (get_type == MUSE_CAMERA_GET_TYPE_POINTER) {
107                 send_msg = muse_core_msg_json_factory_new(api,
108                         MUSE_TYPE_INT, PARAM_API_CLASS, class,
109                         MUSE_TYPE_INT, PARAM_RET, ret,
110                         MUSE_TYPE_INT, PARAM_GET_TYPE, get_type,
111                         MUSE_TYPE_INT, PARAM_GET_INDEX, index,
112                         MUSE_TYPE_POINTER, name, value_pointer,
113                         0);
114         } else {
115                 LOGW("unknown type %d", get_type);
116         }
117
118         __camera_dispatcher_send_msg(module, send_msg);
119
120         return;
121 }
122
123
124 static void muse_camera_msg_return2(int api, int class, int ret, muse_module_h module,
125         int get_type, int index, int value0, int value1)
126 {
127         char *send_msg = muse_core_msg_json_factory_new(api,
128                 MUSE_TYPE_INT, PARAM_API_CLASS, class,
129                 MUSE_TYPE_INT, PARAM_RET, ret,
130                 MUSE_TYPE_INT, PARAM_GET_TYPE, get_type,
131                 MUSE_TYPE_INT, PARAM_GET_INDEX, index,
132                 MUSE_TYPE_INT, "get_value0", value0,
133                 MUSE_TYPE_INT, "get_value1", value1,
134                 0);
135
136         __camera_dispatcher_send_msg(module, send_msg);
137
138         return;
139 }
140
141
142 static void muse_camera_msg_event1(int api, int event, int class, muse_module_h module, const char *name, int value)
143 {
144         char *send_msg = muse_core_msg_json_factory_new(api,
145                 MUSE_TYPE_INT, PARAM_EVENT, event,
146                 MUSE_TYPE_INT, PARAM_EVENT_CLASS, class,
147                 MUSE_TYPE_INT, name, value,
148                 0);
149
150         __camera_dispatcher_send_msg(module, send_msg);
151
152         return;
153 }
154
155
156 static void muse_camera_msg_event2(int api, int event, int class, muse_module_h module,
157         const char *name0, int value0, const char *name1, int value1)
158 {
159         char *send_msg = muse_core_msg_json_factory_new(api,
160                 MUSE_TYPE_INT, PARAM_EVENT, event,
161                 MUSE_TYPE_INT, PARAM_EVENT_CLASS, class,
162                 MUSE_TYPE_INT, name0, value0,
163                 MUSE_TYPE_INT, name1, value1,
164                 0);
165
166         __camera_dispatcher_send_msg(module, send_msg);
167
168         return;
169 }
170
171
172 static void muse_camera_msg_event3(int api, int event, int class, muse_module_h module,
173         const char *name0, int value0, const char *name1, int value1, const char *name2, int value2)
174 {
175         char *send_msg = muse_core_msg_json_factory_new(api,
176                 MUSE_TYPE_INT, PARAM_EVENT, event,
177                 MUSE_TYPE_INT, PARAM_EVENT_CLASS, class,
178                 MUSE_TYPE_INT, name0, value0,
179                 MUSE_TYPE_INT, name1, value1,
180                 MUSE_TYPE_INT, name2, value2,
181                 0);
182
183         __camera_dispatcher_send_msg(module, send_msg);
184
185         return;
186 }
187
188
189 void _camera_dispatcher_callback_supported_theater_mode(int param1, void *user_data)
190 {
191         muse_module_h module = (muse_module_h)user_data;
192
193         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
194                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE,
195                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
196                 module, "param1", param1);
197
198         return;
199 }
200
201 void _camera_dispatcher_callback_supported_af_mode(int param1, void *user_data)
202 {
203         muse_module_h module = (muse_module_h)user_data;
204
205         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
206                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE,
207                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
208                 module, "param1", param1);
209
210         return;
211 }
212
213 void _camera_dispatcher_callback_supported_exposure_mode(int param1, void *user_data)
214 {
215         muse_module_h module = (muse_module_h)user_data;
216
217         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
218                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE,
219                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
220                 module, "param1", param1);
221
222         return;
223 }
224
225 void _camera_dispatcher_callback_supported_iso_mode(int param1, void *user_data)
226 {
227         muse_module_h module = (muse_module_h)user_data;
228
229         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
230                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO,
231                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
232                 module, "param1", param1);
233
234         return;
235 }
236
237 void _camera_dispatcher_callback_supported_whitebalance(int param1, void *user_data)
238 {
239         muse_module_h module = (muse_module_h)user_data;
240
241         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
242                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE,
243                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
244                 module, "param1", param1);
245
246         return;
247 }
248
249 void _camera_dispatcher_callback_supported_effect(int param1, void *user_data)
250 {
251         muse_module_h module = (muse_module_h)user_data;
252
253         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
254                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT,
255                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
256                 module, "param1", param1);
257
258         return;
259 }
260
261 void _camera_dispatcher_callback_supported_scene_mode(int param1, void *user_data)
262 {
263         muse_module_h module = (muse_module_h)user_data;
264
265         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
266                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE,
267                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
268                 module, "param1", param1);
269
270         return;
271 }
272
273 void _camera_dispatcher_callback_supported_flash_mode(int param1, void *user_data)
274 {
275         muse_module_h module = (muse_module_h)user_data;
276
277         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
278                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE,
279                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
280                 module, "param1", param1);
281
282         return;
283 }
284
285 int _camera_dispatcher_callback_supported_flash_mode2(int param1, void *user_data)
286 {
287         int *count = (int *)user_data;
288
289         if (count)
290                 (*count)++;
291
292         return true;
293 }
294
295 void _camera_dispatcher_callback_supported_fps(int param1, void *user_data)
296 {
297         muse_module_h module = (muse_module_h)user_data;
298
299         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
300                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS,
301                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
302                 module, "param1", param1);
303
304         return;
305 }
306
307 void _camera_dispatcher_callback_supported_fps_by_resolution(int param1, void *user_data)
308 {
309         muse_module_h module = (muse_module_h)user_data;
310
311         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
312                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION,
313                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
314                 module, "param1", param1);
315
316         return;
317 }
318
319 void _camera_dispatcher_callback_supported_stream_flip(int param1, void *user_data)
320 {
321         muse_module_h module = (muse_module_h)user_data;
322
323         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
324                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP,
325                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
326                 module, "param1", param1);
327
328         return;
329 }
330
331 void _camera_dispatcher_callback_supported_stream_rotation(int param1, void *user_data)
332 {
333         muse_module_h module = (muse_module_h)user_data;
334
335         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
336                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION,
337                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
338                 module, "param1", param1);
339
340         return;
341 }
342
343 void _camera_dispatcher_callback_supported_capture_format(int param1, void *user_data)
344 {
345         muse_module_h module = (muse_module_h)user_data;
346
347         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
348                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT,
349                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
350                 module, "param1", param1);
351
352         return;
353 }
354
355 void _camera_dispatcher_callback_supported_preview_format(int param1, void *user_data)
356 {
357         muse_module_h module = (muse_module_h)user_data;
358
359         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
360                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT,
361                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
362                 module, "param1", param1);
363
364         return;
365 }
366
367 void _camera_dispatcher_callback_supported_preview_resolution(int param1, int param2, void *user_data)
368 {
369         muse_module_h module = (muse_module_h)user_data;
370
371         muse_camera_msg_event2(MUSE_CAMERA_CB_EVENT,
372                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION,
373                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
374                 module, "param1", param1, "param2", param2);
375
376         return;
377 }
378
379 void _camera_dispatcher_callback_supported_capture_resolution(int param1, int param2, void *user_data)
380 {
381         muse_module_h module = (muse_module_h)user_data;
382
383         muse_camera_msg_event2(MUSE_CAMERA_CB_EVENT,
384                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION,
385                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
386                 module, "param1", param1, "param2", param2);
387
388         return;
389 }
390
391 void _camera_dispatcher_callback_supported_ptz_type(int param1, void *user_data)
392 {
393         muse_module_h module = (muse_module_h)user_data;
394
395         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
396                 MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE,
397                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
398                 module, "param1", param1);
399
400         return;
401 }
402
403 static int _camera_remove_export_data(muse_module_h module, int key, int remove_all)
404 {
405         muse_camera_handle_s *muse_camera = NULL;
406         GList *tmp_list = NULL;
407         muse_camera_export_data *export_data = NULL;
408
409         if (module == NULL || (key <= 0 && remove_all == FALSE)) {
410                 LOGE("invalid parameter %p, %d", module, key);
411                 return FALSE;
412         }
413
414         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
415         if (muse_camera == NULL) {
416                 LOGE("NULL handle");
417                 return FALSE;
418         }
419
420         g_mutex_lock(&muse_camera->list_lock);
421
422         tmp_list = muse_camera->data_list;
423
424         while (tmp_list) {
425                 export_data = (muse_camera_export_data *)tmp_list->data;
426                 tmp_list = tmp_list->next;
427                 if (export_data) {
428                         if (export_data->key == key || remove_all) {
429                                 /*LOGD("key %d matched, remove it (remove_all %d)", key, remove_all);*/
430
431                                 if (remove_all) {
432                                         LOGW("remove remained export data key %d, internal buffer %p",
433                                                 export_data->key, export_data->internal_buffer);
434                                 }
435
436                                 if (export_data->is_capture) {
437                                         LOGD("capture callback is done");
438                                         g_cond_signal(&muse_camera->list_cond);
439                                 }
440
441                                 if (export_data->bo) {
442                                         tbm_bo_unref(export_data->bo);
443                                         export_data->bo = NULL;
444                                 } else {
445                                         LOGW("bo for key %d is NULL", key);
446                                 }
447
448                                 export_data->key = 0;
449
450                                 if (export_data->internal_buffer) {
451                                         gst_buffer_unref((GstBuffer *)export_data->internal_buffer);
452                                         export_data->internal_buffer = NULL;
453                                 }
454
455                                 if (export_data->data_bo) {
456                                         tbm_bo_unref(export_data->data_bo);
457                                         export_data->data_bo = NULL;
458                                 }
459
460                                 muse_camera->data_list = g_list_remove(muse_camera->data_list, export_data);
461
462                                 g_free(export_data);
463                                 export_data = NULL;
464
465                                 if (remove_all == FALSE) {
466                                         /*LOGD("key %d, remove done");*/
467                                         g_mutex_unlock(&muse_camera->list_lock);
468                                         return TRUE;
469                                 } else {
470                                         LOGD("check next data");
471                                 }
472                         }
473                 } else {
474                         LOGW("NULL data");
475                 }
476         }
477
478         g_mutex_unlock(&muse_camera->list_lock);
479
480         if (remove_all) {
481                 LOGW("remove all done");
482         } else {
483                 LOGE("should not be reached here - key %d", key);
484         }
485
486         return FALSE;
487 }
488
489
490 void _camera_dispatcher_capturing_cb(camera_image_data_s* image, camera_image_data_s* postview, camera_image_data_s* thumbnail, void *user_data)
491 {
492         muse_camera_handle_s *muse_camera = NULL;
493         int data_size_main = 0;
494         int data_size_post = 0;
495         int data_size_thumb = 0;
496         tbm_bo bo_main = NULL;
497         tbm_bo bo_post = NULL;
498         tbm_bo bo_thumb = NULL;
499         tbm_bo_handle bo_main_handle = {.ptr = NULL};
500         tbm_bo_handle bo_post_handle = {.ptr = NULL};
501         tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
502         muse_camera_export_data *export_data_main = NULL;
503         muse_camera_export_data *export_data_post = NULL;
504         muse_camera_export_data *export_data_thumb = NULL;
505         int tbm_key_main = 0;
506         int tbm_key_post = 0;
507         int tbm_key_thumb = 0;
508         muse_module_h module = (muse_module_h)user_data;
509         unsigned char *buf_pos = NULL;
510         gint64 end_time = 0;
511
512         LOGD("Enter!!");
513
514         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
515         if (!muse_camera || !image) {
516                 LOGE("invalid ptr %p %p", muse_camera, image);
517                 return;
518         }
519
520         /* main image */
521         export_data_main = g_new0(muse_camera_export_data, 1);
522         if (export_data_main == NULL) {
523                 LOGE("alloc export_data failed");
524                 return;
525         }
526
527         data_size_main = sizeof(camera_image_data_s) + image->size;
528         if (image->exif && image->exif_size > 0)
529                 data_size_main += image->exif_size;
530
531         /* alloc bo */
532         bo_main = tbm_bo_alloc(muse_camera->bufmgr, data_size_main, TBM_BO_DEFAULT);
533         if (bo_main == NULL) {
534                 LOGE("bo alloc failed");
535                 goto main_image_error;
536         }
537
538         bo_main_handle = tbm_bo_map(bo_main, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
539         if (bo_main_handle.ptr == NULL) {
540                 LOGE("bo map Error!");
541                 goto main_image_error;
542         }
543
544         buf_pos = (unsigned char *)bo_main_handle.ptr;
545         memcpy(buf_pos, image, sizeof(camera_image_data_s));
546         buf_pos += sizeof(camera_image_data_s);
547         memcpy(buf_pos, image->data, image->size);
548         if (image->exif && image->exif_size > 0) {
549                 buf_pos += image->size;
550                 memcpy(buf_pos, image->exif, image->exif_size);
551         }
552
553         tbm_bo_unmap(bo_main);
554
555         tbm_key_main = tbm_bo_export(bo_main);
556         if (tbm_key_main == 0) {
557                 LOGE("Create key_info ERROR!!");
558                 goto main_image_error;
559         }
560
561         LOGD("bo %p, vaddr %p, size %d, key %d",
562                 bo_main, bo_main_handle.ptr, data_size_main, tbm_key_main);
563
564         /* set bo info */
565         export_data_main->key = tbm_key_main;
566         export_data_main->bo = bo_main;
567         export_data_main->is_capture = true;
568
569         /* postview image */
570         if (postview && postview->size > 0) {
571                 data_size_post = sizeof(camera_image_data_s) + postview->size;
572
573                 export_data_post = g_new0(muse_camera_export_data, 1);
574                 if (export_data_post == NULL) {
575                         LOGE("alloc export_data failed");
576                         goto postview_image_error;
577                 }
578
579                 /* alloc bo */
580                 bo_post = tbm_bo_alloc(muse_camera->bufmgr, data_size_post, TBM_BO_DEFAULT);
581                 if (bo_post == NULL) {
582                         LOGE("bo alloc failed");
583                         goto postview_image_error;
584                 }
585
586                 bo_post_handle = tbm_bo_map(bo_post, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
587                 if (bo_post_handle.ptr == NULL) {
588                         LOGE("bo map Error!");
589                         goto postview_image_error;
590                 }
591
592                 buf_pos = (unsigned char *)bo_post_handle.ptr;
593                 memcpy(buf_pos, postview, sizeof(camera_image_data_s));
594                 buf_pos += sizeof(camera_image_data_s);
595                 memcpy(buf_pos, postview->data, postview->size);
596                 tbm_bo_unmap(bo_post);
597
598                 tbm_key_post = tbm_bo_export(bo_post);
599                 if (tbm_key_post == 0) {
600                         LOGE("Create key_info ERROR!!");
601                         goto postview_image_error;
602                 }
603
604                 /* set bo info */
605                 export_data_post->key = tbm_key_post;
606                 export_data_post->bo = bo_post;
607         }
608
609         /* thumbnail image */
610         if (thumbnail && thumbnail->size > 0) {
611                 data_size_thumb = sizeof(camera_image_data_s) + thumbnail->size;
612
613                 export_data_thumb = g_new0(muse_camera_export_data, 1);
614                 if (export_data_thumb == NULL) {
615                         LOGE("alloc export_data failed");
616                         goto thumbnail_image_error;
617                 }
618
619                 /* alloc bo */
620                 bo_thumb = tbm_bo_alloc(muse_camera->bufmgr, data_size_thumb, TBM_BO_DEFAULT);
621                 if (bo_thumb == NULL) {
622                         LOGE("bo alloc failed");
623                         goto thumbnail_image_error;
624                 }
625
626                 bo_thumb_handle = tbm_bo_map(bo_thumb, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
627                 if (bo_thumb_handle.ptr == NULL) {
628                         LOGE("bo map Error!");
629                         goto thumbnail_image_error;
630                 }
631
632                 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
633                 memcpy(buf_pos, thumbnail, sizeof(camera_image_data_s));
634                 buf_pos += sizeof(camera_image_data_s);
635                 memcpy(buf_pos, thumbnail->data, thumbnail->size);
636                 tbm_bo_unmap(bo_thumb);
637
638                 tbm_key_thumb = tbm_bo_export(bo_thumb);
639                 if (tbm_key_thumb == 0) {
640                         LOGE("Create key_info ERROR!!");
641                         goto thumbnail_image_error;
642                 }
643
644                 /* set bo info */
645                 export_data_thumb->key = tbm_key_thumb;
646                 export_data_thumb->bo = bo_thumb;
647         }
648
649         /* add bo info to list */
650         g_mutex_lock(&muse_camera->list_lock);
651
652         muse_camera->data_list = g_list_append(muse_camera->data_list, (gpointer)export_data_main);
653
654         if (export_data_post)
655                 muse_camera->data_list = g_list_append(muse_camera->data_list, (gpointer)export_data_post);
656
657         if (export_data_thumb)
658                 muse_camera->data_list = g_list_append(muse_camera->data_list, (gpointer)export_data_thumb);
659
660         /* send message */
661         muse_camera_msg_event3(MUSE_CAMERA_CB_EVENT,
662                 MUSE_CAMERA_EVENT_TYPE_CAPTURE,
663                 MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
664                 module, "tbm_key_main", tbm_key_main, "tbm_key_post", tbm_key_post, "tbm_key_thumb", tbm_key_thumb);
665
666         /* wait for capture callback return */
667         end_time = g_get_monotonic_time() + G_TIME_SPAN_SECOND * 3;
668         if (!g_cond_wait_until(&muse_camera->list_cond, &muse_camera->list_lock, end_time)) {
669                 LOGW("capture callback return timeout");
670         } else {
671                 LOGD("capture callback return");
672         }
673
674         g_mutex_unlock(&muse_camera->list_lock);
675
676         return;
677
678 thumbnail_image_error:
679         if (bo_thumb) {
680                 tbm_bo_unref(bo_thumb);
681                 bo_thumb = NULL;
682         }
683
684         if (export_data_thumb) {
685                 g_free(export_data_thumb);
686                 export_data_thumb = NULL;
687         }
688
689 postview_image_error:
690         if (bo_post) {
691                 tbm_bo_unref(bo_post);
692                 bo_post = NULL;
693         }
694
695         if (export_data_post) {
696                 g_free(export_data_post);
697                 export_data_post = NULL;
698         }
699
700 main_image_error:
701         if (bo_main) {
702                 tbm_bo_unref(bo_main);
703                 bo_main = NULL;
704         }
705
706         if (export_data_main) {
707                 g_free(export_data_main);
708                 export_data_main = NULL;
709         }
710
711         return;
712 }
713
714 void _camera_dispatcher_state_changed_cb(camera_state_e previous, camera_state_e current, bool by_policy, void *user_data)
715 {
716         muse_module_h module = (muse_module_h)user_data;
717         muse_camera_handle_s *muse_camera = NULL;
718         camera_device_e device_type = CAMERA_DEVICE_CAMERA0;
719         char value_key[KEY_LENGTH] = {'\0',};
720         int ret = CAMERA_ERROR_NONE;
721         int set_value = -1;
722
723         LOGD("Enter - previous %d, current %d, by_policy %d",
724              previous, current, by_policy);
725
726         muse_camera_msg_event3(MUSE_CAMERA_CB_EVENT,
727                 MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE,
728                 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
729                 module, "previous", previous, "current", current, "by_policy", by_policy);
730
731         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
732         if (!muse_camera) {
733                 LOGW("NULL muse camera handle");
734                 return;
735         }
736
737         ret = legacy_camera_get_device_type(muse_camera->camera_handle, &device_type);
738         if (ret != CAMERA_ERROR_NONE) {
739                 LOGE("get device type failed 0x%x", ret);
740                 return;
741         }
742
743         snprintf(value_key, KEY_LENGTH, "device_state_camera%d", device_type);
744         if (previous == CAMERA_STATE_CREATED && current == CAMERA_STATE_PREVIEW)
745                 set_value = CAMERA_DEVICE_STATE_WORKING;
746         else if (previous == CAMERA_STATE_PREVIEW && current == CAMERA_STATE_CREATED)
747                 set_value = CAMERA_DEVICE_STATE_NULL;
748
749         if (set_value != -1) {
750                 LOGD("device[%s] state set : %d", value_key, set_value);
751                 muse_core_client_set_value(module, value_key, set_value);
752         }
753
754         return;
755 }
756
757 void _camera_dispatcher_interrupted_cb(camera_policy_e policy, camera_state_e previous, camera_state_e current, void *user_data)
758 {
759         muse_module_h module = (muse_module_h)user_data;
760
761         LOGD("Enter - policy %d, state previous %d, current %d", policy, previous, current);
762
763         muse_camera_msg_event3(MUSE_CAMERA_CB_EVENT,
764                 MUSE_CAMERA_EVENT_TYPE_INTERRUPTED,
765                 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
766                 module, "policy", policy, "previous", previous, "current", current);
767
768         return;
769 }
770
771 void _camera_dispatcher_preview_cb(MMCamcorderVideoStreamDataType *stream, void *user_data)
772 {
773         muse_camera_handle_s *muse_camera = NULL;
774         int data_size = 0;
775         tbm_bo bo = NULL;
776         tbm_bo data_bo = NULL;
777         tbm_bo_handle bo_handle = {.ptr = NULL};
778         tbm_bo_handle data_bo_handle = {.ptr = NULL};
779         muse_camera_export_data *export_data = NULL;
780         int i = 0;
781         int tbm_key = 0;
782         int data_key = 0;
783         int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
784         int num_buffer_key = 0;
785         int send_ret = 0;
786         muse_module_h module = (muse_module_h)user_data;
787         unsigned char *buf_pos = NULL;
788         char *send_message = NULL;
789
790         /*LOGD("Enter");*/
791
792         if (module == NULL || stream == NULL) {
793                 LOGE("NULL data %p, %p", module, stream);
794                 return;
795         }
796
797         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
798         if (muse_camera == NULL) {
799                 LOGE("NULL handle");
800                 return;
801         }
802
803         export_data = g_new0(muse_camera_export_data, 1);
804         if (export_data == NULL) {
805                 LOGE("alloc export_data failed");
806                 return;
807         }
808
809         data_size = sizeof(MMCamcorderVideoStreamDataType);
810
811         bo = tbm_bo_alloc(muse_camera->bufmgr, data_size, TBM_BO_DEFAULT);
812         if (bo == NULL) {
813                 LOGE("bo alloc failed");
814                 goto _PREVIEW_CB_ERROR;
815         }
816
817         bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
818         if (bo_handle.ptr == NULL) {
819                 LOGE("bo map Error!");
820                 goto _PREVIEW_CB_ERROR;
821         }
822
823         buf_pos = (unsigned char *)bo_handle.ptr;
824
825         memcpy(buf_pos, stream, sizeof(MMCamcorderVideoStreamDataType));
826
827         tbm_bo_unmap(bo);
828
829         if (stream->bo[0] == NULL) {
830                 /* non-zero copy */
831                 switch (stream->data_type) {
832                 case MM_CAM_STREAM_DATA_YUV420:
833                         data_size = stream->data.yuv420.length_yuv;
834                         break;
835                 case MM_CAM_STREAM_DATA_YUV422:
836                         data_size = stream->data.yuv422.length_yuv;
837                         break;
838                 case MM_CAM_STREAM_DATA_YUV420SP:
839                         data_size = stream->data.yuv420sp.length_y;
840                         data_size += stream->data.yuv420sp.length_uv;
841                         break;
842                 case MM_CAM_STREAM_DATA_YUV420P:
843                         data_size = stream->data.yuv420p.length_y;
844                         data_size += stream->data.yuv420p.length_u;
845                         data_size += stream->data.yuv420p.length_v;
846                         break;
847                 case MM_CAM_STREAM_DATA_YUV422P:
848                         data_size = stream->data.yuv422p.length_y;
849                         data_size += stream->data.yuv422p.length_u;
850                         data_size += stream->data.yuv422p.length_v;
851                         break;
852                 case MM_CAM_STREAM_DATA_ENCODED:
853                         data_size = stream->data.encoded.length_data;
854                         break;
855                 default:
856                         LOGW("unknown data type %d", stream->data_type);
857                         break;
858                 }
859
860                 data_bo = tbm_bo_alloc(muse_camera->bufmgr, data_size, TBM_BO_DEFAULT);
861                 if (data_bo == NULL) {
862                         LOGE("data_bo alloc failed");
863                         goto _PREVIEW_CB_ERROR;
864                 }
865
866                 data_bo_handle = tbm_bo_map(data_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
867                 if (data_bo_handle.ptr == NULL) {
868                         LOGE("data_bo map Error!");
869                         goto _PREVIEW_CB_ERROR;
870                 }
871
872                 buf_pos = (unsigned char *)data_bo_handle.ptr;
873
874                 switch (stream->data_type) {
875                 case MM_CAM_STREAM_DATA_YUV420:
876                         memcpy(buf_pos, stream->data.yuv420.yuv, stream->data.yuv420.length_yuv);
877                         break;
878                 case MM_CAM_STREAM_DATA_YUV422:
879                         memcpy(buf_pos, stream->data.yuv422.yuv, stream->data.yuv422.length_yuv);
880                         break;
881                 case MM_CAM_STREAM_DATA_YUV420SP:
882                         memcpy(buf_pos, stream->data.yuv420sp.y, stream->data.yuv420sp.length_y);
883                         memcpy(buf_pos + stream->data.yuv420sp.length_y, stream->data.yuv420sp.uv, stream->data.yuv420sp.length_uv);
884                         break;
885                 case MM_CAM_STREAM_DATA_YUV420P:
886                         memcpy(buf_pos, stream->data.yuv420p.y, stream->data.yuv420p.length_y);
887                         memcpy(buf_pos + stream->data.yuv420p.length_y, stream->data.yuv420p.u, stream->data.yuv420p.length_u);
888                         memcpy(buf_pos + stream->data.yuv420p.length_y + stream->data.yuv420p.length_u, stream->data.yuv420p.v, stream->data.yuv420p.length_v);
889                         break;
890                 case MM_CAM_STREAM_DATA_YUV422P:
891                         memcpy(buf_pos, stream->data.yuv422p.y, stream->data.yuv422p.length_y);
892                         memcpy(buf_pos + stream->data.yuv422p.length_y, stream->data.yuv422p.u, stream->data.yuv422p.length_u);
893                         memcpy(buf_pos + stream->data.yuv422p.length_y + stream->data.yuv422p.length_u, stream->data.yuv422p.v, stream->data.yuv422p.length_v);
894                         break;
895                 case MM_CAM_STREAM_DATA_ENCODED:
896                         memcpy(buf_pos, stream->data.encoded.data, stream->data.encoded.length_data);
897                         break;
898                 default:
899                         break;
900                 }
901
902                 tbm_bo_unmap(data_bo);
903         } else {
904                 /* zero copy */
905                 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++) {
906                         if (stream->bo[i]) {
907                                 buffer_key[i] = tbm_bo_export(stream->bo[i]);
908                                 if (buffer_key[i] == 0) {
909                                         LOGE("failed to export bo %p", stream->bo[i]);
910                                         goto _PREVIEW_CB_ERROR;
911                                 }
912                                 num_buffer_key++;
913                         } else {
914                                 /*LOGD("num_buffer_key %d", num_buffer_key);*/
915                                 break;
916                         }
917                 }
918         }
919
920         tbm_key = tbm_bo_export(bo);
921         if (tbm_key == 0) {
922                 LOGE("Create key_info ERROR!!");
923                 goto _PREVIEW_CB_ERROR;
924         }
925
926         /*
927         LOGD("bo %p, vaddr %p, size %d, key %d",
928              bo, bo_handle.ptr, data_size, tbm_key);
929         */
930
931         /* set bo info */
932         export_data->key = tbm_key;
933         export_data->bo = bo;
934         if (stream->internal_buffer) {
935                 export_data->internal_buffer = stream->internal_buffer;
936                 gst_buffer_ref((GstBuffer *)export_data->internal_buffer);
937         }
938         if (data_bo) {
939                 export_data->data_bo = data_bo;
940                 data_key = tbm_bo_export(data_bo);
941                 if (data_key == 0) {
942                         LOGE("Create key_info for data_bo ERROR!!");
943                         goto _PREVIEW_CB_ERROR;
944                 }
945         }
946
947         /* add bo info to list */
948         g_mutex_lock(&muse_camera->list_lock);
949
950         muse_camera->data_list = g_list_append(muse_camera->data_list, (gpointer)export_data);
951
952         if (muse_camera->is_shutting_down) {
953                 LOGW("now shutting down.. skip this buffer");
954                 g_mutex_unlock(&muse_camera->list_lock);
955                 _camera_remove_export_data(module, tbm_key, FALSE);
956                 return;
957         }
958
959         g_mutex_unlock(&muse_camera->list_lock);
960
961         g_mutex_lock(&muse_camera->preview_cb_lock);
962
963         /* send message */
964         send_message = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
965                 MUSE_TYPE_INT, PARAM_EVENT, MUSE_CAMERA_EVENT_TYPE_PREVIEW,
966                 MUSE_TYPE_INT, PARAM_EVENT_CLASS, MUSE_CAMERA_EVENT_CLASS_THREAD_SUB,
967                 MUSE_TYPE_INT, "tbm_key", tbm_key,
968                 MUSE_TYPE_INT, "num_buffer_key", num_buffer_key,
969                 MUSE_TYPE_INT, "data_key", data_key,
970                 MUSE_TYPE_ARRAY, "buffer_key", BUFFER_MAX_PLANE_NUM, buffer_key,
971                 0);
972
973         send_ret = muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), send_message);
974
975         muse_core_msg_json_factory_free(send_message);
976
977         /*LOGD("wait preview callback return message");*/
978
979         if (!CHECK_PREVIEW_CB(muse_camera, PREVIEW_CB_TYPE_EVAS) && send_ret > 0) {
980                 gint64 end_time = g_get_monotonic_time() + G_TIME_SPAN_SECOND;
981
982                 if (!g_cond_wait_until(&muse_camera->preview_cb_cond, &muse_camera->preview_cb_lock, end_time)) {
983                         LOGW("preview callback return message timeout");
984                 } else {
985                         /*LOGD("preview callback return message received");*/
986                 }
987         }
988
989         g_mutex_unlock(&muse_camera->preview_cb_lock);
990
991         return;
992
993 _PREVIEW_CB_ERROR:
994         if (bo) {
995                 tbm_bo_unref(bo);
996                 bo = NULL;
997         }
998         if (data_bo) {
999                 tbm_bo_unref(data_bo);
1000                 data_bo = NULL;
1001         }
1002         if (export_data) {
1003                 g_free(export_data);
1004                 export_data = NULL;
1005         }
1006
1007         return;
1008 }
1009
1010 void _camera_dispatcher_capture_completed_cb(void *user_data)
1011 {
1012         muse_module_h module = (muse_module_h)user_data;
1013
1014         LOGD("Enter");
1015
1016         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
1017                 MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE,
1018                 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1019                 module, "none", 0);
1020
1021         return;
1022 }
1023
1024 void _camera_dispatcher_face_detected_cb(camera_detected_face_s *faces, int count, void *user_data)
1025 {
1026         muse_module_h module = (muse_module_h)user_data;
1027         muse_camera_handle_s *muse_camera = NULL;
1028         tbm_bo bo = NULL;
1029         tbm_bo_handle bo_handle = {NULL, };
1030         int bo_size = sizeof(camera_detected_face_s) * count;
1031         int tbm_key = 0;
1032         muse_camera_export_data *export_data = NULL;
1033
1034         if (count >= 0) {
1035                 if (module == NULL) {
1036                         LOGE("NULL module");
1037                         return;
1038                 }
1039
1040                 if (bo_size > 0) {
1041                         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1042                         if (muse_camera == NULL) {
1043                                 LOGE("NULL handle");
1044                                 return;
1045                         }
1046
1047                         export_data = g_new0(muse_camera_export_data, 1);
1048                         if (export_data == NULL) {
1049                                 LOGE("alloc export_data failed");
1050                                 return;
1051                         }
1052
1053                         bo = tbm_bo_alloc(muse_camera->bufmgr, bo_size, TBM_BO_DEFAULT);
1054                         if (bo == NULL) {
1055                                 LOGE("tbm_bo_alloc failed");
1056
1057                                 g_free(export_data);
1058                                 export_data = NULL;
1059
1060                                 return;
1061                         }
1062
1063                         bo_handle = tbm_bo_map(bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
1064                         if (bo_handle.ptr == NULL) {
1065                                 LOGE("bo map Error!");
1066
1067                                 tbm_bo_unref(bo);
1068                                 bo = NULL;
1069
1070                                 g_free(export_data);
1071                                 export_data = NULL;
1072
1073                                 return;
1074                         }
1075
1076                         /* copy face detection info */
1077                         memcpy(bo_handle.ptr, faces, bo_size);
1078
1079                         tbm_bo_unmap(bo);
1080
1081                         /* export bo */
1082                         tbm_key = tbm_bo_export(bo);
1083                         if (tbm_key == 0) {
1084                                 LOGE("failed to export bo for face detection info");
1085
1086                                 tbm_bo_unref(bo);
1087                                 bo = NULL;
1088
1089                                 g_free(export_data);
1090                                 export_data = NULL;
1091
1092                                 return;
1093                         }
1094
1095                         /* set export data */
1096                         export_data->bo = bo;
1097                         export_data->key = tbm_key;
1098
1099                         /* add bo info to list */
1100                         g_mutex_lock(&muse_camera->list_lock);
1101                         muse_camera->data_list = g_list_append(muse_camera->data_list, (gpointer)export_data);
1102                         g_mutex_unlock(&muse_camera->list_lock);
1103                 }
1104
1105                 LOGD("face - count %d, buffer size %d, key %d", count, bo_size, tbm_key);
1106
1107                 /* send message */
1108                 muse_camera_msg_event2(MUSE_CAMERA_CB_EVENT,
1109                         MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION,
1110                         MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1111                         module, "count", count, "tbm_key", tbm_key);
1112         } else {
1113                 LOGW("invalid count for face detection - %d", count);
1114         }
1115
1116         return;
1117 }
1118
1119 void _camera_dispatcher_focus_changed_cb(camera_focus_state_e state, void *user_data)
1120 {
1121         muse_module_h module = (muse_module_h)user_data;
1122
1123         LOGD("Enter - state %d", state);
1124
1125         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
1126                 MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE,
1127                 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1128                 module, "state", state);
1129
1130         return;
1131 }
1132
1133 void _camera_dispatcher_error_cb(camera_error_e error, camera_state_e current_state, void *user_data)
1134 {
1135         muse_module_h module = (muse_module_h)user_data;
1136
1137         LOGD("Enter - error 0x%x, current_state %d", error, current_state);
1138
1139         muse_camera_msg_event2(MUSE_CAMERA_CB_EVENT,
1140                 MUSE_CAMERA_EVENT_TYPE_ERROR,
1141                 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1142                 module, "error", error, "current_state", current_state);
1143
1144         return;
1145 }
1146
1147 void _camera_dispatcher_hdr_progress_cb(int percent, void *user_data)
1148 {
1149         muse_module_h module = (muse_module_h)user_data;
1150
1151         LOGD("Enter");
1152
1153         muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
1154                 MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS,
1155                 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1156                 module, "percent", percent);
1157
1158         return;
1159 }
1160
1161
1162 static void _camera_task_add_job(muse_camera_handle_s *muse_camera, int api, int class, int value)
1163 {
1164         muse_camera_task_job_s *job = NULL;
1165
1166         if (!muse_camera) {
1167                 LOGE("NULL handle");
1168                 return;
1169         }
1170
1171         job = g_new0(muse_camera_task_job_s, 1);
1172         if (!job) {
1173                 LOGE("job alloc failed");
1174                 muse_camera_msg_return(api, class, CAMERA_ERROR_INVALID_OPERATION, muse_camera->module);
1175                 return;
1176         }
1177
1178         job->api = api;
1179         job->class = class;
1180         job->value = value;
1181
1182         LOGD("push job - api %d", api);
1183
1184         g_mutex_lock(&muse_camera->task_lock);
1185         g_queue_push_tail(&muse_camera->task_queue, (gpointer)job);
1186         g_cond_signal(&muse_camera->task_cond);
1187         g_mutex_unlock(&muse_camera->task_lock);
1188
1189         return;
1190 }
1191
1192
1193 static void __camera_task_process_job(muse_camera_handle_s *muse_camera, muse_camera_task_job_s *job)
1194 {
1195         int ret = CAMERA_ERROR_NONE;
1196
1197         if (!muse_camera) {
1198                 LOGE("NULL handle");
1199                 goto _PROCESS_DONE;
1200         }
1201
1202         LOGD("job start - api %d, value 0x%x", job->api, job->value);
1203
1204         switch (job->api) {
1205         case MUSE_CAMERA_API_STOP_PREVIEW:
1206                 ret = legacy_camera_stop_preview(muse_camera->camera_handle);
1207                 break;
1208         case MUSE_CAMERA_API_START_CAPTURE:
1209                 ret = legacy_camera_start_capture(muse_camera->camera_handle,
1210                         (camera_capturing_cb)_camera_dispatcher_capturing_cb,
1211                         (camera_capture_completed_cb)_camera_dispatcher_capture_completed_cb,
1212                         (void *)muse_camera->module);
1213                 break;
1214         case MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION:
1215                 ret = legacy_camera_set_preview_resolution(muse_camera->camera_handle, \
1216                         job->value >> 16, 0x0000ffff & job->value);
1217                 break;
1218         case MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION:
1219                 ret = legacy_camera_set_capture_resolution(muse_camera->camera_handle, \
1220                         job->value >> 16, 0x0000ffff & job->value);
1221                 break;
1222         case MUSE_CAMERA_API_ATTR_SET_HDR_MODE:
1223                 ret = legacy_camera_attr_set_hdr_mode(muse_camera->camera_handle, \
1224                         (camera_attr_hdr_mode_e)job->value);
1225                 break;
1226         default:
1227                 LOGE("unhandled task - api %d", job->api);
1228                 goto _PROCESS_DONE;
1229         }
1230
1231         LOGD("job done - api %d, ret 0x%x", job->api, ret);
1232
1233         muse_camera_msg_return(job->api, job->class, ret, muse_camera->module);
1234
1235 _PROCESS_DONE:
1236         g_free(job);
1237         job = NULL;
1238
1239         return;
1240 }
1241
1242
1243 static void *_camera_dispatcher_task_func(gpointer data)
1244 {
1245         muse_camera_handle_s *muse_camera = (muse_camera_handle_s *)data;
1246         muse_camera_task_job_s *job = NULL;
1247         gint64 end_time = 0;
1248         bool is_signaled = false;
1249         bool use_wait_until = false;
1250
1251         if (!muse_camera) {
1252                 LOGE("NULL handle");
1253                 return NULL;
1254         }
1255
1256         LOGW("enter");
1257
1258         g_mutex_lock(&muse_camera->task_lock);
1259
1260         while (muse_camera->task_run) {
1261                 if (g_queue_is_empty(&muse_camera->task_queue)) {
1262                         LOGD("empty queue. wait signal [wait until %d]", use_wait_until);
1263
1264                         if (use_wait_until) {
1265                                 end_time = g_get_monotonic_time() + G_TIME_SPAN_SECOND;
1266                                 is_signaled = g_cond_wait_until(&muse_camera->task_cond, &muse_camera->task_lock, end_time);
1267                         } else {
1268                                 g_cond_wait(&muse_camera->task_cond, &muse_camera->task_lock);
1269                                 is_signaled = true;
1270                         }
1271
1272                         /*LOGD("is_signaled %d", is_signaled);*/
1273                 }
1274
1275                 if (!muse_camera->task_run) {
1276                         LOGW("stop task thread : is_signaled %d", is_signaled);
1277                         break;
1278                 }
1279
1280                 job = (muse_camera_task_job_s *)g_queue_pop_head(&muse_camera->task_queue);
1281                 if (!job) {
1282                         if (is_signaled)
1283                                 LOGE("signal received, but no job");
1284
1285                         continue;
1286                 }
1287
1288                 if (job->api == MUSE_CAMERA_API_STOP_PREVIEW)
1289                         use_wait_until = true;
1290                 else
1291                         use_wait_until = false;
1292
1293                 g_mutex_unlock(&muse_camera->task_lock);
1294
1295                 __camera_task_process_job(muse_camera, job);
1296
1297                 g_mutex_lock(&muse_camera->task_lock);
1298         }
1299
1300         while (!g_queue_is_empty(&muse_camera->task_queue)) {
1301                 job = (muse_camera_task_job_s *)g_queue_pop_head(&muse_camera->task_queue);
1302                 if (job) {
1303                         LOGW("remained job - api %d", job->api);
1304                         __camera_task_process_job(muse_camera, job);
1305                 }
1306         }
1307
1308         g_mutex_unlock(&muse_camera->task_lock);
1309
1310         LOGW("leave");
1311
1312         return NULL;
1313 }
1314
1315
1316 static void _camera_dispatcher_release_resource(muse_module_h module)
1317 {
1318         muse_camera_handle_s *muse_camera = NULL;
1319
1320         if (!module) {
1321                 LOGE("NULL handle");
1322                 return;
1323         }
1324
1325         LOGW("enter");
1326
1327         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1328
1329         _camera_remove_export_data(module, 0, TRUE);
1330
1331         g_mutex_clear(&muse_camera->list_lock);
1332         g_cond_clear(&muse_camera->list_cond);
1333         g_mutex_clear(&muse_camera->preview_cb_lock);
1334         g_cond_clear(&muse_camera->preview_cb_cond);
1335
1336         muse_camera->bufmgr = NULL;
1337
1338         if (muse_camera->task_thread) {
1339                 LOGW("task thread exiting start");
1340
1341                 g_mutex_lock(&muse_camera->task_lock);
1342                 muse_camera->task_run = false;
1343                 g_cond_signal(&muse_camera->task_cond);
1344                 g_mutex_unlock(&muse_camera->task_lock);
1345
1346                 LOGW("wait task thread join");
1347
1348                 g_thread_join(muse_camera->task_thread);
1349                 muse_camera->task_thread = NULL;
1350
1351                 LOGW("task thread exiting end");
1352         }
1353
1354         g_mutex_clear(&muse_camera->task_lock);
1355         g_cond_clear(&muse_camera->task_cond);
1356         g_queue_clear(&muse_camera->task_queue);
1357
1358         free(muse_camera);
1359         muse_camera = NULL;
1360
1361         LOGW("leave");
1362
1363         return;
1364 }
1365
1366
1367 int camera_dispatcher_create(muse_module_h module)
1368 {
1369         int ret = CAMERA_ERROR_NONE;
1370         int device_type;
1371         int client_fd = -1;
1372         int pid = 0;
1373         void *gdbus_connection = NULL;
1374         muse_camera_handle_s *muse_camera = NULL;
1375         muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
1376         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1377
1378         muse_camera_msg_get(device_type, muse_core_client_get_msg(module));
1379         muse_camera_msg_get(pid, muse_core_client_get_msg(module));
1380
1381         LOGD("device type : %d, client pid : %d", device_type, pid);
1382
1383         /* privilege check */
1384         client_fd = muse_core_client_get_msg_fd(module);
1385         if (!muse_core_security_check_cynara(client_fd, CAMERA_PRIVILEGE_NAME)) {
1386                 ret = CAMERA_ERROR_PERMISSION_DENIED;
1387                 LOGE("security check failed 0x%x", ret);
1388                 muse_camera_msg_return(api, class, ret, module);
1389                 return MUSE_CAMERA_ERROR_INVALID;
1390         }
1391
1392         /* init handle */
1393         muse_camera = (muse_camera_handle_s *)malloc(sizeof(muse_camera_handle_s));
1394         if (muse_camera == NULL) {
1395                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1396                 LOGE("handle alloc failed 0x%x", ret);
1397                 muse_camera_msg_return(api, class, ret, module);
1398                 return MUSE_CAMERA_ERROR_INVALID;
1399         }
1400
1401         memset(muse_camera, 0x0, sizeof(muse_camera_handle_s));
1402
1403         if (muse_core_ipc_get_bufmgr(&muse_camera->bufmgr) != MM_ERROR_NONE ||
1404                 muse_core_ipc_get_gdbus_connection((GDBusConnection **)&gdbus_connection) != MM_ERROR_NONE) {
1405                 LOGE("tbm bufmgr or gdbus conntection failed %p %p", muse_camera->bufmgr, gdbus_connection);
1406
1407                 free(muse_camera);
1408                 muse_camera = NULL;
1409
1410                 ret = CAMERA_ERROR_INVALID_OPERATION;
1411                 muse_camera_msg_return(api, class, ret, module);
1412
1413                 return MUSE_CAMERA_ERROR_INVALID;
1414         }
1415
1416         ret = legacy_camera_create((camera_device_e)device_type, &muse_camera->camera_handle);
1417         if (ret != CAMERA_ERROR_NONE) {
1418                 free(muse_camera);
1419                 muse_camera = NULL;
1420                 muse_camera_msg_return(api, class, ret, module);
1421
1422                 return MUSE_CAMERA_ERROR_INVALID;
1423         }
1424
1425         g_mutex_init(&muse_camera->task_lock);
1426         g_cond_init(&muse_camera->task_cond);
1427         g_queue_init(&muse_camera->task_queue);
1428
1429         muse_camera->task_run = true;
1430         muse_camera->task_thread = g_thread_try_new("camera_task_thread",
1431                 _camera_dispatcher_task_func, (gpointer)muse_camera, NULL);
1432         if (!muse_camera->task_thread) {
1433                 LOGE("failed to create new thread for task");
1434                 goto _CREATE_ERROR;
1435         }
1436
1437         ret = legacy_camera_set_state_changed_cb(muse_camera->camera_handle,
1438                 (camera_state_changed_cb)_camera_dispatcher_state_changed_cb,
1439                 (void *)module);
1440         if (ret != CAMERA_ERROR_NONE) {
1441                 LOGE("legacy_camera_set_state_changed_cb failed : 0x%x", ret);
1442                 goto _CREATE_ERROR;
1443         }
1444
1445         ret = legacy_camera_set_client_pid(muse_camera->camera_handle, pid);
1446         if (ret != CAMERA_ERROR_NONE) {
1447                 LOGE("legacy_camera_set_client_pid failed : 0x%x", ret);
1448                 goto _CREATE_ERROR;
1449         }
1450
1451         ret = legacy_camera_set_gdbus_connection(muse_camera->camera_handle, gdbus_connection);
1452         if (ret != CAMERA_ERROR_NONE) {
1453                 LOGE("legacy_camera_set_gdbus_connection failed : 0x%x", ret);
1454                 goto _CREATE_ERROR;
1455         }
1456
1457         g_mutex_init(&muse_camera->list_lock);
1458         g_cond_init(&muse_camera->list_cond);
1459         g_mutex_init(&muse_camera->preview_cb_lock);
1460         g_cond_init(&muse_camera->preview_cb_cond);
1461         muse_camera->preview_cb_flag = 0;
1462         muse_camera->module = module;
1463
1464         LOGD("handle : 0x%x", muse_camera);
1465
1466         muse_core_ipc_set_handle(module, (intptr_t)muse_camera);
1467         muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_POINTER, -1, "handle", 0, muse_camera);
1468
1469         return MUSE_CAMERA_ERROR_NONE;
1470
1471 _CREATE_ERROR:
1472         if (muse_camera->task_thread) {
1473                 g_mutex_lock(&muse_camera->task_lock);
1474                 muse_camera->task_run = false;
1475                 g_cond_signal(&muse_camera->task_cond);
1476                 g_mutex_unlock(&muse_camera->task_lock);
1477
1478                 LOGE("task thread join");
1479
1480                 g_thread_join(muse_camera->task_thread);
1481                 muse_camera->task_thread = NULL;
1482         }
1483
1484         g_mutex_clear(&muse_camera->task_lock);
1485         g_cond_clear(&muse_camera->task_cond);
1486         g_queue_clear(&muse_camera->task_queue);
1487
1488         legacy_camera_destroy(muse_camera->camera_handle);
1489         muse_camera->camera_handle = NULL;
1490
1491         free(muse_camera);
1492         muse_camera = NULL;
1493         muse_camera_msg_return(api, class, ret, module);
1494
1495         return MUSE_CAMERA_ERROR_INVALID;
1496 }
1497
1498
1499 int camera_dispatcher_change_device(muse_module_h module)
1500 {
1501         int ret = CAMERA_ERROR_NONE;
1502         int device = CAMERA_DEVICE_CAMERA0;
1503         muse_camera_handle_s *muse_camera = NULL;
1504         muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
1505         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1506
1507         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1508
1509         muse_camera_msg_get(device, muse_core_client_get_msg(module));
1510
1511         LOGD("change device to %d", device);
1512
1513         ret = legacy_camera_change_device(&muse_camera->camera_handle, device,
1514                 CHECK_PREVIEW_CB(muse_camera, PREVIEW_CB_TYPE_EVAS));
1515
1516         muse_camera_msg_return(api, class, ret, module);
1517
1518         return MUSE_CAMERA_ERROR_NONE;
1519 }
1520
1521
1522 int camera_dispatcher_destroy(muse_module_h module)
1523 {
1524         int ret = CAMERA_ERROR_NONE;
1525         muse_camera_handle_s *muse_camera = NULL;
1526         muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
1527         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1528
1529         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1530
1531         LOGD("Enter, handle : %p", muse_camera);
1532
1533         ret = legacy_camera_destroy(muse_camera->camera_handle);
1534         if (ret == CAMERA_ERROR_NONE)
1535                 _camera_dispatcher_release_resource(module);
1536
1537         muse_camera_msg_return(api, class, ret, module);
1538
1539         if (ret == CAMERA_ERROR_NONE)
1540                 return MUSE_CAMERA_ERROR_NONE;
1541         else
1542                 return MUSE_CAMERA_ERROR_INVALID;
1543 }
1544
1545 int camera_dispatcher_start_preview(muse_module_h module)
1546 {
1547         int ret = CAMERA_ERROR_NONE;
1548         muse_camera_handle_s *muse_camera = NULL;
1549         muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
1550         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1551
1552         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1553
1554         LOGD("handle : %p", muse_camera);
1555
1556         ret = legacy_camera_start_preview(muse_camera->camera_handle);
1557
1558         muse_camera_msg_return(api, class, ret, module);
1559
1560         return MUSE_CAMERA_ERROR_NONE;
1561 }
1562
1563 int camera_dispatcher_stop_preview(muse_module_h module)
1564 {
1565         muse_camera_handle_s *muse_camera = NULL;
1566
1567         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1568
1569         LOGD("handle : %p", muse_camera);
1570
1571         _camera_task_add_job(muse_camera, MUSE_CAMERA_API_STOP_PREVIEW,
1572                 MUSE_CAMERA_API_CLASS_IMMEDIATE, 0);
1573
1574         return MUSE_CAMERA_ERROR_NONE;
1575 }
1576
1577 int camera_dispatcher_start_capture(muse_module_h module)
1578 {
1579         muse_camera_handle_s *muse_camera = NULL;
1580
1581         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1582
1583         LOGD("handle : %p", muse_camera);
1584
1585         _camera_task_add_job(muse_camera, MUSE_CAMERA_API_START_CAPTURE,
1586                 MUSE_CAMERA_API_CLASS_IMMEDIATE, 0);
1587
1588         return MUSE_CAMERA_ERROR_NONE;
1589 }
1590
1591 int camera_dispatcher_is_supported_continuous_capture(muse_module_h module)
1592 {
1593         int ret = CAMERA_ERROR_NONE;
1594         muse_camera_handle_s *muse_camera = NULL;
1595         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
1596         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1597
1598         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1599
1600         LOGD("handle : %p", muse_camera);
1601
1602         ret = legacy_camera_is_supported_continuous_capture(muse_camera->camera_handle);
1603
1604         LOGD("is supported ret : %d", ret);
1605
1606         muse_camera_msg_return(api, class, ret, module);
1607
1608         return MUSE_CAMERA_ERROR_NONE;
1609 }
1610
1611 int camera_dispatcher_start_continuous_capture(muse_module_h module)
1612 {
1613         int ret = CAMERA_ERROR_NONE;
1614         muse_camera_handle_s *muse_camera = NULL;
1615         int value = 0;
1616         int count = 0;
1617         int interval = 0;
1618         muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
1619         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1620
1621         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1622
1623         muse_camera_msg_get(value, muse_core_client_get_msg(module));
1624
1625         count = value >> 16;
1626         interval = 0x0000ffff & value;
1627
1628         LOGD("Enter - count %d, interval %d", count, interval);
1629
1630         ret = legacy_camera_start_continuous_capture(muse_camera->camera_handle,
1631                 count,
1632                 interval,
1633                 (camera_capturing_cb)_camera_dispatcher_capturing_cb,
1634                 (camera_capture_completed_cb)_camera_dispatcher_capture_completed_cb,
1635                 (void *)module);
1636
1637         muse_camera_msg_return(api, class, ret, module);
1638
1639         return MUSE_CAMERA_ERROR_NONE;
1640 }
1641
1642 int camera_dispatcher_stop_continuous_capture(muse_module_h module)
1643 {
1644         int ret = CAMERA_ERROR_NONE;
1645         muse_camera_handle_s *muse_camera = NULL;
1646         muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
1647         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1648
1649         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1650
1651         LOGD("handle : %p", muse_camera);
1652
1653         ret = legacy_camera_stop_continuous_capture(muse_camera->camera_handle);
1654
1655         muse_camera_msg_return(api, class, ret, module);
1656
1657         return MUSE_CAMERA_ERROR_NONE;
1658 }
1659
1660 int camera_dispatcher_is_supported_face_detection(muse_module_h module)
1661 {
1662         int ret = CAMERA_ERROR_NONE;
1663         muse_camera_handle_s *muse_camera = NULL;
1664         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
1665         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1666
1667         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1668
1669         LOGD("handle : %p", muse_camera);
1670
1671         ret = legacy_camera_is_supported_face_detection(muse_camera->camera_handle);
1672
1673         LOGD("is supported ret : %d", ret);
1674
1675         muse_camera_msg_return(api, class, ret, module);
1676
1677         return MUSE_CAMERA_ERROR_NONE;
1678 }
1679
1680 int camera_dispatcher_is_supported_zero_shutter_lag(muse_module_h module)
1681 {
1682         int ret = CAMERA_ERROR_NONE;
1683         muse_camera_handle_s *muse_camera = NULL;
1684         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
1685         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1686
1687         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1688
1689         LOGD("handle : %p", muse_camera);
1690
1691         ret = legacy_camera_is_supported_zero_shutter_lag(muse_camera->camera_handle);
1692
1693         LOGD("is supported ret : %d", ret);
1694
1695         muse_camera_msg_return(api, class, ret, module);
1696
1697         return MUSE_CAMERA_ERROR_NONE;
1698 }
1699
1700 int camera_dispatcher_is_supported_media_packet_preview_cb(muse_module_h module)
1701 {
1702         int ret = CAMERA_ERROR_NONE;
1703         muse_camera_handle_s *muse_camera = NULL;
1704         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
1705         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1706
1707         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1708
1709         LOGD("handle : %p", muse_camera);
1710
1711         ret = legacy_camera_is_supported_media_packet_preview_cb(muse_camera->camera_handle);
1712
1713         LOGD("is supported ret : %d", ret);
1714
1715         muse_camera_msg_return(api, class, ret, module);
1716
1717         return MUSE_CAMERA_ERROR_NONE;
1718 }
1719
1720 int camera_dispatcher_get_device_count(muse_module_h module)
1721 {
1722         int ret = CAMERA_ERROR_NONE;
1723         muse_camera_handle_s *muse_camera = NULL;
1724         int get_value = 0;
1725         muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
1726         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1727
1728         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1729
1730         LOGD("handle : %p", muse_camera);
1731
1732         ret = legacy_camera_get_device_count(muse_camera->camera_handle, &get_value);
1733         if (ret == CAMERA_ERROR_NONE) {
1734                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
1735                         MUSE_CAMERA_GET_INT_DEVICE_COUNT, "get_value", get_value, NULL);
1736         } else {
1737                 muse_camera_msg_return(api, class, ret, module);
1738         }
1739
1740         return MUSE_CAMERA_ERROR_NONE;
1741 }
1742
1743 int camera_dispatcher_start_face_detection(muse_module_h module)
1744 {
1745         int ret = CAMERA_ERROR_NONE;
1746         muse_camera_handle_s *muse_camera = NULL;
1747         muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
1748         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1749
1750         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1751
1752         LOGD("Enter, handle : 0x%x, module : %d", muse_camera, module);
1753
1754         ret = legacy_camera_start_face_detection(muse_camera->camera_handle,
1755                 (camera_face_detected_cb)_camera_dispatcher_face_detected_cb,
1756                 (void *)module);
1757
1758         muse_camera_msg_return(api, class, ret, module);
1759
1760         return MUSE_CAMERA_ERROR_NONE;
1761 }
1762
1763 int camera_dispatcher_stop_face_detection(muse_module_h module)
1764 {
1765         int ret = CAMERA_ERROR_NONE;
1766         muse_camera_handle_s *muse_camera = NULL;
1767         muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
1768         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1769
1770         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1771
1772         LOGD("handle : %p", muse_camera);
1773
1774         ret = legacy_camera_stop_face_detection(muse_camera->camera_handle);
1775
1776         muse_camera_msg_return(api, class, ret, module);
1777
1778         return MUSE_CAMERA_ERROR_NONE;
1779 }
1780
1781 int camera_dispatcher_get_state(muse_module_h module)
1782 {
1783         int ret = CAMERA_ERROR_NONE;
1784         muse_camera_handle_s *muse_camera = NULL;
1785         camera_state_e get_value = CAMERA_STATE_NONE;
1786         muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
1787         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1788
1789         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1790
1791         LOGD("handle : %p", muse_camera);
1792
1793         ret = legacy_camera_get_state(muse_camera->camera_handle, &get_value);
1794         if (ret == CAMERA_ERROR_NONE) {
1795                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
1796                         MUSE_CAMERA_GET_INT_STATE, "get_value", get_value, NULL);
1797         } else {
1798                 muse_camera_msg_return(api, class, ret, module);
1799         }
1800
1801         return MUSE_CAMERA_ERROR_NONE;
1802 }
1803
1804 int camera_dispatcher_start_focusing(muse_module_h module)
1805 {
1806         int ret = CAMERA_ERROR_NONE;
1807         muse_camera_handle_s *muse_camera = NULL;
1808         int is_continuous;
1809         muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
1810         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1811
1812         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1813
1814         muse_camera_msg_get(is_continuous, muse_core_client_get_msg(module));
1815
1816         LOGD("Enter, handle : 0x%x, module : %d", muse_camera, module);
1817
1818         ret = legacy_camera_start_focusing(muse_camera->camera_handle, (bool)is_continuous);
1819
1820         muse_camera_msg_return(api, class, ret, module);
1821
1822         return MUSE_CAMERA_ERROR_NONE;
1823 }
1824
1825 int camera_dispatcher_stop_focusing(muse_module_h module)
1826 {
1827         int ret = CAMERA_ERROR_NONE;
1828         muse_camera_handle_s *muse_camera = NULL;
1829         muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
1830         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1831
1832         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1833
1834         LOGD("handle : %p", muse_camera);
1835
1836         ret = legacy_camera_cancel_focusing(muse_camera->camera_handle);
1837
1838         muse_camera_msg_return(api, class, ret, module);
1839
1840         return MUSE_CAMERA_ERROR_NONE;
1841 }
1842
1843 int camera_dispatcher_set_display(muse_module_h module)
1844 {
1845         int ret = CAMERA_ERROR_NONE;
1846         muse_camera_handle_s *muse_camera = NULL;
1847         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
1848         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1849         MMCamWaylandInfo *wl_info = NULL;
1850         camera_display_type_e type = CAMERA_DISPLAY_TYPE_NONE;
1851         camera_h camera = NULL;;
1852
1853         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1854
1855         LOGD("handle : 0x%x", muse_camera);
1856
1857         camera = muse_camera->camera_handle;
1858
1859         muse_camera_msg_get(type, muse_core_client_get_msg(module));
1860
1861         LOGD("type %d", type);
1862
1863         if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
1864                 wl_info = &muse_camera->wl_info;
1865                 muse_camera_msg_get_array(wl_info, muse_core_client_get_msg(module));
1866
1867                 LOGD("wayland global surface id : %d, window : %d,%d,%dx%d",
1868                         wl_info->global_surface_id, wl_info->window_x, wl_info->window_y,
1869                         wl_info->window_width, wl_info->window_height);
1870
1871                 ret = legacy_camera_set_display(muse_camera->camera_handle, type, (void *)wl_info);
1872
1873                 muse_camera_msg_return(api, class, ret, module);
1874         } else {
1875                 LOGD("NOT overlay type. set NONE type.");
1876
1877                 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
1878                         ret = legacy_camera_set_preview_cb(muse_camera->camera_handle,
1879                                 (camera_preview_cb)_camera_dispatcher_preview_cb,
1880                                 (void *)module);
1881
1882                         if (ret == CAMERA_ERROR_NONE)
1883                                 SET_PREVIEW_CB_TYPE(muse_camera, PREVIEW_CB_TYPE_EVAS);
1884                 }
1885
1886                 ret = legacy_camera_set_display(muse_camera->camera_handle, CAMERA_DISPLAY_TYPE_NONE, NULL);
1887
1888                 muse_camera_msg_return(api, class, ret, module);
1889         }
1890
1891         return MUSE_CAMERA_ERROR_NONE;
1892 }
1893
1894 int camera_dispatcher_set_preview_resolution(muse_module_h module)
1895 {
1896         int value = 0;
1897         muse_camera_handle_s *muse_camera = NULL;
1898
1899         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1900
1901         muse_camera_msg_get(value, muse_core_client_get_msg(module));
1902
1903         _camera_task_add_job(muse_camera, MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION,
1904                 MUSE_CAMERA_API_CLASS_IMMEDIATE, value);
1905
1906         return MUSE_CAMERA_ERROR_NONE;
1907 }
1908
1909 int camera_dispatcher_set_capture_resolution(muse_module_h module)
1910 {
1911         int value = 0;
1912         muse_camera_handle_s *muse_camera = NULL;
1913
1914         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1915
1916         muse_camera_msg_get(value, muse_core_client_get_msg(module));
1917
1918         _camera_task_add_job(muse_camera, MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION,
1919                 MUSE_CAMERA_API_CLASS_IMMEDIATE, value);
1920
1921         return MUSE_CAMERA_ERROR_NONE;
1922 }
1923
1924 int camera_dispatcher_set_capture_format(muse_module_h module)
1925 {
1926         int ret = CAMERA_ERROR_NONE;
1927         muse_camera_handle_s *muse_camera = NULL;
1928         int set_format;
1929         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
1930         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1931
1932         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1933
1934         muse_camera_msg_get(set_format, muse_core_client_get_msg(module));
1935
1936         LOGD("handle : 0x%x, set_format : %d", muse_camera, set_format);
1937
1938         ret = legacy_camera_set_capture_format(muse_camera->camera_handle, (camera_pixel_format_e)set_format);
1939
1940         muse_camera_msg_return(api, class, ret, module);
1941
1942         return MUSE_CAMERA_ERROR_NONE;
1943 }
1944
1945 int camera_dispatcher_set_preview_format(muse_module_h module)
1946 {
1947         int ret = CAMERA_ERROR_NONE;
1948         muse_camera_handle_s *muse_camera = NULL;
1949         int set_format;
1950         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
1951         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1952
1953         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1954
1955         muse_camera_msg_get(set_format, muse_core_client_get_msg(module));
1956
1957         LOGD("handle : 0x%x, set_format : %d", muse_camera, set_format);
1958
1959         ret = legacy_camera_set_preview_format(muse_camera->camera_handle, (camera_pixel_format_e)set_format);
1960
1961         muse_camera_msg_return(api, class, ret, module);
1962
1963         return MUSE_CAMERA_ERROR_NONE;
1964 }
1965
1966 int camera_dispatcher_get_preview_resolution(muse_module_h module)
1967 {
1968         int ret = CAMERA_ERROR_NONE;
1969         muse_camera_handle_s *muse_camera = NULL;
1970         int get_width = 0;
1971         int get_height = 0;
1972         int get_value = 0;
1973         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
1974         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1975
1976         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
1977
1978         LOGD("handle : %p", muse_camera);
1979
1980         ret = legacy_camera_get_preview_resolution(muse_camera->camera_handle, &get_width, &get_height);
1981         if (ret == CAMERA_ERROR_NONE) {
1982                 get_value = get_width << 16 | get_height;
1983                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
1984                         MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION, "get_value", get_value, NULL);
1985         } else {
1986                 muse_camera_msg_return(api, class, ret, module);
1987         }
1988
1989         return MUSE_CAMERA_ERROR_NONE;
1990 }
1991
1992 int camera_dispatcher_set_display_rotation(muse_module_h module)
1993 {
1994         int ret = CAMERA_ERROR_NONE;
1995         muse_camera_handle_s *muse_camera = NULL;
1996         int set_rotation;
1997         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROTATION;
1998         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
1999
2000         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2001
2002         muse_camera_msg_get(set_rotation, muse_core_client_get_msg(module));
2003
2004         LOGD("handle : 0x%x, set_rotation : %d", muse_camera, set_rotation);
2005
2006         ret = legacy_camera_set_display_rotation(muse_camera->camera_handle, (camera_rotation_e)set_rotation);
2007
2008         muse_camera_msg_return(api, class, ret, module);
2009
2010         return MUSE_CAMERA_ERROR_NONE;
2011 }
2012
2013 int camera_dispatcher_get_display_rotation(muse_module_h module)
2014 {
2015         int ret = CAMERA_ERROR_NONE;
2016         muse_camera_handle_s *muse_camera = NULL;
2017         camera_rotation_e get_value = CAMERA_ROTATION_NONE;
2018         muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROTATION;
2019         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2020
2021         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2022
2023         LOGD("handle : %p", muse_camera);
2024
2025         ret = legacy_camera_get_display_rotation(muse_camera->camera_handle, &get_value);
2026         if (ret == CAMERA_ERROR_NONE) {
2027                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2028                         MUSE_CAMERA_GET_INT_DISPLAY_ROTATION, "get_value", get_value, NULL);
2029         } else {
2030                 muse_camera_msg_return(api, class, ret, module);
2031         }
2032
2033         return MUSE_CAMERA_ERROR_NONE;
2034 }
2035
2036 int camera_dispatcher_set_display_flip(muse_module_h module)
2037 {
2038         int ret = CAMERA_ERROR_NONE;
2039         muse_camera_handle_s *muse_camera = NULL;
2040         int set_flip;
2041         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_FLIP;
2042         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2043
2044         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2045
2046         muse_camera_msg_get(set_flip, muse_core_client_get_msg(module));
2047
2048         LOGD("handle : 0x%x, set_flip : %d", muse_camera, set_flip);
2049
2050         ret = legacy_camera_set_display_flip(muse_camera->camera_handle, (camera_flip_e)set_flip);
2051
2052         muse_camera_msg_return(api, class, ret, module);
2053
2054         return MUSE_CAMERA_ERROR_NONE;
2055 }
2056
2057 int camera_dispatcher_get_display_flip(muse_module_h module)
2058 {
2059         int ret = CAMERA_ERROR_NONE;
2060         muse_camera_handle_s *muse_camera = NULL;
2061         camera_flip_e get_value = CAMERA_FLIP_NONE;
2062         muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_FLIP;
2063         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2064
2065         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2066
2067         LOGD("handle : %p", muse_camera);
2068
2069         ret = legacy_camera_get_display_flip(muse_camera->camera_handle, &get_value);
2070         if (ret == CAMERA_ERROR_NONE) {
2071                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2072                         MUSE_CAMERA_GET_INT_DISPLAY_FLIP, "get_value", get_value, NULL);
2073         } else {
2074                 muse_camera_msg_return(api, class, ret, module);
2075         }
2076
2077         return MUSE_CAMERA_ERROR_NONE;
2078 }
2079
2080 int camera_dispatcher_set_display_visible(muse_module_h module)
2081 {
2082         int ret = CAMERA_ERROR_NONE;
2083         muse_camera_handle_s *muse_camera = NULL;
2084         int set_visible;
2085         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_VISIBLE;
2086         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2087
2088         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2089
2090         muse_camera_msg_get(set_visible, muse_core_client_get_msg(module));
2091
2092         LOGD("handle : 0x%x, set_visible : %d", muse_camera, set_visible);
2093
2094         ret = legacy_camera_set_display_visible(muse_camera->camera_handle, (bool)set_visible);
2095
2096         muse_camera_msg_return(api, class, ret, module);
2097
2098         return MUSE_CAMERA_ERROR_NONE;
2099 }
2100
2101 int camera_dispatcher_is_display_visible(muse_module_h module)
2102 {
2103         int ret = CAMERA_ERROR_NONE;
2104         muse_camera_handle_s *muse_camera = NULL;
2105         bool get_value = true;
2106         muse_camera_api_e api = MUSE_CAMERA_API_IS_DISPLAY_VISIBLE;
2107         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2108
2109         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2110
2111         LOGD("handle : %p", muse_camera);
2112
2113         ret = legacy_camera_is_display_visible(muse_camera->camera_handle, &get_value);
2114         if (ret == CAMERA_ERROR_NONE) {
2115                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2116                         MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE, "get_value", get_value, NULL);
2117         } else {
2118                 muse_camera_msg_return(api, class, ret, module);
2119         }
2120
2121         return MUSE_CAMERA_ERROR_NONE;
2122 }
2123
2124 int camera_dispatcher_set_display_mode(muse_module_h module)
2125 {
2126         int ret = CAMERA_ERROR_NONE;
2127         muse_camera_handle_s *muse_camera = NULL;
2128         int set_mode;
2129         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_MODE;
2130         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2131
2132         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2133
2134         muse_camera_msg_get(set_mode, muse_core_client_get_msg(module));
2135
2136         LOGD("handle : 0x%x, display_mode : %d", muse_camera, set_mode);
2137
2138         ret = legacy_camera_set_display_mode(muse_camera->camera_handle, (camera_display_mode_e)set_mode);
2139
2140         LOGD("ret : 0x%x", ret);
2141
2142         muse_camera_msg_return(api, class, ret, module);
2143
2144         return MUSE_CAMERA_ERROR_NONE;
2145 }
2146
2147 int camera_dispatcher_get_display_mode(muse_module_h module)
2148 {
2149         int ret = CAMERA_ERROR_NONE;
2150         muse_camera_handle_s *muse_camera = NULL;
2151         camera_display_mode_e get_value = CAMERA_DISPLAY_MODE_LETTER_BOX;
2152         muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_MODE;
2153         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2154
2155         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2156
2157         LOGD("handle : %p", muse_camera);
2158
2159         ret = legacy_camera_get_display_mode(muse_camera->camera_handle, &get_value);
2160         if (ret == CAMERA_ERROR_NONE) {
2161                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2162                         MUSE_CAMERA_GET_INT_DISPLAY_MODE, "get_value", get_value, NULL);
2163         } else {
2164                 muse_camera_msg_return(api, class, ret, module);
2165         }
2166
2167         return MUSE_CAMERA_ERROR_NONE;
2168 }
2169
2170 int camera_dispatcher_get_capture_resolution(muse_module_h module)
2171 {
2172         int ret = CAMERA_ERROR_NONE;
2173         muse_camera_handle_s *muse_camera = NULL;
2174         int get_width = 0;
2175         int get_height = 0;
2176         int get_value = 0;
2177         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
2178         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2179
2180         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2181
2182         LOGD("handle : %p", muse_camera);
2183
2184         ret = legacy_camera_get_capture_resolution(muse_camera->camera_handle, &get_width, &get_height);
2185         if (ret == CAMERA_ERROR_NONE) {
2186                 get_value = get_width << 16 | get_height;
2187                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2188                         MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION, "get_value", get_value, NULL);
2189         } else {
2190                 muse_camera_msg_return(api, class, ret, module);
2191         }
2192
2193         return MUSE_CAMERA_ERROR_NONE;
2194 }
2195
2196 int camera_dispatcher_get_capture_format(muse_module_h module)
2197 {
2198         int ret = CAMERA_ERROR_NONE;
2199         muse_camera_handle_s *muse_camera = NULL;
2200         camera_pixel_format_e get_value = CAMERA_PIXEL_FORMAT_NV12;
2201         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
2202         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2203
2204         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2205
2206         LOGD("handle : %p", muse_camera);
2207
2208         ret = legacy_camera_get_capture_format(muse_camera->camera_handle, &get_value);
2209         if (ret == CAMERA_ERROR_NONE) {
2210                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2211                         MUSE_CAMERA_GET_INT_CAPTURE_FORMAT, "get_value", get_value, NULL);
2212         } else {
2213                 muse_camera_msg_return(api, class, ret, module);
2214         }
2215
2216         return MUSE_CAMERA_ERROR_NONE;
2217 }
2218
2219 int camera_dispatcher_get_preview_format(muse_module_h module)
2220 {
2221         int ret = CAMERA_ERROR_NONE;
2222         muse_camera_handle_s *muse_camera = NULL;
2223         camera_pixel_format_e get_value = CAMERA_PIXEL_FORMAT_NV12;
2224         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
2225         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2226
2227         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2228
2229         LOGD("handle : %p", muse_camera);
2230
2231         ret = legacy_camera_get_preview_format(muse_camera->camera_handle, &get_value);
2232         if (ret == CAMERA_ERROR_NONE) {
2233                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2234                         MUSE_CAMERA_GET_INT_PREVIEW_FORMAT, "get_value", get_value, NULL);
2235         } else {
2236                 muse_camera_msg_return(api, class, ret, module);
2237         }
2238
2239         return MUSE_CAMERA_ERROR_NONE;
2240 }
2241
2242 int camera_dispatcher_get_facing_direction(muse_module_h module)
2243 {
2244         int ret = CAMERA_ERROR_NONE;
2245         muse_camera_handle_s *muse_camera = NULL;
2246         camera_facing_direction_e get_value = CAMERA_FACING_DIRECTION_REAR;
2247         muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
2248         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2249
2250         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2251
2252         LOGD("handle : %p", muse_camera);
2253
2254         ret = legacy_camera_get_facing_direction(muse_camera->camera_handle, &get_value);
2255         if (ret == CAMERA_ERROR_NONE) {
2256                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2257                         MUSE_CAMERA_GET_INT_FACING_DIRECTION, "get_value", get_value, NULL);
2258         } else {
2259                 muse_camera_msg_return(api, class, ret, module);
2260         }
2261
2262         return MUSE_CAMERA_ERROR_NONE;
2263 }
2264
2265 int camera_dispatcher_get_flash_state(muse_module_h module)
2266 {
2267         int ret = CAMERA_ERROR_NONE;
2268         int count = 0;
2269         bool is_called = false;
2270         char value_key[KEY_LENGTH] = {'\0',};
2271         camera_h camera = NULL;
2272         camera_device_e device_type = CAMERA_DEVICE_CAMERA0;
2273         camera_flash_state_e get_flash_state = CAMERA_FLASH_STATE_NOT_USED;
2274         muse_camera_api_e api = MUSE_CAMERA_API_GET_FLASH_STATE;
2275         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2276
2277         muse_camera_msg_get(device_type, muse_core_client_get_msg(module));
2278
2279         if (device_type < CAMERA_DEVICE_CAMERA0 || device_type > CAMERA_DEVICE_CAMERA1) {
2280                 LOGE("invalid device %d", device_type);
2281
2282                 ret = CAMERA_ERROR_INVALID_PARAMETER;
2283                 muse_camera_msg_return(api, class, ret, module);
2284
2285                 return MUSE_CAMERA_ERROR_NONE;
2286         }
2287
2288         muse_core_client_get_value(module, MUSED_KEY_FLASH_STATE_CHECK, (int *)&is_called);
2289
2290         if (!is_called) {
2291                 ret = legacy_camera_create(device_type, &camera);
2292                 if (camera) {
2293                         legacy_camera_attr_foreach_supported_flash_mode(camera,
2294                                 (camera_attr_supported_flash_mode_cb)_camera_dispatcher_callback_supported_flash_mode2,
2295                                 (void *)&count);
2296
2297                         legacy_camera_destroy(camera);
2298                         camera = NULL;
2299                 }
2300
2301                 muse_core_client_set_value(module, MUSED_KEY_FLASH_STATE_RETURN, ret);
2302                 muse_core_client_set_value(module, MUSED_KEY_FLASH_STATE_COUNT, count);
2303                 muse_core_client_set_value(module, MUSED_KEY_FLASH_STATE_CHECK, (int)true);
2304         } else {
2305                 muse_core_client_get_value(module, MUSED_KEY_FLASH_STATE_RETURN, &ret);
2306                 muse_core_client_get_value(module, MUSED_KEY_FLASH_STATE_COUNT, &count);
2307         }
2308
2309         LOGD("is_called %d, ret 0x%x, count %d", is_called, ret, count);
2310
2311         if (ret != CAMERA_ERROR_NONE) {
2312                 LOGE("failed to create or get camera info 0x%x", ret);
2313
2314                 muse_camera_msg_return(api, class, ret, module);
2315
2316                 return MUSE_CAMERA_ERROR_NONE;
2317         }
2318
2319         if (count < 2) {
2320                 LOGE("count[%d] of supported flash mode is too small, so return NOT_SUPPORTED", count);
2321
2322                 ret = CAMERA_ERROR_NOT_SUPPORTED;
2323                 muse_camera_msg_return(api, class, ret, module);
2324
2325                 return MUSE_CAMERA_ERROR_NONE;
2326         }
2327
2328         snprintf(value_key, KEY_LENGTH, "flash_state_camera%d", device_type);
2329         muse_core_client_get_value(module, value_key, (int *)&get_flash_state);
2330
2331         LOGD("[%d] flash state : %d", device_type, get_flash_state);
2332
2333         muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2334                         -1, "get_flash_state", get_flash_state, NULL);
2335
2336         return MUSE_CAMERA_ERROR_NONE;
2337 }
2338
2339 int camera_dispatcher_set_preview_cb(muse_module_h module)
2340 {
2341         int ret = CAMERA_ERROR_NONE;
2342         muse_camera_handle_s *muse_camera = NULL;
2343         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
2344         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2345
2346         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2347
2348         LOGD("handle : %p", muse_camera);
2349
2350         ret = legacy_camera_set_preview_cb(muse_camera->camera_handle,
2351                 (camera_preview_cb)_camera_dispatcher_preview_cb,
2352                 (void *)module);
2353
2354         if (ret == CAMERA_ERROR_NONE)
2355                 SET_PREVIEW_CB_TYPE(muse_camera, PREVIEW_CB_TYPE_USER);
2356
2357         LOGD("ret : 0x%x", ret);
2358
2359         muse_camera_msg_return(api, class, ret, module);
2360
2361         return MUSE_CAMERA_ERROR_NONE;
2362 }
2363
2364 int camera_dispatcher_unset_preview_cb(muse_module_h module)
2365 {
2366         int ret = CAMERA_ERROR_NONE;
2367         muse_camera_handle_s *muse_camera = NULL;
2368         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
2369         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2370
2371         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2372
2373         LOGD("handle : %p", muse_camera);
2374
2375         UNSET_PREVIEW_CB_TYPE(muse_camera, PREVIEW_CB_TYPE_USER);
2376         if (CHECK_PREVIEW_CB(muse_camera, PREVIEW_CB_TYPE_EVAS))
2377                 LOGD("Preview callback for evas surface is remained.");
2378         else
2379                 ret = legacy_camera_unset_preview_cb(muse_camera->camera_handle);
2380
2381         LOGD("ret : 0x%x", ret);
2382
2383         muse_camera_msg_return(api, class, ret, module);
2384
2385         return MUSE_CAMERA_ERROR_NONE;
2386 }
2387
2388 int camera_dispatcher_set_media_packet_preview_cb(muse_module_h module)
2389 {
2390         int ret = CAMERA_ERROR_NONE;
2391         muse_camera_handle_s *muse_camera = NULL;
2392         muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
2393         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2394
2395         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2396
2397         LOGD("handle : %p", muse_camera);
2398
2399         ret = legacy_camera_set_media_packet_preview_cb(muse_camera->camera_handle,
2400                 (camera_preview_cb)_camera_dispatcher_preview_cb,
2401                 (void *)module);
2402
2403         LOGD("ret : 0x%x", ret);
2404
2405         muse_camera_msg_return(api, class, ret, module);
2406
2407         return MUSE_CAMERA_ERROR_NONE;
2408 }
2409
2410 int camera_dispatcher_unset_media_packet_preview_cb(muse_module_h module)
2411 {
2412         int ret = CAMERA_ERROR_NONE;
2413         muse_camera_handle_s *muse_camera = NULL;
2414         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
2415         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2416
2417         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2418
2419         LOGD("handle : %p", muse_camera);
2420
2421         ret = legacy_camera_unset_media_packet_preview_cb(muse_camera->camera_handle);
2422
2423         LOGD("ret : 0x%x", ret);
2424
2425         muse_camera_msg_return(api, class, ret, module);
2426
2427         return MUSE_CAMERA_ERROR_NONE;
2428 }
2429
2430 int camera_dispatcher_set_state_changed_cb(muse_module_h module)
2431 {
2432         int ret = CAMERA_ERROR_NONE;
2433         muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
2434         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2435
2436         LOGD("Enter");
2437
2438         muse_camera_msg_return(api, class, ret, module);
2439
2440         return MUSE_CAMERA_ERROR_NONE;
2441 }
2442
2443 int camera_dispatcher_unset_state_changed_cb(muse_module_h module)
2444 {
2445         int ret = CAMERA_ERROR_NONE;
2446         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
2447         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2448
2449         LOGD("Enter");
2450
2451         muse_camera_msg_return(api, class, ret, module);
2452
2453         return MUSE_CAMERA_ERROR_NONE;
2454 }
2455
2456 int camera_dispatcher_set_interrupted_cb(muse_module_h module)
2457 {
2458         int ret = CAMERA_ERROR_NONE;
2459         muse_camera_handle_s *muse_camera = NULL;
2460         muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
2461         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2462
2463         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2464
2465         LOGD("handle : %p", muse_camera);
2466
2467         ret = legacy_camera_set_interrupted_cb(muse_camera->camera_handle,
2468                 (camera_interrupted_cb)_camera_dispatcher_interrupted_cb,
2469                 (void *)module);
2470
2471         LOGD("ret : 0x%x", ret);
2472
2473         muse_camera_msg_return(api, class, ret, module);
2474
2475         return MUSE_CAMERA_ERROR_NONE;
2476 }
2477
2478 int camera_dispatcher_unset_interrupted_cb(muse_module_h module)
2479 {
2480         int ret = CAMERA_ERROR_NONE;
2481         muse_camera_handle_s *muse_camera = NULL;
2482         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
2483         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2484
2485         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2486
2487         LOGD("handle : %p", muse_camera);
2488
2489         ret = legacy_camera_unset_interrupted_cb(muse_camera->camera_handle);
2490
2491         LOGD("ret : 0x%x", ret);
2492
2493         muse_camera_msg_return(api, class, ret, module);
2494
2495         return MUSE_CAMERA_ERROR_NONE;
2496 }
2497
2498 int camera_dispatcher_set_focus_changed_cb(muse_module_h module)
2499 {
2500         int ret = CAMERA_ERROR_NONE;
2501         muse_camera_handle_s *muse_camera = NULL;
2502         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
2503         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2504
2505         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2506
2507         LOGD("handle : %p", muse_camera);
2508
2509         ret = legacy_camera_set_focus_changed_cb(muse_camera->camera_handle,
2510                 (camera_focus_changed_cb)_camera_dispatcher_focus_changed_cb,
2511                 (void *)module);
2512
2513         LOGD("ret : 0x%x", ret);
2514
2515         muse_camera_msg_return(api, class, ret, module);
2516
2517         return MUSE_CAMERA_ERROR_NONE;
2518 }
2519
2520 int camera_dispatcher_unset_focus_changed_cb(muse_module_h module)
2521 {
2522         int ret = CAMERA_ERROR_NONE;
2523         muse_camera_handle_s *muse_camera = NULL;
2524         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
2525         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2526
2527         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2528
2529         LOGD("handle : %p", muse_camera);
2530
2531         ret = legacy_camera_unset_focus_changed_cb(muse_camera->camera_handle);
2532
2533         LOGD("ret : 0x%x", ret);
2534
2535         muse_camera_msg_return(api, class, ret, module);
2536
2537         return MUSE_CAMERA_ERROR_NONE;
2538 }
2539
2540 int camera_dispatcher_set_error_cb(muse_module_h module)
2541 {
2542         int ret = CAMERA_ERROR_NONE;
2543         muse_camera_handle_s *muse_camera = NULL;
2544         muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
2545         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2546
2547         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2548
2549         LOGD("handle : %p", muse_camera);
2550
2551         ret = legacy_camera_set_error_cb(muse_camera->camera_handle,
2552                 (camera_error_cb)_camera_dispatcher_error_cb,
2553                 (void *)module);
2554
2555         LOGD("ret : 0x%x", ret);
2556
2557         muse_camera_msg_return(api, class, ret, module);
2558
2559         return MUSE_CAMERA_ERROR_NONE;
2560 }
2561
2562 int camera_dispatcher_unset_error_cb(muse_module_h module)
2563 {
2564         int ret = CAMERA_ERROR_NONE;
2565         muse_camera_handle_s *muse_camera = NULL;
2566         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
2567         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2568
2569         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2570
2571         LOGD("handle : %p", muse_camera);
2572
2573         ret = legacy_camera_unset_error_cb(muse_camera->camera_handle);
2574
2575         LOGD("ret : 0x%x", ret);
2576
2577         muse_camera_msg_return(api, class, ret, module);
2578
2579         return MUSE_CAMERA_ERROR_NONE;
2580 }
2581
2582 int camera_dispatcher_foreach_supported_preview_resolution(muse_module_h module)
2583 {
2584         int ret = CAMERA_ERROR_NONE;
2585         muse_camera_handle_s *muse_camera = NULL;
2586         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
2587         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
2588
2589         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2590
2591         LOGD("handle : %p", muse_camera);
2592
2593         ret = legacy_camera_foreach_supported_preview_resolution(muse_camera->camera_handle,
2594                 (camera_supported_preview_resolution_cb)_camera_dispatcher_callback_supported_preview_resolution,
2595                 (void *)module);
2596
2597         LOGD("ret : 0x%x", ret);
2598
2599         muse_camera_msg_return(api, class, ret, module);
2600
2601         return MUSE_CAMERA_ERROR_NONE;
2602 }
2603
2604 int camera_dispatcher_foreach_supported_capture_resolution(muse_module_h module)
2605 {
2606         int ret = CAMERA_ERROR_NONE;
2607         muse_camera_handle_s *muse_camera = NULL;
2608         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
2609         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
2610
2611         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2612
2613         LOGD("handle : %p", muse_camera);
2614
2615         ret = legacy_camera_foreach_supported_capture_resolution(muse_camera->camera_handle,
2616                 (camera_supported_capture_resolution_cb)_camera_dispatcher_callback_supported_capture_resolution,
2617                 (void *)module);
2618
2619         LOGD("ret : 0x%x", ret);
2620
2621         muse_camera_msg_return(api, class, ret, module);
2622
2623         return MUSE_CAMERA_ERROR_NONE;
2624 }
2625
2626 int camera_dispatcher_foreach_supported_capture_format(muse_module_h module)
2627 {
2628         int ret = CAMERA_ERROR_NONE;
2629         muse_camera_handle_s *muse_camera = NULL;
2630         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
2631         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
2632
2633         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2634
2635         LOGD("handle : %p", muse_camera);
2636
2637         ret = legacy_camera_foreach_supported_capture_format(muse_camera->camera_handle,
2638                 (camera_supported_capture_format_cb)_camera_dispatcher_callback_supported_capture_format,
2639                 (void *)module);
2640
2641         LOGD("ret : 0x%x", ret);
2642
2643         muse_camera_msg_return(api, class, ret, module);
2644
2645         return MUSE_CAMERA_ERROR_NONE;
2646 }
2647
2648 int camera_dispatcher_foreach_supported_preview_format(muse_module_h module)
2649 {
2650         int ret = CAMERA_ERROR_NONE;
2651         muse_camera_handle_s *muse_camera = NULL;
2652         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
2653         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
2654
2655         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2656
2657         LOGD("handle : %p", muse_camera);
2658
2659         ret = legacy_camera_foreach_supported_preview_format(muse_camera->camera_handle,
2660                 (camera_supported_preview_format_cb)_camera_dispatcher_callback_supported_preview_format,
2661                 (void *)module);
2662
2663         LOGD("ret : 0x%x", ret);
2664
2665         muse_camera_msg_return(api, class, ret, module);
2666
2667         return MUSE_CAMERA_ERROR_NONE;
2668 }
2669
2670 int camera_dispatcher_get_recommended_preview_resolution(muse_module_h module)
2671 {
2672         int ret = CAMERA_ERROR_NONE;
2673         muse_camera_handle_s *muse_camera = NULL;
2674         int get_width = 0;
2675         int get_height = 0;
2676         int get_value = 0;
2677         muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
2678         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2679
2680         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2681
2682         LOGD("handle : %p", muse_camera);
2683
2684         ret = legacy_camera_get_recommended_preview_resolution(muse_camera->camera_handle, &get_width, &get_height);
2685         if (ret == CAMERA_ERROR_NONE) {
2686                 get_value = get_width << 16 | get_height;
2687                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2688                         MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION, "get_value", get_value, NULL);
2689         } else {
2690                 muse_camera_msg_return(api, class, ret, module);
2691         }
2692
2693         return MUSE_CAMERA_ERROR_NONE;
2694 }
2695
2696 int camera_dispatcher_attr_get_lens_orientation(muse_module_h module)
2697 {
2698         int ret = CAMERA_ERROR_NONE;
2699         muse_camera_handle_s *muse_camera = NULL;
2700         int get_value = 0;
2701         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
2702         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2703
2704         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2705
2706         LOGD("handle : %p", muse_camera);
2707
2708         ret = legacy_camera_attr_get_lens_orientation(muse_camera->camera_handle, &get_value);
2709         if (ret == CAMERA_ERROR_NONE) {
2710                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2711                         MUSE_CAMERA_GET_INT_LENS_ORIENTATION, "get_value", get_value, NULL);
2712         } else {
2713                 muse_camera_msg_return(api, class, ret, module);
2714         }
2715
2716         return MUSE_CAMERA_ERROR_NONE;
2717 }
2718
2719 int camera_dispatcher_attr_set_theater_mode(muse_module_h module)
2720 {
2721         int ret = CAMERA_ERROR_NONE;
2722         muse_camera_handle_s *muse_camera = NULL;
2723         int set_mode;
2724         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
2725         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2726
2727         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2728
2729         muse_camera_msg_get(set_mode, muse_core_client_get_msg(module));
2730
2731         LOGD("handle : %p", muse_camera);
2732
2733         ret = legacy_camera_attr_set_theater_mode(muse_camera->camera_handle, (camera_attr_theater_mode_e)set_mode);
2734
2735         muse_camera_msg_return(api, class, ret, module);
2736
2737         return MUSE_CAMERA_ERROR_NONE;
2738 }
2739
2740 int camera_dispatcher_attr_get_theater_mode(muse_module_h module)
2741 {
2742         int ret = CAMERA_ERROR_NONE;
2743         muse_camera_handle_s *muse_camera = NULL;
2744         camera_attr_theater_mode_e get_value = CAMERA_ATTR_THEATER_MODE_DISABLE;
2745         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
2746         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2747
2748         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2749
2750         LOGD("handle : %p", muse_camera);
2751
2752         ret = legacy_camera_attr_get_theater_mode(muse_camera->camera_handle, &get_value);
2753         if (ret == CAMERA_ERROR_NONE) {
2754                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2755                         MUSE_CAMERA_GET_INT_THEATER_MODE, "get_value", get_value, NULL);
2756         } else {
2757                 muse_camera_msg_return(api, class, ret, module);
2758         }
2759
2760         return MUSE_CAMERA_ERROR_NONE;
2761 }
2762
2763 int camera_dispatcher_attr_foreach_supported_theater_mode(muse_module_h module)
2764 {
2765         int ret = CAMERA_ERROR_NONE;
2766         muse_camera_handle_s *muse_camera = NULL;
2767         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
2768         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
2769
2770         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2771         LOGD("handle : %p", muse_camera);
2772
2773         ret = legacy_camera_attr_foreach_supported_theater_mode(muse_camera->camera_handle,
2774                 (camera_attr_supported_theater_mode_cb)_camera_dispatcher_callback_supported_theater_mode,
2775                 (void *)module);
2776
2777         muse_camera_msg_return(api, class, ret, module);
2778
2779         return MUSE_CAMERA_ERROR_NONE;
2780 }
2781
2782 int camera_dispatcher_attr_set_preview_fps(muse_module_h module)
2783 {
2784         int ret = CAMERA_ERROR_NONE;
2785         muse_camera_handle_s *muse_camera = NULL;
2786         int set_fps;
2787         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
2788         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2789
2790         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2791
2792         muse_camera_msg_get(set_fps, muse_core_client_get_msg(module));
2793
2794         LOGD("handle : %p", muse_camera);
2795
2796         ret = legacy_camera_attr_set_preview_fps(muse_camera->camera_handle, (camera_attr_fps_e)set_fps);
2797
2798         muse_camera_msg_return(api, class, ret, module);
2799
2800         return MUSE_CAMERA_ERROR_NONE;
2801 }
2802
2803 int camera_dispatcher_attr_set_image_quality(muse_module_h module)
2804 {
2805         int ret = CAMERA_ERROR_NONE;
2806         muse_camera_handle_s *muse_camera = NULL;
2807         int quality;
2808         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
2809         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2810
2811         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2812
2813         muse_camera_msg_get(quality, muse_core_client_get_msg(module));
2814
2815         LOGD("handle : 0x%x, image_quality : %d", muse_camera, quality);
2816
2817         ret = legacy_camera_attr_set_image_quality(muse_camera->camera_handle, quality);
2818
2819         LOGD("ret : 0x%x", ret);
2820
2821         muse_camera_msg_return(api, class, ret, module);
2822
2823         return MUSE_CAMERA_ERROR_NONE;
2824 }
2825
2826 int camera_dispatcher_attr_get_preview_fps(muse_module_h module)
2827 {
2828         int ret = CAMERA_ERROR_NONE;
2829         muse_camera_handle_s *muse_camera = NULL;
2830         camera_attr_fps_e get_value = CAMERA_ATTR_FPS_AUTO;
2831         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
2832         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2833
2834         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2835
2836         LOGD("handle : %p", muse_camera);
2837
2838         ret = legacy_camera_attr_get_preview_fps(muse_camera->camera_handle, &get_value);
2839         if (ret == CAMERA_ERROR_NONE) {
2840                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2841                         MUSE_CAMERA_GET_INT_PREVIEW_FPS, "get_value", get_value, NULL);
2842         } else {
2843                 muse_camera_msg_return(api, class, ret, module);
2844         }
2845
2846         return MUSE_CAMERA_ERROR_NONE;
2847 }
2848
2849 int camera_dispatcher_attr_get_image_quality(muse_module_h module)
2850 {
2851         int ret = CAMERA_ERROR_NONE;
2852         muse_camera_handle_s *muse_camera = NULL;
2853         int get_value = 0;
2854         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
2855         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2856
2857         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2858
2859         LOGD("handle : %p", muse_camera);
2860
2861         ret = legacy_camera_attr_get_image_quality(muse_camera->camera_handle, &get_value);
2862         if (ret == CAMERA_ERROR_NONE) {
2863                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
2864                         MUSE_CAMERA_GET_INT_IMAGE_QUALITY, "get_value", get_value, NULL);
2865         } else {
2866                 muse_camera_msg_return(api, class, ret, module);
2867         }
2868
2869         return MUSE_CAMERA_ERROR_NONE;
2870 }
2871
2872 int camera_dispatcher_attr_set_zoom(muse_module_h module)
2873 {
2874         int ret = CAMERA_ERROR_NONE;
2875         muse_camera_handle_s *muse_camera = NULL;
2876         int zoom;
2877         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
2878         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2879
2880         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2881
2882         muse_camera_msg_get(zoom, muse_core_client_get_msg(module));
2883
2884         LOGD("handle : 0x%x, zoom : %d", muse_camera, zoom);
2885
2886         ret = legacy_camera_attr_set_zoom(muse_camera->camera_handle, zoom);
2887
2888         LOGD("ret : 0x%x", ret);
2889
2890         muse_camera_msg_return(api, class, ret, module);
2891
2892         return MUSE_CAMERA_ERROR_NONE;
2893 }
2894
2895 int camera_dispatcher_attr_set_af_mode(muse_module_h module)
2896 {
2897         int ret = CAMERA_ERROR_NONE;
2898         muse_camera_handle_s *muse_camera = NULL;
2899         int set_mode;
2900         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
2901         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2902
2903         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2904
2905         muse_camera_msg_get(set_mode, muse_core_client_get_msg(module));
2906
2907         LOGD("handle : 0x%x, set_mode : %d", muse_camera, set_mode);
2908
2909         ret = legacy_camera_attr_set_af_mode(muse_camera->camera_handle, (camera_attr_af_mode_e)set_mode);
2910
2911         LOGD("ret : 0x%x", ret);
2912
2913         muse_camera_msg_return(api, class, ret, module);
2914
2915         return MUSE_CAMERA_ERROR_NONE;
2916 }
2917
2918 int camera_dispatcher_attr_set_af_area(muse_module_h module)
2919 {
2920         int ret = CAMERA_ERROR_NONE;
2921         muse_camera_handle_s *muse_camera = NULL;
2922         int value = 0;
2923         int x = 0;
2924         int y = 0;
2925         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
2926         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2927
2928         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2929
2930         muse_camera_msg_get(value, muse_core_client_get_msg(module));
2931
2932         x = value >> 16;
2933         y = 0x0000ffff & value;
2934
2935         LOGD("AF area - %d, %d", x, y);
2936
2937         ret = legacy_camera_attr_set_af_area(muse_camera->camera_handle, x, y);
2938
2939         LOGD("ret : 0x%x", ret);
2940
2941         muse_camera_msg_return(api, class, ret, module);
2942
2943         return MUSE_CAMERA_ERROR_NONE;
2944 }
2945
2946 int camera_dispatcher_attr_clear_af_area(muse_module_h module)
2947 {
2948         int ret = CAMERA_ERROR_NONE;
2949         muse_camera_handle_s *muse_camera = NULL;
2950         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
2951         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2952
2953         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2954
2955         LOGD("handle : %p", muse_camera);
2956
2957         ret = legacy_camera_attr_clear_af_area(muse_camera->camera_handle);
2958
2959         LOGD("ret : 0x%x", ret);
2960
2961         muse_camera_msg_return(api, class, ret, module);
2962
2963         return MUSE_CAMERA_ERROR_NONE;
2964 }
2965
2966 int camera_dispatcher_attr_set_exposure_mode(muse_module_h module)
2967 {
2968         int ret = CAMERA_ERROR_NONE;
2969         muse_camera_handle_s *muse_camera = NULL;
2970         int set_mode;
2971         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
2972         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2973
2974         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2975
2976         muse_camera_msg_get(set_mode, muse_core_client_get_msg(module));
2977
2978         LOGD("handle : 0x%x, set_mode : %d", muse_camera, set_mode);
2979
2980         ret = legacy_camera_attr_set_exposure_mode(muse_camera->camera_handle, (camera_attr_exposure_mode_e)set_mode);
2981
2982         LOGD("ret : 0x%x", ret);
2983
2984         muse_camera_msg_return(api, class, ret, module);
2985
2986         return MUSE_CAMERA_ERROR_NONE;
2987 }
2988
2989 int camera_dispatcher_attr_set_exposure(muse_module_h module)
2990 {
2991         int ret = CAMERA_ERROR_NONE;
2992         muse_camera_handle_s *muse_camera = NULL;
2993         int value;
2994         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
2995         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
2996
2997         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
2998
2999         muse_camera_msg_get(value, muse_core_client_get_msg(module));
3000
3001         LOGD("handle : 0x%x, value : %d", muse_camera, value);
3002
3003         ret = legacy_camera_attr_set_exposure(muse_camera->camera_handle, value);
3004
3005         LOGD("ret : 0x%x", ret);
3006
3007         muse_camera_msg_return(api, class, ret, module);
3008
3009         return MUSE_CAMERA_ERROR_NONE;
3010 }
3011
3012 int camera_dispatcher_attr_set_iso(muse_module_h module)
3013 {
3014         int ret = CAMERA_ERROR_NONE;
3015         muse_camera_handle_s *muse_camera = NULL;
3016         int set_iso;
3017         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
3018         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3019
3020         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3021
3022         muse_camera_msg_get(set_iso, muse_core_client_get_msg(module));
3023
3024         LOGD("handle : 0x%x, set_iso : %d", muse_camera, set_iso);
3025
3026         ret = legacy_camera_attr_set_iso(muse_camera->camera_handle, (camera_attr_iso_e)set_iso);
3027
3028         LOGD("ret : 0x%x", ret);
3029
3030         muse_camera_msg_return(api, class, ret, module);
3031
3032         return MUSE_CAMERA_ERROR_NONE;
3033 }
3034
3035 int camera_dispatcher_attr_set_brightness(muse_module_h module)
3036 {
3037         int ret = CAMERA_ERROR_NONE;
3038         muse_camera_handle_s *muse_camera = NULL;
3039         int level;
3040         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
3041         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3042
3043         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3044
3045         muse_camera_msg_get(level, muse_core_client_get_msg(module));
3046
3047         LOGD("handle : 0x%x, level : %d", muse_camera, level);
3048
3049         ret = legacy_camera_attr_set_brightness(muse_camera->camera_handle, level);
3050
3051         LOGD("ret : 0x%x", ret);
3052
3053         muse_camera_msg_return(api, class, ret, module);
3054
3055         return MUSE_CAMERA_ERROR_NONE;
3056 }
3057
3058 int camera_dispatcher_attr_set_contrast(muse_module_h module)
3059 {
3060         int ret = CAMERA_ERROR_NONE;
3061         muse_camera_handle_s *muse_camera = NULL;
3062         int level;
3063         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
3064         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3065
3066         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3067
3068         muse_camera_msg_get(level, muse_core_client_get_msg(module));
3069
3070         LOGD("handle : 0x%x, level : %d", muse_camera, level);
3071
3072         ret = legacy_camera_attr_set_contrast(muse_camera->camera_handle, level);
3073
3074         LOGD("ret : 0x%x", ret);
3075
3076         muse_camera_msg_return(api, class, ret, module);
3077
3078         return MUSE_CAMERA_ERROR_NONE;
3079 }
3080
3081 int camera_dispatcher_attr_set_whitebalance(muse_module_h module)
3082 {
3083         int ret = CAMERA_ERROR_NONE;
3084         muse_camera_handle_s *muse_camera = NULL;
3085         int set_whitebalance;
3086         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
3087         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3088
3089         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3090
3091         muse_camera_msg_get(set_whitebalance, muse_core_client_get_msg(module));
3092
3093         LOGD("handle : 0x%x, set_whitebalance : %d", muse_camera, set_whitebalance);
3094
3095         ret = legacy_camera_attr_set_whitebalance(muse_camera->camera_handle, (camera_attr_whitebalance_e)set_whitebalance);
3096
3097         LOGD("ret : 0x%x", ret);
3098
3099         muse_camera_msg_return(api, class, ret, module);
3100
3101         return MUSE_CAMERA_ERROR_NONE;
3102 }
3103
3104 int camera_dispatcher_attr_set_effect(muse_module_h module)
3105 {
3106         int ret = CAMERA_ERROR_NONE;
3107         muse_camera_handle_s *muse_camera = NULL;
3108         int set_effect;
3109         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
3110         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3111
3112         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3113
3114         muse_camera_msg_get(set_effect, muse_core_client_get_msg(module));
3115
3116         LOGD("handle : 0x%x, set_effect : %d", muse_camera, set_effect);
3117
3118         ret = legacy_camera_attr_set_effect(muse_camera->camera_handle, (camera_attr_effect_mode_e)set_effect);
3119
3120         LOGD("ret : 0x%x", ret);
3121
3122         muse_camera_msg_return(api, class, ret, module);
3123
3124         return MUSE_CAMERA_ERROR_NONE;
3125 }
3126
3127 int camera_dispatcher_attr_set_scene_mode(muse_module_h module)
3128 {
3129         int ret = CAMERA_ERROR_NONE;
3130         muse_camera_handle_s *muse_camera = NULL;
3131         int set_mode;
3132         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
3133         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3134
3135         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3136
3137         muse_camera_msg_get(set_mode, muse_core_client_get_msg(module));
3138
3139         LOGD("handle : 0x%x, set_mode : %d", muse_camera, set_mode);
3140
3141         ret = legacy_camera_attr_set_scene_mode(muse_camera->camera_handle, (camera_attr_scene_mode_e)set_mode);
3142
3143         LOGD("ret : 0x%x", ret);
3144
3145         muse_camera_msg_return(api, class, ret, module);
3146
3147         return MUSE_CAMERA_ERROR_NONE;
3148 }
3149
3150 int camera_dispatcher_attr_enable_tag(muse_module_h module)
3151 {
3152         int ret = CAMERA_ERROR_NONE;
3153         muse_camera_handle_s *muse_camera = NULL;
3154         int set_enable;
3155         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
3156         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3157
3158         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3159
3160         muse_camera_msg_get(set_enable, muse_core_client_get_msg(module));
3161
3162         LOGD("handle : 0x%x, set_enable : %d", muse_camera, set_enable);
3163
3164         ret = legacy_camera_attr_enable_tag(muse_camera->camera_handle, (bool)set_enable);
3165
3166         LOGD("ret : 0x%x", ret);
3167
3168         muse_camera_msg_return(api, class, ret, module);
3169
3170         return MUSE_CAMERA_ERROR_NONE;
3171 }
3172
3173 int camera_dispatcher_attr_set_tag_image_description(muse_module_h module)
3174 {
3175         int ret = CAMERA_ERROR_NONE;
3176         muse_camera_handle_s *muse_camera = NULL;
3177         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
3178         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3179         char description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
3180
3181         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3182
3183         muse_camera_msg_get_string(description, muse_core_client_get_msg(module));
3184
3185         LOGD("handle : 0x%x, description : %s", muse_camera, description);
3186
3187         ret = legacy_camera_attr_set_tag_image_description(muse_camera->camera_handle, description);
3188
3189         LOGD("ret : 0x%x", ret);
3190
3191         muse_camera_msg_return(api, class, ret, module);
3192
3193         return MUSE_CAMERA_ERROR_NONE;
3194 }
3195
3196 int camera_dispatcher_attr_set_tag_orientation(muse_module_h module)
3197 {
3198         int ret = CAMERA_ERROR_NONE;
3199         muse_camera_handle_s *muse_camera = NULL;
3200         int set_orientation;
3201         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
3202         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3203
3204         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3205
3206         muse_camera_msg_get(set_orientation, muse_core_client_get_msg(module));
3207
3208         LOGD("handle : 0x%x, set_orientation : %d", muse_camera, set_orientation);
3209
3210         ret = legacy_camera_attr_set_tag_orientation(muse_camera->camera_handle, (camera_attr_tag_orientation_e)set_orientation);
3211
3212         LOGD("ret : 0x%x", ret);
3213
3214         muse_camera_msg_return(api, class, ret, module);
3215
3216         return MUSE_CAMERA_ERROR_NONE;
3217 }
3218
3219 int camera_dispatcher_attr_set_tag_software(muse_module_h module)
3220 {
3221         int ret = CAMERA_ERROR_NONE;
3222         muse_camera_handle_s *muse_camera = NULL;
3223         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
3224         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3225         char software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
3226
3227         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3228
3229         muse_camera_msg_get_string(software, muse_core_client_get_msg(module));
3230
3231         LOGD("handle : 0x%x, software : %s", muse_camera, software);
3232
3233         ret = legacy_camera_attr_set_tag_software(muse_camera->camera_handle, software);
3234
3235         LOGD("ret : 0x%x", ret);
3236
3237         muse_camera_msg_return(api, class, ret, module);
3238
3239         return MUSE_CAMERA_ERROR_NONE;
3240 }
3241
3242 int camera_dispatcher_attr_set_geotag(muse_module_h module)
3243 {
3244         int ret = CAMERA_ERROR_NONE;
3245         muse_camera_handle_s *muse_camera = NULL;
3246         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
3247         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3248         double set_geotag[3] = {0,};
3249
3250         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3251
3252         muse_camera_msg_get_array(set_geotag, muse_core_client_get_msg(module));
3253
3254         LOGD("handle : 0x%x, set_geotag1 : %d, set_geotag2 : %d, set_geotag3 : %d",
3255              muse_camera, set_geotag[0], set_geotag[1], set_geotag[2]);
3256
3257         ret = legacy_camera_attr_set_geotag(muse_camera->camera_handle, set_geotag[0], set_geotag[1], set_geotag[2]);
3258
3259         LOGD("ret : 0x%x", ret);
3260
3261         muse_camera_msg_return(api, class, ret, module);
3262
3263         return MUSE_CAMERA_ERROR_NONE;
3264 }
3265
3266 int camera_dispatcher_attr_remove_geotag(muse_module_h module)
3267 {
3268         int ret = CAMERA_ERROR_NONE;
3269         muse_camera_handle_s *muse_camera = NULL;
3270         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
3271         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3272
3273         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3274
3275         LOGD("handle : %p", muse_camera);
3276
3277         ret = legacy_camera_attr_remove_geotag(muse_camera->camera_handle);
3278
3279         LOGD("ret : 0x%x", ret);
3280
3281         muse_camera_msg_return(api, class, ret, module);
3282
3283         return MUSE_CAMERA_ERROR_NONE;
3284 }
3285
3286 int camera_dispatcher_attr_set_flash_mode(muse_module_h module)
3287 {
3288         int ret = CAMERA_ERROR_NONE;
3289         int set_mode = 0;;
3290         char value_key[KEY_LENGTH] = {'\0',};
3291         muse_camera_handle_s *muse_camera = NULL;
3292         camera_device_e device_type = CAMERA_DEVICE_CAMERA0;
3293         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
3294         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3295
3296         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3297
3298         muse_camera_msg_get(set_mode, muse_core_client_get_msg(module));
3299
3300         LOGD("handle : 0x%x, set_mode : %d", muse_camera, set_mode);
3301
3302         ret = legacy_camera_attr_set_flash_mode(muse_camera->camera_handle, (camera_attr_flash_mode_e)set_mode);
3303         if (ret == CAMERA_ERROR_NONE) {
3304                 ret = legacy_camera_get_device_type(muse_camera->camera_handle, &device_type);
3305                 if (ret == CAMERA_ERROR_NONE) {
3306                         snprintf(value_key, KEY_LENGTH, "flash_state_camera%d", device_type);
3307                         muse_core_client_set_value(module, value_key, set_mode > 0 ? 1 : 0);
3308                 }
3309         }
3310
3311         LOGD("ret : 0x%x", ret);
3312
3313         muse_camera_msg_return(api, class, ret, module);
3314
3315         return MUSE_CAMERA_ERROR_NONE;
3316 }
3317
3318 int camera_dispatcher_attr_get_zoom(muse_module_h module)
3319 {
3320         int ret = CAMERA_ERROR_NONE;
3321         muse_camera_handle_s *muse_camera = NULL;
3322         int get_value = 0;
3323         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
3324         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3325
3326         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3327
3328         LOGD("handle : %p", muse_camera);
3329
3330         ret = legacy_camera_attr_get_zoom(muse_camera->camera_handle, &get_value);
3331         if (ret == CAMERA_ERROR_NONE) {
3332                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3333                         MUSE_CAMERA_GET_INT_ZOOM, "get_value", get_value, NULL);
3334         } else {
3335                 muse_camera_msg_return(api, class, ret, module);
3336         }
3337
3338         return MUSE_CAMERA_ERROR_NONE;
3339 }
3340
3341 int camera_dispatcher_attr_get_zoom_range(muse_module_h module)
3342 {
3343         int ret = CAMERA_ERROR_NONE;
3344         muse_camera_handle_s *muse_camera = NULL;
3345         int get_value0 = 0;
3346         int get_value1 = 0;
3347         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
3348         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3349         muse_camera_get_type_e get_type = MUSE_CAMERA_GET_TYPE_INT_PAIR;
3350         muse_camera_get_int_pair_e index = MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE;
3351
3352         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3353
3354         LOGD("handle : %p", muse_camera);
3355
3356         ret = legacy_camera_attr_get_zoom_range(muse_camera->camera_handle, &get_value0, &get_value1);
3357         if (ret == CAMERA_ERROR_NONE)
3358                 muse_camera_msg_return2(api, class, ret, module, get_type, index, get_value0, get_value1);
3359         else
3360                 muse_camera_msg_return(api, class, ret, module);
3361
3362         return MUSE_CAMERA_ERROR_NONE;
3363 }
3364
3365 int camera_dispatcher_attr_get_af_mode(muse_module_h module)
3366 {
3367         int ret = CAMERA_ERROR_NONE;
3368         muse_camera_handle_s *muse_camera = NULL;
3369         camera_attr_af_mode_e get_value = CAMERA_ATTR_AF_NONE;
3370         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
3371         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3372
3373         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3374
3375         LOGD("handle : %p", muse_camera);
3376
3377         ret = legacy_camera_attr_get_af_mode(muse_camera->camera_handle, &get_value);
3378         if (ret == CAMERA_ERROR_NONE) {
3379                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3380                         MUSE_CAMERA_GET_INT_AF_MODE, "get_value", get_value, NULL);
3381         } else {
3382                 muse_camera_msg_return(api, class, ret, module);
3383         }
3384
3385         return MUSE_CAMERA_ERROR_NONE;
3386 }
3387
3388 int camera_dispatcher_attr_get_exposure_mode(muse_module_h module)
3389 {
3390         int ret = CAMERA_ERROR_NONE;
3391         muse_camera_handle_s *muse_camera = NULL;
3392         camera_attr_exposure_mode_e get_value = CAMERA_ATTR_EXPOSURE_MODE_OFF;
3393         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
3394         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3395
3396         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3397
3398         LOGD("handle : %p", muse_camera);
3399
3400         ret = legacy_camera_attr_get_exposure_mode(muse_camera->camera_handle, &get_value);
3401         if (ret == CAMERA_ERROR_NONE) {
3402                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3403                         MUSE_CAMERA_GET_INT_EXPOSURE_MODE, "get_value", get_value, NULL);
3404         } else {
3405                 muse_camera_msg_return(api, class, ret, module);
3406         }
3407
3408         return MUSE_CAMERA_ERROR_NONE;
3409 }
3410
3411 int camera_dispatcher_attr_get_exposure(muse_module_h module)
3412 {
3413         int ret = CAMERA_ERROR_NONE;
3414         muse_camera_handle_s *muse_camera = NULL;
3415         int get_value = 0;
3416         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
3417         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3418
3419         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3420
3421         LOGD("handle : %p", muse_camera);
3422
3423         ret = legacy_camera_attr_get_exposure(muse_camera->camera_handle, &get_value);
3424         if (ret == CAMERA_ERROR_NONE) {
3425                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3426                         MUSE_CAMERA_GET_INT_EXPOSURE, "get_value", get_value, NULL);
3427         } else {
3428                 muse_camera_msg_return(api, class, ret, module);
3429         }
3430
3431         return MUSE_CAMERA_ERROR_NONE;
3432 }
3433
3434 int camera_dispatcher_attr_get_exposure_range(muse_module_h module)
3435 {
3436         int ret = CAMERA_ERROR_NONE;
3437         muse_camera_handle_s *muse_camera = NULL;
3438         int get_value0 = 0;
3439         int get_value1 = 0;
3440         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
3441         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3442         muse_camera_get_type_e get_type = MUSE_CAMERA_GET_TYPE_INT_PAIR;
3443         muse_camera_get_int_pair_e index = MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE;
3444
3445         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3446
3447         LOGD("handle : %p", muse_camera);
3448
3449         ret = legacy_camera_attr_get_exposure_range(muse_camera->camera_handle, &get_value0, &get_value1);
3450         if (ret == CAMERA_ERROR_NONE)
3451                 muse_camera_msg_return2(api, class, ret, module, get_type, index, get_value0, get_value1);
3452         else
3453                 muse_camera_msg_return(api, class, ret, module);
3454
3455         return MUSE_CAMERA_ERROR_NONE;
3456 }
3457
3458 int camera_dispatcher_attr_get_iso(muse_module_h module)
3459 {
3460         int ret = CAMERA_ERROR_NONE;
3461         muse_camera_handle_s *muse_camera = NULL;
3462         camera_attr_iso_e get_value = CAMERA_ATTR_ISO_AUTO;
3463         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
3464         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3465
3466         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3467
3468         LOGD("handle : %p", muse_camera);
3469
3470         ret = legacy_camera_attr_get_iso(muse_camera->camera_handle, &get_value);
3471         if (ret == CAMERA_ERROR_NONE) {
3472                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3473                         MUSE_CAMERA_GET_INT_ISO, "get_value", get_value, NULL);
3474         } else {
3475                 muse_camera_msg_return(api, class, ret, module);
3476         }
3477
3478         return MUSE_CAMERA_ERROR_NONE;
3479 }
3480
3481 int camera_dispatcher_attr_get_brightness(muse_module_h module)
3482 {
3483         int ret = CAMERA_ERROR_NONE;
3484         muse_camera_handle_s *muse_camera = NULL;
3485         int get_value = 0;
3486         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
3487         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3488
3489         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3490
3491         LOGD("handle : %p", muse_camera);
3492
3493         ret = legacy_camera_attr_get_brightness(muse_camera->camera_handle, &get_value);
3494         if (ret == CAMERA_ERROR_NONE) {
3495                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3496                         MUSE_CAMERA_GET_INT_BRIGHTNESS, "get_value", get_value, NULL);
3497         } else {
3498                 muse_camera_msg_return(api, class, ret, module);
3499         }
3500
3501         return MUSE_CAMERA_ERROR_NONE;
3502 }
3503
3504 int camera_dispatcher_attr_get_brightness_range(muse_module_h module)
3505 {
3506         int ret = CAMERA_ERROR_NONE;
3507         muse_camera_handle_s *muse_camera = NULL;
3508         int get_value0 = 0;
3509         int get_value1 = 0;
3510         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
3511         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3512         muse_camera_get_type_e get_type = MUSE_CAMERA_GET_TYPE_INT_PAIR;
3513         muse_camera_get_int_pair_e index = MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE;
3514
3515         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3516
3517         LOGD("handle : %p", muse_camera);
3518
3519         ret = legacy_camera_attr_get_brightness_range(muse_camera->camera_handle, &get_value0, &get_value1);
3520         if (ret == CAMERA_ERROR_NONE)
3521                 muse_camera_msg_return2(api, class, ret, module, get_type, index, get_value0, get_value1);
3522         else
3523                 muse_camera_msg_return(api, class, ret, module);
3524
3525         return MUSE_CAMERA_ERROR_NONE;
3526 }
3527
3528 int camera_dispatcher_attr_get_contrast(muse_module_h module)
3529 {
3530         int ret = CAMERA_ERROR_NONE;
3531         muse_camera_handle_s *muse_camera = NULL;
3532         int get_value = 0;
3533         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
3534         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3535
3536         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3537
3538         LOGD("handle : %p", muse_camera);
3539
3540         ret = legacy_camera_attr_get_contrast(muse_camera->camera_handle, &get_value);
3541         if (ret == CAMERA_ERROR_NONE) {
3542                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3543                         MUSE_CAMERA_GET_INT_CONTRAST, "get_value", get_value, NULL);
3544         } else {
3545                 muse_camera_msg_return(api, class, ret, module);
3546         }
3547
3548         return MUSE_CAMERA_ERROR_NONE;
3549 }
3550
3551 int camera_dispatcher_attr_get_contrast_range(muse_module_h module)
3552 {
3553         int ret = CAMERA_ERROR_NONE;
3554         muse_camera_handle_s *muse_camera = NULL;
3555         int get_value0 = 0;
3556         int get_value1 = 0;
3557         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
3558         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3559         muse_camera_get_type_e get_type = MUSE_CAMERA_GET_TYPE_INT_PAIR;
3560         muse_camera_get_int_pair_e index = MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE;
3561
3562         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3563
3564         LOGD("handle : %p", muse_camera);
3565
3566         ret = legacy_camera_attr_get_contrast_range(muse_camera->camera_handle, &get_value0, &get_value1);
3567         if (ret == CAMERA_ERROR_NONE)
3568                 muse_camera_msg_return2(api, class, ret, module, get_type, index, get_value0, get_value1);
3569         else
3570                 muse_camera_msg_return(api, class, ret, module);
3571
3572         return MUSE_CAMERA_ERROR_NONE;
3573 }
3574
3575 int camera_dispatcher_attr_get_whitebalance(muse_module_h module)
3576 {
3577         int ret = CAMERA_ERROR_NONE;
3578         muse_camera_handle_s *muse_camera = NULL;
3579         camera_attr_whitebalance_e get_value = CAMERA_ATTR_WHITE_BALANCE_NONE;
3580         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
3581         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3582
3583         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3584
3585         LOGD("handle : %p", muse_camera);
3586
3587         ret = legacy_camera_attr_get_whitebalance(muse_camera->camera_handle, &get_value);
3588         if (ret == CAMERA_ERROR_NONE) {
3589                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3590                         MUSE_CAMERA_GET_INT_WHITE_BALANCE, "get_value", get_value, NULL);
3591         } else {
3592                 muse_camera_msg_return(api, class, ret, module);
3593         }
3594
3595         return MUSE_CAMERA_ERROR_NONE;
3596 }
3597
3598 int camera_dispatcher_attr_get_effect(muse_module_h module)
3599 {
3600         int ret = CAMERA_ERROR_NONE;
3601         muse_camera_handle_s *muse_camera = NULL;
3602         camera_attr_effect_mode_e get_value = CAMERA_ATTR_EFFECT_NONE;
3603         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
3604         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3605
3606         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3607
3608         LOGD("handle : %p", muse_camera);
3609
3610         ret = legacy_camera_attr_get_effect(muse_camera->camera_handle, &get_value);
3611         if (ret == CAMERA_ERROR_NONE) {
3612                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3613                         MUSE_CAMERA_GET_INT_EFFECT, "get_value", get_value, NULL);
3614         } else {
3615                 muse_camera_msg_return(api, class, ret, module);
3616         }
3617
3618         return MUSE_CAMERA_ERROR_NONE;
3619 }
3620
3621 int camera_dispatcher_attr_get_scene_mode(muse_module_h module)
3622 {
3623         int ret = CAMERA_ERROR_NONE;
3624         muse_camera_handle_s *muse_camera = NULL;
3625         camera_attr_scene_mode_e get_value = CAMERA_ATTR_SCENE_MODE_NORMAL;
3626         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
3627         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3628
3629         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3630
3631         LOGD("handle : %p", muse_camera);
3632
3633         ret = legacy_camera_attr_get_scene_mode(muse_camera->camera_handle, &get_value);
3634         if (ret == CAMERA_ERROR_NONE) {
3635                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3636                         MUSE_CAMERA_GET_INT_SCENE_MODE, "get_value", get_value, NULL);
3637         } else {
3638                 muse_camera_msg_return(api, class, ret, module);
3639         }
3640
3641         return MUSE_CAMERA_ERROR_NONE;
3642 }
3643
3644 int camera_dispatcher_attr_is_enabled_tag(muse_module_h module)
3645 {
3646         int ret = CAMERA_ERROR_NONE;
3647         muse_camera_handle_s *muse_camera = NULL;
3648         bool get_value = false;
3649         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
3650         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3651
3652         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3653
3654         LOGD("handle : %p", muse_camera);
3655
3656         ret = legacy_camera_attr_is_enabled_tag(muse_camera->camera_handle, &get_value);
3657         if (ret == CAMERA_ERROR_NONE) {
3658                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3659                         MUSE_CAMERA_GET_INT_ENABLED_TAG, "get_value", get_value, NULL);
3660         } else {
3661                 muse_camera_msg_return(api, class, ret, module);
3662         }
3663
3664         return MUSE_CAMERA_ERROR_NONE;
3665 }
3666
3667 int camera_dispatcher_attr_get_tag_image_description(muse_module_h module)
3668 {
3669         int ret = CAMERA_ERROR_NONE;
3670         muse_camera_handle_s *muse_camera = NULL;
3671         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
3672         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3673         char *get_value = NULL;
3674
3675         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3676
3677         ret = legacy_camera_attr_get_tag_image_description(muse_camera->camera_handle, &get_value);
3678         if (ret == CAMERA_ERROR_NONE) {
3679                 LOGD("get_description : %s", muse_camera, get_value);
3680                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_STRING,
3681                         MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION, "get_value", 0, get_value);
3682         } else {
3683                 muse_camera_msg_return(api, class, ret, module);
3684         }
3685
3686         if (get_value) {
3687                 free(get_value);
3688                 get_value = NULL;
3689         }
3690
3691         return MUSE_CAMERA_ERROR_NONE;
3692 }
3693
3694 int camera_dispatcher_attr_get_tag_orientation(muse_module_h module)
3695 {
3696         int ret = CAMERA_ERROR_NONE;
3697         muse_camera_handle_s *muse_camera = NULL;
3698         camera_attr_tag_orientation_e get_value = CAMERA_ATTR_TAG_ORIENTATION_TOP_LEFT;
3699         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
3700         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3701
3702         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3703
3704         LOGD("handle : %p", muse_camera);
3705
3706         ret = legacy_camera_attr_get_tag_orientation(muse_camera->camera_handle, &get_value);
3707         if (ret == CAMERA_ERROR_NONE) {
3708                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3709                         MUSE_CAMERA_GET_INT_TAG_ORIENTATION, "get_value", get_value, NULL);
3710         } else {
3711                 muse_camera_msg_return(api, class, ret, module);
3712         }
3713
3714         return MUSE_CAMERA_ERROR_NONE;
3715 }
3716
3717 int camera_dispatcher_attr_get_tag_software(muse_module_h module)
3718 {
3719         int ret = CAMERA_ERROR_NONE;
3720         muse_camera_handle_s *muse_camera = NULL;
3721         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
3722         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3723         char *get_value = NULL;
3724
3725         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3726
3727         ret = legacy_camera_attr_get_tag_software(muse_camera->camera_handle, &get_value);
3728         if (ret == CAMERA_ERROR_NONE) {
3729                 LOGD("get_software : %s", get_value);
3730                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_STRING,
3731                         MUSE_CAMERA_GET_STRING_TAG_SOFTWARE, "get_value", 0, get_value);
3732         } else {
3733                 muse_camera_msg_return(api, class, ret, module);
3734         }
3735
3736         if (get_value) {
3737                 free(get_value);
3738                 get_value = NULL;
3739         }
3740
3741         return MUSE_CAMERA_ERROR_NONE;
3742 }
3743
3744 int camera_dispatcher_attr_get_geotag(muse_module_h module)
3745 {
3746         int ret = CAMERA_ERROR_NONE;
3747         muse_camera_handle_s *muse_camera = NULL;
3748         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
3749         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3750         double get_value[3] = {0.0, 0.0, 0.0};
3751         char *send_msg = NULL;
3752         int msg_array_size = 0;
3753
3754         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3755
3756         LOGD("handle : %p", muse_camera);
3757
3758         ret = legacy_camera_attr_get_geotag(muse_camera->camera_handle, &get_value[0], &get_value[1], &get_value[2]);
3759         if (ret == CAMERA_ERROR_NONE) {
3760                 msg_array_size = sizeof(get_value) / sizeof(int) + (sizeof(get_value) % sizeof(int) ? 1 : 0);
3761
3762                 send_msg = muse_core_msg_json_factory_new(api,
3763                         MUSE_TYPE_INT, PARAM_API_CLASS, class,
3764                         MUSE_TYPE_INT, PARAM_RET, ret,
3765                         MUSE_TYPE_INT, PARAM_GET_TYPE, MUSE_CAMERA_GET_TYPE_ARRAY,
3766                         MUSE_TYPE_ARRAY, "get_value", msg_array_size, get_value,
3767                         0);
3768
3769                 __camera_dispatcher_send_msg(module, send_msg);
3770         } else {
3771                 muse_camera_msg_return(api, class, ret, module);
3772         }
3773
3774         return MUSE_CAMERA_ERROR_NONE;
3775 }
3776
3777 int camera_dispatcher_attr_get_flash_mode(muse_module_h module)
3778 {
3779         int ret = CAMERA_ERROR_NONE;
3780         muse_camera_handle_s *muse_camera = NULL;
3781         camera_attr_flash_mode_e get_value = CAMERA_ATTR_FLASH_MODE_OFF;
3782         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
3783         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
3784
3785         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3786
3787         LOGD("handle : %p", muse_camera);
3788
3789         ret = legacy_camera_attr_get_flash_mode(muse_camera->camera_handle, &get_value);
3790         if (ret == CAMERA_ERROR_NONE) {
3791                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
3792                         MUSE_CAMERA_GET_INT_FLASH_MODE, "get_value", get_value, NULL);
3793         } else {
3794                 muse_camera_msg_return(api, class, ret, module);
3795         }
3796
3797         return MUSE_CAMERA_ERROR_NONE;
3798 }
3799
3800 int camera_dispatcher_attr_foreach_supported_af_mode(muse_module_h module)
3801 {
3802         int ret = CAMERA_ERROR_NONE;
3803         muse_camera_handle_s *muse_camera = NULL;
3804         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
3805         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
3806
3807         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3808
3809         LOGD("handle : %p", muse_camera);
3810
3811         ret = legacy_camera_attr_foreach_supported_af_mode(muse_camera->camera_handle,
3812                 (camera_attr_supported_af_mode_cb)_camera_dispatcher_callback_supported_af_mode,
3813                 (void *)module);
3814
3815         LOGD("ret : 0x%x", ret);
3816
3817         muse_camera_msg_return(api, class, ret, module);
3818
3819         return MUSE_CAMERA_ERROR_NONE;
3820 }
3821
3822 int camera_dispatcher_attr_foreach_supported_exposure_mode(muse_module_h module)
3823 {
3824         int ret = CAMERA_ERROR_NONE;
3825         muse_camera_handle_s *muse_camera = NULL;
3826         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
3827         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
3828
3829         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3830
3831         LOGD("handle : 0x%x, api : %d", muse_camera, api);
3832
3833         ret = legacy_camera_attr_foreach_supported_exposure_mode(muse_camera->camera_handle,
3834                 (camera_attr_supported_exposure_mode_cb)_camera_dispatcher_callback_supported_exposure_mode,
3835                 (void *)module);
3836
3837         LOGD("ret : 0x%x", ret);
3838
3839         muse_camera_msg_return(api, class, ret, module);
3840
3841         return MUSE_CAMERA_ERROR_NONE;
3842 }
3843
3844 int camera_dispatcher_attr_foreach_supported_iso(muse_module_h module)
3845 {
3846         int ret = CAMERA_ERROR_NONE;
3847         muse_camera_handle_s *muse_camera = NULL;
3848         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
3849         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
3850
3851         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3852
3853         LOGD("handle : %p", muse_camera);
3854
3855         ret = legacy_camera_attr_foreach_supported_iso(muse_camera->camera_handle,
3856                 (camera_attr_supported_iso_cb)_camera_dispatcher_callback_supported_iso_mode,
3857                 (void *)module);
3858
3859         LOGD("ret : 0x%x", ret);
3860
3861         muse_camera_msg_return(api, class, ret, module);
3862
3863         return MUSE_CAMERA_ERROR_NONE;
3864 }
3865
3866 int camera_dispatcher_attr_foreach_supported_whitebalance(muse_module_h module)
3867 {
3868         int ret = CAMERA_ERROR_NONE;
3869         muse_camera_handle_s *muse_camera = NULL;
3870         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
3871         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
3872
3873         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3874
3875         LOGD("handle : %p", muse_camera);
3876
3877         ret = legacy_camera_attr_foreach_supported_whitebalance(muse_camera->camera_handle,
3878                 (camera_attr_supported_whitebalance_cb)_camera_dispatcher_callback_supported_whitebalance,
3879                 (void *)module);
3880
3881         LOGD("ret : 0x%x", ret);
3882
3883         muse_camera_msg_return(api, class, ret, module);
3884
3885         return MUSE_CAMERA_ERROR_NONE;
3886 }
3887
3888 int camera_dispatcher_attr_foreach_supported_effect(muse_module_h module)
3889 {
3890         int ret = CAMERA_ERROR_NONE;
3891         muse_camera_handle_s *muse_camera = NULL;
3892         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
3893         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
3894
3895         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3896
3897         LOGD("handle : %p", muse_camera);
3898
3899         ret = legacy_camera_attr_foreach_supported_effect(muse_camera->camera_handle,
3900                 (camera_attr_supported_effect_cb)_camera_dispatcher_callback_supported_effect,
3901                 (void *)module);
3902
3903         LOGD("ret : 0x%x", ret);
3904
3905         muse_camera_msg_return(api, class, ret, module);
3906
3907         return MUSE_CAMERA_ERROR_NONE;
3908 }
3909
3910 int camera_dispatcher_attr_foreach_supported_scene_mode(muse_module_h module)
3911 {
3912         int ret = CAMERA_ERROR_NONE;
3913         muse_camera_handle_s *muse_camera = NULL;
3914         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
3915         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
3916
3917         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3918
3919         LOGD("handle : %p", muse_camera);
3920
3921         ret = legacy_camera_attr_foreach_supported_scene_mode(muse_camera->camera_handle,
3922                 (camera_attr_supported_scene_mode_cb)_camera_dispatcher_callback_supported_scene_mode,
3923                 (void *)module);
3924
3925         LOGD("ret : 0x%x", ret);
3926
3927         muse_camera_msg_return(api, class, ret, module);
3928
3929         return MUSE_CAMERA_ERROR_NONE;
3930 }
3931
3932 int camera_dispatcher_attr_foreach_supported_flash_mode(muse_module_h module)
3933 {
3934         int ret = CAMERA_ERROR_NONE;
3935         muse_camera_handle_s *muse_camera = NULL;
3936         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
3937         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
3938
3939         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3940
3941         LOGD("handle : %p", muse_camera);
3942
3943         ret = legacy_camera_attr_foreach_supported_flash_mode(muse_camera->camera_handle,
3944                 (camera_attr_supported_flash_mode_cb)_camera_dispatcher_callback_supported_flash_mode,
3945                 (void *)module);
3946
3947         LOGD("ret : 0x%x", ret);
3948
3949         muse_camera_msg_return(api, class, ret, module);
3950
3951         return MUSE_CAMERA_ERROR_NONE;
3952 }
3953
3954 int camera_dispatcher_attr_foreach_supported_fps(muse_module_h module)
3955 {
3956         int ret = CAMERA_ERROR_NONE;
3957         muse_camera_handle_s *muse_camera = NULL;
3958         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
3959         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
3960
3961         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3962
3963         LOGD("handle : %p", muse_camera);
3964
3965         ret = legacy_camera_attr_foreach_supported_fps(muse_camera->camera_handle,
3966                 (camera_attr_supported_fps_cb)_camera_dispatcher_callback_supported_fps,
3967                 (void *)module);
3968
3969         LOGD("ret : 0x%x", ret);
3970
3971         muse_camera_msg_return(api, class, ret, module);
3972
3973         return MUSE_CAMERA_ERROR_NONE;
3974 }
3975
3976 int camera_dispatcher_attr_foreach_supported_fps_by_resolution(muse_module_h module)
3977 {
3978         int ret = CAMERA_ERROR_NONE;
3979         muse_camera_handle_s *muse_camera = NULL;
3980         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
3981         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
3982         int value = 0;
3983         int width = 0;
3984         int height = 0;
3985
3986         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
3987
3988         muse_camera_msg_get(value, muse_core_client_get_msg(module));
3989
3990         width = value >> 16;
3991         height = 0x0000ffff & value;
3992
3993         LOGD("handle : %p - %dx%d", muse_camera, width, height);
3994
3995         ret = legacy_camera_attr_foreach_supported_fps_by_resolution(muse_camera->camera_handle,
3996                 width, height,
3997                 (camera_attr_supported_fps_cb)_camera_dispatcher_callback_supported_fps_by_resolution,
3998                 (void *)module);
3999
4000         LOGD("ret : 0x%x", ret);
4001
4002         muse_camera_msg_return(api, class, ret, module);
4003
4004         return MUSE_CAMERA_ERROR_NONE;
4005 }
4006
4007 int camera_dispatcher_attr_foreach_supported_stream_flip(muse_module_h module)
4008 {
4009         int ret = CAMERA_ERROR_NONE;
4010         muse_camera_handle_s *muse_camera = NULL;
4011         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
4012         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
4013
4014         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4015
4016         LOGD("handle : %p", muse_camera);
4017
4018         ret = legacy_camera_attr_foreach_supported_stream_flip(muse_camera->camera_handle,
4019                 (camera_attr_supported_stream_flip_cb)_camera_dispatcher_callback_supported_stream_flip,
4020                 (void *)module);
4021
4022         LOGD("ret : 0x%x", ret);
4023
4024         muse_camera_msg_return(api, class, ret, module);
4025
4026         return MUSE_CAMERA_ERROR_NONE;
4027 }
4028
4029 int camera_dispatcher_attr_foreach_supported_stream_rotation(muse_module_h module)
4030 {
4031         int ret = CAMERA_ERROR_NONE;
4032         muse_camera_handle_s *muse_camera = NULL;
4033         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
4034         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
4035
4036         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4037
4038         LOGD("handle : %p", muse_camera);
4039
4040         ret = legacy_camera_attr_foreach_supported_stream_rotation(muse_camera->camera_handle,
4041                 (camera_attr_supported_stream_rotation_cb)_camera_dispatcher_callback_supported_stream_rotation,
4042                 (void *)module);
4043
4044         LOGD("ret : 0x%x", ret);
4045
4046         muse_camera_msg_return(api, class, ret, module);
4047
4048         return MUSE_CAMERA_ERROR_NONE;
4049 }
4050
4051 int camera_dispatcher_attr_set_stream_rotation(muse_module_h module)
4052 {
4053         int ret = CAMERA_ERROR_NONE;
4054         muse_camera_handle_s *muse_camera = NULL;
4055         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
4056         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4057         int set_rotation;
4058
4059         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4060
4061         muse_camera_msg_get(set_rotation, muse_core_client_get_msg(module));
4062
4063         LOGD("handle : %p", muse_camera);
4064
4065         ret = legacy_camera_attr_set_stream_rotation(muse_camera->camera_handle, (camera_rotation_e)set_rotation);
4066
4067         LOGD("ret : 0x%x", ret);
4068
4069         muse_camera_msg_return(api, class, ret, module);
4070
4071         return MUSE_CAMERA_ERROR_NONE;
4072 }
4073
4074 int camera_dispatcher_attr_get_stream_rotation(muse_module_h module)
4075 {
4076         int ret = CAMERA_ERROR_NONE;
4077         muse_camera_handle_s *muse_camera = NULL;
4078         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
4079         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4080         camera_rotation_e get_value = CAMERA_ROTATION_NONE;
4081
4082         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4083
4084         LOGD("handle : %p", muse_camera);
4085
4086         ret = legacy_camera_attr_get_stream_rotation(muse_camera->camera_handle, &get_value);
4087         if (ret == CAMERA_ERROR_NONE) {
4088                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4089                         MUSE_CAMERA_GET_INT_STREAM_ROTATION, "get_value", get_value, NULL);
4090         } else {
4091                 muse_camera_msg_return(api, class, ret, module);
4092         }
4093
4094         return MUSE_CAMERA_ERROR_NONE;
4095 }
4096
4097 int camera_dispatcher_attr_set_stream_flip(muse_module_h module)
4098 {
4099         int ret = CAMERA_ERROR_NONE;
4100         muse_camera_handle_s *muse_camera = NULL;
4101         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
4102         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4103         int set_flip;
4104
4105         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4106
4107         muse_camera_msg_get(set_flip, muse_core_client_get_msg(module));
4108
4109         LOGD("handle : %p", muse_camera);
4110
4111         ret = legacy_camera_attr_set_stream_flip(muse_camera->camera_handle, (camera_flip_e)set_flip);
4112
4113         LOGD("ret : 0x%x", ret);
4114
4115         muse_camera_msg_return(api, class, ret, module);
4116
4117         return MUSE_CAMERA_ERROR_NONE;
4118 }
4119
4120 int camera_dispatcher_attr_get_stream_flip(muse_module_h module)
4121 {
4122         int ret = CAMERA_ERROR_NONE;
4123         muse_camera_handle_s *muse_camera = NULL;
4124         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
4125         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4126         camera_flip_e get_value = CAMERA_FLIP_NONE;
4127
4128         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4129
4130         LOGD("handle : %p", muse_camera);
4131
4132         ret = legacy_camera_attr_get_stream_flip(muse_camera->camera_handle, &get_value);
4133         if (ret == CAMERA_ERROR_NONE) {
4134                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4135                         MUSE_CAMERA_GET_INT_STREAM_FLIP, "get_value", get_value, NULL);
4136         } else {
4137                 muse_camera_msg_return(api, class, ret, module);
4138         }
4139
4140         return MUSE_CAMERA_ERROR_NONE;
4141 }
4142
4143 int camera_dispatcher_attr_set_hdr_mode(muse_module_h module)
4144 {
4145         int set_mode = 0;
4146         muse_camera_handle_s *muse_camera = NULL;
4147
4148         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4149
4150         LOGD("handle : %p", muse_camera);
4151
4152         muse_camera_msg_get(set_mode, muse_core_client_get_msg(module));
4153
4154         _camera_task_add_job(muse_camera, MUSE_CAMERA_API_ATTR_SET_HDR_MODE,
4155                 MUSE_CAMERA_API_CLASS_IMMEDIATE, set_mode);
4156
4157         return MUSE_CAMERA_ERROR_NONE;
4158 }
4159
4160 int camera_dispatcher_attr_get_hdr_mode(muse_module_h module)
4161 {
4162         int ret = CAMERA_ERROR_NONE;
4163         muse_camera_handle_s *muse_camera = NULL;
4164         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
4165         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4166         camera_attr_hdr_mode_e get_value = CAMERA_ATTR_HDR_MODE_DISABLE;
4167
4168         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4169
4170         LOGD("handle : %p", muse_camera);
4171
4172         ret = legacy_camera_attr_get_hdr_mode(muse_camera->camera_handle, &get_value);
4173         if (ret == CAMERA_ERROR_NONE) {
4174                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4175                         MUSE_CAMERA_GET_INT_HDR_MODE, "get_value", get_value, NULL);
4176         } else {
4177                 muse_camera_msg_return(api, class, ret, module);
4178         }
4179
4180         return MUSE_CAMERA_ERROR_NONE;
4181 }
4182
4183 int camera_dispatcher_attr_is_supported_hdr_capture(muse_module_h module)
4184 {
4185         int ret = CAMERA_ERROR_NONE;
4186         muse_camera_handle_s *muse_camera = NULL;
4187         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
4188         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4189
4190         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4191
4192         LOGD("handle : %p", muse_camera);
4193
4194         ret = legacy_camera_attr_is_supported_hdr_capture(muse_camera->camera_handle);
4195
4196         LOGD("ret : 0x%x", ret);
4197
4198         muse_camera_msg_return(api, class, ret, module);
4199
4200         return MUSE_CAMERA_ERROR_NONE;
4201 }
4202
4203 int camera_dispatcher_attr_set_hdr_capture_progress_cb(muse_module_h module)
4204 {
4205         int ret = CAMERA_ERROR_NONE;
4206         muse_camera_handle_s *muse_camera = NULL;
4207         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
4208         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4209
4210         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4211
4212         LOGD("handle : %p", muse_camera);
4213
4214         ret = legacy_camera_attr_set_hdr_capture_progress_cb(muse_camera->camera_handle,
4215                 (camera_attr_hdr_progress_cb)_camera_dispatcher_hdr_progress_cb,
4216                 (void *)module);
4217
4218         LOGD("ret : 0x%x", ret);
4219
4220         muse_camera_msg_return(api, class, ret, module);
4221
4222         return MUSE_CAMERA_ERROR_NONE;
4223 }
4224
4225 int camera_dispatcher_attr_unset_hdr_capture_progress_cb(muse_module_h module)
4226 {
4227         int ret = CAMERA_ERROR_NONE;
4228         muse_camera_handle_s *muse_camera = NULL;
4229         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
4230         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4231
4232         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4233
4234         LOGD("handle : %p", muse_camera);
4235
4236         ret = legacy_camera_attr_unset_hdr_capture_progress_cb(muse_camera->camera_handle);
4237
4238         LOGD("ret : 0x%x", ret);
4239
4240         muse_camera_msg_return(api, class, ret, module);
4241
4242         return MUSE_CAMERA_ERROR_NONE;
4243 }
4244
4245 int camera_dispatcher_attr_enable_anti_shake(muse_module_h module)
4246 {
4247         int ret = CAMERA_ERROR_NONE;
4248         muse_camera_handle_s *muse_camera = NULL;
4249         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
4250         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4251         int set_enable;
4252
4253         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4254
4255         muse_camera_msg_get(set_enable, muse_core_client_get_msg(module));
4256
4257         LOGD("handle : %p", muse_camera);
4258
4259         ret = legacy_camera_attr_enable_anti_shake(muse_camera->camera_handle, (bool)set_enable);
4260
4261         LOGD("ret : 0x%x", ret);
4262
4263         muse_camera_msg_return(api, class, ret, module);
4264
4265         return MUSE_CAMERA_ERROR_NONE;
4266 }
4267
4268 int camera_dispatcher_attr_is_enabled_anti_shake(muse_module_h module)
4269 {
4270         int ret = CAMERA_ERROR_NONE;
4271         muse_camera_handle_s *muse_camera = NULL;
4272         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
4273         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4274         bool get_value = false;
4275
4276         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4277
4278         LOGD("handle : %p", muse_camera);
4279
4280         ret = legacy_camera_attr_is_enabled_anti_shake(muse_camera->camera_handle, &get_value);
4281         if (ret == CAMERA_ERROR_NONE) {
4282                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4283                         MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE, "get_value", get_value, NULL);
4284         } else {
4285                 muse_camera_msg_return(api, class, ret, module);
4286         }
4287
4288         return MUSE_CAMERA_ERROR_NONE;
4289 }
4290
4291 int camera_dispatcher_attr_is_supported_anti_shake(muse_module_h module)
4292 {
4293         int ret = CAMERA_ERROR_NONE;
4294         muse_camera_handle_s *muse_camera = NULL;
4295         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
4296         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4297
4298         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4299
4300         LOGD("handle : %p", muse_camera);
4301
4302         ret = legacy_camera_attr_is_supported_anti_shake(muse_camera->camera_handle);
4303
4304         LOGD("ret : 0x%x", ret);
4305
4306         muse_camera_msg_return(api, class, ret, module);
4307
4308         return MUSE_CAMERA_ERROR_NONE;
4309 }
4310
4311 int camera_dispatcher_attr_enable_video_stabilization(muse_module_h module)
4312 {
4313         int ret = CAMERA_ERROR_NONE;
4314         muse_camera_handle_s *muse_camera = NULL;
4315         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
4316         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4317         int set_enable;
4318
4319         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4320
4321         muse_camera_msg_get(set_enable, muse_core_client_get_msg(module));
4322
4323         LOGD("handle : %p", muse_camera);
4324
4325         ret = legacy_camera_attr_enable_video_stabilization(muse_camera->camera_handle, (bool)set_enable);
4326
4327         LOGD("ret : 0x%x", ret);
4328
4329         muse_camera_msg_return(api, class, ret, module);
4330
4331         return MUSE_CAMERA_ERROR_NONE;
4332 }
4333
4334 int camera_dispatcher_attr_is_enabled_video_stabilization(muse_module_h module)
4335 {
4336         int ret = CAMERA_ERROR_NONE;
4337         muse_camera_handle_s *muse_camera = NULL;
4338         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
4339         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4340         bool get_value = false;
4341
4342         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4343
4344         LOGD("handle : %p", muse_camera);
4345
4346         ret = legacy_camera_attr_is_enabled_video_stabilization(muse_camera->camera_handle, &get_value);
4347         if (ret == CAMERA_ERROR_NONE) {
4348                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4349                         MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION, "get_value", get_value, NULL);
4350         } else {
4351                 muse_camera_msg_return(api, class, ret, module);
4352         }
4353
4354         return MUSE_CAMERA_ERROR_NONE;
4355 }
4356
4357 int camera_dispatcher_attr_is_supported_video_stabilization(muse_module_h module)
4358 {
4359         int ret = CAMERA_ERROR_NONE;
4360         muse_camera_handle_s *muse_camera = NULL;
4361         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
4362         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4363
4364         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4365
4366         LOGD("handle : %p", muse_camera);
4367
4368         ret = legacy_camera_attr_is_supported_video_stabilization(muse_camera->camera_handle);
4369
4370         LOGD("ret : 0x%x", ret);
4371
4372         muse_camera_msg_return(api, class, ret, module);
4373
4374         return MUSE_CAMERA_ERROR_NONE;
4375 }
4376
4377 int camera_dispatcher_attr_enable_auto_contrast(muse_module_h module)
4378 {
4379         int ret = CAMERA_ERROR_NONE;
4380         muse_camera_handle_s *muse_camera = NULL;
4381         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
4382         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4383         int set_enable;
4384
4385         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4386
4387         muse_camera_msg_get(set_enable, muse_core_client_get_msg(module));
4388
4389         LOGD("handle : %p", muse_camera);
4390
4391         ret = legacy_camera_attr_enable_auto_contrast(muse_camera->camera_handle, (bool)set_enable);
4392
4393         LOGD("ret : 0x%x", ret);
4394
4395         muse_camera_msg_return(api, class, ret, module);
4396
4397         return MUSE_CAMERA_ERROR_NONE;
4398 }
4399
4400 int camera_dispatcher_attr_is_enabled_auto_contrast(muse_module_h module)
4401 {
4402         int ret = CAMERA_ERROR_NONE;
4403         muse_camera_handle_s *muse_camera = NULL;
4404         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
4405         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4406         bool get_value = false;
4407
4408         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4409
4410         LOGD("handle : %p", muse_camera);
4411
4412         ret = legacy_camera_attr_is_enabled_auto_contrast(muse_camera->camera_handle, &get_value);
4413         if (ret == CAMERA_ERROR_NONE) {
4414                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4415                         MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST, "get_value", get_value, NULL);
4416         } else {
4417                 muse_camera_msg_return(api, class, ret, module);
4418         }
4419
4420         return MUSE_CAMERA_ERROR_NONE;
4421 }
4422
4423 int camera_dispatcher_attr_is_supported_auto_contrast(muse_module_h module)
4424 {
4425         int ret = CAMERA_ERROR_NONE;
4426         muse_camera_handle_s *muse_camera = NULL;
4427         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
4428         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4429
4430         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4431
4432         LOGD("handle : %p", muse_camera);
4433
4434         ret = legacy_camera_attr_is_supported_auto_contrast(muse_camera->camera_handle);
4435
4436         LOGD("ret : 0x%x", ret);
4437
4438         muse_camera_msg_return(api, class, ret, module);
4439
4440         return MUSE_CAMERA_ERROR_NONE;
4441 }
4442
4443 int camera_dispatcher_attr_disable_shutter_sound(muse_module_h module)
4444 {
4445         int ret = CAMERA_ERROR_NONE;
4446         muse_camera_handle_s *muse_camera = NULL;
4447         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
4448         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4449         int set_disable;
4450
4451         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4452
4453         muse_camera_msg_get(set_disable, muse_core_client_get_msg(module));
4454
4455         LOGD("handle : %p", muse_camera);
4456
4457         ret = legacy_camera_attr_disable_shutter_sound(muse_camera->camera_handle, (bool)set_disable);
4458
4459         LOGD("ret : 0x%x", ret);
4460
4461         muse_camera_msg_return(api, class, ret, module);
4462
4463         return MUSE_CAMERA_ERROR_NONE;
4464 }
4465
4466 int camera_dispatcher_attr_get_encoded_preview_bitrate(muse_module_h module)
4467 {
4468         int ret = CAMERA_ERROR_NONE;
4469         muse_camera_handle_s *muse_camera = NULL;
4470         int get_value = 0;
4471         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4472         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4473
4474         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4475
4476         LOGD("handle : %p", muse_camera);
4477
4478         ret = legacy_camera_attr_get_encoded_preview_bitrate(muse_camera->camera_handle, &get_value);
4479         if (ret == CAMERA_ERROR_NONE) {
4480                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4481                         MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE, "get_value", get_value, NULL);
4482         } else {
4483                 muse_camera_msg_return(api, class, ret, module);
4484         }
4485
4486         return MUSE_CAMERA_ERROR_NONE;
4487 }
4488
4489 int camera_dispatcher_attr_set_encoded_preview_bitrate(muse_module_h module)
4490 {
4491         int ret = CAMERA_ERROR_NONE;
4492         muse_camera_handle_s *muse_camera = NULL;
4493         int set_bitrate;
4494         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4495         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4496
4497         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4498
4499         muse_camera_msg_get(set_bitrate, muse_core_client_get_msg(module));
4500
4501         LOGD("handle : 0x%x, set_encoded_preview_bitrate : %d", muse_camera, set_bitrate);
4502
4503         ret = legacy_camera_attr_set_encoded_preview_bitrate(muse_camera->camera_handle, set_bitrate);
4504
4505         LOGD("ret : 0x%x", ret);
4506
4507         muse_camera_msg_return(api, class, ret, module);
4508
4509         return MUSE_CAMERA_ERROR_NONE;
4510 }
4511
4512 int camera_dispatcher_attr_get_encoded_preview_gop_interval(muse_module_h module)
4513 {
4514         int ret = CAMERA_ERROR_NONE;
4515         muse_camera_handle_s *muse_camera = NULL;
4516         int get_value;
4517         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4518         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4519
4520         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4521
4522         LOGD("handle : %p", muse_camera);
4523
4524         ret = legacy_camera_attr_get_encoded_preview_gop_interval(muse_camera->camera_handle, &get_value);
4525         if (ret == CAMERA_ERROR_NONE) {
4526                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4527                         MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL, "get_value", get_value, NULL);
4528         } else {
4529                 muse_camera_msg_return(api, class, ret, module);
4530         }
4531
4532         return MUSE_CAMERA_ERROR_NONE;
4533 }
4534
4535 int camera_dispatcher_attr_set_encoded_preview_gop_interval(muse_module_h module)
4536 {
4537         int ret = CAMERA_ERROR_NONE;
4538         muse_camera_handle_s *muse_camera = NULL;
4539         int set_gop_interval;
4540         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4541         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4542
4543         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4544
4545         muse_camera_msg_get(set_gop_interval, muse_core_client_get_msg(module));
4546
4547         LOGD("handle : 0x%x, set_encoded_preview_gop_interval : %d", muse_camera, set_gop_interval);
4548
4549         ret = legacy_camera_attr_set_encoded_preview_gop_interval(muse_camera->camera_handle, set_gop_interval);
4550
4551         LOGD("ret : 0x%x", ret);
4552
4553         muse_camera_msg_return(api, class, ret, module);
4554
4555         return MUSE_CAMERA_ERROR_NONE;
4556 }
4557
4558 int camera_dispatcher_attr_set_pan(muse_module_h module)
4559 {
4560         int ret = CAMERA_ERROR_NONE;
4561         muse_camera_handle_s *muse_camera = NULL;
4562         int value = 0;
4563         int type = 0;
4564         int step = 0;
4565         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
4566         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4567
4568         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4569
4570         muse_camera_msg_get(value, muse_core_client_get_msg(module));
4571
4572         type = value >> 16;
4573         step = 0x0000ffff & value;
4574
4575         LOGD("handle : 0x%x - type %d, step %d", muse_camera, type, step);
4576
4577         ret = legacy_camera_attr_set_pan(muse_camera->camera_handle, type, step);
4578
4579         LOGD("ret : 0x%x", ret);
4580
4581         muse_camera_msg_return(api, class, ret, module);
4582
4583         return MUSE_CAMERA_ERROR_NONE;
4584 }
4585
4586 int camera_dispatcher_attr_get_pan(muse_module_h module)
4587 {
4588         int ret = CAMERA_ERROR_NONE;
4589         muse_camera_handle_s *muse_camera = NULL;
4590         int get_value = 0;
4591         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
4592         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4593
4594         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4595
4596         LOGD("handle : %p", muse_camera);
4597
4598         ret = legacy_camera_attr_get_pan(muse_camera->camera_handle, &get_value);
4599         if (ret == CAMERA_ERROR_NONE) {
4600                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4601                         MUSE_CAMERA_GET_INT_PAN, "get_value", get_value, NULL);
4602         } else {
4603                 muse_camera_msg_return(api, class, ret, module);
4604         }
4605
4606         return MUSE_CAMERA_ERROR_NONE;
4607 }
4608
4609 int camera_dispatcher_attr_get_pan_range(muse_module_h module)
4610 {
4611         int ret = CAMERA_ERROR_NONE;
4612         muse_camera_handle_s *muse_camera = NULL;
4613         int get_value0 = 0;
4614         int get_value1 = 0;
4615         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
4616         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4617         muse_camera_get_type_e get_type = MUSE_CAMERA_GET_TYPE_INT_PAIR;
4618         muse_camera_get_int_pair_e index = MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE;
4619
4620         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4621
4622         LOGD("handle : %p", muse_camera);
4623
4624         ret = legacy_camera_attr_get_pan_range(muse_camera->camera_handle, &get_value0, &get_value1);
4625         if (ret == CAMERA_ERROR_NONE)
4626                 muse_camera_msg_return2(api, class, ret, module, get_type, index, get_value0, get_value1);
4627         else
4628                 muse_camera_msg_return(api, class, ret, module);
4629
4630         return MUSE_CAMERA_ERROR_NONE;
4631 }
4632
4633 int camera_dispatcher_attr_set_tilt(muse_module_h module)
4634 {
4635         int ret = CAMERA_ERROR_NONE;
4636         muse_camera_handle_s *muse_camera = NULL;
4637         int value = 0;
4638         int type = 0;
4639         int step = 0;
4640         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
4641         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4642
4643         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4644
4645         muse_camera_msg_get(value, muse_core_client_get_msg(module));
4646
4647         type = value >> 16;
4648         step = 0x0000ffff & value;
4649
4650         LOGD("handle : 0x%x - type %d, step %d", muse_camera, type, step);
4651
4652         ret = legacy_camera_attr_set_tilt(muse_camera->camera_handle, type, step);
4653
4654         LOGD("ret : 0x%x", ret);
4655
4656         muse_camera_msg_return(api, class, ret, module);
4657
4658         return MUSE_CAMERA_ERROR_NONE;
4659 }
4660
4661 int camera_dispatcher_attr_get_tilt(muse_module_h module)
4662 {
4663         int ret = CAMERA_ERROR_NONE;
4664         muse_camera_handle_s *muse_camera = NULL;
4665         int get_value = 0;
4666         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
4667         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4668
4669         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4670
4671         LOGD("handle : %p", muse_camera);
4672
4673         ret = legacy_camera_attr_get_tilt(muse_camera->camera_handle, &get_value);
4674         if (ret == CAMERA_ERROR_NONE) {
4675                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4676                         MUSE_CAMERA_GET_INT_TILT, "get_value", get_value, NULL);
4677         } else {
4678                 muse_camera_msg_return(api, class, ret, module);
4679         }
4680
4681         return MUSE_CAMERA_ERROR_NONE;
4682 }
4683
4684 int camera_dispatcher_attr_get_tilt_range(muse_module_h module)
4685 {
4686         int ret = CAMERA_ERROR_NONE;
4687         muse_camera_handle_s *muse_camera = NULL;
4688         int get_value0 = 0;
4689         int get_value1 = 0;
4690         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
4691         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4692         muse_camera_get_type_e get_type = MUSE_CAMERA_GET_TYPE_INT_PAIR;
4693         muse_camera_get_int_pair_e index = MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE;
4694
4695         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4696
4697         LOGD("handle : %p", muse_camera);
4698
4699         ret = legacy_camera_attr_get_tilt_range(muse_camera->camera_handle, &get_value0, &get_value1);
4700         if (ret == CAMERA_ERROR_NONE)
4701                 muse_camera_msg_return2(api, class, ret, module, get_type, index, get_value0, get_value1);
4702         else
4703                 muse_camera_msg_return(api, class, ret, module);
4704
4705         return MUSE_CAMERA_ERROR_NONE;
4706 }
4707
4708 int camera_dispatcher_attr_set_ptz_type(muse_module_h module)
4709 {
4710         int ret = CAMERA_ERROR_NONE;
4711         muse_camera_handle_s *muse_camera = NULL;
4712         int set_ptz_type = 0;
4713         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
4714         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4715
4716         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4717
4718         muse_camera_msg_get(set_ptz_type, muse_core_client_get_msg(module));
4719
4720         LOGD("handle : 0x%x", muse_camera);
4721
4722         ret = legacy_camera_attr_set_ptz_type(muse_camera->camera_handle, set_ptz_type);
4723
4724         LOGD("ret : 0x%x", ret);
4725
4726         muse_camera_msg_return(api, class, ret, module);
4727
4728         return MUSE_CAMERA_ERROR_NONE;
4729 }
4730
4731 int camera_dispatcher_attr_foreach_supported_ptz_type(muse_module_h module)
4732 {
4733         int ret = CAMERA_ERROR_NONE;
4734         muse_camera_handle_s *muse_camera = NULL;
4735         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
4736         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_THREAD_SUB;
4737
4738         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4739
4740         LOGD("handle : %p", muse_camera);
4741
4742         ret = legacy_camera_attr_foreach_supported_ptz_type(muse_camera->camera_handle,
4743                 (camera_attr_supported_ptz_type_cb)_camera_dispatcher_callback_supported_ptz_type,
4744                 (void *)module);
4745
4746         LOGD("ret : 0x%x", ret);
4747
4748         muse_camera_msg_return(api, class, ret, module);
4749
4750         return MUSE_CAMERA_ERROR_NONE;
4751 }
4752
4753 int camera_dispatcher_attr_set_display_roi_area(muse_module_h module)
4754 {
4755         int ret = CAMERA_ERROR_NONE;
4756         muse_camera_handle_s *muse_camera = NULL;
4757         int set_display_roi_area[4] = {0,};
4758         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
4759         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4760
4761         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4762
4763         muse_camera_msg_get_array(set_display_roi_area, muse_core_client_get_msg(module));
4764
4765         LOGD("handle : 0x%x, x : %d, y : %d, width : %d, height : %d", muse_camera,
4766                 set_display_roi_area[0], set_display_roi_area[1], set_display_roi_area[2], set_display_roi_area[3]);
4767
4768         ret = legacy_camera_attr_set_display_roi_area(muse_camera->camera_handle, set_display_roi_area);
4769
4770         LOGD("ret : 0x%x", ret);
4771
4772         muse_camera_msg_return(api, class, ret, module);
4773
4774         return MUSE_CAMERA_ERROR_NONE;
4775 }
4776
4777 int camera_dispatcher_attr_get_display_roi_area(muse_module_h module)
4778 {
4779         int ret = CAMERA_ERROR_NONE;
4780         muse_camera_handle_s *muse_camera = NULL;
4781         int get_value[4] = {0,};
4782         muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
4783         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4784         char *send_msg = NULL;
4785
4786         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4787
4788         LOGD("handle : %p", muse_camera);
4789
4790         ret = legacy_camera_attr_get_display_roi_area(muse_camera->camera_handle, get_value);
4791         if (ret == CAMERA_ERROR_NONE) {
4792                 send_msg = muse_core_msg_json_factory_new(api,
4793                         MUSE_TYPE_INT, PARAM_API_CLASS, class,
4794                         MUSE_TYPE_INT, PARAM_RET, ret,
4795                         MUSE_TYPE_INT, PARAM_GET_TYPE, MUSE_CAMERA_GET_TYPE_ARRAY,
4796                         MUSE_TYPE_ARRAY, "get_value", 4, get_value,
4797                         0);
4798
4799                 __camera_dispatcher_send_msg(module, send_msg);
4800         } else {
4801                 muse_camera_msg_return(api, class, ret, module);
4802         }
4803
4804         return MUSE_CAMERA_ERROR_NONE;
4805 }
4806
4807
4808 int camera_dispatcher_return_buffer(muse_module_h module)
4809 {
4810         int tbm_key = 0;
4811         muse_camera_handle_s *muse_camera = NULL;
4812
4813         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4814
4815         muse_camera_msg_get(tbm_key, muse_core_client_get_msg(module));
4816
4817         /*LOGD("handle : %p, key : %d", muse_camera, tbm_key);*/
4818
4819         if (!_camera_remove_export_data(module, tbm_key, FALSE))
4820                 LOGE("remove export data failed : key %d", tbm_key);
4821
4822         return MUSE_CAMERA_ERROR_NONE;
4823 }
4824
4825 int camera_dispatcher_preview_cb_return(muse_module_h module)
4826 {
4827         muse_camera_handle_s *muse_camera = NULL;
4828
4829         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4830
4831         if (muse_camera == NULL) {
4832                 LOGE("NULL handle");
4833                 return MUSE_CAMERA_ERROR_NONE;
4834         }
4835
4836         /*LOGD("ENTER");*/
4837
4838         g_mutex_lock(&muse_camera->preview_cb_lock);
4839         g_cond_signal(&muse_camera->preview_cb_cond);
4840         /*LOGD("send signal for preview callback");*/
4841         g_mutex_unlock(&muse_camera->preview_cb_lock);
4842
4843         /*LOGD("DONE");*/
4844
4845         return MUSE_CAMERA_ERROR_NONE;
4846 }
4847
4848 int camera_dispatcher_set_display_reuse_hint(muse_module_h module)
4849 {
4850         int ret = CAMERA_ERROR_NONE;
4851         int set_hint = 0;
4852         muse_camera_handle_s *muse_camera = NULL;
4853         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT;
4854         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4855
4856         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4857
4858         muse_camera_msg_get(set_hint, muse_core_client_get_msg(module));
4859
4860         LOGD("set hint : %d", set_hint);
4861
4862         ret = legacy_camera_set_display_reuse_hint(muse_camera->camera_handle, (bool)set_hint);
4863
4864         muse_camera_msg_return(api, class, ret, module);
4865
4866         return MUSE_CAMERA_ERROR_NONE;
4867 }
4868
4869 int camera_dispatcher_get_display_reuse_hint(muse_module_h module)
4870 {
4871         int ret = CAMERA_ERROR_NONE;
4872         int get_value = 0;
4873         muse_camera_handle_s *muse_camera = NULL;
4874         muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
4875         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4876
4877         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
4878
4879         ret = legacy_camera_get_display_reuse_hint(muse_camera->camera_handle, &get_value);
4880         if (ret == CAMERA_ERROR_NONE) {
4881                 LOGD("hint : %d", get_value);
4882                 muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4883                         MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT, "get_value", get_value, NULL);
4884         } else {
4885                 muse_camera_msg_return(api, class, ret, module);
4886         }
4887
4888         return MUSE_CAMERA_ERROR_NONE;
4889 }
4890
4891 int camera_dispatcher_get_device_state(muse_module_h module)
4892 {
4893         int ret = CAMERA_ERROR_NONE;
4894         bool is_called = false;
4895         char value_key[KEY_LENGTH] = {'\0',};
4896         camera_h camera = NULL;
4897         camera_device_e device_type = CAMERA_DEVICE_CAMERA0;
4898         camera_device_state_e get_device_state = CAMERA_DEVICE_STATE_NULL;
4899         muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_STATE;
4900         muse_camera_api_class_e class = MUSE_CAMERA_API_CLASS_IMMEDIATE;
4901
4902         muse_camera_msg_get(device_type, muse_core_client_get_msg(module));
4903
4904         if (device_type < CAMERA_DEVICE_CAMERA0 || device_type > CAMERA_DEVICE_CAMERA1) {
4905                 LOGE("invalid device %d", device_type);
4906
4907                 ret = CAMERA_ERROR_INVALID_PARAMETER;
4908                 muse_camera_msg_return(api, class, ret, module);
4909
4910                 return MUSE_CAMERA_ERROR_NONE;
4911         }
4912
4913         muse_core_client_get_value(module, MUSED_KEY_DEVICE_STATE_CHECK, (int *)&is_called);
4914
4915         if (!is_called) {
4916                 ret = legacy_camera_create(device_type, &camera);
4917                 if (camera) {
4918                         legacy_camera_destroy(camera);
4919                         camera = NULL;
4920                 }
4921
4922                 muse_core_client_set_value(module, MUSED_KEY_DEVICE_STATE_RETURN, ret);
4923                 muse_core_client_set_value(module, MUSED_KEY_DEVICE_STATE_CHECK, (int)true);
4924         } else {
4925                 muse_core_client_get_value(module, MUSED_KEY_DEVICE_STATE_RETURN, &ret);
4926         }
4927
4928         LOGD("is_called %d, ret 0x%x", is_called, ret);
4929
4930         if (ret != CAMERA_ERROR_NONE) {
4931                 LOGE("failed to create camera handle 0x%x", ret);
4932
4933                 muse_camera_msg_return(api, class, ret, module);
4934
4935                 return MUSE_CAMERA_ERROR_NONE;
4936         }
4937
4938         snprintf(value_key, KEY_LENGTH, "device_state_camera%d", device_type);
4939         muse_core_client_get_value(module, value_key, (int *)&get_device_state);
4940
4941         LOGD("device[%d] state : %d", device_type, get_device_state);
4942
4943         muse_camera_msg_return1(api, class, ret, module, MUSE_CAMERA_GET_TYPE_INT,
4944                 -1, "get_device_state", get_device_state, NULL);
4945
4946         return MUSE_CAMERA_ERROR_NONE;
4947 }
4948
4949 int (*dispatcher[MUSE_CAMERA_API_MAX]) (muse_module_h module) = {
4950         camera_dispatcher_create, /* MUSE_CAMERA_API_CREATE */
4951         camera_dispatcher_destroy, /* MUSE_CAMERA_API_DESTROY */
4952         camera_dispatcher_start_preview, /* MUSE_CAMERA_START_PREVIEW */
4953         camera_dispatcher_stop_preview, /* MUSE_CAMERA_API_START_PREVIEW */
4954         camera_dispatcher_start_capture, /* MUSE_CAMERA_START_CAPTURE */
4955         camera_dispatcher_is_supported_continuous_capture, /* MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE */
4956         camera_dispatcher_start_continuous_capture, /* MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE, */
4957         camera_dispatcher_stop_continuous_capture, /* MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE, */
4958         camera_dispatcher_is_supported_face_detection, /* MUSE_CAMERA_API_SUPPORT_FACE_DETECTION, */
4959         camera_dispatcher_is_supported_zero_shutter_lag, /* MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG, */
4960         camera_dispatcher_is_supported_media_packet_preview_cb, /* MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB, */
4961         camera_dispatcher_get_device_count, /* MUSE_CAMERA_API_GET_DEVICE_COUNT, */
4962         camera_dispatcher_start_face_detection, /* MUSE_CAMERA_API_START_FACE_DETECTION, */
4963         camera_dispatcher_stop_face_detection, /* MUSE_CAMERA_API_STOP_FACE_DETECTION, */
4964         camera_dispatcher_get_state, /* MUSE_CAMERA_API_GET_STATE, */
4965         camera_dispatcher_start_focusing, /* MUSE_CAMERA_API_START_FOCUSING, */
4966         camera_dispatcher_stop_focusing, /* MUSE_CAMERA_API_CANCEL_FOCUSING, */
4967         camera_dispatcher_set_display, /* MUSE_CAMERA_API_SET_DISPLAY, */
4968         camera_dispatcher_set_preview_resolution, /* MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION, */
4969         camera_dispatcher_set_capture_resolution, /* MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION, */
4970         camera_dispatcher_set_capture_format, /* MUSE_CAMERA_API_SET_CAPTURE_FORMAT, */
4971         camera_dispatcher_set_preview_format, /* MUSE_CAMERA_API_SET_PREVIEW_FORMAT, */
4972         camera_dispatcher_get_preview_resolution, /* MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION, */
4973         camera_dispatcher_set_display_rotation, /* MUSE_CAMERA_API_SET_DISPLAY_ROTATION, */
4974         camera_dispatcher_get_display_rotation, /* MUSE_CAMERA_API_GET_DISPLAY_ROTATION, */
4975         camera_dispatcher_set_display_flip, /* MUSE_CAMERA_API_SET_DISPLAY_FLIP, */
4976         camera_dispatcher_get_display_flip, /* MUSE_CAMERA_API_GET_DISPLAY_FLIP, */
4977         camera_dispatcher_set_display_visible, /* MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, */
4978         camera_dispatcher_is_display_visible, /* MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, */
4979         camera_dispatcher_set_display_mode, /* MUSE_CAMERA_API_SET_DISPLAY_MODE, */
4980         camera_dispatcher_get_display_mode, /* MUSE_CAMERA_API_GET_DISPLAY_MODE, */
4981         camera_dispatcher_get_capture_resolution, /* MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION, */
4982         camera_dispatcher_get_capture_format, /* MUSE_CAMERA_API_GET_CAPTURE_FORMAT, */
4983         camera_dispatcher_get_preview_format, /* MUSE_CAMERA_API_GET_PREVIEW_FORMAT, */
4984         camera_dispatcher_get_facing_direction, /* MUSE_CAMERA_API_GET_FACING_DIRECTION, */
4985         camera_dispatcher_get_flash_state, /* MUSE_CAMERA_API_GET_FLASH_STATE, */
4986         camera_dispatcher_set_preview_cb, /* MUSE_CAMERA_API_SET_PREVIEW_CB, */
4987         camera_dispatcher_unset_preview_cb, /* MUSE_CAMERA_API_UNSET_PREVIEW_CB, */
4988         camera_dispatcher_set_media_packet_preview_cb, /* MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB, */
4989         camera_dispatcher_unset_media_packet_preview_cb, /* MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB, */
4990         camera_dispatcher_set_state_changed_cb, /* MUSE_CAMERA_API_SET_STATE_CHANGED_CB, */
4991         camera_dispatcher_unset_state_changed_cb, /* MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB, */
4992         camera_dispatcher_set_interrupted_cb, /* MUSE_CAMERA_API_SET_INTERRUPTED_CB, */
4993         camera_dispatcher_unset_interrupted_cb, /* MUSE_CAMERA_API_UNSET_INTERRUPTED_CB, */
4994         camera_dispatcher_set_focus_changed_cb, /* MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB, */
4995         camera_dispatcher_unset_focus_changed_cb, /* MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB, */
4996         camera_dispatcher_set_error_cb, /* MUSE_CAMERA_API_SET_ERROR_CB, */
4997         camera_dispatcher_unset_error_cb, /* MUSE_CAMERA_API_UNSET_ERROR_CB, */
4998         camera_dispatcher_foreach_supported_preview_resolution, /* MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION, */
4999         camera_dispatcher_foreach_supported_capture_resolution, /* MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION, */
5000         camera_dispatcher_foreach_supported_capture_format, /* MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT, */
5001         camera_dispatcher_foreach_supported_preview_format, /* MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT, */
5002         camera_dispatcher_get_recommended_preview_resolution, /* MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION, */
5003         camera_dispatcher_attr_get_lens_orientation, /* MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION, */
5004         camera_dispatcher_attr_set_theater_mode, /* MUSE_CAMERA_API_ATTR_SET_THEATER_MODE, */
5005         camera_dispatcher_attr_get_theater_mode, /* MUSE_CAMERA_API_ATTR_GET_THEATER_MODE, */
5006         camera_dispatcher_attr_foreach_supported_theater_mode, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE, */
5007         camera_dispatcher_attr_set_preview_fps, /* MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS, */
5008         camera_dispatcher_attr_set_image_quality, /* MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY, */
5009         camera_dispatcher_attr_get_preview_fps, /* MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS, */
5010         camera_dispatcher_attr_get_image_quality, /* MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY, */
5011         camera_dispatcher_attr_set_zoom, /* MUSE_CAMERA_API_ATTR_SET_ZOOM, */
5012         camera_dispatcher_attr_set_af_mode, /* MUSE_CAMERA_API_ATTR_SET_AF_MODE, */
5013         camera_dispatcher_attr_set_af_area, /* MUSE_CAMERA_API_ATTR_SET_AF_AREA, */
5014         camera_dispatcher_attr_clear_af_area, /* MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA, */
5015         camera_dispatcher_attr_set_exposure_mode, /* MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE, */
5016         camera_dispatcher_attr_set_exposure, /* MUSE_CAMERA_API_ATTR_SET_EXPOSURE, */
5017         camera_dispatcher_attr_set_iso, /* MUSE_CAMERA_API_ATTR_SET_ISO, */
5018         camera_dispatcher_attr_set_brightness, /* MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS, */
5019         camera_dispatcher_attr_set_contrast, /* MUSE_CAMERA_API_ATTR_SET_CONTRAST, */
5020         camera_dispatcher_attr_set_whitebalance, /* MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE, */
5021         camera_dispatcher_attr_set_effect, /* MUSE_CAMERA_API_ATTR_SET_EFFECT, */
5022         camera_dispatcher_attr_set_scene_mode, /* MUSE_CAMERA_API_ATTR_SET_SCENE_MODE, */
5023         camera_dispatcher_attr_enable_tag, /* MUSE_CAMERA_API_ATTR_ENABLE_TAG, */
5024         camera_dispatcher_attr_set_tag_image_description, /* MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION, */
5025         camera_dispatcher_attr_set_tag_orientation, /* MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION, */
5026         camera_dispatcher_attr_set_tag_software, /* MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE, */
5027         camera_dispatcher_attr_set_geotag, /* MUSE_CAMERA_API_ATTR_SET_GEOTAG, */
5028         camera_dispatcher_attr_remove_geotag, /* MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG, */
5029         camera_dispatcher_attr_set_flash_mode, /* MUSE_CAMERA_API_ATTR_SET_FLASH_MODE, */
5030         camera_dispatcher_attr_get_zoom, /* MUSE_CAMERA_API_ATTR_GET_ZOOM, */
5031         camera_dispatcher_attr_get_zoom_range, /* MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE, */
5032         camera_dispatcher_attr_get_af_mode, /* MUSE_CAMERA_API_ATTR_GET_AF_MODE, */
5033         camera_dispatcher_attr_get_exposure_mode, /* MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE, */
5034         camera_dispatcher_attr_get_exposure, /* MUSE_CAMERA_API_ATTR_GET_EXPOSURE, */
5035         camera_dispatcher_attr_get_exposure_range, /* MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE, */
5036         camera_dispatcher_attr_get_iso, /* MUSE_CAMERA_API_ATTR_GET_ISO, */
5037         camera_dispatcher_attr_get_brightness, /* MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS, */
5038         camera_dispatcher_attr_get_brightness_range, /* MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE, */
5039         camera_dispatcher_attr_get_contrast, /* MUSE_CAMERA_API_ATTR_GET_CONTRAST, */
5040         camera_dispatcher_attr_get_contrast_range, /* MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE, */
5041         camera_dispatcher_attr_get_whitebalance, /* MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE, */
5042         camera_dispatcher_attr_get_effect, /* MUSE_CAMERA_API_ATTR_GET_EFFECT, */
5043         camera_dispatcher_attr_get_scene_mode, /* MUSE_CAMERA_API_ATTR_GET_SCENE_MODE, */
5044         camera_dispatcher_attr_is_enabled_tag, /* MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG, */
5045         camera_dispatcher_attr_get_tag_image_description, /* MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION, */
5046         camera_dispatcher_attr_get_tag_orientation, /* MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION, */
5047         camera_dispatcher_attr_get_tag_software, /* MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE, */
5048         camera_dispatcher_attr_get_geotag, /* MUSE_CAMERA_API_ATTR_GET_GEOTAG, */
5049         camera_dispatcher_attr_get_flash_mode, /* MUSE_CAMERA_API_ATTR_GET_FLASH_MODE, */
5050         camera_dispatcher_attr_foreach_supported_af_mode, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE, */
5051         camera_dispatcher_attr_foreach_supported_exposure_mode, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE, */
5052         camera_dispatcher_attr_foreach_supported_iso, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO, */
5053         camera_dispatcher_attr_foreach_supported_whitebalance, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE, */
5054         camera_dispatcher_attr_foreach_supported_effect, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT, */
5055         camera_dispatcher_attr_foreach_supported_scene_mode, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE, */
5056         camera_dispatcher_attr_foreach_supported_flash_mode, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE, */
5057         camera_dispatcher_attr_foreach_supported_fps, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS, */
5058         camera_dispatcher_attr_foreach_supported_fps_by_resolution, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION, */
5059         camera_dispatcher_attr_foreach_supported_stream_flip, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP, */
5060         camera_dispatcher_attr_foreach_supported_stream_rotation, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION, */
5061         camera_dispatcher_attr_set_stream_rotation, /* MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION, */
5062         camera_dispatcher_attr_get_stream_rotation, /* MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION, */
5063         camera_dispatcher_attr_set_stream_flip, /* MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP, */
5064         camera_dispatcher_attr_get_stream_flip, /* MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP, */
5065         camera_dispatcher_attr_set_hdr_mode, /* MUSE_CAMERA_API_ATTR_SET_HDR_MODE, */
5066         camera_dispatcher_attr_get_hdr_mode, /* MUSE_CAMERA_API_ATTR_GET_HDR_MODE, */
5067         camera_dispatcher_attr_is_supported_hdr_capture, /* MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE, */
5068         camera_dispatcher_attr_set_hdr_capture_progress_cb, /* MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB, */
5069         camera_dispatcher_attr_unset_hdr_capture_progress_cb, /* MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB, */
5070         camera_dispatcher_attr_enable_anti_shake, /* MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE, */
5071         camera_dispatcher_attr_is_enabled_anti_shake, /* MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE, */
5072         camera_dispatcher_attr_is_supported_anti_shake, /* MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE, */
5073         camera_dispatcher_attr_enable_video_stabilization, /* MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION, */
5074         camera_dispatcher_attr_is_enabled_video_stabilization, /* MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION, */
5075         camera_dispatcher_attr_is_supported_video_stabilization, /* MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION, */
5076         camera_dispatcher_attr_enable_auto_contrast, /* MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST, */
5077         camera_dispatcher_attr_is_enabled_auto_contrast, /* MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST, */
5078         camera_dispatcher_attr_is_supported_auto_contrast, /* MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST, */
5079         camera_dispatcher_attr_disable_shutter_sound, /* MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND, */
5080         camera_dispatcher_attr_get_encoded_preview_bitrate, /* MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE, */
5081         camera_dispatcher_attr_set_encoded_preview_bitrate, /* MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE, */
5082         camera_dispatcher_attr_get_encoded_preview_gop_interval, /* MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL, */
5083         camera_dispatcher_attr_set_encoded_preview_gop_interval, /* MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL, */
5084         camera_dispatcher_attr_set_pan, /* MUSE_CAMERA_API_ATTR_SET_PAN */
5085         camera_dispatcher_attr_get_pan, /* MUSE_CAMERA_API_ATTR_GET_PAN */
5086         camera_dispatcher_attr_get_pan_range, /* MUSE_CAMERA_API_ATTR_GET_PAN_RANGE */
5087         camera_dispatcher_attr_set_tilt, /* MUSE_CAMERA_API_ATTR_SET_TILT */
5088         camera_dispatcher_attr_get_tilt, /* MUSE_CAMERA_API_ATTR_GET_TILT */
5089         camera_dispatcher_attr_get_tilt_range, /* MUSE_CAMERA_API_ATTR_GET_TILT_RANGE */
5090         camera_dispatcher_attr_set_ptz_type, /* MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE */
5091         camera_dispatcher_attr_foreach_supported_ptz_type, /* MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE */
5092         camera_dispatcher_attr_set_display_roi_area, /* MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA */
5093         camera_dispatcher_attr_get_display_roi_area, /* MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA */
5094         camera_dispatcher_return_buffer, /* MUSE_CAMERA_API_RETURN_BUFFER */
5095         camera_dispatcher_preview_cb_return, /* MUSE_CAMERA_API_PREVIEW_CB_RETURN */
5096         camera_dispatcher_set_display_reuse_hint, /* MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT */
5097         camera_dispatcher_get_display_reuse_hint, /* MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT */
5098         camera_dispatcher_change_device, /* MUSE_CAMERA_API_CHANGE_DEVICE */
5099         camera_dispatcher_get_device_state /* MUSE_CAMERA_API_GET_DEVICE_STATE */
5100 };
5101
5102
5103 /******************/
5104 /* cmd dispatcher */
5105 /******************/
5106 static int camera_cmd_dispatcher_initialize(muse_module_h module)
5107 {
5108         int item_count = 0;
5109         int i = 0;
5110         GstPlugin *plugin = NULL;
5111
5112         const char *load_list[] = {
5113                 LIBDIR"/gstreamer-1.0/libgstcoreelements.so",
5114                 LIBDIR"/gstreamer-1.0/libgstcamerasrc.so",
5115                 LIBDIR"/gstreamer-1.0/libgstwaylandsink.so",
5116         };
5117
5118         item_count = sizeof(load_list) / sizeof(load_list[0]);
5119
5120         LOGD("item count %d", item_count);
5121
5122         for (i = 0 ; i < item_count ; i++) {
5123                 plugin = gst_plugin_load_file(load_list[i], NULL);
5124                 if (plugin) {
5125                         LOGD("%s loaded", load_list[i]);
5126                         gst_object_unref(plugin);
5127                         plugin = NULL;
5128                 } else {
5129                         LOGW("failed to load %s", load_list[i]);
5130                 }
5131         }
5132
5133         LOGD("done");
5134
5135         return MUSE_CAMERA_ERROR_NONE;
5136 }
5137
5138
5139 static int camera_cmd_dispatcher_shutdown(muse_module_h module)
5140 {
5141         muse_camera_handle_s *muse_camera = NULL;
5142         camera_state_e state = CAMERA_STATE_NONE;
5143         int capture_try_count = 0;
5144         int ret = 0;
5145
5146         muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
5147         if (muse_camera == NULL) {
5148                 LOGE("NULL handle");
5149                 return MUSE_CAMERA_ERROR_INVALID;
5150         }
5151
5152         legacy_camera_lock(muse_camera->camera_handle, true);
5153
5154         if (legacy_camera_is_used(muse_camera->camera_handle)) {
5155                 LOGW("camera is used in recorder.. wait...");
5156                 if (legacy_camera_wait(muse_camera->camera_handle, 3000)) {
5157                         LOGD("recorder is released");
5158                 } else {
5159                         legacy_camera_lock(muse_camera->camera_handle, false);
5160                         LOGE("wait timeout, could not release camera handle %p", muse_camera->camera_handle);
5161                         return MUSE_CAMERA_ERROR_INVALID;
5162                 }
5163         }
5164
5165         legacy_camera_lock(muse_camera->camera_handle, false);
5166
5167         muse_camera->is_shutting_down = true;
5168
5169 again:
5170         legacy_camera_get_state(muse_camera->camera_handle, &state);
5171
5172         LOGW("current state : %d", state);
5173
5174         switch (state) {
5175         case CAMERA_STATE_CAPTURING:
5176                 if (capture_try_count < 30) {
5177                         LOGW("now capturing.. wait for capture data...");
5178                         usleep(100 * 1000);
5179                         capture_try_count++;
5180                         goto again;
5181                 } else {
5182                         LOGE("wait capture data timeout! keep going...");
5183                 }
5184                 /* fall through */
5185         case CAMERA_STATE_CAPTURED:
5186                 legacy_camera_start_preview(muse_camera->camera_handle);
5187                 /* fall through */
5188         case CAMERA_STATE_PREVIEW:
5189                 _camera_remove_export_data(module, 0, TRUE); /* force return buffer before stop preview */
5190                 legacy_camera_stop_preview(muse_camera->camera_handle);
5191                 /* fall through */
5192         case CAMERA_STATE_CREATED:
5193                 ret = legacy_camera_destroy(muse_camera->camera_handle);
5194                 if (ret == CAMERA_ERROR_NONE)
5195                         _camera_dispatcher_release_resource(module);
5196                 else
5197                         LOGE("failed to destroy camera handle");
5198
5199                 break;
5200         default:
5201                 break;
5202         }
5203
5204         LOGW("done");
5205
5206         return MUSE_CAMERA_ERROR_NONE;
5207 }
5208
5209
5210 int (*cmd_dispatcher[MUSE_MODULE_COMMAND_MAX])(muse_module_h module) = {
5211         camera_cmd_dispatcher_initialize, /* MUSE_MODULE_COMMAND_INITIALIZE */
5212         camera_cmd_dispatcher_shutdown, /* MUSE_MODULE_COMMAND_SHUTDOWN */
5213         NULL, /* MUSE_MODULE_COMMAND_DEBUG_INFO_DUMP */
5214         NULL, /* MUSE_MODULE_COMMAND_CREATE_SERVER_ACK */
5215         NULL, /* MUSE_MODULE_COMMAND_RESOURCE_NOT_AVAILABLE */
5216         NULL  /* MUSE_MODULE_COMMAND_EXTERNAL_STORAGE_STATE_CHANGED */
5217 };