Set device type as camera id in case of network camera
[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 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3526 {
3527         GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3528         MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3529         return strcmp(Colorchannel->label, user_data);
3530 }
3531
3532 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3533 {
3534         GstColorBalance *balance = NULL;
3535         GstColorBalanceChannel *Colorchannel = NULL;
3536         GList *controls = NULL;
3537         GList *item = NULL;
3538         int newVal = 0;
3539         int mslVal = 0;
3540         int current_state = MM_CAMCORDER_STATE_NONE;
3541         const char *control_label = NULL;
3542         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3543         _MMCamcorderSubContext *sc = NULL;
3544
3545         int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3546         gboolean check_scene_mode = FALSE;
3547
3548         int wb_temp_table[] = {
3549                 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3550                 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3551                 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3552                 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3553                 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3554                 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3555         };
3556
3557         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3558
3559         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3560         if (!sc)
3561                 return TRUE;
3562
3563         /* check whether set or not */
3564         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3565                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3566                 return TRUE;
3567         }
3568
3569         current_state = _mmcamcorder_get_state(handle);
3570         if (current_state < MM_CAMCORDER_STATE_READY) {
3571                 MMCAM_LOG_INFO("will be applied when preview starts");
3572                 return TRUE;
3573         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3574                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3575                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3576                 return FALSE;
3577         }
3578
3579         if (value->type != MM_ATTRS_TYPE_INT) {
3580                 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3581                 return FALSE;
3582         }
3583
3584         mslVal = value->value.i_val;
3585
3586         switch (attr_idx) {
3587         case MM_CAM_FILTER_BRIGHTNESS:
3588                 control_label = "brightness";
3589                 check_scene_mode = TRUE;
3590                 break;
3591         case MM_CAM_FILTER_CONTRAST:
3592                 control_label = "contrast";
3593                 break;
3594         case MM_CAM_FILTER_WB:
3595                 control_label = "white balance";
3596                 check_scene_mode = TRUE;
3597                 break;
3598         case MM_CAM_FILTER_COLOR_TONE:
3599                 control_label = "color tone";
3600                 break;
3601         case MM_CAM_FILTER_SATURATION:
3602                 control_label = "saturation";
3603                 check_scene_mode = TRUE;
3604                 break;
3605         case MM_CAM_FILTER_HUE:
3606                 control_label = "hue";
3607                 break;
3608         case MM_CAM_FILTER_SHARPNESS:
3609                 control_label = "sharpness";
3610                 check_scene_mode = TRUE;
3611                 break;
3612         default:
3613                 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3614                 return FALSE;
3615         }
3616
3617         if (check_scene_mode) {
3618                 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3619                 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3620                         MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3621                         return FALSE;
3622                 }
3623         }
3624
3625         newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3626         if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3627                 return FALSE;
3628
3629         if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3630                 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3631                 return TRUE;
3632         }
3633
3634         balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3635         if (balance == NULL) {
3636                 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3637                 return FALSE;
3638         }
3639
3640         controls = (GList *)gst_color_balance_list_channels(balance);
3641         if (controls == NULL) {
3642                 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3643                 return FALSE;
3644         }
3645
3646 _CHECK_AGAIN:
3647         MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3648                 attr_idx, control_label, mslVal, newVal);
3649
3650         item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3651         if (item) {
3652                 Colorchannel = item->data;
3653                 gst_color_balance_set_value(balance, Colorchannel, newVal);
3654                 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3655                 return TRUE;
3656         }
3657
3658         if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3659                 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3660                         newVal = 1;
3661                         control_label = "white_balance_temperature_auto";
3662                         goto _CHECK_AGAIN;
3663                 } else {
3664                         newVal = wb_temp_table[mslVal];
3665                         control_label = "white_balance_temperature";
3666                         goto _CHECK_AGAIN;
3667                 }
3668         }
3669
3670         MMCAM_LOG_ERROR("failed to find color channel item");
3671
3672         return FALSE;
3673 }
3674
3675
3676 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3677 {
3678         int mslVal = 0;
3679         int newVal = 0;
3680         int current_state = MM_CAMCORDER_STATE_NONE;
3681         GstCameraControl *control = NULL;
3682         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3683         _MMCamcorderSubContext *sc = NULL;
3684
3685         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3686
3687         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3688         if (!sc)
3689                 return TRUE;
3690
3691         mslVal = value->value.i_val;
3692         newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3693
3694         /* check whether set or not */
3695         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3696                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3697                 return TRUE;
3698         }
3699
3700         current_state = _mmcamcorder_get_state(handle);
3701         if (current_state < MM_CAMCORDER_STATE_READY) {
3702                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3703                 return TRUE;
3704         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3705                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3706                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3707                 return FALSE;
3708         }
3709
3710         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3711                 int ret = 0;
3712
3713                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3714                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3715                         return TRUE;
3716                 }
3717
3718                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3719                 if (control == NULL) {
3720                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3721                         return FALSE;
3722                 }
3723
3724                 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3725                 if (ret) {
3726                         MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3727
3728                         if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3729                                 unsigned int i = 0;
3730                                 int attr_idxs[] = {
3731                                         MM_CAM_CAMERA_ISO,
3732                                         MM_CAM_FILTER_BRIGHTNESS,
3733                                         MM_CAM_FILTER_WB,
3734                                         MM_CAM_FILTER_SATURATION,
3735                                         MM_CAM_FILTER_SHARPNESS,
3736                                         MM_CAM_FILTER_COLOR_TONE,
3737                                         MM_CAM_CAMERA_EXPOSURE_MODE
3738                                 };
3739                                 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3740
3741                                 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3742                                         if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3743                                                 mm_attrs_set_modified(attrs, attr_idxs[i]);
3744                                 }
3745                         }
3746
3747                         return TRUE;
3748                 } else {
3749                         MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3750                 }
3751         } else {
3752                 MMCAM_LOG_WARNING("pointer of video src is null");
3753         }
3754
3755         return FALSE;
3756 }
3757
3758
3759 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3760 {
3761         mmf_return_val_if_fail(handle && value, FALSE);
3762
3763         MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3764
3765         return TRUE;
3766 }
3767
3768
3769 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3770 {
3771         mmf_return_val_if_fail(handle && value, FALSE);
3772
3773         MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3774
3775         return TRUE;
3776 }
3777
3778
3779 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3780 {
3781         int current_state = MM_CAMCORDER_STATE_NONE;
3782         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3783
3784         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3785
3786         current_state = _mmcamcorder_get_state(handle);
3787         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3788                 MMCAM_LOG_WARNING("Can NOT Disable AUDIO. invalid state %d", current_state);
3789                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3790                 return FALSE;
3791         } else {
3792                 MMCAM_LOG_INFO("Disable AUDIO when Recording");
3793                 return TRUE;
3794         }
3795 }
3796
3797
3798 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3799 {
3800         int current_state = MM_CAMCORDER_STATE_NONE;
3801         const char *videosink_name = NULL;
3802         void *dp_handle = NULL;
3803         MMCamWindowInfo *window_info = NULL;
3804
3805         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3806         _MMCamcorderSubContext *sc = NULL;
3807
3808         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3809
3810         /* check type */
3811         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3812                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3813                 return FALSE;
3814         }
3815
3816         /* check current state */
3817         current_state = _mmcamcorder_get_state(handle);
3818         if (current_state < MM_CAMCORDER_STATE_READY) {
3819                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3820                 return TRUE;
3821         }
3822
3823         dp_handle = value->value.p_val;
3824         if (!dp_handle) {
3825                 MMCAM_LOG_WARNING("Display handle is NULL");
3826                 return FALSE;
3827         }
3828
3829         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3830
3831         /* get videosink name */
3832         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3833         if (!videosink_name) {
3834                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3835                 return FALSE;
3836         }
3837
3838         MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3839
3840         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3841                 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
3842                 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
3843         } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3844                 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
3845                 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
3846         } else if (!strcmp(videosink_name, "tizenwlsink")) {
3847                 window_info = (MMCamWindowInfo *)dp_handle;
3848                 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
3849                 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3850         } else if (!strcmp(videosink_name, "directvideosink")) {
3851                 window_info = (MMCamWindowInfo *)dp_handle;
3852                 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
3853                         window_info->surface_id,
3854                         window_info->rect.x,
3855                         window_info->rect.y,
3856                         window_info->rect.width,
3857                         window_info->rect.height);
3858                 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3859                 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3860                         window_info->rect.x,
3861                         window_info->rect.y,
3862                         window_info->rect.width,
3863                         window_info->rect.height);
3864         } else {
3865                 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
3866                 return FALSE;
3867         }
3868
3869         return TRUE;
3870 }
3871
3872
3873 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3874 {
3875         int current_state = MM_CAMCORDER_STATE_NONE;
3876         const char *videosink_name = NULL;
3877
3878         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3879         _MMCamcorderSubContext *sc = NULL;
3880
3881         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3882
3883         /* check type */
3884         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3885                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3886                 return FALSE;
3887         }
3888
3889         /* check current state */
3890         current_state = _mmcamcorder_get_state(handle);
3891         if (current_state < MM_CAMCORDER_STATE_READY) {
3892                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3893                 return TRUE;
3894         }
3895
3896         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3897
3898         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3899         if (videosink_name == NULL) {
3900                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3901                 return FALSE;
3902         }
3903
3904         MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3905
3906         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3907                 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
3908                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3909         } else {
3910                 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
3911         }
3912
3913         return TRUE;
3914 }
3915
3916
3917 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3918 {
3919         int current_state = MM_CAMCORDER_STATE_NONE;
3920
3921         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3922
3923         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3924
3925         /* check type */
3926         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3927                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3928                 return FALSE;
3929         }
3930
3931         /* check current state */
3932         current_state = _mmcamcorder_get_state(handle);
3933         if (current_state < MM_CAMCORDER_STATE_READY) {
3934                 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3935                 return TRUE;
3936         }
3937
3938         return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3939 }
3940
3941
3942 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3943 {
3944         int current_state = MM_CAMCORDER_STATE_NONE;
3945
3946         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3947
3948         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3949
3950         /* check type */
3951         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3952                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3953                 return FALSE;
3954         }
3955
3956         /* check current state */
3957         current_state = _mmcamcorder_get_state(handle);
3958         if (current_state < MM_CAMCORDER_STATE_READY) {
3959                 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3960                 return TRUE;
3961         }
3962
3963         return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3964 }
3965
3966
3967 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3968 {
3969         int current_state = MM_CAMCORDER_STATE_NONE;
3970         const char *videosink_name = NULL;
3971
3972         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3973         _MMCamcorderSubContext *sc = NULL;
3974
3975         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3976
3977         /* check type */
3978         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3979                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3980                 return FALSE;
3981         }
3982
3983         /* check current state */
3984         current_state = _mmcamcorder_get_state(handle);
3985         if (current_state < MM_CAMCORDER_STATE_READY) {
3986                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3987                 return TRUE;
3988         }
3989
3990         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3991
3992         /* Get videosink name */
3993         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3994         if (videosink_name == NULL) {
3995                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3996                 return FALSE;
3997         }
3998
3999         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4000                 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4001                 !strcmp(videosink_name, "directvideosink")) {
4002                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4003                 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4004         } else {
4005                 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4006         }
4007
4008         return TRUE;
4009 }
4010
4011
4012 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4013 {
4014         int method = 0;
4015         int current_state = MM_CAMCORDER_STATE_NONE;
4016         const char *videosink_name = NULL;
4017
4018         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4019         _MMCamcorderSubContext *sc = NULL;
4020
4021         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4022
4023         /* check type */
4024         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4025                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4026                 return FALSE;
4027         }
4028
4029         /* check current state */
4030         current_state = _mmcamcorder_get_state(handle);
4031         if (current_state < MM_CAMCORDER_STATE_READY) {
4032                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4033                 return TRUE;
4034         }
4035
4036         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4037
4038         /* Get videosink name */
4039         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4040         if (videosink_name == NULL) {
4041                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4042                 return FALSE;
4043         }
4044
4045         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4046             !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4047             !strcmp(videosink_name, "directvideosink")) {
4048                 method = value->value.i_val;
4049                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4050         } else {
4051                 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4052         }
4053
4054         return TRUE;
4055 }
4056
4057
4058 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4059 {
4060         int current_state = MM_CAMCORDER_STATE_NONE;
4061         int ret = MM_ERROR_NONE;
4062         const char *videosink_name = NULL;
4063
4064         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4065         _MMCamcorderSubContext *sc = NULL;
4066
4067         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4068
4069         /* check type */
4070         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4071                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4072                 return FALSE;
4073         }
4074
4075         /* check current state */
4076         current_state = _mmcamcorder_get_state(handle);
4077         if (current_state < MM_CAMCORDER_STATE_READY) {
4078                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4079                 return TRUE;
4080         }
4081
4082         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4083
4084         /* Get videosink name */
4085         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4086         if (videosink_name == NULL) {
4087                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4088                 return FALSE;
4089         }
4090
4091         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4092             !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4093                 int rect_x = 0;
4094                 int rect_y = 0;
4095                 int rect_width = 0;
4096                 int rect_height = 0;
4097                 int flags = MM_ATTRS_FLAG_NONE;
4098                 MMCamAttrsInfo info;
4099
4100                 mm_camcorder_get_attributes(handle, NULL,
4101                         MMCAM_DISPLAY_RECT_X, &rect_x,
4102                         MMCAM_DISPLAY_RECT_Y, &rect_y,
4103                         MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4104                         MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4105                         NULL);
4106                 switch (attr_idx) {
4107                 case MM_CAM_DISPLAY_RECT_X:
4108                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4109                         flags |= info.flag;
4110                         memset(&info, 0x00, sizeof(info));
4111                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4112                         flags |= info.flag;
4113                         memset(&info, 0x00, sizeof(info));
4114                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4115                         flags |= info.flag;
4116
4117                         rect_x = value->value.i_val;
4118                         break;
4119                 case MM_CAM_DISPLAY_RECT_Y:
4120                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4121                         flags |= info.flag;
4122                         memset(&info, 0x00, sizeof(info));
4123                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4124                         flags |= info.flag;
4125
4126                         rect_y = value->value.i_val;
4127                         break;
4128                 case MM_CAM_DISPLAY_RECT_WIDTH:
4129                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4130                         flags |= info.flag;
4131
4132                         rect_width = value->value.i_val;
4133                         break;
4134                 case MM_CAM_DISPLAY_RECT_HEIGHT:
4135                         rect_height = value->value.i_val;
4136                         break;
4137                 default:
4138                         MMCAM_LOG_ERROR("Wrong attr_idx!");
4139                         return FALSE;
4140                 }
4141
4142                 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4143                         MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4144
4145                         if (!strcmp(videosink_name, "tizenwlsink")) {
4146                             ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4147                                         rect_x, rect_y, rect_width, rect_height);
4148                                 if (!ret) {
4149                                         MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4150                                         return FALSE;
4151                                 }
4152                         } else {
4153                             g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4154                                         "dst-roi-x", rect_x,
4155                                         "dst-roi-y", rect_y,
4156                                         "dst-roi-w", rect_width,
4157                                         "dst-roi-h", rect_height,
4158                                         NULL);
4159                         }
4160                 }
4161         } else {
4162                 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4163         }
4164
4165         return TRUE;
4166 }
4167
4168
4169 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4170 {
4171         int zoom = 0;
4172         int current_state = MM_CAMCORDER_STATE_NONE;
4173         const char *videosink_name = NULL;
4174         GstElement *vs_element = NULL;
4175
4176         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4177         _MMCamcorderSubContext *sc = NULL;
4178
4179         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4180
4181         /* check type */
4182         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4183                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4184                 return FALSE;
4185         }
4186
4187         /* check current state */
4188         current_state = _mmcamcorder_get_state(handle);
4189         if (current_state < MM_CAMCORDER_STATE_READY) {
4190                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4191                 return TRUE;
4192         }
4193
4194         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4195
4196         /* Get videosink name */
4197         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4198         if (videosink_name == NULL) {
4199                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4200                 return FALSE;
4201         }
4202
4203         zoom = value->value.i_val;
4204         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4205                 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4206
4207                 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4208                 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4209
4210                 return TRUE;
4211         } else {
4212                 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4213                 return FALSE;
4214         }
4215 }
4216
4217
4218 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4219 {
4220         int current_state = MM_CAMCORDER_STATE_NONE;
4221         int do_scaling = 0;
4222         const char *videosink_name = NULL;
4223
4224         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4225         _MMCamcorderSubContext *sc = NULL;
4226
4227         mmf_return_val_if_fail(handle && value, FALSE);
4228
4229         /* check type */
4230         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4231                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4232                 return FALSE;
4233         }
4234
4235         /* check current state */
4236         current_state = _mmcamcorder_get_state(handle);
4237         if (current_state < MM_CAMCORDER_STATE_READY) {
4238                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4239                 return TRUE;
4240         }
4241
4242         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4243
4244         do_scaling = value->value.i_val;
4245
4246         /* Get videosink name */
4247         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4248         if (videosink_name == NULL) {
4249                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4250                 return FALSE;
4251         }
4252
4253         if (!strcmp(videosink_name, "evaspixmapsink")) {
4254                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4255                 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4256                 return TRUE;
4257         } else {
4258                 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4259                 return FALSE;
4260         }
4261 }
4262
4263
4264 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4265 {
4266         bool bret = FALSE;
4267         _MMCamcorderSubContext *sc = NULL;
4268         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4269         int strobe_type, mslVal, newVal, cur_value;
4270         int current_state = MM_CAMCORDER_STATE_NONE;
4271
4272         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4273
4274         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4275         if (!sc)
4276                 return TRUE;
4277
4278         /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4279
4280         mslVal = value->value.i_val;
4281
4282         /* check flash state */
4283         if (attr_idx == MM_CAM_STROBE_MODE) {
4284                 int flash_brightness = 0;
4285
4286                 /* get current flash brightness */
4287                 if (_mmcamcorder_get_device_flash_brightness(hcamcorder->gdbus_conn, &flash_brightness) != MM_ERROR_NONE) {
4288                         MMCAM_LOG_ERROR("_mmcamcorder_get_device_flash_brightness failed");
4289                         hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4290                         return FALSE;
4291                 }
4292
4293                 MMCAM_LOG_INFO("flash brightness %d", flash_brightness);
4294
4295                 if (flash_brightness > 0 &&
4296                     mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4297                         /* other module already turned on flash */
4298                         hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4299                         MMCAM_LOG_ERROR("other module already turned on flash. avoid to set flash mode here.");
4300                         return FALSE;
4301                 } else {
4302                         MMCAM_LOG_INFO("keep going");
4303                 }
4304         }
4305
4306         /* check state */
4307         current_state = _mmcamcorder_get_state(handle);
4308         if (current_state < MM_CAMCORDER_STATE_READY) {
4309                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4310                 return TRUE;
4311         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4312                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4313                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4314                 return FALSE;
4315         }
4316
4317         switch (attr_idx) {
4318         case MM_CAM_STROBE_CONTROL:
4319                 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4320                 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4321                 break;
4322         case MM_CAM_STROBE_CAPABILITIES:
4323                 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4324                 newVal = mslVal;
4325                 break;
4326         case MM_CAM_STROBE_MODE:
4327                 /* check whether set or not */
4328                 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4329                         MMCAM_LOG_INFO("skip set value %d", mslVal);
4330                         return TRUE;
4331                 }
4332
4333                 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4334                 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4335                 break;
4336         default:
4337                 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4338                 return FALSE;
4339         }
4340
4341         GstCameraControl *control = NULL;
4342         if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4343                 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4344                 bret = FALSE;
4345         } else {
4346                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4347                 if (control == NULL) {
4348                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4349                         return FALSE;
4350                 }
4351
4352                 if (gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4353                         if (newVal != cur_value) {
4354                                 if (gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4355                                         MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4356                                         bret = TRUE;
4357                                 } else {
4358                                         MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4359                                         bret = FALSE;
4360                                 }
4361                         } else {
4362                                 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4363                                 bret = TRUE;
4364                         }
4365                 } else {
4366                         MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4367                         bret = FALSE;
4368                 }
4369         }
4370
4371         return bret;
4372 }
4373
4374
4375 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4376 {
4377         int ret = 0;
4378         int current_state = MM_CAMCORDER_STATE_NONE;
4379         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4380
4381         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4382
4383         MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4384
4385         /* state check */
4386         current_state = _mmcamcorder_get_state(handle);
4387         if (current_state > MM_CAMCORDER_STATE_READY) {
4388                 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4389                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4390                 return FALSE;
4391         } else if (current_state < MM_CAMCORDER_STATE_READY) {
4392                 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4393                 return TRUE;
4394         }
4395
4396         ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4397
4398         MMCAM_LOG_INFO("ret %d", ret);
4399
4400         return ret;
4401 }
4402
4403
4404 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4405 {
4406         int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4407         int current_state = MM_CAMCORDER_STATE_NONE;
4408         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4409         _MMCamcorderSubContext *sc = NULL;
4410
4411         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4412
4413         /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4414
4415         /* check whether set or not */
4416         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4417                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4418                 return TRUE;
4419         }
4420
4421         /* state check */
4422         current_state = _mmcamcorder_get_state(handle);
4423         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4424                 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4425                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4426                 return FALSE;
4427         }
4428
4429         if (current_state >= MM_CAMCORDER_STATE_READY) {
4430                 int current_value = 0;
4431
4432                 set_hdr_mode = value->value.i_val;
4433                 mm_camcorder_get_attributes(handle, NULL,
4434                         MMCAM_CAMERA_HDR_CAPTURE, &current_value,
4435                         NULL);
4436
4437                 if (set_hdr_mode == current_value) {
4438                         MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4439                         return TRUE;
4440                 }
4441
4442                 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4443                 if (sc) {
4444                         if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4445                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4446                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4447
4448                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4449
4450                                 /* check decoder recreation */
4451                                 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4452                                         MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4453                                         return FALSE;
4454                                 }
4455
4456                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4457                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4458                         }
4459
4460                         set_hdr_mode = value->value.i_val;
4461                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4462                         sc->info_image->hdr_capture_mode = set_hdr_mode;
4463                         MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4464
4465                         if (current_state == MM_CAMCORDER_STATE_PREPARE)
4466                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4467                 } else {
4468                         MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4469                         return FALSE;
4470                 }
4471         }
4472
4473         return TRUE;
4474 }
4475
4476
4477 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4478 {
4479         bool bret = FALSE;
4480         _MMCamcorderSubContext *sc = NULL;
4481         int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4482         int set_value = 0;
4483         int current_value = 0;
4484         int current_state = MM_CAMCORDER_STATE_NONE;
4485         GstCameraControl *control = NULL;
4486
4487         mmf_return_val_if_fail(handle && value, FALSE);
4488
4489         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4490         if (!sc)
4491                 return TRUE;
4492
4493         /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4494
4495         /* state check */
4496         current_state = _mmcamcorder_get_state(handle);
4497         if (current_state < MM_CAMCORDER_STATE_READY) {
4498                 MMCAM_LOG_INFO("will be applied when preview starts");
4499                 return TRUE;
4500         }
4501
4502         set_value = value->value.i_val;
4503
4504         switch (attr_idx) {
4505         case MM_CAM_DETECT_MODE:
4506                 /* check whether set or not */
4507                 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4508                         MMCAM_LOG_INFO("skip set value %d", set_value);
4509                         return TRUE;
4510                 }
4511
4512                 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4513                 break;
4514         case MM_CAM_DETECT_NUMBER:
4515                 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4516                 break;
4517         case MM_CAM_DETECT_FOCUS_SELECT:
4518                 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4519                 break;
4520         case MM_CAM_DETECT_SELECT_NUMBER:
4521                 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4522                 break;
4523         case MM_CAM_DETECT_STATUS:
4524                 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4525                 break;
4526         default:
4527                 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4528                 return FALSE;
4529         }
4530
4531         if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4532                 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4533                 bret = FALSE;
4534         } else {
4535                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4536                 if (control == NULL) {
4537                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4538                         return FALSE;
4539                 }
4540
4541                 if (gst_camera_control_get_detect(control, detect_type, &current_value)) {
4542                         if (current_value == set_value) {
4543                                 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4544                                 bret = TRUE;
4545                         } else {
4546                                 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4547                                         MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4548                                                 detect_type, set_value);
4549                                         bret = FALSE;
4550                                 } else {
4551                                         MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4552                                                 detect_type, set_value);
4553                                         bret = TRUE;
4554                                 }
4555                         }
4556                 } else {
4557                         MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4558                         bret = FALSE;
4559                 }
4560         }
4561
4562         return bret;
4563 }
4564
4565
4566 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4567 {
4568         int current_state = MM_CAMCORDER_STATE_NONE;
4569         int preview_format = MM_PIXEL_FORMAT_NV12;
4570
4571         mmf_return_val_if_fail(handle && value, FALSE);
4572
4573         MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4574
4575         /* check preview format */
4576         mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4577         if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4578                 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4579                 return FALSE;
4580         }
4581
4582         /* check state */
4583         current_state = _mmcamcorder_get_state(handle);
4584         if (current_state < MM_CAMCORDER_STATE_READY) {
4585                 MMCAM_LOG_INFO("will be applied when preview starts");
4586                 return TRUE;
4587         }
4588
4589         return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4590 }
4591
4592
4593 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4594 {
4595         int current_state = MM_CAMCORDER_STATE_NONE;
4596         int preview_format = MM_PIXEL_FORMAT_NV12;
4597
4598         mmf_return_val_if_fail(handle && value, FALSE);
4599
4600         MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4601
4602         /* check preview format */
4603         mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4604         if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4605                 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4606                 return FALSE;
4607         }
4608
4609         /* check state */
4610         current_state = _mmcamcorder_get_state(handle);
4611         if (current_state < MM_CAMCORDER_STATE_READY) {
4612                 MMCAM_LOG_INFO("will be applied when preview starts");
4613                 return TRUE;
4614         }
4615
4616         return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4617 }
4618
4619
4620 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4621 {
4622         int stream_index = 0;
4623         char *stream_type = NULL;
4624         _MMCamcorderSubContext *sc = NULL;
4625
4626         mmf_return_val_if_fail(handle && value, FALSE);
4627
4628         stream_type = value->value.s_val;
4629         if (!stream_type) {
4630                 MMCAM_LOG_ERROR("NULL string");
4631                 return FALSE;
4632         }
4633
4634         mm_camcorder_get_attributes(handle, NULL,
4635                 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4636                 NULL);
4637         if (stream_index < 0) {
4638                 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4639                 return FALSE;
4640         }
4641
4642         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4643         if (!sc || !sc->encode_element ||
4644             !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4645                 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4646                 return TRUE;
4647         }
4648
4649         MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4650
4651         return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4652 }
4653
4654
4655 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4656 {
4657         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4658         int current_state = MM_CAMCORDER_STATE_NONE;
4659
4660         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4661
4662         current_state = _mmcamcorder_get_state(handle);
4663         if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4664                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4665                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4666                 return FALSE;
4667         }
4668
4669         return TRUE;
4670 }
4671
4672 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4673 {
4674         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4675
4676         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4677
4678         if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4679                 /* Replay gain enable */
4680                 int current_state = MM_CAMCORDER_STATE_NONE;
4681                 int audio_disable = FALSE;
4682
4683                 current_state = _mmcamcorder_get_state(handle);
4684                 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4685                         MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4686                         hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4687                         return FALSE;
4688                 }
4689
4690                 mm_camcorder_get_attributes(handle, NULL,
4691                         MMCAM_AUDIO_DISABLE, &audio_disable,
4692                         NULL);
4693
4694                 if (audio_disable) {
4695                         MMCAM_LOG_ERROR("audio is disabled");
4696                         hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4697                         return FALSE;
4698                 }
4699
4700                 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4701         } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4702                 /* Replay gain reference level */
4703                 int replay_gain_enable = FALSE;
4704
4705                 mm_camcorder_get_attributes(handle, NULL,
4706                         MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4707                         NULL);
4708
4709                 if (replay_gain_enable == FALSE) {
4710                         MMCAM_LOG_ERROR("replay gain is disabled");
4711                         hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4712                         return FALSE;
4713                 }
4714
4715                 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4716         } else {
4717                 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4718                 return FALSE;
4719         }
4720
4721         return TRUE;
4722 }
4723
4724
4725 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4726 {
4727         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4728         MMHandleType attrs;
4729
4730         int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4731
4732         unsigned int i = 0;
4733         int ret = TRUE;
4734         int attr_idxs_default[] = {
4735                 MM_CAM_CAMERA_DIGITAL_ZOOM,
4736                 MM_CAM_CAMERA_OPTICAL_ZOOM,
4737                 MM_CAM_CAMERA_WDR,
4738                 MM_CAM_FILTER_CONTRAST,
4739                 MM_CAM_FILTER_HUE,
4740                 MM_CAM_DETECT_MODE
4741         };
4742
4743         int attr_idxs_extra[] = {
4744                 MM_CAM_CAMERA_ISO,
4745                 MM_CAM_FILTER_BRIGHTNESS,
4746                 MM_CAM_FILTER_WB,
4747                 MM_CAM_FILTER_SATURATION,
4748                 MM_CAM_FILTER_SHARPNESS,
4749                 MM_CAM_FILTER_COLOR_TONE,
4750                 MM_CAM_CAMERA_EXPOSURE_MODE
4751         };
4752
4753         mmf_return_val_if_fail(hcamcorder, FALSE);
4754
4755         MMCAM_LOG_INFO("commit some attributes again");
4756
4757         attrs = MMF_CAMCORDER_ATTRS(handle);
4758         if (attrs == NULL) {
4759                 MMCAM_LOG_ERROR("Get attribute handle failed.");
4760                 return FALSE;
4761         }
4762
4763         /* Get Scene mode */
4764         mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4765
4766         for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4767                 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4768                         mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4769         }
4770
4771         /* Set extra if scene mode is NORMAL */
4772         if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4773                 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4774                         if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4775                                 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4776                 }
4777         } else {
4778                 /* Set scene mode if scene mode is NOT NORMAL */
4779                 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4780                         mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4781         }
4782
4783         if (mm_attrs_commit_all(attrs) == -1)
4784                 ret = FALSE;
4785         else
4786                 ret = TRUE;
4787
4788         MMCAM_LOG_INFO("Done.");
4789
4790         return ret;
4791 }
4792
4793
4794 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4795 {
4796         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4797         MMHandleType attrs;
4798         unsigned int i = 0;
4799         int ret = TRUE;
4800         int attr_idxs[] = {
4801                 MM_CAM_STROBE_MODE,
4802                 MM_CAM_CAMERA_PTZ_TYPE,
4803                 MM_CAM_CAMERA_PAN_MECHA,
4804                 MM_CAM_CAMERA_PAN_ELEC,
4805                 MM_CAM_CAMERA_TILT_MECHA,
4806                 MM_CAM_CAMERA_TILT_ELEC
4807         };
4808
4809         mmf_return_val_if_fail(hcamcorder, FALSE);
4810
4811         MMCAM_LOG_INFO("commit some attribute again[2]");
4812
4813         attrs = MMF_CAMCORDER_ATTRS(handle);
4814         if (attrs == NULL) {
4815                 MMCAM_LOG_ERROR("Get attribute handle failed.");
4816                 return FALSE;
4817         }
4818
4819         for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4820                 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4821                         mm_attrs_set_modified(attrs, attr_idxs[i]);
4822         }
4823
4824         if (mm_attrs_commit_all(attrs) == -1)
4825                 ret = FALSE;
4826         else
4827                 ret = TRUE;
4828
4829         MMCAM_LOG_INFO("Done.");
4830
4831         return ret;
4832 }
4833
4834
4835 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4836 {
4837         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4838         MMHandleType attrs;
4839         int table_size = 0;
4840         int i = 0;
4841         int nerror = MM_ERROR_NONE;
4842
4843         mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4844
4845         attrs = MMF_CAMCORDER_ATTRS(handle);
4846         mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4847
4848         MMCAM_LOG_INFO("");
4849
4850         table_size = ARRAY_SIZE(readonly_attributes);
4851         MMCAM_LOG_INFO("%d", table_size);
4852         for (i = 0; i < table_size; i++) {
4853                 int sCategory = readonly_attributes[i];
4854
4855                 mm_attrs_set_readonly(attrs, sCategory);
4856         }
4857
4858         return nerror;
4859 }
4860
4861
4862 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4863 {
4864         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4865         MMHandleType attrs;
4866         int i = 0;
4867         type_string_array * disabled_attr = NULL;
4868         int cnt_str = 0;
4869         int nerror = MM_ERROR_NONE ;
4870
4871         mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4872
4873         attrs = MMF_CAMCORDER_ATTRS(handle);
4874         mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4875
4876         MMCAM_LOG_INFO("");
4877
4878         /* add gst_param */
4879         _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4880                 CONFIGURE_CATEGORY_MAIN_GENERAL,
4881                 "DisabledAttributes",
4882                 &disabled_attr);
4883         if (disabled_attr != NULL && disabled_attr->value) {
4884                 cnt_str = disabled_attr->count;
4885                 for (i = 0; i < cnt_str; i++) {
4886                         int idx = 0;
4887                         MMCAM_LOG_INFO("[%d]%s", i, disabled_attr->value[i]);
4888                         nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
4889
4890                         if (nerror == MM_ERROR_NONE)
4891                                 mm_attrs_set_disabled(attrs, idx);
4892                         else
4893                                 MMCAM_LOG_WARNING("No ATTR named %s[%d]", disabled_attr->value[i], i);
4894                 }
4895         }
4896
4897         return nerror;
4898 }
4899
4900
4901 /*---------------------------------------------------------------------------------------
4902 |    INTERNAL FUNCTION DEFINITIONS:                                                     |
4903 ---------------------------------------------------------------------------------------*/
4904 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4905 {
4906         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4907         _MMCamcorderSubContext *sc = NULL;
4908         int current_state = MM_CAMCORDER_STATE_NULL;
4909
4910         mmf_return_val_if_fail(hcamcorder, FALSE);
4911
4912         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4913         if (!sc)
4914                 return TRUE;
4915
4916         current_state = _mmcamcorder_get_state(handle);
4917
4918         if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4919                 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4920                         MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
4921                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4922                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4923                 } else {
4924                         MMCAM_LOG_WARNING("invalid state[%d]", current_state);
4925                         return FALSE;
4926                 }
4927         } else {
4928                 MMCAM_LOG_INFO("element is not created yet");
4929         }
4930
4931         return TRUE;
4932 }
4933
4934
4935 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4936 {
4937         #define INIT_VALUE            -1
4938         #define CHECK_COUNT           3
4939
4940         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4941         MMHandleType attrs = 0;
4942
4943         int ret = MM_ERROR_NONE;
4944         int i = 0;
4945         int j = 0;
4946         const char *name = NULL;
4947         const char *check_pair_name[CHECK_COUNT][3] = {
4948                 {MMCAM_CAMERA_WIDTH,  MMCAM_CAMERA_HEIGHT,  "MMCAM_CAMERA_WIDTH and HEIGHT"},
4949                 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
4950                 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
4951         };
4952
4953         int check_pair_value[CHECK_COUNT][2] = {
4954                 {INIT_VALUE, INIT_VALUE},
4955                 {INIT_VALUE, INIT_VALUE},
4956                 {INIT_VALUE, INIT_VALUE},
4957         };
4958
4959         if (hcamcorder == NULL || attribute_name == NULL) {
4960                 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
4961                         hcamcorder, attribute_name);
4962                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4963         }
4964
4965         if (err_attr_name)
4966                 *err_attr_name = NULL;
4967
4968         /*MMCAM_LOG_INFO( "ENTER" );*/
4969
4970         attrs = MMF_CAMCORDER_ATTRS(handle);
4971
4972         name = attribute_name;
4973
4974         while (name) {
4975                 int idx = -1;
4976                 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
4977
4978                 /*MMCAM_LOG_INFO("NAME : %s", name);*/
4979
4980                 /* attribute name check */
4981                 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
4982                         if (err_attr_name)
4983                                 *err_attr_name = strdup(name);
4984
4985                         if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
4986                                 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
4987                         else
4988                                 return ret;
4989                 }
4990
4991                 /* type check */
4992                 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
4993                         return ret;
4994
4995                 switch (attr_type) {
4996                 case MM_ATTRS_TYPE_INT:
4997                 {
4998                         gboolean matched = FALSE;
4999                         for (i = 0 ; i < CHECK_COUNT ; i++) {
5000                                 for (j = 0 ; j < 2 ; j++) {
5001                                         if (!strcmp(name, check_pair_name[i][j])) {
5002                                                 check_pair_value[i][j] = va_arg((var_args), int);
5003                                                 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5004                                                 matched = TRUE;
5005                                                 break;
5006                                         }
5007                                 }
5008                                 if (matched)
5009                                         break;
5010                         }
5011                         if (matched == FALSE)
5012                                 va_arg((var_args), int);
5013                         break;
5014                 }
5015                 case MM_ATTRS_TYPE_DOUBLE:
5016                         va_arg((var_args), double);
5017                         break;
5018                 case MM_ATTRS_TYPE_STRING:
5019                         va_arg((var_args), char*); /* string */
5020                         va_arg((var_args), int);   /* size */
5021                         break;
5022                 case MM_ATTRS_TYPE_DATA:
5023                         va_arg((var_args), void*); /* data */
5024                         va_arg((var_args), int);   /* size */
5025                         break;
5026                 case MM_ATTRS_TYPE_INVALID:
5027                 default:
5028                         MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5029                         if (err_attr_name)
5030                                 *err_attr_name = strdup(name);
5031
5032                         return  MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5033                 }
5034
5035                 /* next name */
5036                 name = va_arg(var_args, const char*);
5037         }
5038
5039         for (i = 0 ; i < CHECK_COUNT ; i++) {
5040                 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5041                         gboolean check_result = FALSE;
5042                         char *err_name = NULL;
5043                         MMCamAttrsInfo attr_info_0, attr_info_1;
5044
5045                         if (check_pair_value[i][0] == INIT_VALUE) {
5046                                 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5047                                 err_name = strdup(check_pair_name[i][1]);
5048                         } else if (check_pair_value[i][1] == INIT_VALUE) {
5049                                 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5050                                 err_name = strdup(check_pair_name[i][0]);
5051                         } else {
5052                                 err_name = strdup(check_pair_name[i][2]);
5053                         }
5054
5055                         mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5056                         mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5057
5058                         check_result = FALSE;
5059
5060                         for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5061                                 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5062                                     attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5063                                         /*
5064                                         MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5065                                                 check_pair_name[i][0], check_pair_name[i][1],
5066                                                 check_pair_value[i][0], check_pair_value[i][1], i);
5067                                         */
5068                                         check_result = TRUE;
5069                                         break;
5070                                 }
5071                         }
5072
5073                         if (check_result == FALSE) {
5074                                 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5075                                         check_pair_name[i][0], check_pair_name[i][1],
5076                                         check_pair_value[i][0], check_pair_value[i][1]);
5077                                 if (err_attr_name) {
5078                                         *err_attr_name = err_name;
5079                                 } else {
5080                                         if (err_name) {
5081                                                 free(err_name);
5082                                                 err_name = NULL;
5083                                         }
5084                                 }
5085
5086                                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5087                         }
5088
5089                         if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5090                                 int current_width = 0;
5091                                 int current_height = 0;
5092
5093                                 mm_camcorder_get_attributes(handle, NULL,
5094                                         MMCAM_CAMERA_WIDTH, &current_width,
5095                                         MMCAM_CAMERA_HEIGHT, &current_height,
5096                                         NULL);
5097
5098                                 if (current_width != check_pair_value[i][0] ||
5099                                     current_height != check_pair_value[i][1]) {
5100                                         hcamcorder->resolution_changed = TRUE;
5101                                 } else {
5102                                         hcamcorder->resolution_changed = FALSE;
5103                                 }
5104
5105                                 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5106                         }
5107
5108                         if (err_name) {
5109                                 free(err_name);
5110                                 err_name = NULL;
5111                         }
5112                 }
5113         }
5114
5115         /*MMCAM_LOG_INFO("DONE");*/
5116
5117         return MM_ERROR_NONE;
5118 }
5119
5120
5121 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5122 {
5123         MMAttrsInfo info;
5124
5125         if ((void *)handle == NULL) {
5126                 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5127                 return FALSE;
5128         }
5129
5130         memset(&info, 0x0, sizeof(MMAttrsInfo));
5131
5132         mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5133
5134         switch (info.validity_type) {
5135         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5136                 /*
5137                 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5138                 */
5139                 if (info.int_array.count < 1)
5140                         return FALSE;
5141                 break;
5142         case MM_ATTRS_VALID_TYPE_INT_RANGE:
5143                 /*
5144                 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5145                 */
5146                 if (info.int_range.min > info.int_range.max)
5147                         return FALSE;
5148                 break;
5149         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5150                 /*
5151                 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5152                 */
5153                 if (info.double_array.count < 1)
5154                         return FALSE;
5155                 break;
5156         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5157                 /*
5158                 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5159                 */
5160                 if (info.double_range.min >= info.double_range.max)
5161                         return FALSE;
5162                 break;
5163         default:
5164                 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);
5165                 return FALSE;
5166         }
5167
5168         return TRUE;
5169 }