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