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