Add new APIs for camera settings
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_attribute.c
1 /*
2  * libmm-camcorder
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jeongmo Yang <jm80.yang@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22
23 /*=======================================================================================
24 |  INCLUDE FILES                                                                        |
25 =======================================================================================*/
26 #include "mm_camcorder_internal.h"
27 #include "mm_camcorder_gstcommon.h"
28
29 #include <gst/video/colorbalance.h>
30 #include <gst/video/videooverlay.h>
31
32 /*-----------------------------------------------------------------------
33 |    MACRO DEFINITIONS:                                                 |
34 -----------------------------------------------------------------------*/
35 #define MMCAMCORDER_DEFAULT_CAMERA_WIDTH        640
36 #define MMCAMCORDER_DEFAULT_CAMERA_HEIGHT       480
37 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL 1000
38 #define MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL  89.0
39
40 /*---------------------------------------------------------------------------------------
41 |    GLOBAL VARIABLE DEFINITIONS for internal                                           |
42 ---------------------------------------------------------------------------------------*/
43
44 /*-----------------------------------------------------------------------
45 |    LOCAL VARIABLE DEFINITIONS for internal                            |
46 -----------------------------------------------------------------------*/
47 /*      Readonly attributes list.
48 *       If you want to make some attributes read only, write down here.
49 *       It will make them read only after composing whole attributes.
50 */
51
52 static int readonly_attributes[] = {
53         MM_CAM_CAMERA_DEVICE_COUNT,
54         MM_CAM_CAMERA_DEVICE_NAME,
55         MM_CAM_CAMERA_FACING_DIRECTION,
56         MM_CAM_CAMERA_SHUTTER_SPEED,
57         MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
58         MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
59         MM_CAM_CAPTURED_SCREENNAIL,
60         MM_CAM_RECOMMEND_DISPLAY_ROTATION,
61         MM_CAM_SUPPORT_ZSL_CAPTURE,
62         MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
63         MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
64         MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
65         MM_CAM_VIDEOSRC_ELEMENT_NAME,
66         MM_CAM_AUDIOSRC_ELEMENT_NAME
67 };
68
69 /*-----------------------------------------------------------------------
70 |    LOCAL FUNCTION PROTOTYPES:                                         |
71 -----------------------------------------------------------------------*/
72 /* STATIC INTERNAL FUNCTION */
73 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height);
74 static int  __mmcamcorder_set_conf_to_valid_info(MMHandleType handle);
75 static int  __mmcamcorder_release_conf_valid_info(MMHandleType handle);
76 static int  __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
77
78 /*=======================================================================
79 |  FUNCTION DEFINITIONS                                                 |
80 =======================================================================*/
81 /*-----------------------------------------------------------------------
82 |    GLOBAL FUNCTION DEFINITIONS:                                       |
83 -----------------------------------------------------------------------*/
84 MMHandleType
85 _mmcamcorder_alloc_attribute(MMHandleType handle)
86 {
87         MMCAM_LOG_INFO("");
88
89         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
90         MMHandleType attrs = NULL;
91         MMAttrsConstructInfo *attrs_const_info;
92         unsigned int attr_count = 0;
93         unsigned int idx;
94         int ret = MM_ERROR_NONE;
95
96         static int depth[] = {MM_CAMCORDER_AUDIO_FORMAT_PCM_U8, MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE};
97         static int flip_list[] = { MM_FLIP_NONE };
98         static int rotation_list[] = { MM_VIDEO_INPUT_ROTATION_NONE };
99         static int visible_values[] = { 0, 1 }; /*0: off, 1:on*/
100         static int tag_orientation_values[] = {
101                         1,      /*The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.*/
102                         2,      /*the 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.*/
103                         3,      /*the 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.*/
104                         4,      /*the 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.*/
105                         5,      /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual top.*/
106                         6,      /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual top.*/
107                         7,      /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.*/
108                         8,      /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.*/
109                 };
110
111         if (hcamcorder == NULL) {
112                 MMCAM_LOG_ERROR("handle is NULL");
113                 return 0;
114         }
115
116         /* Create attribute constructor */
117         MMCAM_LOG_INFO("start");
118
119         /* alloc 'MMAttrsConstructInfo' */
120         attr_count = MM_CAM_ATTRIBUTE_NUM;
121         attrs_const_info = malloc(attr_count * sizeof(MMAttrsConstructInfo));
122         if (!attrs_const_info) {
123                 MMCAM_LOG_ERROR("Fail to alloc constructor.");
124                 return 0;
125         }
126
127         /* alloc default attribute info */
128         hcamcorder->cam_attrs_const_info = (mm_cam_attr_construct_info *)malloc(sizeof(mm_cam_attr_construct_info) * attr_count);
129         if (hcamcorder->cam_attrs_const_info == NULL) {
130                 MMCAM_LOG_ERROR("failed to alloc default attribute info");
131                 free(attrs_const_info);
132                 attrs_const_info = NULL;
133                 return 0;
134         }
135
136         /* basic attributes' info */
137         mm_cam_attr_construct_info temp_info[] = {
138                 /* 0 */
139                 {
140                         MM_CAM_MODE,                        /* ID */
141                         "mode",                             /* Name */
142                         MM_ATTRS_TYPE_INT,                 /* Type */
143                         MM_ATTRS_FLAG_RW,                   /* Flag */
144                         {(void*)MM_CAMCORDER_MODE_VIDEO_CAPTURE},     /* Default value */
145                         MM_ATTRS_VALID_TYPE_INT_RANGE,      /* Validity type */
146                         {.int_min = MM_CAMCORDER_MODE_VIDEO_CAPTURE},    /* Validity val1 (min, *array,...) */
147                         {.int_max = MM_CAMCORDER_MODE_AUDIO},            /* Validity val2 (max, count, ...) */
148                         NULL,                               /* Runtime setting function of the attribute */
149                 },
150                 {
151                         MM_CAM_AUDIO_DEVICE,
152                         "audio-device",
153                         MM_ATTRS_TYPE_INT,
154                         MM_ATTRS_FLAG_RW,
155                         {(void*)MM_AUDIO_DEVICE_MIC},
156                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
157                         {NULL},
158                         {0},
159                         NULL,
160                 },
161                 {
162                         MM_CAM_CAMERA_DEVICE_COUNT,
163                         "camera-device-count",
164                         MM_ATTRS_TYPE_INT,
165                         MM_ATTRS_FLAG_RW,
166                         {(void*)MM_VIDEO_DEVICE_NUM},
167                         MM_ATTRS_VALID_TYPE_INT_RANGE,
168                         {.int_min = MM_VIDEO_DEVICE_NONE},
169                         {.int_max = MM_VIDEO_DEVICE_NUM},
170                         NULL,
171                 },
172                 {
173                         MM_CAM_AUDIO_ENCODER,
174                         "audio-encoder",
175                         MM_ATTRS_TYPE_INT,
176                         MM_ATTRS_FLAG_RW,
177                         {(void*)MM_AUDIO_CODEC_AMR},
178                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
179                         {NULL},
180                         {0},
181                         NULL,
182                 },
183                 {
184                         MM_CAM_VIDEO_ENCODER,
185                         "video-encoder",
186                         MM_ATTRS_TYPE_INT,
187                         MM_ATTRS_FLAG_RW,
188                         {(void*)MM_VIDEO_CODEC_MPEG4},
189                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
190                         {NULL},
191                         {0},
192                         NULL,
193                 },
194                 {
195                         MM_CAM_IMAGE_ENCODER,
196                         "image-encoder",
197                         MM_ATTRS_TYPE_INT,
198                         MM_ATTRS_FLAG_RW,
199                         {(void*)MM_IMAGE_CODEC_JPEG},
200                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
201                         {NULL},
202                         {0},
203                         NULL,
204                 },
205                 {
206                         MM_CAM_FILE_FORMAT,
207                         "file-format",
208                         MM_ATTRS_TYPE_INT,
209                         MM_ATTRS_FLAG_RW,
210                         {(void*)MM_FILE_FORMAT_MP4},
211                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
212                         {NULL},
213                         {0},
214                         NULL,
215                 },
216                 {
217                         MM_CAM_CAMERA_DEVICE_NAME,
218                         "camera-device-name",
219                         MM_ATTRS_TYPE_STRING,
220                         MM_ATTRS_FLAG_RW,
221                         {NULL},
222                         MM_ATTRS_VALID_TYPE_NONE,
223                         {0},
224                         {0},
225                         NULL,
226                 },
227                 {
228                         MM_CAM_AUDIO_SAMPLERATE,
229                         "audio-samplerate",
230                         MM_ATTRS_TYPE_INT,
231                         MM_ATTRS_FLAG_RW,
232                         {(void*)8000},
233                         MM_ATTRS_VALID_TYPE_INT_RANGE,
234                         {.int_min = 0},
235                         {.int_max = _MMCAMCORDER_MAX_INT},
236                         NULL,
237                 },
238                 {
239                         MM_CAM_AUDIO_FORMAT,
240                         "audio-format",
241                         MM_ATTRS_TYPE_INT,
242                         MM_ATTRS_FLAG_RW,
243                         {(void*)MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE},
244                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
245                         {depth},
246                         {ARRAY_SIZE(depth)},
247                         NULL,
248                 },
249                 /* 10 */
250                 {
251                         MM_CAM_AUDIO_CHANNEL,
252                         "audio-channel",
253                         MM_ATTRS_TYPE_INT,
254                         MM_ATTRS_FLAG_RW,
255                         {(void*)2},
256                         MM_ATTRS_VALID_TYPE_INT_RANGE,
257                         {.int_min = 1},
258                         {.int_max = 2},
259                         NULL,
260                 },
261                 {
262                         MM_CAM_AUDIO_VOLUME,
263                         "audio-volume",
264                         MM_ATTRS_TYPE_DOUBLE,
265                         MM_ATTRS_FLAG_RW,
266                         {.value_double = 1.0},
267                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
268                         {.double_min = 0.0},
269                         {.double_max = 10.0},
270                         _mmcamcorder_commit_audio_volume,
271                 },
272                 {
273                         MM_CAM_AUDIO_INPUT_ROUTE,
274                         "audio-input-route",
275                         MM_ATTRS_TYPE_INT,
276                         MM_ATTRS_FLAG_RW,
277                         {(void*)MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
278                         MM_ATTRS_VALID_TYPE_INT_RANGE,
279                         {.int_min = MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
280                         {.int_max = MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY},
281                         _mmcamcorder_commit_audio_input_route,
282                 },
283                 {
284                         MM_CAM_FILTER_SCENE_MODE,
285                         "filter-scene-mode",
286                         MM_ATTRS_TYPE_INT,
287                         MM_ATTRS_FLAG_RW,
288                         {(void*)0},
289                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
290                         {0},
291                         {0},
292                         _mmcamcorder_commit_filter_scene_mode,
293                 },
294                 {
295                         MM_CAM_FILTER_BRIGHTNESS,
296                         "filter-brightness",
297                         MM_ATTRS_TYPE_INT,
298                         MM_ATTRS_FLAG_RW,
299                         {(void*)1},
300                         MM_ATTRS_VALID_TYPE_INT_RANGE,
301                         {.int_min = 0},
302                         {.int_max = -1},
303                         _mmcamcorder_commit_filter,
304                 },
305                 {
306                         MM_CAM_FILTER_CONTRAST,
307                         "filter-contrast",
308                         MM_ATTRS_TYPE_INT,
309                         MM_ATTRS_FLAG_RW,
310                         {(void*)0},
311                         MM_ATTRS_VALID_TYPE_INT_RANGE,
312                         {.int_min = 0},
313                         {.int_max = -1},
314                         _mmcamcorder_commit_filter,
315                 },
316                 {
317                         MM_CAM_FILTER_WB,
318                         "filter-wb",
319                         MM_ATTRS_TYPE_INT,
320                         MM_ATTRS_FLAG_RW,
321                         {(void*)0},
322                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
323                         {0},
324                         {0},
325                         _mmcamcorder_commit_filter,
326                 },
327                 {
328                         MM_CAM_FILTER_COLOR_TONE,
329                         "filter-color-tone",
330                         MM_ATTRS_TYPE_INT,
331                         MM_ATTRS_FLAG_RW,
332                         {(void*)0},
333                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
334                         {0},
335                         {0},
336                         _mmcamcorder_commit_filter,
337                 },
338                 {
339                         MM_CAM_FILTER_SATURATION,
340                         "filter-saturation",
341                         MM_ATTRS_TYPE_INT,
342                         MM_ATTRS_FLAG_RW,
343                         {(void*)0},
344                         MM_ATTRS_VALID_TYPE_INT_RANGE,
345                         {.int_min = 0},
346                         {.int_max = -1},
347                         _mmcamcorder_commit_filter,
348                 },
349                 {
350                         MM_CAM_FILTER_HUE,
351                         "filter-hue",
352                         MM_ATTRS_TYPE_INT,
353                         MM_ATTRS_FLAG_RW,
354                         {(void*)0},
355                         MM_ATTRS_VALID_TYPE_INT_RANGE,
356                         {.int_min = 0},
357                         {.int_max = -1},
358                         _mmcamcorder_commit_filter,
359                 },
360                 /* 20 */
361                 {
362                         MM_CAM_FILTER_SHARPNESS,
363                         "filter-sharpness",
364                         MM_ATTRS_TYPE_INT,
365                         MM_ATTRS_FLAG_RW,
366                         {(void*)0},
367                         MM_ATTRS_VALID_TYPE_INT_RANGE,
368                         {.int_min = 0},
369                         {.int_max = -1},
370                         _mmcamcorder_commit_filter,
371                 },
372                 {
373                         MM_CAM_CAMERA_FORMAT,
374                         "camera-format",
375                         MM_ATTRS_TYPE_INT,
376                         MM_ATTRS_FLAG_RW,
377                         {(void*)MM_PIXEL_FORMAT_YUYV},
378                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
379                         {0},
380                         {0},
381                         _mmcamcorder_commit_camera_format,
382                 },
383                 {
384                         MM_CAM_CAMERA_RECORDING_MOTION_RATE,
385                         "camera-recording-motion-rate",
386                         MM_ATTRS_TYPE_DOUBLE,
387                         MM_ATTRS_FLAG_RW,
388                         {.value_double = 1.0},
389                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
390                         {.double_min = 0.0},
391                         {.double_max = _MMCAMCORDER_MAX_DOUBLE},
392                         _mmcamcorder_commit_camera_recording_motion_rate,
393                 },
394                 {
395                         MM_CAM_CAMERA_FPS,
396                         "camera-fps",
397                         MM_ATTRS_TYPE_INT,
398                         MM_ATTRS_FLAG_RW,
399                         {(void*)30},
400                         MM_ATTRS_VALID_TYPE_INT_RANGE,
401                         {0},
402                         {1024},
403                         _mmcamcorder_commit_camera_fps,
404                 },
405                 {
406                         MM_CAM_CAMERA_WIDTH,
407                         "camera-width",
408                         MM_ATTRS_TYPE_INT,
409                         MM_ATTRS_FLAG_RW,
410                         {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
411                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
412                         {0},
413                         {0},
414                         _mmcamcorder_commit_camera_width,
415                 },
416                 {
417                         MM_CAM_CAMERA_HEIGHT,
418                         "camera-height",
419                         MM_ATTRS_TYPE_INT,
420                         MM_ATTRS_FLAG_RW,
421                         {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
422                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
423                         {0},
424                         {0},
425                         _mmcamcorder_commit_camera_height,
426                 },
427                 {
428                         MM_CAM_CAMERA_DIGITAL_ZOOM,
429                         "camera-digital-zoom",
430                         MM_ATTRS_TYPE_INT,
431                         MM_ATTRS_FLAG_RW,
432                         {(void*)10},
433                         MM_ATTRS_VALID_TYPE_INT_RANGE,
434                         {.int_min = 0},
435                         {.int_max = -1},
436                         _mmcamcorder_commit_camera_zoom,
437                 },
438                 {
439                         MM_CAM_CAMERA_OPTICAL_ZOOM,
440                         "camera-optical-zoom",
441                         MM_ATTRS_TYPE_INT,
442                         MM_ATTRS_FLAG_RW,
443                         {(void*)0},
444                         MM_ATTRS_VALID_TYPE_INT_RANGE,
445                         {.int_min = 0},
446                         {.int_max = -1},
447                         _mmcamcorder_commit_camera_zoom,
448                 },
449                 {
450                         MM_CAM_CAMERA_FOCUS_MODE,
451                         "camera-focus-mode",
452                         MM_ATTRS_TYPE_INT,
453                         MM_ATTRS_FLAG_RW,
454                         {(void*)MM_CAMCORDER_FOCUS_MODE_NONE},
455                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
456                         {0},
457                         {0},
458                         _mmcamcorder_commit_camera_focus_mode,
459                 },
460                 {
461                         MM_CAM_CAMERA_AF_SCAN_RANGE,
462                         "camera-af-scan-range",
463                         MM_ATTRS_TYPE_INT,
464                         MM_ATTRS_FLAG_RW,
465                         {(void*)0},
466                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
467                         {0},
468                         {0},
469                         _mmcamcorder_commit_camera_af_scan_range,
470                 },
471                 /* 30 */
472                 {
473                         MM_CAM_CAMERA_EXPOSURE_MODE,
474                         "camera-exposure-mode",
475                         MM_ATTRS_TYPE_INT,
476                         MM_ATTRS_FLAG_RW,
477                         {(void*)0},
478                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
479                         {0},
480                         {0},
481                         _mmcamcorder_commit_camera_capture_mode,
482                 },
483                 {
484                         MM_CAM_CAMERA_EXPOSURE_VALUE,
485                         "camera-exposure-value",
486                         MM_ATTRS_TYPE_INT,
487                         MM_ATTRS_FLAG_RW,
488                         {(void*)0},
489                         MM_ATTRS_VALID_TYPE_INT_RANGE,
490                         {.int_min = 0},
491                         {.int_max = -1},
492                         _mmcamcorder_commit_camera_capture_mode,
493                 },
494                 {
495                         MM_CAM_CAMERA_F_NUMBER,
496                         "camera-f-number",
497                         MM_ATTRS_TYPE_INT,
498                         MM_ATTRS_FLAG_RW,
499                         {(void*)0},
500                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
501                         {0},
502                         {0},
503                         _mmcamcorder_commit_camera_capture_mode,
504                 },
505                 {
506                         MM_CAM_CAMERA_SHUTTER_SPEED,
507                         "camera-shutter-speed",
508                         MM_ATTRS_TYPE_INT,
509                         MM_ATTRS_FLAG_RW,
510                         {(void*)0},
511                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
512                         {0},
513                         {0},
514                         _mmcamcorder_commit_camera_capture_mode,
515                 },
516                 {
517                         MM_CAM_CAMERA_ISO,
518                         "camera-iso",
519                         MM_ATTRS_TYPE_INT,
520                         MM_ATTRS_FLAG_RW,
521                         {(void*)0},
522                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
523                         {0},
524                         {0},
525                         _mmcamcorder_commit_camera_capture_mode,
526                 },
527                 {
528                         MM_CAM_CAMERA_WDR,
529                         "camera-wdr",
530                         MM_ATTRS_TYPE_INT,
531                         MM_ATTRS_FLAG_RW,
532                         {(void*)0},
533                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
534                         {0},
535                         {0},
536                         _mmcamcorder_commit_camera_wdr,
537                 },
538                 {
539                         MM_CAM_CAMERA_ANTI_HANDSHAKE,
540                         "camera-anti-handshake",
541                         MM_ATTRS_TYPE_INT,
542                         MM_ATTRS_FLAG_RW,
543                         {(void*)0},
544                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
545                         {0},
546                         {0},
547                         _mmcamcorder_commit_camera_anti_handshake,
548                 },
549                 {
550                         MM_CAM_CAMERA_FPS_AUTO,
551                         "camera-fps-auto",
552                         MM_ATTRS_TYPE_INT,
553                         MM_ATTRS_FLAG_RW,
554                         {(void*)FALSE},
555                         MM_ATTRS_VALID_TYPE_INT_RANGE,
556                         {.int_min = 0},
557                         {.int_max = 1},
558                         _mmcamcorder_commit_camera_fps,
559                 },
560                 {
561                         MM_CAM_CAMERA_DELAY_ATTR_SETTING,
562                         "camera-delay-attr-setting",
563                         MM_ATTRS_TYPE_INT,
564                         MM_ATTRS_FLAG_RW,
565                         {(void*)FALSE},
566                         MM_ATTRS_VALID_TYPE_INT_RANGE,
567                         {.int_min = 0},
568                         {.int_max = 1},
569                         NULL,
570                 },
571                 {
572                         MM_CAM_AUDIO_ENCODER_BITRATE,
573                         "audio-encoder-bitrate",
574                         MM_ATTRS_TYPE_INT,
575                         MM_ATTRS_FLAG_RW,
576                         {(void*)0},
577                         MM_ATTRS_VALID_TYPE_INT_RANGE,
578                         {.int_min = 0},
579                         {.int_max = _MMCAMCORDER_MAX_INT},
580                         _mmcamcorder_commit_encoder_bitrate,
581                 },
582                 /* 40 */
583                 {
584                         MM_CAM_VIDEO_ENCODER_BITRATE,
585                         "video-encoder-bitrate",
586                         MM_ATTRS_TYPE_INT,
587                         MM_ATTRS_FLAG_RW,
588                         {(void*)0},
589                         MM_ATTRS_VALID_TYPE_INT_RANGE,
590                         {.int_min = 0},
591                         {.int_max = _MMCAMCORDER_MAX_INT},
592                         _mmcamcorder_commit_encoder_bitrate,
593                 },
594                 {
595                         MM_CAM_IMAGE_ENCODER_QUALITY,
596                         "image-encoder-quality",
597                         MM_ATTRS_TYPE_INT,
598                         MM_ATTRS_FLAG_RW,
599                         {(void*)95},
600                         MM_ATTRS_VALID_TYPE_INT_RANGE,
601                         {.int_min = 0},
602                         {.int_max = -1},
603                         _mmcamcorder_commit_image_encoder_quality,
604                 },
605                 {
606                         MM_CAM_CAPTURE_FORMAT,
607                         "capture-format",
608                         MM_ATTRS_TYPE_INT,
609                         MM_ATTRS_FLAG_RW,
610                         {(void*)MM_PIXEL_FORMAT_ENCODED},
611                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
612                         {0},
613                         {0},
614                         NULL,
615                 },
616                 {
617                         MM_CAM_CAPTURE_WIDTH,
618                         "capture-width",
619                         MM_ATTRS_TYPE_INT,
620                         MM_ATTRS_FLAG_RW,
621                         {(void*)1600},
622                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
623                         {0},
624                         {0},
625                         _mmcamcorder_commit_capture_width ,
626                 },
627                 {
628                         MM_CAM_CAPTURE_HEIGHT,
629                         "capture-height",
630                         MM_ATTRS_TYPE_INT,
631                         MM_ATTRS_FLAG_RW,
632                         {(void*)1200},
633                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
634                         {0},
635                         {0},
636                         _mmcamcorder_commit_capture_height,
637                 },
638                 {
639                         MM_CAM_CAPTURE_COUNT,
640                         "capture-count",
641                         MM_ATTRS_TYPE_INT,
642                         MM_ATTRS_FLAG_RW,
643                         {(void*)1},
644                         MM_ATTRS_VALID_TYPE_INT_RANGE,
645                         {.int_min = 0},
646                         {.int_max = -1},
647                         _mmcamcorder_commit_capture_count,
648                 },
649                 {
650                         MM_CAM_CAPTURE_INTERVAL,
651                         "capture-interval",
652                         MM_ATTRS_TYPE_INT,
653                         MM_ATTRS_FLAG_RW,
654                         {(void*)0},
655                         MM_ATTRS_VALID_TYPE_INT_RANGE,
656                         {.int_min = 0},
657                         {.int_max = _MMCAMCORDER_MAX_INT},
658                         NULL,
659                 },
660                 {
661                         MM_CAM_CAPTURE_BREAK_CONTINUOUS_SHOT,
662                         "capture-break-cont-shot",
663                         MM_ATTRS_TYPE_INT,
664                         MM_ATTRS_FLAG_RW,
665                         {(void*)FALSE},
666                         MM_ATTRS_VALID_TYPE_INT_RANGE,
667                         {.int_min = 0},
668                         {.int_max = 1},
669                         _mmcamcorder_commit_capture_break_cont_shot,
670                 },
671                 {
672                         MM_CAM_DISPLAY_HANDLE,
673                         "display-handle",
674                         MM_ATTRS_TYPE_DATA,
675                         MM_ATTRS_FLAG_RW,
676                         {NULL},
677                         MM_ATTRS_VALID_TYPE_NONE,
678                         {0},
679                         {0},
680                         _mmcamcorder_commit_display_handle,
681                 },
682                 {
683                         MM_CAM_DISPLAY_DEVICE,
684                         "display-device",
685                         MM_ATTRS_TYPE_INT,
686                         MM_ATTRS_FLAG_RW,
687                         {(void*)MM_DISPLAY_DEVICE_MAINLCD},
688                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
689                         {0},
690                         {0},
691                         NULL,
692                 },
693                 /* 50 */
694                 {
695                         MM_CAM_DISPLAY_SURFACE,
696                         "display-surface",
697                         MM_ATTRS_TYPE_INT,
698                         MM_ATTRS_FLAG_RW,
699                         {(void*)MM_DISPLAY_SURFACE_OVERLAY},
700                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
701                         {0},
702                         {0},
703                         NULL,
704                 },
705                 {
706                         MM_CAM_DISPLAY_RECT_X,
707                         "display-rect-x",
708                         MM_ATTRS_TYPE_INT,
709                         MM_ATTRS_FLAG_RW,
710                         {(void*)0},
711                         MM_ATTRS_VALID_TYPE_INT_RANGE,
712                         {.int_min = 0},
713                         {.int_max = _MMCAMCORDER_MAX_INT},
714                         _mmcamcorder_commit_display_rect,
715                 },
716                 {
717                         MM_CAM_DISPLAY_RECT_Y,
718                         "display-rect-y",
719                         MM_ATTRS_TYPE_INT,
720                         MM_ATTRS_FLAG_RW,
721                         {(void*)0},
722                         MM_ATTRS_VALID_TYPE_INT_RANGE,
723                         {.int_min = 0},
724                         {.int_max = _MMCAMCORDER_MAX_INT},
725                         _mmcamcorder_commit_display_rect,
726                 },
727                 {
728                         MM_CAM_DISPLAY_RECT_WIDTH,
729                         "display-rect-width",
730                         MM_ATTRS_TYPE_INT,
731                         MM_ATTRS_FLAG_RW,
732                         {(void*)0},
733                         MM_ATTRS_VALID_TYPE_INT_RANGE,
734                         {.int_min = 1},
735                         {.int_max = _MMCAMCORDER_MAX_INT},
736                         _mmcamcorder_commit_display_rect,
737                 },
738                 {
739                         MM_CAM_DISPLAY_RECT_HEIGHT,
740                         "display-rect-height",
741                         MM_ATTRS_TYPE_INT,
742                         MM_ATTRS_FLAG_RW,
743                         {(void*)0},
744                         MM_ATTRS_VALID_TYPE_INT_RANGE,
745                         {.int_min = 1},
746                         {.int_max = _MMCAMCORDER_MAX_INT},
747                         _mmcamcorder_commit_display_rect,
748                 },
749                 {
750                         MM_CAM_DISPLAY_SOURCE_X,
751                         "display-src-x",
752                         MM_ATTRS_TYPE_INT,
753                         MM_ATTRS_FLAG_RW,
754                         {(void*)0},
755                         MM_ATTRS_VALID_TYPE_INT_RANGE,
756                         {.int_min = 0},
757                         {.int_max = _MMCAMCORDER_MAX_INT},
758                         NULL,
759                 },
760                 {
761                         MM_CAM_DISPLAY_SOURCE_Y,
762                         "display-src-y",
763                         MM_ATTRS_TYPE_INT,
764                         MM_ATTRS_FLAG_RW,
765                         {(void*)0},
766                         MM_ATTRS_VALID_TYPE_INT_RANGE,
767                         {.int_min = 0},
768                         {.int_max = _MMCAMCORDER_MAX_INT},
769                         NULL,
770                 },
771                 {
772                         MM_CAM_DISPLAY_SOURCE_WIDTH,
773                         "display-src-width",
774                         MM_ATTRS_TYPE_INT,
775                         MM_ATTRS_FLAG_RW,
776                         {(void*)0},
777                         MM_ATTRS_VALID_TYPE_INT_RANGE,
778                         {.int_min = 0},
779                         {.int_max = _MMCAMCORDER_MAX_INT},
780                         NULL,
781                 },
782                 {
783                         MM_CAM_DISPLAY_SOURCE_HEIGHT,
784                         "display-src-height",
785                         MM_ATTRS_TYPE_INT,
786                         MM_ATTRS_FLAG_RW,
787                         {(void*)0},
788                         MM_ATTRS_VALID_TYPE_INT_RANGE,
789                         {.int_min = 0},
790                         {.int_max = _MMCAMCORDER_MAX_INT},
791                         NULL,
792                 },
793                 {
794                         MM_CAM_DISPLAY_ROTATION,
795                         "display-rotation",
796                         MM_ATTRS_TYPE_INT,
797                         MM_ATTRS_FLAG_RW,
798                         {(void*)MM_DISPLAY_ROTATION_NONE},
799                         MM_ATTRS_VALID_TYPE_INT_RANGE,
800                         {.int_min = MM_DISPLAY_ROTATION_NONE},
801                         {.int_max = MM_DISPLAY_ROTATION_270},
802                         _mmcamcorder_commit_display_rotation,
803                 },
804                 /* 60 */
805                 {
806                         MM_CAM_DISPLAY_VISIBLE,
807                         "display-visible",
808                         MM_ATTRS_TYPE_INT,
809                         MM_ATTRS_FLAG_RW,
810                         {(void*)1},
811                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
812                         {visible_values},
813                         {ARRAY_SIZE(visible_values)},
814                         _mmcamcorder_commit_display_visible,
815                 },
816                 {
817                         MM_CAM_DISPLAY_SCALE,
818                         "display-scale",
819                         MM_ATTRS_TYPE_INT,
820                         MM_ATTRS_FLAG_RW,
821                         {(void*)0},
822                         MM_ATTRS_VALID_TYPE_INT_RANGE,
823                         {.int_min = MM_DISPLAY_SCALE_DEFAULT},
824                         {.int_max = MM_DISPLAY_SCALE_TRIPLE_LENGTH},
825                         _mmcamcorder_commit_display_scale,
826                 },
827                 {
828                         MM_CAM_DISPLAY_GEOMETRY_METHOD,
829                         "display-geometry-method",
830                         MM_ATTRS_TYPE_INT,
831                         MM_ATTRS_FLAG_RW,
832                         {(void*)0},
833                         MM_ATTRS_VALID_TYPE_INT_RANGE,
834                         {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
835                         {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
836                         _mmcamcorder_commit_display_geometry_method,
837                 },
838                 {
839                         MM_CAM_TARGET_FILENAME,
840                         "target-filename",
841                         MM_ATTRS_TYPE_STRING,
842                         MM_ATTRS_FLAG_RW,
843                         {NULL},
844                         MM_ATTRS_VALID_TYPE_NONE,
845                         {0},
846                         {0},
847                         _mmcamcorder_commit_target_filename,
848                 },
849                 {
850                         MM_CAM_TARGET_MAX_SIZE,
851                         "target-max-size",
852                         MM_ATTRS_TYPE_INT,
853                         MM_ATTRS_FLAG_RW,
854                         {(void*)0},
855                         MM_ATTRS_VALID_TYPE_INT_RANGE,
856                         {.int_min = 0},
857                         {.int_max = _MMCAMCORDER_MAX_INT},
858                         _mmcamcorder_commit_recording_max_limit,
859                 },
860                 {
861                         MM_CAM_TARGET_TIME_LIMIT,
862                         "target-time-limit",
863                         MM_ATTRS_TYPE_INT,
864                         MM_ATTRS_FLAG_RW,
865                         {(void*)0},
866                         MM_ATTRS_VALID_TYPE_INT_RANGE,
867                         {.int_min = 0},
868                         {.int_max = _MMCAMCORDER_MAX_INT},
869                         _mmcamcorder_commit_recording_max_limit,
870                 },
871                 {
872                         MM_CAM_TAG_ENABLE,
873                         "tag-enable",
874                         MM_ATTRS_TYPE_INT,
875                         MM_ATTRS_FLAG_RW,
876                         {(void*)FALSE},
877                         MM_ATTRS_VALID_TYPE_INT_RANGE,
878                         {.int_min = FALSE},
879                         {.int_max = TRUE},
880                         _mmcamcorder_commit_tag,
881                 },
882                 {
883                         MM_CAM_TAG_IMAGE_DESCRIPTION,
884                         "tag-image-description",
885                         MM_ATTRS_TYPE_STRING,
886                         MM_ATTRS_FLAG_RW,
887                         {NULL},
888                         MM_ATTRS_VALID_TYPE_NONE,
889                         {0},
890                         {0},
891                         _mmcamcorder_commit_tag,
892                 },
893                 {
894                         MM_CAM_TAG_ORIENTATION,
895                         "tag-orientation",
896                         MM_ATTRS_TYPE_INT,
897                         MM_ATTRS_FLAG_RW,
898                         {(void*)1},
899                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
900                         {tag_orientation_values},
901                         {ARRAY_SIZE(tag_orientation_values)},
902                         _mmcamcorder_commit_tag,
903                 },
904                 {
905                         MM_CAM_TAG_SOFTWARE,
906                         "tag-software",
907                         MM_ATTRS_TYPE_STRING,
908                         MM_ATTRS_FLAG_RW,
909                         {NULL},
910                         MM_ATTRS_VALID_TYPE_NONE,
911                         {0},
912                         {0},
913                         _mmcamcorder_commit_tag,
914                 },
915                 /* 70 */
916                 {
917                         MM_CAM_TAG_LATITUDE,
918                         "tag-latitude",
919                         MM_ATTRS_TYPE_DOUBLE,
920                         MM_ATTRS_FLAG_RW,
921                         {.value_double = 0.0},
922                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
923                         {.double_min = -360.0},
924                         {.double_max = 360.0},
925                         _mmcamcorder_commit_tag,
926                 },
927                 {
928                         MM_CAM_TAG_LONGITUDE,
929                         "tag-longitude",
930                         MM_ATTRS_TYPE_DOUBLE,
931                         MM_ATTRS_FLAG_RW,
932                         {.value_double = 0.0},
933                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
934                         {.double_min = -360.0},
935                         {.double_max = 360.0},
936                         _mmcamcorder_commit_tag,
937                 },
938                 {
939                         MM_CAM_TAG_ALTITUDE,
940                         "tag-altitude",
941                         MM_ATTRS_TYPE_DOUBLE,
942                         MM_ATTRS_FLAG_RW,
943                         {.value_double = 0.0},
944                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
945                         {.double_min = -999999.0},
946                         {.double_max = 999999.0},
947                         _mmcamcorder_commit_tag,
948                 },
949                 {
950                         MM_CAM_STROBE_CONTROL,
951                         "strobe-control",
952                         MM_ATTRS_TYPE_INT,
953                         MM_ATTRS_FLAG_RW,
954                         {(void*)0},
955                         MM_ATTRS_VALID_TYPE_INT_RANGE,
956                         {.int_min = 0},
957                         {.int_max = -1},
958                         _mmcamcorder_commit_strobe,
959                 },
960                 {
961                         MM_CAM_STROBE_CAPABILITIES,
962                         "strobe-capabilities",
963                         MM_ATTRS_TYPE_INT,
964                         MM_ATTRS_FLAG_RW,
965                         {(void*)0},
966                         MM_ATTRS_VALID_TYPE_INT_RANGE,
967                         {.int_min = 0},
968                         {.int_max = -1},
969                         _mmcamcorder_commit_strobe,
970                 },
971                 {
972                         MM_CAM_STROBE_MODE,
973                         "strobe-mode",
974                         MM_ATTRS_TYPE_INT,
975                         MM_ATTRS_FLAG_RW,
976                         {(void*)0},
977                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
978                         {0},
979                         {0},
980                         _mmcamcorder_commit_strobe,
981                 },
982                 {
983                         MM_CAM_DETECT_MODE,
984                         "detect-mode",
985                         MM_ATTRS_TYPE_INT,
986                         MM_ATTRS_FLAG_RW,
987                         {(void*)0},
988                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
989                         {0},
990                         {0},
991                         _mmcamcorder_commit_detect,
992                 },
993                 {
994                         MM_CAM_DETECT_NUMBER,
995                         "detect-number",
996                         MM_ATTRS_TYPE_INT,
997                         MM_ATTRS_FLAG_RW,
998                         {(void*)0},
999                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1000                         {.int_min = 0},
1001                         {.int_max = -1},
1002                         _mmcamcorder_commit_detect,
1003                 },
1004                 {
1005                         MM_CAM_DETECT_FOCUS_SELECT,
1006                         "detect-focus-select",
1007                         MM_ATTRS_TYPE_INT,
1008                         MM_ATTRS_FLAG_RW,
1009                         {(void*)0},
1010                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1011                         {.int_min = 0},
1012                         {.int_max = -1},
1013                         _mmcamcorder_commit_detect,
1014                 },
1015                 {
1016                         MM_CAM_DETECT_SELECT_NUMBER,
1017                         "detect-select-number",
1018                         MM_ATTRS_TYPE_INT,
1019                         MM_ATTRS_FLAG_RW,
1020                         {(void*)0},
1021                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1022                         {.int_min = 0},
1023                         {.int_max = -1},
1024                         _mmcamcorder_commit_detect,
1025                 },
1026                 /* 80 */
1027                 {
1028                         MM_CAM_DETECT_STATUS,
1029                         "detect-status",
1030                         MM_ATTRS_TYPE_INT,
1031                         MM_ATTRS_FLAG_RW,
1032                         {(void*)0},
1033                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1034                         {0},
1035                         {0},
1036                         _mmcamcorder_commit_detect,
1037                 },
1038                 {
1039                         MM_CAM_CAPTURE_ZERO_SYSTEMLAG,
1040                         "capture-zero-systemlag",
1041                         MM_ATTRS_TYPE_INT,
1042                         MM_ATTRS_FLAG_RW,
1043                         {(void*)FALSE},
1044                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1045                         {.int_min = 0},
1046                         {.int_max = 1},
1047                         NULL,
1048                 },
1049                 {
1050                         MM_CAM_CAMERA_AF_TOUCH_X,
1051                         "camera-af-touch-x",
1052                         MM_ATTRS_TYPE_INT,
1053                         MM_ATTRS_FLAG_RW,
1054                         {(void*)0},
1055                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1056                         {.int_min = 0},
1057                         {.int_max = _MMCAMCORDER_MAX_INT},
1058                         _mmcamcorder_commit_camera_af_touch_area,
1059                 },
1060                 {
1061                         MM_CAM_CAMERA_AF_TOUCH_Y,
1062                         "camera-af-touch-y",
1063                         MM_ATTRS_TYPE_INT,
1064                         MM_ATTRS_FLAG_RW,
1065                         {(void*)0},
1066                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1067                         {.int_min = 0},
1068                         {.int_max = _MMCAMCORDER_MAX_INT},
1069                         _mmcamcorder_commit_camera_af_touch_area,
1070                 },
1071                 {
1072                         MM_CAM_CAMERA_AF_TOUCH_WIDTH,
1073                         "camera-af-touch-width",
1074                         MM_ATTRS_TYPE_INT,
1075                         MM_ATTRS_FLAG_RW,
1076                         {(void*)0},
1077                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1078                         {.int_min = 0},
1079                         {.int_max = _MMCAMCORDER_MAX_INT},
1080                         _mmcamcorder_commit_camera_af_touch_area,
1081                 },
1082                 {
1083                         MM_CAM_CAMERA_AF_TOUCH_HEIGHT,
1084                         "camera-af-touch-height",
1085                         MM_ATTRS_TYPE_INT,
1086                         MM_ATTRS_FLAG_RW,
1087                         {(void*)0},
1088                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1089                         {.int_min = 0},
1090                         {.int_max = _MMCAMCORDER_MAX_INT},
1091                         _mmcamcorder_commit_camera_af_touch_area,
1092                 },
1093                 {
1094                         MM_CAM_CAMERA_FOCAL_LENGTH,
1095                         "camera-focal-length",
1096                         MM_ATTRS_TYPE_DOUBLE,
1097                         MM_ATTRS_FLAG_RW,
1098                         {.value_double = 0.0},
1099                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1100                         {.double_min = 0.0},
1101                         {.double_max = 1000.0},
1102                         _mmcamcorder_commit_camera_capture_mode,
1103                 },
1104                 {
1105                         MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
1106                         "recommend-preview-format-for-capture",
1107                         MM_ATTRS_TYPE_INT,
1108                         MM_ATTRS_FLAG_RW,
1109                         {(void*)MM_PIXEL_FORMAT_YUYV},
1110                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1111                         {.int_min = MM_PIXEL_FORMAT_NV12},
1112                         {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1113                         NULL,
1114                 },
1115                 {
1116                         MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
1117                         "recommend-preview-format-for-recording",
1118                         MM_ATTRS_TYPE_INT,
1119                         MM_ATTRS_FLAG_RW,
1120                         {(void*)MM_PIXEL_FORMAT_NV12},
1121                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1122                         {.int_min = MM_PIXEL_FORMAT_NV12},
1123                         {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1124                         NULL,
1125                 },
1126                 {
1127                         MM_CAM_TAG_GPS_ENABLE,
1128                         "tag-gps-enable",
1129                         MM_ATTRS_TYPE_INT,
1130                         MM_ATTRS_FLAG_RW,
1131                         {(void*)FALSE},
1132                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1133                         {.int_min = FALSE},
1134                         {.int_max = TRUE},
1135                         _mmcamcorder_commit_tag,
1136                 },
1137                 /* 90 */
1138                 {
1139                         MM_CAM_TAG_GPS_TIME_STAMP,
1140                         "tag-gps-time-stamp",
1141                         MM_ATTRS_TYPE_DOUBLE,
1142                         MM_ATTRS_FLAG_RW,
1143                         {.value_double = 0.0},
1144                         MM_ATTRS_VALID_TYPE_NONE,
1145                         {0},
1146                         {0},
1147                         _mmcamcorder_commit_tag,
1148                 },
1149                 {
1150                         MM_CAM_TAG_GPS_DATE_STAMP,
1151                         "tag-gps-date-stamp",
1152                         MM_ATTRS_TYPE_STRING,
1153                         MM_ATTRS_FLAG_RW,
1154                         {NULL},
1155                         MM_ATTRS_VALID_TYPE_NONE,
1156                         {0},
1157                         {0},
1158                         _mmcamcorder_commit_tag,
1159                 },
1160                 {
1161                         MM_CAM_TAG_GPS_PROCESSING_METHOD,
1162                         "tag-gps-processing-method",
1163                         MM_ATTRS_TYPE_STRING,
1164                         MM_ATTRS_FLAG_RW,
1165                         {NULL},
1166                         MM_ATTRS_VALID_TYPE_NONE,
1167                         {0},
1168                         {0},
1169                         _mmcamcorder_commit_tag,
1170                 },
1171                 {
1172                         MM_CAM_CAMERA_ROTATION,
1173                         "camera-rotation",
1174                         MM_ATTRS_TYPE_INT,
1175                         MM_ATTRS_FLAG_RW,
1176                         {(void*)MM_VIDEO_INPUT_ROTATION_NONE},
1177                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1178                         {rotation_list},
1179                         {ARRAY_SIZE(rotation_list)},
1180                         _mmcamcorder_commit_camera_rotate,
1181                 },
1182                 {
1183                         MM_CAM_CAPTURED_SCREENNAIL,
1184                         "captured-screennail",
1185                         MM_ATTRS_TYPE_DATA,
1186                         MM_ATTRS_FLAG_RW,
1187                         {NULL},
1188                         MM_ATTRS_VALID_TYPE_NONE,
1189                         {0},
1190                         {0},
1191                         NULL,
1192                 },
1193                 {
1194                         MM_CAM_CAPTURE_SOUND_ENABLE,
1195                         "capture-sound-enable",
1196                         MM_ATTRS_TYPE_INT,
1197                         MM_ATTRS_FLAG_RW,
1198                         {(void*)TRUE},
1199                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1200                         {.int_min = FALSE},
1201                         {.int_max = TRUE},
1202                         _mmcamcorder_commit_capture_sound_enable,
1203                 },
1204                 {
1205                         MM_CAM_RECOMMEND_DISPLAY_ROTATION,
1206                         "recommend-display-rotation",
1207                         MM_ATTRS_TYPE_INT,
1208                         MM_ATTRS_FLAG_RW,
1209                         {(void*)MM_DISPLAY_ROTATION_270},
1210                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1211                         {.int_min = MM_DISPLAY_ROTATION_NONE},
1212                         {.int_max = MM_DISPLAY_ROTATION_270},
1213                         NULL,
1214                 },
1215                 {
1216                         MM_CAM_CAMERA_FLIP,
1217                         "camera-flip",
1218                         MM_ATTRS_TYPE_INT,
1219                         MM_ATTRS_FLAG_RW,
1220                         {(void*)MM_FLIP_NONE},
1221                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1222                         {flip_list},
1223                         {ARRAY_SIZE(flip_list)},
1224                         _mmcamcorder_commit_camera_flip,
1225                 },
1226                 {
1227                         MM_CAM_CAMERA_HDR_CAPTURE,
1228                         "camera-hdr-capture",
1229                         MM_ATTRS_TYPE_INT,
1230                         MM_ATTRS_FLAG_RW,
1231                         {(void*)FALSE},
1232                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1233                         {0},
1234                         {0},
1235                         _mmcamcorder_commit_camera_hdr_capture,
1236                 },
1237                 {
1238                         MM_CAM_DISPLAY_MODE,
1239                         "display-mode",
1240                         MM_ATTRS_TYPE_INT,
1241                         MM_ATTRS_FLAG_RW,
1242                         {(void*)MM_DISPLAY_MODE_DEFAULT},
1243                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1244                         {0},
1245                         {0},
1246                         _mmcamcorder_commit_display_mode,
1247                 },
1248                 /* 100 */
1249                 {
1250                         MM_CAM_AUDIO_DISABLE,
1251                         "audio-disable",
1252                         MM_ATTRS_TYPE_INT,
1253                         MM_ATTRS_FLAG_RW,
1254                         {(void*)FALSE},
1255                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1256                         {.int_min = FALSE},
1257                         {.int_max = TRUE},
1258                         _mmcamcorder_commit_audio_disable,
1259                 },
1260                 {
1261                         MM_CAM_RECOMMEND_CAMERA_WIDTH,
1262                         "recommend-camera-width",
1263                         MM_ATTRS_TYPE_INT,
1264                         MM_ATTRS_FLAG_RW,
1265                         {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
1266                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1267                         {0},
1268                         {0},
1269                         NULL,
1270                 },
1271                 {
1272                         MM_CAM_RECOMMEND_CAMERA_HEIGHT,
1273                         "recommend-camera-height",
1274                         MM_ATTRS_TYPE_INT,
1275                         MM_ATTRS_FLAG_RW,
1276                         {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
1277                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1278                         {0},
1279                         {0},
1280                         NULL,
1281                 },
1282                 {
1283                         MM_CAM_CAPTURED_EXIF_RAW_DATA,
1284                         "captured-exif-raw-data",
1285                         MM_ATTRS_TYPE_DATA,
1286                         MM_ATTRS_FLAG_RW,
1287                         {NULL},
1288                         MM_ATTRS_VALID_TYPE_NONE,
1289                         {0},
1290                         {0},
1291                         NULL,
1292                 },
1293                 {
1294                         MM_CAM_DISPLAY_EVAS_SURFACE_SINK,
1295                         "display-evas-surface-sink",
1296                         MM_ATTRS_TYPE_STRING,
1297                         MM_ATTRS_FLAG_RW,
1298                         {NULL},
1299                         MM_ATTRS_VALID_TYPE_NONE,
1300                         {0},
1301                         {0},
1302                         NULL,
1303                 },
1304                 {
1305                         MM_CAM_DISPLAY_EVAS_DO_SCALING,
1306                         "display-evas-do-scaling",
1307                         MM_ATTRS_TYPE_INT,
1308                         MM_ATTRS_FLAG_RW,
1309                         {(void*)TRUE},
1310                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1311                         {.int_min = FALSE},
1312                         {.int_max = TRUE},
1313                         _mmcamcorder_commit_display_evas_do_scaling,
1314                 },
1315                 {
1316                         MM_CAM_CAMERA_FACING_DIRECTION,
1317                         "camera-facing-direction",
1318                         MM_ATTRS_TYPE_INT,
1319                         MM_ATTRS_FLAG_RW,
1320                         {(void*)MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1321                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1322                         {.int_min = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1323                         {.int_max = MM_CAMCORDER_CAMERA_FACING_DIRECTION_FRONT},
1324                         NULL,
1325                 },
1326                 {
1327                         MM_CAM_DISPLAY_FLIP,
1328                         "display-flip",
1329                         MM_ATTRS_TYPE_INT,
1330                         MM_ATTRS_FLAG_RW,
1331                         {(void*)MM_FLIP_NONE},
1332                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1333                         {.int_min = MM_FLIP_NONE},
1334                         {.int_max = MM_FLIP_BOTH},
1335                         _mmcamcorder_commit_display_flip,
1336                 },
1337                 {
1338                         MM_CAM_CAMERA_VIDEO_STABILIZATION,
1339                         "camera-video-stabilization",
1340                         MM_ATTRS_TYPE_INT,
1341                         MM_ATTRS_FLAG_RW,
1342                         {(void*)MM_CAMCORDER_VIDEO_STABILIZATION_OFF},
1343                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1344                         {0},
1345                         {0},
1346                         _mmcamcorder_commit_camera_video_stabilization,
1347                 },
1348                 {
1349                         MM_CAM_TAG_VIDEO_ORIENTATION,
1350                         "tag-video-orientation",
1351                         MM_ATTRS_TYPE_INT,
1352                         MM_ATTRS_FLAG_RW,
1353                         {(void*)MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1354                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1355                         {.int_min = MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1356                         {.int_max = MM_CAMCORDER_TAG_VIDEO_ORT_270},
1357                         NULL,
1358                 },
1359                 /* 110 */
1360                 {
1361                         MM_CAM_CAMERA_PAN_MECHA,
1362                         "camera-pan-mecha",
1363                         MM_ATTRS_TYPE_INT,
1364                         MM_ATTRS_FLAG_RW,
1365                         {(void*)0},
1366                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1367                         {.int_min = 0},
1368                         {.int_max = -1},
1369                         _mmcamcorder_commit_camera_pan,
1370                 },
1371                 {
1372                         MM_CAM_CAMERA_PAN_ELEC,
1373                         "camera-pan-elec",
1374                         MM_ATTRS_TYPE_INT,
1375                         MM_ATTRS_FLAG_RW,
1376                         {(void*)0},
1377                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1378                         {.int_min = 0},
1379                         {.int_max = -1},
1380                         _mmcamcorder_commit_camera_pan,
1381                 },
1382                 {
1383                         MM_CAM_CAMERA_TILT_MECHA,
1384                         "camera-tilt-mecha",
1385                         MM_ATTRS_TYPE_INT,
1386                         MM_ATTRS_FLAG_RW,
1387                         {(void*)0},
1388                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1389                         {.int_min = 0},
1390                         {.int_max = -1},
1391                         _mmcamcorder_commit_camera_tilt,
1392                 },
1393                 {
1394                         MM_CAM_CAMERA_TILT_ELEC,
1395                         "camera-tilt-elec",
1396                         MM_ATTRS_TYPE_INT,
1397                         MM_ATTRS_FLAG_RW,
1398                         {(void*)0},
1399                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1400                         {.int_min = 0},
1401                         {.int_max = -1},
1402                         _mmcamcorder_commit_camera_tilt,
1403                 },
1404                 {
1405                         MM_CAM_CAMERA_PTZ_TYPE,
1406                         "camera-ptz-type",
1407                         MM_ATTRS_TYPE_INT,
1408                         MM_ATTRS_FLAG_RW,
1409                         {(void*)0},
1410                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1411                         {0},
1412                         {0},
1413                         _mmcamcorder_commit_camera_ptz_type,
1414                 },
1415                 {
1416                         MM_CAM_VIDEO_WIDTH,
1417                         "video-width",
1418                         MM_ATTRS_TYPE_INT,
1419                         MM_ATTRS_FLAG_RW,
1420                         {(void*)0},
1421                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1422                         {0},
1423                         {0},
1424                         _mmcamcorder_commit_video_size,
1425                 },
1426                 {
1427                         MM_CAM_VIDEO_HEIGHT,
1428                         "video-height",
1429                         MM_ATTRS_TYPE_INT,
1430                         MM_ATTRS_FLAG_RW,
1431                         {(void*)0},
1432                         MM_ATTRS_VALID_TYPE_INT_ARRAY,
1433                         {0},
1434                         {0},
1435                         _mmcamcorder_commit_video_size,
1436                 },
1437                 {
1438                         MM_CAM_SUPPORT_ZSL_CAPTURE,
1439                         "support-zsl-capture",
1440                         MM_ATTRS_TYPE_INT,
1441                         MM_ATTRS_FLAG_RW,
1442                         {(void*)FALSE},
1443                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1444                         {.int_min = FALSE},
1445                         {.int_max = TRUE},
1446                         NULL,
1447                 },
1448                 {
1449                         MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
1450                         "support-zero-copy-format",
1451                         MM_ATTRS_TYPE_INT,
1452                         MM_ATTRS_FLAG_RW,
1453                         {(void*)FALSE},
1454                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1455                         {.int_min = FALSE},
1456                         {.int_max = TRUE},
1457                         NULL,
1458                 },
1459                 {
1460                         MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
1461                         "support-media-packet-preview-cb",
1462                         MM_ATTRS_TYPE_INT,
1463                         MM_ATTRS_FLAG_RW,
1464                         {(void*)FALSE},
1465                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1466                         {.int_min = FALSE},
1467                         {.int_max = TRUE},
1468                         NULL,
1469                 },
1470                 /* 120 */
1471                 {
1472                         MM_CAM_ENCODED_PREVIEW_BITRATE,
1473                         "encoded-preview-bitrate",
1474                         MM_ATTRS_TYPE_INT,
1475                         MM_ATTRS_FLAG_RW,
1476                         {(void*)0},
1477                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1478                         {.int_min = 0},
1479                         {.int_max = _MMCAMCORDER_MAX_INT},
1480                         _mmcamcorder_commit_encoded_preview_bitrate,
1481                 },
1482                 {
1483                         MM_CAM_ENCODED_PREVIEW_GOP_INTERVAL,
1484                         "encoded-preview-gop-interval",
1485                         MM_ATTRS_TYPE_INT,
1486                         MM_ATTRS_FLAG_RW,
1487                         {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL},
1488                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1489                         {.int_min = 0},
1490                         {.int_max = _MMCAMCORDER_MAX_INT},
1491                         _mmcamcorder_commit_encoded_preview_gop_interval,
1492                 },
1493                 {
1494                         MM_CAM_RECORDER_TAG_ENABLE,
1495                         "recorder-tag-enable",
1496                         MM_ATTRS_TYPE_INT,
1497                         MM_ATTRS_FLAG_RW,
1498                         {(void*)FALSE},
1499                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1500                         {.int_min = FALSE},
1501                         {.int_max = TRUE},
1502                         NULL,
1503                 },
1504                 {
1505                         MM_CAM_DISPLAY_SOCKET_PATH,
1506                         "display-socket-path",
1507                         MM_ATTRS_TYPE_STRING,
1508                         MM_ATTRS_FLAG_RW,
1509                         {NULL},
1510                         MM_ATTRS_VALID_TYPE_NONE,
1511                         {0},
1512                         {0},
1513                         NULL,
1514                 },
1515                 {
1516                         MM_CAM_CLIENT_PID,
1517                         "client-pid",
1518                         MM_ATTRS_TYPE_INT,
1519                         MM_ATTRS_FLAG_RW,
1520                         {(void*)0},
1521                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1522                         {.int_min = 0},
1523                         {.int_max = _MMCAMCORDER_MAX_INT},
1524                         NULL,
1525                 },
1526                 {
1527                         MM_CAM_ROOT_DIRECTORY,
1528                         "root-directory",
1529                         MM_ATTRS_TYPE_STRING,
1530                         MM_ATTRS_FLAG_RW,
1531                         {NULL},
1532                         MM_ATTRS_VALID_TYPE_NONE,
1533                         {0},
1534                         {0},
1535                         NULL,
1536                 },
1537                 {
1538                         MM_CAM_SOUND_STREAM_INDEX,
1539                         "sound-stream-index",
1540                         MM_ATTRS_TYPE_INT,
1541                         MM_ATTRS_FLAG_RW,
1542                         {(void*)-1},
1543                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1544                         {.int_min = -1},
1545                         {.int_max = _MMCAMCORDER_MAX_INT},
1546                         NULL,
1547                 },
1548                 {
1549                         MM_CAM_SOUND_STREAM_TYPE,
1550                         "sound-stream-type",
1551                         MM_ATTRS_TYPE_STRING,
1552                         MM_ATTRS_FLAG_RW,
1553                         {NULL},
1554                         MM_ATTRS_VALID_TYPE_NONE,
1555                         {0},
1556                         {0},
1557                         _mmcamcorder_commit_sound_stream_info,
1558                 },
1559                 {
1560                         MM_CAM_DISPLAY_REUSE_HINT,
1561                         "display-reuse-hint",
1562                         MM_ATTRS_TYPE_INT,
1563                         MM_ATTRS_FLAG_RW,
1564                         {(void*)FALSE},
1565                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1566                         {.int_min = FALSE},
1567                         {.int_max = TRUE},
1568                         NULL,
1569                 },
1570                 {
1571                         MM_CAM_DISPLAY_REUSE_ELEMENT,
1572                         "display-reuse-element",
1573                         MM_ATTRS_TYPE_DATA,
1574                         MM_ATTRS_FLAG_RW,
1575                         {NULL},
1576                         MM_ATTRS_VALID_TYPE_NONE,
1577                         {0},
1578                         {0},
1579                         NULL,
1580                 },
1581                 {
1582                         MM_CAM_GDBUS_CONNECTION,
1583                         "gdbus-connection",
1584                         MM_ATTRS_TYPE_DATA,
1585                         MM_ATTRS_FLAG_RW,
1586                         {NULL},
1587                         MM_ATTRS_VALID_TYPE_NONE,
1588                         {0},
1589                         {0},
1590                         NULL,
1591                 },
1592                 {
1593                         MM_CAM_AUDIO_REPLAY_GAIN_ENABLE,
1594                         "audio-replay-gain-enable",
1595                         MM_ATTRS_TYPE_INT,
1596                         MM_ATTRS_FLAG_RW,
1597                         {(void*)FALSE},
1598                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1599                         {.int_min = FALSE},
1600                         {.int_max = TRUE},
1601                         _mmcamcorder_commit_audio_replay_gain,
1602                 },
1603                 {
1604                         MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL,
1605                         "audio-replay-gain-reference-level",
1606                         MM_ATTRS_TYPE_DOUBLE,
1607                         MM_ATTRS_FLAG_RW,
1608                         {.value_double = MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL},
1609                         MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1610                         {.double_min = 0.0},
1611                         {.double_max = 150.0},
1612                         _mmcamcorder_commit_audio_replay_gain,
1613                 },
1614                 {
1615                         MM_CAM_SUPPORT_USER_BUFFER,
1616                         "support-user-buffer",
1617                         MM_ATTRS_TYPE_INT,
1618                         MM_ATTRS_FLAG_RW,
1619                         {(void*)FALSE},
1620                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1621                         {.int_min = FALSE},
1622                         {.int_max = TRUE},
1623                         NULL,
1624                 },
1625                 {
1626                         MM_CAM_USER_BUFFER_FD,
1627                         "user-buffer-fd",
1628                         MM_ATTRS_TYPE_DATA,
1629                         MM_ATTRS_FLAG_RW,
1630                         {NULL},
1631                         MM_ATTRS_VALID_TYPE_NONE,
1632                         {0},
1633                         {0},
1634                         NULL,
1635                 },
1636                 {
1637                         MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
1638                         "platform-privilege-camera",
1639                         MM_ATTRS_TYPE_STRING,
1640                         MM_ATTRS_FLAG_RW,
1641                         {NULL},
1642                         MM_ATTRS_VALID_TYPE_NONE,
1643                         {0},
1644                         {0},
1645                         NULL,
1646                 },
1647                 {
1648                         MM_CAM_STROBE_BRIGHTNESS,
1649                         "strobe-brightness",
1650                         MM_ATTRS_TYPE_INT,
1651                         MM_ATTRS_FLAG_RW,
1652                         {(void*)1},
1653                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1654                         {.int_min = 0},
1655                         {.int_max = -1},
1656                         _mmcamcorder_commit_strobe,
1657                 },
1658                 {
1659                         MM_CAM_VIDEOSRC_ELEMENT_NAME,
1660                         "videosrc-element-name",
1661                         MM_ATTRS_TYPE_STRING,
1662                         MM_ATTRS_FLAG_RW,
1663                         {NULL},
1664                         MM_ATTRS_VALID_TYPE_NONE,
1665                         {0},
1666                         {0},
1667                         NULL,
1668                 },
1669                 {
1670                         MM_CAM_AUDIOSRC_ELEMENT_NAME,
1671                         "audiosrc-element-name",
1672                         MM_ATTRS_TYPE_STRING,
1673                         MM_ATTRS_FLAG_RW,
1674                         {NULL},
1675                         MM_ATTRS_VALID_TYPE_NONE,
1676                         {0},
1677                         {0},
1678                         NULL,
1679                 },
1680                 {
1681                         MM_CAM_EXTRA_PREVIEW_ENABLE,
1682                         "extra-preview-enable",
1683                         MM_ATTRS_TYPE_INT,
1684                         MM_ATTRS_FLAG_RW,
1685                         {(void*)FALSE},
1686                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1687                         {.int_min = FALSE},
1688                         {.int_max = TRUE},
1689                         _mmcamcorder_commit_extra_preview,
1690                 },
1691                 {
1692                         MM_CAM_CAMERA_FOCUS_LEVEL,
1693                         "camera-focus-level",
1694                         MM_ATTRS_TYPE_INT,
1695                         MM_ATTRS_FLAG_RW,
1696                         {(void*)0},
1697                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1698                         {.int_min = 0},
1699                         {.int_max = -1},
1700                         _mmcamcorder_commit_camera_focus_level,
1701                 },
1702                 {
1703                         MM_CAM_SUPPORT_EXTRA_PREVIEW,
1704                         "support-extra-preview",
1705                         MM_ATTRS_TYPE_INT,
1706                         MM_ATTRS_FLAG_RW,
1707                         {(void*)FALSE},
1708                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1709                         {.int_min = FALSE},
1710                         {.int_max = TRUE},
1711                         NULL,
1712                 },
1713                 {
1714                         MM_CAM_REQUEST_CODEC_CONFIG,
1715                         "request-codec-config",
1716                         MM_ATTRS_TYPE_INT,
1717                         MM_ATTRS_FLAG_RW,
1718                         {(void*)FALSE},
1719                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1720                         {.int_min = FALSE},
1721                         {.int_max = TRUE},
1722                         _mmcamcorder_commit_request_codec_config,
1723                 },
1724                 {
1725                         MM_CAM_FILTER_WB_TEMPERATURE,
1726                         "filter-wb-temperature",
1727                         MM_ATTRS_TYPE_INT,
1728                         MM_ATTRS_FLAG_RW,
1729                         {(void*)0},
1730                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1731                         {.int_min = 0},
1732                         {.int_max = -1},
1733                         _mmcamcorder_commit_filter,
1734                 },
1735                 {
1736                         MM_CAM_FILTER_WB_TEMPERATURE_STEP,
1737                         "filter-wb-temperature-step",
1738                         MM_ATTRS_TYPE_INT,
1739                         MM_ATTRS_FLAG_RW,
1740                         {(void*)1},
1741                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1742                         {.int_min = 1},
1743                         {.int_max = _MMCAMCORDER_MAX_INT},
1744                         NULL,
1745                 },
1746                 {
1747                         MM_CAM_CAMERA_GAIN,
1748                         "camera-gain",
1749                         MM_ATTRS_TYPE_INT,
1750                         MM_ATTRS_FLAG_RW,
1751                         {(void*)0},
1752                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1753                         {.int_min = 0},
1754                         {.int_max = -1},
1755                         _mmcamcorder_commit_camera_capture_mode,
1756                 },
1757                 {
1758                         MM_CAM_CAMERA_GAIN_STEP,
1759                         "camera-gain-step",
1760                         MM_ATTRS_TYPE_INT,
1761                         MM_ATTRS_FLAG_RW,
1762                         {(void*)1},
1763                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1764                         {.int_min = 1},
1765                         {.int_max = _MMCAMCORDER_MAX_INT},
1766                         NULL,
1767                 }
1768         };
1769
1770         memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1771
1772         for (idx = 0 ; idx < attr_count ; idx++) {
1773                 /* attribute order check. This should be same. */
1774                 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1775                         MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1776                         free(attrs_const_info);
1777                         attrs_const_info = NULL;
1778                         free(hcamcorder->cam_attrs_const_info);
1779                         hcamcorder->cam_attrs_const_info = NULL;
1780                         return 0;
1781                 }
1782
1783                 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1784                 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1785                 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1786                 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1787         }
1788
1789         /* Camcorder Attributes */
1790         MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1791
1792         ret = mm_attrs_new(attrs_const_info,
1793                 attr_count,
1794                 "Camcorder_Attributes",
1795                 _mmcamcorder_commit_camcorder_attrs,
1796                 (void *)handle,
1797                 &attrs);
1798
1799         free(attrs_const_info);
1800         attrs_const_info = NULL;
1801
1802         if (ret != MM_ERROR_NONE) {
1803                 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1804                 free(hcamcorder->cam_attrs_const_info);
1805                 hcamcorder->cam_attrs_const_info = NULL;
1806                 return 0;
1807         }
1808
1809         __mmcamcorder_set_conf_to_valid_info(handle);
1810
1811         for (idx = 0; idx < attr_count; idx++) {
1812                 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1813
1814                 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1815
1816                 switch (attr_info->validity_type) {
1817                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1818                         if (attr_info->validity_value_1.int_array &&
1819                             attr_info->validity_value_2.count > 0) {
1820                                 mm_attrs_set_valid_array(attrs, idx,
1821                                         (const int *)(attr_info->validity_value_1.int_array),
1822                                         attr_info->validity_value_2.count,
1823                                         attr_info->default_value.value_int);
1824                         }
1825                         break;
1826                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1827                         mm_attrs_set_valid_range(attrs, idx,
1828                                 attr_info->validity_value_1.int_min,
1829                                 attr_info->validity_value_2.int_max,
1830                                 attr_info->default_value.value_int);
1831                         break;
1832                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1833                         if (attr_info->validity_value_1.double_array &&
1834                             attr_info->validity_value_2.count > 0) {
1835                                 mm_attrs_set_valid_double_array(attrs, idx,
1836                                         (const double *)(attr_info->validity_value_1.double_array),
1837                                         attr_info->validity_value_2.count,
1838                                         attr_info->default_value.value_double);
1839                         }
1840                         break;
1841                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1842                         mm_attrs_set_valid_double_range(attrs, idx,
1843                                 attr_info->validity_value_1.double_min,
1844                                 attr_info->validity_value_2.double_max,
1845                                 attr_info->default_value.value_double);
1846                         break;
1847                 case MM_ATTRS_VALID_TYPE_NONE:
1848                         break;
1849                 case MM_ATTRS_VALID_TYPE_INVALID:
1850                 default:
1851                         MMCAM_LOG_ERROR("Valid type error.");
1852                         break;
1853                 }
1854         }
1855
1856         __mmcamcorder_release_conf_valid_info(handle);
1857
1858         return attrs;
1859 }
1860
1861
1862 void
1863 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1864 {
1865         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1866
1867         if (hcamcorder == NULL) {
1868                 MMCAM_LOG_ERROR("handle is NULL");
1869                 return;
1870         }
1871
1872         MMCAM_LOG_INFO("");
1873
1874         if (attrs) {
1875                 mm_attrs_free(attrs);
1876                 MMCAM_LOG_INFO("released attribute");
1877         }
1878
1879         if (hcamcorder->cam_attrs_const_info) {
1880                 free(hcamcorder->cam_attrs_const_info);
1881                 hcamcorder->cam_attrs_const_info = NULL;
1882                 MMCAM_LOG_INFO("released attribute info");
1883         }
1884
1885         return;
1886 }
1887
1888
1889 int
1890 _mmcamcorder_get_attributes(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list var_args)
1891 {
1892         MMHandleType attrs = 0;
1893         int ret = MM_ERROR_NONE;
1894
1895         mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1896         /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1897
1898         attrs = MMF_CAMCORDER_ATTRS(handle);
1899         mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1900
1901         ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1902
1903         return ret;
1904 }
1905
1906
1907 int
1908 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1909 {
1910         MMHandleType attrs = 0;
1911         int ret = MM_ERROR_NONE;
1912         int err_index = 0;
1913         char *tmp_err_attr_name = NULL;
1914         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1915         va_list var_args_copy;
1916
1917         mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1918
1919         if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1920                 MMCAM_LOG_ERROR("Another command is running.");
1921                 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1922         }
1923
1924         /* copy var_args to keep original var_args */
1925         va_copy(var_args_copy, var_args);
1926
1927         attrs = MMF_CAMCORDER_ATTRS(handle);
1928         if (attrs) {
1929                 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1930         } else {
1931                 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1932                 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1933         }
1934
1935         if (ret == MM_ERROR_NONE) {
1936                 hcamcorder->error_code = MM_ERROR_NONE;
1937                 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1938                 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1939         }
1940
1941         va_end(var_args_copy);
1942
1943         _MMCAMCORDER_UNLOCK_CMD(handle);
1944
1945         if (ret != MM_ERROR_NONE) {
1946                 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1947                         if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1948                                 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1949                                 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1950                                         tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1951                                 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1952                         }
1953                 }
1954
1955                 if (hcamcorder->error_code != MM_ERROR_NONE) {
1956                         MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1957                         ret = hcamcorder->error_code;
1958                         hcamcorder->error_code = MM_ERROR_NONE;
1959                 }
1960
1961                 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1962         }
1963
1964         if (tmp_err_attr_name) {
1965                 if (!err_attr_name) {
1966                         MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1967                         free(tmp_err_attr_name);
1968                         tmp_err_attr_name = NULL;
1969                 } else {
1970                         *err_attr_name = tmp_err_attr_name;
1971                 }
1972         }
1973
1974         return ret;
1975 }
1976
1977
1978 int
1979 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1980 {
1981         MMHandleType attrs = 0;
1982         MMAttrsInfo attrinfo;
1983         int ret = MM_ERROR_NONE;
1984
1985         mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1986         mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1987         mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1988
1989         attrs = MMF_CAMCORDER_ATTRS(handle);
1990         mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1991
1992         ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1993
1994         if (ret == MM_ERROR_NONE) {
1995                 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1996                 info->type = attrinfo.type;
1997                 info->flag = attrinfo.flag;
1998                 info->validity_type = attrinfo.validity_type;
1999
2000                 switch (attrinfo.validity_type) {
2001                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
2002                         info->int_array.array = attrinfo.int_array.array;
2003                         info->int_array.count = attrinfo.int_array.count;
2004                         info->int_array.def = attrinfo.int_array.dval;
2005                         break;
2006                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
2007                         info->int_range.min = attrinfo.int_range.min;
2008                         info->int_range.max = attrinfo.int_range.max;
2009                         info->int_range.def = attrinfo.int_range.dval;
2010                         break;
2011                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
2012                         info->double_array.array = attrinfo.double_array.array;
2013                         info->double_array.count = attrinfo.double_array.count;
2014                         info->double_array.def = attrinfo.double_array.dval;
2015                         break;
2016                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
2017                         info->double_range.min = attrinfo.double_range.min;
2018                         info->double_range.max = attrinfo.double_range.max;
2019                         info->double_range.def = attrinfo.double_range.dval;
2020                         break;
2021                 case MM_ATTRS_VALID_TYPE_NONE:
2022                         break;
2023                 case MM_ATTRS_VALID_TYPE_INVALID:
2024                 default:
2025                         break;
2026                 }
2027         }
2028
2029         return ret;
2030 }
2031
2032
2033 bool
2034 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
2035 {
2036         bool bret = FALSE;
2037         mmf_camcorder_t *hcamcorder = NULL;
2038
2039         mmf_return_val_if_fail(commit_param, FALSE);
2040         mmf_return_val_if_fail(attr_idx >= 0, FALSE);
2041         mmf_return_val_if_fail(attr_name, FALSE);
2042         mmf_return_val_if_fail(value, FALSE);
2043
2044         hcamcorder = MMF_CAMCORDER(commit_param);
2045
2046         if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
2047                 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
2048         else
2049                 bret = TRUE;
2050
2051         return bret;
2052 }
2053
2054
2055 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
2056 {
2057         int *format = NULL;
2058         int total_count = 0;
2059
2060         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2061
2062         if (hcamcorder == NULL) {
2063                 MMCAM_LOG_ERROR("handle is NULL");
2064                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2065         }
2066
2067         /* Audio encoder */
2068         total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
2069         hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
2070         hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
2071
2072         /* Video encoder */
2073         total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
2074         hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
2075         hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
2076
2077         /* Image encoder */
2078         total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
2079         hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
2080         hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
2081
2082         /* File format */
2083         total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
2084         hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
2085         hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
2086
2087         return MM_ERROR_NONE;
2088 }
2089
2090
2091 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
2092 {
2093         int *allocated_memory = NULL;
2094
2095         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2096
2097         if (hcamcorder == NULL) {
2098                 MMCAM_LOG_ERROR("handle is NULL");
2099                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2100         }
2101
2102         MMCAM_LOG_INFO("START");
2103
2104         /* Audio encoder info */
2105         allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2106         if (allocated_memory) {
2107                 g_free(allocated_memory);
2108                 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2109                 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2110         }
2111
2112         /* Video encoder info */
2113         allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2114         if (allocated_memory) {
2115                 g_free(allocated_memory);
2116                 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2117                 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2118         }
2119
2120         /* Image encoder info */
2121         allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2122         if (allocated_memory) {
2123                 g_free(allocated_memory);
2124                 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2125                 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2126         }
2127
2128         /* File format info */
2129         allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2130         if (allocated_memory) {
2131                 g_free(allocated_memory);
2132                 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2133                 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2134         }
2135
2136         MMCAM_LOG_INFO("DONE");
2137
2138         return MM_ERROR_NONE;
2139 }
2140
2141
2142 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2143 {
2144         MMHandleType attr = 0;
2145         int current_state = MM_CAMCORDER_STATE_NONE;
2146
2147         mmf_return_val_if_fail(handle && value, FALSE);
2148
2149         attr = MMF_CAMCORDER_ATTRS(handle);
2150         mmf_return_val_if_fail(attr, FALSE);
2151
2152         /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2153
2154         current_state = _mmcamcorder_get_state(handle);
2155         if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2156                 int flags = MM_ATTRS_FLAG_NONE;
2157                 int capture_width, capture_height;
2158                 MMCamAttrsInfo info;
2159
2160                 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2161                 flags = info.flag;
2162
2163                 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2164                         mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2165                         capture_width = value->value.i_val;
2166
2167                         /* Check whether they are valid pair */
2168                         return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2169                 }
2170
2171                 return TRUE;
2172         } else {
2173                 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2174                 return FALSE;
2175         }
2176 }
2177
2178
2179 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2180 {
2181         int current_state = MM_CAMCORDER_STATE_NONE;
2182
2183         current_state = _mmcamcorder_get_state(handle);
2184
2185         if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2186                 int capture_width, capture_height;
2187
2188                 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2189                 capture_height = value->value.i_val;
2190
2191                 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2192         } else {
2193                 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2194
2195                 return FALSE;
2196         }
2197 }
2198
2199
2200 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2201 {
2202         int current_state = 0;
2203         int ivalue = 0;
2204         _MMCamcorderSubContext *sc = NULL;
2205         _MMCamcorderImageInfo *info = NULL;
2206         GstCameraControl *control = NULL;
2207
2208         mmf_return_val_if_fail(handle && value, FALSE);
2209
2210         current_state = _mmcamcorder_get_state(handle);
2211         ivalue = value->value.i_val;
2212
2213         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2214         if (!sc)
2215                 return TRUE;
2216
2217         info = sc->info_image;
2218         if (!info) {
2219                 MMCAM_LOG_ERROR("info image is NULL");
2220                 return FALSE;
2221         }
2222
2223         if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2224                 if (info->capture_send_count > 0) {
2225                         info->capturing = FALSE;
2226                         MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2227                 }
2228
2229                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2230                         MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2231                         return TRUE;
2232                 }
2233
2234                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2235                 if (control) {
2236                         gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2237                         MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2238                 } else {
2239                         MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2240                 }
2241         } else {
2242                 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2243         }
2244
2245         return TRUE;
2246 }
2247
2248
2249 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2250 {
2251         int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2252         int current_state = MM_CAMCORDER_STATE_NONE;
2253         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2254
2255         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2256
2257         current_state = _mmcamcorder_get_state(handle);
2258         mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2259
2260         MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2261                 current_state, mode, value->value.i_val);
2262
2263         if (mode != MM_CAMCORDER_MODE_AUDIO &&
2264             current_state != MM_CAMCORDER_STATE_CAPTURING) {
2265                 return TRUE;
2266         } else {
2267                 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2268                 return FALSE;
2269         }
2270 }
2271
2272
2273 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2274 {
2275         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2276
2277         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2278
2279         MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2280
2281         /* return error when disable shutter sound if policy is TRUE */
2282         if (!value->value.i_val &&
2283             hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2284                 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2285                 return FALSE;
2286         } else {
2287                 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2288                 return TRUE;
2289         }
2290 }
2291
2292
2293 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2294 {
2295         int current_state = MM_CAMCORDER_STATE_NONE;
2296         _MMCamcorderSubContext *sc = NULL;
2297         bool bret = FALSE;
2298
2299         mmf_return_val_if_fail(handle && value, FALSE);
2300
2301         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2302         if (!sc)
2303                 return TRUE;
2304
2305         current_state = _mmcamcorder_get_state(handle);
2306
2307         if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2308                 double mslNewVal = 0;
2309                 mslNewVal = value->value.d_val;
2310
2311                 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2312                         if (mslNewVal == 0.0) {
2313                                 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2314                                 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2315                         } else {
2316                                 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2317                                 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2318                         }
2319                 }
2320
2321                 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2322                 bret = TRUE;
2323         } else {
2324                 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2325                 bret = TRUE;
2326         }
2327
2328         return bret;
2329 }
2330
2331
2332 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2333 {
2334         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2335         int current_state = MM_CAMCORDER_STATE_NONE;
2336
2337         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2338
2339         current_state = _mmcamcorder_get_state(handle);
2340         if (current_state > MM_CAMCORDER_STATE_READY) {
2341                 MMCAM_LOG_ERROR("invalid state %d", current_state);
2342                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2343                 return FALSE;
2344         }
2345
2346         return TRUE;
2347 }
2348
2349
2350 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2351 {
2352         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2353         MMCamAttrsInfo fps_info;
2354         int resolution_width = 0;
2355         int resolution_height = 0;
2356         int i = 0;
2357         int ret = 0;
2358         int current_state = MM_CAMCORDER_STATE_NONE;
2359
2360         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2361
2362         current_state = _mmcamcorder_get_state(handle);
2363         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2364                 MMCAM_LOG_ERROR("invalid state %d", current_state);
2365                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2366                 return FALSE;
2367         }
2368
2369         if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2370                 return TRUE;
2371
2372         MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2373
2374         ret = mm_camcorder_get_attributes(handle, NULL,
2375                 MMCAM_CAMERA_WIDTH, &resolution_width,
2376                 MMCAM_CAMERA_HEIGHT, &resolution_height,
2377                 NULL);
2378
2379         if (ret != MM_ERROR_NONE) {
2380                 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2381                 return FALSE;
2382         }
2383
2384         ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2385         if (ret != MM_ERROR_NONE) {
2386                 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2387                 return FALSE;
2388         }
2389
2390         for (i = 0 ; i < fps_info.int_array.count ; i++) {
2391                 if (value->value.i_val == fps_info.int_array.array[i])
2392                         return TRUE;
2393         }
2394
2395         MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2396
2397         return FALSE;
2398 }
2399
2400
2401 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2402 {
2403         int current_state = MM_CAMCORDER_STATE_NONE;
2404         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2405         _MMCamcorderSubContext *sc = NULL;
2406
2407         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2408
2409         current_state = _mmcamcorder_get_state(handle);
2410         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2411                 MMCAM_LOG_WARNING("invalid state %d", current_state);
2412                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2413                 return FALSE;
2414         }
2415
2416         /* Verify recording motion rate */
2417         if (value->value.d_val > 0.0) {
2418                 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2419                 if (!sc)
2420                         return TRUE;
2421
2422                 /* set is_slow flag */
2423                 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2424                         sc->is_modified_rate = TRUE;
2425                 else
2426                         sc->is_modified_rate = FALSE;
2427
2428                 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2429                 return TRUE;
2430         } else {
2431                 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2432                 return FALSE;
2433         }
2434 }
2435
2436
2437 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2438 {
2439         MMHandleType attr = 0;
2440         int current_state = MM_CAMCORDER_STATE_NONE;
2441         int ret = 0;
2442         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2443         _MMCamcorderSubContext *sc = NULL;
2444
2445         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2446
2447         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2448         if (!sc)
2449                 return TRUE;
2450
2451         attr = MMF_CAMCORDER_ATTRS(handle);
2452         mmf_return_val_if_fail(attr, FALSE);
2453
2454         MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2455
2456         current_state = _mmcamcorder_get_state(handle);
2457
2458         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2459                 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2460                 return FALSE;
2461         } else {
2462                 int flags = MM_ATTRS_FLAG_NONE;
2463                 MMCamAttrsInfo info;
2464                 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2465                 flags = info.flag;
2466
2467                 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2468                         int width = value->value.i_val;
2469                         int height = 0;
2470                         int preview_format = MM_PIXEL_FORMAT_NV12;
2471                         int codec_type = MM_IMAGE_CODEC_JPEG;
2472
2473                         mm_camcorder_get_attributes(handle, NULL,
2474                                 MMCAM_CAMERA_HEIGHT, &height,
2475                                 MMCAM_CAMERA_FORMAT, &preview_format,
2476                                 MMCAM_IMAGE_ENCODER, &codec_type,
2477                                 NULL);
2478
2479                         if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2480                                 if (hcamcorder->resolution_changed == FALSE) {
2481                                         MMCAM_LOG_INFO("no need to restart preview");
2482                                         return TRUE;
2483                                 }
2484
2485                                 hcamcorder->resolution_changed = FALSE;
2486
2487                                 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2488                                         MMCAM_LOG_INFO("restart preview");
2489
2490                                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2491                                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2492
2493                                         if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2494                                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2495
2496                                         /* check decoder recreation */
2497                                         if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2498                                                 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2499                                                 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2500                                                 return FALSE;
2501                                         }
2502
2503                                         /* get preview format */
2504                                         sc->info_image->preview_format = preview_format;
2505                                         sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2506                                         ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2507
2508                                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2509                                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2510
2511                                         if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2512                                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2513
2514                                         /* unlock */
2515                                         g_mutex_unlock(&hcamcorder->restart_preview_lock);
2516                                 } else {
2517                                         MMCAM_LOG_ERROR("currently locked for preview restart");
2518                                         return FALSE;
2519                                 }
2520                         } else {
2521                                 /* get preview format */
2522                                 sc->info_image->preview_format = preview_format;
2523                                 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2524                                 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2525                         }
2526
2527                         return ret;
2528                 }
2529
2530                 return TRUE;
2531         }
2532 }
2533
2534
2535 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2536 {
2537         int ret = 0;
2538         int current_state = MM_CAMCORDER_STATE_NONE;
2539         MMHandleType attr = 0;
2540         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2541         _MMCamcorderSubContext *sc = NULL;
2542
2543         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2544
2545         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2546         if (!sc)
2547                 return TRUE;
2548
2549         attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2550         mmf_return_val_if_fail(attr, FALSE);
2551
2552         MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2553         current_state = _mmcamcorder_get_state(handle);
2554
2555         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2556                 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2557                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2558                 return FALSE;
2559         } else {
2560                 int width = 0;
2561                 int height = value->value.i_val;
2562                 int preview_format = MM_PIXEL_FORMAT_NV12;
2563                 int codec_type = MM_IMAGE_CODEC_JPEG;
2564                 int video_stabilization = 0;
2565
2566                 mm_camcorder_get_attributes(handle, NULL,
2567                         MMCAM_CAMERA_WIDTH, &width,
2568                         MMCAM_CAMERA_FORMAT, &preview_format,
2569                         MMCAM_IMAGE_ENCODER, &codec_type,
2570                         MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2571                         NULL);
2572
2573                 sc->info_video->preview_width = width;
2574                 sc->info_video->preview_height = height;
2575
2576                 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2577                         if (hcamcorder->resolution_changed == FALSE) {
2578                                 MMCAM_LOG_INFO("no need to restart preview");
2579                                 return TRUE;
2580                         }
2581
2582                         hcamcorder->resolution_changed = FALSE;
2583
2584                         if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2585                                 MMCAM_LOG_INFO("restart preview");
2586
2587                                 MMCAM_LOG_INFO("set empty buffers");
2588
2589                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2590                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2591
2592                                 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2593                                         _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2594
2595                                 /* check decoder recreation */
2596                                 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2597                                         MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2598                                         g_mutex_unlock(&hcamcorder->restart_preview_lock);
2599                                         return FALSE;
2600                                 }
2601
2602                                 /* get preview format */
2603                                 sc->info_image->preview_format = preview_format;
2604                                 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2605
2606                                 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2607
2608                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2609                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2610
2611                                 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2612                                         _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2613
2614                                 /* unlock */
2615                                 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2616                         } else {
2617                                 MMCAM_LOG_ERROR("currently locked for preview restart");
2618                                 return FALSE;
2619                         }
2620                 } else {
2621                         /* get preview format */
2622                         sc->info_image->preview_format = preview_format;
2623                         sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2624                         ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2625                 }
2626
2627                 return ret;
2628         }
2629 }
2630
2631
2632 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2633 {
2634         int current_state = MM_CAMCORDER_STATE_NONE;
2635         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2636
2637         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2638
2639         current_state = _mmcamcorder_get_state(handle);
2640         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2641                 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2642                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2643                 return FALSE;
2644         } else {
2645                 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2646                         value->value.i_val, attr_idx);
2647                 return TRUE;
2648         }
2649 }
2650
2651
2652 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2653 {
2654         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2655         _MMCamcorderSubContext *sc = NULL;
2656         int current_state = MM_CAMCORDER_STATE_NONE;
2657         GstCameraControl *control = NULL;
2658         int zoom_level = 0;
2659         int zoom_type = 0;
2660
2661         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2662
2663         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2664         if (!sc)
2665                 return TRUE;
2666
2667         zoom_level = value->value.i_val;
2668
2669         MMCAM_LOG_INFO("(%d)", attr_idx);
2670
2671         current_state = _mmcamcorder_get_state(handle);
2672         if (current_state < MM_CAMCORDER_STATE_READY) {
2673                 MMCAM_LOG_INFO("will be applied when preview starts");
2674                 return TRUE;
2675         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2676                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2677                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2678                 return FALSE;
2679         }
2680
2681         if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2682                 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2683         else
2684                 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2685
2686         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2687                 int ret = FALSE;
2688
2689                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2690                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2691                         return TRUE;
2692                 }
2693
2694                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2695                 if (control == NULL) {
2696                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2697                         return FALSE;
2698                 }
2699
2700                 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2701                 if (ret) {
2702                         MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2703                         return TRUE;
2704                 } else {
2705                         MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2706                 }
2707         } else {
2708                 MMCAM_LOG_INFO("pointer of video src is null");
2709         }
2710
2711         return FALSE;
2712 }
2713
2714
2715 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2716 {
2717         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2718         _MMCamcorderSubContext *sc = NULL;
2719         int current_state = MM_CAMCORDER_STATE_NONE;
2720
2721         GstCameraControl *CameraControl = NULL;
2722         GstCameraControlChannel *CameraControlChannel = NULL;
2723         const GList *controls = NULL;
2724         const GList *item = NULL;
2725
2726         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2727
2728         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2729         mmf_return_val_if_fail(sc, TRUE);
2730
2731         MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2732
2733         current_state = _mmcamcorder_get_state(handle);
2734         if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2735             current_state == MM_CAMCORDER_STATE_CAPTURING) {
2736                 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2737                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2738                 return FALSE;
2739         }
2740
2741         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2742                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2743                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2744                         return FALSE;
2745                 }
2746
2747                 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2748                 if (CameraControl == NULL) {
2749                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2750                         return FALSE;
2751                 }
2752
2753                 controls = gst_camera_control_list_channels(CameraControl);
2754                 if (controls == NULL) {
2755                         MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2756                         return FALSE;
2757                 }
2758
2759                 for (item = controls ; item && item->data ; item = item->next) {
2760                         CameraControlChannel = item->data;
2761                         MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2762                         if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2763                                 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2764                                         MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2765                                         return TRUE;
2766                                 } else {
2767                                         MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2768                                         return FALSE;
2769                                 }
2770                         }
2771                 }
2772
2773                 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2774         }
2775
2776         return FALSE;
2777 }
2778
2779
2780 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2781 {
2782         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2783         _MMCamcorderSubContext *sc = NULL;
2784         int current_state = MM_CAMCORDER_STATE_NONE;
2785
2786         GstCameraControl *CameraControl = NULL;
2787         GstCameraControlChannel *CameraControlChannel = NULL;
2788         const GList *controls = NULL;
2789         const GList *item = NULL;
2790
2791         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2792
2793         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2794         mmf_return_val_if_fail(sc, TRUE);
2795
2796         MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2797
2798         current_state = _mmcamcorder_get_state(handle);
2799         if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2800             current_state == MM_CAMCORDER_STATE_CAPTURING) {
2801                 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2802                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2803                 return FALSE;
2804         }
2805
2806         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2807                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2808                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2809                         return FALSE;
2810                 }
2811
2812                 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2813                 if (CameraControl == NULL) {
2814                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2815                         return FALSE;
2816                 }
2817
2818                 controls = gst_camera_control_list_channels(CameraControl);
2819                 if (controls == NULL) {
2820                         MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2821                         return FALSE;
2822                 }
2823
2824                 for (item = controls ; item && item->data ; item = item->next) {
2825                         CameraControlChannel = item->data;
2826                         MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2827                         if (!strcmp(CameraControlChannel->label, "pan")) {
2828                                 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2829                                         MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2830                                         return TRUE;
2831                                 } else {
2832                                         MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2833                                         return FALSE;
2834                                 }
2835                         }
2836                 }
2837
2838                 MMCAM_LOG_WARNING("failed to find pan control channel");
2839         }
2840
2841         return FALSE;
2842 }
2843
2844
2845 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2846 {
2847         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2848         _MMCamcorderSubContext *sc = NULL;
2849         int current_state = MM_CAMCORDER_STATE_NONE;
2850
2851         GstCameraControl *CameraControl = NULL;
2852         GstCameraControlChannel *CameraControlChannel = NULL;
2853         const GList *controls = NULL;
2854         const GList *item = NULL;
2855
2856         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2857
2858         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2859         mmf_return_val_if_fail(sc, TRUE);
2860
2861         MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2862
2863         current_state = _mmcamcorder_get_state(handle);
2864         if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2865             current_state == MM_CAMCORDER_STATE_CAPTURING) {
2866                 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2867                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2868                 return FALSE;
2869         }
2870
2871         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2872                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2873                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2874                         return FALSE;
2875                 }
2876
2877                 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2878                 if (CameraControl == NULL) {
2879                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2880                         return FALSE;
2881                 }
2882
2883                 controls = gst_camera_control_list_channels(CameraControl);
2884                 if (controls == NULL) {
2885                         MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2886                         return FALSE;
2887                 }
2888
2889                 for (item = controls ; item && item->data ; item = item->next) {
2890                         CameraControlChannel = item->data;
2891                         MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2892                         if (!strcmp(CameraControlChannel->label, "tilt")) {
2893                                 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2894                                         MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2895                                         return TRUE;
2896                                 } else {
2897                                         MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2898                                         return FALSE;
2899                                 }
2900                         }
2901                 }
2902
2903                 MMCAM_LOG_WARNING("failed to find tilt control channel");
2904         }
2905
2906         return FALSE;
2907 }
2908
2909
2910 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2911 {
2912         MMHandleType attr = 0;
2913         int current_state = MM_CAMCORDER_STATE_NONE;
2914         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2915         _MMCamcorderSubContext *sc = NULL;
2916         GstCameraControl *control = NULL;
2917         int mslVal;
2918         int set_focus_mode = 0;
2919         int cur_focus_mode = 0;
2920         int cur_focus_range = 0;
2921
2922         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2923
2924         attr = MMF_CAMCORDER_ATTRS(handle);
2925         mmf_return_val_if_fail(attr, FALSE);
2926
2927         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2928         if (!sc)
2929                 return TRUE;
2930
2931         MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2932
2933         /* check whether set or not */
2934         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2935                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2936                 return TRUE;
2937         }
2938
2939         current_state = _mmcamcorder_get_state(handle);
2940         if (current_state < MM_CAMCORDER_STATE_NULL) {
2941                 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2942                 return TRUE;
2943         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2944                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2945                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2946                 return FALSE;
2947         }
2948
2949         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2950                 int flags = MM_ATTRS_FLAG_NONE;
2951                 MMCamAttrsInfo info;
2952
2953                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2954                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2955                         return TRUE;
2956                 }
2957
2958                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2959                 if (control == NULL) {
2960                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2961                         return FALSE;
2962                 }
2963
2964                 mslVal = value->value.i_val;
2965                 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2966
2967                 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2968                 flags = info.flag;
2969
2970                 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2971                         if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2972                                 if (set_focus_mode != cur_focus_mode) {
2973                                         if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2974                                                 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2975                                                 return TRUE;
2976                                         } else {
2977                                                 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2978                                         }
2979                                 } else {
2980                                         MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2981                                         return TRUE;
2982                                 }
2983                         } else {
2984                                 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2985                         }
2986                 }
2987         } else {
2988                 MMCAM_LOG_INFO("pointer of video src is null");
2989         }
2990
2991         return TRUE;
2992 }
2993
2994
2995 bool _mmcamcorder_commit_camera_focus_level(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2996 {
2997         int current_state = MM_CAMCORDER_STATE_NONE;
2998         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2999         _MMCamcorderSubContext *sc = NULL;
3000         GstCameraControl *control = NULL;
3001
3002         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3003
3004         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3005         if (!sc)
3006                 return TRUE;
3007
3008         MMCAM_LOG_INFO("Focus level[%d]", value->value.i_val);
3009
3010         current_state = _mmcamcorder_get_state(handle);
3011         if (current_state < MM_CAMCORDER_STATE_READY) {
3012                 MMCAM_LOG_INFO("Focus level will be set later.(state=%d)", current_state);
3013                 return TRUE;
3014         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3015                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3016                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3017                 return FALSE;
3018         }
3019
3020         if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3021                 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
3022                 return FALSE;
3023         }
3024
3025         control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3026         if (control == NULL) {
3027                 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3028                 return FALSE;
3029         }
3030
3031         if (!gst_camera_control_set_focus_level(control, value->value.i_val)) {
3032                 MMCAM_LOG_ERROR("set focus level[%d[ failed", value->value.i_val);
3033                 return FALSE;
3034         }
3035
3036         return TRUE;
3037 }
3038
3039
3040 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3041 {
3042         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3043         _MMCamcorderSubContext *sc = NULL;
3044         GstCameraControl *control = NULL;
3045         int current_state = MM_CAMCORDER_STATE_NONE;
3046         int mslVal = 0;
3047         int newVal = 0;
3048         int cur_focus_mode = 0;
3049         int cur_focus_range = 0;
3050         int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3051         int converted_mode = 0;
3052
3053         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3054
3055         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3056         if (!sc)
3057                 return TRUE;
3058
3059         MMCAM_LOG_INFO("(%d)", attr_idx);
3060
3061         /* check whether set or not */
3062         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3063                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3064                 return TRUE;
3065         }
3066
3067         mslVal = value->value.i_val;
3068         newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3069
3070         current_state = _mmcamcorder_get_state(handle);
3071         if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3072                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3073                 return TRUE;
3074         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3075                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3076                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3077                 return FALSE;
3078         }
3079
3080         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3081                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3082                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3083                         return TRUE;
3084                 }
3085
3086                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3087                 if (control == NULL) {
3088                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3089                         return FALSE;
3090                 }
3091
3092                 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
3093                 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
3094
3095                 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
3096                         if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
3097                                 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
3098                                         /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
3099                                         return TRUE;
3100                                 } else {
3101                                         MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
3102                                 }
3103                         } else {
3104                                 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
3105                                 return TRUE;
3106                         }
3107                 } else {
3108                         MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
3109                 }
3110         } else {
3111                 MMCAM_LOG_INFO("pointer of video src is null");
3112         }
3113
3114         return FALSE;
3115 }
3116
3117
3118 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3119 {
3120         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3121         _MMCamcorderSubContext *sc = NULL;
3122         GstCameraControl *control = NULL;
3123         GstCameraControlRectType set_area = { 0, 0, 0, 0 };
3124         GstCameraControlRectType get_area = { 0, 0, 0, 0 };
3125
3126         int current_state = MM_CAMCORDER_STATE_NONE;
3127         int ret = FALSE;
3128         int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3129
3130         gboolean do_set = FALSE;
3131
3132         MMCamAttrsInfo info_y;
3133         MMCamAttrsInfo info_w;
3134         MMCamAttrsInfo info_h;
3135
3136         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3137
3138         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3139         if (!sc)
3140                 return TRUE;
3141
3142         MMCAM_LOG_INFO("(%d)", attr_idx);
3143
3144         current_state = _mmcamcorder_get_state(handle);
3145         if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3146                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3147                 return TRUE;
3148         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3149                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3150                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3151                 return FALSE;
3152         }
3153
3154         ret = mm_camcorder_get_attributes(handle, NULL,
3155                 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3156                 NULL);
3157         if (ret != MM_ERROR_NONE) {
3158                 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3159                 return FALSE;
3160         }
3161
3162         if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3163                 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3164                 return FALSE;
3165         }
3166
3167         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3168                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3169                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3170                         return TRUE;
3171                 }
3172
3173                 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3174                 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3175                 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3176
3177                 switch (attr_idx) {
3178                 case MM_CAM_CAMERA_AF_TOUCH_X:
3179                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3180                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3181                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3182                         if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3183                                 set_area.x = value->value.i_val;
3184                                 mm_camcorder_get_attributes(handle, NULL,
3185                                         MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3186                                         MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3187                                         MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3188                                         NULL);
3189                                 do_set = TRUE;
3190                         } else {
3191                                 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3192                                 return TRUE;
3193                         }
3194                         break;
3195                 case MM_CAM_CAMERA_AF_TOUCH_Y:
3196                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3197                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3198                         if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3199                                 set_area.y = value->value.i_val;
3200                                 mm_camcorder_get_attributes(handle, NULL,
3201                                         MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3202                                         MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3203                                         MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3204                                         NULL);
3205                                 do_set = TRUE;
3206                         } else {
3207                                 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3208                                 return TRUE;
3209                         }
3210                         break;
3211                 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3212                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3213                         if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3214                                 set_area.width = value->value.i_val;
3215                                 mm_camcorder_get_attributes(handle, NULL,
3216                                         MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3217                                         MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3218                                         MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3219                                         NULL);
3220                                 do_set = TRUE;
3221                         } else {
3222                                 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3223                                 return TRUE;
3224                         }
3225                         break;
3226                 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3227                         set_area.height = value->value.i_val;
3228                         mm_camcorder_get_attributes(handle, NULL,
3229                                 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3230                                 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3231                                 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3232                                 NULL);
3233                         do_set = TRUE;
3234                         break;
3235                 default:
3236                         break;
3237                 }
3238
3239                 if (do_set) {
3240                         _MMCamcorderVideoInfo *info = sc->info_video;
3241
3242                         if (info == NULL) {
3243                                 MMCAM_LOG_ERROR("video info is NULL");
3244                                 return FALSE;
3245                         }
3246
3247                         control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3248                         if (control == NULL) {
3249                                 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3250                                 return FALSE;
3251                         }
3252
3253                         /* convert area */
3254                         if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3255                             (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3256                                 float ratio_width = 0.0;
3257                                 float ratio_height = 0.0;
3258
3259                                 if (info->preview_width != 0 && info->preview_height != 0) {
3260                                         ratio_width = (float)info->video_width / (float)info->preview_width;
3261                                         ratio_height = (float)info->video_height / (float)info->preview_height;
3262
3263                                         MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3264                                                 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3265
3266                                         set_area.x = (int)((float)set_area.x * ratio_width);
3267                                         set_area.y = (int)((float)set_area.y * ratio_height);
3268                                         set_area.width = (int)((float)set_area.width * ratio_width);
3269                                         set_area.height = (int)((float)set_area.height * ratio_height);
3270
3271                                         if (set_area.width <= 0)
3272                                                 set_area.width = 1;
3273
3274                                         if (set_area.height <= 0)
3275                                                 set_area.height = 1;
3276
3277                                         MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3278                                                 set_area.x, set_area.y, set_area.width, set_area.height);
3279                                 } else {
3280                                         MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3281                                                 info->preview_width, info->preview_height);
3282                                 }
3283                         }
3284
3285                         ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3286                         if (!ret) {
3287                                 MMCAM_LOG_WARNING("Failed to get AF area");
3288                                 return FALSE;
3289                         }
3290
3291                         /* width and height are not supported now */
3292                         if (get_area.x == set_area.x && get_area.y == set_area.y) {
3293                                 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3294                                         get_area.x, get_area.y);
3295                                 return TRUE;
3296                         }
3297
3298                         ret = gst_camera_control_set_auto_focus_area(control, set_area);
3299                         if (ret) {
3300                                 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3301                                         set_area.x, set_area.y, set_area.width, set_area.height);
3302                                 return TRUE;
3303                         } else {
3304                                 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3305                                         set_area.x, set_area.y, set_area.width, set_area.height);
3306                         }
3307                 }
3308         } else {
3309                 MMCAM_LOG_INFO("pointer of video src is null");
3310         }
3311
3312         return FALSE;
3313 }
3314
3315
3316 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3317 {
3318         GstCameraControl *control = NULL;
3319         int ivalue = 0;
3320         int mslVal1 = 0;
3321         int mslVal2 = 0;
3322         int newVal1 = 0;
3323         int newVal2 = 0;
3324         int exposure_type = 0;
3325         int current_state = MM_CAMCORDER_STATE_NONE;
3326         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3327         _MMCamcorderSubContext *sc = NULL;
3328
3329         int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3330         gboolean check_scene_mode = FALSE;
3331
3332         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3333
3334         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3335         if (!sc)
3336                 return TRUE;
3337
3338         /* check whether set or not */
3339         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3340                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3341                 return TRUE;
3342         }
3343
3344         current_state = _mmcamcorder_get_state(handle);
3345         if (current_state < MM_CAMCORDER_STATE_READY) {
3346                 MMCAM_LOG_INFO("will be applied when preview starts");
3347                 return TRUE;
3348         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3349                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3350                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3351                 return FALSE;
3352         }
3353
3354         ivalue = value->value.i_val;
3355
3356         switch (attr_idx) {
3357         case MM_CAM_CAMERA_F_NUMBER:
3358                 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3359                 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3360                 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3361                 break;
3362         case MM_CAM_CAMERA_SHUTTER_SPEED:
3363                 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3364                 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3365                 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3366                 break;
3367         case MM_CAM_CAMERA_ISO:
3368                 exposure_type = GST_CAMERA_CONTROL_ISO;
3369                 mslVal1 = ivalue;
3370                 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3371                 check_scene_mode = TRUE;
3372                 break;
3373         case MM_CAM_CAMERA_EXPOSURE_MODE:
3374                 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3375                 mslVal1 = ivalue;
3376                 newVal1 =  _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3377                 check_scene_mode = TRUE;
3378                 break;
3379         case MM_CAM_CAMERA_EXPOSURE_VALUE:
3380                 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3381                 mslVal1 = newVal1 = ivalue;
3382                 break;
3383         case MM_CAM_CAMERA_GAIN:
3384                 exposure_type = GST_CAMERA_CONTROL_GAIN;
3385                 mslVal1 = newVal1 = ivalue;
3386                 break;
3387         default:
3388                 MMCAM_LOG_ERROR("unknown attr idx[%d]", attr_idx);
3389                 return FALSE;
3390         }
3391
3392         if (check_scene_mode) {
3393                 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3394                 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3395                         MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3396                         return FALSE;
3397                 }
3398         }
3399
3400         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3401                 int ret = 0;
3402
3403                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3404                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3405                         return TRUE;
3406                 }
3407
3408                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3409                 if (control == NULL) {
3410                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3411                         return FALSE;
3412                 }
3413
3414                 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3415                 if (ret) {
3416                         MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3417                         return TRUE;
3418                 } else {
3419                         MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3420                 }
3421         } else {
3422                 MMCAM_LOG_INFO("pointer of video src is null");
3423         }
3424
3425         return FALSE;
3426 }
3427
3428
3429 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3430 {
3431         GstCameraControl *control = NULL;
3432         int mslVal = 0;
3433         int newVal = 0;
3434         int cur_value = 0;
3435         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3436         _MMCamcorderSubContext *sc = NULL;
3437         int current_state = MM_CAMCORDER_STATE_NONE;
3438
3439         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3440
3441         /* check whether set or not */
3442         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3443                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3444                 return TRUE;
3445         }
3446
3447         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3448         if (!sc)
3449                 return TRUE;
3450
3451         /* check current state */
3452         current_state = _mmcamcorder_get_state(handle);
3453         if (current_state < MM_CAMCORDER_STATE_READY) {
3454                 MMCAM_LOG_INFO("will be applied when preview starts");
3455                 return TRUE;
3456         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3457                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3458                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3459                 return FALSE;
3460         }
3461
3462         mslVal = value->value.i_val;
3463         newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3464
3465         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3466                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3467                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3468                         return TRUE;
3469                 }
3470
3471                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3472                 if (control == NULL) {
3473                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3474                         return FALSE;
3475                 }
3476
3477                 if (gst_camera_control_get_wdr(control, &cur_value)) {
3478                         if (newVal != cur_value) {
3479                                 if (gst_camera_control_set_wdr(control, newVal)) {
3480                                         MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3481                                         return TRUE;
3482                                 } else {
3483                                         MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3484                                 }
3485                         } else {
3486                                 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3487                                 return TRUE;
3488                         }
3489                 } else {
3490                         MMCAM_LOG_WARNING("Failed to get WDR.");
3491                 }
3492         } else {
3493                 MMCAM_LOG_INFO("pointer of video src is null");
3494         }
3495
3496         return FALSE;
3497 }
3498
3499
3500 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3501 {
3502         int current_state = MM_CAMCORDER_STATE_NONE;
3503         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3504
3505         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3506
3507         /* check whether set or not */
3508         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3509                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3510                 return TRUE;
3511         }
3512
3513         current_state = _mmcamcorder_get_state(handle);
3514         if (current_state < MM_CAMCORDER_STATE_READY) {
3515                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3516                 return TRUE;
3517         } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3518                 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3519                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3520                 return FALSE;
3521         }
3522
3523         return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3524 }
3525
3526
3527 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3528 {
3529         int audio_enc = 0;
3530         int bitrate = 0;
3531         int current_state = MM_CAMCORDER_STATE_NONE;
3532         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3533         _MMCamcorderSubContext *sc = NULL;
3534
3535         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3536
3537         bitrate = value->value.i_val;
3538
3539         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3540         if (!sc || !sc->encode_element) {
3541                 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3542                 return TRUE;
3543         }
3544
3545         current_state = _mmcamcorder_get_state(handle);
3546         if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3547                 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3548                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3549                 return FALSE;
3550         }
3551
3552         if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3553                 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3554
3555                 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3556                         bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3557         } else {
3558                 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3559                         bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3560         }
3561
3562         return TRUE;
3563 }
3564
3565
3566 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3567 {
3568         int current_state = MM_CAMCORDER_STATE_NONE;
3569         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3570
3571         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3572
3573         current_state = _mmcamcorder_get_state(handle);
3574         if (current_state < MM_CAMCORDER_STATE_READY) {
3575                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3576                 return TRUE;
3577         } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3578                 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3579                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3580                 return FALSE;
3581         }
3582
3583         return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3584 }
3585
3586
3587 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3588 {
3589         int current_state = MM_CAMCORDER_STATE_NONE;
3590         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3591
3592         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3593
3594         MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3595
3596         current_state = _mmcamcorder_get_state(handle);
3597
3598         if (current_state > MM_CAMCORDER_STATE_READY) {
3599                 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3600                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3601                 return FALSE;
3602         } else {
3603                 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3604         }
3605 }
3606
3607
3608 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3609 {
3610         int current_state = MM_CAMCORDER_STATE_NONE;
3611
3612         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3613         _MMCamcorderSubContext *sc = NULL;
3614
3615         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3616
3617         /* check type */
3618         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3619                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3620                 return FALSE;
3621         }
3622
3623         /* check current state */
3624         current_state = _mmcamcorder_get_state(handle);
3625         if (current_state < MM_CAMCORDER_STATE_READY) {
3626                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3627                 return TRUE;
3628         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3629                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3630                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3631                 return FALSE;
3632         }
3633
3634         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3635
3636         MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3637
3638         if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3639                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3640                 return TRUE;
3641         } else {
3642                 MMCAM_LOG_ERROR("invalid state %d", current_state);
3643                 return FALSE;
3644         }
3645 }
3646
3647
3648 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3649 {
3650         mmf_return_val_if_fail(handle && value, FALSE);
3651
3652         /* get string */
3653         if (!value->value.s_val) {
3654                 MMCAM_LOG_ERROR("NULL filename");
3655                 return FALSE;
3656         }
3657
3658         MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3659
3660         return TRUE;
3661 }
3662
3663
3664 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3665 {
3666         int current_state = MM_CAMCORDER_STATE_NONE;
3667         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3668
3669         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3670
3671         current_state = _mmcamcorder_get_state(handle);
3672         if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3673                 MMCAM_LOG_ERROR("Can not set while RECORDING");
3674                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3675                 return FALSE;
3676         }
3677
3678         return TRUE;
3679 }
3680
3681
3682 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3683 {
3684         GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3685         MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3686         return strcmp(Colorchannel->label, user_data);
3687 }
3688
3689 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3690 {
3691         GstColorBalance *balance = NULL;
3692         GstColorBalanceChannel *Colorchannel = NULL;
3693         GList *controls = NULL;
3694         GList *item = NULL;
3695         int newVal = 0;
3696         int mslVal = 0;
3697         int current_state = MM_CAMCORDER_STATE_NONE;
3698         const char *control_label = NULL;
3699         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3700         _MMCamcorderSubContext *sc = NULL;
3701
3702         int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3703         gboolean check_scene_mode = FALSE;
3704
3705         int wb_temp_table[] = {
3706                 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3707                 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3708                 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3709                 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3710                 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3711                 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3712         };
3713
3714         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3715
3716         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3717         if (!sc)
3718                 return TRUE;
3719
3720         /* check whether set or not */
3721         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3722                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3723                 return TRUE;
3724         }
3725
3726         current_state = _mmcamcorder_get_state(handle);
3727         if (current_state < MM_CAMCORDER_STATE_READY) {
3728                 MMCAM_LOG_INFO("will be applied when preview starts");
3729                 return TRUE;
3730         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3731                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3732                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3733                 return FALSE;
3734         }
3735
3736         if (value->type != MM_ATTRS_TYPE_INT) {
3737                 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3738                 return FALSE;
3739         }
3740
3741         mslVal = value->value.i_val;
3742
3743         switch (attr_idx) {
3744         case MM_CAM_FILTER_BRIGHTNESS:
3745                 control_label = "brightness";
3746                 check_scene_mode = TRUE;
3747                 break;
3748         case MM_CAM_FILTER_CONTRAST:
3749                 control_label = "contrast";
3750                 break;
3751         case MM_CAM_FILTER_WB:
3752                 control_label = "white balance";
3753                 check_scene_mode = TRUE;
3754                 break;
3755         case MM_CAM_FILTER_WB_TEMPERATURE:
3756                 control_label = "white balance temperature";
3757                 check_scene_mode = TRUE;
3758                 break;
3759         case MM_CAM_FILTER_COLOR_TONE:
3760                 control_label = "color tone";
3761                 break;
3762         case MM_CAM_FILTER_SATURATION:
3763                 control_label = "saturation";
3764                 check_scene_mode = TRUE;
3765                 break;
3766         case MM_CAM_FILTER_HUE:
3767                 control_label = "hue";
3768                 break;
3769         case MM_CAM_FILTER_SHARPNESS:
3770                 control_label = "sharpness";
3771                 check_scene_mode = TRUE;
3772                 break;
3773         default:
3774                 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3775                 return FALSE;
3776         }
3777
3778         if (check_scene_mode) {
3779                 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3780                 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3781                         MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3782                         return FALSE;
3783                 }
3784         }
3785
3786         newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3787         if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3788                 return FALSE;
3789
3790         if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3791                 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3792                 return TRUE;
3793         }
3794
3795         balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3796         if (balance == NULL) {
3797                 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3798                 return FALSE;
3799         }
3800
3801         controls = (GList *)gst_color_balance_list_channels(balance);
3802         if (controls == NULL) {
3803                 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3804                 return FALSE;
3805         }
3806
3807 _CHECK_AGAIN:
3808         MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3809                 attr_idx, control_label, mslVal, newVal);
3810
3811         item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3812         if (item) {
3813                 Colorchannel = item->data;
3814                 gst_color_balance_set_value(balance, Colorchannel, newVal);
3815                 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3816                 return TRUE;
3817         }
3818
3819         if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3820                 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3821                         newVal = 1;
3822                         control_label = "white_balance_temperature_auto";
3823                         goto _CHECK_AGAIN;
3824                 } else {
3825                         newVal = wb_temp_table[mslVal];
3826                         control_label = "white_balance_temperature";
3827                         goto _CHECK_AGAIN;
3828                 }
3829         }
3830
3831         MMCAM_LOG_ERROR("failed to find color channel item");
3832
3833         return FALSE;
3834 }
3835
3836
3837 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3838 {
3839         int mslVal = 0;
3840         int newVal = 0;
3841         int current_state = MM_CAMCORDER_STATE_NONE;
3842         GstCameraControl *control = NULL;
3843         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3844         _MMCamcorderSubContext *sc = NULL;
3845
3846         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3847
3848         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3849         if (!sc)
3850                 return TRUE;
3851
3852         mslVal = value->value.i_val;
3853         newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3854
3855         /* check whether set or not */
3856         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3857                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3858                 return TRUE;
3859         }
3860
3861         current_state = _mmcamcorder_get_state(handle);
3862         if (current_state < MM_CAMCORDER_STATE_READY) {
3863                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3864                 return TRUE;
3865         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3866                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3867                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3868                 return FALSE;
3869         }
3870
3871         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3872                 int ret = 0;
3873
3874                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3875                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3876                         return TRUE;
3877                 }
3878
3879                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3880                 if (control == NULL) {
3881                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3882                         return FALSE;
3883                 }
3884
3885                 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3886                 if (ret) {
3887                         MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3888
3889                         if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3890                                 unsigned int i = 0;
3891                                 int attr_idxs[] = {
3892                                         MM_CAM_CAMERA_ISO,
3893                                         MM_CAM_FILTER_BRIGHTNESS,
3894                                         MM_CAM_FILTER_WB,
3895                                         MM_CAM_FILTER_SATURATION,
3896                                         MM_CAM_FILTER_SHARPNESS,
3897                                         MM_CAM_FILTER_COLOR_TONE,
3898                                         MM_CAM_CAMERA_EXPOSURE_MODE
3899                                 };
3900                                 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3901
3902                                 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3903                                         if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3904                                                 mm_attrs_set_modified(attrs, attr_idxs[i]);
3905                                 }
3906                         }
3907
3908                         return TRUE;
3909                 } else {
3910                         MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3911                 }
3912         } else {
3913                 MMCAM_LOG_WARNING("pointer of video src is null");
3914         }
3915
3916         return FALSE;
3917 }
3918
3919
3920 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3921 {
3922         mmf_return_val_if_fail(handle && value, FALSE);
3923
3924         MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3925
3926         return TRUE;
3927 }
3928
3929
3930 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3931 {
3932         mmf_return_val_if_fail(handle && value, FALSE);
3933
3934         MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3935
3936         return TRUE;
3937 }
3938
3939
3940 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3941 {
3942         int current_state = MM_CAMCORDER_STATE_NONE;
3943         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3944
3945         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3946
3947         current_state = _mmcamcorder_get_state(handle);
3948         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3949                 MMCAM_LOG_WARNING("Can NOT set disable[%d] AUDIO. invalid state %d",
3950                         value->value.i_val, current_state);
3951                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3952                 return FALSE;
3953         } else {
3954                 MMCAM_LOG_INFO("Set disable[%d] AUDIO when Recording", value->value.i_val);
3955                 return TRUE;
3956         }
3957 }
3958
3959
3960 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3961 {
3962         int current_state = MM_CAMCORDER_STATE_NONE;
3963         const char *videosink_name = NULL;
3964         void *dp_handle = NULL;
3965         MMCamWindowInfo *window_info = NULL;
3966
3967         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3968         _MMCamcorderSubContext *sc = NULL;
3969
3970         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3971
3972         /* check type */
3973         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3974                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3975                 return FALSE;
3976         }
3977
3978         /* check current state */
3979         current_state = _mmcamcorder_get_state(handle);
3980         if (current_state < MM_CAMCORDER_STATE_READY) {
3981                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3982                 return TRUE;
3983         }
3984
3985         dp_handle = value->value.p_val;
3986         if (!dp_handle) {
3987                 MMCAM_LOG_WARNING("Display handle is NULL");
3988                 return FALSE;
3989         }
3990
3991         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3992
3993         /* get videosink name */
3994         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3995         if (!videosink_name) {
3996                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3997                 return FALSE;
3998         }
3999
4000         MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
4001
4002         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
4003                 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
4004                 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
4005         } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
4006                 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
4007                 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
4008         } else if (!strcmp(videosink_name, "tizenwlsink")) {
4009                 window_info = (MMCamWindowInfo *)dp_handle;
4010                 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
4011                 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
4012         } else if (!strcmp(videosink_name, "directvideosink")) {
4013                 window_info = (MMCamWindowInfo *)dp_handle;
4014                 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
4015                         window_info->surface_id,
4016                         window_info->rect.x,
4017                         window_info->rect.y,
4018                         window_info->rect.width,
4019                         window_info->rect.height);
4020                 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
4021                 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4022                         window_info->rect.x,
4023                         window_info->rect.y,
4024                         window_info->rect.width,
4025                         window_info->rect.height);
4026         } else {
4027                 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
4028                 return FALSE;
4029         }
4030
4031         return TRUE;
4032 }
4033
4034
4035 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4036 {
4037         int current_state = MM_CAMCORDER_STATE_NONE;
4038         const char *videosink_name = NULL;
4039
4040         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4041         _MMCamcorderSubContext *sc = NULL;
4042
4043         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4044
4045         /* check type */
4046         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4047                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4048                 return FALSE;
4049         }
4050
4051         /* check current state */
4052         current_state = _mmcamcorder_get_state(handle);
4053         if (current_state < MM_CAMCORDER_STATE_READY) {
4054                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4055                 return TRUE;
4056         }
4057
4058         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4059
4060         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4061         if (videosink_name == NULL) {
4062                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4063                 return FALSE;
4064         }
4065
4066         MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
4067
4068         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4069                 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
4070                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
4071         } else {
4072                 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
4073         }
4074
4075         return TRUE;
4076 }
4077
4078
4079 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4080 {
4081         int current_state = MM_CAMCORDER_STATE_NONE;
4082
4083         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4084
4085         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4086
4087         /* check type */
4088         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4089                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4090                 return FALSE;
4091         }
4092
4093         /* check current state */
4094         current_state = _mmcamcorder_get_state(handle);
4095         if (current_state < MM_CAMCORDER_STATE_READY) {
4096                 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
4097                 return TRUE;
4098         }
4099
4100         return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4101 }
4102
4103
4104 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4105 {
4106         int current_state = MM_CAMCORDER_STATE_NONE;
4107
4108         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4109
4110         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4111
4112         /* check type */
4113         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4114                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4115                 return FALSE;
4116         }
4117
4118         /* check current state */
4119         current_state = _mmcamcorder_get_state(handle);
4120         if (current_state < MM_CAMCORDER_STATE_READY) {
4121                 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
4122                 return TRUE;
4123         }
4124
4125         return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4126 }
4127
4128
4129 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4130 {
4131         int current_state = MM_CAMCORDER_STATE_NONE;
4132         const char *videosink_name = NULL;
4133
4134         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4135         _MMCamcorderSubContext *sc = NULL;
4136
4137         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4138
4139         /* check type */
4140         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4141                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4142                 return FALSE;
4143         }
4144
4145         /* check current state */
4146         current_state = _mmcamcorder_get_state(handle);
4147         if (current_state < MM_CAMCORDER_STATE_READY) {
4148                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4149                 return TRUE;
4150         }
4151
4152         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4153
4154         /* Get videosink name */
4155         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4156         if (videosink_name == NULL) {
4157                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4158                 return FALSE;
4159         }
4160
4161         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4162                 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4163                 !strcmp(videosink_name, "directvideosink")) {
4164                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4165                 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4166         } else {
4167                 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4168         }
4169
4170         return TRUE;
4171 }
4172
4173
4174 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4175 {
4176         int method = 0;
4177         int current_state = MM_CAMCORDER_STATE_NONE;
4178         const char *videosink_name = NULL;
4179
4180         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4181         _MMCamcorderSubContext *sc = NULL;
4182
4183         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4184
4185         /* check type */
4186         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4187                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4188                 return FALSE;
4189         }
4190
4191         /* check current state */
4192         current_state = _mmcamcorder_get_state(handle);
4193         if (current_state < MM_CAMCORDER_STATE_READY) {
4194                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4195                 return TRUE;
4196         }
4197
4198         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4199
4200         /* Get videosink name */
4201         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4202         if (videosink_name == NULL) {
4203                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4204                 return FALSE;
4205         }
4206
4207         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4208             !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4209             !strcmp(videosink_name, "directvideosink")) {
4210                 method = value->value.i_val;
4211                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4212         } else {
4213                 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4214         }
4215
4216         return TRUE;
4217 }
4218
4219
4220 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4221 {
4222         int current_state = MM_CAMCORDER_STATE_NONE;
4223         int ret = MM_ERROR_NONE;
4224         const char *videosink_name = NULL;
4225
4226         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4227         _MMCamcorderSubContext *sc = NULL;
4228
4229         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4230
4231         /* check type */
4232         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4233                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4234                 return FALSE;
4235         }
4236
4237         /* check current state */
4238         current_state = _mmcamcorder_get_state(handle);
4239         if (current_state < MM_CAMCORDER_STATE_READY) {
4240                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4241                 return TRUE;
4242         }
4243
4244         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4245
4246         /* Get videosink name */
4247         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4248         if (videosink_name == NULL) {
4249                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4250                 return FALSE;
4251         }
4252
4253         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4254             !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4255                 int rect_x = 0;
4256                 int rect_y = 0;
4257                 int rect_width = 0;
4258                 int rect_height = 0;
4259                 int flags = MM_ATTRS_FLAG_NONE;
4260                 MMCamAttrsInfo info;
4261
4262                 mm_camcorder_get_attributes(handle, NULL,
4263                         MMCAM_DISPLAY_RECT_X, &rect_x,
4264                         MMCAM_DISPLAY_RECT_Y, &rect_y,
4265                         MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4266                         MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4267                         NULL);
4268                 switch (attr_idx) {
4269                 case MM_CAM_DISPLAY_RECT_X:
4270                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4271                         flags |= info.flag;
4272                         memset(&info, 0x00, sizeof(info));
4273                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4274                         flags |= info.flag;
4275                         memset(&info, 0x00, sizeof(info));
4276                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4277                         flags |= info.flag;
4278
4279                         rect_x = value->value.i_val;
4280                         break;
4281                 case MM_CAM_DISPLAY_RECT_Y:
4282                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4283                         flags |= info.flag;
4284                         memset(&info, 0x00, sizeof(info));
4285                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4286                         flags |= info.flag;
4287
4288                         rect_y = value->value.i_val;
4289                         break;
4290                 case MM_CAM_DISPLAY_RECT_WIDTH:
4291                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4292                         flags |= info.flag;
4293
4294                         rect_width = value->value.i_val;
4295                         break;
4296                 case MM_CAM_DISPLAY_RECT_HEIGHT:
4297                         rect_height = value->value.i_val;
4298                         break;
4299                 default:
4300                         MMCAM_LOG_ERROR("Wrong attr_idx!");
4301                         return FALSE;
4302                 }
4303
4304                 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4305                         MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4306
4307                         if (!strcmp(videosink_name, "tizenwlsink")) {
4308                             ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4309                                         rect_x, rect_y, rect_width, rect_height);
4310                                 if (!ret) {
4311                                         MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4312                                         return FALSE;
4313                                 }
4314                         } else {
4315                             g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4316                                         "dst-roi-x", rect_x,
4317                                         "dst-roi-y", rect_y,
4318                                         "dst-roi-w", rect_width,
4319                                         "dst-roi-h", rect_height,
4320                                         NULL);
4321                         }
4322                 }
4323         } else {
4324                 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4325         }
4326
4327         return TRUE;
4328 }
4329
4330
4331 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4332 {
4333         int zoom = 0;
4334         int current_state = MM_CAMCORDER_STATE_NONE;
4335         const char *videosink_name = NULL;
4336         GstElement *vs_element = NULL;
4337
4338         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4339         _MMCamcorderSubContext *sc = NULL;
4340
4341         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4342
4343         /* check type */
4344         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4345                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4346                 return FALSE;
4347         }
4348
4349         /* check current state */
4350         current_state = _mmcamcorder_get_state(handle);
4351         if (current_state < MM_CAMCORDER_STATE_READY) {
4352                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4353                 return TRUE;
4354         }
4355
4356         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4357
4358         /* Get videosink name */
4359         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4360         if (videosink_name == NULL) {
4361                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4362                 return FALSE;
4363         }
4364
4365         zoom = value->value.i_val;
4366         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4367                 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4368
4369                 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4370                 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4371
4372                 return TRUE;
4373         } else {
4374                 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4375                 return FALSE;
4376         }
4377 }
4378
4379
4380 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4381 {
4382         int current_state = MM_CAMCORDER_STATE_NONE;
4383         int do_scaling = 0;
4384         const char *videosink_name = NULL;
4385
4386         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4387         _MMCamcorderSubContext *sc = NULL;
4388
4389         mmf_return_val_if_fail(handle && value, FALSE);
4390
4391         /* check type */
4392         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4393                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4394                 return FALSE;
4395         }
4396
4397         /* check current state */
4398         current_state = _mmcamcorder_get_state(handle);
4399         if (current_state < MM_CAMCORDER_STATE_READY) {
4400                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4401                 return TRUE;
4402         }
4403
4404         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4405
4406         do_scaling = value->value.i_val;
4407
4408         /* Get videosink name */
4409         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4410         if (videosink_name == NULL) {
4411                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4412                 return FALSE;
4413         }
4414
4415         if (!strcmp(videosink_name, "evaspixmapsink")) {
4416                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4417                 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4418                 return TRUE;
4419         } else {
4420                 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4421                 return FALSE;
4422         }
4423 }
4424
4425
4426 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4427 {
4428         _MMCamcorderSubContext *sc = NULL;
4429         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4430         int strobe_type, mslVal, newVal, cur_value;
4431         int current_state = MM_CAMCORDER_STATE_NONE;
4432
4433         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4434
4435         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4436         if (!sc)
4437                 return TRUE;
4438
4439         /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4440
4441         mslVal = value->value.i_val;
4442
4443         /* check flash state */
4444         if (attr_idx == MM_CAM_STROBE_MODE) {
4445                 int led_brightness = 0;
4446
4447                 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4448                         MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4449                         hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4450                         return FALSE;
4451                 }
4452
4453                 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4454
4455                 if (led_brightness > 0 &&
4456                     mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4457                         /* other module already turned on LED */
4458                         hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4459                         MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4460                         return FALSE;
4461                 }
4462
4463                 MMCAM_LOG_INFO("keep going");
4464         }
4465
4466         /* check state */
4467         current_state = _mmcamcorder_get_state(handle);
4468         if (current_state < MM_CAMCORDER_STATE_READY) {
4469                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4470                 return TRUE;
4471         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4472                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4473                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4474                 return FALSE;
4475         }
4476
4477         switch (attr_idx) {
4478         case MM_CAM_STROBE_CONTROL:
4479                 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4480                 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4481                 break;
4482         case MM_CAM_STROBE_CAPABILITIES:
4483                 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4484                 newVal = mslVal;
4485                 break;
4486         case MM_CAM_STROBE_MODE:
4487                 /* check whether set or not */
4488                 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4489                         MMCAM_LOG_INFO("skip set value %d", mslVal);
4490                         return TRUE;
4491                 }
4492
4493                 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4494                 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4495                 break;
4496         case MM_CAM_STROBE_BRIGHTNESS:
4497                 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4498                 newVal = mslVal;
4499                 break;
4500         default:
4501                 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4502                 return FALSE;
4503         }
4504
4505         GstCameraControl *control = NULL;
4506         if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4507                 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4508                 return FALSE;
4509         }
4510
4511         control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4512         if (control == NULL) {
4513                 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4514                 return FALSE;
4515         }
4516
4517         if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4518                 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4519                 return FALSE;
4520         }
4521
4522         if (newVal == cur_value) {
4523                 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4524                 return TRUE;
4525         }
4526
4527         if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4528                 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4529                 return FALSE;
4530         }
4531
4532         MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4533
4534         return TRUE;
4535 }
4536
4537
4538 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4539 {
4540         int ret = 0;
4541         int current_state = MM_CAMCORDER_STATE_NONE;
4542         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4543
4544         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4545
4546         MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4547
4548         /* state check */
4549         current_state = _mmcamcorder_get_state(handle);
4550         if (current_state > MM_CAMCORDER_STATE_READY) {
4551                 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4552                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4553                 return FALSE;
4554         } else if (current_state < MM_CAMCORDER_STATE_READY) {
4555                 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4556                 return TRUE;
4557         }
4558
4559         ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4560
4561         MMCAM_LOG_INFO("ret %d", ret);
4562
4563         return ret;
4564 }
4565
4566
4567 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4568 {
4569         int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4570         int current_state = MM_CAMCORDER_STATE_NONE;
4571         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4572         _MMCamcorderSubContext *sc = NULL;
4573
4574         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4575
4576         /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4577
4578         /* check whether set or not */
4579         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4580                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4581                 return TRUE;
4582         }
4583
4584         /* state check */
4585         current_state = _mmcamcorder_get_state(handle);
4586         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4587                 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4588                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4589                 return FALSE;
4590         }
4591
4592         if (current_state >= MM_CAMCORDER_STATE_READY) {
4593                 int current_value = 0;
4594
4595                 set_hdr_mode = value->value.i_val;
4596                 mm_camcorder_get_attributes(handle, NULL,
4597                         MMCAM_CAMERA_HDR_CAPTURE, &current_value,
4598                         NULL);
4599
4600                 if (set_hdr_mode == current_value) {
4601                         MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4602                         return TRUE;
4603                 }
4604
4605                 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4606                 if (sc) {
4607                         if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4608                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4609                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4610
4611                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4612
4613                                 /* check decoder recreation */
4614                                 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4615                                         MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4616                                         return FALSE;
4617                                 }
4618
4619                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4620                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4621                         }
4622
4623                         set_hdr_mode = value->value.i_val;
4624                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4625                         sc->info_image->hdr_capture_mode = set_hdr_mode;
4626                         MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4627
4628                         if (current_state == MM_CAMCORDER_STATE_PREPARE)
4629                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4630                 } else {
4631                         MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4632                         return FALSE;
4633                 }
4634         }
4635
4636         return TRUE;
4637 }
4638
4639
4640 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4641 {
4642         bool bret = FALSE;
4643         _MMCamcorderSubContext *sc = NULL;
4644         int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4645         int set_value = 0;
4646         int current_value = 0;
4647         int current_state = MM_CAMCORDER_STATE_NONE;
4648         GstCameraControl *control = NULL;
4649
4650         mmf_return_val_if_fail(handle && value, FALSE);
4651
4652         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4653         if (!sc)
4654                 return TRUE;
4655
4656         /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4657
4658         /* state check */
4659         current_state = _mmcamcorder_get_state(handle);
4660         if (current_state < MM_CAMCORDER_STATE_READY) {
4661                 MMCAM_LOG_INFO("will be applied when preview starts");
4662                 return TRUE;
4663         }
4664
4665         set_value = value->value.i_val;
4666
4667         switch (attr_idx) {
4668         case MM_CAM_DETECT_MODE:
4669                 /* check whether set or not */
4670                 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4671                         MMCAM_LOG_INFO("skip set value %d", set_value);
4672                         return TRUE;
4673                 }
4674
4675                 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4676                 break;
4677         case MM_CAM_DETECT_NUMBER:
4678                 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4679                 break;
4680         case MM_CAM_DETECT_FOCUS_SELECT:
4681                 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4682                 break;
4683         case MM_CAM_DETECT_SELECT_NUMBER:
4684                 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4685                 break;
4686         case MM_CAM_DETECT_STATUS:
4687                 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4688                 break;
4689         default:
4690                 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4691                 return FALSE;
4692         }
4693
4694         if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4695                 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4696                 bret = FALSE;
4697         } else {
4698                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4699                 if (control == NULL) {
4700                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4701                         return FALSE;
4702                 }
4703
4704                 if (gst_camera_control_get_detect(control, detect_type, &current_value)) {
4705                         if (current_value == set_value) {
4706                                 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4707                                 bret = TRUE;
4708                         } else {
4709                                 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4710                                         MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4711                                                 detect_type, set_value);
4712                                         bret = FALSE;
4713                                 } else {
4714                                         MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4715                                                 detect_type, set_value);
4716                                         bret = TRUE;
4717                                 }
4718                         }
4719                 } else {
4720                         MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4721                         bret = FALSE;
4722                 }
4723         }
4724
4725         return bret;
4726 }
4727
4728
4729 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4730 {
4731         int current_state = MM_CAMCORDER_STATE_NONE;
4732
4733         mmf_return_val_if_fail(handle && value, FALSE);
4734
4735         MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4736
4737         /* check state */
4738         current_state = _mmcamcorder_get_state(handle);
4739         if (current_state < MM_CAMCORDER_STATE_READY) {
4740                 MMCAM_LOG_INFO("will be applied when preview starts");
4741                 return TRUE;
4742         }
4743
4744         return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4745 }
4746
4747
4748 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4749 {
4750         int current_state = MM_CAMCORDER_STATE_NONE;
4751         int preview_format = MM_PIXEL_FORMAT_NV12;
4752
4753         mmf_return_val_if_fail(handle && value, FALSE);
4754
4755         MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4756
4757         /* check preview format */
4758         mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4759         if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
4760                 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4761                 return FALSE;
4762         }
4763
4764         /* check state */
4765         current_state = _mmcamcorder_get_state(handle);
4766         if (current_state < MM_CAMCORDER_STATE_READY) {
4767                 MMCAM_LOG_INFO("will be applied when preview starts");
4768                 return TRUE;
4769         }
4770
4771         return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4772 }
4773
4774
4775 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4776 {
4777         int stream_index = 0;
4778         char *stream_type = NULL;
4779         _MMCamcorderSubContext *sc = NULL;
4780
4781         mmf_return_val_if_fail(handle && value, FALSE);
4782
4783         stream_type = value->value.s_val;
4784         if (!stream_type) {
4785                 MMCAM_LOG_ERROR("NULL string");
4786                 return FALSE;
4787         }
4788
4789         mm_camcorder_get_attributes(handle, NULL,
4790                 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4791                 NULL);
4792         if (stream_index < 0) {
4793                 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4794                 return FALSE;
4795         }
4796
4797         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4798         if (!sc || !sc->encode_element ||
4799             !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4800                 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4801                 return TRUE;
4802         }
4803
4804         MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4805
4806         return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4807 }
4808
4809
4810 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4811 {
4812         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4813         int current_state = MM_CAMCORDER_STATE_NONE;
4814
4815         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4816
4817         current_state = _mmcamcorder_get_state(handle);
4818         if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4819                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4820                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4821                 return FALSE;
4822         }
4823
4824         return TRUE;
4825 }
4826
4827 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4828 {
4829         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4830
4831         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4832
4833         if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4834                 /* Replay gain enable */
4835                 int current_state = MM_CAMCORDER_STATE_NONE;
4836                 int audio_disable = FALSE;
4837
4838                 current_state = _mmcamcorder_get_state(handle);
4839                 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4840                         MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4841                         hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4842                         return FALSE;
4843                 }
4844
4845                 mm_camcorder_get_attributes(handle, NULL,
4846                         MMCAM_AUDIO_DISABLE, &audio_disable,
4847                         NULL);
4848
4849                 if (audio_disable) {
4850                         MMCAM_LOG_ERROR("audio is disabled");
4851                         hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4852                         return FALSE;
4853                 }
4854
4855                 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4856         } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4857                 /* Replay gain reference level */
4858                 int replay_gain_enable = FALSE;
4859
4860                 mm_camcorder_get_attributes(handle, NULL,
4861                         MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4862                         NULL);
4863
4864                 if (replay_gain_enable == FALSE) {
4865                         MMCAM_LOG_ERROR("replay gain is disabled");
4866                         hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4867                         return FALSE;
4868                 }
4869
4870                 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4871         } else {
4872                 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4873                 return FALSE;
4874         }
4875
4876         return TRUE;
4877 }
4878
4879
4880 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4881 {
4882         int ret = MM_ERROR_NONE;
4883         int current_state = MM_CAMCORDER_STATE_NONE;
4884         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4885         _MMCamcorderSubContext *sc = NULL;
4886
4887         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4888
4889         if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4890                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4891                 return FALSE;
4892         }
4893
4894         MMCAM_LOG_INFO("Enable extra preview(%d)", value->value.i_val);
4895
4896         current_state = _mmcamcorder_get_state(handle);
4897         if (current_state < MM_CAMCORDER_STATE_READY) {
4898                 MMCAM_LOG_INFO("will be set when preview is started");
4899                 return TRUE;
4900         }
4901
4902         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4903         mmf_return_val_if_fail(sc, FALSE);
4904
4905         if (value->value.i_val)
4906                 ret = _mmcamcorder_initialize_extra_preview_mode(handle);
4907         else
4908                 ret = _mmcamcorder_deinitialize_extra_preview_mode(handle);
4909
4910         if (ret != MM_ERROR_NONE) {
4911                 MMCAM_LOG_ERROR("set[%d] failed[0x%x]", value->value.i_val, ret);
4912                 return FALSE;
4913         }
4914
4915         MMCAM_LOG_INFO("done");
4916
4917         return TRUE;
4918 }
4919
4920
4921 bool _mmcamcorder_commit_request_codec_config(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4922 {
4923         int ret = MM_ERROR_NONE;
4924         int current_state = MM_CAMCORDER_STATE_NONE;
4925         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4926         _MMCamcorderSubContext *sc = NULL;
4927
4928         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4929
4930         if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4931                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4932                 return FALSE;
4933         }
4934
4935         MMCAM_LOG_INFO("Request codec config");
4936
4937         current_state = _mmcamcorder_get_state(handle);
4938         if (current_state < MM_CAMCORDER_STATE_READY) {
4939                 MMCAM_LOG_INFO("invalid state[%d]", current_state);
4940                 return FALSE;
4941         }
4942
4943         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4944         mmf_return_val_if_fail(sc, FALSE);
4945
4946         ret = _mmcamcorder_request_codec_config(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4947         if (ret != MM_ERROR_NONE) {
4948                 hcamcorder->error_code = ret;
4949                 return FALSE;
4950         }
4951
4952         return TRUE;
4953 }
4954
4955
4956 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4957 {
4958         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4959         MMHandleType attrs;
4960
4961         int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4962
4963         unsigned int i = 0;
4964         int ret = TRUE;
4965         int attr_idxs_default[] = {
4966                 MM_CAM_CAMERA_DIGITAL_ZOOM,
4967                 MM_CAM_CAMERA_OPTICAL_ZOOM,
4968                 MM_CAM_CAMERA_WDR,
4969                 MM_CAM_FILTER_CONTRAST,
4970                 MM_CAM_FILTER_HUE,
4971                 MM_CAM_DETECT_MODE,
4972                 MM_CAM_STROBE_BRIGHTNESS
4973         };
4974
4975         int attr_idxs_extra[] = {
4976                 MM_CAM_CAMERA_ISO,
4977                 MM_CAM_FILTER_BRIGHTNESS,
4978                 MM_CAM_FILTER_WB,
4979                 MM_CAM_FILTER_SATURATION,
4980                 MM_CAM_FILTER_SHARPNESS,
4981                 MM_CAM_FILTER_COLOR_TONE,
4982                 MM_CAM_CAMERA_EXPOSURE_MODE
4983         };
4984
4985         mmf_return_val_if_fail(hcamcorder, FALSE);
4986
4987         MMCAM_LOG_INFO("commit some attributes again");
4988
4989         attrs = MMF_CAMCORDER_ATTRS(handle);
4990         if (attrs == NULL) {
4991                 MMCAM_LOG_ERROR("Get attribute handle failed.");
4992                 return FALSE;
4993         }
4994
4995         /* Get Scene mode */
4996         mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4997
4998         for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4999                 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
5000                         mm_attrs_set_modified(attrs, attr_idxs_default[i]);
5001         }
5002
5003         /* Set extra if scene mode is NORMAL */
5004         if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
5005                 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
5006                         if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
5007                                 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
5008                 }
5009         } else {
5010                 /* Set scene mode if scene mode is NOT NORMAL */
5011                 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
5012                         mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
5013         }
5014
5015         if (mm_attrs_commit_all(attrs) == -1)
5016                 ret = FALSE;
5017         else
5018                 ret = TRUE;
5019
5020         MMCAM_LOG_INFO("Done.");
5021
5022         return ret;
5023 }
5024
5025
5026 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
5027 {
5028         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5029         MMHandleType attrs;
5030         unsigned int i = 0;
5031         int ret = TRUE;
5032         int attr_idxs[] = {
5033                 MM_CAM_STROBE_MODE,
5034                 MM_CAM_CAMERA_PTZ_TYPE,
5035                 MM_CAM_CAMERA_PAN_MECHA,
5036                 MM_CAM_CAMERA_PAN_ELEC,
5037                 MM_CAM_CAMERA_TILT_MECHA,
5038                 MM_CAM_CAMERA_TILT_ELEC
5039         };
5040
5041         mmf_return_val_if_fail(hcamcorder, FALSE);
5042
5043         MMCAM_LOG_INFO("commit some attribute again[2]");
5044
5045         attrs = MMF_CAMCORDER_ATTRS(handle);
5046         if (attrs == NULL) {
5047                 MMCAM_LOG_ERROR("Get attribute handle failed.");
5048                 return FALSE;
5049         }
5050
5051         for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
5052                 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
5053                         mm_attrs_set_modified(attrs, attr_idxs[i]);
5054         }
5055
5056         if (mm_attrs_commit_all(attrs) == -1)
5057                 ret = FALSE;
5058         else
5059                 ret = TRUE;
5060
5061         MMCAM_LOG_INFO("Done.");
5062
5063         return ret;
5064 }
5065
5066
5067 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
5068 {
5069         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5070         MMHandleType attrs;
5071         int table_size = 0;
5072         int i = 0;
5073         int nerror = MM_ERROR_NONE;
5074
5075         mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
5076
5077         attrs = MMF_CAMCORDER_ATTRS(handle);
5078         mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
5079
5080         MMCAM_LOG_INFO("");
5081
5082         table_size = ARRAY_SIZE(readonly_attributes);
5083         MMCAM_LOG_INFO("%d", table_size);
5084         for (i = 0; i < table_size; i++) {
5085                 int sCategory = readonly_attributes[i];
5086
5087                 mm_attrs_set_readonly(attrs, sCategory);
5088         }
5089
5090         return nerror;
5091 }
5092
5093
5094 /*---------------------------------------------------------------------------------------
5095 |    INTERNAL FUNCTION DEFINITIONS:                                                     |
5096 ---------------------------------------------------------------------------------------*/
5097 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
5098 {
5099         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5100         _MMCamcorderSubContext *sc = NULL;
5101         int current_state = MM_CAMCORDER_STATE_NULL;
5102
5103         mmf_return_val_if_fail(hcamcorder, FALSE);
5104
5105         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
5106         if (!sc)
5107                 return TRUE;
5108
5109         current_state = _mmcamcorder_get_state(handle);
5110
5111         if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
5112                 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
5113                         MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
5114                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
5115                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
5116                 } else {
5117                         MMCAM_LOG_WARNING("invalid state[%d]", current_state);
5118                         return FALSE;
5119                 }
5120         } else {
5121                 MMCAM_LOG_INFO("element is not created yet");
5122         }
5123
5124         return TRUE;
5125 }
5126
5127
5128 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
5129 {
5130         #define INIT_VALUE            -1
5131         #define CHECK_COUNT           3
5132
5133         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5134         MMHandleType attrs = 0;
5135
5136         int ret = MM_ERROR_NONE;
5137         int i = 0;
5138         int j = 0;
5139         const char *name = NULL;
5140         const char *check_pair_name[CHECK_COUNT][3] = {
5141                 {MMCAM_CAMERA_WIDTH,  MMCAM_CAMERA_HEIGHT,  "MMCAM_CAMERA_WIDTH and HEIGHT"},
5142                 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
5143                 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
5144         };
5145
5146         int check_pair_value[CHECK_COUNT][2] = {
5147                 {INIT_VALUE, INIT_VALUE},
5148                 {INIT_VALUE, INIT_VALUE},
5149                 {INIT_VALUE, INIT_VALUE},
5150         };
5151
5152         if (hcamcorder == NULL || attribute_name == NULL) {
5153                 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
5154                         hcamcorder, attribute_name);
5155                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5156         }
5157
5158         if (err_attr_name)
5159                 *err_attr_name = NULL;
5160
5161         /*MMCAM_LOG_INFO( "ENTER" );*/
5162
5163         attrs = MMF_CAMCORDER_ATTRS(handle);
5164
5165         name = attribute_name;
5166
5167         while (name) {
5168                 int idx = -1;
5169                 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
5170
5171                 /*MMCAM_LOG_INFO("NAME : %s", name);*/
5172
5173                 /* attribute name check */
5174                 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
5175                         if (err_attr_name)
5176                                 *err_attr_name = strdup(name);
5177
5178                         if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
5179                                 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5180                         else
5181                                 return ret;
5182                 }
5183
5184                 /* type check */
5185                 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5186                         return ret;
5187
5188                 switch (attr_type) {
5189                 case MM_ATTRS_TYPE_INT:
5190                 {
5191                         gboolean matched = FALSE;
5192                         for (i = 0 ; i < CHECK_COUNT ; i++) {
5193                                 for (j = 0 ; j < 2 ; j++) {
5194                                         if (!strcmp(name, check_pair_name[i][j])) {
5195                                                 check_pair_value[i][j] = va_arg((var_args), int);
5196                                                 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5197                                                 matched = TRUE;
5198                                                 break;
5199                                         }
5200                                 }
5201                                 if (matched)
5202                                         break;
5203                         }
5204                         if (matched == FALSE)
5205                                 va_arg((var_args), int);
5206                         break;
5207                 }
5208                 case MM_ATTRS_TYPE_DOUBLE:
5209                         va_arg((var_args), double);
5210                         break;
5211                 case MM_ATTRS_TYPE_STRING:
5212                         va_arg((var_args), char*); /* string */
5213                         va_arg((var_args), int);   /* size */
5214                         break;
5215                 case MM_ATTRS_TYPE_DATA:
5216                         va_arg((var_args), void*); /* data */
5217                         va_arg((var_args), int);   /* size */
5218                         break;
5219                 case MM_ATTRS_TYPE_INVALID:
5220                 default:
5221                         MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5222                         if (err_attr_name)
5223                                 *err_attr_name = strdup(name);
5224
5225                         return  MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5226                 }
5227
5228                 /* next name */
5229                 name = va_arg(var_args, const char*);
5230         }
5231
5232         for (i = 0 ; i < CHECK_COUNT ; i++) {
5233                 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5234                         gboolean check_result = FALSE;
5235                         char *err_name = NULL;
5236                         MMCamAttrsInfo attr_info_0, attr_info_1;
5237
5238                         if (check_pair_value[i][0] == INIT_VALUE) {
5239                                 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5240                                 err_name = strdup(check_pair_name[i][1]);
5241                         } else if (check_pair_value[i][1] == INIT_VALUE) {
5242                                 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5243                                 err_name = strdup(check_pair_name[i][0]);
5244                         } else {
5245                                 err_name = strdup(check_pair_name[i][2]);
5246                         }
5247
5248                         mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5249                         mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5250
5251                         check_result = FALSE;
5252
5253                         for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5254                                 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5255                                     attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5256                                         /*
5257                                         MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5258                                                 check_pair_name[i][0], check_pair_name[i][1],
5259                                                 check_pair_value[i][0], check_pair_value[i][1], i);
5260                                         */
5261                                         check_result = TRUE;
5262                                         break;
5263                                 }
5264                         }
5265
5266                         if (check_result == FALSE) {
5267                                 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5268                                         check_pair_name[i][0], check_pair_name[i][1],
5269                                         check_pair_value[i][0], check_pair_value[i][1]);
5270                                 if (err_attr_name) {
5271                                         *err_attr_name = err_name;
5272                                 } else {
5273                                         if (err_name) {
5274                                                 free(err_name);
5275                                                 err_name = NULL;
5276                                         }
5277                                 }
5278
5279                                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5280                         }
5281
5282                         if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5283                                 int current_width = 0;
5284                                 int current_height = 0;
5285
5286                                 mm_camcorder_get_attributes(handle, NULL,
5287                                         MMCAM_CAMERA_WIDTH, &current_width,
5288                                         MMCAM_CAMERA_HEIGHT, &current_height,
5289                                         NULL);
5290
5291                                 if (current_width != check_pair_value[i][0] ||
5292                                     current_height != check_pair_value[i][1]) {
5293                                         hcamcorder->resolution_changed = TRUE;
5294                                 } else {
5295                                         hcamcorder->resolution_changed = FALSE;
5296                                 }
5297
5298                                 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5299                         }
5300
5301                         if (err_name) {
5302                                 free(err_name);
5303                                 err_name = NULL;
5304                         }
5305                 }
5306         }
5307
5308         /*MMCAM_LOG_INFO("DONE");*/
5309
5310         return MM_ERROR_NONE;
5311 }
5312
5313
5314 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5315 {
5316         MMAttrsInfo info;
5317
5318         if ((void *)handle == NULL) {
5319                 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5320                 return FALSE;
5321         }
5322
5323         memset(&info, 0x0, sizeof(MMAttrsInfo));
5324
5325         mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5326
5327         switch (info.validity_type) {
5328         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5329                 /*
5330                 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5331                 */
5332                 if (info.int_array.count < 1)
5333                         return FALSE;
5334                 break;
5335         case MM_ATTRS_VALID_TYPE_INT_RANGE:
5336                 /*
5337                 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5338                 */
5339                 if (info.int_range.min > info.int_range.max)
5340                         return FALSE;
5341                 break;
5342         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5343                 /*
5344                 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5345                 */
5346                 if (info.double_array.count < 1)
5347                         return FALSE;
5348                 break;
5349         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5350                 /*
5351                 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5352                 */
5353                 if (info.double_range.min >= info.double_range.max)
5354                         return FALSE;
5355                 break;
5356         default:
5357                 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);
5358                 return FALSE;
5359         }
5360
5361         return TRUE;
5362 }