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