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