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