[Release version 0.2.41] Fix UTC - invalid parameter check
[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         ret = mm_camcorder_client_create(&pc->client_handle);
1814         if (ret != MM_ERROR_NONE) {
1815                 LOGE("camera client create Failed 0x%x", ret);
1816                 ret = __convert_camera_error_code(__func__, ret);
1817                 goto ErrorExit;
1818         }
1819
1820         pc->cb_info = _client_callback_new(sock_fd);
1821         if (pc->cb_info == NULL) {
1822                 LOGE("cb_info alloc failed");
1823                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1824                 goto ErrorExit;
1825         }
1826
1827         LOGD("cb info : %d", pc->cb_info->fd);
1828
1829         ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
1830         if (ret == CAMERA_ERROR_NONE) {
1831                 intptr_t handle = 0;
1832                 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
1833                 if (handle == 0) {
1834                         LOGE("Receiving Handle Failed!!");
1835                         ret = CAMERA_ERROR_INVALID_OPERATION;
1836                         goto ErrorExit;
1837                 }
1838
1839                 pc->remote_handle = handle;
1840                 pc->cb_info->bufmgr = bufmgr;
1841
1842                 LOGD("camera create 0x%x", pc->remote_handle);
1843                 *camera = (camera_h) pc;
1844         } else {
1845                 goto ErrorExit;
1846         }
1847
1848         return ret;
1849
1850 ErrorExit:
1851         tbm_bufmgr_deinit(bufmgr);
1852         bufmgr = NULL;
1853
1854         if (pc) {
1855                 if (pc->client_handle) {
1856                         mm_camcorder_client_destroy(pc->client_handle);
1857                         pc->client_handle = NULL;
1858                 }
1859                 _client_callback_destroy(pc->cb_info);
1860                 pc->cb_info = NULL;
1861                 g_free(pc);
1862                 pc = NULL;
1863         }
1864
1865         LOGE("camera create error : 0x%x", ret);
1866
1867         return ret;
1868 }
1869
1870 int camera_destroy(camera_h camera)
1871 {
1872         if (camera == NULL) {
1873                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1874                 return CAMERA_ERROR_INVALID_PARAMETER;
1875         }
1876
1877         int ret = CAMERA_ERROR_NONE;
1878         muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
1879         camera_cli_s *pc = (camera_cli_s *)camera;
1880         int sock_fd = 0;
1881
1882         LOGD("ENTER");
1883
1884         if (pc->cb_info == NULL) {
1885                 LOGE("cb_info NULL, INVALID_PARAMETER");
1886                 return CAMERA_ERROR_INVALID_PARAMETER;
1887         }
1888
1889         sock_fd = pc->cb_info->fd;
1890
1891         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
1892         if (ret == CAMERA_ERROR_NONE) {
1893                 if (pc->client_handle) {
1894                         mm_camcorder_client_destroy(pc->client_handle);
1895                         pc->client_handle = NULL;
1896                 }
1897                 _camera_remove_idle_event_all(pc->cb_info);
1898                 _client_callback_destroy(pc->cb_info);
1899                 pc->cb_info = NULL;
1900
1901 #ifdef HAVE_WAYLAND
1902                 if (pc->wl_info) {
1903                         g_free(pc->wl_info);
1904                         pc->wl_info = NULL;
1905                 }
1906 #endif /* HAVE_WAYLAND */
1907
1908                 g_free(pc);
1909                 pc = NULL;
1910         } else {
1911                 LOGE("camera destroy error : 0x%x", ret);
1912         }
1913
1914         return ret;
1915 }
1916
1917 int camera_start_preview(camera_h camera)
1918 {
1919         int ret = CAMERA_ERROR_NONE;
1920         muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
1921         camera_cli_s *pc = (camera_cli_s *)camera;
1922         int sock_fd = 0;
1923
1924         if (camera == NULL) {
1925                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1926                 return CAMERA_ERROR_INVALID_PARAMETER;
1927         }
1928
1929         if (pc->cb_info == NULL) {
1930                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1931                 return CAMERA_ERROR_INVALID_PARAMETER;
1932         }
1933
1934         LOGD("start");
1935
1936         sock_fd = pc->cb_info->fd;
1937
1938         if (pc->client_handle == NULL) {
1939                 LOGW("set display is not called by application. set NONE type internally");
1940                 ret = camera_set_display(camera, CAMERA_DISPLAY_TYPE_NONE, NULL);
1941                 if (ret != CAMERA_ERROR_NONE) {
1942                         LOGE("Internal camera_set_display failed 0x%x", ret);
1943                         return ret;
1944                 }
1945         }
1946
1947         muse_camera_msg_send_longtime(api, sock_fd, pc->cb_info, ret);
1948
1949         if (ret != CAMERA_ERROR_NONE) {
1950                 LOGE("start preview failed 0x%x", ret);
1951                 return ret;
1952         }
1953
1954         if (pc->cb_info->prev_state == CAMERA_STATE_CREATED) {
1955                 if (pc->cb_info->caps == NULL) {
1956                         LOGE("caps string is NULL");
1957                         goto _START_PREVIEW_ERROR;
1958                 }
1959
1960                 ret = mm_camcorder_client_realize(pc->client_handle, pc->cb_info->caps);
1961                 if (ret != MM_ERROR_NONE) {
1962                         LOGE("client realize failed 0x%x", ret);
1963                         goto _START_PREVIEW_ERROR;
1964                 }
1965         }
1966
1967         LOGD("ret : 0x%x", ret);
1968
1969         return CAMERA_ERROR_NONE;
1970
1971 _START_PREVIEW_ERROR:
1972         muse_camera_msg_send_longtime(MUSE_CAMERA_API_STOP_PREVIEW, sock_fd, pc->cb_info, ret);
1973
1974         return CAMERA_ERROR_INVALID_OPERATION;
1975 }
1976
1977 int camera_stop_preview(camera_h camera)
1978 {
1979         int ret = CAMERA_ERROR_NONE;
1980         int client_ret = MM_ERROR_NONE;
1981         int sock_fd = 0;
1982         camera_cli_s *pc = NULL;
1983         muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
1984
1985         if (camera == NULL) {
1986                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1987                 return CAMERA_ERROR_INVALID_PARAMETER;
1988         }
1989
1990         pc = (camera_cli_s *)camera;
1991
1992         if (pc->cb_info == NULL) {
1993                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1994                 return CAMERA_ERROR_INVALID_PARAMETER;
1995         }
1996
1997         sock_fd = pc->cb_info->fd;
1998
1999         LOGD("Enter");
2000
2001         /* destroy client pipeline first */
2002         if (pc->client_handle != NULL) {
2003                 client_ret = mm_camcorder_client_unrealize(pc->client_handle);
2004         } else {
2005                 LOGW("client handle is NULL");
2006         }
2007
2008         /* send stop preview message */
2009         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2010
2011         if (ret == MM_ERROR_NONE && client_ret != MM_ERROR_NONE) {
2012                 LOGE("client unrealize failed, restart preview");
2013                 muse_camera_msg_send_longtime(MUSE_CAMERA_API_START_PREVIEW, sock_fd, pc->cb_info, ret);
2014                 ret = CAMERA_ERROR_INVALID_OPERATION;
2015         } else if (ret != MM_ERROR_NONE && client_ret == MM_ERROR_NONE) {
2016                 LOGE("stop preview failed, realize client again");
2017                 mm_camcorder_client_realize(pc->client_handle, pc->cb_info->caps);
2018                 ret = CAMERA_ERROR_INVALID_OPERATION;
2019         }
2020
2021         LOGD("ret : 0x%x", ret);
2022
2023         return ret;
2024 }
2025
2026 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2027 {
2028         if (camera == NULL) {
2029                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2030                 return CAMERA_ERROR_INVALID_PARAMETER;
2031         }
2032         int ret = CAMERA_ERROR_NONE;
2033
2034         camera_cli_s *pc = (camera_cli_s *)camera;
2035         muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2036         int sock_fd;
2037         int is_capturing_cb = 0;
2038         int is_completed_cb = 0;
2039         LOGD("Enter, handle :%x", pc->remote_handle);
2040
2041         if (pc->cb_info == NULL) {
2042                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2043                 return CAMERA_ERROR_INVALID_PARAMETER;
2044         }
2045
2046         sock_fd = pc->cb_info->fd;
2047
2048         if (capturing_cb != NULL) {
2049                 is_capturing_cb = 1;
2050                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2051                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2052         }
2053
2054         if (completed_cb != NULL) {
2055                 is_completed_cb = 1;
2056                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2057                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2058         }
2059
2060         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, is_capturing_cb, INT, is_completed_cb);
2061         LOGD("is_capturing_cb :%d, is_completed_cb : %d", is_capturing_cb, is_completed_cb);
2062         LOGD("ret : 0x%x", ret);
2063         return ret;
2064 }
2065
2066 bool camera_is_supported_continuous_capture(camera_h camera)
2067 {
2068         if (camera == NULL) {
2069                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2070                 return false;
2071         }
2072
2073         int ret = CAMERA_ERROR_NONE;
2074         camera_cli_s *pc = (camera_cli_s *)camera;
2075         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2076         int sock_fd;
2077
2078         if (pc->cb_info == NULL) {
2079                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2080                 return CAMERA_ERROR_INVALID_PARAMETER;
2081         }
2082
2083         sock_fd = pc->cb_info->fd;
2084
2085         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2086         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2087         LOGD("ret : 0x%x", ret);
2088         return (bool)ret;
2089 }
2090
2091 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)
2092 {
2093         if (camera == NULL) {
2094                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2095                 return CAMERA_ERROR_INVALID_PARAMETER;
2096         }
2097
2098         int ret = CAMERA_ERROR_NONE;
2099
2100         camera_cli_s *pc = (camera_cli_s *)camera;
2101         muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2102
2103         LOGD("Enter, handle :%x", pc->remote_handle);
2104
2105         int sock_fd;
2106         if (pc->cb_info == NULL) {
2107                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2108                 return CAMERA_ERROR_INVALID_PARAMETER;
2109         }
2110         sock_fd = pc->cb_info->fd;
2111
2112         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2113         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2114         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2115
2116         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, count, INT, interval);
2117
2118         LOGD("ret : 0x%x", ret);
2119
2120         return ret;
2121 }
2122
2123 int camera_stop_continuous_capture(camera_h camera)
2124 {
2125         if (camera == NULL) {
2126                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2127                 return CAMERA_ERROR_INVALID_PARAMETER;
2128         }
2129
2130
2131         int ret = CAMERA_ERROR_NONE;
2132
2133         camera_cli_s *pc = (camera_cli_s *)camera;
2134         muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2135         LOGD("Enter,  handle :%x", pc->remote_handle);
2136         int sock_fd;
2137         if (pc->cb_info == NULL) {
2138                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2139                 return CAMERA_ERROR_INVALID_PARAMETER;
2140         }
2141         sock_fd = pc->cb_info->fd;
2142         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2143         LOGD("ret : 0x%x", ret);
2144         return ret;
2145 }
2146
2147 bool camera_is_supported_face_detection(camera_h camera)
2148 {
2149         if (camera == NULL) {
2150                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2151                 return false;
2152         }
2153         int ret = CAMERA_ERROR_NONE;
2154
2155         camera_cli_s *pc = (camera_cli_s *)camera;
2156         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2157         int sock_fd;
2158         if (pc->cb_info == NULL) {
2159                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2160                 return CAMERA_ERROR_INVALID_PARAMETER;
2161         }
2162         sock_fd = pc->cb_info->fd;
2163
2164         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2165         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2166         LOGD("ret : 0x%x", ret);
2167         return (bool)ret;
2168 }
2169
2170 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2171 {
2172         if (camera == NULL) {
2173                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2174                 return false;
2175         }
2176         int ret = CAMERA_ERROR_NONE;
2177
2178         camera_cli_s *pc = (camera_cli_s *)camera;
2179         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2180         int sock_fd;
2181         if (pc->cb_info == NULL) {
2182                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2183                 return CAMERA_ERROR_INVALID_PARAMETER;
2184         }
2185         sock_fd = pc->cb_info->fd;
2186
2187         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2188         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2189         LOGD("ret : 0x%x", ret);
2190         return (bool)ret;
2191 }
2192
2193 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2194 {
2195         if (camera == NULL) {
2196                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2197                 return false;
2198         }
2199
2200         int ret = CAMERA_ERROR_NONE;
2201
2202         camera_cli_s *pc = (camera_cli_s *)camera;
2203         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2204         int sock_fd;
2205         if (pc->cb_info == NULL) {
2206                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2207                 return CAMERA_ERROR_INVALID_PARAMETER;
2208         }
2209         sock_fd = pc->cb_info->fd;
2210
2211         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2212         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2213         LOGD("ret : 0x%x", ret);
2214         return (bool)ret;
2215 }
2216
2217 int camera_get_device_count(camera_h camera, int *device_count)
2218 {
2219         if (camera == NULL || device_count == NULL) {
2220                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2221                 return CAMERA_ERROR_INVALID_PARAMETER;
2222         }
2223         int ret = CAMERA_ERROR_NONE;
2224
2225         camera_cli_s *pc = (camera_cli_s *)camera;
2226         muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2227         int sock_fd;
2228         if (pc->cb_info == NULL) {
2229                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2230                 return CAMERA_ERROR_INVALID_PARAMETER;
2231         }
2232         sock_fd = pc->cb_info->fd;
2233         int get_device_count;
2234
2235         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2236         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2237
2238         if (ret == CAMERA_ERROR_NONE) {
2239                 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2240                 *device_count = get_device_count;
2241         }
2242         LOGD("ret : 0x%x", ret);
2243         return ret;
2244 }
2245
2246 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void * user_data)
2247 {
2248         if (camera == NULL) {
2249                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2250                 return CAMERA_ERROR_INVALID_PARAMETER;
2251         }
2252
2253         int ret = CAMERA_ERROR_NONE;
2254
2255         camera_cli_s *pc = (camera_cli_s *)camera;
2256         muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2257
2258         LOGD("Enter, handle :%x", pc->remote_handle);
2259         int sock_fd;
2260         if (pc->cb_info == NULL) {
2261                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2262                 return CAMERA_ERROR_INVALID_PARAMETER;
2263         }
2264         sock_fd = pc->cb_info->fd;
2265         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2266         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2267
2268         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2269         LOGD("ret : 0x%x", ret);
2270         return ret;
2271 }
2272
2273 int camera_stop_face_detection(camera_h camera)
2274 {
2275         if (camera == NULL) {
2276                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2277                 return CAMERA_ERROR_INVALID_PARAMETER;
2278         }
2279
2280         int ret = CAMERA_ERROR_NONE;
2281
2282         camera_cli_s *pc = (camera_cli_s *)camera;
2283         muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2284         LOGD("Enter,  handle :%x", pc->remote_handle);
2285         int sock_fd;
2286         if (pc->cb_info == NULL) {
2287                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2288                 return CAMERA_ERROR_INVALID_PARAMETER;
2289         }
2290         sock_fd = pc->cb_info->fd;
2291         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2292         LOGD("ret : 0x%x", ret);
2293         return ret;
2294 }
2295
2296 int camera_get_state(camera_h camera, camera_state_e * state)
2297 {
2298         if (camera == NULL || state == NULL) {
2299                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2300                 return CAMERA_ERROR_INVALID_PARAMETER;
2301         }
2302         int ret = CAMERA_ERROR_NONE;
2303
2304         camera_cli_s *pc = (camera_cli_s *)camera;
2305         muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2306         int sock_fd;
2307         if (pc->cb_info == NULL) {
2308                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2309                 return CAMERA_ERROR_INVALID_PARAMETER;
2310         }
2311         sock_fd = pc->cb_info->fd;
2312         int get_state;
2313
2314         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2315         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2316
2317         if (ret == CAMERA_ERROR_NONE) {
2318                 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2319                 *state = (camera_state_e)get_state;
2320         }
2321         LOGD("ret : 0x%x", ret);
2322         return ret;
2323 }
2324
2325 int camera_start_focusing(camera_h camera, bool continuous)
2326 {
2327         if (camera == NULL) {
2328                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2329                 return CAMERA_ERROR_INVALID_PARAMETER;
2330         }
2331
2332         int ret = CAMERA_ERROR_NONE;
2333
2334         camera_cli_s *pc = (camera_cli_s *)camera;
2335         muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2336         int sock_fd;
2337         if (pc->cb_info == NULL) {
2338                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2339                 return CAMERA_ERROR_INVALID_PARAMETER;
2340         }
2341         sock_fd = pc->cb_info->fd;
2342         int is_continuous = (int)continuous;
2343
2344         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2345         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, is_continuous);
2346         LOGD("ret : 0x%x", ret);
2347         return ret;
2348 }
2349
2350 int camera_cancel_focusing(camera_h camera)
2351 {
2352         if (camera == NULL) {
2353                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2354                 return CAMERA_ERROR_INVALID_PARAMETER;
2355         }
2356
2357         int ret = CAMERA_ERROR_NONE;
2358
2359         camera_cli_s *pc = (camera_cli_s *)camera;
2360         muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2361         int sock_fd;
2362         if (pc->cb_info == NULL) {
2363                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2364                 return CAMERA_ERROR_INVALID_PARAMETER;
2365         }
2366         sock_fd = pc->cb_info->fd;
2367
2368         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2369         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2370         LOGD("ret : 0x%x", ret);
2371         return ret;
2372 }
2373
2374 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2375 {
2376         int ret = CAMERA_ERROR_NONE;
2377         void *set_display_handle = NULL;
2378         int set_surface = MM_DISPLAY_SURFACE_OVERLAY;
2379         Evas_Object *obj = NULL;
2380         const char *object_type = NULL;
2381         char socket_path[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
2382 #ifdef HAVE_WAYLAND
2383         MMCamWaylandInfo *wl_info = NULL;
2384 #endif /* HAVE_WAYLAND */
2385
2386         if (camera == NULL) {
2387                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2388                 return CAMERA_ERROR_INVALID_PARAMETER;
2389         }
2390
2391         if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2392                 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2393                 return CAMERA_ERROR_INVALID_PARAMETER;
2394         }
2395
2396         camera_cli_s *pc = (camera_cli_s *)camera;
2397         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2398         int sock_fd;
2399         if (pc->cb_info == NULL) {
2400                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2401                 return CAMERA_ERROR_INVALID_PARAMETER;
2402         }
2403         sock_fd = pc->cb_info->fd;
2404
2405         LOGD("Enter, remote_handle : %x display : 0x%x", pc->remote_handle, display);
2406
2407         if (type == CAMERA_DISPLAY_TYPE_NONE) {
2408                 set_display_handle = 0;
2409                 set_surface = MM_DISPLAY_SURFACE_NULL;
2410                 LOGD("display type NONE");
2411         } else {
2412                 obj = (Evas_Object *)display;
2413                 object_type = evas_object_type_get(obj);
2414                 if (object_type) {
2415                         if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2416 #ifdef HAVE_WAYLAND
2417                                 /* set wayland info */
2418                                 wl_info = _get_wl_info(obj);
2419                                 if (wl_info == NULL) {
2420                                         LOGE("failed to get wl_info");
2421                                         return CAMERA_ERROR_INVALID_OPERATION;
2422                                 }
2423
2424                                 set_display_handle = (void *)wl_info;
2425 #else /* HAVE_WAYLAND */
2426                                 /* x window overlay surface */
2427                                 set_display_handle = (void *)elm_win_xwindow_get(obj);
2428 #endif
2429                                 set_surface = MM_DISPLAY_SURFACE_OVERLAY;
2430                                 LOGD("display type OVERLAY : handle %p", set_display_handle);
2431                         } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2432                                 /* evas object surface */
2433                                 set_display_handle = (void *)display;
2434                                 set_surface = MM_DISPLAY_SURFACE_EVAS;
2435                                 LOGD("display type EVAS : handle %p", set_display_handle);
2436                         } else {
2437                                 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
2438                                 return CAMERA_ERROR_INVALID_PARAMETER;
2439                         }
2440                 } else {
2441                         LOGE("failed to get evas object type from %p", obj);
2442                         return CAMERA_ERROR_INVALID_PARAMETER;
2443                 }
2444         }
2445
2446         pc->display_handle = (intptr_t)set_display_handle;
2447
2448         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2449
2450         if (ret == CAMERA_ERROR_NONE) {
2451                 if (muse_camera_msg_get_string(socket_path, pc->cb_info->recv_msg) == FALSE) {
2452                         LOGE("failed to get socket path");
2453                         goto _SET_DISPLAY_ERROR;
2454                 }
2455
2456                 LOGD("socket path : %s", socket_path);
2457
2458                 ret = mm_camcorder_client_set_socket_path(pc->client_handle, socket_path);
2459                 if (ret != MM_ERROR_NONE) {
2460                         LOGE("failed to set socket path 0x%x", ret);
2461                         goto _SET_DISPLAY_ERROR;
2462                 }
2463
2464                 ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2465                         MMCAM_DISPLAY_SURFACE, set_surface,
2466                         NULL);
2467                 if (ret != MM_ERROR_NONE) {
2468                         LOGE("set display surface failed 0x%x", ret);
2469                         goto _SET_DISPLAY_ERROR;
2470                 }
2471
2472                 if (type != CAMERA_DISPLAY_TYPE_NONE) {
2473                         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2474                                 MMCAM_DISPLAY_HANDLE, set_display_handle, sizeof(void *),
2475                                 NULL);
2476                         if (ret != MM_ERROR_NONE) {
2477                                 LOGE("set display handle failed 0x%x", ret);
2478                                 goto _SET_DISPLAY_ERROR;
2479                         }
2480                 }
2481
2482 #ifdef HAVE_WAYLAND
2483                 if (pc->wl_info) {
2484                         g_free(pc->wl_info);
2485                         pc->wl_info = NULL;
2486                 }
2487
2488                 pc->wl_info = wl_info;
2489 #endif /* HAVE_WAYLAND */
2490
2491                 return CAMERA_ERROR_NONE;;
2492         } else {
2493                 LOGE("set display error - 0x%x");
2494                 return ret;
2495         }
2496
2497 _SET_DISPLAY_ERROR:
2498 #ifdef HAVE_WAYLAND
2499         if (wl_info) {
2500                 g_free(wl_info);
2501                 wl_info = NULL;
2502         }
2503 #endif /* HAVE_WAYLAND */
2504
2505         return __convert_camera_error_code(__func__, ret);
2506 }
2507
2508 int camera_set_preview_resolution(camera_h camera,  int width, int height)
2509 {
2510         if (camera == NULL) {
2511                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2512                 return CAMERA_ERROR_INVALID_PARAMETER;
2513         }
2514         int ret = CAMERA_ERROR_NONE;
2515
2516         camera_cli_s *pc = (camera_cli_s *)camera;
2517         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
2518         int sock_fd;
2519         if (pc->cb_info == NULL) {
2520                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2521                 return CAMERA_ERROR_INVALID_PARAMETER;
2522         }
2523         sock_fd = pc->cb_info->fd;
2524
2525         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2526         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2527         LOGD("ret : 0x%x", ret);
2528         return ret;
2529 }
2530
2531
2532 int camera_set_capture_resolution(camera_h camera,  int width, int height)
2533 {
2534         if (camera == NULL) {
2535                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2536                 return CAMERA_ERROR_INVALID_PARAMETER;
2537         }
2538
2539         int ret = CAMERA_ERROR_NONE;
2540
2541         camera_cli_s *pc = (camera_cli_s *)camera;
2542         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
2543         int sock_fd;
2544         if (pc->cb_info == NULL) {
2545                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2546                 return CAMERA_ERROR_INVALID_PARAMETER;
2547         }
2548         sock_fd = pc->cb_info->fd;
2549
2550         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2551         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2552         LOGD("ret : 0x%x", ret);
2553         return ret;
2554 }
2555
2556 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
2557 {
2558         if (camera == NULL) {
2559                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2560                 return CAMERA_ERROR_INVALID_PARAMETER;
2561         }
2562
2563         int ret = CAMERA_ERROR_NONE;
2564         int set_format = (int)format;
2565
2566         camera_cli_s *pc = (camera_cli_s *)camera;
2567         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
2568         int sock_fd;
2569         if (pc->cb_info == NULL) {
2570                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2571                 return CAMERA_ERROR_INVALID_PARAMETER;
2572         }
2573         sock_fd = pc->cb_info->fd;
2574
2575         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2576         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2577         LOGD("ret : 0x%x", ret);
2578         return ret;
2579 }
2580
2581 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
2582 {
2583         if (camera == NULL) {
2584                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2585                 return CAMERA_ERROR_INVALID_PARAMETER;
2586         }
2587
2588         int ret = CAMERA_ERROR_NONE;
2589         int set_format = (int)format;
2590
2591         camera_cli_s *pc = (camera_cli_s *)camera;
2592         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
2593         int sock_fd;
2594         if (pc->cb_info == NULL) {
2595                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2596                 return CAMERA_ERROR_INVALID_PARAMETER;
2597         }
2598         sock_fd = pc->cb_info->fd;
2599
2600         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2601         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2602         LOGD("ret : 0x%x", ret);
2603         return ret;
2604 }
2605
2606 int camera_get_preview_resolution(camera_h camera,  int *width, int *height)
2607 {
2608         if (camera == NULL || width == NULL || height == NULL) {
2609                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2610                 return CAMERA_ERROR_INVALID_PARAMETER;
2611         }
2612
2613
2614         int ret = CAMERA_ERROR_NONE;
2615
2616         camera_cli_s *pc = (camera_cli_s *)camera;
2617         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
2618         int sock_fd;
2619         if (pc->cb_info == NULL) {
2620                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2621                 return CAMERA_ERROR_INVALID_PARAMETER;
2622         }
2623         sock_fd = pc->cb_info->fd;
2624         int get_width;
2625         int get_height;
2626
2627         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2628         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2629
2630         if (ret == CAMERA_ERROR_NONE) {
2631                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2632                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2633                 *width = get_width;
2634                 *height = get_height;
2635         }
2636         LOGD("ret : 0x%x", ret);
2637         return ret;
2638 }
2639
2640 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
2641 {
2642         int ret = CAMERA_ERROR_NONE;
2643         camera_cli_s *pc = NULL;
2644
2645         if (camera == NULL) {
2646                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2647                 return CAMERA_ERROR_INVALID_PARAMETER;
2648         }
2649
2650         if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
2651                 return CAMERA_ERROR_INVALID_PARAMETER;
2652         }
2653
2654         pc = (camera_cli_s *)camera;
2655
2656         if (pc->client_handle == NULL) {
2657                 LOGE("client handle is NULL");
2658                 return CAMERA_ERROR_INVALID_OPERATION;
2659         }
2660
2661         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2662                 MMCAM_DISPLAY_ROTATION, rotation,
2663                 NULL);
2664
2665         return __convert_camera_error_code(__func__, ret);
2666 }
2667
2668 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
2669 {
2670         int ret = CAMERA_ERROR_NONE;
2671         camera_cli_s *pc = NULL;
2672
2673         if (camera == NULL || rotation == NULL) {
2674                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2675                 return CAMERA_ERROR_INVALID_PARAMETER;
2676         }
2677
2678         pc = (camera_cli_s *)camera;
2679
2680         if (pc->client_handle == NULL) {
2681                 LOGE("client handle is NULL");
2682                 return CAMERA_ERROR_INVALID_OPERATION;
2683         }
2684
2685         ret = mm_camcorder_get_attributes(pc->client_handle, NULL,
2686                 MMCAM_DISPLAY_ROTATION, rotation,
2687                 NULL);
2688
2689         return __convert_camera_error_code(__func__, ret);
2690 }
2691
2692 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
2693 {
2694         int ret = CAMERA_ERROR_NONE;
2695         camera_cli_s *pc = NULL;
2696
2697         if (camera == NULL) {
2698                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2699                 return CAMERA_ERROR_INVALID_PARAMETER;
2700         }
2701
2702         if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
2703                 return CAMERA_ERROR_INVALID_PARAMETER;
2704         }
2705
2706         pc = (camera_cli_s *)camera;
2707
2708         if (pc->client_handle == NULL) {
2709                 LOGE("client handle is NULL");
2710                 return CAMERA_ERROR_INVALID_OPERATION;
2711         }
2712
2713         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2714                 MMCAM_DISPLAY_FLIP, flip,
2715                 NULL);
2716
2717         return __convert_camera_error_code(__func__, ret);
2718 }
2719
2720 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
2721 {
2722         int ret = CAMERA_ERROR_NONE;
2723         camera_cli_s *pc = NULL;
2724
2725         if (camera == NULL || flip == NULL) {
2726                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2727                 return CAMERA_ERROR_INVALID_PARAMETER;
2728         }
2729
2730         pc = (camera_cli_s *)camera;
2731
2732         if (pc->client_handle == NULL) {
2733                 LOGE("client handle is NULL");
2734                 return CAMERA_ERROR_INVALID_OPERATION;
2735         }
2736
2737         ret = mm_camcorder_get_attributes(pc->client_handle, NULL,
2738                 MMCAM_DISPLAY_FLIP, flip,
2739                 NULL);
2740
2741         return __convert_camera_error_code(__func__, ret);
2742 }
2743
2744 int camera_set_display_visible(camera_h camera, bool visible)
2745 {
2746         int ret = CAMERA_ERROR_NONE;
2747         camera_cli_s *pc = NULL;
2748
2749         if (camera == NULL) {
2750                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2751                 return CAMERA_ERROR_INVALID_PARAMETER;
2752         }
2753
2754         pc = (camera_cli_s *)camera;
2755
2756         if (pc->client_handle == NULL) {
2757                 LOGE("client handle is NULL");
2758                 return CAMERA_ERROR_INVALID_OPERATION;
2759         }
2760
2761         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2762                 MMCAM_DISPLAY_VISIBLE, visible,
2763                 NULL);
2764
2765         return __convert_camera_error_code(__func__, ret);
2766 }
2767
2768 int camera_is_display_visible(camera_h camera, bool* visible)
2769 {
2770         if (camera == NULL || visible == NULL) {
2771                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2772                 return CAMERA_ERROR_INVALID_PARAMETER;
2773         }
2774
2775         int ret = CAMERA_ERROR_NONE;
2776
2777         camera_cli_s *pc = (camera_cli_s *)camera;
2778         muse_camera_api_e api = MUSE_CAMERA_API_IS_DISPLAY_VISIBLE;
2779         int sock_fd;
2780         if (pc->cb_info == NULL) {
2781                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2782                 return CAMERA_ERROR_INVALID_PARAMETER;
2783         }
2784         sock_fd = pc->cb_info->fd;
2785         int get_visible;
2786
2787         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2788         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2789
2790         if (ret == CAMERA_ERROR_NONE) {
2791                 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
2792                 *visible = (bool)get_visible;
2793         }
2794         LOGD("ret : 0x%x", ret);
2795         return ret;
2796 }
2797
2798 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
2799 {
2800         int ret = CAMERA_ERROR_NONE;
2801         camera_cli_s *pc = NULL;
2802
2803         if (camera == NULL) {
2804                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2805                 return CAMERA_ERROR_INVALID_PARAMETER;
2806         }
2807
2808         if (mode < CAMERA_DISPLAY_MODE_LETTER_BOX || mode > CAMERA_DISPLAY_MODE_CROPPED_FULL) {
2809                 return CAMERA_ERROR_INVALID_PARAMETER;
2810         }
2811
2812         pc = (camera_cli_s *)camera;
2813
2814         if (pc->client_handle == NULL) {
2815                 LOGE("client handle is NULL");
2816                 return CAMERA_ERROR_INVALID_OPERATION;
2817         }
2818
2819         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2820                 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
2821                 NULL);
2822
2823         return __convert_camera_error_code(__func__, ret);
2824 }
2825
2826 int camera_get_display_mode(camera_h camera, camera_display_mode_e* mode)
2827 {
2828         int ret = CAMERA_ERROR_NONE;
2829         camera_cli_s *pc = NULL;
2830
2831         if (camera == NULL || mode == NULL) {
2832                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2833                 return CAMERA_ERROR_INVALID_PARAMETER;
2834         }
2835
2836         pc = (camera_cli_s *)camera;
2837
2838         if (pc->client_handle == NULL) {
2839                 LOGE("client handle is NULL");
2840                 return CAMERA_ERROR_INVALID_OPERATION;
2841         }
2842
2843         ret = mm_camcorder_get_attributes(pc->client_handle, NULL,
2844                 MMCAM_DISPLAY_GEOMETRY_METHOD, mode,
2845                 NULL);
2846
2847         return __convert_camera_error_code(__func__, ret);
2848 }
2849
2850 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
2851 {
2852         if (camera == NULL || width == NULL || height == NULL) {
2853                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2854                 return CAMERA_ERROR_INVALID_PARAMETER;
2855         }
2856         int ret = CAMERA_ERROR_NONE;
2857
2858         camera_cli_s *pc = (camera_cli_s *)camera;
2859         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
2860         int sock_fd;
2861         if (pc->cb_info == NULL) {
2862                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2863                 return CAMERA_ERROR_INVALID_PARAMETER;
2864         }
2865         sock_fd = pc->cb_info->fd;
2866         int get_width;
2867         int get_height;
2868
2869         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2870         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2871
2872         if (ret == CAMERA_ERROR_NONE) {
2873                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2874                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2875                 *width = get_width;
2876                 *height = get_height;
2877         }
2878         LOGD("ret : 0x%x", ret);
2879         return ret;
2880 }
2881
2882 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
2883 {
2884         if (camera == NULL || format == NULL) {
2885                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2886                 return CAMERA_ERROR_INVALID_PARAMETER;
2887         }
2888         int ret = CAMERA_ERROR_NONE;
2889
2890         camera_cli_s *pc = (camera_cli_s *)camera;
2891         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
2892         int get_format;
2893         int sock_fd;
2894         if (pc->cb_info == NULL) {
2895                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2896                 return CAMERA_ERROR_INVALID_PARAMETER;
2897         }
2898         sock_fd = pc->cb_info->fd;
2899
2900         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2901         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2902
2903         if (ret == CAMERA_ERROR_NONE) {
2904                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
2905                 *format = (camera_pixel_format_e)get_format;
2906         }
2907         LOGD("ret : 0x%x", ret);
2908         return ret;
2909 }
2910
2911 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
2912 {
2913         if (camera == NULL || format == NULL) {
2914                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2915                 return CAMERA_ERROR_INVALID_PARAMETER;
2916         }
2917
2918         int ret = CAMERA_ERROR_NONE;
2919
2920         camera_cli_s *pc = (camera_cli_s *)camera;
2921         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
2922         int get_format;
2923         int sock_fd;
2924         if (pc->cb_info == NULL) {
2925                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2926                 return CAMERA_ERROR_INVALID_PARAMETER;
2927         }
2928         sock_fd = pc->cb_info->fd;
2929
2930         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2931         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2932
2933         if (ret == CAMERA_ERROR_NONE) {
2934                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
2935                 *format = (camera_pixel_format_e)get_format;
2936         }
2937         LOGD("ret : 0x%x", ret);
2938         return ret;
2939 }
2940
2941 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton)
2942 {
2943         if (camera == NULL || facing_direciton == NULL) {
2944                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2945                 return CAMERA_ERROR_INVALID_PARAMETER;
2946         }
2947
2948         int ret = CAMERA_ERROR_NONE;
2949
2950         camera_cli_s *pc = (camera_cli_s *)camera;
2951         muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
2952         int sock_fd;
2953         if (pc->cb_info == NULL) {
2954                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2955                 return CAMERA_ERROR_INVALID_PARAMETER;
2956         }
2957         sock_fd = pc->cb_info->fd;
2958         int get_facing_direction;
2959
2960         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2961         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2962
2963         if (ret == CAMERA_ERROR_NONE) {
2964                 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
2965                 *facing_direciton = (camera_facing_direction_e)get_facing_direction;
2966         }
2967         LOGD("ret : 0x%x", ret);
2968         return ret;
2969 }
2970
2971 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void* user_data)
2972 {
2973         if (camera == NULL || callback == NULL) {
2974                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2975                 return CAMERA_ERROR_INVALID_PARAMETER;
2976         }
2977         int ret = CAMERA_ERROR_NONE;
2978
2979         camera_cli_s *pc = (camera_cli_s *)camera;
2980         int sock_fd;
2981         if (pc->cb_info == NULL) {
2982                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2983                 return CAMERA_ERROR_INVALID_PARAMETER;
2984         }
2985         sock_fd = pc->cb_info->fd;
2986         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
2987
2988         LOGD("Enter, handle :%x", pc->remote_handle);
2989
2990         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
2991         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
2992
2993         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2994         LOGD("ret : 0x%x", ret);
2995         return ret;
2996 }
2997
2998 int camera_unset_preview_cb(camera_h camera)
2999 {
3000         if (camera == NULL) {
3001                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3002                 return CAMERA_ERROR_INVALID_PARAMETER;
3003         }
3004
3005         int ret = CAMERA_ERROR_NONE;
3006
3007         camera_cli_s *pc = (camera_cli_s *)camera;
3008         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3009
3010         LOGD("Enter, handle :%x", pc->remote_handle);
3011
3012         int sock_fd;
3013         if (pc->cb_info == NULL) {
3014                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3015                 return CAMERA_ERROR_INVALID_PARAMETER;
3016         }
3017         sock_fd = pc->cb_info->fd;
3018         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
3019         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
3020
3021         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3022         LOGD("ret : 0x%x", ret);
3023         return ret;
3024 }
3025
3026 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void* user_data)
3027 {
3028         if (camera == NULL) {
3029                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3030                 return CAMERA_ERROR_INVALID_PARAMETER;
3031         }
3032
3033         if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3034                 LOGE("NOT SUPPORTED");
3035                 return CAMERA_ERROR_NOT_SUPPORTED;
3036         }
3037
3038         if (callback == NULL) {
3039                 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
3040                 return CAMERA_ERROR_INVALID_PARAMETER;
3041         }
3042
3043         int ret = CAMERA_ERROR_NONE;
3044
3045         camera_cli_s *pc = (camera_cli_s *)camera;
3046         muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3047
3048         LOGD("Enter, handle :%x", pc->remote_handle);
3049
3050         int sock_fd;
3051         if (pc->cb_info == NULL) {
3052                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3053                 return CAMERA_ERROR_INVALID_PARAMETER;
3054         }
3055         sock_fd = pc->cb_info->fd;
3056         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3057         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3058
3059         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3060         LOGD("ret : 0x%x", ret);
3061         return ret;
3062 }
3063
3064 int camera_unset_media_packet_preview_cb(camera_h camera)
3065 {
3066         if (camera == NULL) {
3067                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3068                 return CAMERA_ERROR_INVALID_PARAMETER;
3069         }
3070
3071         int ret = CAMERA_ERROR_NONE;
3072
3073         camera_cli_s *pc = (camera_cli_s *)camera;
3074         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3075
3076         LOGD("Enter, handle :%x", pc->remote_handle);
3077
3078         int sock_fd;
3079         if (pc->cb_info == NULL) {
3080                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3081                 return CAMERA_ERROR_INVALID_PARAMETER;
3082         }
3083         sock_fd = pc->cb_info->fd;
3084         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3085         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3086
3087         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3088         LOGD("ret : 0x%x", ret);
3089         return ret;
3090 }
3091
3092 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data)
3093 {
3094         if (camera == NULL || callback == NULL) {
3095                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3096                 return CAMERA_ERROR_INVALID_PARAMETER;
3097         }
3098         int ret = CAMERA_ERROR_NONE;
3099
3100         camera_cli_s *pc = (camera_cli_s *)camera;
3101         muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3102
3103         LOGD("Enter, handle :%x", pc->remote_handle);
3104
3105         int sock_fd;
3106         if (pc->cb_info == NULL) {
3107                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3108                 return CAMERA_ERROR_INVALID_PARAMETER;
3109         }
3110         sock_fd = pc->cb_info->fd;
3111         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3112         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3113
3114         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3115         LOGD("ret : 0x%x", ret);
3116         return ret;
3117 }
3118 int camera_unset_state_changed_cb(camera_h camera)
3119 {
3120         if (camera == NULL) {
3121                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3122                 return CAMERA_ERROR_INVALID_PARAMETER;
3123         }
3124         int ret = CAMERA_ERROR_NONE;
3125
3126         camera_cli_s *pc = (camera_cli_s *)camera;
3127         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3128
3129         LOGD("Enter, handle :%x", pc->remote_handle);
3130
3131         int sock_fd;
3132         if (pc->cb_info == NULL) {
3133                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3134                 return CAMERA_ERROR_INVALID_PARAMETER;
3135         }
3136         sock_fd = pc->cb_info->fd;
3137         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3138         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3139
3140         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3141         LOGD("ret : 0x%x", ret);
3142         return ret;
3143 }
3144
3145 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3146 {
3147         if (camera == NULL || callback == NULL) {
3148                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3149                 return CAMERA_ERROR_INVALID_PARAMETER;
3150         }
3151         int ret = CAMERA_ERROR_NONE;
3152
3153         camera_cli_s *pc = (camera_cli_s *)camera;
3154         muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3155
3156         LOGD("Enter, handle :%x", pc->remote_handle);
3157
3158         int sock_fd;
3159         if (pc->cb_info == NULL) {
3160                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3161                 return CAMERA_ERROR_INVALID_PARAMETER;
3162         }
3163         sock_fd = pc->cb_info->fd;
3164         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3165         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3166
3167         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3168         LOGD("ret : 0x%x", ret);
3169         return ret;
3170 }
3171
3172 int camera_unset_interrupted_cb(camera_h camera)
3173 {
3174         if (camera == NULL) {
3175                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3176                 return CAMERA_ERROR_INVALID_PARAMETER;
3177         }
3178         int ret = CAMERA_ERROR_NONE;
3179
3180         camera_cli_s *pc = (camera_cli_s *)camera;
3181         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3182
3183         LOGD("Enter, handle :%x", pc->remote_handle);
3184
3185         int sock_fd;
3186         if (pc->cb_info == NULL) {
3187                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3188                 return CAMERA_ERROR_INVALID_PARAMETER;
3189         }
3190         sock_fd = pc->cb_info->fd;
3191         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3192         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3193
3194         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3195         LOGD("ret : 0x%x", ret);
3196         return ret;
3197 }
3198
3199 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data)
3200 {
3201         if (camera == NULL || callback == NULL) {
3202                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3203                 return CAMERA_ERROR_INVALID_PARAMETER;
3204         }
3205         int ret = CAMERA_ERROR_NONE;
3206
3207         camera_cli_s *pc = (camera_cli_s *)camera;
3208         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3209
3210         LOGD("Enter, handle :%x", pc->remote_handle);
3211
3212         int sock_fd;
3213         if (pc->cb_info == NULL) {
3214                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3215                 return CAMERA_ERROR_INVALID_PARAMETER;
3216         }
3217         sock_fd = pc->cb_info->fd;
3218         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3219         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3220
3221         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3222         LOGD("ret : 0x%x", ret);
3223         return ret;
3224 }
3225
3226 int camera_unset_focus_changed_cb(camera_h camera)
3227 {
3228         if (camera == NULL) {
3229                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3230                 return CAMERA_ERROR_INVALID_PARAMETER;
3231         }
3232         int ret = CAMERA_ERROR_NONE;
3233
3234         camera_cli_s *pc = (camera_cli_s *)camera;
3235         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3236
3237         LOGD("Enter, handle :%x", pc->remote_handle);
3238
3239         int sock_fd;
3240         if (pc->cb_info == NULL) {
3241                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3242                 return CAMERA_ERROR_INVALID_PARAMETER;
3243         }
3244         sock_fd = pc->cb_info->fd;
3245         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3246         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3247
3248         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3249         LOGD("ret : 0x%x", ret);
3250         return ret;
3251 }
3252
3253 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3254 {
3255         if (camera == NULL || callback == NULL) {
3256                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3257                 return CAMERA_ERROR_INVALID_PARAMETER;
3258         }
3259         int ret = CAMERA_ERROR_NONE;
3260
3261         camera_cli_s *pc = (camera_cli_s *)camera;
3262         muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3263
3264         LOGD("Enter, handle :%x", pc->remote_handle);
3265
3266         int sock_fd;
3267         if (pc->cb_info == NULL) {
3268                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3269                 return CAMERA_ERROR_INVALID_PARAMETER;
3270         }
3271         sock_fd = pc->cb_info->fd;
3272         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3273         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3274
3275         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3276         LOGD("ret : 0x%x", ret);
3277         return ret;
3278 }
3279
3280 int camera_unset_error_cb(camera_h camera)
3281 {
3282         if (camera == NULL) {
3283                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3284                 return CAMERA_ERROR_INVALID_PARAMETER;
3285         }
3286         int ret = CAMERA_ERROR_NONE;
3287
3288         camera_cli_s *pc = (camera_cli_s *)camera;
3289         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3290
3291         LOGD("Enter, handle :%x", pc->remote_handle);
3292
3293         int sock_fd;
3294         if (pc->cb_info == NULL) {
3295                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3296                 return CAMERA_ERROR_INVALID_PARAMETER;
3297         }
3298         sock_fd = pc->cb_info->fd;
3299         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3300         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3301
3302         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3303         LOGD("ret : 0x%x", ret);
3304         return ret;
3305 }
3306
3307 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data)
3308 {
3309         if (camera == NULL || foreach_cb == NULL) {
3310                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3311                 return CAMERA_ERROR_INVALID_PARAMETER;
3312         }
3313         int ret = CAMERA_ERROR_NONE;
3314
3315         camera_cli_s *pc = (camera_cli_s *)camera;
3316         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3317
3318         LOGD("Enter, handle :%x", pc->remote_handle);
3319
3320         int sock_fd;
3321         if (pc->cb_info == NULL) {
3322                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3323                 return CAMERA_ERROR_INVALID_PARAMETER;
3324         }
3325         sock_fd = pc->cb_info->fd;
3326         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3327         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3328
3329         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3330         LOGD("ret : 0x%x", ret);
3331         return ret;
3332 }
3333
3334 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data)
3335 {
3336         if (camera == NULL || foreach_cb == NULL) {
3337                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3338                 return CAMERA_ERROR_INVALID_PARAMETER;
3339         }
3340         int ret = CAMERA_ERROR_NONE;
3341
3342         camera_cli_s *pc = (camera_cli_s *)camera;
3343         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3344
3345         LOGD("Enter, handle :%x", pc->remote_handle);
3346
3347         int sock_fd;
3348         if (pc->cb_info == NULL) {
3349                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3350                 return CAMERA_ERROR_INVALID_PARAMETER;
3351         }
3352         sock_fd = pc->cb_info->fd;
3353         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3354         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3355
3356         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3357         LOGD("ret : 0x%x", ret);
3358         return ret;
3359 }
3360
3361 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data)
3362 {
3363         if (camera == NULL || foreach_cb == NULL) {
3364                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3365                 return CAMERA_ERROR_INVALID_PARAMETER;
3366         }
3367         int ret = CAMERA_ERROR_NONE;
3368
3369         camera_cli_s *pc = (camera_cli_s *)camera;
3370         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3371
3372         LOGD("Enter, handle :%x", pc->remote_handle);
3373
3374         int sock_fd;
3375         if (pc->cb_info == NULL) {
3376                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3377                 return CAMERA_ERROR_INVALID_PARAMETER;
3378         }
3379         sock_fd = pc->cb_info->fd;
3380         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3381         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3382
3383         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3384         LOGD("ret : 0x%x", ret);
3385         return ret;
3386 }
3387
3388
3389 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data)
3390 {
3391         if (camera == NULL || foreach_cb == NULL) {
3392                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3393                 return CAMERA_ERROR_INVALID_PARAMETER;
3394         }
3395         int ret = CAMERA_ERROR_NONE;
3396
3397         camera_cli_s *pc = (camera_cli_s *)camera;
3398         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
3399
3400         LOGD("Enter, handle :%x", pc->remote_handle);
3401
3402         int sock_fd;
3403         if (pc->cb_info == NULL) {
3404                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3405                 return CAMERA_ERROR_INVALID_PARAMETER;
3406         }
3407         sock_fd = pc->cb_info->fd;
3408         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
3409         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
3410
3411         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3412         LOGD("ret : 0x%x", ret);
3413         return ret;
3414 }
3415
3416
3417 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
3418 {
3419         if (camera == NULL || width == NULL || height == NULL) {
3420                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3421                 return CAMERA_ERROR_INVALID_PARAMETER;
3422         }
3423         int ret = CAMERA_ERROR_NONE;
3424
3425         camera_cli_s *pc = (camera_cli_s *)camera;
3426         muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
3427         int sock_fd;
3428         if (pc->cb_info == NULL) {
3429                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3430                 return CAMERA_ERROR_INVALID_PARAMETER;
3431         }
3432         sock_fd = pc->cb_info->fd;
3433         int get_width;
3434         int get_height;
3435
3436         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3437         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3438
3439         if (ret == CAMERA_ERROR_NONE) {
3440                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3441                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3442                 *width = get_width;
3443                 *height = get_height;
3444         }
3445         LOGD("ret : 0x%x", ret);
3446         return ret;
3447 }
3448
3449
3450 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
3451 {
3452         if (camera == NULL || angle == NULL) {
3453                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3454                 return CAMERA_ERROR_INVALID_PARAMETER;
3455         }
3456         int ret = CAMERA_ERROR_NONE;
3457
3458         camera_cli_s *pc = (camera_cli_s *)camera;
3459         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
3460         int sock_fd;
3461         if (pc->cb_info == NULL) {
3462                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3463                 return CAMERA_ERROR_INVALID_PARAMETER;
3464         }
3465         sock_fd = pc->cb_info->fd;
3466         int get_angle;
3467
3468         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3469         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3470
3471         if (ret == CAMERA_ERROR_NONE) {
3472                 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
3473                 *angle = get_angle;
3474         }
3475         LOGD("ret : 0x%x", ret);
3476         return ret;
3477 }
3478
3479 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
3480 {
3481         if (camera == NULL) {
3482                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3483                 return CAMERA_ERROR_INVALID_PARAMETER;
3484         }
3485         int ret = CAMERA_ERROR_NONE;
3486         camera_cli_s *pc = (camera_cli_s *)camera;
3487         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
3488         int sock_fd;
3489         if (pc->cb_info == NULL) {
3490                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3491                 return CAMERA_ERROR_INVALID_PARAMETER;
3492         }
3493         sock_fd = pc->cb_info->fd;
3494         int set_mode = (int)mode;
3495         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3496         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3497         LOGD("ret : 0x%x", ret);
3498         return ret;
3499 }
3500
3501 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
3502 {
3503         if (camera == NULL || mode == NULL) {
3504                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3505                 return CAMERA_ERROR_INVALID_PARAMETER;
3506         }
3507
3508         int ret = CAMERA_ERROR_NONE;
3509         camera_cli_s *pc = (camera_cli_s *)camera;
3510         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
3511         int sock_fd;
3512         if (pc->cb_info == NULL) {
3513                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3514                 return CAMERA_ERROR_INVALID_PARAMETER;
3515         }
3516         sock_fd = pc->cb_info->fd;
3517         int get_mode;
3518         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3519         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3520
3521         if (ret == CAMERA_ERROR_NONE) {
3522                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3523                 *mode = (camera_attr_theater_mode_e)get_mode;
3524         }
3525         LOGD("ret : 0x%x", ret);
3526         return ret;
3527 }
3528
3529 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
3530 {
3531         if (camera == NULL || foreach_cb == NULL) {
3532                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3533                 return CAMERA_ERROR_INVALID_PARAMETER;
3534         }
3535         int ret = CAMERA_ERROR_NONE;
3536
3537         camera_cli_s *pc = (camera_cli_s *)camera;
3538         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
3539
3540         LOGD("Enter, handle :%x", pc->remote_handle);
3541
3542         int sock_fd;
3543         if (pc->cb_info == NULL) {
3544                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3545                 return CAMERA_ERROR_INVALID_PARAMETER;
3546         }
3547         sock_fd = pc->cb_info->fd;
3548         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
3549         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
3550
3551         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3552
3553         LOGD("Finish, return :%x", ret);
3554
3555         return ret;
3556 }
3557
3558 int camera_attr_set_preview_fps(camera_h camera,  camera_attr_fps_e fps)
3559 {
3560         if (camera == NULL) {
3561                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3562                 return CAMERA_ERROR_INVALID_PARAMETER;
3563         }
3564         int ret = CAMERA_ERROR_NONE;
3565         camera_cli_s *pc = (camera_cli_s *)camera;
3566         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
3567         int sock_fd;
3568         if (pc->cb_info == NULL) {
3569                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3570                 return CAMERA_ERROR_INVALID_PARAMETER;
3571         }
3572         sock_fd = pc->cb_info->fd;
3573         int set_fps = (int)fps;
3574         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3575         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_fps);
3576         LOGD("ret : 0x%x", ret);
3577         return ret;
3578 }
3579
3580
3581 int camera_attr_set_image_quality(camera_h camera,  int quality)
3582 {
3583         if (camera == NULL) {
3584                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3585                 return CAMERA_ERROR_INVALID_PARAMETER;
3586         }
3587         int ret = CAMERA_ERROR_NONE;
3588
3589         camera_cli_s *pc = (camera_cli_s *)camera;
3590         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
3591         int sock_fd;
3592         if (pc->cb_info == NULL) {
3593                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3594                 return CAMERA_ERROR_INVALID_PARAMETER;
3595         }
3596         sock_fd = pc->cb_info->fd;
3597         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3598         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, quality);
3599         LOGD("ret : 0x%x", ret);
3600         return ret;
3601 }
3602
3603 int camera_attr_get_preview_fps(camera_h camera,  camera_attr_fps_e *fps)
3604 {
3605         if (camera == NULL || fps == NULL) {
3606                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3607                 return CAMERA_ERROR_INVALID_PARAMETER;
3608         }
3609         int ret = CAMERA_ERROR_NONE;
3610
3611         camera_cli_s *pc = (camera_cli_s *)camera;
3612         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
3613         int get_fps;
3614         int sock_fd;
3615         if (pc->cb_info == NULL) {
3616                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3617                 return CAMERA_ERROR_INVALID_PARAMETER;
3618         }
3619         sock_fd = pc->cb_info->fd;
3620
3621         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3622         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3623
3624         if (ret == CAMERA_ERROR_NONE) {
3625                 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
3626                 *fps = (camera_attr_fps_e)get_fps;
3627         }
3628         LOGD("ret : 0x%x", ret);
3629         return ret;
3630 }
3631
3632
3633 int camera_attr_get_image_quality(camera_h camera, int *quality)
3634 {
3635         if (camera == NULL || quality == NULL) {
3636                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3637                 return CAMERA_ERROR_INVALID_PARAMETER;
3638         }
3639         int ret = CAMERA_ERROR_NONE;
3640
3641         camera_cli_s *pc = (camera_cli_s *)camera;
3642         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
3643         int sock_fd;
3644         if (pc->cb_info == NULL) {
3645                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3646                 return CAMERA_ERROR_INVALID_PARAMETER;
3647         }
3648         sock_fd = pc->cb_info->fd;
3649         int get_quality;
3650         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3651         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3652
3653         if (ret == CAMERA_ERROR_NONE) {
3654                 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
3655                 *quality = get_quality;
3656         }
3657         LOGD("ret : 0x%x", ret);
3658         return ret;
3659 }
3660
3661
3662 int camera_attr_set_zoom(camera_h camera, int zoom)
3663 {
3664         if (camera == NULL) {
3665                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3666                 return CAMERA_ERROR_INVALID_PARAMETER;
3667         }
3668         int ret = CAMERA_ERROR_NONE;
3669
3670         camera_cli_s *pc = (camera_cli_s *)camera;
3671         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
3672         int sock_fd;
3673         if (pc->cb_info == NULL) {
3674                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3675                 return CAMERA_ERROR_INVALID_PARAMETER;
3676         }
3677         sock_fd = pc->cb_info->fd;
3678
3679         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3680         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, zoom);
3681         LOGD("ret : 0x%x", ret);
3682         return ret;
3683 }
3684
3685 int camera_attr_set_af_mode(camera_h camera,  camera_attr_af_mode_e mode)
3686 {
3687         if (camera == NULL) {
3688                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3689                 return CAMERA_ERROR_INVALID_PARAMETER;
3690         }
3691         int ret = CAMERA_ERROR_NONE;
3692
3693         camera_cli_s *pc = (camera_cli_s *)camera;
3694         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
3695         int sock_fd;
3696         if (pc->cb_info == NULL) {
3697                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3698                 return CAMERA_ERROR_INVALID_PARAMETER;
3699         }
3700         sock_fd = pc->cb_info->fd;
3701         int set_mode = (int)mode;
3702         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3703         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3704         LOGD("ret : 0x%x", ret);
3705         return ret;
3706 }
3707
3708 int camera_attr_set_af_area(camera_h camera, int x, int y)
3709 {
3710         if (camera == NULL) {
3711                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3712                 return CAMERA_ERROR_INVALID_PARAMETER;
3713         }
3714         int ret = CAMERA_ERROR_NONE;
3715         camera_cli_s *pc = (camera_cli_s *)camera;
3716         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
3717         int sock_fd = pc->cb_info->fd;
3718         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3719         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, x, INT, y);
3720         LOGD("ret : 0x%x", ret);
3721         return ret;
3722 }
3723
3724
3725 int camera_attr_clear_af_area(camera_h camera)
3726 {
3727         if (camera == NULL) {
3728                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3729                 return CAMERA_ERROR_INVALID_PARAMETER;
3730         }
3731         int ret = CAMERA_ERROR_NONE;
3732
3733         camera_cli_s *pc = (camera_cli_s *)camera;
3734         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
3735         int sock_fd;
3736         if (pc->cb_info == NULL) {
3737                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3738                 return CAMERA_ERROR_INVALID_PARAMETER;
3739         }
3740         sock_fd = pc->cb_info->fd;
3741         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3742         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3743         LOGD("ret : 0x%x", ret);
3744         return ret;
3745 }
3746
3747
3748 int camera_attr_set_exposure_mode(camera_h camera,  camera_attr_exposure_mode_e mode)
3749 {
3750         if (camera == NULL) {
3751                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3752                 return CAMERA_ERROR_INVALID_PARAMETER;
3753         }
3754
3755         if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
3756                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3757                 return CAMERA_ERROR_INVALID_PARAMETER;
3758         }
3759
3760         int ret = CAMERA_ERROR_NONE;
3761         camera_cli_s *pc = (camera_cli_s *)camera;
3762         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
3763         int set_mode = (int)mode;
3764         int sock_fd;
3765         if (pc->cb_info == NULL) {
3766                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3767                 return CAMERA_ERROR_INVALID_PARAMETER;
3768         }
3769         sock_fd = pc->cb_info->fd;
3770         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3771         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3772         LOGD("ret : 0x%x", ret);
3773         return ret;
3774 }
3775
3776
3777 int camera_attr_set_exposure(camera_h camera, int value)
3778 {
3779         if (camera == NULL) {
3780                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3781                 return CAMERA_ERROR_INVALID_PARAMETER;
3782         }
3783         int ret = CAMERA_ERROR_NONE;
3784
3785         camera_cli_s *pc = (camera_cli_s *)camera;
3786         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
3787         int sock_fd;
3788         if (pc->cb_info == NULL) {
3789                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3790                 return CAMERA_ERROR_INVALID_PARAMETER;
3791         }
3792         sock_fd = pc->cb_info->fd;
3793
3794         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3795         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, value);
3796         LOGD("ret : 0x%x", ret);
3797         return ret;
3798 }
3799
3800
3801 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
3802 {
3803         if (camera == NULL) {
3804                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3805                 return CAMERA_ERROR_INVALID_PARAMETER;
3806         }
3807         int ret = CAMERA_ERROR_NONE;
3808
3809         camera_cli_s *pc = (camera_cli_s *)camera;
3810         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
3811         int sock_fd;
3812         if (pc->cb_info == NULL) {
3813                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3814                 return CAMERA_ERROR_INVALID_PARAMETER;
3815         }
3816         sock_fd = pc->cb_info->fd;
3817         int set_iso = (int)iso;
3818         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3819         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_iso);
3820         LOGD("ret : 0x%x", ret);
3821         return ret;
3822 }
3823
3824
3825 int camera_attr_set_brightness(camera_h camera, int level)
3826 {
3827         if (camera == NULL) {
3828                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3829                 return CAMERA_ERROR_INVALID_PARAMETER;
3830         }
3831         int ret = CAMERA_ERROR_NONE;
3832
3833         camera_cli_s *pc = (camera_cli_s *)camera;
3834         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
3835         int sock_fd;
3836         if (pc->cb_info == NULL) {
3837                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3838                 return CAMERA_ERROR_INVALID_PARAMETER;
3839         }
3840         sock_fd = pc->cb_info->fd;
3841
3842         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3843         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
3844         LOGD("ret : 0x%x", ret);
3845         return ret;
3846 }
3847
3848
3849 int camera_attr_set_contrast(camera_h camera, int level)
3850 {
3851         if (camera == NULL) {
3852                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3853                 return CAMERA_ERROR_INVALID_PARAMETER;
3854         }
3855         int ret = CAMERA_ERROR_NONE;
3856
3857         camera_cli_s *pc = (camera_cli_s *)camera;
3858         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
3859         int sock_fd;
3860         if (pc->cb_info == NULL) {
3861                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3862                 return CAMERA_ERROR_INVALID_PARAMETER;
3863         }
3864         sock_fd = pc->cb_info->fd;
3865
3866         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3867         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
3868         LOGD("ret : 0x%x", ret);
3869         return ret;
3870 }
3871
3872
3873 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
3874 {
3875         if (camera == NULL) {
3876                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3877                 return CAMERA_ERROR_INVALID_PARAMETER;
3878         }
3879
3880         if (wb < CAMERA_ATTR_WHITE_BALANCE_NONE || wb > CAMERA_ATTR_WHITE_BALANCE_CUSTOM) {
3881                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3882                 return CAMERA_ERROR_NOT_SUPPORTED;
3883         }
3884
3885         int ret = CAMERA_ERROR_NONE;
3886
3887         camera_cli_s *pc = (camera_cli_s *)camera;
3888         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
3889         int sock_fd;
3890         if (pc->cb_info == NULL) {
3891                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3892                 return CAMERA_ERROR_INVALID_PARAMETER;
3893         }
3894         sock_fd = pc->cb_info->fd;
3895         int set_whitebalance = (int)wb;
3896         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3897         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_whitebalance);
3898         LOGD("ret : 0x%x", ret);
3899         return ret;
3900 }
3901
3902
3903 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
3904 {
3905         if (camera == NULL) {
3906                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3907                 return CAMERA_ERROR_INVALID_PARAMETER;
3908         }
3909         int ret = CAMERA_ERROR_NONE;
3910
3911         camera_cli_s *pc = (camera_cli_s *)camera;
3912         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
3913         int sock_fd;
3914         if (pc->cb_info == NULL) {
3915                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3916                 return CAMERA_ERROR_INVALID_PARAMETER;
3917         }
3918         sock_fd = pc->cb_info->fd;
3919         int set_effect = (int)effect;
3920         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3921         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_effect);
3922         LOGD("ret : 0x%x", ret);
3923         return ret;
3924 }
3925
3926
3927 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
3928 {
3929         if (camera == NULL) {
3930                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3931                 return CAMERA_ERROR_INVALID_PARAMETER;
3932         }
3933         int ret = CAMERA_ERROR_NONE;
3934
3935         camera_cli_s *pc = (camera_cli_s *)camera;
3936         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
3937         int sock_fd;
3938         if (pc->cb_info == NULL) {
3939                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3940                 return CAMERA_ERROR_INVALID_PARAMETER;
3941         }
3942         sock_fd = pc->cb_info->fd;
3943         int set_mode = (int)mode;
3944         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3945         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3946         LOGD("ret : 0x%x", ret);
3947         return ret;
3948 }
3949
3950
3951 int camera_attr_enable_tag(camera_h camera, bool enable)
3952 {
3953         if (camera == NULL) {
3954                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3955                 return CAMERA_ERROR_INVALID_PARAMETER;
3956         }
3957         int ret = CAMERA_ERROR_NONE;
3958         camera_cli_s *pc = (camera_cli_s *)camera;
3959         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
3960         int sock_fd;
3961         if (pc->cb_info == NULL) {
3962                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3963                 return CAMERA_ERROR_INVALID_PARAMETER;
3964         }
3965         sock_fd = pc->cb_info->fd;
3966         int set_enable = (int)enable;
3967
3968         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3969         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
3970         LOGD("ret : 0x%x", ret);
3971         return ret;
3972 }
3973
3974
3975 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
3976 {
3977         if (camera == NULL) {
3978                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3979                 return CAMERA_ERROR_INVALID_PARAMETER;
3980         }
3981         if (description == NULL) {
3982                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3983                 return CAMERA_ERROR_INVALID_PARAMETER;
3984         }
3985         int ret = CAMERA_ERROR_NONE;
3986         camera_cli_s *pc = (camera_cli_s *)camera;
3987         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
3988         int sock_fd;
3989         if (pc->cb_info == NULL) {
3990                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3991                 return CAMERA_ERROR_INVALID_PARAMETER;
3992         }
3993         sock_fd = pc->cb_info->fd;
3994         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3995         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, description);
3996         LOGD("ret : 0x%x", ret);
3997         return ret;
3998 }
3999
4000
4001 int camera_attr_set_tag_orientation(camera_h camera,  camera_attr_tag_orientation_e orientation)
4002 {
4003         if (camera == NULL) {
4004                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4005                 return CAMERA_ERROR_INVALID_PARAMETER;
4006         }
4007         int ret = CAMERA_ERROR_NONE;
4008         camera_cli_s *pc = (camera_cli_s *)camera;
4009         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4010         int sock_fd;
4011         if (pc->cb_info == NULL) {
4012                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4013                 return CAMERA_ERROR_INVALID_PARAMETER;
4014         }
4015         sock_fd = pc->cb_info->fd;
4016         int set_orientation = (int)orientation;
4017
4018         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4019         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_orientation);
4020         LOGD("ret : 0x%x", ret);
4021         return ret;
4022 }
4023
4024
4025 int camera_attr_set_tag_software(camera_h camera,  const char *software)
4026 {
4027         if (camera == NULL) {
4028                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4029                 return CAMERA_ERROR_INVALID_PARAMETER;
4030         }
4031         if (software == NULL) {
4032                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4033                 return CAMERA_ERROR_INVALID_PARAMETER;
4034         }
4035         int ret = CAMERA_ERROR_NONE;
4036         camera_cli_s *pc = (camera_cli_s *)camera;
4037         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4038         int sock_fd;
4039         if (pc->cb_info == NULL) {
4040                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4041                 return CAMERA_ERROR_INVALID_PARAMETER;
4042         }
4043         sock_fd = pc->cb_info->fd;
4044         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4045         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, software);
4046         LOGD("ret : 0x%x", ret);
4047         return ret;
4048 }
4049
4050
4051 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
4052 {
4053         if (camera == NULL) {
4054                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4055                 return CAMERA_ERROR_INVALID_PARAMETER;
4056         }
4057         int ret = CAMERA_ERROR_NONE;
4058         camera_cli_s *pc = (camera_cli_s *)camera;
4059         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4060         int sock_fd;
4061         if (pc->cb_info == NULL) {
4062                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4063                 return CAMERA_ERROR_INVALID_PARAMETER;
4064         }
4065         sock_fd = pc->cb_info->fd;
4066         double set_geotag[3] = { latitude, longitude, altitude };
4067
4068         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4069         muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
4070                                                                         set_geotag, sizeof(set_geotag), sizeof(double));
4071         LOGD("ret : 0x%x", ret);
4072         return ret;
4073 }
4074
4075
4076 int camera_attr_remove_geotag(camera_h camera)
4077 {
4078         if (camera == NULL) {
4079                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4080                 return CAMERA_ERROR_INVALID_PARAMETER;
4081         }
4082         int ret = CAMERA_ERROR_NONE;
4083         camera_cli_s *pc = (camera_cli_s *)camera;
4084         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4085         int sock_fd;
4086         if (pc->cb_info == NULL) {
4087                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4088                 return CAMERA_ERROR_INVALID_PARAMETER;
4089         }
4090         sock_fd = pc->cb_info->fd;
4091         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4092         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4093         LOGD("ret : 0x%x", ret);
4094         return ret;
4095 }
4096
4097
4098 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4099 {
4100         if (camera == NULL) {
4101                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4102                 return CAMERA_ERROR_INVALID_PARAMETER;
4103         }
4104         int ret = CAMERA_ERROR_NONE;
4105         camera_cli_s *pc = (camera_cli_s *)camera;
4106         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4107         int sock_fd;
4108         if (pc->cb_info == NULL) {
4109                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4110                 return CAMERA_ERROR_INVALID_PARAMETER;
4111         }
4112         sock_fd = pc->cb_info->fd;
4113         int set_mode = (int)mode;
4114
4115         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4116         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4117         LOGD("ret : 0x%x", ret);
4118         return ret;
4119 }
4120
4121
4122 int camera_attr_get_zoom(camera_h camera, int *zoom)
4123 {
4124         if (camera == NULL || zoom == NULL) {
4125                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4126                 return CAMERA_ERROR_INVALID_PARAMETER;
4127         }
4128         int ret = CAMERA_ERROR_NONE;
4129
4130         camera_cli_s *pc = (camera_cli_s *)camera;
4131         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4132         int get_zoom;
4133         int sock_fd;
4134         if (pc->cb_info == NULL) {
4135                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4136                 return CAMERA_ERROR_INVALID_PARAMETER;
4137         }
4138         sock_fd = pc->cb_info->fd;
4139
4140         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4141         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4142
4143         if (ret == CAMERA_ERROR_NONE) {
4144                 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4145                 *zoom = get_zoom;
4146         }
4147         LOGD("ret : 0x%x", ret);
4148         return ret;
4149 }
4150
4151
4152 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4153 {
4154         if (camera == NULL || min == NULL || max == NULL) {
4155                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4156                 return CAMERA_ERROR_INVALID_PARAMETER;
4157         }
4158         int ret = CAMERA_ERROR_NONE;
4159         camera_cli_s *pc = (camera_cli_s *)camera;
4160         int sock_fd;
4161         if (pc->cb_info == NULL) {
4162                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4163                 return CAMERA_ERROR_INVALID_PARAMETER;
4164         }
4165         sock_fd = pc->cb_info->fd;
4166         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4167         int get_min;
4168         int get_max;
4169
4170         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4171         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4172
4173         if (ret == CAMERA_ERROR_NONE) {
4174                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4175                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4176                 *min = get_min;
4177                 *max = get_max;
4178         }
4179         LOGD("ret : 0x%x", ret);
4180         return ret;
4181 }
4182
4183
4184 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4185 {
4186         if (camera == NULL || mode == NULL) {
4187                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4188                 return CAMERA_ERROR_INVALID_PARAMETER;
4189         }
4190         int ret = CAMERA_ERROR_NONE;
4191         camera_cli_s *pc = (camera_cli_s *)camera;
4192         int sock_fd;
4193         if (pc->cb_info == NULL) {
4194                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4195                 return CAMERA_ERROR_INVALID_PARAMETER;
4196         }
4197         sock_fd = pc->cb_info->fd;
4198         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4199         int get_mode;
4200
4201         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4202         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4203
4204         if (ret == CAMERA_ERROR_NONE) {
4205                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4206                 *mode = (camera_attr_af_mode_e)get_mode;
4207         }
4208         LOGD("ret : 0x%x", ret);
4209         return ret;
4210 }
4211
4212
4213 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4214 {
4215         if (camera == NULL || mode == NULL) {
4216                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4217                 return CAMERA_ERROR_INVALID_PARAMETER;
4218         }
4219         int ret = CAMERA_ERROR_NONE;
4220         camera_cli_s *pc = (camera_cli_s *)camera;
4221         int sock_fd;
4222         if (pc->cb_info == NULL) {
4223                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4224                 return CAMERA_ERROR_INVALID_PARAMETER;
4225         }
4226         sock_fd = pc->cb_info->fd;
4227         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4228         int get_mode;
4229
4230         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4231         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4232
4233         if (ret == CAMERA_ERROR_NONE) {
4234                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4235                 *mode = (camera_attr_exposure_mode_e)get_mode;
4236         }
4237         LOGD("ret : 0x%x", ret);
4238         return ret;
4239 }
4240
4241 int camera_attr_get_exposure(camera_h camera, int *value)
4242 {
4243         if (camera == NULL || value == NULL) {
4244                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4245                 return CAMERA_ERROR_INVALID_PARAMETER;
4246         }
4247         int ret = CAMERA_ERROR_NONE;
4248         camera_cli_s *pc = (camera_cli_s *)camera;
4249         int sock_fd;
4250         if (pc->cb_info == NULL) {
4251                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4252                 return CAMERA_ERROR_INVALID_PARAMETER;
4253         }
4254         sock_fd = pc->cb_info->fd;
4255         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4256         int get_value;
4257
4258         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4259         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4260
4261         if (ret == CAMERA_ERROR_NONE) {
4262                 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4263                 *value = get_value;
4264         }
4265         LOGD("ret : 0x%x", ret);
4266         return ret;
4267 }
4268
4269
4270 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4271 {
4272         if (camera == NULL || min == NULL || max == NULL) {
4273                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4274                 return CAMERA_ERROR_INVALID_PARAMETER;
4275         }
4276         int ret = CAMERA_ERROR_NONE;
4277         camera_cli_s *pc = (camera_cli_s *)camera;
4278         int sock_fd;
4279         if (pc->cb_info == NULL) {
4280                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4281                 return CAMERA_ERROR_INVALID_PARAMETER;
4282         }
4283         sock_fd = pc->cb_info->fd;
4284         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4285         int get_min;
4286         int get_max;
4287
4288         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4289         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4290
4291         if (ret == CAMERA_ERROR_NONE) {
4292                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4293                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4294                 *min = get_min;
4295                 *max = get_max;
4296         }
4297         LOGD("ret : 0x%x", ret);
4298         return ret;
4299 }
4300
4301
4302 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4303 {
4304         if (camera == NULL || iso == NULL) {
4305                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4306                 return CAMERA_ERROR_INVALID_PARAMETER;
4307         }
4308         int ret = CAMERA_ERROR_NONE;
4309         camera_cli_s *pc = (camera_cli_s *)camera;
4310         int sock_fd;
4311         if (pc->cb_info == NULL) {
4312                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4313                 return CAMERA_ERROR_INVALID_PARAMETER;
4314         }
4315         sock_fd = pc->cb_info->fd;
4316         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4317         int get_iso;
4318
4319         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4320         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4321
4322         if (ret == CAMERA_ERROR_NONE) {
4323                 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
4324                 *iso = (camera_attr_iso_e)get_iso;
4325         }
4326         LOGD("ret : 0x%x", ret);
4327         return ret;
4328 }
4329
4330
4331 int camera_attr_get_brightness(camera_h camera,  int *level)
4332 {
4333         if (camera == NULL || level == NULL) {
4334                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4335                 return CAMERA_ERROR_INVALID_PARAMETER;
4336         }
4337         int ret = CAMERA_ERROR_NONE;
4338         camera_cli_s *pc = (camera_cli_s *)camera;
4339         int sock_fd;
4340         if (pc->cb_info == NULL) {
4341                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4342                 return CAMERA_ERROR_INVALID_PARAMETER;
4343         }
4344         sock_fd = pc->cb_info->fd;
4345         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4346         int get_level;
4347
4348         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4349         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4350
4351         if (ret == CAMERA_ERROR_NONE) {
4352                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4353                 *level = get_level;
4354         }
4355         LOGD("ret : 0x%x", ret);
4356         return ret;
4357 }
4358
4359
4360 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
4361 {
4362         if (camera == NULL || min == NULL || max == NULL) {
4363                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4364                 return CAMERA_ERROR_INVALID_PARAMETER;
4365         }
4366         int ret = CAMERA_ERROR_NONE;
4367         camera_cli_s *pc = (camera_cli_s *)camera;
4368         int sock_fd;
4369         if (pc->cb_info == NULL) {
4370                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4371                 return CAMERA_ERROR_INVALID_PARAMETER;
4372         }
4373         sock_fd = pc->cb_info->fd;
4374         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
4375         int get_min;
4376         int get_max;
4377
4378         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4379         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4380
4381         if (ret == CAMERA_ERROR_NONE) {
4382                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4383                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4384                 *min = get_min;
4385                 *max = get_max;
4386         }
4387         LOGD("ret : 0x%x", ret);
4388         return ret;
4389 }
4390
4391
4392 int camera_attr_get_contrast(camera_h camera,  int *level)
4393 {
4394         if (camera == NULL || level == NULL) {
4395                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4396                 return CAMERA_ERROR_INVALID_PARAMETER;
4397         }
4398         int ret = CAMERA_ERROR_NONE;
4399         camera_cli_s *pc = (camera_cli_s *)camera;
4400         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
4401         int sock_fd;
4402         if (pc->cb_info == NULL) {
4403                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4404                 return CAMERA_ERROR_INVALID_PARAMETER;
4405         }
4406         sock_fd = pc->cb_info->fd;
4407         int get_level;
4408
4409         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4410         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4411
4412         if (ret == CAMERA_ERROR_NONE) {
4413                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4414                 *level = get_level;
4415         }
4416         LOGD("ret : 0x%x", ret);
4417         return ret;
4418 }
4419
4420
4421 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max)
4422 {
4423         if (camera == NULL || min == NULL || max == NULL) {
4424                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4425                 return CAMERA_ERROR_INVALID_PARAMETER;
4426         }
4427         int ret = CAMERA_ERROR_NONE;
4428         camera_cli_s *pc = (camera_cli_s *)camera;
4429         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
4430         int sock_fd;
4431         if (pc->cb_info == NULL) {
4432                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4433                 return CAMERA_ERROR_INVALID_PARAMETER;
4434         }
4435         sock_fd = pc->cb_info->fd;
4436         int get_min;
4437         int get_max;
4438
4439         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4440         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4441
4442         if (ret == CAMERA_ERROR_NONE) {
4443                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4444                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4445                 *min = get_min;
4446                 *max = get_max;
4447         }
4448         LOGD("ret : 0x%x", ret);
4449         return ret;
4450 }
4451
4452
4453 int camera_attr_get_whitebalance(camera_h camera,  camera_attr_whitebalance_e *wb)
4454 {
4455         if (camera == NULL || wb == NULL) {
4456                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4457                 return CAMERA_ERROR_INVALID_PARAMETER;
4458         }
4459         int ret = CAMERA_ERROR_NONE;
4460         camera_cli_s *pc = (camera_cli_s *)camera;
4461         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
4462         int sock_fd;
4463         if (pc->cb_info == NULL) {
4464                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4465                 return CAMERA_ERROR_INVALID_PARAMETER;
4466         }
4467         sock_fd = pc->cb_info->fd;
4468         int get_wb;
4469
4470         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4471         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4472
4473         if (ret == CAMERA_ERROR_NONE) {
4474                 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
4475                 *wb = (camera_attr_whitebalance_e)get_wb;
4476         }
4477         LOGD("ret : 0x%x", ret);
4478         return ret;
4479 }
4480
4481
4482 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
4483 {
4484         if (camera == NULL || effect == NULL) {
4485                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4486                 return CAMERA_ERROR_INVALID_PARAMETER;
4487         }
4488
4489         int ret = CAMERA_ERROR_NONE;
4490         camera_cli_s *pc = (camera_cli_s *)camera;
4491         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
4492         int sock_fd;
4493         if (pc->cb_info == NULL) {
4494                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4495                 return CAMERA_ERROR_INVALID_PARAMETER;
4496         }
4497         sock_fd = pc->cb_info->fd;
4498         int get_effect;
4499
4500         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4501         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4502
4503         if (ret == CAMERA_ERROR_NONE) {
4504                 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
4505                 *effect = (camera_attr_effect_mode_e)get_effect;
4506         }
4507         LOGD("ret : 0x%x", ret);
4508         return ret;
4509 }
4510
4511
4512 int camera_attr_get_scene_mode(camera_h camera,  camera_attr_scene_mode_e *mode)
4513 {
4514         if (camera == NULL || mode == NULL) {
4515                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4516                 return CAMERA_ERROR_INVALID_PARAMETER;
4517         }
4518
4519         int ret = CAMERA_ERROR_NONE;
4520         camera_cli_s *pc = (camera_cli_s *)camera;
4521         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
4522         int sock_fd;
4523         if (pc->cb_info == NULL) {
4524                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4525                 return CAMERA_ERROR_INVALID_PARAMETER;
4526         }
4527         sock_fd = pc->cb_info->fd;
4528         int get_mode;
4529
4530         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4531         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4532
4533         if (ret == CAMERA_ERROR_NONE) {
4534                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4535                 *mode = (camera_attr_scene_mode_e)get_mode;
4536         }
4537         LOGD("ret : 0x%x", ret);
4538         return ret;
4539 }
4540
4541
4542 int camera_attr_is_enabled_tag(camera_h camera,  bool *enable)
4543 {
4544         if (camera == NULL || enable == NULL) {
4545                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4546                 return CAMERA_ERROR_INVALID_PARAMETER;
4547         }
4548
4549         int ret = CAMERA_ERROR_NONE;
4550         camera_cli_s *pc = (camera_cli_s *)camera;
4551         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
4552         int sock_fd;
4553         if (pc->cb_info == NULL) {
4554                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4555                 return CAMERA_ERROR_INVALID_PARAMETER;
4556         }
4557         sock_fd = pc->cb_info->fd;
4558         int get_enabled;
4559
4560         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4561         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4562
4563         if (ret == CAMERA_ERROR_NONE) {
4564                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
4565                 *enable = (bool)get_enabled;
4566         }
4567         LOGD("ret : 0x%x", ret);
4568         return ret;
4569 }
4570
4571
4572 int camera_attr_get_tag_image_description(camera_h camera,  char **description)
4573 {
4574         if (camera == NULL || description == NULL) {
4575                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4576                 return CAMERA_ERROR_INVALID_PARAMETER;
4577         }
4578
4579         int ret = CAMERA_ERROR_NONE;
4580         camera_cli_s *pc = (camera_cli_s *)camera;
4581         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
4582         int sock_fd;
4583         if (pc->cb_info == NULL) {
4584                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4585                 return CAMERA_ERROR_INVALID_PARAMETER;
4586         }
4587         sock_fd = pc->cb_info->fd;
4588         char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
4589
4590         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4591         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4592
4593         if (ret == CAMERA_ERROR_NONE) {
4594                 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
4595                 *description = strdup(get_description);
4596         }
4597         LOGD("ret : 0x%x", ret);
4598         return ret;
4599 }
4600
4601
4602 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
4603 {
4604         if (camera == NULL || orientation == NULL) {
4605                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4606                 return CAMERA_ERROR_INVALID_PARAMETER;
4607         }
4608
4609         int ret = CAMERA_ERROR_NONE;
4610         camera_cli_s *pc = (camera_cli_s *)camera;
4611         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
4612         int sock_fd;
4613         if (pc->cb_info == NULL) {
4614                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4615                 return CAMERA_ERROR_INVALID_PARAMETER;
4616         }
4617         sock_fd = pc->cb_info->fd;
4618         int get_orientation;
4619
4620         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4621         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4622
4623         if (ret == CAMERA_ERROR_NONE) {
4624                 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
4625                 *orientation = (camera_attr_tag_orientation_e)get_orientation;
4626                 LOGD("success, orientation : %d", *orientation);
4627         }
4628         LOGD("ret : 0x%x", ret);
4629         return ret;
4630 }
4631
4632
4633 int camera_attr_get_tag_software(camera_h camera, char **software)
4634 {
4635         if (camera == NULL || software == NULL) {
4636                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4637                 return CAMERA_ERROR_INVALID_PARAMETER;
4638         }
4639
4640         int ret = CAMERA_ERROR_NONE;
4641         camera_cli_s *pc = (camera_cli_s *)camera;
4642         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
4643         int sock_fd;
4644         if (pc->cb_info == NULL) {
4645                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4646                 return CAMERA_ERROR_INVALID_PARAMETER;
4647         }
4648         sock_fd = pc->cb_info->fd;
4649         char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
4650
4651         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4652         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4653
4654         if (ret == CAMERA_ERROR_NONE) {
4655                 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
4656                 *software = strdup(get_software);
4657         }
4658         LOGD("ret : 0x%x", ret);
4659         return ret;
4660 }
4661
4662
4663 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
4664 {
4665         if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
4666                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4667                 return CAMERA_ERROR_INVALID_PARAMETER;
4668         }
4669
4670         int ret = CAMERA_ERROR_NONE;
4671         camera_cli_s *pc = (camera_cli_s *)camera;
4672         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
4673         double get_geotag[3] = {0,};
4674         int sock_fd;
4675         if (pc->cb_info == NULL) {
4676                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4677                 return CAMERA_ERROR_INVALID_PARAMETER;
4678         }
4679         sock_fd = pc->cb_info->fd;
4680         int valid = 0;
4681         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4682         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4683
4684         if (ret == CAMERA_ERROR_NONE) {
4685                 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
4686                 *latitude = get_geotag[0];
4687                 *longitude = get_geotag[1];
4688                 *altitude = get_geotag[2];
4689         } else {
4690                 LOGE("Returned value is not valid : 0x%x", valid);
4691         }
4692
4693         LOGD("ret : 0x%x", ret);
4694
4695         return ret;
4696 }
4697
4698
4699 int camera_attr_get_flash_mode(camera_h camera,  camera_attr_flash_mode_e *mode)
4700 {
4701         if (camera == NULL || mode == NULL) {
4702                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4703                 return CAMERA_ERROR_INVALID_PARAMETER;
4704         }
4705
4706         int ret = CAMERA_ERROR_NONE;
4707         camera_cli_s *pc = (camera_cli_s *)camera;
4708         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
4709         int sock_fd;
4710         if (pc->cb_info == NULL) {
4711                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4712                 return CAMERA_ERROR_INVALID_PARAMETER;
4713         }
4714         sock_fd = pc->cb_info->fd;
4715         int get_mode;
4716
4717         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4718         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4719
4720         if (ret == CAMERA_ERROR_NONE) {
4721                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4722                 *mode = (camera_attr_flash_mode_e)get_mode;
4723         }
4724         LOGD("ret : 0x%x", ret);
4725         return ret;
4726 }
4727
4728
4729 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
4730 {
4731         if (camera == NULL || foreach_cb == NULL) {
4732                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4733                 return CAMERA_ERROR_INVALID_PARAMETER;
4734         }
4735         int ret = CAMERA_ERROR_NONE;
4736
4737         camera_cli_s *pc = (camera_cli_s *)camera;
4738         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
4739
4740         LOGD("Enter, handle :%x", pc->remote_handle);
4741
4742         int sock_fd;
4743         if (pc->cb_info == NULL) {
4744                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4745                 return CAMERA_ERROR_INVALID_PARAMETER;
4746         }
4747         sock_fd = pc->cb_info->fd;
4748         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
4749         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
4750
4751         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4752         LOGD("ret : 0x%x", ret);
4753         return ret;
4754 }
4755
4756
4757 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data)
4758 {
4759         if (camera == NULL || foreach_cb == NULL) {
4760                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4761                 return CAMERA_ERROR_INVALID_PARAMETER;
4762         }
4763         int ret = CAMERA_ERROR_NONE;
4764
4765         camera_cli_s *pc = (camera_cli_s *)camera;
4766         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
4767
4768         LOGD("Enter, handle :%x", pc->remote_handle);
4769
4770         int sock_fd;
4771         if (pc->cb_info == NULL) {
4772                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4773                 return CAMERA_ERROR_INVALID_PARAMETER;
4774         }
4775         sock_fd = pc->cb_info->fd;
4776         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
4777         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
4778
4779         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4780         LOGD("ret : 0x%x", ret);
4781         return ret;
4782 }
4783
4784
4785 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
4786 {
4787         if (camera == NULL || foreach_cb == NULL) {
4788                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4789                 return CAMERA_ERROR_INVALID_PARAMETER;
4790         }
4791         int ret = CAMERA_ERROR_NONE;
4792
4793         camera_cli_s *pc = (camera_cli_s *)camera;
4794         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
4795
4796         LOGD("Enter, handle :%x", pc->remote_handle);
4797
4798         int sock_fd;
4799         if (pc->cb_info == NULL) {
4800                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4801                 return CAMERA_ERROR_INVALID_PARAMETER;
4802         }
4803         sock_fd = pc->cb_info->fd;
4804         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
4805         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
4806
4807         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4808         LOGD("ret : 0x%x", ret);
4809         return ret;
4810 }
4811
4812
4813 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data)
4814 {
4815         if (camera == NULL || foreach_cb == NULL) {
4816                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4817                 return CAMERA_ERROR_INVALID_PARAMETER;
4818         }
4819         int ret = CAMERA_ERROR_NONE;
4820
4821         camera_cli_s *pc = (camera_cli_s *)camera;
4822         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
4823
4824         LOGD("Enter, handle :%x", pc->remote_handle);
4825
4826         int sock_fd;
4827         if (pc->cb_info == NULL) {
4828                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4829                 return CAMERA_ERROR_INVALID_PARAMETER;
4830         }
4831         sock_fd = pc->cb_info->fd;
4832         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
4833         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
4834
4835         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4836         LOGD("ret : 0x%x", ret);
4837         return ret;
4838 }
4839
4840
4841 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data)
4842 {
4843         if (camera == NULL || foreach_cb == NULL) {
4844                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4845                 return CAMERA_ERROR_INVALID_PARAMETER;
4846         }
4847         int ret = CAMERA_ERROR_NONE;
4848
4849         camera_cli_s *pc = (camera_cli_s *)camera;
4850         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
4851
4852         LOGD("Enter, handle :%x", pc->remote_handle);
4853
4854         int sock_fd;
4855         if (pc->cb_info == NULL) {
4856                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4857                 return CAMERA_ERROR_INVALID_PARAMETER;
4858         }
4859         sock_fd = pc->cb_info->fd;
4860         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
4861         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
4862
4863         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4864         LOGD("ret : 0x%x", ret);
4865         return ret;
4866 }
4867
4868
4869 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data)
4870 {
4871         if (camera == NULL || foreach_cb == NULL) {
4872                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4873                 return CAMERA_ERROR_INVALID_PARAMETER;
4874         }
4875         int ret = CAMERA_ERROR_NONE;
4876
4877         camera_cli_s *pc = (camera_cli_s *)camera;
4878         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
4879
4880         LOGD("Enter, handle :%x", pc->remote_handle);
4881
4882         int sock_fd;
4883         if (pc->cb_info == NULL) {
4884                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4885                 return CAMERA_ERROR_INVALID_PARAMETER;
4886         }
4887         sock_fd = pc->cb_info->fd;
4888         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
4889         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
4890
4891         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4892         LOGD("ret : 0x%x", ret);
4893         return ret;
4894 }
4895
4896
4897 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data)
4898 {
4899         if (camera == NULL || foreach_cb == NULL) {
4900                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4901                 return CAMERA_ERROR_INVALID_PARAMETER;
4902         }
4903         int ret = CAMERA_ERROR_NONE;
4904
4905         camera_cli_s *pc = (camera_cli_s *)camera;
4906         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
4907
4908         LOGD("Enter, handle :%x", pc->remote_handle);
4909
4910         int sock_fd;
4911         if (pc->cb_info == NULL) {
4912                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4913                 return CAMERA_ERROR_INVALID_PARAMETER;
4914         }
4915         sock_fd = pc->cb_info->fd;
4916         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
4917         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
4918
4919         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4920         LOGD("ret : 0x%x", ret);
4921         return ret;
4922 }
4923
4924
4925 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data)
4926 {
4927         if (camera == NULL || foreach_cb == NULL) {
4928                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4929                 return CAMERA_ERROR_INVALID_PARAMETER;
4930         }
4931         int ret = CAMERA_ERROR_NONE;
4932
4933         camera_cli_s *pc = (camera_cli_s *)camera;
4934         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
4935         int sock_fd;
4936         if (pc->cb_info == NULL) {
4937                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4938                 return CAMERA_ERROR_INVALID_PARAMETER;
4939         }
4940         sock_fd = pc->cb_info->fd;
4941         LOGD("Enter, handle :%x", pc->remote_handle);
4942         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
4943         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
4944
4945         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4946         LOGD("Enter, handle :%x", pc->remote_handle);
4947         return ret;
4948 }
4949
4950 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)
4951 {
4952         if (camera == NULL || foreach_cb == NULL) {
4953                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4954                 return CAMERA_ERROR_INVALID_PARAMETER;
4955         }
4956         int ret = CAMERA_ERROR_NONE;
4957
4958         camera_cli_s *pc = (camera_cli_s *)camera;
4959         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
4960         int sock_fd;
4961         if (pc->cb_info == NULL) {
4962                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4963                 return CAMERA_ERROR_INVALID_PARAMETER;
4964         }
4965         sock_fd = pc->cb_info->fd;
4966         LOGD("Enter, handle :%x", pc->remote_handle);
4967         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
4968         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
4969
4970         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
4971         LOGD("ret : 0x%x", ret);
4972         return ret;
4973 }
4974
4975 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
4976 {
4977         if (camera == NULL || foreach_cb == NULL) {
4978                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4979                 return CAMERA_ERROR_INVALID_PARAMETER;
4980         }
4981         int ret = CAMERA_ERROR_NONE;
4982
4983         camera_cli_s *pc = (camera_cli_s *)camera;
4984         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
4985         int sock_fd;
4986         if (pc->cb_info == NULL) {
4987                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4988                 return CAMERA_ERROR_INVALID_PARAMETER;
4989         }
4990         sock_fd = pc->cb_info->fd;
4991         LOGD("Enter, handle :%x", pc->remote_handle);
4992         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
4993         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
4994
4995         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4996         LOGD("ret : 0x%x", ret);
4997         return ret;
4998 }
4999
5000
5001 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5002 {
5003         if (camera == NULL || foreach_cb == NULL) {
5004                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5005                 return CAMERA_ERROR_INVALID_PARAMETER;
5006         }
5007         int ret = CAMERA_ERROR_NONE;
5008
5009         camera_cli_s *pc = (camera_cli_s *)camera;
5010         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5011         int sock_fd;
5012         if (pc->cb_info == NULL) {
5013                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5014                 return CAMERA_ERROR_INVALID_PARAMETER;
5015         }
5016         sock_fd = pc->cb_info->fd;
5017         LOGD("Enter, handle :%x", pc->remote_handle);
5018         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5019         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5020
5021         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5022         LOGD("ret : 0x%x", ret);
5023         return ret;
5024 }
5025
5026
5027 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation)
5028 {
5029         if (camera == NULL) {
5030                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5031                 return CAMERA_ERROR_INVALID_PARAMETER;
5032         }
5033
5034         int ret = CAMERA_ERROR_NONE;
5035         camera_cli_s *pc = (camera_cli_s *)camera;
5036         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5037         int sock_fd;
5038         if (pc->cb_info == NULL) {
5039                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5040                 return CAMERA_ERROR_INVALID_PARAMETER;
5041         }
5042         sock_fd = pc->cb_info->fd;
5043         int set_rotation = (int)rotation;
5044
5045         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5046         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation);
5047         LOGD("ret : 0x%x", ret);
5048         return ret;
5049 }
5050
5051
5052 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation)
5053 {
5054         if (camera == NULL || rotation == NULL) {
5055                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5056                 return CAMERA_ERROR_INVALID_PARAMETER;
5057         }
5058
5059         int ret = CAMERA_ERROR_NONE;
5060         camera_cli_s *pc = (camera_cli_s *)camera;
5061         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5062         int sock_fd;
5063         if (pc->cb_info == NULL) {
5064                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5065                 return CAMERA_ERROR_INVALID_PARAMETER;
5066         }
5067         sock_fd = pc->cb_info->fd;
5068         int get_rotation;
5069
5070         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5071         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5072
5073         if (ret == CAMERA_ERROR_NONE) {
5074                 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5075                 *rotation = (camera_rotation_e)get_rotation;
5076         }
5077         LOGD("ret : 0x%x", ret);
5078         return ret;
5079 }
5080
5081
5082 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip)
5083 {
5084         if (camera == NULL) {
5085                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5086                 return CAMERA_ERROR_INVALID_PARAMETER;
5087         }
5088
5089         int ret = CAMERA_ERROR_NONE;
5090         camera_cli_s *pc = (camera_cli_s *)camera;
5091         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5092         int sock_fd;
5093         if (pc->cb_info == NULL) {
5094                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5095                 return CAMERA_ERROR_INVALID_PARAMETER;
5096         }
5097         sock_fd = pc->cb_info->fd;
5098         int set_flip = (int)flip;
5099
5100         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5101         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip);
5102         LOGD("ret : 0x%x", ret);
5103         return ret;
5104 }
5105
5106
5107 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip)
5108 {
5109         if (camera == NULL || flip == NULL) {
5110                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5111                 return CAMERA_ERROR_INVALID_PARAMETER;
5112         }
5113
5114         int ret = CAMERA_ERROR_NONE;
5115         camera_cli_s *pc = (camera_cli_s *)camera;
5116         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5117         int sock_fd;
5118         if (pc->cb_info == NULL) {
5119                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5120                 return CAMERA_ERROR_INVALID_PARAMETER;
5121         }
5122         sock_fd = pc->cb_info->fd;
5123         int get_flip;
5124
5125         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5126         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5127
5128         if (ret == CAMERA_ERROR_NONE) {
5129                 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5130                 *flip = (camera_flip_e)get_flip;
5131         }
5132         LOGD("ret : 0x%x", ret);
5133         return ret;
5134 }
5135
5136 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5137 {
5138         if (camera == NULL) {
5139                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5140                 return CAMERA_ERROR_INVALID_PARAMETER;
5141         }
5142
5143         int ret = CAMERA_ERROR_NONE;
5144         camera_cli_s *pc = (camera_cli_s *)camera;
5145         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5146         int sock_fd;
5147         if (pc->cb_info == NULL) {
5148                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5149                 return CAMERA_ERROR_INVALID_PARAMETER;
5150         }
5151         sock_fd = pc->cb_info->fd;
5152         int set_mode = (int)mode;
5153
5154         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5155         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
5156         LOGD("ret : 0x%x", ret);
5157         return ret;
5158 }
5159
5160
5161 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5162 {
5163         if (camera == NULL) {
5164                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5165                 return CAMERA_ERROR_INVALID_PARAMETER;
5166         }
5167         if (mode == NULL) {
5168                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - mode", CAMERA_ERROR_NOT_SUPPORTED);
5169                 return CAMERA_ERROR_NOT_SUPPORTED;
5170         }
5171         int ret = CAMERA_ERROR_NONE;
5172         camera_cli_s *pc = (camera_cli_s *)camera;
5173         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5174         int sock_fd;
5175         if (pc->cb_info == NULL) {
5176                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5177                 return CAMERA_ERROR_INVALID_PARAMETER;
5178         }
5179         sock_fd = pc->cb_info->fd;
5180         int get_mode;
5181
5182         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5183         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5184
5185         if (ret == CAMERA_ERROR_NONE) {
5186                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5187                 *mode = (camera_attr_hdr_mode_e)get_mode;
5188         }
5189         LOGD("ret : 0x%x", ret);
5190         return ret;
5191 }
5192
5193
5194 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5195 {
5196         if (camera == NULL) {
5197                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5198                 return false;
5199         }
5200
5201         int ret = CAMERA_ERROR_NONE;
5202         camera_cli_s *pc = (camera_cli_s *)camera;
5203         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5204         int sock_fd;
5205         if (pc->cb_info == NULL) {
5206                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5207                 return CAMERA_ERROR_INVALID_PARAMETER;
5208         }
5209         sock_fd = pc->cb_info->fd;
5210         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5211         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5212         LOGD("ret : 0x%x", ret);
5213         return (bool)ret;
5214 }
5215
5216
5217 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void* user_data)
5218 {
5219         if (camera == NULL) {
5220                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5221                 return CAMERA_ERROR_INVALID_PARAMETER;
5222         }
5223         if (callback == NULL) {
5224                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - callback", CAMERA_ERROR_NOT_SUPPORTED);
5225                 return CAMERA_ERROR_NOT_SUPPORTED;
5226         }
5227         int ret = CAMERA_ERROR_NONE;
5228
5229         camera_cli_s *pc = (camera_cli_s *)camera;
5230         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5231         int sock_fd;
5232         if (pc->cb_info == NULL) {
5233                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5234                 return CAMERA_ERROR_INVALID_PARAMETER;
5235         }
5236         sock_fd = pc->cb_info->fd;
5237         LOGD("Enter, handle :%x", pc->remote_handle);
5238
5239         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5240         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5241
5242         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5243         LOGD("ret : 0x%x", ret);
5244         return ret;
5245 }
5246
5247
5248 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5249 {
5250         if (camera == NULL) {
5251                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5252                 return CAMERA_ERROR_INVALID_PARAMETER;
5253         }
5254
5255         int ret = CAMERA_ERROR_NONE;
5256
5257         camera_cli_s *pc = (camera_cli_s *)camera;
5258         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5259         int sock_fd;
5260         if (pc->cb_info == NULL) {
5261                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5262                 return CAMERA_ERROR_INVALID_PARAMETER;
5263         }
5264         sock_fd = pc->cb_info->fd;
5265         LOGD("Enter, handle :%x", pc->remote_handle);
5266
5267         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5268         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5269
5270         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5271         LOGD("ret : 0x%x", ret);
5272         return ret;
5273 }
5274
5275
5276 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5277 {
5278         if (camera == NULL) {
5279                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5280                 return CAMERA_ERROR_INVALID_PARAMETER;
5281         }
5282
5283         int ret = CAMERA_ERROR_NONE;
5284         camera_cli_s *pc = (camera_cli_s *)camera;
5285         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5286         int sock_fd;
5287         if (pc->cb_info == NULL) {
5288                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5289                 return CAMERA_ERROR_INVALID_PARAMETER;
5290         }
5291         sock_fd = pc->cb_info->fd;
5292         int set_enable = (int)enable;
5293
5294         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5295         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5296         LOGD("ret : 0x%x", ret);
5297         return ret;
5298 }
5299
5300
5301 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled)
5302 {
5303         if (camera == NULL) {
5304                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5305                 return CAMERA_ERROR_INVALID_PARAMETER;
5306         }
5307         if (enabled == NULL) {
5308                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5309                 return CAMERA_ERROR_NOT_SUPPORTED;
5310         }
5311         int ret = CAMERA_ERROR_NONE;
5312         camera_cli_s *pc = (camera_cli_s *)camera;
5313         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5314         int sock_fd;
5315         if (pc->cb_info == NULL) {
5316                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5317                 return CAMERA_ERROR_INVALID_PARAMETER;
5318         }
5319         sock_fd = pc->cb_info->fd;
5320         int get_enabled;
5321
5322         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5323         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5324
5325         if (ret == CAMERA_ERROR_NONE) {
5326                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5327                 *enabled = (bool)get_enabled;
5328         }
5329         LOGD("ret : 0x%x", ret);
5330         return ret;
5331 }
5332
5333
5334 bool camera_attr_is_supported_anti_shake(camera_h camera)
5335 {
5336
5337         if (camera == NULL) {
5338                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5339                 return false;
5340         }
5341
5342         int ret = CAMERA_ERROR_NONE;
5343         camera_cli_s *pc = (camera_cli_s *)camera;
5344         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5345         int sock_fd;
5346         if (pc->cb_info == NULL) {
5347                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5348                 return CAMERA_ERROR_INVALID_PARAMETER;
5349         }
5350         sock_fd = pc->cb_info->fd;
5351         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5352         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5353         LOGD("ret : 0x%x", ret);
5354         return ret;
5355 }
5356
5357
5358 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5359 {
5360         if (camera == NULL) {
5361                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5362                 return CAMERA_ERROR_INVALID_PARAMETER;
5363         }
5364
5365         int ret = CAMERA_ERROR_NONE;
5366         camera_cli_s *pc = (camera_cli_s *)camera;
5367         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
5368         int sock_fd;
5369         if (pc->cb_info == NULL) {
5370                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5371                 return CAMERA_ERROR_INVALID_PARAMETER;
5372         }
5373         sock_fd = pc->cb_info->fd;
5374         int set_enable = (int)enable;
5375
5376         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5377         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5378         LOGD("ret : 0x%x", ret);
5379         return ret;
5380 }
5381
5382
5383 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5384 {
5385         if (camera == NULL) {
5386                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5387                 return CAMERA_ERROR_INVALID_PARAMETER;
5388         }
5389         if (enabled == NULL) {
5390                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5391                 return CAMERA_ERROR_NOT_SUPPORTED;
5392         }
5393         int ret = CAMERA_ERROR_NONE;
5394         camera_cli_s *pc = (camera_cli_s *)camera;
5395         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5396         int sock_fd;
5397         if (pc->cb_info == NULL) {
5398                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5399                 return CAMERA_ERROR_INVALID_PARAMETER;
5400         }
5401         sock_fd = pc->cb_info->fd;
5402         int get_enabled;
5403
5404         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5405         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5406
5407         if (ret == CAMERA_ERROR_NONE) {
5408                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5409                 *enabled = (bool)get_enabled;
5410         }
5411         LOGD("ret : 0x%x", ret);
5412         return ret;
5413 }
5414
5415
5416 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5417 {
5418         if (camera == NULL) {
5419                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5420                 return false;
5421         }
5422
5423         int ret = CAMERA_ERROR_NONE;
5424         camera_cli_s *pc = (camera_cli_s *)camera;
5425         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
5426         int sock_fd;
5427         if (pc->cb_info == NULL) {
5428                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5429                 return CAMERA_ERROR_INVALID_PARAMETER;
5430         }
5431         sock_fd = pc->cb_info->fd;
5432         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5433         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5434         LOGD("ret : 0x%x", ret);
5435         return ret;
5436 }
5437
5438
5439 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5440 {
5441         if (camera == NULL) {
5442                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5443                 return CAMERA_ERROR_INVALID_PARAMETER;
5444         }
5445
5446         int ret = CAMERA_ERROR_NONE;
5447         camera_cli_s *pc = (camera_cli_s *)camera;
5448         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
5449         int sock_fd;
5450         if (pc->cb_info == NULL) {
5451                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5452                 return CAMERA_ERROR_INVALID_PARAMETER;
5453         }
5454         sock_fd = pc->cb_info->fd;
5455         int set_enable = (int)enable;
5456
5457         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5458         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5459         LOGD("ret : 0x%x", ret);
5460         return ret;
5461 }
5462
5463
5464 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5465 {
5466         if (camera == NULL) {
5467                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5468                 return CAMERA_ERROR_INVALID_PARAMETER;
5469         }
5470         if (enabled == NULL) {
5471                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5472                 return CAMERA_ERROR_INVALID_PARAMETER;
5473         }
5474         int ret = CAMERA_ERROR_NONE;
5475         camera_cli_s *pc = (camera_cli_s *)camera;
5476         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5477         int sock_fd;
5478         if (pc->cb_info == NULL) {
5479                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5480                 return CAMERA_ERROR_INVALID_PARAMETER;
5481         }
5482         sock_fd = pc->cb_info->fd;
5483         int get_enabled;
5484
5485         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5486         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5487
5488         if (ret == CAMERA_ERROR_NONE) {
5489                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5490                 *enabled = (bool)get_enabled;
5491         }
5492         LOGD("ret : 0x%x", ret);
5493         return ret;
5494 }
5495
5496
5497 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5498 {
5499         if (camera == NULL) {
5500                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5501                 return false;
5502         }
5503
5504         int ret = CAMERA_ERROR_NONE;
5505         camera_cli_s *pc = (camera_cli_s *)camera;
5506         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
5507         int sock_fd;
5508         if (pc->cb_info == NULL) {
5509                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5510                 return CAMERA_ERROR_INVALID_PARAMETER;
5511         }
5512         sock_fd = pc->cb_info->fd;
5513         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5514         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5515         LOGD("ret : 0x%x", ret);
5516         return ret;
5517 }
5518
5519
5520 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5521 {
5522         if (camera == NULL) {
5523                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5524                 return CAMERA_ERROR_INVALID_PARAMETER;
5525         }
5526
5527         int ret = CAMERA_ERROR_NONE;
5528         camera_cli_s *pc = (camera_cli_s *)camera;
5529         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5530         int sock_fd;
5531         if (pc->cb_info == NULL) {
5532                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5533                 return CAMERA_ERROR_INVALID_PARAMETER;
5534         }
5535         sock_fd = pc->cb_info->fd;
5536         int set_disable = (int)disable;
5537
5538         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5539         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_disable);
5540         LOGD("ret : 0x%x", ret);
5541         return ret;
5542 }