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