[Release version 0.2.38] Fix bug - invalid display setting
[platform/core/api/camera.git] / src / camera.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
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <mm.h>
22 #include <mm_types.h>
23 #include <camera.h>
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <muse_core_ipc.h>
27 #include <muse_core_module.h>
28 #include <camera_private.h>
29 #include <muse_core.h>
30 #include <dlog.h>
31 #include <Elementary.h>
32 #include <tbm_surface_internal.h>
33 #include <gst/gst.h>
34 #include <mm_camcorder.h>
35 #include <mm_camcorder_client.h>
36 #include <Evas.h>
37 #ifdef HAVE_WAYLAND
38 #include <Ecore_Wayland.h>
39 #else
40 #include <Ecore.h>
41 #endif
42
43 #ifdef LOG_TAG
44 #undef LOG_TAG
45 #endif
46 #define LOG_TAG "TIZEN_N_CAMERA"
47
48
49 int __convert_camera_error_code(const char *func, int code)
50 {
51         int ret = CAMERA_ERROR_NONE;
52         const char *errorstr = NULL;
53
54         switch (code) {
55         case MM_ERROR_NONE:
56                 ret = CAMERA_ERROR_NONE;
57                 errorstr = "ERROR_NONE";
58                 break;
59         case MM_ERROR_CAMCORDER_INVALID_ARGUMENT:
60         case MM_ERROR_COMMON_INVALID_ATTRTYPE:
61                 ret = CAMERA_ERROR_INVALID_PARAMETER;
62                 errorstr = "INVALID_PARAMETER";
63                 break;
64         case MM_ERROR_CAMCORDER_NOT_INITIALIZED:
65         case MM_ERROR_CAMCORDER_INVALID_STATE:
66                 ret = CAMERA_ERROR_INVALID_STATE;
67                 errorstr = "INVALID_STATE";
68                 break;
69         case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND:
70                 ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
71                 errorstr = "DEVICE_NOT_FOUND";
72                 break;
73         case MM_ERROR_CAMCORDER_DEVICE_BUSY:
74         case MM_ERROR_CAMCORDER_DEVICE_OPEN:
75         case MM_ERROR_CAMCORDER_CMD_IS_RUNNING:
76                 ret = CAMERA_ERROR_DEVICE_BUSY;
77                 errorstr = "DEVICE_BUSY";
78                 break;
79         case MM_ERROR_CAMCORDER_DEVICE:
80         case MM_ERROR_CAMCORDER_DEVICE_IO:
81         case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
82         case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
83         case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER:
84                 ret = CAMERA_ERROR_DEVICE;
85                 errorstr = "ERROR_DEVICE";
86                 break;
87         case MM_ERROR_CAMCORDER_GST_CORE:
88         case MM_ERROR_CAMCORDER_GST_LIBRARY:
89         case MM_ERROR_CAMCORDER_GST_RESOURCE:
90         case MM_ERROR_CAMCORDER_GST_STREAM:
91         case MM_ERROR_CAMCORDER_GST_STATECHANGE:
92         case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
93         case MM_ERROR_CAMCORDER_GST_LINK:
94         case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
95         case MM_ERROR_CAMCORDER_ENCODER:
96         case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
97         case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE:
98         case MM_ERROR_CAMCORDER_ENCODER_WORKING:
99         case MM_ERROR_CAMCORDER_INTERNAL:
100         case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT:
101         case MM_ERROR_CAMCORDER_DSP_FAIL:
102         case MM_ERROR_CAMCORDER_AUDIO_EMPTY:
103         case MM_ERROR_CAMCORDER_CREATE_CONFIGURE:
104         case MM_ERROR_CAMCORDER_FILE_SIZE_OVER:
105         case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF:
106         case MM_ERROR_CAMCORDER_INVALID_CONDITION:
107                 ret = CAMERA_ERROR_INVALID_OPERATION;
108                 errorstr = "INVALID_OPERATION";
109                 break;
110         case MM_ERROR_CAMCORDER_RESOURCE_CREATION:
111         case MM_ERROR_COMMON_OUT_OF_MEMORY:
112                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
113                 errorstr = "OUT_OF_MEMORY";
114                 break;
115         case MM_ERROR_POLICY_BLOCKED:
116                 ret = CAMERA_ERROR_SOUND_POLICY;
117                 errorstr = "ERROR_SOUND_POLICY";
118                 break;
119         case MM_ERROR_POLICY_BLOCKED_BY_CALL:
120                 ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
121                 errorstr = "ERROR_SOUND_POLICY_BY_CALL";
122                 break;
123         case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
124                 ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
125                 errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
126                 break;
127         case MM_ERROR_POLICY_RESTRICTED:
128                 ret = CAMERA_ERROR_SECURITY_RESTRICTED;
129                 errorstr = "ERROR_RESTRICTED";
130                 break;
131         case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
132                 ret = CAMERA_ERROR_ESD;
133                 errorstr = "ERROR_ESD";
134                 break;
135         case MM_ERROR_COMMON_INVALID_PERMISSION:
136                 ret = CAMERA_ERROR_PERMISSION_DENIED;
137                 errorstr = "ERROR_PERMISSION_DENIED";
138                 break;
139         case MM_ERROR_COMMON_OUT_OF_ARRAY:
140         case MM_ERROR_COMMON_OUT_OF_RANGE:
141         case MM_ERROR_COMMON_ATTR_NOT_EXIST:
142         case MM_ERROR_CAMCORDER_NOT_SUPPORTED:
143                 ret = CAMERA_ERROR_NOT_SUPPORTED;
144                 errorstr = "ERROR_NOT_SUPPORTED";
145                 break;
146         default:
147                 ret = CAMERA_ERROR_INVALID_OPERATION;
148                 errorstr = "INVALID_OPERATION";
149         }
150
151         if (code != MM_ERROR_NONE)
152                 LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func ? func : "NULL_FUNC", errorstr, ret, code);
153
154         return ret;
155 }
156
157 #ifdef HAVE_WAYLAND
158 static MMCamWaylandInfo *_get_wl_info(Evas_Object *obj)
159 {
160         MMCamWaylandInfo *wl_info = NULL;
161
162         if (obj == NULL) {
163                 LOGE("evas object is NULL");
164                 return NULL;
165         }
166
167         wl_info = g_new0(MMCamWaylandInfo, 1);
168         if (wl_info == NULL) {
169                 LOGE("wl_info alloc failed : %d", sizeof(MMCamWaylandInfo));
170                 return NULL;
171         }
172
173         wl_info->evas_obj = (void *)obj;
174         wl_info->window = (void *)elm_win_wl_window_get(obj);
175         wl_info->surface = (void *)ecore_wl_window_surface_get(wl_info->window);
176         wl_info->display = (void *)ecore_wl_display_get();
177
178         if (wl_info->window == NULL || wl_info->surface == NULL || wl_info->display == NULL) {
179                 LOGE("something is NULL %p, %p, %p", wl_info->window, wl_info->surface, wl_info->display);
180                 g_free(wl_info);
181                 return NULL;
182         }
183
184         evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
185                 &wl_info->window_width, &wl_info->window_height);
186
187         LOGD("wayland obj %p, window %p, surface %p, display %p, size %d,%d,%dx%d",
188              wl_info->evas_obj, wl_info->window, wl_info->surface, wl_info->display,
189              wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
190
191         return wl_info;
192 }
193 #endif /* HAVE_WAYLAND */
194
195 static int _import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
196 {
197         tbm_bo tmp_bo = NULL;
198         tbm_bo_handle tmp_bo_handle = {NULL, };
199
200         if (bufmgr == NULL || bo == NULL || bo_handle == NULL || tbm_key == 0) {
201                 LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, key %d",
202                      bufmgr, bo, bo_handle, tbm_key);
203                 return false;
204         }
205
206         tmp_bo = tbm_bo_import(bufmgr, tbm_key);
207         if (tmp_bo == NULL) {
208                 LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key);
209                 return false;
210         }
211
212         tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
213         if (tmp_bo_handle.ptr == NULL) {
214                 LOGE("bo map failed %p", tmp_bo);
215                 tbm_bo_unref(tmp_bo);
216                 tmp_bo = NULL;
217                 return false;
218         }
219
220         /* set bo and bo_handle */
221         *bo = tmp_bo;
222         *bo_handle = tmp_bo_handle;
223
224         return true;
225 }
226
227 static void _release_imported_bo(tbm_bo *bo)
228 {
229         if (bo == NULL || *bo == NULL) {
230                 LOGW("NULL bo");
231                 return;
232         }
233
234         tbm_bo_unmap(*bo);
235         tbm_bo_unref(*bo);
236         *bo = NULL;
237
238         return;
239 }
240
241 static int _client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
242 {
243         int ret = CAMERA_ERROR_NONE;
244         gint64 end_time;
245
246         LOGD("Enter api : %d", api);
247
248         g_mutex_lock(&(cb_info->api_mutex[api]));
249
250         if (cb_info->api_activating[api] == 0) {
251                 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
252                 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
253                         ret = cb_info->api_ret[api];
254                         cb_info->api_activating[api] = 0;
255
256                         LOGD("return value : 0x%x", ret);
257                 } else {
258                         ret = CAMERA_ERROR_INVALID_OPERATION;
259
260                         LOGE("api %d was TIMED OUT!", api);
261                 }
262         } else {
263                 ret = cb_info->api_ret[api];
264                 cb_info->api_activating[api] = 0;
265
266                 LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);
267         }
268
269         g_mutex_unlock(&(cb_info->api_mutex[api]));
270
271         return ret;
272 }
273
274 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
275 {
276         if (in_format <= MM_PIXEL_FORMAT_INVALID ||
277             in_format >= MM_PIXEL_FORMAT_NUM ||
278             out_format == NULL) {
279                 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
280                 return CAMERA_ERROR_INVALID_PARAMETER;
281         }
282
283         switch (in_format) {
284         case MM_PIXEL_FORMAT_NV12:
285         case MM_PIXEL_FORMAT_NV12T:
286                 *out_format = TBM_FORMAT_NV12;
287                 break;
288         case MM_PIXEL_FORMAT_NV16:
289                 *out_format = TBM_FORMAT_NV16;
290                 break;
291         case MM_PIXEL_FORMAT_NV21:
292                 *out_format = TBM_FORMAT_NV21;
293                 break;
294         case MM_PIXEL_FORMAT_YUYV:
295                 *out_format = TBM_FORMAT_YUYV;
296                 break;
297         case MM_PIXEL_FORMAT_UYVY:
298         case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
299                 *out_format = TBM_FORMAT_UYVY;
300                 break;
301         case MM_PIXEL_FORMAT_422P:
302                 *out_format = TBM_FORMAT_YUV422;
303                 break;
304         case MM_PIXEL_FORMAT_I420:
305                 *out_format = TBM_FORMAT_YUV420;
306                 break;
307         case MM_PIXEL_FORMAT_YV12:
308                 *out_format = TBM_FORMAT_YVU420;
309                 break;
310         case MM_PIXEL_FORMAT_RGB565:
311                 *out_format = TBM_FORMAT_RGB565;
312                 break;
313         case MM_PIXEL_FORMAT_RGB888:
314                 *out_format = TBM_FORMAT_RGB888;
315                 break;
316         case MM_PIXEL_FORMAT_RGBA:
317                 *out_format = TBM_FORMAT_RGBA8888;
318                 break;
319         case MM_PIXEL_FORMAT_ARGB:
320                 *out_format = TBM_FORMAT_ARGB8888;
321                 break;
322         default:
323                 LOGE("invalid in_format %d", in_format);
324                 return CAMERA_ERROR_INVALID_PARAMETER;
325         }
326
327         return CAMERA_ERROR_NONE;
328 }
329
330
331 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
332 {
333         if (in_format <= MM_PIXEL_FORMAT_INVALID ||
334             in_format >= MM_PIXEL_FORMAT_NUM ||
335             mimetype == NULL) {
336                 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
337                 return CAMERA_ERROR_INVALID_PARAMETER;
338         }
339
340         switch (in_format) {
341         case MM_PIXEL_FORMAT_NV12:
342         case MM_PIXEL_FORMAT_NV12T:
343                 *mimetype = MEDIA_FORMAT_NV12;
344                 break;
345         case MM_PIXEL_FORMAT_NV16:
346                 *mimetype = MEDIA_FORMAT_NV16;
347                 break;
348         case MM_PIXEL_FORMAT_NV21:
349                 *mimetype = MEDIA_FORMAT_NV21;
350                 break;
351         case MM_PIXEL_FORMAT_YUYV:
352                 *mimetype = MEDIA_FORMAT_YUYV;
353                 break;
354         case MM_PIXEL_FORMAT_UYVY:
355         case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
356                 *mimetype = MEDIA_FORMAT_UYVY;
357                 break;
358         case MM_PIXEL_FORMAT_422P:
359                 *mimetype = MEDIA_FORMAT_422P;
360                 break;
361         case MM_PIXEL_FORMAT_I420:
362                 *mimetype = MEDIA_FORMAT_I420;
363                 break;
364         case MM_PIXEL_FORMAT_YV12:
365                 *mimetype = MEDIA_FORMAT_YV12;
366                 break;
367         case MM_PIXEL_FORMAT_RGB565:
368                 *mimetype = MEDIA_FORMAT_RGB565;
369                 break;
370         case MM_PIXEL_FORMAT_RGB888:
371                 *mimetype = MEDIA_FORMAT_RGB888;
372                 break;
373         case MM_PIXEL_FORMAT_RGBA:
374                 *mimetype = MEDIA_FORMAT_RGBA;
375                 break;
376         case MM_PIXEL_FORMAT_ARGB:
377                 *mimetype = MEDIA_FORMAT_ARGB;
378                 break;
379         default:
380                 LOGE("invalid in_format %d", in_format);
381                 return CAMERA_ERROR_INVALID_PARAMETER;
382         }
383
384         return CAMERA_ERROR_NONE;
385 }
386
387 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
388 {
389         int i = 0;
390         int ret = 0;
391         camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
392         camera_media_packet_data *mp_data = NULL;
393         tbm_surface_h tsurf = NULL;
394
395         if (pkt == NULL || cb_info == NULL) {
396                 LOGE("invalid parameter buffer %p, cb_info %p", pkt, cb_info);
397                 return MEDIA_PACKET_FINALIZE;
398         }
399
400         ret = media_packet_get_extra(pkt, (void **)&mp_data);
401         if (ret != MEDIA_PACKET_ERROR_NONE) {
402                 LOGE("media_packet_get_extra failed 0x%x", ret);
403                 return MEDIA_PACKET_FINALIZE;
404         }
405
406         /*LOGD("mp_data %p", mp_data);*/
407
408         if (mp_data) {
409                 int tbm_key = mp_data->tbm_key;
410
411                 /* release imported bo */
412                 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
413                         tbm_bo_unref(mp_data->buffer_bo[i]);
414                         mp_data->buffer_bo[i] = NULL;
415                 }
416
417                 /* unmap and unref tbm bo */
418                 _release_imported_bo(&mp_data->bo);
419
420                 /* return buffer */
421                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
422                         cb_info->fd, cb_info, INT, tbm_key);
423                 g_free(mp_data);
424                 mp_data = NULL;
425         }
426
427         ret = media_packet_get_tbm_surface(pkt, &tsurf);
428         if (ret != MEDIA_PACKET_ERROR_NONE) {
429                 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
430                 return MEDIA_PACKET_FINALIZE;
431         }
432
433         if (tsurf) {
434                 tbm_surface_destroy(tsurf);
435                 tsurf = NULL;
436         }
437
438         return MEDIA_PACKET_FINALIZE;
439 }
440
441 static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
442 {
443         int param1 = 0;
444         int param2 = 0;
445         int tbm_key = 0;
446         tbm_bo bo = NULL;
447         tbm_bo_handle bo_handle = {NULL, };
448
449         if (recv_msg == NULL || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
450                 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
451                 return;
452         }
453
454         LOGD("get camera msg %s, event %d", recv_msg, event);
455
456         if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
457                 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
458                         cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
459                         LOGW("all preview callback from user are NULL");
460                         return;
461                 }
462         } else if (cb_info->user_cb[event] == NULL) {
463                 LOGW("user callback for event %d is not set", event);
464                 return;
465         }
466
467         switch (event) {
468         case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
469                 {
470                         int previous = 0;
471                         int current = 0;
472                         int by_policy = 0;
473
474                         muse_camera_msg_get(previous, recv_msg);
475                         muse_camera_msg_get(current, recv_msg);
476                         muse_camera_msg_get(by_policy, recv_msg);
477
478                         LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
479                              previous, current, by_policy);
480
481                         ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
482                                 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
483                 }
484                 break;
485         case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
486                 {
487                         int state = 0;
488
489                         muse_camera_msg_get(state, recv_msg);
490
491                         LOGD("FOCUS state - %d", state);
492
493                         ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
494                 }
495                 break;
496         case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
497                 LOGD("CAPTURE_COMPLETED");
498                 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
499                 break;
500         case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
501         case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
502                 {
503                         camera_preview_data_s frame;
504                         unsigned char *buf_pos = NULL;
505                         MMCamcorderVideoStreamDataType *stream = NULL;
506                         int i = 0;
507                         int total_size = 0;
508                         int num_buffer_key = 0;
509                         int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
510                         tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
511                         tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
512                         camera_media_packet_data *mp_data = NULL;
513
514                         muse_camera_msg_get(tbm_key, recv_msg);
515                         muse_camera_msg_get(num_buffer_key, recv_msg);
516                         muse_camera_msg_get_array(buffer_key, recv_msg);
517
518                         memset(&frame, 0x0, sizeof(camera_preview_data_s));
519
520                         if (tbm_key <= 0) {
521                                 LOGE("invalid key %d", tbm_key);
522                                 break;
523                         }
524
525                         /* import tbm bo and get virtual address */
526                         if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
527                                 LOGE("failed to import key %d", tbm_key);
528
529                                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
530                                         cb_info->fd, cb_info, INT, tbm_key);
531                                 break;
532                         }
533
534                         buf_pos = (unsigned char *)bo_handle.ptr;
535
536                         /* get stream info */
537                         stream = (MMCamcorderVideoStreamDataType *)buf_pos;
538
539                         for (i = 0 ; i < num_buffer_key ; i++) {
540                                 /* import buffer bo and get virtual address */
541                                 if (!_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
542                                         LOGE("failed to import buffer key %d", buffer_key[i]);
543
544                                         /* release imported bo */
545                                         for (i -= 1 ; i >= 0 ; i--)
546                                                 _release_imported_bo(&buffer_bo[i]);
547
548                                         _release_imported_bo(&bo);
549
550                                         /* send return buffer */
551                                         muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
552                                                 cb_info->fd, cb_info, INT, tbm_key);
553                                         return;
554                                 }
555                         }
556
557                         if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
558                                 /* set frame info */
559                                 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
560                                         frame.format  = MM_PIXEL_FORMAT_UYVY;
561                                 else
562                                         frame.format = stream->format;
563                                 frame.width = stream->width;
564                                 frame.height = stream->height;
565                                 frame.timestamp = stream->timestamp;
566                                 frame.num_of_planes = stream->num_planes;
567
568                                 if (num_buffer_key == 0) {
569                                         /* non-zero copy */
570                                         buf_pos += sizeof(MMCamcorderVideoStreamDataType);
571
572                                         if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
573                                                 frame.data.encoded_plane.data = buf_pos;
574                                                 frame.data.encoded_plane.size = stream->data.encoded.length_data;
575                                                 total_size = stream->data.encoded.length_data;
576                                         } else {
577                                                 switch (stream->num_planes) {
578                                                 case 1:
579                                                         frame.data.single_plane.yuv = buf_pos;
580                                                         frame.data.single_plane.size = stream->data.yuv420.length_yuv;
581                                                         total_size = stream->data.yuv420.length_yuv;
582                                                         break;
583                                                 case 2:
584                                                         frame.data.double_plane.y = buf_pos;
585                                                         frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
586                                                         buf_pos += stream->data.yuv420sp.length_y;
587                                                         frame.data.double_plane.uv = buf_pos;
588                                                         frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
589                                                         total_size = stream->data.yuv420sp.length_y + \
590                                                                 stream->data.yuv420sp.length_uv;
591                                                         break;
592                                                 case 3:
593                                                         frame.data.triple_plane.y = buf_pos;
594                                                         frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
595                                                         buf_pos += stream->data.yuv420p.length_y;
596                                                         frame.data.triple_plane.u = buf_pos;
597                                                         frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
598                                                         buf_pos += stream->data.yuv420p.length_u;
599                                                         frame.data.triple_plane.v = buf_pos;
600                                                         frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
601                                                         total_size = stream->data.yuv420p.length_y + \
602                                                                 stream->data.yuv420p.length_u + \
603                                                                 stream->data.yuv420p.length_v;
604                                                         break;
605                                                 default:
606                                                         break;
607                                                 }
608                                         }
609                                 } else {
610                                         /* zero copy */
611                                         switch (stream->num_planes) {
612                                         case 1:
613                                                 frame.data.single_plane.yuv = buffer_bo_handle[0].ptr;
614                                                 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
615                                                 total_size = stream->data.yuv420.length_yuv;
616                                                 break;
617                                         case 2:
618                                                 frame.data.double_plane.y = buffer_bo_handle[0].ptr;
619                                                 if (stream->num_planes == (unsigned int)num_buffer_key)
620                                                         frame.data.double_plane.uv = buffer_bo_handle[1].ptr;
621                                                 else
622                                                         frame.data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
623                                                 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
624                                                 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
625                                                 total_size = stream->data.yuv420sp.length_y + \
626                                                         stream->data.yuv420sp.length_uv;
627                                                 break;
628                                         case 3:
629                                                 frame.data.triple_plane.y = buffer_bo_handle[0].ptr;
630                                                 if (stream->num_planes == (unsigned int)num_buffer_key) {
631                                                         frame.data.triple_plane.u = buffer_bo_handle[1].ptr;
632                                                         frame.data.triple_plane.v = buffer_bo_handle[2].ptr;
633                                                 } else {
634                                                         frame.data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
635                                                         frame.data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
636                                                 }
637                                                 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
638                                                 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
639                                                 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
640                                                 total_size = stream->data.yuv420p.length_y + \
641                                                         stream->data.yuv420p.length_u + \
642                                                         stream->data.yuv420p.length_v;
643                                                 break;
644                                         default:
645                                                 break;
646                                         }
647                                 }
648
649                                 /*
650                                 LOGD("PREVIEW_CB - format %d, %dx%d, size %d plane num %d",
651                                      frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
652                                 */
653
654                                 ((camera_preview_cb)cb_info->user_cb[event])(&frame, cb_info->user_data[event]);
655
656                                 /*LOGD("PREVIEW_CB retuned");*/
657                         }
658
659                         if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
660                                 media_packet_h pkt = NULL;
661                                 tbm_surface_h tsurf = NULL;
662                                 uint32_t bo_format = 0;
663                                 int ret = 0;
664                                 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
665                                 bool make_pkt_fmt = false;
666                                 tbm_surface_info_s tsurf_info;
667
668                                 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
669
670                                 /* unmap buffer bo */
671                                 for (i = 0 ; i < num_buffer_key ; i++) {
672                                         if (buffer_bo[i])
673                                                 tbm_bo_unmap(buffer_bo[i]);
674                                 }
675
676                                 /* create tbm surface */
677                                 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
678                                         tsurf_info.planes[i].stride = stream->stride[i];
679
680                                 /* get tbm surface format */
681                                 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
682                                 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
683
684                                 if (num_buffer_key > 0 && ret == CAMERA_ERROR_NONE) {
685                                         tsurf_info.width = stream->width;
686                                         tsurf_info.height = stream->height;
687                                         tsurf_info.format = bo_format;
688                                         tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
689                                         tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
690
691                                         switch (bo_format) {
692                                         case TBM_FORMAT_NV12:
693                                         case TBM_FORMAT_NV21:
694                                                 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
695                                                 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
696                                                 tsurf_info.planes[0].offset = 0;
697                                                 if (num_buffer_key == 1)
698                                                         tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
699                                                 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
700                                                 break;
701                                         case TBM_FORMAT_YUV420:
702                                         case TBM_FORMAT_YVU420:
703                                                 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
704                                                 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
705                                                 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
706                                                 tsurf_info.planes[0].offset = 0;
707                                                 if (num_buffer_key == 1) {
708                                                         tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
709                                                         tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
710                                                 }
711                                                 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
712                                                 break;
713                                         case TBM_FORMAT_UYVY:
714                                         case TBM_FORMAT_YUYV:
715                                                 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
716                                                 tsurf_info.planes[0].offset = 0;
717                                                 tsurf_info.size = tsurf_info.planes[0].size;
718                                                 break;
719                                         default:
720                                                 break;
721                                         }
722
723                                         tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
724                                         /*LOGD("tbm surface %p", tsurf);*/
725                                 }
726
727                                 if (tsurf) {
728                                         /* check media packet format */
729                                         if (cb_info->pkt_fmt) {
730                                                 int pkt_fmt_width = 0;
731                                                 int pkt_fmt_height = 0;
732                                                 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
733
734                                                 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
735                                                 if (pkt_fmt_mimetype != mimetype ||
736                                                     pkt_fmt_width != stream->width ||
737                                                     pkt_fmt_height != stream->height) {
738                                                         LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
739                                                              pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
740                                                         media_format_unref(cb_info->pkt_fmt);
741                                                         cb_info->pkt_fmt = NULL;
742                                                         make_pkt_fmt = true;
743                                                 }
744                                         } else {
745                                                 make_pkt_fmt = true;
746                                         }
747
748                                         /* create packet format */
749                                         if (make_pkt_fmt) {
750                                                 LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
751                                                 ret = media_format_create(&cb_info->pkt_fmt);
752                                                 if (ret == MEDIA_FORMAT_ERROR_NONE) {
753                                                         ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
754                                                         ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
755                                                         ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
756                                                         LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
757                                                 } else {
758                                                         LOGW("media_format_create failed");
759                                                 }
760                                         }
761
762                                         /* create media packet */
763                                         ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
764                                                 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
765                                                 (void *)cb_info, &pkt);
766                                         if (ret != MEDIA_PACKET_ERROR_NONE) {
767                                                 LOGE("media_packet_create_from_tbm_surface failed");
768
769                                                 tbm_surface_destroy(tsurf);
770                                                 tsurf = NULL;
771                                         }
772                                 } else {
773                                         LOGE("failed to create tbm surface %dx%d, format %d, num_buffer_key %d",
774                                              stream->width, stream->height, stream->format, num_buffer_key);
775                                 }
776
777                                 if (pkt) {
778                                         /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
779
780                                         mp_data = g_new0(camera_media_packet_data, 1);
781                                         if (mp_data) {
782                                                 mp_data->tbm_key = tbm_key;
783                                                 mp_data->num_buffer_key = num_buffer_key;
784                                                 mp_data->bo = bo;
785                                                 for (i = 0 ; i < num_buffer_key ; i++)
786                                                         mp_data->buffer_bo[i] = buffer_bo[i];
787
788                                                 /* set media packet data */
789                                                 ret = media_packet_set_extra(pkt, (void *)mp_data);
790                                                 if (ret != MEDIA_PACKET_ERROR_NONE) {
791                                                         LOGE("media_packet_set_extra failed");
792
793                                                         if (mp_data) {
794                                                                 g_free(mp_data);
795                                                                 mp_data = NULL;
796                                                         }
797
798                                                         media_packet_destroy(pkt);
799                                                         pkt = NULL;
800                                                 } else {
801                                                         int e_type = MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW;
802
803                                                         /* set timestamp : msec -> nsec */
804                                                         if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
805                                                                 LOGW("media_packet_set_pts failed");
806
807                                                         /* call media packet callback */
808                                                         ((camera_media_packet_preview_cb)cb_info->user_cb[e_type])(pkt, cb_info->user_data[e_type]);
809                                                 }
810                                         } else {
811                                                 LOGE("failed to alloc media packet data");
812                                         }
813                                 }
814                         }
815
816                         /* send message for preview callback return */
817                         muse_camera_msg_send_no_return(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info->fd, cb_info);
818
819                         if (mp_data == NULL) {
820                                 /* release imported bo */
821                                 for (i = 0 ; i < num_buffer_key ; i++)
822                                         _release_imported_bo(&buffer_bo[i]);
823
824                                 /* unmap and unref tbm bo */
825                                 _release_imported_bo(&bo);
826
827                                 /* return buffer */
828                                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
829                                         cb_info->fd, cb_info, INT, tbm_key);
830
831                                 /*LOGD("return buffer Done");*/
832                         }
833                 }
834                 break;
835         case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
836                 {
837                         int percent = 0;
838
839                         muse_camera_msg_get(percent, recv_msg);
840
841                         LOGD("HDR progress - %d \%", percent);
842
843                         ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
844                 }
845                 break;
846         case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
847                 {
848                         int policy = 0;
849                         int previous = 0;
850                         int current = 0;
851
852                         muse_camera_msg_get(policy, recv_msg);
853                         muse_camera_msg_get(previous, recv_msg);
854                         muse_camera_msg_get(current, recv_msg);
855
856                         LOGD("INTERRUPTED - policy %d, state previous %d, current %d",
857                              policy, previous, current);
858
859                         ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
860                                 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
861                 }
862                 break;
863         case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
864                 {
865                         int count = 0;
866                         camera_detected_face_s *faces = NULL;
867
868                         muse_camera_msg_get(count, recv_msg);
869                         muse_camera_msg_get(tbm_key, recv_msg);
870
871                         if (count > 0 && tbm_key > 0) {
872                                 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
873
874                                 if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
875                                         break;
876
877                                 /* set face info */
878                                 faces = bo_handle.ptr;
879
880                                 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
881
882 #if 0
883                                 {
884                                         int i = 0;
885
886                                         for (i = 0 ; i < count ; i++) {
887                                                 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
888                                                      i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
889                                         }
890                                 }
891 #endif
892
893                                 /* release bo */
894                                 _release_imported_bo(&bo);
895
896                                 /* return buffer */
897                                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
898                                         cb_info->fd, cb_info, INT, tbm_key);
899
900                                 LOGD("return buffer done");
901                         } else {
902                                 LOGE("invalid message - count %d, key %d", count, tbm_key);
903                         }
904                 }
905                 break;
906         case MUSE_CAMERA_EVENT_TYPE_ERROR:
907                 {
908                         int error = 0;
909                         int current_state = 0;
910
911                         muse_camera_msg_get(error, recv_msg);
912                         muse_camera_msg_get(current_state, recv_msg);
913
914                         LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
915
916                         ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
917                                 (camera_state_e)current_state, cb_info->user_data[event]);
918                 }
919                 break;
920         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
921                 muse_camera_msg_get(param1, recv_msg);
922                 muse_camera_msg_get(param2, recv_msg);
923
924                 LOGD("SUPPORTED_PREVIEW_RESOLUTION - %d x %d", param1, param2);
925
926                 if (((camera_supported_preview_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
927                         cb_info->user_cb[event] = NULL;
928                         cb_info->user_data[event] = NULL;
929                         LOGD("stop foreach callback for SUPPORTED_PREVIEW_RESOLUTION");
930                 }
931                 break;
932         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
933                 muse_camera_msg_get(param1, recv_msg);
934                 muse_camera_msg_get(param2, recv_msg);
935
936                 LOGD("SUPPORTED_CAPTURE_RESOLUTION - %d x %d", param1, param2);
937
938                 if (((camera_supported_capture_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
939                         cb_info->user_cb[event] = NULL;
940                         cb_info->user_data[event] = NULL;
941                         LOGD("stop foreach callback for SUPPORTED_CAPTURE_RESOLUTION");
942                 }
943                 break;
944         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
945                 muse_camera_msg_get(param1, recv_msg);
946
947                 LOGD("SUPPORTED_CAPTURE_FORMAT - %d ", param1);
948
949                 if (((camera_supported_capture_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) {
950                         cb_info->user_cb[event] = NULL;
951                         cb_info->user_data[event] = NULL;
952                         LOGD("stop foreach callback for SUPPORTED_CAPTURE_FORMAT");
953                 }
954                 break;
955         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
956                 muse_camera_msg_get(param1, recv_msg);
957
958                 LOGD("SUPPORTED_PREVIEW_FORMAT - %d ", param1);
959
960                 if (((camera_supported_preview_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) {
961                         cb_info->user_cb[event] = NULL;
962                         cb_info->user_data[event] = NULL;
963                         LOGD("stop foreach callback for SUPPORTED_PREVIEW_FORMAT");
964                 }
965                 break;
966         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
967                 muse_camera_msg_get(param1, recv_msg);
968
969                 LOGD("SUPPORTED_AF_MODE - %d ", param1);
970
971                 if (((camera_attr_supported_af_mode_cb)cb_info->user_cb[event])((camera_attr_af_mode_e)param1, cb_info->user_data[event]) == false) {
972                         cb_info->user_cb[event] = NULL;
973                         cb_info->user_data[event] = NULL;
974                         LOGD("stop foreach callback for SUPPORTED_AF_MODE");
975                 }
976                 break;
977         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
978                 muse_camera_msg_get(param1, recv_msg);
979
980                 LOGD("SUPPORTED_EXPOSURE_MODE - %d ", param1);
981
982                 if (((camera_attr_supported_exposure_mode_cb)cb_info->user_cb[event])((camera_attr_exposure_mode_e)param1, cb_info->user_data[event]) == false) {
983                         cb_info->user_cb[event] = NULL;
984                         cb_info->user_data[event] = NULL;
985                         LOGD("stop foreach callback for SUPPORTED_EXPOSURE_MODE");
986                 }
987                 break;
988         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
989                 muse_camera_msg_get(param1, recv_msg);
990
991                 LOGD("SUPPORTED_ISO - %d ", param1);
992
993                 if (((camera_attr_supported_iso_cb)cb_info->user_cb[event])((camera_attr_iso_e)param1, cb_info->user_data[event]) == false) {
994                         cb_info->user_cb[event] = NULL;
995                         cb_info->user_data[event] = NULL;
996                         LOGD("stop foreach callback for SUPPORTED_ISO");
997                 }
998                 break;
999         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1000                 muse_camera_msg_get(param1, recv_msg);
1001
1002                 LOGD("SUPPORTED_WHITEBALANCE - %d ", param1);
1003
1004                 if (((camera_attr_supported_whitebalance_cb)cb_info->user_cb[event])((camera_attr_whitebalance_e)param1, cb_info->user_data[event]) == false) {
1005                         cb_info->user_cb[event] = NULL;
1006                         cb_info->user_data[event] = NULL;
1007                         LOGD("stop foreach callback for SUPPORTED_WHITEBALANCE");
1008                 }
1009                 break;
1010         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1011                 muse_camera_msg_get(param1, recv_msg);
1012
1013                 LOGD("SUPPORTED_EFFECT - %d ", param1);
1014
1015                 if (((camera_attr_supported_effect_cb)cb_info->user_cb[event])((camera_attr_effect_mode_e)param1, cb_info->user_data[event]) == false) {
1016                         cb_info->user_cb[event] = NULL;
1017                         cb_info->user_data[event] = NULL;
1018                         LOGD("stop foreach callback for SUPPORTED_EFFECT");
1019                 }
1020                 break;
1021         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1022                 muse_camera_msg_get(param1, recv_msg);
1023
1024                 LOGD("SUPPORTED_SCENE_MODE - %d ", param1);
1025
1026                 if (((camera_attr_supported_scene_mode_cb)cb_info->user_cb[event])((camera_attr_scene_mode_e)param1, cb_info->user_data[event]) == false) {
1027                         cb_info->user_cb[event] = NULL;
1028                         cb_info->user_data[event] = NULL;
1029                         LOGD("stop foreach callback for SUPPORTED_SCENE_MODE");
1030                 }
1031                 break;
1032         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1033                 muse_camera_msg_get(param1, recv_msg);
1034
1035                 LOGD("SUPPORTED_FLASH_MODE - %d ", param1);
1036
1037                 if (((camera_attr_supported_flash_mode_cb)cb_info->user_cb[event])((camera_attr_flash_mode_e)param1, cb_info->user_data[event]) == false) {
1038                         cb_info->user_cb[event] = NULL;
1039                         cb_info->user_data[event] = NULL;
1040                         LOGD("stop foreach callback for SUPPORTED_FLASH_MODE");
1041                 }
1042                 break;
1043         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1044                 muse_camera_msg_get(param1, recv_msg);
1045
1046                 LOGD("SUPPORTED_FPS - %d ", param1);
1047
1048                 if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) {
1049                         cb_info->user_cb[event] = NULL;
1050                         cb_info->user_data[event] = NULL;
1051                         LOGD("stop foreach callback for SUPPORTED_FPS");
1052                 }
1053                 break;
1054         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1055                 muse_camera_msg_get(param1, recv_msg);
1056
1057                 LOGD("SUPPORTED_FPS_BY_RESOLUTION - %d ", param1);
1058
1059                 if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) {
1060                         cb_info->user_cb[event] = NULL;
1061                         cb_info->user_data[event] = NULL;
1062                         LOGD("stop foreach callback for SUPPORTED_FPS_BY_RESOLUTION");
1063                 }
1064                 break;
1065         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1066                 muse_camera_msg_get(param1, recv_msg);
1067
1068                 LOGD("SUPPORTED_STREAM_FLIP - %d ", param1);
1069
1070                 if (((camera_attr_supported_stream_flip_cb)cb_info->user_cb[event])((camera_flip_e)param1, cb_info->user_data[event]) == false) {
1071                         cb_info->user_cb[event] = NULL;
1072                         cb_info->user_data[event] = NULL;
1073                         LOGD("stop foreach callback for SUPPORTED_STREAM_FLIP");
1074                 }
1075                 break;
1076         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1077                 muse_camera_msg_get(param1, recv_msg);
1078
1079                 LOGD("SUPPORTED_STREAM_ROTATION - %d ", param1);
1080
1081                 if (((camera_attr_supported_stream_rotation_cb)cb_info->user_cb[event])((camera_rotation_e)param1, cb_info->user_data[event]) == false) {
1082                         cb_info->user_cb[event] = NULL;
1083                         cb_info->user_data[event] = NULL;
1084                         LOGD("stop foreach callback for SUPPORTED_STREAM_ROTATION");
1085                 }
1086                 break;
1087         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1088                 muse_camera_msg_get(param1, recv_msg);
1089
1090                 LOGD("SUPPORTED_THEATER_MODE - %d ", param1);
1091
1092                 if (((camera_attr_supported_theater_mode_cb)cb_info->user_cb[event])((camera_attr_theater_mode_e)param1, cb_info->user_data[event]) == false) {
1093                         cb_info->user_cb[event] = NULL;
1094                         cb_info->user_data[event] = NULL;
1095                         LOGD("stop foreach callback for SUPPORTED_THEATER_MODE");
1096                 }
1097                 break;
1098         case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1099                 {
1100                         camera_image_data_s *rImage = NULL;
1101                         camera_image_data_s *rPostview = NULL;
1102                         camera_image_data_s *rThumbnail = NULL;
1103                         unsigned char *buf_pos = NULL;
1104                         int is_postview = 0;
1105                         int is_thumbnail = 0;
1106
1107                         muse_camera_msg_get(tbm_key, recv_msg);
1108                         muse_camera_msg_get(is_postview, recv_msg);
1109                         muse_camera_msg_get(is_thumbnail, recv_msg);
1110
1111                         LOGD("camera capture callback came in. key %d, postview %d, thumbnail %d",
1112                              tbm_key, is_postview, is_thumbnail);
1113
1114                         if (tbm_key <= 0) {
1115                                 LOGE("invalid key %d", tbm_key);
1116                                 break;
1117                         }
1118
1119                         /* import tbm bo and get virtual address */
1120                         if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1121                                 break;
1122
1123                         buf_pos = (unsigned char *)bo_handle.ptr;
1124                         rImage = (camera_image_data_s *)buf_pos;
1125                         rImage->data = buf_pos + sizeof(camera_image_data_s);
1126                         buf_pos += sizeof(camera_image_data_s) + rImage->size;
1127
1128                         if (is_postview) {
1129                                 rPostview = (camera_image_data_s *)buf_pos;
1130                                 LOGD("rPostview->size : %d", rPostview->size);
1131                                 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1132                                 buf_pos += sizeof(camera_image_data_s) + rPostview->size;
1133                         }
1134
1135                         if (is_thumbnail) {
1136                                 rThumbnail = (camera_image_data_s *)buf_pos;
1137                                 LOGD("rThumbnail->size : %d", rThumbnail->size);
1138                                 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1139                                 buf_pos += sizeof(camera_image_data_s) + rThumbnail->size;
1140                         }
1141
1142                         LOGD("image info %dx%d, size : %d", rImage->height, rImage->width, rImage->size);
1143
1144                         ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1145
1146                         /* unmap and unref tbm bo */
1147                         _release_imported_bo(&bo);
1148
1149                         /* return buffer */
1150                         muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
1151                                 cb_info->fd, cb_info, INT, tbm_key);
1152
1153                         LOGD("return buffer done");
1154                 }
1155                 break;
1156         case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
1157                 break;
1158         default:
1159                 LOGW("Unknown event : %d", event);
1160                 break;
1161         }
1162
1163         return;
1164 }
1165
1166 static bool _camera_idle_event_callback(void *data)
1167 {
1168         camera_cb_info_s *cb_info = NULL;
1169         camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1170
1171         if (cam_idle_event == NULL) {
1172                 LOGE("cam_idle_event is NULL");
1173                 return false;
1174         }
1175
1176         /* lock event */
1177         g_mutex_lock(&cam_idle_event->event_mutex);
1178
1179         cb_info = cam_idle_event->cb_info;
1180         if (cb_info == NULL) {
1181                 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1182                 goto IDLE_EVENT_CALLBACK_DONE;
1183         }
1184
1185         /* remove event from list */
1186         g_mutex_lock(&cb_info->idle_event_mutex);
1187         if (cb_info->idle_event_list)
1188                 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1189
1190         /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1191         g_mutex_unlock(&cb_info->idle_event_mutex);
1192
1193         /* user callback */
1194         _client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1195
1196         /* send signal for waiting thread */
1197         g_cond_signal(&cb_info->idle_event_cond);
1198
1199 IDLE_EVENT_CALLBACK_DONE:
1200         /* unlock and release event */
1201         g_mutex_unlock(&cam_idle_event->event_mutex);
1202         g_mutex_clear(&cam_idle_event->event_mutex);
1203
1204         free(cam_idle_event);
1205         cam_idle_event = NULL;
1206
1207         return false;
1208 }
1209
1210 static void *_camera_msg_handler_func(gpointer data)
1211 {
1212         int ret = 0;
1213         int api = 0;
1214         int event = 0;
1215         int event_class = 0;
1216         camera_message_s *cam_msg = NULL;
1217         camera_idle_event_s *cam_idle_event = NULL;
1218         camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1219
1220         if (cb_info == NULL) {
1221                 LOGE("cb_info NULL");
1222                 return NULL;
1223         }
1224
1225         LOGD("start");
1226
1227         g_mutex_lock(&cb_info->msg_handler_mutex);
1228
1229         while (g_atomic_int_get(&cb_info->msg_handler_running)) {
1230                 if (g_queue_is_empty(cb_info->msg_queue)) {
1231                         LOGD("signal wait...");
1232                         g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex);
1233                         LOGD("signal received");
1234
1235                         if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) {
1236                                 LOGD("stop event thread");
1237                                 break;
1238                         }
1239                 }
1240
1241                 cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
1242
1243                 g_mutex_unlock(&cb_info->msg_handler_mutex);
1244
1245                 if (cam_msg == NULL) {
1246                         LOGE("NULL message");
1247                         g_mutex_lock(&cb_info->msg_handler_mutex);
1248                         continue;
1249                 }
1250
1251                 api = cam_msg->api;
1252
1253                 if (api < MUSE_CAMERA_API_MAX) {
1254                         g_mutex_lock(&cb_info->api_mutex[api]);
1255
1256                         if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1257                                 cb_info->api_ret[api] = ret;
1258                                 cb_info->api_activating[api] = 1;
1259
1260                                 LOGD("camera api %d - return 0x%x", ret);
1261
1262                                 g_cond_signal(&cb_info->api_cond[api]);
1263                         } else {
1264                                 LOGE("failed to get camera ret for api %d, msg %s", api, cam_msg->recv_msg);
1265                         }
1266
1267                         g_mutex_unlock(&cb_info->api_mutex[api]);
1268                 } else if (api == MUSE_CAMERA_CB_EVENT) {
1269                         event = -1;
1270                         event_class = -1;
1271
1272                         if (!muse_camera_msg_get(event, cam_msg->recv_msg) ||
1273                             !muse_camera_msg_get(event_class, cam_msg->recv_msg)) {
1274                                 LOGE("failed to get camera event %d, class %d", event, event_class);
1275
1276                                 g_free(cam_msg);
1277                                 cam_msg = NULL;
1278
1279                                 g_mutex_lock(&cb_info->msg_handler_mutex);
1280                                 continue;
1281                         }
1282
1283                         switch (event_class) {
1284                         case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1285                                 _client_user_callback(cb_info, cam_msg->recv_msg, event);
1286                                 break;
1287                         case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1288                                 cam_idle_event = (camera_idle_event_s *)malloc(sizeof(camera_idle_event_s));
1289                                 if (cam_idle_event == NULL) {
1290                                         LOGE("cam_idle_event alloc failed");
1291                                         break;
1292                                 }
1293
1294                                 cam_idle_event->event = event;
1295                                 cam_idle_event->cb_info = cb_info;
1296                                 g_mutex_init(&cam_idle_event->event_mutex);
1297                                 memcpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1298
1299                                 LOGD("add camera event[%d, %p] to IDLE", event, cam_idle_event);
1300
1301                                 g_mutex_lock(&cb_info->idle_event_mutex);
1302                                 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1303                                 g_mutex_unlock(&cb_info->idle_event_mutex);
1304
1305                                 g_idle_add_full(G_PRIORITY_DEFAULT,
1306                                         (GSourceFunc)_camera_idle_event_callback,
1307                                         (gpointer)cam_idle_event,
1308                                         NULL);
1309                                 break;
1310                         default:
1311                                 LOGE("unknown camera event class %d", event_class);
1312                                 break;
1313                         }
1314                 } else {
1315                         LOGE("unknown camera api[%d] message[%s]", api, cam_msg->recv_msg);
1316                 }
1317
1318                 free(cam_msg);
1319                 cam_msg = NULL;
1320
1321                 g_mutex_lock(&cb_info->msg_handler_mutex);
1322         }
1323
1324         /* remove remained event */
1325         while (!g_queue_is_empty(cb_info->msg_queue)) {
1326                 cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
1327                 if (cam_msg) {
1328                         LOGD("remove camera message %p", cam_msg);
1329                         free(cam_msg);
1330                         cam_msg = NULL;
1331                 } else {
1332                         LOGW("NULL camera message");
1333                 }
1334         }
1335
1336         g_mutex_unlock(&cb_info->msg_handler_mutex);
1337
1338         LOGD("return");
1339
1340         return NULL;
1341 }
1342
1343 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1344 {
1345         camera_idle_event_s *cam_idle_event = NULL;
1346         gboolean ret = TRUE;
1347         GList *list = NULL;
1348         gint64 end_time = 0;
1349
1350         if (cb_info == NULL) {
1351                 LOGE("cb_info is NULL");
1352                 return;
1353         }
1354
1355         g_mutex_lock(&cb_info->idle_event_mutex);
1356
1357         if (cb_info->idle_event_list == NULL) {
1358                 LOGD("No idle event is remained.");
1359         } else {
1360                 list = cb_info->idle_event_list;
1361
1362                 while (list) {
1363                         cam_idle_event = list->data;
1364                         list = g_list_next(list);
1365
1366                         if (!cam_idle_event) {
1367                                 LOGW("Fail to remove idle event. The event is NULL");
1368                         } else {
1369                                 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1370                                         ret = g_idle_remove_by_data(cam_idle_event);
1371
1372                                         LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1373
1374                                         if (ret == FALSE) {
1375                                                 cam_idle_event->cb_info = NULL;
1376                                                 LOGW("idle callback for event %p will be called later", cam_idle_event);
1377                                         }
1378
1379                                         cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1380
1381                                         g_mutex_unlock(&cam_idle_event->event_mutex);
1382
1383                                         if (ret == TRUE) {
1384                                                 g_mutex_clear(&cam_idle_event->event_mutex);
1385
1386                                                 free(cam_idle_event);
1387                                                 cam_idle_event = NULL;
1388
1389                                                 LOGD("remove idle event done");
1390                                         }
1391                                 } else {
1392                                         LOGW("event lock failed. it's being called...");
1393
1394                                         end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1395
1396                                         if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1397                                                 LOGW("signal received");
1398                                         else
1399                                                 LOGW("timeout");
1400                                 }
1401                         }
1402                 }
1403
1404                 g_list_free(cb_info->idle_event_list);
1405                 cb_info->idle_event_list = NULL;
1406         }
1407
1408         g_mutex_unlock(&cb_info->idle_event_mutex);
1409
1410         return;
1411 }
1412
1413 static void *_camera_msg_recv_func(gpointer data)
1414 {
1415         int i = 0;
1416         int ret = 0;
1417         int api = 0;
1418         int api_class = 0;
1419         int num_token = 0;
1420         int str_pos = 0;
1421         int prev_pos = 0;
1422         char *recv_msg = NULL;
1423         char **parse_str = NULL;
1424         camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1425
1426         if (cb_info == NULL) {
1427                 LOGE("cb_info NULL");
1428                 return NULL;
1429         }
1430
1431         LOGD("start");
1432
1433         parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE);
1434         if (parse_str == NULL) {
1435                 LOGE("parse_str malloc failed");
1436                 return NULL;
1437         }
1438
1439         for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1440                 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1441                 if (parse_str[i] == NULL) {
1442                         LOGE("parse_str[%d] malloc failed", i);
1443                         goto CB_HANDLER_EXIT;
1444                 }
1445         }
1446
1447         recv_msg = cb_info->recv_msg;
1448
1449         while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1450                 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1451                 if (ret <= 0)
1452                         break;
1453                 recv_msg[ret] = '\0';
1454
1455                 str_pos = 0;
1456                 prev_pos = 0;
1457                 num_token = 0;
1458
1459                 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
1460
1461                 /* Need to split the combined entering msgs.
1462                     This module supports up to 200 combined msgs. */
1463                 for (str_pos = 0; str_pos < ret; str_pos++) {
1464                         if (recv_msg[str_pos] == '}') {
1465                                 memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1466                                 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
1467                                 LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);
1468                                 prev_pos = str_pos+1;
1469                                 num_token++;
1470                         }
1471                 }
1472
1473                 /*LOGD("num_token : %d", num_token);*/
1474
1475                 /* Re-construct to the useful single msg. */
1476                 for (i = 0; i < num_token; i++) {
1477                         if (i >= CAMERA_PARSE_STRING_SIZE) {
1478                                 LOGE("invalid token index %d", i);
1479                                 break;
1480                         }
1481
1482                         api = -1;
1483                         api_class = -1;
1484
1485                         if (!muse_camera_msg_get(api, parse_str[i])) {
1486                                 LOGE("failed to get camera api");
1487                                 continue;
1488                         }
1489
1490                         if (muse_camera_msg_get(api_class, parse_str[i]))
1491                                 LOGD("camera api_class[%d]", api_class);
1492
1493                         if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1494                                 g_mutex_lock(&cb_info->api_mutex[api]);
1495
1496                                 if (!muse_camera_msg_get(ret, parse_str[i])) {
1497                                         LOGE("failed to get camera ret");
1498                                         g_mutex_unlock(&cb_info->api_mutex[api]);
1499                                         continue;
1500                                 }
1501
1502                                 cb_info->api_ret[api] = ret;
1503                                 cb_info->api_activating[api] = 1;
1504
1505                                 if (api == MUSE_CAMERA_API_CREATE) {
1506                                         if (ret != CAMERA_ERROR_NONE) {
1507                                                 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1508                                                 LOGE("camera create error 0x%x. close client cb handler", ret);
1509                                         }
1510                                 } else if (api == MUSE_CAMERA_API_DESTROY) {
1511                                         if (ret == CAMERA_ERROR_NONE) {
1512                                                 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1513                                                 LOGD("camera destroy done. close client cb handler");
1514                                         }
1515                                 } else if (api == MUSE_CAMERA_API_START_PREVIEW) {
1516                                         int prev_state = CAMERA_STATE_NONE;
1517                                         gchar caps[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
1518
1519                                         muse_camera_msg_get(prev_state, parse_str[i]);
1520
1521                                         cb_info->prev_state = prev_state;
1522                                         if (prev_state == CAMERA_STATE_CREATED) {
1523                                                 if (cb_info->caps) {
1524                                                         g_free(cb_info->caps);
1525                                                         cb_info->caps = NULL;
1526                                                 }
1527
1528                                                 muse_camera_msg_get(caps, parse_str[i]);
1529                                                 if (strlen(caps) > 0) {
1530                                                         cb_info->caps = g_strdup(caps);
1531                                                         if (cb_info->caps) {
1532                                                                 LOGD("caps from server [%s]", cb_info->caps);
1533                                                         } else {
1534                                                                 LOGE("failed to copy caps string");
1535                                                         }
1536                                                 } else {
1537                                                         LOGE("no string for caps");
1538                                                 }
1539                                         }
1540                                 }
1541
1542                                 g_cond_signal(&cb_info->api_cond[api]);
1543                                 g_mutex_unlock(&cb_info->api_mutex[api]);
1544                         } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1545                                 camera_message_s *cam_msg = g_new0(camera_message_s, 1);
1546                                 if (cam_msg == NULL) {
1547                                         LOGE("failed to alloc cam_msg");
1548                                         continue;
1549                                 }
1550
1551                                 cam_msg->api = api;
1552                                 memcpy(cam_msg->recv_msg, parse_str[i], sizeof(cam_msg->recv_msg));
1553
1554                                 LOGD("add camera message to queue : api %d", api);
1555
1556                                 g_mutex_lock(&cb_info->msg_handler_mutex);
1557                                 g_queue_push_tail(cb_info->msg_queue, (gpointer)cam_msg);
1558                                 g_cond_signal(&cb_info->msg_handler_cond);
1559                                 g_mutex_unlock(&cb_info->msg_handler_mutex);
1560                         } else {
1561                                 LOGW("unknown camera api %d and api_class %d", api, api_class);
1562                         }
1563                 }
1564
1565         }
1566
1567         LOGD("client cb exit");
1568
1569 CB_HANDLER_EXIT:
1570         if (parse_str) {
1571                 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1572                         if (parse_str[i]) {
1573                                 free(parse_str[i]);
1574                                 parse_str[i] = NULL;
1575                         }
1576                 }
1577
1578                 free(parse_str);
1579                 parse_str = NULL;
1580         }
1581
1582         return NULL;
1583 }
1584
1585 static camera_cb_info_s *_client_callback_new(gint sockfd)
1586 {
1587         camera_cb_info_s *cb_info = NULL;
1588         gint *tmp_activating = NULL;
1589         gint *tmp_ret = NULL;
1590         gint i = 0;
1591
1592         g_return_val_if_fail(sockfd > 0, NULL);
1593
1594         cb_info = g_new0(camera_cb_info_s, 1);
1595         if (cb_info == NULL) {
1596                 LOGE("cb_info failed");
1597                 goto ErrorExit;
1598         }
1599
1600         g_mutex_init(&cb_info->msg_handler_mutex);
1601         g_cond_init(&cb_info->msg_handler_cond);
1602         g_mutex_init(&cb_info->idle_event_mutex);
1603         g_cond_init(&cb_info->idle_event_cond);
1604
1605         for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1606                 g_mutex_init(&cb_info->api_mutex[i]);
1607                 g_cond_init(&cb_info->api_cond[i]);
1608         }
1609
1610         tmp_activating = g_new0(gint, MUSE_CAMERA_API_MAX);
1611         if (tmp_activating == NULL) {
1612                 LOGE("tmp_activating failed");
1613                 goto ErrorExit;
1614         }
1615
1616         tmp_ret = g_new0(gint, MUSE_CAMERA_API_MAX);
1617         if (tmp_ret == NULL) {
1618                 LOGE("tmp_ret failed");
1619                 goto ErrorExit;
1620         }
1621
1622         cb_info->msg_queue = g_queue_new();
1623         if (cb_info->msg_queue == NULL) {
1624                 LOGE("msg_queue new failed");
1625                 goto ErrorExit;
1626         }
1627
1628         g_atomic_int_set(&cb_info->msg_handler_running, 1);
1629         cb_info->msg_handler_thread = g_thread_try_new("camera_msg_handler",
1630                 _camera_msg_handler_func, (gpointer)cb_info, NULL);
1631         if (cb_info->msg_handler_thread == NULL) {
1632                 LOGE("message handler thread creation failed");
1633                 goto ErrorExit;
1634         }
1635
1636         cb_info->fd = sockfd;
1637         cb_info->api_activating = tmp_activating;
1638         cb_info->api_ret = tmp_ret;
1639
1640         g_atomic_int_set(&cb_info->msg_recv_running, 1);
1641         cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
1642                 _camera_msg_recv_func, (gpointer)cb_info, NULL);
1643         if (cb_info->msg_recv_thread == NULL) {
1644                 LOGE("message receive thread creation failed");
1645                 goto ErrorExit;
1646         }
1647
1648         return cb_info;
1649
1650 ErrorExit:
1651         if (cb_info) {
1652                 if (cb_info->msg_handler_thread) {
1653                         g_mutex_lock(&cb_info->msg_handler_mutex);
1654                         g_atomic_int_set(&cb_info->msg_handler_running, 0);
1655                         g_cond_signal(&cb_info->msg_handler_cond);
1656                         g_mutex_unlock(&cb_info->msg_handler_mutex);
1657
1658                         g_thread_join(cb_info->msg_handler_thread);
1659                         g_thread_unref(cb_info->msg_handler_thread);
1660                         cb_info->msg_handler_thread = NULL;
1661                 }
1662
1663                 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1664                         g_mutex_clear(&cb_info->api_mutex[i]);
1665                         g_cond_clear(&cb_info->api_cond[i]);
1666                 }
1667
1668                 g_mutex_clear(&cb_info->msg_handler_mutex);
1669                 g_cond_clear(&cb_info->msg_handler_cond);
1670                 g_mutex_clear(&cb_info->idle_event_mutex);
1671                 g_cond_clear(&cb_info->idle_event_cond);
1672
1673                 if (cb_info->msg_queue) {
1674                         g_queue_free(cb_info->msg_queue);
1675                         cb_info->msg_queue = NULL;
1676                 }
1677
1678                 g_free(cb_info);
1679                 cb_info = NULL;
1680         }
1681
1682         if (tmp_activating) {
1683                 g_free(tmp_activating);
1684                 tmp_activating = NULL;
1685         }
1686         if (tmp_ret) {
1687                 g_free(tmp_ret);
1688                 tmp_ret = NULL;
1689         }
1690
1691         return NULL;
1692 }
1693
1694 static void _client_callback_destroy(camera_cb_info_s *cb_info)
1695 {
1696         gint i = 0;
1697
1698         g_return_if_fail(cb_info != NULL);
1699
1700         LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
1701
1702         g_thread_join(cb_info->msg_recv_thread);
1703         g_thread_unref(cb_info->msg_recv_thread);
1704         cb_info->msg_recv_thread = NULL;
1705
1706         LOGD("msg thread removed");
1707
1708         g_mutex_lock(&cb_info->msg_handler_mutex);
1709         g_atomic_int_set(&cb_info->msg_handler_running, 0);
1710         g_cond_signal(&cb_info->msg_handler_cond);
1711         g_mutex_unlock(&cb_info->msg_handler_mutex);
1712
1713         g_thread_join(cb_info->msg_handler_thread);
1714         g_thread_unref(cb_info->msg_handler_thread);
1715         cb_info->msg_handler_thread = NULL;
1716
1717         g_queue_free(cb_info->msg_queue);
1718         cb_info->msg_queue = NULL;
1719
1720         for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1721                 g_mutex_clear(&cb_info->api_mutex[i]);
1722                 g_cond_clear(&cb_info->api_cond[i]);
1723         }
1724
1725         g_mutex_clear(&cb_info->msg_handler_mutex);
1726         g_cond_clear(&cb_info->msg_handler_cond);
1727         g_mutex_clear(&cb_info->idle_event_mutex);
1728         g_cond_clear(&cb_info->idle_event_cond);
1729
1730         LOGD("event thread removed");
1731
1732         if (cb_info->fd > -1) {
1733                 muse_core_connection_close(cb_info->fd);
1734                 cb_info->fd = -1;
1735         }
1736
1737         if (cb_info->bufmgr) {
1738                 tbm_bufmgr_deinit(cb_info->bufmgr);
1739                 cb_info->bufmgr = NULL;
1740         }
1741         if (cb_info->api_activating) {
1742                 g_free(cb_info->api_activating);
1743                 cb_info->api_activating = NULL;
1744         }
1745         if (cb_info->api_ret) {
1746                 g_free(cb_info->api_ret);
1747                 cb_info->api_ret = NULL;
1748         }
1749         if (cb_info->pkt_fmt) {
1750                 media_format_unref(cb_info->pkt_fmt);
1751                 cb_info->pkt_fmt = NULL;
1752         }
1753         if (cb_info->caps) {
1754                 g_free(cb_info->caps);
1755                 cb_info->caps = NULL;
1756         }
1757
1758         g_free(cb_info);
1759         cb_info = NULL;
1760
1761         return;
1762 }
1763
1764 int camera_create(camera_device_e device, camera_h* camera)
1765 {
1766         int sock_fd = -1;
1767         char *sndMsg;
1768         int ret = CAMERA_ERROR_NONE;
1769         int pid = 0;
1770         camera_cli_s *pc = NULL;
1771         tbm_bufmgr bufmgr = NULL;
1772
1773         muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
1774         muse_core_api_module_e muse_module = MUSE_CAMERA;
1775         int device_type = (int)device;
1776
1777         if (camera == NULL) {
1778                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1779                 return CAMERA_ERROR_INVALID_PARAMETER;
1780         }
1781
1782         bufmgr = tbm_bufmgr_init(-1);
1783         if (bufmgr == NULL) {
1784                 LOGE("get tbm bufmgr failed");
1785                 return CAMERA_ERROR_INVALID_OPERATION;
1786         }
1787
1788         sock_fd = muse_core_client_new();
1789         if (sock_fd < 0) {
1790                 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
1791                 ret = CAMERA_ERROR_INVALID_OPERATION;
1792                 goto ErrorExit;
1793         }
1794
1795         pid = getpid();
1796
1797         sndMsg = muse_core_msg_json_factory_new(api,
1798                 MUSE_TYPE_INT, "module", muse_module,
1799                 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
1800                 MUSE_TYPE_INT, "pid", pid,
1801                 0);
1802
1803         muse_core_ipc_send_msg(sock_fd, sndMsg);
1804         muse_core_msg_json_factory_free(sndMsg);
1805
1806         pc = g_new0(camera_cli_s, 1);
1807         if (pc == NULL) {
1808                 LOGE("camera_cli_s alloc failed");
1809                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1810                 goto ErrorExit;
1811         }
1812
1813         pc->cb_info = _client_callback_new(sock_fd);
1814         if (pc->cb_info == NULL) {
1815                 LOGE("cb_info alloc failed");
1816                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1817                 goto ErrorExit;
1818         }
1819
1820         LOGD("cb info : %d", pc->cb_info->fd);
1821
1822         ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
1823         if (ret == CAMERA_ERROR_NONE) {
1824                 intptr_t handle = 0;
1825                 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
1826                 if (handle == 0) {
1827                         LOGE("Receiving Handle Failed!!");
1828                         ret = CAMERA_ERROR_INVALID_OPERATION;
1829                         goto ErrorExit;
1830                 }
1831
1832                 pc->remote_handle = handle;
1833                 pc->cb_info->bufmgr = bufmgr;
1834
1835                 LOGD("camera create 0x%x", pc->remote_handle);
1836                 *camera = (camera_h) pc;
1837         } else {
1838                 goto ErrorExit;
1839         }
1840
1841         return ret;
1842
1843 ErrorExit:
1844         tbm_bufmgr_deinit(bufmgr);
1845         bufmgr = NULL;
1846
1847         if (pc) {
1848                 _client_callback_destroy(pc->cb_info);
1849                 pc->cb_info = NULL;
1850                 g_free(pc);
1851                 pc = NULL;
1852         }
1853
1854         LOGE("camera create error : 0x%x", ret);
1855
1856         return ret;
1857 }
1858
1859 int camera_destroy(camera_h camera)
1860 {
1861         if (camera == NULL) {
1862                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1863                 return CAMERA_ERROR_INVALID_PARAMETER;
1864         }
1865
1866         int ret = CAMERA_ERROR_NONE;
1867         muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
1868         camera_cli_s *pc = (camera_cli_s *)camera;
1869         int sock_fd = 0;
1870
1871         LOGD("ENTER");
1872
1873         if (pc->cb_info == NULL) {
1874                 LOGE("cb_info NULL, INVALID_PARAMETER");
1875                 return CAMERA_ERROR_INVALID_PARAMETER;
1876         }
1877
1878         sock_fd = pc->cb_info->fd;
1879
1880         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
1881         if (ret == CAMERA_ERROR_NONE) {
1882                 if (pc->client_handle) {
1883                         mm_camcorder_client_destroy(pc->client_handle);
1884                         pc->client_handle = NULL;
1885                 }
1886                 _camera_remove_idle_event_all(pc->cb_info);
1887                 _client_callback_destroy(pc->cb_info);
1888                 pc->cb_info = NULL;
1889
1890 #ifdef HAVE_WAYLAND
1891                 if (pc->wl_info) {
1892                         g_free(pc->wl_info);
1893                         pc->wl_info = NULL;
1894                 }
1895 #endif /* HAVE_WAYLAND */
1896
1897                 g_free(pc);
1898                 pc = NULL;
1899         } else {
1900                 LOGE("camera destroy error : 0x%x", ret);
1901         }
1902
1903         return ret;
1904 }
1905
1906 int camera_start_preview(camera_h camera)
1907 {
1908         int ret = CAMERA_ERROR_NONE;
1909         muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
1910         camera_cli_s *pc = (camera_cli_s *)camera;
1911         int sock_fd = 0;
1912
1913         if (camera == NULL) {
1914                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1915                 return CAMERA_ERROR_INVALID_PARAMETER;
1916         }
1917
1918         if (pc->cb_info == NULL) {
1919                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1920                 return CAMERA_ERROR_INVALID_PARAMETER;
1921         }
1922
1923         LOGD("start");
1924
1925         sock_fd = pc->cb_info->fd;
1926
1927         if (pc->client_handle == NULL) {
1928                 LOGW("set display is not called by application. set NONE type internally");
1929                 ret = camera_set_display(camera, CAMERA_DISPLAY_TYPE_NONE, NULL);
1930                 if (ret != CAMERA_ERROR_NONE) {
1931                         LOGE("Internal camera_set_display failed 0x%x", ret);
1932                         return ret;
1933                 }
1934         }
1935
1936         muse_camera_msg_send_longtime(api, sock_fd, pc->cb_info, ret);
1937
1938         if (ret != CAMERA_ERROR_NONE) {
1939                 LOGE("start preview failed 0x%x", ret);
1940                 return ret;
1941         }
1942
1943         if (pc->cb_info->prev_state == CAMERA_STATE_CREATED) {
1944                 if (pc->cb_info->caps == NULL) {
1945                         LOGE("caps string is NULL");
1946                         goto _START_PREVIEW_ERROR;
1947                 }
1948
1949                 ret = mm_camcorder_client_realize(pc->client_handle, pc->cb_info->caps);
1950                 if (ret != MM_ERROR_NONE) {
1951                         LOGE("client realize failed 0x%x", ret);
1952                         goto _START_PREVIEW_ERROR;
1953                 }
1954         }
1955
1956         LOGD("ret : 0x%x", ret);
1957
1958         return CAMERA_ERROR_NONE;
1959
1960 _START_PREVIEW_ERROR:
1961         muse_camera_msg_send_longtime(MUSE_CAMERA_API_STOP_PREVIEW, sock_fd, pc->cb_info, ret);
1962
1963         return CAMERA_ERROR_INVALID_OPERATION;
1964 }
1965
1966 int camera_stop_preview(camera_h camera)
1967 {
1968         int ret = CAMERA_ERROR_NONE;
1969         int client_ret = MM_ERROR_NONE;
1970         int sock_fd = 0;
1971         camera_cli_s *pc = NULL;
1972         muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
1973
1974         if (camera == NULL) {
1975                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1976                 return CAMERA_ERROR_INVALID_PARAMETER;
1977         }
1978
1979         pc = (camera_cli_s *)camera;
1980
1981         if (pc->cb_info == NULL) {
1982                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1983                 return CAMERA_ERROR_INVALID_PARAMETER;
1984         }
1985
1986         sock_fd = pc->cb_info->fd;
1987
1988         LOGD("Enter");
1989
1990         /* destroy client pipeline first */
1991         if (pc->client_handle != NULL) {
1992                 client_ret = mm_camcorder_client_unrealize(pc->client_handle);
1993         } else {
1994                 LOGW("client handle is NULL");
1995         }
1996
1997         /* send stop preview message */
1998         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
1999
2000         if (ret == MM_ERROR_NONE && client_ret != MM_ERROR_NONE) {
2001                 LOGE("client unrealize failed, restart preview");
2002                 muse_camera_msg_send_longtime(MUSE_CAMERA_API_START_PREVIEW, sock_fd, pc->cb_info, ret);
2003                 ret = CAMERA_ERROR_INVALID_OPERATION;
2004         } else if (ret != MM_ERROR_NONE && client_ret == MM_ERROR_NONE) {
2005                 LOGE("stop preview failed, realize client again");
2006                 mm_camcorder_client_realize(pc->client_handle, pc->cb_info->caps);
2007                 ret = CAMERA_ERROR_INVALID_OPERATION;
2008         }
2009
2010         LOGD("ret : 0x%x", ret);
2011
2012         return ret;
2013 }
2014
2015 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2016 {
2017         if (camera == NULL) {
2018                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2019                 return CAMERA_ERROR_INVALID_PARAMETER;
2020         }
2021         int ret = CAMERA_ERROR_NONE;
2022
2023         camera_cli_s *pc = (camera_cli_s *)camera;
2024         muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2025         int sock_fd;
2026         int is_capturing_cb = 0;
2027         int is_completed_cb = 0;
2028         LOGD("Enter, handle :%x", pc->remote_handle);
2029
2030         if (pc->cb_info == NULL) {
2031                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2032                 return CAMERA_ERROR_INVALID_PARAMETER;
2033         }
2034
2035         sock_fd = pc->cb_info->fd;
2036
2037         if (capturing_cb != NULL) {
2038                 is_capturing_cb = 1;
2039                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2040                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2041         }
2042
2043         if (completed_cb != NULL) {
2044                 is_completed_cb = 1;
2045                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2046                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2047         }
2048
2049         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, is_capturing_cb, INT, is_completed_cb);
2050         LOGD("is_capturing_cb :%d, is_completed_cb : %d", is_capturing_cb, is_completed_cb);
2051         LOGD("ret : 0x%x", ret);
2052         return ret;
2053 }
2054
2055 bool camera_is_supported_continuous_capture(camera_h camera)
2056 {
2057         if (camera == NULL) {
2058                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2059                 return false;
2060         }
2061
2062         int ret = CAMERA_ERROR_NONE;
2063         camera_cli_s *pc = (camera_cli_s *)camera;
2064         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2065         int sock_fd;
2066
2067         if (pc->cb_info == NULL) {
2068                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2069                 return CAMERA_ERROR_INVALID_PARAMETER;
2070         }
2071
2072         sock_fd = pc->cb_info->fd;
2073
2074         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2075         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2076         LOGD("ret : 0x%x", ret);
2077         return (bool)ret;
2078 }
2079
2080 int camera_start_continuous_capture(camera_h camera, int count, int interval, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb , void *user_data)
2081 {
2082         if (camera == NULL) {
2083                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2084                 return CAMERA_ERROR_INVALID_PARAMETER;
2085         }
2086
2087         int ret = CAMERA_ERROR_NONE;
2088
2089         camera_cli_s *pc = (camera_cli_s *)camera;
2090         muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2091
2092         LOGD("Enter, handle :%x", pc->remote_handle);
2093
2094         int sock_fd;
2095         if (pc->cb_info == NULL) {
2096                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2097                 return CAMERA_ERROR_INVALID_PARAMETER;
2098         }
2099         sock_fd = pc->cb_info->fd;
2100
2101         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2102         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2103         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2104
2105         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, count, INT, interval);
2106
2107         LOGD("ret : 0x%x", ret);
2108
2109         return ret;
2110 }
2111
2112 int camera_stop_continuous_capture(camera_h camera)
2113 {
2114         if (camera == NULL) {
2115                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2116                 return CAMERA_ERROR_INVALID_PARAMETER;
2117         }
2118
2119
2120         int ret = CAMERA_ERROR_NONE;
2121
2122         camera_cli_s *pc = (camera_cli_s *)camera;
2123         muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2124         LOGD("Enter,  handle :%x", pc->remote_handle);
2125         int sock_fd;
2126         if (pc->cb_info == NULL) {
2127                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2128                 return CAMERA_ERROR_INVALID_PARAMETER;
2129         }
2130         sock_fd = pc->cb_info->fd;
2131         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2132         LOGD("ret : 0x%x", ret);
2133         return ret;
2134 }
2135
2136 bool camera_is_supported_face_detection(camera_h camera)
2137 {
2138         if (camera == NULL) {
2139                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2140                 return false;
2141         }
2142         int ret = CAMERA_ERROR_NONE;
2143
2144         camera_cli_s *pc = (camera_cli_s *)camera;
2145         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2146         int sock_fd;
2147         if (pc->cb_info == NULL) {
2148                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2149                 return CAMERA_ERROR_INVALID_PARAMETER;
2150         }
2151         sock_fd = pc->cb_info->fd;
2152
2153         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2154         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2155         LOGD("ret : 0x%x", ret);
2156         return (bool)ret;
2157 }
2158
2159 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2160 {
2161         if (camera == NULL) {
2162                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2163                 return false;
2164         }
2165         int ret = CAMERA_ERROR_NONE;
2166
2167         camera_cli_s *pc = (camera_cli_s *)camera;
2168         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2169         int sock_fd;
2170         if (pc->cb_info == NULL) {
2171                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2172                 return CAMERA_ERROR_INVALID_PARAMETER;
2173         }
2174         sock_fd = pc->cb_info->fd;
2175
2176         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2177         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2178         LOGD("ret : 0x%x", ret);
2179         return (bool)ret;
2180 }
2181
2182 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2183 {
2184         if (camera == NULL) {
2185                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2186                 return false;
2187         }
2188
2189         int ret = CAMERA_ERROR_NONE;
2190
2191         camera_cli_s *pc = (camera_cli_s *)camera;
2192         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2193         int sock_fd;
2194         if (pc->cb_info == NULL) {
2195                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2196                 return CAMERA_ERROR_INVALID_PARAMETER;
2197         }
2198         sock_fd = pc->cb_info->fd;
2199
2200         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2201         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2202         LOGD("ret : 0x%x", ret);
2203         return (bool)ret;
2204 }
2205
2206 int camera_get_device_count(camera_h camera, int *device_count)
2207 {
2208         if (camera == NULL || device_count == NULL) {
2209                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2210                 return CAMERA_ERROR_INVALID_PARAMETER;
2211         }
2212         int ret = CAMERA_ERROR_NONE;
2213
2214         camera_cli_s *pc = (camera_cli_s *)camera;
2215         muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2216         int sock_fd;
2217         if (pc->cb_info == NULL) {
2218                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2219                 return CAMERA_ERROR_INVALID_PARAMETER;
2220         }
2221         sock_fd = pc->cb_info->fd;
2222         int get_device_count;
2223
2224         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2225         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2226
2227         if (ret == CAMERA_ERROR_NONE) {
2228                 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2229                 *device_count = get_device_count;
2230         }
2231         LOGD("ret : 0x%x", ret);
2232         return ret;
2233 }
2234
2235 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void * user_data)
2236 {
2237         if (camera == NULL) {
2238                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2239                 return CAMERA_ERROR_INVALID_PARAMETER;
2240         }
2241
2242         int ret = CAMERA_ERROR_NONE;
2243
2244         camera_cli_s *pc = (camera_cli_s *)camera;
2245         muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2246
2247         LOGD("Enter, handle :%x", pc->remote_handle);
2248         int sock_fd;
2249         if (pc->cb_info == NULL) {
2250                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2251                 return CAMERA_ERROR_INVALID_PARAMETER;
2252         }
2253         sock_fd = pc->cb_info->fd;
2254         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2255         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2256
2257         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2258         LOGD("ret : 0x%x", ret);
2259         return ret;
2260 }
2261
2262 int camera_stop_face_detection(camera_h camera)
2263 {
2264         if (camera == NULL) {
2265                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2266                 return CAMERA_ERROR_INVALID_PARAMETER;
2267         }
2268
2269         int ret = CAMERA_ERROR_NONE;
2270
2271         camera_cli_s *pc = (camera_cli_s *)camera;
2272         muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2273         LOGD("Enter,  handle :%x", pc->remote_handle);
2274         int sock_fd;
2275         if (pc->cb_info == NULL) {
2276                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2277                 return CAMERA_ERROR_INVALID_PARAMETER;
2278         }
2279         sock_fd = pc->cb_info->fd;
2280         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2281         LOGD("ret : 0x%x", ret);
2282         return ret;
2283 }
2284
2285 int camera_get_state(camera_h camera, camera_state_e * state)
2286 {
2287         if (camera == NULL || state == NULL) {
2288                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2289                 return CAMERA_ERROR_INVALID_PARAMETER;
2290         }
2291         int ret = CAMERA_ERROR_NONE;
2292
2293         camera_cli_s *pc = (camera_cli_s *)camera;
2294         muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2295         int sock_fd;
2296         if (pc->cb_info == NULL) {
2297                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2298                 return CAMERA_ERROR_INVALID_PARAMETER;
2299         }
2300         sock_fd = pc->cb_info->fd;
2301         int get_state;
2302
2303         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2304         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2305
2306         if (ret == CAMERA_ERROR_NONE) {
2307                 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2308                 *state = (camera_state_e)get_state;
2309         }
2310         LOGD("ret : 0x%x", ret);
2311         return ret;
2312 }
2313
2314 int camera_start_focusing(camera_h camera, bool continuous)
2315 {
2316         if (camera == NULL) {
2317                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2318                 return CAMERA_ERROR_INVALID_PARAMETER;
2319         }
2320
2321         int ret = CAMERA_ERROR_NONE;
2322
2323         camera_cli_s *pc = (camera_cli_s *)camera;
2324         muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2325         int sock_fd;
2326         if (pc->cb_info == NULL) {
2327                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2328                 return CAMERA_ERROR_INVALID_PARAMETER;
2329         }
2330         sock_fd = pc->cb_info->fd;
2331         int is_continuous = (int)continuous;
2332
2333         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2334         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, is_continuous);
2335         LOGD("ret : 0x%x", ret);
2336         return ret;
2337 }
2338
2339 int camera_cancel_focusing(camera_h camera)
2340 {
2341         if (camera == NULL) {
2342                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2343                 return CAMERA_ERROR_INVALID_PARAMETER;
2344         }
2345
2346         int ret = CAMERA_ERROR_NONE;
2347
2348         camera_cli_s *pc = (camera_cli_s *)camera;
2349         muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2350         int sock_fd;
2351         if (pc->cb_info == NULL) {
2352                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2353                 return CAMERA_ERROR_INVALID_PARAMETER;
2354         }
2355         sock_fd = pc->cb_info->fd;
2356
2357         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2358         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2359         LOGD("ret : 0x%x", ret);
2360         return ret;
2361 }
2362
2363 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2364 {
2365         int ret = CAMERA_ERROR_NONE;
2366         void *set_display_handle = NULL;
2367         int set_surface = MM_DISPLAY_SURFACE_X;
2368         Evas_Object *obj = NULL;
2369         const char *object_type = NULL;
2370         char socket_path[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
2371 #ifdef HAVE_WAYLAND
2372         MMCamWaylandInfo *wl_info = NULL;
2373 #endif /* HAVE_WAYLAND */
2374
2375         if (camera == NULL) {
2376                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2377                 return CAMERA_ERROR_INVALID_PARAMETER;
2378         }
2379
2380         if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2381                 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2382                 return CAMERA_ERROR_INVALID_PARAMETER;
2383         }
2384
2385         camera_cli_s *pc = (camera_cli_s *)camera;
2386         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2387         int sock_fd;
2388         if (pc->cb_info == NULL) {
2389                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2390                 return CAMERA_ERROR_INVALID_PARAMETER;
2391         }
2392         sock_fd = pc->cb_info->fd;
2393
2394         LOGD("Enter, remote_handle : %x display : 0x%x", pc->remote_handle, display);
2395
2396         if (type == CAMERA_DISPLAY_TYPE_NONE) {
2397                 set_display_handle = 0;
2398                 set_surface = MM_DISPLAY_SURFACE_NULL;
2399                 LOGD("display type NONE");
2400         } else {
2401                 obj = (Evas_Object *)display;
2402                 object_type = evas_object_type_get(obj);
2403                 if (object_type) {
2404                         if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2405 #ifdef HAVE_WAYLAND
2406                                 /* set wayland info */
2407                                 wl_info = _get_wl_info(obj);
2408                                 if (wl_info == NULL) {
2409                                         LOGE("failed to get wl_info");
2410                                         return CAMERA_ERROR_INVALID_OPERATION;
2411                                 }
2412
2413                                 set_display_handle = (void *)wl_info;
2414 #else /* HAVE_WAYLAND */
2415                                 /* x window overlay surface */
2416                                 set_display_handle = (void *)elm_win_xwindow_get(obj);
2417 #endif
2418                                 set_surface = MM_DISPLAY_SURFACE_X;
2419                                 LOGD("display type OVERLAY : handle %p", set_display_handle);
2420                         } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2421                                 /* evas object surface */
2422                                 set_display_handle = (void *)display;
2423                                 set_surface = MM_DISPLAY_SURFACE_EVAS;
2424                                 LOGD("display type EVAS : handle %p", set_display_handle);
2425                         } else {
2426                                 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
2427                                 return CAMERA_ERROR_INVALID_PARAMETER;
2428                         }
2429                 } else {
2430                         LOGE("failed to get evas object type from %p", obj);
2431                         return CAMERA_ERROR_INVALID_PARAMETER;
2432                 }
2433         }
2434
2435         pc->display_handle = (intptr_t)set_display_handle;
2436
2437         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2438
2439         if (ret == CAMERA_ERROR_NONE) {
2440                 if (pc->client_handle == NULL) {
2441                         ret = mm_camcorder_client_create(&pc->client_handle);
2442                         if (ret != MM_ERROR_NONE) {
2443                                 LOGE("camera client create Failed 0x%x", ret);
2444                                 goto _SET_DISPLAY_ERROR;
2445                         }
2446                 }
2447
2448                 if (muse_camera_msg_get_string(socket_path, pc->cb_info->recv_msg) == FALSE) {
2449                         LOGE("failed to get socket path");
2450                         goto _SET_DISPLAY_ERROR;
2451                 }
2452
2453                 LOGD("socket path : %s", socket_path);
2454
2455                 ret = mm_camcorder_client_set_socket_path(pc->client_handle, socket_path);
2456                 if (ret != MM_ERROR_NONE) {
2457                         LOGE("failed to set socket path 0x%x", ret);
2458                         goto _SET_DISPLAY_ERROR;
2459                 }
2460
2461                 ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2462                         MMCAM_DISPLAY_SURFACE, set_surface,
2463                         NULL);
2464                 if (ret != MM_ERROR_NONE) {
2465                         LOGE("set display surface failed 0x%x", ret);
2466                         goto _SET_DISPLAY_ERROR;
2467                 }
2468
2469                 if (type != CAMERA_DISPLAY_TYPE_NONE) {
2470                         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2471                                 MMCAM_DISPLAY_HANDLE, set_display_handle, sizeof(void *),
2472                                 NULL);
2473                         if (ret != MM_ERROR_NONE) {
2474                                 LOGE("set display handle failed 0x%x", ret);
2475                                 goto _SET_DISPLAY_ERROR;
2476                         }
2477                 }
2478
2479 #ifdef HAVE_WAYLAND
2480                 if (pc->wl_info) {
2481                         g_free(pc->wl_info);
2482                         pc->wl_info = NULL;
2483                 }
2484
2485                 pc->wl_info = wl_info;
2486 #endif /* HAVE_WAYLAND */
2487
2488                 return CAMERA_ERROR_NONE;;
2489         } else {
2490                 LOGE("set display error - 0x%x");
2491                 return ret;
2492         }
2493
2494 _SET_DISPLAY_ERROR:
2495 #ifdef HAVE_WAYLAND
2496         if (wl_info) {
2497                 g_free(wl_info);
2498                 wl_info = NULL;
2499         }
2500 #endif /* HAVE_WAYLAND */
2501
2502         return __convert_camera_error_code(__func__, ret);
2503 }
2504
2505 int camera_set_preview_resolution(camera_h camera,  int width, int height)
2506 {
2507         if (camera == NULL) {
2508                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2509                 return CAMERA_ERROR_INVALID_PARAMETER;
2510         }
2511         int ret = CAMERA_ERROR_NONE;
2512
2513         camera_cli_s *pc = (camera_cli_s *)camera;
2514         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
2515         int sock_fd;
2516         if (pc->cb_info == NULL) {
2517                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2518                 return CAMERA_ERROR_INVALID_PARAMETER;
2519         }
2520         sock_fd = pc->cb_info->fd;
2521
2522         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2523         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2524         LOGD("ret : 0x%x", ret);
2525         return ret;
2526 }
2527
2528
2529 int camera_set_capture_resolution(camera_h camera,  int width, int height)
2530 {
2531         if (camera == NULL) {
2532                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2533                 return CAMERA_ERROR_INVALID_PARAMETER;
2534         }
2535
2536         int ret = CAMERA_ERROR_NONE;
2537
2538         camera_cli_s *pc = (camera_cli_s *)camera;
2539         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
2540         int sock_fd;
2541         if (pc->cb_info == NULL) {
2542                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2543                 return CAMERA_ERROR_INVALID_PARAMETER;
2544         }
2545         sock_fd = pc->cb_info->fd;
2546
2547         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2548         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2549         LOGD("ret : 0x%x", ret);
2550         return ret;
2551 }
2552
2553 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
2554 {
2555         if (camera == NULL) {
2556                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2557                 return CAMERA_ERROR_INVALID_PARAMETER;
2558         }
2559
2560         int ret = CAMERA_ERROR_NONE;
2561         int set_format = (int)format;
2562
2563         camera_cli_s *pc = (camera_cli_s *)camera;
2564         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
2565         int sock_fd;
2566         if (pc->cb_info == NULL) {
2567                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2568                 return CAMERA_ERROR_INVALID_PARAMETER;
2569         }
2570         sock_fd = pc->cb_info->fd;
2571
2572         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2573         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2574         LOGD("ret : 0x%x", ret);
2575         return ret;
2576 }
2577
2578 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
2579 {
2580         if (camera == NULL) {
2581                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2582                 return CAMERA_ERROR_INVALID_PARAMETER;
2583         }
2584
2585         int ret = CAMERA_ERROR_NONE;
2586         int set_format = (int)format;
2587
2588         camera_cli_s *pc = (camera_cli_s *)camera;
2589         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
2590         int sock_fd;
2591         if (pc->cb_info == NULL) {
2592                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2593                 return CAMERA_ERROR_INVALID_PARAMETER;
2594         }
2595         sock_fd = pc->cb_info->fd;
2596
2597         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2598         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2599         LOGD("ret : 0x%x", ret);
2600         return ret;
2601 }
2602
2603 int camera_get_preview_resolution(camera_h camera,  int *width, int *height)
2604 {
2605         if (camera == NULL || width == NULL || height == NULL) {
2606                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2607                 return CAMERA_ERROR_INVALID_PARAMETER;
2608         }
2609
2610
2611         int ret = CAMERA_ERROR_NONE;
2612
2613         camera_cli_s *pc = (camera_cli_s *)camera;
2614         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
2615         int sock_fd;
2616         if (pc->cb_info == NULL) {
2617                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2618                 return CAMERA_ERROR_INVALID_PARAMETER;
2619         }
2620         sock_fd = pc->cb_info->fd;
2621         int get_width;
2622         int get_height;
2623
2624         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2625         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2626
2627         if (ret == CAMERA_ERROR_NONE) {
2628                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2629                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2630                 *width = get_width;
2631                 *height = get_height;
2632         }
2633         LOGD("ret : 0x%x", ret);
2634         return ret;
2635 }
2636
2637 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
2638 {
2639         int ret = CAMERA_ERROR_NONE;
2640         camera_cli_s *pc = NULL;
2641
2642         if (camera == NULL) {
2643                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2644                 return CAMERA_ERROR_INVALID_PARAMETER;
2645         }
2646
2647         pc = (camera_cli_s *)camera;
2648
2649         if (pc->client_handle == NULL) {
2650                 LOGE("client handle is NULL");
2651                 return CAMERA_ERROR_INVALID_OPERATION;
2652         }
2653
2654         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2655                 MMCAM_DISPLAY_ROTATION, rotation,
2656                 NULL);
2657
2658         return __convert_camera_error_code(__func__, ret);
2659 }
2660
2661 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
2662 {
2663         int ret = CAMERA_ERROR_NONE;
2664         camera_cli_s *pc = NULL;
2665
2666         if (camera == NULL || rotation == NULL) {
2667                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2668                 return CAMERA_ERROR_INVALID_PARAMETER;
2669         }
2670
2671         pc = (camera_cli_s *)camera;
2672
2673         if (pc->client_handle == NULL) {
2674                 LOGE("client handle is NULL");
2675                 return CAMERA_ERROR_INVALID_OPERATION;
2676         }
2677
2678         ret = mm_camcorder_get_attributes(pc->client_handle, NULL,
2679                 MMCAM_DISPLAY_ROTATION, rotation,
2680                 NULL);
2681
2682         return __convert_camera_error_code(__func__, ret);
2683 }
2684
2685 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
2686 {
2687         int ret = CAMERA_ERROR_NONE;
2688         camera_cli_s *pc = NULL;
2689
2690         if (camera == NULL) {
2691                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2692                 return CAMERA_ERROR_INVALID_PARAMETER;
2693         }
2694
2695         pc = (camera_cli_s *)camera;
2696
2697         if (pc->client_handle == NULL) {
2698                 LOGE("client handle is NULL");
2699                 return CAMERA_ERROR_INVALID_OPERATION;
2700         }
2701
2702         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2703                 MMCAM_DISPLAY_FLIP, flip,
2704                 NULL);
2705
2706         return __convert_camera_error_code(__func__, ret);
2707 }
2708
2709 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
2710 {
2711         int ret = CAMERA_ERROR_NONE;
2712         camera_cli_s *pc = NULL;
2713
2714         if (camera == NULL || flip == NULL) {
2715                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2716                 return CAMERA_ERROR_INVALID_PARAMETER;
2717         }
2718
2719         pc = (camera_cli_s *)camera;
2720
2721         if (pc->client_handle == NULL) {
2722                 LOGE("client handle is NULL");
2723                 return CAMERA_ERROR_INVALID_OPERATION;
2724         }
2725
2726         ret = mm_camcorder_get_attributes(pc->client_handle, NULL,
2727                 MMCAM_DISPLAY_FLIP, flip,
2728                 NULL);
2729
2730         return __convert_camera_error_code(__func__, ret);
2731 }
2732
2733 int camera_set_display_visible(camera_h camera, bool visible)
2734 {
2735         int ret = CAMERA_ERROR_NONE;
2736         camera_cli_s *pc = NULL;
2737
2738         if (camera == NULL) {
2739                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2740                 return CAMERA_ERROR_INVALID_PARAMETER;
2741         }
2742
2743         pc = (camera_cli_s *)camera;
2744
2745         if (pc->client_handle == NULL) {
2746                 LOGE("client handle is NULL");
2747                 return CAMERA_ERROR_INVALID_OPERATION;
2748         }
2749
2750         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2751                 MMCAM_DISPLAY_VISIBLE, visible,
2752                 NULL);
2753
2754         return __convert_camera_error_code(__func__, ret);
2755 }
2756
2757 int camera_is_display_visible(camera_h camera, bool* visible)
2758 {
2759         if (camera == NULL || visible == NULL) {
2760                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2761                 return CAMERA_ERROR_INVALID_PARAMETER;
2762         }
2763
2764         int ret = CAMERA_ERROR_NONE;
2765
2766         camera_cli_s *pc = (camera_cli_s *)camera;
2767         muse_camera_api_e api = MUSE_CAMERA_API_IS_DISPLAY_VISIBLE;
2768         int sock_fd;
2769         if (pc->cb_info == NULL) {
2770                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2771                 return CAMERA_ERROR_INVALID_PARAMETER;
2772         }
2773         sock_fd = pc->cb_info->fd;
2774         int get_visible;
2775
2776         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2777         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2778
2779         if (ret == CAMERA_ERROR_NONE) {
2780                 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
2781                 *visible = (bool)get_visible;
2782         }
2783         LOGD("ret : 0x%x", ret);
2784         return ret;
2785 }
2786
2787 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
2788 {
2789         int ret = CAMERA_ERROR_NONE;
2790         camera_cli_s *pc = NULL;
2791
2792         if (camera == NULL) {
2793                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2794                 return CAMERA_ERROR_INVALID_PARAMETER;
2795         }
2796
2797         pc = (camera_cli_s *)camera;
2798
2799         if (pc->client_handle == NULL) {
2800                 LOGE("client handle is NULL");
2801                 return CAMERA_ERROR_INVALID_OPERATION;
2802         }
2803
2804         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2805                 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
2806                 NULL);
2807
2808         return __convert_camera_error_code(__func__, ret);
2809 }
2810
2811 int camera_get_display_mode(camera_h camera, camera_display_mode_e* mode)
2812 {
2813         int ret = CAMERA_ERROR_NONE;
2814         camera_cli_s *pc = NULL;
2815
2816         if (camera == NULL || mode == NULL) {
2817                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2818                 return CAMERA_ERROR_INVALID_PARAMETER;
2819         }
2820
2821         pc = (camera_cli_s *)camera;
2822
2823         if (pc->client_handle == NULL) {
2824                 LOGE("client handle is NULL");
2825                 return CAMERA_ERROR_INVALID_OPERATION;
2826         }
2827
2828         ret = mm_camcorder_get_attributes(pc->client_handle, NULL,
2829                 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
2830                 NULL);
2831
2832         return __convert_camera_error_code(__func__, ret);
2833 }
2834
2835 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
2836 {
2837         if (camera == NULL || width == NULL || height == NULL) {
2838                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2839                 return CAMERA_ERROR_INVALID_PARAMETER;
2840         }
2841         int ret = CAMERA_ERROR_NONE;
2842
2843         camera_cli_s *pc = (camera_cli_s *)camera;
2844         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
2845         int sock_fd;
2846         if (pc->cb_info == NULL) {
2847                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2848                 return CAMERA_ERROR_INVALID_PARAMETER;
2849         }
2850         sock_fd = pc->cb_info->fd;
2851         int get_width;
2852         int get_height;
2853
2854         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2855         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2856
2857         if (ret == CAMERA_ERROR_NONE) {
2858                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2859                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2860                 *width = get_width;
2861                 *height = get_height;
2862         }
2863         LOGD("ret : 0x%x", ret);
2864         return ret;
2865 }
2866
2867 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
2868 {
2869         if (camera == NULL || format == NULL) {
2870                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2871                 return CAMERA_ERROR_INVALID_PARAMETER;
2872         }
2873         int ret = CAMERA_ERROR_NONE;
2874
2875         camera_cli_s *pc = (camera_cli_s *)camera;
2876         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
2877         int get_format;
2878         int sock_fd;
2879         if (pc->cb_info == NULL) {
2880                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2881                 return CAMERA_ERROR_INVALID_PARAMETER;
2882         }
2883         sock_fd = pc->cb_info->fd;
2884
2885         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2886         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2887
2888         if (ret == CAMERA_ERROR_NONE) {
2889                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
2890                 *format = (camera_pixel_format_e)get_format;
2891         }
2892         LOGD("ret : 0x%x", ret);
2893         return ret;
2894 }
2895
2896 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
2897 {
2898         if (camera == NULL || format == NULL) {
2899                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2900                 return CAMERA_ERROR_INVALID_PARAMETER;
2901         }
2902
2903         int ret = CAMERA_ERROR_NONE;
2904
2905         camera_cli_s *pc = (camera_cli_s *)camera;
2906         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
2907         int get_format;
2908         int sock_fd;
2909         if (pc->cb_info == NULL) {
2910                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2911                 return CAMERA_ERROR_INVALID_PARAMETER;
2912         }
2913         sock_fd = pc->cb_info->fd;
2914
2915         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2916         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2917
2918         if (ret == CAMERA_ERROR_NONE) {
2919                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
2920                 *format = (camera_pixel_format_e)get_format;
2921         }
2922         LOGD("ret : 0x%x", ret);
2923         return ret;
2924 }
2925
2926 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton)
2927 {
2928         if (camera == NULL || facing_direciton == NULL) {
2929                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2930                 return CAMERA_ERROR_INVALID_PARAMETER;
2931         }
2932
2933         int ret = CAMERA_ERROR_NONE;
2934
2935         camera_cli_s *pc = (camera_cli_s *)camera;
2936         muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
2937         int sock_fd;
2938         if (pc->cb_info == NULL) {
2939                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2940                 return CAMERA_ERROR_INVALID_PARAMETER;
2941         }
2942         sock_fd = pc->cb_info->fd;
2943         int get_facing_direction;
2944
2945         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2946         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2947
2948         if (ret == CAMERA_ERROR_NONE) {
2949                 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
2950                 *facing_direciton = (camera_facing_direction_e)get_facing_direction;
2951         }
2952         LOGD("ret : 0x%x", ret);
2953         return ret;
2954 }
2955
2956 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void* user_data)
2957 {
2958         if (camera == NULL || callback == NULL) {
2959                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2960                 return CAMERA_ERROR_INVALID_PARAMETER;
2961         }
2962         int ret = CAMERA_ERROR_NONE;
2963
2964         camera_cli_s *pc = (camera_cli_s *)camera;
2965         int sock_fd;
2966         if (pc->cb_info == NULL) {
2967                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2968                 return CAMERA_ERROR_INVALID_PARAMETER;
2969         }
2970         sock_fd = pc->cb_info->fd;
2971         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
2972
2973         LOGD("Enter, handle :%x", pc->remote_handle);
2974
2975         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
2976         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
2977
2978         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2979         LOGD("ret : 0x%x", ret);
2980         return ret;
2981 }
2982
2983 int camera_unset_preview_cb(camera_h camera)
2984 {
2985         if (camera == NULL) {
2986                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2987                 return CAMERA_ERROR_INVALID_PARAMETER;
2988         }
2989
2990         int ret = CAMERA_ERROR_NONE;
2991
2992         camera_cli_s *pc = (camera_cli_s *)camera;
2993         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
2994
2995         LOGD("Enter, handle :%x", pc->remote_handle);
2996
2997         int sock_fd;
2998         if (pc->cb_info == NULL) {
2999                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3000                 return CAMERA_ERROR_INVALID_PARAMETER;
3001         }
3002         sock_fd = pc->cb_info->fd;
3003         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
3004         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
3005
3006         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3007         LOGD("ret : 0x%x", ret);
3008         return ret;
3009 }
3010
3011 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void* user_data)
3012 {
3013         if (camera == NULL) {
3014                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3015                 return CAMERA_ERROR_INVALID_PARAMETER;
3016         }
3017
3018         if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3019                 LOGE("NOT SUPPORTED");
3020                 return CAMERA_ERROR_NOT_SUPPORTED;
3021         }
3022
3023         if (callback == NULL) {
3024                 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
3025                 return CAMERA_ERROR_INVALID_PARAMETER;
3026         }
3027
3028         int ret = CAMERA_ERROR_NONE;
3029
3030         camera_cli_s *pc = (camera_cli_s *)camera;
3031         muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3032
3033         LOGD("Enter, handle :%x", pc->remote_handle);
3034
3035         int sock_fd;
3036         if (pc->cb_info == NULL) {
3037                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3038                 return CAMERA_ERROR_INVALID_PARAMETER;
3039         }
3040         sock_fd = pc->cb_info->fd;
3041         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3042         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3043
3044         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3045         LOGD("ret : 0x%x", ret);
3046         return ret;
3047 }
3048
3049 int camera_unset_media_packet_preview_cb(camera_h camera)
3050 {
3051         if (camera == NULL) {
3052                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3053                 return CAMERA_ERROR_INVALID_PARAMETER;
3054         }
3055
3056         int ret = CAMERA_ERROR_NONE;
3057
3058         camera_cli_s *pc = (camera_cli_s *)camera;
3059         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3060
3061         LOGD("Enter, handle :%x", pc->remote_handle);
3062
3063         int sock_fd;
3064         if (pc->cb_info == NULL) {
3065                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3066                 return CAMERA_ERROR_INVALID_PARAMETER;
3067         }
3068         sock_fd = pc->cb_info->fd;
3069         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3070         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3071
3072         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3073         LOGD("ret : 0x%x", ret);
3074         return ret;
3075 }
3076
3077 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data)
3078 {
3079         if (camera == NULL || callback == NULL) {
3080                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3081                 return CAMERA_ERROR_INVALID_PARAMETER;
3082         }
3083         int ret = CAMERA_ERROR_NONE;
3084
3085         camera_cli_s *pc = (camera_cli_s *)camera;
3086         muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3087
3088         LOGD("Enter, handle :%x", pc->remote_handle);
3089
3090         int sock_fd;
3091         if (pc->cb_info == NULL) {
3092                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3093                 return CAMERA_ERROR_INVALID_PARAMETER;
3094         }
3095         sock_fd = pc->cb_info->fd;
3096         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3097         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3098
3099         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3100         LOGD("ret : 0x%x", ret);
3101         return ret;
3102 }
3103 int camera_unset_state_changed_cb(camera_h camera)
3104 {
3105         if (camera == NULL) {
3106                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3107                 return CAMERA_ERROR_INVALID_PARAMETER;
3108         }
3109         int ret = CAMERA_ERROR_NONE;
3110
3111         camera_cli_s *pc = (camera_cli_s *)camera;
3112         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3113
3114         LOGD("Enter, handle :%x", pc->remote_handle);
3115
3116         int sock_fd;
3117         if (pc->cb_info == NULL) {
3118                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3119                 return CAMERA_ERROR_INVALID_PARAMETER;
3120         }
3121         sock_fd = pc->cb_info->fd;
3122         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3123         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3124
3125         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3126         LOGD("ret : 0x%x", ret);
3127         return ret;
3128 }
3129
3130 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3131 {
3132         if (camera == NULL || callback == NULL) {
3133                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3134                 return CAMERA_ERROR_INVALID_PARAMETER;
3135         }
3136         int ret = CAMERA_ERROR_NONE;
3137
3138         camera_cli_s *pc = (camera_cli_s *)camera;
3139         muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3140
3141         LOGD("Enter, handle :%x", pc->remote_handle);
3142
3143         int sock_fd;
3144         if (pc->cb_info == NULL) {
3145                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3146                 return CAMERA_ERROR_INVALID_PARAMETER;
3147         }
3148         sock_fd = pc->cb_info->fd;
3149         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3150         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3151
3152         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3153         LOGD("ret : 0x%x", ret);
3154         return ret;
3155 }
3156
3157 int camera_unset_interrupted_cb(camera_h camera)
3158 {
3159         if (camera == NULL) {
3160                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3161                 return CAMERA_ERROR_INVALID_PARAMETER;
3162         }
3163         int ret = CAMERA_ERROR_NONE;
3164
3165         camera_cli_s *pc = (camera_cli_s *)camera;
3166         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3167
3168         LOGD("Enter, handle :%x", pc->remote_handle);
3169
3170         int sock_fd;
3171         if (pc->cb_info == NULL) {
3172                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3173                 return CAMERA_ERROR_INVALID_PARAMETER;
3174         }
3175         sock_fd = pc->cb_info->fd;
3176         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3177         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3178
3179         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3180         LOGD("ret : 0x%x", ret);
3181         return ret;
3182 }
3183
3184 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data)
3185 {
3186         if (camera == NULL || callback == NULL) {
3187                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3188                 return CAMERA_ERROR_INVALID_PARAMETER;
3189         }
3190         int ret = CAMERA_ERROR_NONE;
3191
3192         camera_cli_s *pc = (camera_cli_s *)camera;
3193         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3194
3195         LOGD("Enter, handle :%x", pc->remote_handle);
3196
3197         int sock_fd;
3198         if (pc->cb_info == NULL) {
3199                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3200                 return CAMERA_ERROR_INVALID_PARAMETER;
3201         }
3202         sock_fd = pc->cb_info->fd;
3203         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3204         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3205
3206         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3207         LOGD("ret : 0x%x", ret);
3208         return ret;
3209 }
3210
3211 int camera_unset_focus_changed_cb(camera_h camera)
3212 {
3213         if (camera == NULL) {
3214                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3215                 return CAMERA_ERROR_INVALID_PARAMETER;
3216         }
3217         int ret = CAMERA_ERROR_NONE;
3218
3219         camera_cli_s *pc = (camera_cli_s *)camera;
3220         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3221
3222         LOGD("Enter, handle :%x", pc->remote_handle);
3223
3224         int sock_fd;
3225         if (pc->cb_info == NULL) {
3226                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3227                 return CAMERA_ERROR_INVALID_PARAMETER;
3228         }
3229         sock_fd = pc->cb_info->fd;
3230         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3231         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3232
3233         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3234         LOGD("ret : 0x%x", ret);
3235         return ret;
3236 }
3237
3238 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3239 {
3240         if (camera == NULL || callback == NULL) {
3241                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3242                 return CAMERA_ERROR_INVALID_PARAMETER;
3243         }
3244         int ret = CAMERA_ERROR_NONE;
3245
3246         camera_cli_s *pc = (camera_cli_s *)camera;
3247         muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3248
3249         LOGD("Enter, handle :%x", pc->remote_handle);
3250
3251         int sock_fd;
3252         if (pc->cb_info == NULL) {
3253                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3254                 return CAMERA_ERROR_INVALID_PARAMETER;
3255         }
3256         sock_fd = pc->cb_info->fd;
3257         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3258         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3259
3260         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3261         LOGD("ret : 0x%x", ret);
3262         return ret;
3263 }
3264
3265 int camera_unset_error_cb(camera_h camera)
3266 {
3267         if (camera == NULL) {
3268                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3269                 return CAMERA_ERROR_INVALID_PARAMETER;
3270         }
3271         int ret = CAMERA_ERROR_NONE;
3272
3273         camera_cli_s *pc = (camera_cli_s *)camera;
3274         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3275
3276         LOGD("Enter, handle :%x", pc->remote_handle);
3277
3278         int sock_fd;
3279         if (pc->cb_info == NULL) {
3280                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3281                 return CAMERA_ERROR_INVALID_PARAMETER;
3282         }
3283         sock_fd = pc->cb_info->fd;
3284         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3285         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3286
3287         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3288         LOGD("ret : 0x%x", ret);
3289         return ret;
3290 }
3291
3292 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data)
3293 {
3294         if (camera == NULL || foreach_cb == NULL) {
3295                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3296                 return CAMERA_ERROR_INVALID_PARAMETER;
3297         }
3298         int ret = CAMERA_ERROR_NONE;
3299
3300         camera_cli_s *pc = (camera_cli_s *)camera;
3301         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3302
3303         LOGD("Enter, handle :%x", pc->remote_handle);
3304
3305         int sock_fd;
3306         if (pc->cb_info == NULL) {
3307                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3308                 return CAMERA_ERROR_INVALID_PARAMETER;
3309         }
3310         sock_fd = pc->cb_info->fd;
3311         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3312         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3313
3314         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3315         LOGD("ret : 0x%x", ret);
3316         return ret;
3317 }
3318
3319 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data)
3320 {
3321         if (camera == NULL || foreach_cb == NULL) {
3322                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3323                 return CAMERA_ERROR_INVALID_PARAMETER;
3324         }
3325         int ret = CAMERA_ERROR_NONE;
3326
3327         camera_cli_s *pc = (camera_cli_s *)camera;
3328         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3329
3330         LOGD("Enter, handle :%x", pc->remote_handle);
3331
3332         int sock_fd;
3333         if (pc->cb_info == NULL) {
3334                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3335                 return CAMERA_ERROR_INVALID_PARAMETER;
3336         }
3337         sock_fd = pc->cb_info->fd;
3338         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3339         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3340
3341         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3342         LOGD("ret : 0x%x", ret);
3343         return ret;
3344 }
3345
3346 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data)
3347 {
3348         if (camera == NULL || foreach_cb == NULL) {
3349                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3350                 return CAMERA_ERROR_INVALID_PARAMETER;
3351         }
3352         int ret = CAMERA_ERROR_NONE;
3353
3354         camera_cli_s *pc = (camera_cli_s *)camera;
3355         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3356
3357         LOGD("Enter, handle :%x", pc->remote_handle);
3358
3359         int sock_fd;
3360         if (pc->cb_info == NULL) {
3361                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3362                 return CAMERA_ERROR_INVALID_PARAMETER;
3363         }
3364         sock_fd = pc->cb_info->fd;
3365         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3366         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3367
3368         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3369         LOGD("ret : 0x%x", ret);
3370         return ret;
3371 }
3372
3373
3374 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data)
3375 {
3376         if (camera == NULL || foreach_cb == NULL) {
3377                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3378                 return CAMERA_ERROR_INVALID_PARAMETER;
3379         }
3380         int ret = CAMERA_ERROR_NONE;
3381
3382         camera_cli_s *pc = (camera_cli_s *)camera;
3383         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
3384
3385         LOGD("Enter, handle :%x", pc->remote_handle);
3386
3387         int sock_fd;
3388         if (pc->cb_info == NULL) {
3389                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3390                 return CAMERA_ERROR_INVALID_PARAMETER;
3391         }
3392         sock_fd = pc->cb_info->fd;
3393         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
3394         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
3395
3396         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3397         LOGD("ret : 0x%x", ret);
3398         return ret;
3399 }
3400
3401
3402 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
3403 {
3404         if (camera == NULL || width == NULL || height == NULL) {
3405                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3406                 return CAMERA_ERROR_INVALID_PARAMETER;
3407         }
3408         int ret = CAMERA_ERROR_NONE;
3409
3410         camera_cli_s *pc = (camera_cli_s *)camera;
3411         muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
3412         int sock_fd;
3413         if (pc->cb_info == NULL) {
3414                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3415                 return CAMERA_ERROR_INVALID_PARAMETER;
3416         }
3417         sock_fd = pc->cb_info->fd;
3418         int get_width;
3419         int get_height;
3420
3421         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3422         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3423
3424         if (ret == CAMERA_ERROR_NONE) {
3425                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3426                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3427                 *width = get_width;
3428                 *height = get_height;
3429         }
3430         LOGD("ret : 0x%x", ret);
3431         return ret;
3432 }
3433
3434
3435 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
3436 {
3437         if (camera == NULL || angle == NULL) {
3438                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3439                 return CAMERA_ERROR_INVALID_PARAMETER;
3440         }
3441         int ret = CAMERA_ERROR_NONE;
3442
3443         camera_cli_s *pc = (camera_cli_s *)camera;
3444         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
3445         int sock_fd;
3446         if (pc->cb_info == NULL) {
3447                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3448                 return CAMERA_ERROR_INVALID_PARAMETER;
3449         }
3450         sock_fd = pc->cb_info->fd;
3451         int get_angle;
3452
3453         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3454         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3455
3456         if (ret == CAMERA_ERROR_NONE) {
3457                 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
3458                 *angle = get_angle;
3459         }
3460         LOGD("ret : 0x%x", ret);
3461         return ret;
3462 }
3463
3464 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
3465 {
3466         if (camera == NULL) {
3467                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3468                 return CAMERA_ERROR_INVALID_PARAMETER;
3469         }
3470         int ret = CAMERA_ERROR_NONE;
3471         camera_cli_s *pc = (camera_cli_s *)camera;
3472         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
3473         int sock_fd;
3474         if (pc->cb_info == NULL) {
3475                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3476                 return CAMERA_ERROR_INVALID_PARAMETER;
3477         }
3478         sock_fd = pc->cb_info->fd;
3479         int set_mode = (int)mode;
3480         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3481         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3482         LOGD("ret : 0x%x", ret);
3483         return ret;
3484 }
3485
3486 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
3487 {
3488         if (camera == NULL || mode == NULL) {
3489                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3490                 return CAMERA_ERROR_INVALID_PARAMETER;
3491         }
3492
3493         int ret = CAMERA_ERROR_NONE;
3494         camera_cli_s *pc = (camera_cli_s *)camera;
3495         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
3496         int sock_fd;
3497         if (pc->cb_info == NULL) {
3498                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3499                 return CAMERA_ERROR_INVALID_PARAMETER;
3500         }
3501         sock_fd = pc->cb_info->fd;
3502         int get_mode;
3503         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3504         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3505
3506         if (ret == CAMERA_ERROR_NONE) {
3507                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3508                 *mode = (camera_attr_theater_mode_e)get_mode;
3509         }
3510         LOGD("ret : 0x%x", ret);
3511         return ret;
3512 }
3513
3514 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
3515 {
3516         if (camera == NULL || foreach_cb == NULL) {
3517                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3518                 return CAMERA_ERROR_INVALID_PARAMETER;
3519         }
3520         int ret = CAMERA_ERROR_NONE;
3521
3522         camera_cli_s *pc = (camera_cli_s *)camera;
3523         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
3524
3525         LOGD("Enter, handle :%x", pc->remote_handle);
3526
3527         int sock_fd;
3528         if (pc->cb_info == NULL) {
3529                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3530                 return CAMERA_ERROR_INVALID_PARAMETER;
3531         }
3532         sock_fd = pc->cb_info->fd;
3533         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
3534         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
3535
3536         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3537
3538         LOGD("Finish, return :%x", ret);
3539
3540         return ret;
3541 }
3542
3543 int camera_attr_set_preview_fps(camera_h camera,  camera_attr_fps_e fps)
3544 {
3545         if (camera == NULL) {
3546                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3547                 return CAMERA_ERROR_INVALID_PARAMETER;
3548         }
3549         int ret = CAMERA_ERROR_NONE;
3550         camera_cli_s *pc = (camera_cli_s *)camera;
3551         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
3552         int sock_fd;
3553         if (pc->cb_info == NULL) {
3554                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3555                 return CAMERA_ERROR_INVALID_PARAMETER;
3556         }
3557         sock_fd = pc->cb_info->fd;
3558         int set_fps = (int)fps;
3559         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3560         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_fps);
3561         LOGD("ret : 0x%x", ret);
3562         return ret;
3563 }
3564
3565
3566 int camera_attr_set_image_quality(camera_h camera,  int quality)
3567 {
3568         if (camera == NULL) {
3569                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3570                 return CAMERA_ERROR_INVALID_PARAMETER;
3571         }
3572         int ret = CAMERA_ERROR_NONE;
3573
3574         camera_cli_s *pc = (camera_cli_s *)camera;
3575         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
3576         int sock_fd;
3577         if (pc->cb_info == NULL) {
3578                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3579                 return CAMERA_ERROR_INVALID_PARAMETER;
3580         }
3581         sock_fd = pc->cb_info->fd;
3582         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3583         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, quality);
3584         LOGD("ret : 0x%x", ret);
3585         return ret;
3586 }
3587
3588 int camera_attr_get_preview_fps(camera_h camera,  camera_attr_fps_e *fps)
3589 {
3590         if (camera == NULL || fps == NULL) {
3591                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3592                 return CAMERA_ERROR_INVALID_PARAMETER;
3593         }
3594         int ret = CAMERA_ERROR_NONE;
3595
3596         camera_cli_s *pc = (camera_cli_s *)camera;
3597         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
3598         int get_fps;
3599         int sock_fd;
3600         if (pc->cb_info == NULL) {
3601                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3602                 return CAMERA_ERROR_INVALID_PARAMETER;
3603         }
3604         sock_fd = pc->cb_info->fd;
3605
3606         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3607         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3608
3609         if (ret == CAMERA_ERROR_NONE) {
3610                 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
3611                 *fps = (camera_attr_fps_e)get_fps;
3612         }
3613         LOGD("ret : 0x%x", ret);
3614         return ret;
3615 }
3616
3617
3618 int camera_attr_get_image_quality(camera_h camera, int *quality)
3619 {
3620         if (camera == NULL || quality == NULL) {
3621                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3622                 return CAMERA_ERROR_INVALID_PARAMETER;
3623         }
3624         int ret = CAMERA_ERROR_NONE;
3625
3626         camera_cli_s *pc = (camera_cli_s *)camera;
3627         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
3628         int sock_fd;
3629         if (pc->cb_info == NULL) {
3630                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3631                 return CAMERA_ERROR_INVALID_PARAMETER;
3632         }
3633         sock_fd = pc->cb_info->fd;
3634         int get_quality;
3635         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3636         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3637
3638         if (ret == CAMERA_ERROR_NONE) {
3639                 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
3640                 *quality = get_quality;
3641         }
3642         LOGD("ret : 0x%x", ret);
3643         return ret;
3644 }
3645
3646
3647 int camera_attr_set_zoom(camera_h camera, int zoom)
3648 {
3649         if (camera == NULL) {
3650                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3651                 return CAMERA_ERROR_INVALID_PARAMETER;
3652         }
3653         int ret = CAMERA_ERROR_NONE;
3654
3655         camera_cli_s *pc = (camera_cli_s *)camera;
3656         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
3657         int sock_fd;
3658         if (pc->cb_info == NULL) {
3659                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3660                 return CAMERA_ERROR_INVALID_PARAMETER;
3661         }
3662         sock_fd = pc->cb_info->fd;
3663
3664         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3665         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, zoom);
3666         LOGD("ret : 0x%x", ret);
3667         return ret;
3668 }
3669
3670 int camera_attr_set_af_mode(camera_h camera,  camera_attr_af_mode_e mode)
3671 {
3672         if (camera == NULL) {
3673                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3674                 return CAMERA_ERROR_INVALID_PARAMETER;
3675         }
3676         int ret = CAMERA_ERROR_NONE;
3677
3678         camera_cli_s *pc = (camera_cli_s *)camera;
3679         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
3680         int sock_fd;
3681         if (pc->cb_info == NULL) {
3682                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3683                 return CAMERA_ERROR_INVALID_PARAMETER;
3684         }
3685         sock_fd = pc->cb_info->fd;
3686         int set_mode = (int)mode;
3687         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3688         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3689         LOGD("ret : 0x%x", ret);
3690         return ret;
3691 }
3692
3693 int camera_attr_set_af_area(camera_h camera, int x, int y)
3694 {
3695         if (camera == NULL) {
3696                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3697                 return CAMERA_ERROR_INVALID_PARAMETER;
3698         }
3699         int ret = CAMERA_ERROR_NONE;
3700         camera_cli_s *pc = (camera_cli_s *)camera;
3701         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
3702         int sock_fd = pc->cb_info->fd;
3703         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3704         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, x, INT, y);
3705         LOGD("ret : 0x%x", ret);
3706         return ret;
3707 }
3708
3709
3710 int camera_attr_clear_af_area(camera_h camera)
3711 {
3712         if (camera == NULL) {
3713                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3714                 return CAMERA_ERROR_INVALID_PARAMETER;
3715         }
3716         int ret = CAMERA_ERROR_NONE;
3717
3718         camera_cli_s *pc = (camera_cli_s *)camera;
3719         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
3720         int sock_fd;
3721         if (pc->cb_info == NULL) {
3722                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3723                 return CAMERA_ERROR_INVALID_PARAMETER;
3724         }
3725         sock_fd = pc->cb_info->fd;
3726         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3727         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3728         LOGD("ret : 0x%x", ret);
3729         return ret;
3730 }
3731
3732
3733 int camera_attr_set_exposure_mode(camera_h camera,  camera_attr_exposure_mode_e mode)
3734 {
3735         if (camera == NULL) {
3736                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3737                 return CAMERA_ERROR_INVALID_PARAMETER;
3738         }
3739
3740         if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
3741                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3742                 return CAMERA_ERROR_INVALID_PARAMETER;
3743         }
3744
3745         int ret = CAMERA_ERROR_NONE;
3746         camera_cli_s *pc = (camera_cli_s *)camera;
3747         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
3748         int set_mode = (int)mode;
3749         int sock_fd;
3750         if (pc->cb_info == NULL) {
3751                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3752                 return CAMERA_ERROR_INVALID_PARAMETER;
3753         }
3754         sock_fd = pc->cb_info->fd;
3755         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3756         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3757         LOGD("ret : 0x%x", ret);
3758         return ret;
3759 }
3760
3761
3762 int camera_attr_set_exposure(camera_h camera, int value)
3763 {
3764         if (camera == NULL) {
3765                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3766                 return CAMERA_ERROR_INVALID_PARAMETER;
3767         }
3768         int ret = CAMERA_ERROR_NONE;
3769
3770         camera_cli_s *pc = (camera_cli_s *)camera;
3771         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
3772         int sock_fd;
3773         if (pc->cb_info == NULL) {
3774                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3775                 return CAMERA_ERROR_INVALID_PARAMETER;
3776         }
3777         sock_fd = pc->cb_info->fd;
3778
3779         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3780         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, value);
3781         LOGD("ret : 0x%x", ret);
3782         return ret;
3783 }
3784
3785
3786 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
3787 {
3788         if (camera == NULL) {
3789                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3790                 return CAMERA_ERROR_INVALID_PARAMETER;
3791         }
3792         int ret = CAMERA_ERROR_NONE;
3793
3794         camera_cli_s *pc = (camera_cli_s *)camera;
3795         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
3796         int sock_fd;
3797         if (pc->cb_info == NULL) {
3798                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3799                 return CAMERA_ERROR_INVALID_PARAMETER;
3800         }
3801         sock_fd = pc->cb_info->fd;
3802         int set_iso = (int)iso;
3803         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3804         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_iso);
3805         LOGD("ret : 0x%x", ret);
3806         return ret;
3807 }
3808
3809
3810 int camera_attr_set_brightness(camera_h camera, int level)
3811 {
3812         if (camera == NULL) {
3813                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3814                 return CAMERA_ERROR_INVALID_PARAMETER;
3815         }
3816         int ret = CAMERA_ERROR_NONE;
3817
3818         camera_cli_s *pc = (camera_cli_s *)camera;
3819         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
3820         int sock_fd;
3821         if (pc->cb_info == NULL) {
3822                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3823                 return CAMERA_ERROR_INVALID_PARAMETER;
3824         }
3825         sock_fd = pc->cb_info->fd;
3826
3827         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3828         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
3829         LOGD("ret : 0x%x", ret);
3830         return ret;
3831 }
3832
3833
3834 int camera_attr_set_contrast(camera_h camera, int level)
3835 {
3836         if (camera == NULL) {
3837                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3838                 return CAMERA_ERROR_INVALID_PARAMETER;
3839         }
3840         int ret = CAMERA_ERROR_NONE;
3841
3842         camera_cli_s *pc = (camera_cli_s *)camera;
3843         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
3844         int sock_fd;
3845         if (pc->cb_info == NULL) {
3846                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3847                 return CAMERA_ERROR_INVALID_PARAMETER;
3848         }
3849         sock_fd = pc->cb_info->fd;
3850
3851         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3852         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
3853         LOGD("ret : 0x%x", ret);
3854         return ret;
3855 }
3856
3857
3858 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
3859 {
3860         if (camera == NULL) {
3861                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3862                 return CAMERA_ERROR_INVALID_PARAMETER;
3863         }
3864
3865         if (wb < CAMERA_ATTR_WHITE_BALANCE_NONE || wb > CAMERA_ATTR_WHITE_BALANCE_CUSTOM) {
3866                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3867                 return CAMERA_ERROR_NOT_SUPPORTED;
3868         }
3869
3870         int ret = CAMERA_ERROR_NONE;
3871
3872         camera_cli_s *pc = (camera_cli_s *)camera;
3873         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
3874         int sock_fd;
3875         if (pc->cb_info == NULL) {
3876                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3877                 return CAMERA_ERROR_INVALID_PARAMETER;
3878         }
3879         sock_fd = pc->cb_info->fd;
3880         int set_whitebalance = (int)wb;
3881         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3882         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_whitebalance);
3883         LOGD("ret : 0x%x", ret);
3884         return ret;
3885 }
3886
3887
3888 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
3889 {
3890         if (camera == NULL) {
3891                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3892                 return CAMERA_ERROR_INVALID_PARAMETER;
3893         }
3894         int ret = CAMERA_ERROR_NONE;
3895
3896         camera_cli_s *pc = (camera_cli_s *)camera;
3897         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
3898         int sock_fd;
3899         if (pc->cb_info == NULL) {
3900                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3901                 return CAMERA_ERROR_INVALID_PARAMETER;
3902         }
3903         sock_fd = pc->cb_info->fd;
3904         int set_effect = (int)effect;
3905         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3906         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_effect);
3907         LOGD("ret : 0x%x", ret);
3908         return ret;
3909 }
3910
3911
3912 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
3913 {
3914         if (camera == NULL) {
3915                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3916                 return CAMERA_ERROR_INVALID_PARAMETER;
3917         }
3918         int ret = CAMERA_ERROR_NONE;
3919
3920         camera_cli_s *pc = (camera_cli_s *)camera;
3921         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
3922         int sock_fd;
3923         if (pc->cb_info == NULL) {
3924                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3925                 return CAMERA_ERROR_INVALID_PARAMETER;
3926         }
3927         sock_fd = pc->cb_info->fd;
3928         int set_mode = (int)mode;
3929         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3930         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3931         LOGD("ret : 0x%x", ret);
3932         return ret;
3933 }
3934
3935
3936 int camera_attr_enable_tag(camera_h camera, bool enable)
3937 {
3938         if (camera == NULL) {
3939                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3940                 return CAMERA_ERROR_INVALID_PARAMETER;
3941         }
3942         int ret = CAMERA_ERROR_NONE;
3943         camera_cli_s *pc = (camera_cli_s *)camera;
3944         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
3945         int sock_fd;
3946         if (pc->cb_info == NULL) {
3947                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3948                 return CAMERA_ERROR_INVALID_PARAMETER;
3949         }
3950         sock_fd = pc->cb_info->fd;
3951         int set_enable = (int)enable;
3952
3953         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3954         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
3955         LOGD("ret : 0x%x", ret);
3956         return ret;
3957 }
3958
3959
3960 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
3961 {
3962         if (camera == NULL) {
3963                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3964                 return CAMERA_ERROR_INVALID_PARAMETER;
3965         }
3966         if (description == NULL) {
3967                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3968                 return CAMERA_ERROR_INVALID_PARAMETER;
3969         }
3970         int ret = CAMERA_ERROR_NONE;
3971         camera_cli_s *pc = (camera_cli_s *)camera;
3972         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
3973         int sock_fd;
3974         if (pc->cb_info == NULL) {
3975                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3976                 return CAMERA_ERROR_INVALID_PARAMETER;
3977         }
3978         sock_fd = pc->cb_info->fd;
3979         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3980         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, description);
3981         LOGD("ret : 0x%x", ret);
3982         return ret;
3983 }
3984
3985
3986 int camera_attr_set_tag_orientation(camera_h camera,  camera_attr_tag_orientation_e orientation)
3987 {
3988         if (camera == NULL) {
3989                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3990                 return CAMERA_ERROR_INVALID_PARAMETER;
3991         }
3992         int ret = CAMERA_ERROR_NONE;
3993         camera_cli_s *pc = (camera_cli_s *)camera;
3994         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
3995         int sock_fd;
3996         if (pc->cb_info == NULL) {
3997                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3998                 return CAMERA_ERROR_INVALID_PARAMETER;
3999         }
4000         sock_fd = pc->cb_info->fd;
4001         int set_orientation = (int)orientation;
4002
4003         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4004         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_orientation);
4005         LOGD("ret : 0x%x", ret);
4006         return ret;
4007 }
4008
4009
4010 int camera_attr_set_tag_software(camera_h camera,  const char *software)
4011 {
4012         if (camera == NULL) {
4013                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4014                 return CAMERA_ERROR_INVALID_PARAMETER;
4015         }
4016         if (software == NULL) {
4017                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4018                 return CAMERA_ERROR_INVALID_PARAMETER;
4019         }
4020         int ret = CAMERA_ERROR_NONE;
4021         camera_cli_s *pc = (camera_cli_s *)camera;
4022         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4023         int sock_fd;
4024         if (pc->cb_info == NULL) {
4025                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4026                 return CAMERA_ERROR_INVALID_PARAMETER;
4027         }
4028         sock_fd = pc->cb_info->fd;
4029         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4030         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, software);
4031         LOGD("ret : 0x%x", ret);
4032         return ret;
4033 }
4034
4035
4036 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
4037 {
4038         if (camera == NULL) {
4039                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4040                 return CAMERA_ERROR_INVALID_PARAMETER;
4041         }
4042         int ret = CAMERA_ERROR_NONE;
4043         camera_cli_s *pc = (camera_cli_s *)camera;
4044         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4045         int sock_fd;
4046         if (pc->cb_info == NULL) {
4047                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4048                 return CAMERA_ERROR_INVALID_PARAMETER;
4049         }
4050         sock_fd = pc->cb_info->fd;
4051         double set_geotag[3] = { latitude, longitude, altitude };
4052
4053         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4054         muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
4055                                                                         set_geotag, sizeof(set_geotag), sizeof(double));
4056         LOGD("ret : 0x%x", ret);
4057         return ret;
4058 }
4059
4060
4061 int camera_attr_remove_geotag(camera_h camera)
4062 {
4063         if (camera == NULL) {
4064                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4065                 return CAMERA_ERROR_INVALID_PARAMETER;
4066         }
4067         int ret = CAMERA_ERROR_NONE;
4068         camera_cli_s *pc = (camera_cli_s *)camera;
4069         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4070         int sock_fd;
4071         if (pc->cb_info == NULL) {
4072                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4073                 return CAMERA_ERROR_INVALID_PARAMETER;
4074         }
4075         sock_fd = pc->cb_info->fd;
4076         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4077         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4078         LOGD("ret : 0x%x", ret);
4079         return ret;
4080 }
4081
4082
4083 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4084 {
4085         if (camera == NULL) {
4086                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4087                 return CAMERA_ERROR_INVALID_PARAMETER;
4088         }
4089         int ret = CAMERA_ERROR_NONE;
4090         camera_cli_s *pc = (camera_cli_s *)camera;
4091         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4092         int sock_fd;
4093         if (pc->cb_info == NULL) {
4094                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4095                 return CAMERA_ERROR_INVALID_PARAMETER;
4096         }
4097         sock_fd = pc->cb_info->fd;
4098         int set_mode = (int)mode;
4099
4100         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4101         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4102         LOGD("ret : 0x%x", ret);
4103         return ret;
4104 }
4105
4106
4107 int camera_attr_get_zoom(camera_h camera, int *zoom)
4108 {
4109         if (camera == NULL || zoom == NULL) {
4110                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4111                 return CAMERA_ERROR_INVALID_PARAMETER;
4112         }
4113         int ret = CAMERA_ERROR_NONE;
4114
4115         camera_cli_s *pc = (camera_cli_s *)camera;
4116         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4117         int get_zoom;
4118         int sock_fd;
4119         if (pc->cb_info == NULL) {
4120                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4121                 return CAMERA_ERROR_INVALID_PARAMETER;
4122         }
4123         sock_fd = pc->cb_info->fd;
4124
4125         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4126         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4127
4128         if (ret == CAMERA_ERROR_NONE) {
4129                 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4130                 *zoom = get_zoom;
4131         }
4132         LOGD("ret : 0x%x", ret);
4133         return ret;
4134 }
4135
4136
4137 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4138 {
4139         if (camera == NULL || min == NULL || max == NULL) {
4140                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4141                 return CAMERA_ERROR_INVALID_PARAMETER;
4142         }
4143         int ret = CAMERA_ERROR_NONE;
4144         camera_cli_s *pc = (camera_cli_s *)camera;
4145         int sock_fd;
4146         if (pc->cb_info == NULL) {
4147                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4148                 return CAMERA_ERROR_INVALID_PARAMETER;
4149         }
4150         sock_fd = pc->cb_info->fd;
4151         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4152         int get_min;
4153         int get_max;
4154
4155         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4156         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4157
4158         if (ret == CAMERA_ERROR_NONE) {
4159                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4160                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4161                 *min = get_min;
4162                 *max = get_max;
4163         }
4164         LOGD("ret : 0x%x", ret);
4165         return ret;
4166 }
4167
4168
4169 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4170 {
4171         if (camera == NULL || mode == NULL) {
4172                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4173                 return CAMERA_ERROR_INVALID_PARAMETER;
4174         }
4175         int ret = CAMERA_ERROR_NONE;
4176         camera_cli_s *pc = (camera_cli_s *)camera;
4177         int sock_fd;
4178         if (pc->cb_info == NULL) {
4179                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4180                 return CAMERA_ERROR_INVALID_PARAMETER;
4181         }
4182         sock_fd = pc->cb_info->fd;
4183         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4184         int get_mode;
4185
4186         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4187         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4188
4189         if (ret == CAMERA_ERROR_NONE) {
4190                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4191                 *mode = (camera_attr_af_mode_e)get_mode;
4192         }
4193         LOGD("ret : 0x%x", ret);
4194         return ret;
4195 }
4196
4197
4198 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4199 {
4200         if (camera == NULL || mode == NULL) {
4201                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4202                 return CAMERA_ERROR_INVALID_PARAMETER;
4203         }
4204         int ret = CAMERA_ERROR_NONE;
4205         camera_cli_s *pc = (camera_cli_s *)camera;
4206         int sock_fd;
4207         if (pc->cb_info == NULL) {
4208                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4209                 return CAMERA_ERROR_INVALID_PARAMETER;
4210         }
4211         sock_fd = pc->cb_info->fd;
4212         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4213         int get_mode;
4214
4215         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4216         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4217
4218         if (ret == CAMERA_ERROR_NONE) {
4219                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4220                 *mode = (camera_attr_exposure_mode_e)get_mode;
4221         }
4222         LOGD("ret : 0x%x", ret);
4223         return ret;
4224 }
4225
4226 int camera_attr_get_exposure(camera_h camera, int *value)
4227 {
4228         if (camera == NULL || value == NULL) {
4229                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4230                 return CAMERA_ERROR_INVALID_PARAMETER;
4231         }
4232         int ret = CAMERA_ERROR_NONE;
4233         camera_cli_s *pc = (camera_cli_s *)camera;
4234         int sock_fd;
4235         if (pc->cb_info == NULL) {
4236                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4237                 return CAMERA_ERROR_INVALID_PARAMETER;
4238         }
4239         sock_fd = pc->cb_info->fd;
4240         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4241         int get_value;
4242
4243         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4244         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4245
4246         if (ret == CAMERA_ERROR_NONE) {
4247                 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4248                 *value = get_value;
4249         }
4250         LOGD("ret : 0x%x", ret);
4251         return ret;
4252 }
4253
4254
4255 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4256 {
4257         if (camera == NULL || min == NULL || max == NULL) {
4258                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4259                 return CAMERA_ERROR_INVALID_PARAMETER;
4260         }
4261         int ret = CAMERA_ERROR_NONE;
4262         camera_cli_s *pc = (camera_cli_s *)camera;
4263         int sock_fd;
4264         if (pc->cb_info == NULL) {
4265                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4266                 return CAMERA_ERROR_INVALID_PARAMETER;
4267         }
4268         sock_fd = pc->cb_info->fd;
4269         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4270         int get_min;
4271         int get_max;
4272
4273         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4274         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4275
4276         if (ret == CAMERA_ERROR_NONE) {
4277                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4278                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4279                 *min = get_min;
4280                 *max = get_max;
4281         }
4282         LOGD("ret : 0x%x", ret);
4283         return ret;
4284 }
4285
4286
4287 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4288 {
4289         if (camera == NULL || iso == NULL) {
4290                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4291                 return CAMERA_ERROR_INVALID_PARAMETER;
4292         }
4293         int ret = CAMERA_ERROR_NONE;
4294         camera_cli_s *pc = (camera_cli_s *)camera;
4295         int sock_fd;
4296         if (pc->cb_info == NULL) {
4297                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4298                 return CAMERA_ERROR_INVALID_PARAMETER;
4299         }
4300         sock_fd = pc->cb_info->fd;
4301         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4302         int get_iso;
4303
4304         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4305         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4306
4307         if (ret == CAMERA_ERROR_NONE) {
4308                 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
4309                 *iso = (camera_attr_iso_e)get_iso;
4310         }
4311         LOGD("ret : 0x%x", ret);
4312         return ret;
4313 }
4314
4315
4316 int camera_attr_get_brightness(camera_h camera,  int *level)
4317 {
4318         if (camera == NULL || level == NULL) {
4319                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4320                 return CAMERA_ERROR_INVALID_PARAMETER;
4321         }
4322         int ret = CAMERA_ERROR_NONE;
4323         camera_cli_s *pc = (camera_cli_s *)camera;
4324         int sock_fd;
4325         if (pc->cb_info == NULL) {
4326                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4327                 return CAMERA_ERROR_INVALID_PARAMETER;
4328         }
4329         sock_fd = pc->cb_info->fd;
4330         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4331         int get_level;
4332
4333         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4334         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4335
4336         if (ret == CAMERA_ERROR_NONE) {
4337                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4338                 *level = get_level;
4339         }
4340         LOGD("ret : 0x%x", ret);
4341         return ret;
4342 }
4343
4344
4345 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
4346 {
4347         if (camera == NULL || min == NULL || max == NULL) {
4348                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4349                 return CAMERA_ERROR_INVALID_PARAMETER;
4350         }
4351         int ret = CAMERA_ERROR_NONE;
4352         camera_cli_s *pc = (camera_cli_s *)camera;
4353         int sock_fd;
4354         if (pc->cb_info == NULL) {
4355                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4356                 return CAMERA_ERROR_INVALID_PARAMETER;
4357         }
4358         sock_fd = pc->cb_info->fd;
4359         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
4360         int get_min;
4361         int get_max;
4362
4363         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4364         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4365
4366         if (ret == CAMERA_ERROR_NONE) {
4367                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4368                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4369                 *min = get_min;
4370                 *max = get_max;
4371         }
4372         LOGD("ret : 0x%x", ret);
4373         return ret;
4374 }
4375
4376
4377 int camera_attr_get_contrast(camera_h camera,  int *level)
4378 {
4379         if (camera == NULL || level == NULL) {
4380                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4381                 return CAMERA_ERROR_INVALID_PARAMETER;
4382         }
4383         int ret = CAMERA_ERROR_NONE;
4384         camera_cli_s *pc = (camera_cli_s *)camera;
4385         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
4386         int sock_fd;
4387         if (pc->cb_info == NULL) {
4388                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4389                 return CAMERA_ERROR_INVALID_PARAMETER;
4390         }
4391         sock_fd = pc->cb_info->fd;
4392         int get_level;
4393
4394         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4395         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4396
4397         if (ret == CAMERA_ERROR_NONE) {
4398                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4399                 *level = get_level;
4400         }
4401         LOGD("ret : 0x%x", ret);
4402         return ret;
4403 }
4404
4405
4406 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max)
4407 {
4408         if (camera == NULL || min == NULL || max == NULL) {
4409                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4410                 return CAMERA_ERROR_INVALID_PARAMETER;
4411         }
4412         int ret = CAMERA_ERROR_NONE;
4413         camera_cli_s *pc = (camera_cli_s *)camera;
4414         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
4415         int sock_fd;
4416         if (pc->cb_info == NULL) {
4417                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4418                 return CAMERA_ERROR_INVALID_PARAMETER;
4419         }
4420         sock_fd = pc->cb_info->fd;
4421         int get_min;
4422         int get_max;
4423
4424         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4425         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4426
4427         if (ret == CAMERA_ERROR_NONE) {
4428                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4429                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4430                 *min = get_min;
4431                 *max = get_max;
4432         }
4433         LOGD("ret : 0x%x", ret);
4434         return ret;
4435 }
4436
4437
4438 int camera_attr_get_whitebalance(camera_h camera,  camera_attr_whitebalance_e *wb)
4439 {
4440         if (camera == NULL || wb == NULL) {
4441                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4442                 return CAMERA_ERROR_INVALID_PARAMETER;
4443         }
4444         int ret = CAMERA_ERROR_NONE;
4445         camera_cli_s *pc = (camera_cli_s *)camera;
4446         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
4447         int sock_fd;
4448         if (pc->cb_info == NULL) {
4449                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4450                 return CAMERA_ERROR_INVALID_PARAMETER;
4451         }
4452         sock_fd = pc->cb_info->fd;
4453         int get_wb;
4454
4455         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4456         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4457
4458         if (ret == CAMERA_ERROR_NONE) {
4459                 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
4460                 *wb = (camera_attr_whitebalance_e)get_wb;
4461         }
4462         LOGD("ret : 0x%x", ret);
4463         return ret;
4464 }
4465
4466
4467 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
4468 {
4469         if (camera == NULL || effect == NULL) {
4470                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4471                 return CAMERA_ERROR_INVALID_PARAMETER;
4472         }
4473
4474         int ret = CAMERA_ERROR_NONE;
4475         camera_cli_s *pc = (camera_cli_s *)camera;
4476         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
4477         int sock_fd;
4478         if (pc->cb_info == NULL) {
4479                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4480                 return CAMERA_ERROR_INVALID_PARAMETER;
4481         }
4482         sock_fd = pc->cb_info->fd;
4483         int get_effect;
4484
4485         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4486         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4487
4488         if (ret == CAMERA_ERROR_NONE) {
4489                 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
4490                 *effect = (camera_attr_effect_mode_e)get_effect;
4491         }
4492         LOGD("ret : 0x%x", ret);
4493         return ret;
4494 }
4495
4496
4497 int camera_attr_get_scene_mode(camera_h camera,  camera_attr_scene_mode_e *mode)
4498 {
4499         if (camera == NULL || mode == NULL) {
4500                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4501                 return CAMERA_ERROR_INVALID_PARAMETER;
4502         }
4503
4504         int ret = CAMERA_ERROR_NONE;
4505         camera_cli_s *pc = (camera_cli_s *)camera;
4506         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
4507         int sock_fd;
4508         if (pc->cb_info == NULL) {
4509                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4510                 return CAMERA_ERROR_INVALID_PARAMETER;
4511         }
4512         sock_fd = pc->cb_info->fd;
4513         int get_mode;
4514
4515         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4516         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4517
4518         if (ret == CAMERA_ERROR_NONE) {
4519                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4520                 *mode = (camera_attr_scene_mode_e)get_mode;
4521         }
4522         LOGD("ret : 0x%x", ret);
4523         return ret;
4524 }
4525
4526
4527 int camera_attr_is_enabled_tag(camera_h camera,  bool *enable)
4528 {
4529         if (camera == NULL || enable == NULL) {
4530                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4531                 return CAMERA_ERROR_INVALID_PARAMETER;
4532         }
4533
4534         int ret = CAMERA_ERROR_NONE;
4535         camera_cli_s *pc = (camera_cli_s *)camera;
4536         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
4537         int sock_fd;
4538         if (pc->cb_info == NULL) {
4539                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4540                 return CAMERA_ERROR_INVALID_PARAMETER;
4541         }
4542         sock_fd = pc->cb_info->fd;
4543         int get_enabled;
4544
4545         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4546         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4547
4548         if (ret == CAMERA_ERROR_NONE) {
4549                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
4550                 *enable = (bool)get_enabled;
4551         }
4552         LOGD("ret : 0x%x", ret);
4553         return ret;
4554 }
4555
4556
4557 int camera_attr_get_tag_image_description(camera_h camera,  char **description)
4558 {
4559         if (camera == NULL || description == NULL) {
4560                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4561                 return CAMERA_ERROR_INVALID_PARAMETER;
4562         }
4563
4564         int ret = CAMERA_ERROR_NONE;
4565         camera_cli_s *pc = (camera_cli_s *)camera;
4566         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
4567         int sock_fd;
4568         if (pc->cb_info == NULL) {
4569                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4570                 return CAMERA_ERROR_INVALID_PARAMETER;
4571         }
4572         sock_fd = pc->cb_info->fd;
4573         char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
4574
4575         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4576         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4577
4578         if (ret == CAMERA_ERROR_NONE) {
4579                 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
4580                 *description = strdup(get_description);
4581         }
4582         LOGD("ret : 0x%x", ret);
4583         return ret;
4584 }
4585
4586
4587 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
4588 {
4589         if (camera == NULL || orientation == NULL) {
4590                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4591                 return CAMERA_ERROR_INVALID_PARAMETER;
4592         }
4593
4594         int ret = CAMERA_ERROR_NONE;
4595         camera_cli_s *pc = (camera_cli_s *)camera;
4596         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
4597         int sock_fd;
4598         if (pc->cb_info == NULL) {
4599                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4600                 return CAMERA_ERROR_INVALID_PARAMETER;
4601         }
4602         sock_fd = pc->cb_info->fd;
4603         int get_orientation;
4604
4605         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4606         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4607
4608         if (ret == CAMERA_ERROR_NONE) {
4609                 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
4610                 *orientation = (camera_attr_tag_orientation_e)get_orientation;
4611                 LOGD("success, orientation : %d", *orientation);
4612         }
4613         LOGD("ret : 0x%x", ret);
4614         return ret;
4615 }
4616
4617
4618 int camera_attr_get_tag_software(camera_h camera, char **software)
4619 {
4620         if (camera == NULL || software == NULL) {
4621                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4622                 return CAMERA_ERROR_INVALID_PARAMETER;
4623         }
4624
4625         int ret = CAMERA_ERROR_NONE;
4626         camera_cli_s *pc = (camera_cli_s *)camera;
4627         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
4628         int sock_fd;
4629         if (pc->cb_info == NULL) {
4630                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4631                 return CAMERA_ERROR_INVALID_PARAMETER;
4632         }
4633         sock_fd = pc->cb_info->fd;
4634         char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
4635
4636         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4637         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4638
4639         if (ret == CAMERA_ERROR_NONE) {
4640                 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
4641                 *software = strdup(get_software);
4642         }
4643         LOGD("ret : 0x%x", ret);
4644         return ret;
4645 }
4646
4647
4648 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
4649 {
4650         if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
4651                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4652                 return CAMERA_ERROR_INVALID_PARAMETER;
4653         }
4654
4655         int ret = CAMERA_ERROR_NONE;
4656         camera_cli_s *pc = (camera_cli_s *)camera;
4657         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
4658         double get_geotag[3] = {0,};
4659         int sock_fd;
4660         if (pc->cb_info == NULL) {
4661                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4662                 return CAMERA_ERROR_INVALID_PARAMETER;
4663         }
4664         sock_fd = pc->cb_info->fd;
4665         int valid = 0;
4666         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4667         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4668
4669         if (ret == CAMERA_ERROR_NONE) {
4670                 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
4671                 *latitude = get_geotag[0];
4672                 *longitude = get_geotag[1];
4673                 *altitude = get_geotag[2];
4674         } else {
4675                 LOGE("Returned value is not valid : 0x%x", valid);
4676         }
4677
4678         LOGD("ret : 0x%x", ret);
4679
4680         return ret;
4681 }
4682
4683
4684 int camera_attr_get_flash_mode(camera_h camera,  camera_attr_flash_mode_e *mode)
4685 {
4686         if (camera == NULL || mode == NULL) {
4687                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4688                 return CAMERA_ERROR_INVALID_PARAMETER;
4689         }
4690
4691         int ret = CAMERA_ERROR_NONE;
4692         camera_cli_s *pc = (camera_cli_s *)camera;
4693         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
4694         int sock_fd;
4695         if (pc->cb_info == NULL) {
4696                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4697                 return CAMERA_ERROR_INVALID_PARAMETER;
4698         }
4699         sock_fd = pc->cb_info->fd;
4700         int get_mode;
4701
4702         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4703         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4704
4705         if (ret == CAMERA_ERROR_NONE) {
4706                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4707                 *mode = (camera_attr_flash_mode_e)get_mode;
4708         }
4709         LOGD("ret : 0x%x", ret);
4710         return ret;
4711 }
4712
4713
4714 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
4715 {
4716         if (camera == NULL || foreach_cb == NULL) {
4717                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4718                 return CAMERA_ERROR_INVALID_PARAMETER;
4719         }
4720         int ret = CAMERA_ERROR_NONE;
4721
4722         camera_cli_s *pc = (camera_cli_s *)camera;
4723         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
4724
4725         LOGD("Enter, handle :%x", pc->remote_handle);
4726
4727         int sock_fd;
4728         if (pc->cb_info == NULL) {
4729                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4730                 return CAMERA_ERROR_INVALID_PARAMETER;
4731         }
4732         sock_fd = pc->cb_info->fd;
4733         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
4734         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
4735
4736         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4737         LOGD("ret : 0x%x", ret);
4738         return ret;
4739 }
4740
4741
4742 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data)
4743 {
4744         if (camera == NULL || foreach_cb == NULL) {
4745                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4746                 return CAMERA_ERROR_INVALID_PARAMETER;
4747         }
4748         int ret = CAMERA_ERROR_NONE;
4749
4750         camera_cli_s *pc = (camera_cli_s *)camera;
4751         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
4752
4753         LOGD("Enter, handle :%x", pc->remote_handle);
4754
4755         int sock_fd;
4756         if (pc->cb_info == NULL) {
4757                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4758                 return CAMERA_ERROR_INVALID_PARAMETER;
4759         }
4760         sock_fd = pc->cb_info->fd;
4761         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
4762         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
4763
4764         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4765         LOGD("ret : 0x%x", ret);
4766         return ret;
4767 }
4768
4769
4770 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
4771 {
4772         if (camera == NULL || foreach_cb == NULL) {
4773                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4774                 return CAMERA_ERROR_INVALID_PARAMETER;
4775         }
4776         int ret = CAMERA_ERROR_NONE;
4777
4778         camera_cli_s *pc = (camera_cli_s *)camera;
4779         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
4780
4781         LOGD("Enter, handle :%x", pc->remote_handle);
4782
4783         int sock_fd;
4784         if (pc->cb_info == NULL) {
4785                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4786                 return CAMERA_ERROR_INVALID_PARAMETER;
4787         }
4788         sock_fd = pc->cb_info->fd;
4789         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
4790         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
4791
4792         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4793         LOGD("ret : 0x%x", ret);
4794         return ret;
4795 }
4796
4797
4798 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data)
4799 {
4800         if (camera == NULL || foreach_cb == NULL) {
4801                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4802                 return CAMERA_ERROR_INVALID_PARAMETER;
4803         }
4804         int ret = CAMERA_ERROR_NONE;
4805
4806         camera_cli_s *pc = (camera_cli_s *)camera;
4807         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
4808
4809         LOGD("Enter, handle :%x", pc->remote_handle);
4810
4811         int sock_fd;
4812         if (pc->cb_info == NULL) {
4813                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4814                 return CAMERA_ERROR_INVALID_PARAMETER;
4815         }
4816         sock_fd = pc->cb_info->fd;
4817         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
4818         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
4819
4820         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4821         LOGD("ret : 0x%x", ret);
4822         return ret;
4823 }
4824
4825
4826 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data)
4827 {
4828         if (camera == NULL || foreach_cb == NULL) {
4829                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4830                 return CAMERA_ERROR_INVALID_PARAMETER;
4831         }
4832         int ret = CAMERA_ERROR_NONE;
4833
4834         camera_cli_s *pc = (camera_cli_s *)camera;
4835         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
4836
4837         LOGD("Enter, handle :%x", pc->remote_handle);
4838
4839         int sock_fd;
4840         if (pc->cb_info == NULL) {
4841                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4842                 return CAMERA_ERROR_INVALID_PARAMETER;
4843         }
4844         sock_fd = pc->cb_info->fd;
4845         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
4846         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
4847
4848         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4849         LOGD("ret : 0x%x", ret);
4850         return ret;
4851 }
4852
4853
4854 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data)
4855 {
4856         if (camera == NULL || foreach_cb == NULL) {
4857                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4858                 return CAMERA_ERROR_INVALID_PARAMETER;
4859         }
4860         int ret = CAMERA_ERROR_NONE;
4861
4862         camera_cli_s *pc = (camera_cli_s *)camera;
4863         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
4864
4865         LOGD("Enter, handle :%x", pc->remote_handle);
4866
4867         int sock_fd;
4868         if (pc->cb_info == NULL) {
4869                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4870                 return CAMERA_ERROR_INVALID_PARAMETER;
4871         }
4872         sock_fd = pc->cb_info->fd;
4873         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
4874         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
4875
4876         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4877         LOGD("ret : 0x%x", ret);
4878         return ret;
4879 }
4880
4881
4882 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data)
4883 {
4884         if (camera == NULL || foreach_cb == NULL) {
4885                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4886                 return CAMERA_ERROR_INVALID_PARAMETER;
4887         }
4888         int ret = CAMERA_ERROR_NONE;
4889
4890         camera_cli_s *pc = (camera_cli_s *)camera;
4891         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
4892
4893         LOGD("Enter, handle :%x", pc->remote_handle);
4894
4895         int sock_fd;
4896         if (pc->cb_info == NULL) {
4897                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4898                 return CAMERA_ERROR_INVALID_PARAMETER;
4899         }
4900         sock_fd = pc->cb_info->fd;
4901         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
4902         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
4903
4904         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4905         LOGD("ret : 0x%x", ret);
4906         return ret;
4907 }
4908
4909
4910 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data)
4911 {
4912         if (camera == NULL || foreach_cb == NULL) {
4913                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4914                 return CAMERA_ERROR_INVALID_PARAMETER;
4915         }
4916         int ret = CAMERA_ERROR_NONE;
4917
4918         camera_cli_s *pc = (camera_cli_s *)camera;
4919         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
4920         int sock_fd;
4921         if (pc->cb_info == NULL) {
4922                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4923                 return CAMERA_ERROR_INVALID_PARAMETER;
4924         }
4925         sock_fd = pc->cb_info->fd;
4926         LOGD("Enter, handle :%x", pc->remote_handle);
4927         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
4928         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
4929
4930         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4931         LOGD("Enter, handle :%x", pc->remote_handle);
4932         return ret;
4933 }
4934
4935 int camera_attr_foreach_supported_fps_by_resolution(camera_h camera, int width, int height, camera_attr_supported_fps_cb foreach_cb, void *user_data)
4936 {
4937         if (camera == NULL || foreach_cb == NULL) {
4938                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4939                 return CAMERA_ERROR_INVALID_PARAMETER;
4940         }
4941         int ret = CAMERA_ERROR_NONE;
4942
4943         camera_cli_s *pc = (camera_cli_s *)camera;
4944         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
4945         int sock_fd;
4946         if (pc->cb_info == NULL) {
4947                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4948                 return CAMERA_ERROR_INVALID_PARAMETER;
4949         }
4950         sock_fd = pc->cb_info->fd;
4951         LOGD("Enter, handle :%x", pc->remote_handle);
4952         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
4953         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
4954
4955         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
4956         LOGD("ret : 0x%x", ret);
4957         return ret;
4958 }
4959
4960 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
4961 {
4962         if (camera == NULL || foreach_cb == NULL) {
4963                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4964                 return CAMERA_ERROR_INVALID_PARAMETER;
4965         }
4966         int ret = CAMERA_ERROR_NONE;
4967
4968         camera_cli_s *pc = (camera_cli_s *)camera;
4969         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
4970         int sock_fd;
4971         if (pc->cb_info == NULL) {
4972                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4973                 return CAMERA_ERROR_INVALID_PARAMETER;
4974         }
4975         sock_fd = pc->cb_info->fd;
4976         LOGD("Enter, handle :%x", pc->remote_handle);
4977         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
4978         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
4979
4980         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4981         LOGD("ret : 0x%x", ret);
4982         return ret;
4983 }
4984
4985
4986 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
4987 {
4988         if (camera == NULL || foreach_cb == NULL) {
4989                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4990                 return CAMERA_ERROR_INVALID_PARAMETER;
4991         }
4992         int ret = CAMERA_ERROR_NONE;
4993
4994         camera_cli_s *pc = (camera_cli_s *)camera;
4995         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
4996         int sock_fd;
4997         if (pc->cb_info == NULL) {
4998                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4999                 return CAMERA_ERROR_INVALID_PARAMETER;
5000         }
5001         sock_fd = pc->cb_info->fd;
5002         LOGD("Enter, handle :%x", pc->remote_handle);
5003         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5004         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5005
5006         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5007         LOGD("ret : 0x%x", ret);
5008         return ret;
5009 }
5010
5011
5012 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation)
5013 {
5014         if (camera == NULL) {
5015                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5016                 return CAMERA_ERROR_INVALID_PARAMETER;
5017         }
5018
5019         int ret = CAMERA_ERROR_NONE;
5020         camera_cli_s *pc = (camera_cli_s *)camera;
5021         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5022         int sock_fd;
5023         if (pc->cb_info == NULL) {
5024                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5025                 return CAMERA_ERROR_INVALID_PARAMETER;
5026         }
5027         sock_fd = pc->cb_info->fd;
5028         int set_rotation = (int)rotation;
5029
5030         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5031         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation);
5032         LOGD("ret : 0x%x", ret);
5033         return ret;
5034 }
5035
5036
5037 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation)
5038 {
5039         if (camera == NULL || rotation == NULL) {
5040                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5041                 return CAMERA_ERROR_INVALID_PARAMETER;
5042         }
5043
5044         int ret = CAMERA_ERROR_NONE;
5045         camera_cli_s *pc = (camera_cli_s *)camera;
5046         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5047         int sock_fd;
5048         if (pc->cb_info == NULL) {
5049                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5050                 return CAMERA_ERROR_INVALID_PARAMETER;
5051         }
5052         sock_fd = pc->cb_info->fd;
5053         int get_rotation;
5054
5055         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5056         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5057
5058         if (ret == CAMERA_ERROR_NONE) {
5059                 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5060                 *rotation = (camera_rotation_e)get_rotation;
5061         }
5062         LOGD("ret : 0x%x", ret);
5063         return ret;
5064 }
5065
5066
5067 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip)
5068 {
5069         if (camera == NULL) {
5070                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5071                 return CAMERA_ERROR_INVALID_PARAMETER;
5072         }
5073
5074         int ret = CAMERA_ERROR_NONE;
5075         camera_cli_s *pc = (camera_cli_s *)camera;
5076         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5077         int sock_fd;
5078         if (pc->cb_info == NULL) {
5079                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5080                 return CAMERA_ERROR_INVALID_PARAMETER;
5081         }
5082         sock_fd = pc->cb_info->fd;
5083         int set_flip = (int)flip;
5084
5085         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5086         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip);
5087         LOGD("ret : 0x%x", ret);
5088         return ret;
5089 }
5090
5091
5092 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip)
5093 {
5094         if (camera == NULL || flip == NULL) {
5095                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5096                 return CAMERA_ERROR_INVALID_PARAMETER;
5097         }
5098
5099         int ret = CAMERA_ERROR_NONE;
5100         camera_cli_s *pc = (camera_cli_s *)camera;
5101         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5102         int sock_fd;
5103         if (pc->cb_info == NULL) {
5104                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5105                 return CAMERA_ERROR_INVALID_PARAMETER;
5106         }
5107         sock_fd = pc->cb_info->fd;
5108         int get_flip;
5109
5110         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5111         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5112
5113         if (ret == CAMERA_ERROR_NONE) {
5114                 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5115                 *flip = (camera_flip_e)get_flip;
5116         }
5117         LOGD("ret : 0x%x", ret);
5118         return ret;
5119 }
5120
5121 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5122 {
5123         if (camera == NULL) {
5124                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5125                 return CAMERA_ERROR_INVALID_PARAMETER;
5126         }
5127
5128         int ret = CAMERA_ERROR_NONE;
5129         camera_cli_s *pc = (camera_cli_s *)camera;
5130         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5131         int sock_fd;
5132         if (pc->cb_info == NULL) {
5133                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5134                 return CAMERA_ERROR_INVALID_PARAMETER;
5135         }
5136         sock_fd = pc->cb_info->fd;
5137         int set_mode = (int)mode;
5138
5139         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5140         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
5141         LOGD("ret : 0x%x", ret);
5142         return ret;
5143 }
5144
5145
5146 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5147 {
5148         if (camera == NULL) {
5149                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5150                 return CAMERA_ERROR_INVALID_PARAMETER;
5151         }
5152         if (mode == NULL) {
5153                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - mode", CAMERA_ERROR_NOT_SUPPORTED);
5154                 return CAMERA_ERROR_NOT_SUPPORTED;
5155         }
5156         int ret = CAMERA_ERROR_NONE;
5157         camera_cli_s *pc = (camera_cli_s *)camera;
5158         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5159         int sock_fd;
5160         if (pc->cb_info == NULL) {
5161                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5162                 return CAMERA_ERROR_INVALID_PARAMETER;
5163         }
5164         sock_fd = pc->cb_info->fd;
5165         int get_mode;
5166
5167         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5168         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5169
5170         if (ret == CAMERA_ERROR_NONE) {
5171                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5172                 *mode = (camera_attr_hdr_mode_e)get_mode;
5173         }
5174         LOGD("ret : 0x%x", ret);
5175         return ret;
5176 }
5177
5178
5179 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5180 {
5181         if (camera == NULL) {
5182                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5183                 return false;
5184         }
5185
5186         int ret = CAMERA_ERROR_NONE;
5187         camera_cli_s *pc = (camera_cli_s *)camera;
5188         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5189         int sock_fd;
5190         if (pc->cb_info == NULL) {
5191                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5192                 return CAMERA_ERROR_INVALID_PARAMETER;
5193         }
5194         sock_fd = pc->cb_info->fd;
5195         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5196         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5197         LOGD("ret : 0x%x", ret);
5198         return (bool)ret;
5199 }
5200
5201
5202 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void* user_data)
5203 {
5204         if (camera == NULL) {
5205                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5206                 return CAMERA_ERROR_INVALID_PARAMETER;
5207         }
5208         if (callback == NULL) {
5209                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - callback", CAMERA_ERROR_NOT_SUPPORTED);
5210                 return CAMERA_ERROR_NOT_SUPPORTED;
5211         }
5212         int ret = CAMERA_ERROR_NONE;
5213
5214         camera_cli_s *pc = (camera_cli_s *)camera;
5215         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5216         int sock_fd;
5217         if (pc->cb_info == NULL) {
5218                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5219                 return CAMERA_ERROR_INVALID_PARAMETER;
5220         }
5221         sock_fd = pc->cb_info->fd;
5222         LOGD("Enter, handle :%x", pc->remote_handle);
5223
5224         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5225         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5226
5227         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5228         LOGD("ret : 0x%x", ret);
5229         return ret;
5230 }
5231
5232
5233 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5234 {
5235         if (camera == NULL) {
5236                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5237                 return CAMERA_ERROR_INVALID_PARAMETER;
5238         }
5239
5240         int ret = CAMERA_ERROR_NONE;
5241
5242         camera_cli_s *pc = (camera_cli_s *)camera;
5243         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5244         int sock_fd;
5245         if (pc->cb_info == NULL) {
5246                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5247                 return CAMERA_ERROR_INVALID_PARAMETER;
5248         }
5249         sock_fd = pc->cb_info->fd;
5250         LOGD("Enter, handle :%x", pc->remote_handle);
5251
5252         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5253         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5254
5255         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5256         LOGD("ret : 0x%x", ret);
5257         return ret;
5258 }
5259
5260
5261 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5262 {
5263         if (camera == NULL) {
5264                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5265                 return CAMERA_ERROR_INVALID_PARAMETER;
5266         }
5267
5268         int ret = CAMERA_ERROR_NONE;
5269         camera_cli_s *pc = (camera_cli_s *)camera;
5270         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5271         int sock_fd;
5272         if (pc->cb_info == NULL) {
5273                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5274                 return CAMERA_ERROR_INVALID_PARAMETER;
5275         }
5276         sock_fd = pc->cb_info->fd;
5277         int set_enable = (int)enable;
5278
5279         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5280         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5281         LOGD("ret : 0x%x", ret);
5282         return ret;
5283 }
5284
5285
5286 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled)
5287 {
5288         if (camera == NULL) {
5289                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5290                 return CAMERA_ERROR_INVALID_PARAMETER;
5291         }
5292         if (enabled == NULL) {
5293                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5294                 return CAMERA_ERROR_NOT_SUPPORTED;
5295         }
5296         int ret = CAMERA_ERROR_NONE;
5297         camera_cli_s *pc = (camera_cli_s *)camera;
5298         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5299         int sock_fd;
5300         if (pc->cb_info == NULL) {
5301                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5302                 return CAMERA_ERROR_INVALID_PARAMETER;
5303         }
5304         sock_fd = pc->cb_info->fd;
5305         int get_enabled;
5306
5307         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5308         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5309
5310         if (ret == CAMERA_ERROR_NONE) {
5311                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5312                 *enabled = (bool)get_enabled;
5313         }
5314         LOGD("ret : 0x%x", ret);
5315         return ret;
5316 }
5317
5318
5319 bool camera_attr_is_supported_anti_shake(camera_h camera)
5320 {
5321
5322         if (camera == NULL) {
5323                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5324                 return false;
5325         }
5326
5327         int ret = CAMERA_ERROR_NONE;
5328         camera_cli_s *pc = (camera_cli_s *)camera;
5329         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5330         int sock_fd;
5331         if (pc->cb_info == NULL) {
5332                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5333                 return CAMERA_ERROR_INVALID_PARAMETER;
5334         }
5335         sock_fd = pc->cb_info->fd;
5336         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5337         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5338         LOGD("ret : 0x%x", ret);
5339         return ret;
5340 }
5341
5342
5343 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5344 {
5345         if (camera == NULL) {
5346                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5347                 return CAMERA_ERROR_INVALID_PARAMETER;
5348         }
5349
5350         int ret = CAMERA_ERROR_NONE;
5351         camera_cli_s *pc = (camera_cli_s *)camera;
5352         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
5353         int sock_fd;
5354         if (pc->cb_info == NULL) {
5355                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5356                 return CAMERA_ERROR_INVALID_PARAMETER;
5357         }
5358         sock_fd = pc->cb_info->fd;
5359         int set_enable = (int)enable;
5360
5361         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5362         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5363         LOGD("ret : 0x%x", ret);
5364         return ret;
5365 }
5366
5367
5368 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5369 {
5370         if (camera == NULL) {
5371                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5372                 return CAMERA_ERROR_INVALID_PARAMETER;
5373         }
5374         if (enabled == NULL) {
5375                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5376                 return CAMERA_ERROR_NOT_SUPPORTED;
5377         }
5378         int ret = CAMERA_ERROR_NONE;
5379         camera_cli_s *pc = (camera_cli_s *)camera;
5380         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5381         int sock_fd;
5382         if (pc->cb_info == NULL) {
5383                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5384                 return CAMERA_ERROR_INVALID_PARAMETER;
5385         }
5386         sock_fd = pc->cb_info->fd;
5387         int get_enabled;
5388
5389         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5390         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5391
5392         if (ret == CAMERA_ERROR_NONE) {
5393                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5394                 *enabled = (bool)get_enabled;
5395         }
5396         LOGD("ret : 0x%x", ret);
5397         return ret;
5398 }
5399
5400
5401 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5402 {
5403         if (camera == NULL) {
5404                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5405                 return false;
5406         }
5407
5408         int ret = CAMERA_ERROR_NONE;
5409         camera_cli_s *pc = (camera_cli_s *)camera;
5410         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
5411         int sock_fd;
5412         if (pc->cb_info == NULL) {
5413                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5414                 return CAMERA_ERROR_INVALID_PARAMETER;
5415         }
5416         sock_fd = pc->cb_info->fd;
5417         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5418         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5419         LOGD("ret : 0x%x", ret);
5420         return ret;
5421 }
5422
5423
5424 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5425 {
5426         if (camera == NULL) {
5427                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5428                 return CAMERA_ERROR_INVALID_PARAMETER;
5429         }
5430
5431         int ret = CAMERA_ERROR_NONE;
5432         camera_cli_s *pc = (camera_cli_s *)camera;
5433         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
5434         int sock_fd;
5435         if (pc->cb_info == NULL) {
5436                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5437                 return CAMERA_ERROR_INVALID_PARAMETER;
5438         }
5439         sock_fd = pc->cb_info->fd;
5440         int set_enable = (int)enable;
5441
5442         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5443         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5444         LOGD("ret : 0x%x", ret);
5445         return ret;
5446 }
5447
5448
5449 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5450 {
5451         if (camera == NULL) {
5452                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5453                 return CAMERA_ERROR_INVALID_PARAMETER;
5454         }
5455         if (enabled == NULL) {
5456                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5457                 return CAMERA_ERROR_INVALID_PARAMETER;
5458         }
5459         int ret = CAMERA_ERROR_NONE;
5460         camera_cli_s *pc = (camera_cli_s *)camera;
5461         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5462         int sock_fd;
5463         if (pc->cb_info == NULL) {
5464                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5465                 return CAMERA_ERROR_INVALID_PARAMETER;
5466         }
5467         sock_fd = pc->cb_info->fd;
5468         int get_enabled;
5469
5470         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5471         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5472
5473         if (ret == CAMERA_ERROR_NONE) {
5474                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5475                 *enabled = (bool)get_enabled;
5476         }
5477         LOGD("ret : 0x%x", ret);
5478         return ret;
5479 }
5480
5481
5482 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5483 {
5484         if (camera == NULL) {
5485                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5486                 return false;
5487         }
5488
5489         int ret = CAMERA_ERROR_NONE;
5490         camera_cli_s *pc = (camera_cli_s *)camera;
5491         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
5492         int sock_fd;
5493         if (pc->cb_info == NULL) {
5494                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5495                 return CAMERA_ERROR_INVALID_PARAMETER;
5496         }
5497         sock_fd = pc->cb_info->fd;
5498         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5499         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5500         LOGD("ret : 0x%x", ret);
5501         return ret;
5502 }
5503
5504
5505 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5506 {
5507         if (camera == NULL) {
5508                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5509                 return CAMERA_ERROR_INVALID_PARAMETER;
5510         }
5511
5512         int ret = CAMERA_ERROR_NONE;
5513         camera_cli_s *pc = (camera_cli_s *)camera;
5514         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5515         int sock_fd;
5516         if (pc->cb_info == NULL) {
5517                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5518                 return CAMERA_ERROR_INVALID_PARAMETER;
5519         }
5520         sock_fd = pc->cb_info->fd;
5521         int set_disable = (int)disable;
5522
5523         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5524         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_disable);
5525         LOGD("ret : 0x%x", ret);
5526         return ret;
5527 }