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