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