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