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