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