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