60b40ecc8fa5244ab326c64519ff25358ef5734b
[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                         MM_CAM_EXTRA_PREVIEW_ENABLE,
1684                         "extra-preview-enable",
1685                         MM_ATTRS_TYPE_INT,
1686                         MM_ATTRS_FLAG_RW,
1687                         {(void*)FALSE},
1688                         MM_ATTRS_VALID_TYPE_INT_RANGE,
1689                         {.int_min = 0},
1690                         {.int_max = 1},
1691                         _mmcamcorder_commit_extra_preview,
1692                 }
1693         };
1694
1695         memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1696
1697         for (idx = 0 ; idx < attr_count ; idx++) {
1698                 /* attribute order check. This should be same. */
1699                 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1700                         MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1701                         free(attrs_const_info);
1702                         attrs_const_info = NULL;
1703                         free(hcamcorder->cam_attrs_const_info);
1704                         hcamcorder->cam_attrs_const_info = NULL;
1705                         return 0;
1706                 }
1707
1708                 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1709                 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1710                 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1711                 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1712         }
1713
1714         /* Camcorder Attributes */
1715         MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1716
1717         ret = mm_attrs_new(attrs_const_info,
1718                 attr_count,
1719                 "Camcorder_Attributes",
1720                 _mmcamcorder_commit_camcorder_attrs,
1721                 (void *)handle,
1722                 &attrs);
1723
1724         free(attrs_const_info);
1725         attrs_const_info = NULL;
1726
1727         if (ret != MM_ERROR_NONE) {
1728                 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1729                 free(hcamcorder->cam_attrs_const_info);
1730                 hcamcorder->cam_attrs_const_info = NULL;
1731                 return 0;
1732         }
1733
1734         __mmcamcorder_set_conf_to_valid_info(handle);
1735
1736         for (idx = 0; idx < attr_count; idx++) {
1737                 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1738
1739                 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1740
1741                 switch (attr_info->validity_type) {
1742                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1743                         if (attr_info->validity_value_1.int_array &&
1744                             attr_info->validity_value_2.count > 0) {
1745                                 mm_attrs_set_valid_array(attrs, idx,
1746                                         (const int *)(attr_info->validity_value_1.int_array),
1747                                         attr_info->validity_value_2.count,
1748                                         attr_info->default_value.value_int);
1749                         }
1750                         break;
1751                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1752                         mm_attrs_set_valid_range(attrs, idx,
1753                                 attr_info->validity_value_1.int_min,
1754                                 attr_info->validity_value_2.int_max,
1755                                 attr_info->default_value.value_int);
1756                         break;
1757                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1758                         if (attr_info->validity_value_1.double_array &&
1759                             attr_info->validity_value_2.count > 0) {
1760                                 mm_attrs_set_valid_double_array(attrs, idx,
1761                                         (const double *)(attr_info->validity_value_1.double_array),
1762                                         attr_info->validity_value_2.count,
1763                                         attr_info->default_value.value_double);
1764                         }
1765                         break;
1766                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1767                         mm_attrs_set_valid_double_range(attrs, idx,
1768                                 attr_info->validity_value_1.double_min,
1769                                 attr_info->validity_value_2.double_max,
1770                                 attr_info->default_value.value_double);
1771                         break;
1772                 case MM_ATTRS_VALID_TYPE_NONE:
1773                         break;
1774                 case MM_ATTRS_VALID_TYPE_INVALID:
1775                 default:
1776                         MMCAM_LOG_ERROR("Valid type error.");
1777                         break;
1778                 }
1779         }
1780
1781         __mmcamcorder_release_conf_valid_info(handle);
1782
1783         return attrs;
1784 }
1785
1786
1787 void
1788 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1789 {
1790         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1791
1792         if (hcamcorder == NULL) {
1793                 MMCAM_LOG_ERROR("handle is NULL");
1794                 return;
1795         }
1796
1797         MMCAM_LOG_INFO("");
1798
1799         if (attrs) {
1800                 mm_attrs_free(attrs);
1801                 MMCAM_LOG_INFO("released attribute");
1802         }
1803
1804         if (hcamcorder->cam_attrs_const_info) {
1805                 free(hcamcorder->cam_attrs_const_info);
1806                 hcamcorder->cam_attrs_const_info = NULL;
1807                 MMCAM_LOG_INFO("released attribute info");
1808         }
1809
1810         return;
1811 }
1812
1813
1814 int
1815 _mmcamcorder_get_attributes(MMHandleType handle,  char **err_attr_name, const char *attribute_name, va_list var_args)
1816 {
1817         MMHandleType attrs = 0;
1818         int ret = MM_ERROR_NONE;
1819
1820         mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1821         /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1822
1823         attrs = MMF_CAMCORDER_ATTRS(handle);
1824         mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1825
1826         ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1827
1828         return ret;
1829 }
1830
1831
1832 int
1833 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1834 {
1835         MMHandleType attrs = 0;
1836         int ret = MM_ERROR_NONE;
1837         int err_index = 0;
1838         char *tmp_err_attr_name = NULL;
1839         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1840         va_list var_args_copy;
1841
1842         mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1843
1844         if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1845                 MMCAM_LOG_ERROR("Another command is running.");
1846                 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1847         }
1848
1849         /* copy var_args to keep original var_args */
1850         va_copy(var_args_copy, var_args);
1851
1852         attrs = MMF_CAMCORDER_ATTRS(handle);
1853         if (attrs) {
1854                 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1855         } else {
1856                 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1857                 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1858         }
1859
1860         if (ret == MM_ERROR_NONE) {
1861                 hcamcorder->error_code = MM_ERROR_NONE;
1862                 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1863                 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1864         }
1865
1866         va_end(var_args_copy);
1867
1868         _MMCAMCORDER_UNLOCK_CMD(handle);
1869
1870         if (ret != MM_ERROR_NONE) {
1871                 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1872                         if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1873                                 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1874                                 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1875                                         tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1876                                 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1877                         }
1878                 }
1879
1880                 if (hcamcorder->error_code != MM_ERROR_NONE) {
1881                         MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1882                         ret = hcamcorder->error_code;
1883                         hcamcorder->error_code = MM_ERROR_NONE;
1884                 }
1885
1886                 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1887         }
1888
1889         if (tmp_err_attr_name) {
1890                 if (!err_attr_name) {
1891                         MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1892                         free(tmp_err_attr_name);
1893                         tmp_err_attr_name = NULL;
1894                 } else {
1895                         *err_attr_name = tmp_err_attr_name;
1896                 }
1897         }
1898
1899         return ret;
1900 }
1901
1902
1903 int
1904 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1905 {
1906         MMHandleType attrs = 0;
1907         MMAttrsInfo attrinfo;
1908         int ret = MM_ERROR_NONE;
1909
1910         mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1911         mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1912         mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1913
1914         attrs = MMF_CAMCORDER_ATTRS(handle);
1915         mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1916
1917         ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1918
1919         if (ret == MM_ERROR_NONE) {
1920                 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1921                 info->type = attrinfo.type;
1922                 info->flag = attrinfo.flag;
1923                 info->validity_type = attrinfo.validity_type;
1924
1925                 switch (attrinfo.validity_type) {
1926                 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1927                         info->int_array.array = attrinfo.int_array.array;
1928                         info->int_array.count = attrinfo.int_array.count;
1929                         info->int_array.def = attrinfo.int_array.dval;
1930                         break;
1931                 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1932                         info->int_range.min = attrinfo.int_range.min;
1933                         info->int_range.max = attrinfo.int_range.max;
1934                         info->int_range.def = attrinfo.int_range.dval;
1935                         break;
1936                 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1937                         info->double_array.array = attrinfo.double_array.array;
1938                         info->double_array.count = attrinfo.double_array.count;
1939                         info->double_array.def = attrinfo.double_array.dval;
1940                         break;
1941                 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1942                         info->double_range.min = attrinfo.double_range.min;
1943                         info->double_range.max = attrinfo.double_range.max;
1944                         info->double_range.def = attrinfo.double_range.dval;
1945                         break;
1946                 case MM_ATTRS_VALID_TYPE_NONE:
1947                         break;
1948                 case MM_ATTRS_VALID_TYPE_INVALID:
1949                 default:
1950                         break;
1951                 }
1952         }
1953
1954         return ret;
1955 }
1956
1957
1958 bool
1959 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1960 {
1961         bool bret = FALSE;
1962         mmf_camcorder_t *hcamcorder = NULL;
1963
1964         mmf_return_val_if_fail(commit_param, FALSE);
1965         mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1966         mmf_return_val_if_fail(attr_name, FALSE);
1967         mmf_return_val_if_fail(value, FALSE);
1968
1969         hcamcorder = MMF_CAMCORDER(commit_param);
1970
1971         if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1972                 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1973         else
1974                 bret = TRUE;
1975
1976         return bret;
1977 }
1978
1979
1980 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1981 {
1982         int *format = NULL;
1983         int total_count = 0;
1984
1985         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1986
1987         if (hcamcorder == NULL) {
1988                 MMCAM_LOG_ERROR("handle is NULL");
1989                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1990         }
1991
1992         /* Audio encoder */
1993         total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
1994         hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
1995         hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
1996
1997         /* Video encoder */
1998         total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
1999         hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
2000         hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
2001
2002         /* Image encoder */
2003         total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
2004         hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
2005         hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
2006
2007         /* File format */
2008         total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
2009         hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
2010         hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
2011
2012         return MM_ERROR_NONE;
2013 }
2014
2015
2016 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
2017 {
2018         int *allocated_memory = NULL;
2019
2020         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2021
2022         if (hcamcorder == NULL) {
2023                 MMCAM_LOG_ERROR("handle is NULL");
2024                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2025         }
2026
2027         MMCAM_LOG_INFO("START");
2028
2029         /* Audio encoder info */
2030         allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2031         if (allocated_memory) {
2032                 g_free(allocated_memory);
2033                 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2034                 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2035         }
2036
2037         /* Video encoder info */
2038         allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2039         if (allocated_memory) {
2040                 g_free(allocated_memory);
2041                 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2042                 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2043         }
2044
2045         /* Image encoder info */
2046         allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2047         if (allocated_memory) {
2048                 g_free(allocated_memory);
2049                 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2050                 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2051         }
2052
2053         /* File format info */
2054         allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2055         if (allocated_memory) {
2056                 g_free(allocated_memory);
2057                 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2058                 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2059         }
2060
2061         MMCAM_LOG_INFO("DONE");
2062
2063         return MM_ERROR_NONE;
2064 }
2065
2066
2067 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2068 {
2069         MMHandleType attr = 0;
2070         int current_state = MM_CAMCORDER_STATE_NONE;
2071
2072         mmf_return_val_if_fail(handle && value, FALSE);
2073
2074         attr = MMF_CAMCORDER_ATTRS(handle);
2075         mmf_return_val_if_fail(attr, FALSE);
2076
2077         /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2078
2079         current_state = _mmcamcorder_get_state(handle);
2080         if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2081                 int flags = MM_ATTRS_FLAG_NONE;
2082                 int capture_width, capture_height;
2083                 MMCamAttrsInfo info;
2084
2085                 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2086                 flags = info.flag;
2087
2088                 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2089                         mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2090                         capture_width = value->value.i_val;
2091
2092                         /* Check whether they are valid pair */
2093                         return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2094                 }
2095
2096                 return TRUE;
2097         } else {
2098                 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2099                 return FALSE;
2100         }
2101 }
2102
2103
2104 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2105 {
2106         int current_state = MM_CAMCORDER_STATE_NONE;
2107
2108         current_state = _mmcamcorder_get_state(handle);
2109
2110         if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2111                 int capture_width, capture_height;
2112
2113                 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2114                 capture_height = value->value.i_val;
2115
2116                 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2117         } else {
2118                 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2119
2120                 return FALSE;
2121         }
2122 }
2123
2124
2125 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2126 {
2127         int current_state = 0;
2128         int ivalue = 0;
2129         _MMCamcorderSubContext *sc = NULL;
2130         _MMCamcorderImageInfo *info = NULL;
2131         GstCameraControl *control = NULL;
2132
2133         mmf_return_val_if_fail(handle && value, FALSE);
2134
2135         current_state = _mmcamcorder_get_state(handle);
2136         ivalue = value->value.i_val;
2137
2138         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2139         if (!sc)
2140                 return TRUE;
2141
2142         info = sc->info_image;
2143         if (!info) {
2144                 MMCAM_LOG_ERROR("info image is NULL");
2145                 return FALSE;
2146         }
2147
2148         if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2149                 if (info->capture_send_count > 0) {
2150                         info->capturing = FALSE;
2151                         MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2152                 }
2153
2154                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2155                         MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2156                         return TRUE;
2157                 }
2158
2159                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2160                 if (control) {
2161                         gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2162                         MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2163                 } else {
2164                         MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2165                 }
2166         } else {
2167                 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2168         }
2169
2170         return TRUE;
2171 }
2172
2173
2174 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2175 {
2176         int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2177         int current_state = MM_CAMCORDER_STATE_NONE;
2178         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2179
2180         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2181
2182         current_state = _mmcamcorder_get_state(handle);
2183         mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2184
2185         MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2186                 current_state, mode, value->value.i_val);
2187
2188         if (mode != MM_CAMCORDER_MODE_AUDIO &&
2189             current_state != MM_CAMCORDER_STATE_CAPTURING) {
2190                 return TRUE;
2191         } else {
2192                 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2193                 return FALSE;
2194         }
2195 }
2196
2197
2198 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2199 {
2200         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2201
2202         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2203
2204         MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2205
2206         /* return error when disable shutter sound if policy is TRUE */
2207         if (!value->value.i_val &&
2208             hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2209                 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2210                 return FALSE;
2211         } else {
2212                 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2213                 return TRUE;
2214         }
2215 }
2216
2217
2218 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2219 {
2220         int current_state = MM_CAMCORDER_STATE_NONE;
2221         _MMCamcorderSubContext *sc = NULL;
2222         bool bret = FALSE;
2223
2224         mmf_return_val_if_fail(handle && value, FALSE);
2225
2226         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2227         if (!sc)
2228                 return TRUE;
2229
2230         current_state = _mmcamcorder_get_state(handle);
2231
2232         if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2233                 double mslNewVal = 0;
2234                 mslNewVal = value->value.d_val;
2235
2236                 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2237                         if (mslNewVal == 0.0) {
2238                                 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2239                                 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2240                         } else {
2241                                 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2242                                 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2243                         }
2244                 }
2245
2246                 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2247                 bret = TRUE;
2248         } else {
2249                 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2250                 bret = TRUE;
2251         }
2252
2253         return bret;
2254 }
2255
2256
2257 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2258 {
2259         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2260         int current_state = MM_CAMCORDER_STATE_NONE;
2261
2262         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2263
2264         current_state = _mmcamcorder_get_state(handle);
2265         if (current_state > MM_CAMCORDER_STATE_READY) {
2266                 MMCAM_LOG_ERROR("invalid state %d", current_state);
2267                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2268                 return FALSE;
2269         }
2270
2271         return TRUE;
2272 }
2273
2274
2275 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2276 {
2277         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2278         MMCamAttrsInfo fps_info;
2279         int resolution_width = 0;
2280         int resolution_height = 0;
2281         int i = 0;
2282         int ret = 0;
2283         int current_state = MM_CAMCORDER_STATE_NONE;
2284
2285         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2286
2287         current_state = _mmcamcorder_get_state(handle);
2288         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2289                 MMCAM_LOG_ERROR("invalid state %d", current_state);
2290                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2291                 return FALSE;
2292         }
2293
2294         if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2295                 return TRUE;
2296
2297         MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2298
2299         ret = mm_camcorder_get_attributes(handle, NULL,
2300                 MMCAM_CAMERA_WIDTH, &resolution_width,
2301                 MMCAM_CAMERA_HEIGHT, &resolution_height,
2302                 NULL);
2303
2304         if (ret != MM_ERROR_NONE) {
2305                 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2306                 return FALSE;
2307         }
2308
2309         ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2310         if (ret != MM_ERROR_NONE) {
2311                 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2312                 return FALSE;
2313         }
2314
2315         for (i = 0 ; i < fps_info.int_array.count ; i++) {
2316                 if (value->value.i_val == fps_info.int_array.array[i])
2317                         return TRUE;
2318         }
2319
2320         MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2321
2322         return FALSE;
2323 }
2324
2325
2326 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2327 {
2328         int current_state = MM_CAMCORDER_STATE_NONE;
2329         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2330         _MMCamcorderSubContext *sc = NULL;
2331
2332         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2333
2334         current_state = _mmcamcorder_get_state(handle);
2335         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2336                 MMCAM_LOG_WARNING("invalid state %d", current_state);
2337                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2338                 return FALSE;
2339         }
2340
2341         /* Verify recording motion rate */
2342         if (value->value.d_val > 0.0) {
2343                 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2344                 if (!sc)
2345                         return TRUE;
2346
2347                 /* set is_slow flag */
2348                 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2349                         sc->is_modified_rate = TRUE;
2350                 else
2351                         sc->is_modified_rate = FALSE;
2352
2353                 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2354                 return TRUE;
2355         } else {
2356                 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2357                 return FALSE;
2358         }
2359 }
2360
2361
2362 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2363 {
2364         MMHandleType attr = 0;
2365         int current_state = MM_CAMCORDER_STATE_NONE;
2366         int ret = 0;
2367         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2368         _MMCamcorderSubContext *sc = NULL;
2369
2370         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2371
2372         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2373         if (!sc)
2374                 return TRUE;
2375
2376         attr = MMF_CAMCORDER_ATTRS(handle);
2377         mmf_return_val_if_fail(attr, FALSE);
2378
2379         MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2380
2381         current_state = _mmcamcorder_get_state(handle);
2382
2383         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2384                 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2385                 return FALSE;
2386         } else {
2387                 int flags = MM_ATTRS_FLAG_NONE;
2388                 MMCamAttrsInfo info;
2389                 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2390                 flags = info.flag;
2391
2392                 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2393                         int width = value->value.i_val;
2394                         int height = 0;
2395                         int preview_format = MM_PIXEL_FORMAT_NV12;
2396                         int codec_type = MM_IMAGE_CODEC_JPEG;
2397
2398                         mm_camcorder_get_attributes(handle, NULL,
2399                                 MMCAM_CAMERA_HEIGHT, &height,
2400                                 MMCAM_CAMERA_FORMAT, &preview_format,
2401                                 MMCAM_IMAGE_ENCODER, &codec_type,
2402                                 NULL);
2403
2404                         if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2405                                 if (hcamcorder->resolution_changed == FALSE) {
2406                                         MMCAM_LOG_INFO("no need to restart preview");
2407                                         return TRUE;
2408                                 }
2409
2410                                 hcamcorder->resolution_changed = FALSE;
2411
2412                                 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2413                                         MMCAM_LOG_INFO("restart preview");
2414
2415                                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2416                                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2417
2418                                         if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2419                                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2420
2421                                         /* check decoder recreation */
2422                                         if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2423                                                 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2424                                                 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2425                                                 return FALSE;
2426                                         }
2427
2428                                         /* get preview format */
2429                                         sc->info_image->preview_format = preview_format;
2430                                         sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2431                                         ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2432
2433                                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2434                                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2435
2436                                         if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2437                                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2438
2439                                         /* unlock */
2440                                         g_mutex_unlock(&hcamcorder->restart_preview_lock);
2441                                 } else {
2442                                         MMCAM_LOG_ERROR("currently locked for preview restart");
2443                                         return FALSE;
2444                                 }
2445                         } else {
2446                                 /* get preview format */
2447                                 sc->info_image->preview_format = preview_format;
2448                                 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2449                                 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2450                         }
2451
2452                         return ret;
2453                 }
2454
2455                 return TRUE;
2456         }
2457 }
2458
2459
2460 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2461 {
2462         int ret = 0;
2463         int current_state = MM_CAMCORDER_STATE_NONE;
2464         MMHandleType attr = 0;
2465         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2466         _MMCamcorderSubContext *sc = NULL;
2467
2468         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2469
2470         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2471         if (!sc)
2472                 return TRUE;
2473
2474         attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2475         mmf_return_val_if_fail(attr, FALSE);
2476
2477         MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2478         current_state = _mmcamcorder_get_state(handle);
2479
2480         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2481                 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2482                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2483                 return FALSE;
2484         } else {
2485                 int width = 0;
2486                 int height = value->value.i_val;
2487                 int preview_format = MM_PIXEL_FORMAT_NV12;
2488                 int codec_type = MM_IMAGE_CODEC_JPEG;
2489                 int video_stabilization = 0;
2490
2491                 mm_camcorder_get_attributes(handle, NULL,
2492                         MMCAM_CAMERA_WIDTH, &width,
2493                         MMCAM_CAMERA_FORMAT, &preview_format,
2494                         MMCAM_IMAGE_ENCODER, &codec_type,
2495                         MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2496                         NULL);
2497
2498                 sc->info_video->preview_width = width;
2499                 sc->info_video->preview_height = height;
2500
2501                 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2502                         if (hcamcorder->resolution_changed == FALSE) {
2503                                 MMCAM_LOG_INFO("no need to restart preview");
2504                                 return TRUE;
2505                         }
2506
2507                         hcamcorder->resolution_changed = FALSE;
2508
2509                         if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2510                                 MMCAM_LOG_INFO("restart preview");
2511
2512                                 MMCAM_LOG_INFO("set empty buffers");
2513
2514                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2515                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2516
2517                                 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2518                                         _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2519
2520                                 /* check decoder recreation */
2521                                 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2522                                         MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2523                                         g_mutex_unlock(&hcamcorder->restart_preview_lock);
2524                                         return FALSE;
2525                                 }
2526
2527                                 /* get preview format */
2528                                 sc->info_image->preview_format = preview_format;
2529                                 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2530
2531                                 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2532
2533                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2534                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2535
2536                                 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2537                                         _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2538
2539                                 /* unlock */
2540                                 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2541                         } else {
2542                                 MMCAM_LOG_ERROR("currently locked for preview restart");
2543                                 return FALSE;
2544                         }
2545                 } else {
2546                         /* get preview format */
2547                         sc->info_image->preview_format = preview_format;
2548                         sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2549                         ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2550                 }
2551
2552                 return ret;
2553         }
2554 }
2555
2556
2557 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2558 {
2559         int current_state = MM_CAMCORDER_STATE_NONE;
2560         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2561
2562         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2563
2564         current_state = _mmcamcorder_get_state(handle);
2565         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2566                 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2567                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2568                 return FALSE;
2569         } else {
2570                 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2571                         value->value.i_val, attr_idx);
2572                 return TRUE;
2573         }
2574 }
2575
2576
2577 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2578 {
2579         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2580         _MMCamcorderSubContext *sc = NULL;
2581         int current_state = MM_CAMCORDER_STATE_NONE;
2582         GstCameraControl *control = NULL;
2583         int zoom_level = 0;
2584         int zoom_type = 0;
2585
2586         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2587
2588         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2589         if (!sc)
2590                 return TRUE;
2591
2592         zoom_level = value->value.i_val;
2593
2594         MMCAM_LOG_INFO("(%d)", attr_idx);
2595
2596         current_state = _mmcamcorder_get_state(handle);
2597         if (current_state < MM_CAMCORDER_STATE_READY) {
2598                 MMCAM_LOG_INFO("will be applied when preview starts");
2599                 return TRUE;
2600         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2601                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2602                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2603                 return FALSE;
2604         }
2605
2606         if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2607                 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2608         else
2609                 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2610
2611         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2612                 int ret = FALSE;
2613
2614                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2615                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2616                         return TRUE;
2617                 }
2618
2619                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2620                 if (control == NULL) {
2621                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2622                         return FALSE;
2623                 }
2624
2625                 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2626                 if (ret) {
2627                         MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2628                         return TRUE;
2629                 } else {
2630                         MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2631                 }
2632         } else {
2633                 MMCAM_LOG_INFO("pointer of video src is null");
2634         }
2635
2636         return FALSE;
2637 }
2638
2639
2640 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2641 {
2642         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2643         _MMCamcorderSubContext *sc = NULL;
2644         int current_state = MM_CAMCORDER_STATE_NONE;
2645
2646         GstCameraControl *CameraControl = NULL;
2647         GstCameraControlChannel *CameraControlChannel = NULL;
2648         const GList *controls = NULL;
2649         const GList *item = NULL;
2650
2651         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2652
2653         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2654         mmf_return_val_if_fail(sc, TRUE);
2655
2656         MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2657
2658         current_state = _mmcamcorder_get_state(handle);
2659         if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2660             current_state == MM_CAMCORDER_STATE_CAPTURING) {
2661                 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2662                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2663                 return FALSE;
2664         }
2665
2666         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2667                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2668                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2669                         return FALSE;
2670                 }
2671
2672                 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2673                 if (CameraControl == NULL) {
2674                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2675                         return FALSE;
2676                 }
2677
2678                 controls = gst_camera_control_list_channels(CameraControl);
2679                 if (controls == NULL) {
2680                         MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2681                         return FALSE;
2682                 }
2683
2684                 for (item = controls ; item && item->data ; item = item->next) {
2685                         CameraControlChannel = item->data;
2686                         MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2687                         if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2688                                 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2689                                         MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2690                                         return TRUE;
2691                                 } else {
2692                                         MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2693                                         return FALSE;
2694                                 }
2695                         }
2696                 }
2697
2698                 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2699         }
2700
2701         return FALSE;
2702 }
2703
2704
2705 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2706 {
2707         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2708         _MMCamcorderSubContext *sc = NULL;
2709         int current_state = MM_CAMCORDER_STATE_NONE;
2710
2711         GstCameraControl *CameraControl = NULL;
2712         GstCameraControlChannel *CameraControlChannel = NULL;
2713         const GList *controls = NULL;
2714         const GList *item = NULL;
2715
2716         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2717
2718         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2719         mmf_return_val_if_fail(sc, TRUE);
2720
2721         MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2722
2723         current_state = _mmcamcorder_get_state(handle);
2724         if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2725             current_state == MM_CAMCORDER_STATE_CAPTURING) {
2726                 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2727                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2728                 return FALSE;
2729         }
2730
2731         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2732                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2733                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2734                         return FALSE;
2735                 }
2736
2737                 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2738                 if (CameraControl == NULL) {
2739                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2740                         return FALSE;
2741                 }
2742
2743                 controls = gst_camera_control_list_channels(CameraControl);
2744                 if (controls == NULL) {
2745                         MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2746                         return FALSE;
2747                 }
2748
2749                 for (item = controls ; item && item->data ; item = item->next) {
2750                         CameraControlChannel = item->data;
2751                         MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2752                         if (!strcmp(CameraControlChannel->label, "pan")) {
2753                                 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2754                                         MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2755                                         return TRUE;
2756                                 } else {
2757                                         MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2758                                         return FALSE;
2759                                 }
2760                         }
2761                 }
2762
2763                 MMCAM_LOG_WARNING("failed to find pan control channel");
2764         }
2765
2766         return FALSE;
2767 }
2768
2769
2770 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2771 {
2772         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2773         _MMCamcorderSubContext *sc = NULL;
2774         int current_state = MM_CAMCORDER_STATE_NONE;
2775
2776         GstCameraControl *CameraControl = NULL;
2777         GstCameraControlChannel *CameraControlChannel = NULL;
2778         const GList *controls = NULL;
2779         const GList *item = NULL;
2780
2781         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2782
2783         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2784         mmf_return_val_if_fail(sc, TRUE);
2785
2786         MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2787
2788         current_state = _mmcamcorder_get_state(handle);
2789         if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2790             current_state == MM_CAMCORDER_STATE_CAPTURING) {
2791                 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2792                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2793                 return FALSE;
2794         }
2795
2796         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2797                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2798                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2799                         return FALSE;
2800                 }
2801
2802                 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2803                 if (CameraControl == NULL) {
2804                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2805                         return FALSE;
2806                 }
2807
2808                 controls = gst_camera_control_list_channels(CameraControl);
2809                 if (controls == NULL) {
2810                         MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2811                         return FALSE;
2812                 }
2813
2814                 for (item = controls ; item && item->data ; item = item->next) {
2815                         CameraControlChannel = item->data;
2816                         MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2817                         if (!strcmp(CameraControlChannel->label, "tilt")) {
2818                                 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2819                                         MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2820                                         return TRUE;
2821                                 } else {
2822                                         MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2823                                         return FALSE;
2824                                 }
2825                         }
2826                 }
2827
2828                 MMCAM_LOG_WARNING("failed to find tilt control channel");
2829         }
2830
2831         return FALSE;
2832 }
2833
2834
2835 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2836 {
2837         MMHandleType attr = 0;
2838         int current_state = MM_CAMCORDER_STATE_NONE;
2839         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2840         _MMCamcorderSubContext *sc = NULL;
2841         GstCameraControl *control = NULL;
2842         int mslVal;
2843         int set_focus_mode = 0;
2844         int cur_focus_mode = 0;
2845         int cur_focus_range = 0;
2846
2847         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2848
2849         attr = MMF_CAMCORDER_ATTRS(handle);
2850         mmf_return_val_if_fail(attr, FALSE);
2851
2852         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2853         if (!sc)
2854                 return TRUE;
2855
2856         MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2857
2858         /* check whether set or not */
2859         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2860                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2861                 return TRUE;
2862         }
2863
2864         current_state = _mmcamcorder_get_state(handle);
2865         if (current_state < MM_CAMCORDER_STATE_NULL) {
2866                 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2867                 return TRUE;
2868         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2869                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2870                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2871                 return FALSE;
2872         }
2873
2874         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2875                 int flags = MM_ATTRS_FLAG_NONE;
2876                 MMCamAttrsInfo info;
2877
2878                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2879                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2880                         return TRUE;
2881                 }
2882
2883                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2884                 if (control == NULL) {
2885                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2886                         return FALSE;
2887                 }
2888
2889                 mslVal = value->value.i_val;
2890                 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2891
2892                 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2893                 flags = info.flag;
2894
2895                 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2896                         if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2897                                 if (set_focus_mode != cur_focus_mode) {
2898                                         if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2899                                                 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2900                                                 return TRUE;
2901                                         } else {
2902                                                 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2903                                         }
2904                                 } else {
2905                                         MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2906                                         return TRUE;
2907                                 }
2908                         } else {
2909                                 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2910                         }
2911                 }
2912         } else {
2913                 MMCAM_LOG_INFO("pointer of video src is null");
2914         }
2915
2916         return TRUE;
2917 }
2918
2919
2920 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2921 {
2922         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2923         _MMCamcorderSubContext *sc = NULL;
2924         GstCameraControl *control = NULL;
2925         int current_state = MM_CAMCORDER_STATE_NONE;
2926         int mslVal = 0;
2927         int newVal = 0;
2928         int cur_focus_mode = 0;
2929         int cur_focus_range = 0;
2930         int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2931         int converted_mode = 0;
2932
2933         mmf_return_val_if_fail(hcamcorder && value, FALSE);
2934
2935         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2936         if (!sc)
2937                 return TRUE;
2938
2939         MMCAM_LOG_INFO("(%d)", attr_idx);
2940
2941         /* check whether set or not */
2942         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2943                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2944                 return TRUE;
2945         }
2946
2947         mslVal = value->value.i_val;
2948         newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2949
2950         current_state = _mmcamcorder_get_state(handle);
2951         if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2952                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
2953                 return TRUE;
2954         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2955                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2956                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2957                 return FALSE;
2958         }
2959
2960         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2961                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2962                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2963                         return TRUE;
2964                 }
2965
2966                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2967                 if (control == NULL) {
2968                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2969                         return FALSE;
2970                 }
2971
2972                 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
2973                 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
2974
2975                 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2976                         if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
2977                                 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
2978                                         /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
2979                                         return TRUE;
2980                                 } else {
2981                                         MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2982                                 }
2983                         } else {
2984                                 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
2985                                 return TRUE;
2986                         }
2987                 } else {
2988                         MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2989                 }
2990         } else {
2991                 MMCAM_LOG_INFO("pointer of video src is null");
2992         }
2993
2994         return FALSE;
2995 }
2996
2997
2998 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2999 {
3000         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3001         _MMCamcorderSubContext *sc = NULL;
3002         GstCameraControl *control = NULL;
3003         GstCameraControlRectType set_area = { 0, 0, 0, 0 };
3004         GstCameraControlRectType get_area = { 0, 0, 0, 0 };
3005
3006         int current_state = MM_CAMCORDER_STATE_NONE;
3007         int ret = FALSE;
3008         int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3009
3010         gboolean do_set = FALSE;
3011
3012         MMCamAttrsInfo info_y;
3013         MMCamAttrsInfo info_w;
3014         MMCamAttrsInfo info_h;
3015
3016         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3017
3018         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3019         if (!sc)
3020                 return TRUE;
3021
3022         MMCAM_LOG_INFO("(%d)", attr_idx);
3023
3024         current_state = _mmcamcorder_get_state(handle);
3025         if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3026                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3027                 return TRUE;
3028         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3029                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3030                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3031                 return FALSE;
3032         }
3033
3034         ret = mm_camcorder_get_attributes(handle, NULL,
3035                 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3036                 NULL);
3037         if (ret != MM_ERROR_NONE) {
3038                 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3039                 return FALSE;
3040         }
3041
3042         if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3043                 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3044                 return FALSE;
3045         }
3046
3047         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3048                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3049                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3050                         return TRUE;
3051                 }
3052
3053                 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3054                 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3055                 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3056
3057                 switch (attr_idx) {
3058                 case MM_CAM_CAMERA_AF_TOUCH_X:
3059                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3060                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3061                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3062                         if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3063                                 set_area.x = value->value.i_val;
3064                                 mm_camcorder_get_attributes(handle, NULL,
3065                                         MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3066                                         MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3067                                         MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3068                                         NULL);
3069                                 do_set = TRUE;
3070                         } else {
3071                                 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3072                                 return TRUE;
3073                         }
3074                         break;
3075                 case MM_CAM_CAMERA_AF_TOUCH_Y:
3076                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3077                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3078                         if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3079                                 set_area.y = value->value.i_val;
3080                                 mm_camcorder_get_attributes(handle, NULL,
3081                                         MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3082                                         MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3083                                         MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3084                                         NULL);
3085                                 do_set = TRUE;
3086                         } else {
3087                                 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3088                                 return TRUE;
3089                         }
3090                         break;
3091                 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3092                         mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3093                         if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3094                                 set_area.width = value->value.i_val;
3095                                 mm_camcorder_get_attributes(handle, NULL,
3096                                         MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3097                                         MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3098                                         MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3099                                         NULL);
3100                                 do_set = TRUE;
3101                         } else {
3102                                 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3103                                 return TRUE;
3104                         }
3105                         break;
3106                 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3107                         set_area.height = value->value.i_val;
3108                         mm_camcorder_get_attributes(handle, NULL,
3109                                 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3110                                 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3111                                 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3112                                 NULL);
3113                         do_set = TRUE;
3114                         break;
3115                 default:
3116                         break;
3117                 }
3118
3119                 if (do_set) {
3120                         _MMCamcorderVideoInfo *info = sc->info_video;
3121
3122                         if (info == NULL) {
3123                                 MMCAM_LOG_ERROR("video info is NULL");
3124                                 return FALSE;
3125                         }
3126
3127                         control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3128                         if (control == NULL) {
3129                                 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3130                                 return FALSE;
3131                         }
3132
3133                         /* convert area */
3134                         if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3135                             (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3136                                 float ratio_width = 0.0;
3137                                 float ratio_height = 0.0;
3138
3139                                 if (info->preview_width != 0 && info->preview_height != 0) {
3140                                         ratio_width = (float)info->video_width / (float)info->preview_width;
3141                                         ratio_height = (float)info->video_height / (float)info->preview_height;
3142
3143                                         MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3144                                                 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3145
3146                                         set_area.x = (int)((float)set_area.x * ratio_width);
3147                                         set_area.y = (int)((float)set_area.y * ratio_height);
3148                                         set_area.width = (int)((float)set_area.width * ratio_width);
3149                                         set_area.height = (int)((float)set_area.height * ratio_height);
3150
3151                                         if (set_area.width <= 0)
3152                                                 set_area.width = 1;
3153
3154                                         if (set_area.height <= 0)
3155                                                 set_area.height = 1;
3156
3157                                         MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3158                                                 set_area.x, set_area.y, set_area.width, set_area.height);
3159                                 } else {
3160                                         MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3161                                                 info->preview_width, info->preview_height);
3162                                 }
3163                         }
3164
3165                         ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3166                         if (!ret) {
3167                                 MMCAM_LOG_WARNING("Failed to get AF area");
3168                                 return FALSE;
3169                         }
3170
3171                         /* width and height are not supported now */
3172                         if (get_area.x == set_area.x && get_area.y == set_area.y) {
3173                                 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3174                                         get_area.x, get_area.y);
3175                                 return TRUE;
3176                         }
3177
3178                         ret = gst_camera_control_set_auto_focus_area(control, set_area);
3179                         if (ret) {
3180                                 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3181                                         set_area.x, set_area.y, set_area.width, set_area.height);
3182                                 return TRUE;
3183                         } else {
3184                                 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3185                                         set_area.x, set_area.y, set_area.width, set_area.height);
3186                         }
3187                 }
3188         } else {
3189                 MMCAM_LOG_INFO("pointer of video src is null");
3190         }
3191
3192         return FALSE;
3193 }
3194
3195
3196 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3197 {
3198         GstCameraControl *control = NULL;
3199         int ivalue = 0;
3200         int mslVal1 = 0;
3201         int mslVal2 = 0;
3202         int newVal1 = 0;
3203         int newVal2 = 0;
3204         int exposure_type = 0;
3205         int current_state = MM_CAMCORDER_STATE_NONE;
3206         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3207         _MMCamcorderSubContext *sc = NULL;
3208
3209         int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3210         gboolean check_scene_mode = FALSE;
3211
3212         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3213
3214         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3215         if (!sc)
3216                 return TRUE;
3217
3218         /* check whether set or not */
3219         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3220                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3221                 return TRUE;
3222         }
3223
3224         current_state = _mmcamcorder_get_state(handle);
3225         if (current_state < MM_CAMCORDER_STATE_READY) {
3226                 MMCAM_LOG_INFO("will be applied when preview starts");
3227                 return TRUE;
3228         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3229                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3230                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3231                 return FALSE;
3232         }
3233
3234         ivalue = value->value.i_val;
3235
3236         if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3237                 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3238                 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3239                 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3240         } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3241                 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3242                 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3243                 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3244         } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3245                 exposure_type = GST_CAMERA_CONTROL_ISO;
3246                 mslVal1 = ivalue;
3247                 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3248                 check_scene_mode = TRUE;
3249         } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3250                 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3251                 mslVal1 = ivalue;
3252                 newVal1 =  _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3253                 check_scene_mode = TRUE;
3254         } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3255                 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3256                 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3257                 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3258         }
3259
3260         if (check_scene_mode) {
3261                 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3262                 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3263                         MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3264                         return FALSE;
3265                 }
3266         }
3267
3268         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3269                 int ret = 0;
3270
3271                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3272                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3273                         return TRUE;
3274                 }
3275
3276                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3277                 if (control == NULL) {
3278                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3279                         return FALSE;
3280                 }
3281
3282                 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3283                 if (ret) {
3284                         MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3285                         return TRUE;
3286                 } else {
3287                         MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3288                 }
3289         } else {
3290                 MMCAM_LOG_INFO("pointer of video src is null");
3291         }
3292
3293         return FALSE;
3294 }
3295
3296
3297 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3298 {
3299         GstCameraControl *control = NULL;
3300         int mslVal = 0;
3301         int newVal = 0;
3302         int cur_value = 0;
3303         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3304         _MMCamcorderSubContext *sc = NULL;
3305         int current_state = MM_CAMCORDER_STATE_NONE;
3306
3307         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3308
3309         /* check whether set or not */
3310         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3311                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3312                 return TRUE;
3313         }
3314
3315         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3316         if (!sc)
3317                 return TRUE;
3318
3319         /* check current state */
3320         current_state = _mmcamcorder_get_state(handle);
3321         if (current_state < MM_CAMCORDER_STATE_READY) {
3322                 MMCAM_LOG_INFO("will be applied when preview starts");
3323                 return TRUE;
3324         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3325                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3326                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3327                 return FALSE;
3328         }
3329
3330         mslVal = value->value.i_val;
3331         newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3332
3333         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3334                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3335                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3336                         return TRUE;
3337                 }
3338
3339                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3340                 if (control == NULL) {
3341                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3342                         return FALSE;
3343                 }
3344
3345                 if (gst_camera_control_get_wdr(control, &cur_value)) {
3346                         if (newVal != cur_value) {
3347                                 if (gst_camera_control_set_wdr(control, newVal)) {
3348                                         MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3349                                         return TRUE;
3350                                 } else {
3351                                         MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3352                                 }
3353                         } else {
3354                                 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3355                                 return TRUE;
3356                         }
3357                 } else {
3358                         MMCAM_LOG_WARNING("Failed to get WDR.");
3359                 }
3360         } else {
3361                 MMCAM_LOG_INFO("pointer of video src is null");
3362         }
3363
3364         return FALSE;
3365 }
3366
3367
3368 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3369 {
3370         int current_state = MM_CAMCORDER_STATE_NONE;
3371         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3372
3373         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3374
3375         /* check whether set or not */
3376         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3377                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3378                 return TRUE;
3379         }
3380
3381         current_state = _mmcamcorder_get_state(handle);
3382         if (current_state < MM_CAMCORDER_STATE_READY) {
3383                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3384                 return TRUE;
3385         } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3386                 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3387                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3388                 return FALSE;
3389         }
3390
3391         return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3392 }
3393
3394
3395 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3396 {
3397         int audio_enc = 0;
3398         int bitrate = 0;
3399         int current_state = MM_CAMCORDER_STATE_NONE;
3400         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3401         _MMCamcorderSubContext *sc = NULL;
3402
3403         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3404
3405         bitrate = value->value.i_val;
3406
3407         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3408         if (!sc || !sc->encode_element) {
3409                 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3410                 return TRUE;
3411         }
3412
3413         current_state = _mmcamcorder_get_state(handle);
3414         if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3415                 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3416                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3417                 return FALSE;
3418         }
3419
3420         if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3421                 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3422
3423                 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3424                         bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3425         } else {
3426                 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3427                         bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3428         }
3429
3430         return TRUE;
3431 }
3432
3433
3434 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3435 {
3436         int current_state = MM_CAMCORDER_STATE_NONE;
3437         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3438
3439         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3440
3441         current_state = _mmcamcorder_get_state(handle);
3442         if (current_state < MM_CAMCORDER_STATE_READY) {
3443                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3444                 return TRUE;
3445         } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3446                 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3447                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3448                 return FALSE;
3449         }
3450
3451         return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3452 }
3453
3454
3455 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3456 {
3457         int current_state = MM_CAMCORDER_STATE_NONE;
3458         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3459
3460         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3461
3462         MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3463
3464         current_state = _mmcamcorder_get_state(handle);
3465
3466         if (current_state > MM_CAMCORDER_STATE_READY) {
3467                 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3468                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3469                 return FALSE;
3470         } else {
3471                 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3472         }
3473 }
3474
3475
3476 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3477 {
3478         int current_state = MM_CAMCORDER_STATE_NONE;
3479
3480         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3481         _MMCamcorderSubContext *sc = NULL;
3482
3483         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3484
3485         /* check type */
3486         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3487                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3488                 return FALSE;
3489         }
3490
3491         /* check current state */
3492         current_state = _mmcamcorder_get_state(handle);
3493         if (current_state < MM_CAMCORDER_STATE_READY) {
3494                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3495                 return TRUE;
3496         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3497                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3498                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3499                 return FALSE;
3500         }
3501
3502         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3503
3504         MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3505
3506         if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3507                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3508                 return TRUE;
3509         } else {
3510                 MMCAM_LOG_ERROR("invalid state %d", current_state);
3511                 return FALSE;
3512         }
3513 }
3514
3515
3516 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3517 {
3518         mmf_return_val_if_fail(handle && value, FALSE);
3519
3520         /* get string */
3521         if (!value->value.s_val) {
3522                 MMCAM_LOG_ERROR("NULL filename");
3523                 return FALSE;
3524         }
3525
3526         MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3527
3528         return TRUE;
3529 }
3530
3531
3532 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3533 {
3534         int current_state = MM_CAMCORDER_STATE_NONE;
3535         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3536
3537         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3538
3539         current_state = _mmcamcorder_get_state(handle);
3540         if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3541                 MMCAM_LOG_ERROR("Can not set while RECORDING");
3542                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3543                 return FALSE;
3544         }
3545
3546         return TRUE;
3547 }
3548
3549
3550 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3551 {
3552         GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3553         MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3554         return strcmp(Colorchannel->label, user_data);
3555 }
3556
3557 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3558 {
3559         GstColorBalance *balance = NULL;
3560         GstColorBalanceChannel *Colorchannel = NULL;
3561         GList *controls = NULL;
3562         GList *item = NULL;
3563         int newVal = 0;
3564         int mslVal = 0;
3565         int current_state = MM_CAMCORDER_STATE_NONE;
3566         const char *control_label = NULL;
3567         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3568         _MMCamcorderSubContext *sc = NULL;
3569
3570         int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3571         gboolean check_scene_mode = FALSE;
3572
3573         int wb_temp_table[] = {
3574                 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3575                 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3576                 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3577                 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3578                 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3579                 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3580         };
3581
3582         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3583
3584         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3585         if (!sc)
3586                 return TRUE;
3587
3588         /* check whether set or not */
3589         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3590                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3591                 return TRUE;
3592         }
3593
3594         current_state = _mmcamcorder_get_state(handle);
3595         if (current_state < MM_CAMCORDER_STATE_READY) {
3596                 MMCAM_LOG_INFO("will be applied when preview starts");
3597                 return TRUE;
3598         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3599                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3600                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3601                 return FALSE;
3602         }
3603
3604         if (value->type != MM_ATTRS_TYPE_INT) {
3605                 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3606                 return FALSE;
3607         }
3608
3609         mslVal = value->value.i_val;
3610
3611         switch (attr_idx) {
3612         case MM_CAM_FILTER_BRIGHTNESS:
3613                 control_label = "brightness";
3614                 check_scene_mode = TRUE;
3615                 break;
3616         case MM_CAM_FILTER_CONTRAST:
3617                 control_label = "contrast";
3618                 break;
3619         case MM_CAM_FILTER_WB:
3620                 control_label = "white balance";
3621                 check_scene_mode = TRUE;
3622                 break;
3623         case MM_CAM_FILTER_COLOR_TONE:
3624                 control_label = "color tone";
3625                 break;
3626         case MM_CAM_FILTER_SATURATION:
3627                 control_label = "saturation";
3628                 check_scene_mode = TRUE;
3629                 break;
3630         case MM_CAM_FILTER_HUE:
3631                 control_label = "hue";
3632                 break;
3633         case MM_CAM_FILTER_SHARPNESS:
3634                 control_label = "sharpness";
3635                 check_scene_mode = TRUE;
3636                 break;
3637         default:
3638                 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3639                 return FALSE;
3640         }
3641
3642         if (check_scene_mode) {
3643                 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3644                 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3645                         MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3646                         return FALSE;
3647                 }
3648         }
3649
3650         newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3651         if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3652                 return FALSE;
3653
3654         if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3655                 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3656                 return TRUE;
3657         }
3658
3659         balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3660         if (balance == NULL) {
3661                 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3662                 return FALSE;
3663         }
3664
3665         controls = (GList *)gst_color_balance_list_channels(balance);
3666         if (controls == NULL) {
3667                 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3668                 return FALSE;
3669         }
3670
3671 _CHECK_AGAIN:
3672         MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3673                 attr_idx, control_label, mslVal, newVal);
3674
3675         item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3676         if (item) {
3677                 Colorchannel = item->data;
3678                 gst_color_balance_set_value(balance, Colorchannel, newVal);
3679                 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3680                 return TRUE;
3681         }
3682
3683         if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3684                 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3685                         newVal = 1;
3686                         control_label = "white_balance_temperature_auto";
3687                         goto _CHECK_AGAIN;
3688                 } else {
3689                         newVal = wb_temp_table[mslVal];
3690                         control_label = "white_balance_temperature";
3691                         goto _CHECK_AGAIN;
3692                 }
3693         }
3694
3695         MMCAM_LOG_ERROR("failed to find color channel item");
3696
3697         return FALSE;
3698 }
3699
3700
3701 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3702 {
3703         int mslVal = 0;
3704         int newVal = 0;
3705         int current_state = MM_CAMCORDER_STATE_NONE;
3706         GstCameraControl *control = NULL;
3707         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3708         _MMCamcorderSubContext *sc = NULL;
3709
3710         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3711
3712         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3713         if (!sc)
3714                 return TRUE;
3715
3716         mslVal = value->value.i_val;
3717         newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3718
3719         /* check whether set or not */
3720         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3721                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3722                 return TRUE;
3723         }
3724
3725         current_state = _mmcamcorder_get_state(handle);
3726         if (current_state < MM_CAMCORDER_STATE_READY) {
3727                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3728                 return TRUE;
3729         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3730                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3731                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3732                 return FALSE;
3733         }
3734
3735         if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3736                 int ret = 0;
3737
3738                 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3739                         MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3740                         return TRUE;
3741                 }
3742
3743                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3744                 if (control == NULL) {
3745                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3746                         return FALSE;
3747                 }
3748
3749                 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3750                 if (ret) {
3751                         MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3752
3753                         if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3754                                 unsigned int i = 0;
3755                                 int attr_idxs[] = {
3756                                         MM_CAM_CAMERA_ISO,
3757                                         MM_CAM_FILTER_BRIGHTNESS,
3758                                         MM_CAM_FILTER_WB,
3759                                         MM_CAM_FILTER_SATURATION,
3760                                         MM_CAM_FILTER_SHARPNESS,
3761                                         MM_CAM_FILTER_COLOR_TONE,
3762                                         MM_CAM_CAMERA_EXPOSURE_MODE
3763                                 };
3764                                 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3765
3766                                 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3767                                         if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3768                                                 mm_attrs_set_modified(attrs, attr_idxs[i]);
3769                                 }
3770                         }
3771
3772                         return TRUE;
3773                 } else {
3774                         MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3775                 }
3776         } else {
3777                 MMCAM_LOG_WARNING("pointer of video src is null");
3778         }
3779
3780         return FALSE;
3781 }
3782
3783
3784 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3785 {
3786         mmf_return_val_if_fail(handle && value, FALSE);
3787
3788         MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3789
3790         return TRUE;
3791 }
3792
3793
3794 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3795 {
3796         mmf_return_val_if_fail(handle && value, FALSE);
3797
3798         MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3799
3800         return TRUE;
3801 }
3802
3803
3804 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3805 {
3806         int current_state = MM_CAMCORDER_STATE_NONE;
3807         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3808
3809         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3810
3811         current_state = _mmcamcorder_get_state(handle);
3812         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3813                 MMCAM_LOG_WARNING("Can NOT Disable AUDIO. invalid state %d", current_state);
3814                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3815                 return FALSE;
3816         } else {
3817                 MMCAM_LOG_INFO("Disable AUDIO when Recording");
3818                 return TRUE;
3819         }
3820 }
3821
3822
3823 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3824 {
3825         int current_state = MM_CAMCORDER_STATE_NONE;
3826         const char *videosink_name = NULL;
3827         void *dp_handle = NULL;
3828         MMCamWindowInfo *window_info = NULL;
3829
3830         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3831         _MMCamcorderSubContext *sc = NULL;
3832
3833         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3834
3835         /* check type */
3836         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3837                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3838                 return FALSE;
3839         }
3840
3841         /* check current state */
3842         current_state = _mmcamcorder_get_state(handle);
3843         if (current_state < MM_CAMCORDER_STATE_READY) {
3844                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3845                 return TRUE;
3846         }
3847
3848         dp_handle = value->value.p_val;
3849         if (!dp_handle) {
3850                 MMCAM_LOG_WARNING("Display handle is NULL");
3851                 return FALSE;
3852         }
3853
3854         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3855
3856         /* get videosink name */
3857         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3858         if (!videosink_name) {
3859                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3860                 return FALSE;
3861         }
3862
3863         MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3864
3865         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3866                 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
3867                 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
3868         } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3869                 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
3870                 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
3871         } else if (!strcmp(videosink_name, "tizenwlsink")) {
3872                 window_info = (MMCamWindowInfo *)dp_handle;
3873                 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
3874                 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3875         } else if (!strcmp(videosink_name, "directvideosink")) {
3876                 window_info = (MMCamWindowInfo *)dp_handle;
3877                 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
3878                         window_info->surface_id,
3879                         window_info->rect.x,
3880                         window_info->rect.y,
3881                         window_info->rect.width,
3882                         window_info->rect.height);
3883                 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3884                 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3885                         window_info->rect.x,
3886                         window_info->rect.y,
3887                         window_info->rect.width,
3888                         window_info->rect.height);
3889         } else {
3890                 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
3891                 return FALSE;
3892         }
3893
3894         return TRUE;
3895 }
3896
3897
3898 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3899 {
3900         int current_state = MM_CAMCORDER_STATE_NONE;
3901         const char *videosink_name = NULL;
3902
3903         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3904         _MMCamcorderSubContext *sc = NULL;
3905
3906         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3907
3908         /* check type */
3909         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3910                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3911                 return FALSE;
3912         }
3913
3914         /* check current state */
3915         current_state = _mmcamcorder_get_state(handle);
3916         if (current_state < MM_CAMCORDER_STATE_READY) {
3917                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3918                 return TRUE;
3919         }
3920
3921         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3922
3923         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3924         if (videosink_name == NULL) {
3925                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3926                 return FALSE;
3927         }
3928
3929         MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3930
3931         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3932                 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
3933                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3934         } else {
3935                 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
3936         }
3937
3938         return TRUE;
3939 }
3940
3941
3942 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3943 {
3944         int current_state = MM_CAMCORDER_STATE_NONE;
3945
3946         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3947
3948         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3949
3950         /* check type */
3951         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3952                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3953                 return FALSE;
3954         }
3955
3956         /* check current state */
3957         current_state = _mmcamcorder_get_state(handle);
3958         if (current_state < MM_CAMCORDER_STATE_READY) {
3959                 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3960                 return TRUE;
3961         }
3962
3963         return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3964 }
3965
3966
3967 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3968 {
3969         int current_state = MM_CAMCORDER_STATE_NONE;
3970
3971         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3972
3973         mmf_return_val_if_fail(hcamcorder && value, FALSE);
3974
3975         /* check type */
3976         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3977                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3978                 return FALSE;
3979         }
3980
3981         /* check current state */
3982         current_state = _mmcamcorder_get_state(handle);
3983         if (current_state < MM_CAMCORDER_STATE_READY) {
3984                 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3985                 return TRUE;
3986         }
3987
3988         return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3989 }
3990
3991
3992 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3993 {
3994         int current_state = MM_CAMCORDER_STATE_NONE;
3995         const char *videosink_name = NULL;
3996
3997         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3998         _MMCamcorderSubContext *sc = NULL;
3999
4000         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4001
4002         /* check type */
4003         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4004                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4005                 return FALSE;
4006         }
4007
4008         /* check current state */
4009         current_state = _mmcamcorder_get_state(handle);
4010         if (current_state < MM_CAMCORDER_STATE_READY) {
4011                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4012                 return TRUE;
4013         }
4014
4015         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4016
4017         /* Get videosink name */
4018         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4019         if (videosink_name == NULL) {
4020                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4021                 return FALSE;
4022         }
4023
4024         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4025                 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4026                 !strcmp(videosink_name, "directvideosink")) {
4027                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4028                 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4029         } else {
4030                 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4031         }
4032
4033         return TRUE;
4034 }
4035
4036
4037 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4038 {
4039         int method = 0;
4040         int current_state = MM_CAMCORDER_STATE_NONE;
4041         const char *videosink_name = NULL;
4042
4043         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4044         _MMCamcorderSubContext *sc = NULL;
4045
4046         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4047
4048         /* check type */
4049         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4050                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4051                 return FALSE;
4052         }
4053
4054         /* check current state */
4055         current_state = _mmcamcorder_get_state(handle);
4056         if (current_state < MM_CAMCORDER_STATE_READY) {
4057                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4058                 return TRUE;
4059         }
4060
4061         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4062
4063         /* Get videosink name */
4064         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4065         if (videosink_name == NULL) {
4066                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4067                 return FALSE;
4068         }
4069
4070         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4071             !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4072             !strcmp(videosink_name, "directvideosink")) {
4073                 method = value->value.i_val;
4074                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4075         } else {
4076                 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4077         }
4078
4079         return TRUE;
4080 }
4081
4082
4083 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4084 {
4085         int current_state = MM_CAMCORDER_STATE_NONE;
4086         int ret = MM_ERROR_NONE;
4087         const char *videosink_name = NULL;
4088
4089         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4090         _MMCamcorderSubContext *sc = NULL;
4091
4092         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4093
4094         /* check type */
4095         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4096                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4097                 return FALSE;
4098         }
4099
4100         /* check current state */
4101         current_state = _mmcamcorder_get_state(handle);
4102         if (current_state < MM_CAMCORDER_STATE_READY) {
4103                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4104                 return TRUE;
4105         }
4106
4107         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4108
4109         /* Get videosink name */
4110         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4111         if (videosink_name == NULL) {
4112                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4113                 return FALSE;
4114         }
4115
4116         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4117             !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4118                 int rect_x = 0;
4119                 int rect_y = 0;
4120                 int rect_width = 0;
4121                 int rect_height = 0;
4122                 int flags = MM_ATTRS_FLAG_NONE;
4123                 MMCamAttrsInfo info;
4124
4125                 mm_camcorder_get_attributes(handle, NULL,
4126                         MMCAM_DISPLAY_RECT_X, &rect_x,
4127                         MMCAM_DISPLAY_RECT_Y, &rect_y,
4128                         MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4129                         MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4130                         NULL);
4131                 switch (attr_idx) {
4132                 case MM_CAM_DISPLAY_RECT_X:
4133                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4134                         flags |= info.flag;
4135                         memset(&info, 0x00, sizeof(info));
4136                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4137                         flags |= info.flag;
4138                         memset(&info, 0x00, sizeof(info));
4139                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4140                         flags |= info.flag;
4141
4142                         rect_x = value->value.i_val;
4143                         break;
4144                 case MM_CAM_DISPLAY_RECT_Y:
4145                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4146                         flags |= info.flag;
4147                         memset(&info, 0x00, sizeof(info));
4148                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4149                         flags |= info.flag;
4150
4151                         rect_y = value->value.i_val;
4152                         break;
4153                 case MM_CAM_DISPLAY_RECT_WIDTH:
4154                         mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4155                         flags |= info.flag;
4156
4157                         rect_width = value->value.i_val;
4158                         break;
4159                 case MM_CAM_DISPLAY_RECT_HEIGHT:
4160                         rect_height = value->value.i_val;
4161                         break;
4162                 default:
4163                         MMCAM_LOG_ERROR("Wrong attr_idx!");
4164                         return FALSE;
4165                 }
4166
4167                 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4168                         MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4169
4170                         if (!strcmp(videosink_name, "tizenwlsink")) {
4171                             ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4172                                         rect_x, rect_y, rect_width, rect_height);
4173                                 if (!ret) {
4174                                         MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4175                                         return FALSE;
4176                                 }
4177                         } else {
4178                             g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4179                                         "dst-roi-x", rect_x,
4180                                         "dst-roi-y", rect_y,
4181                                         "dst-roi-w", rect_width,
4182                                         "dst-roi-h", rect_height,
4183                                         NULL);
4184                         }
4185                 }
4186         } else {
4187                 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4188         }
4189
4190         return TRUE;
4191 }
4192
4193
4194 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4195 {
4196         int zoom = 0;
4197         int current_state = MM_CAMCORDER_STATE_NONE;
4198         const char *videosink_name = NULL;
4199         GstElement *vs_element = NULL;
4200
4201         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4202         _MMCamcorderSubContext *sc = NULL;
4203
4204         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4205
4206         /* check type */
4207         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4208                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4209                 return FALSE;
4210         }
4211
4212         /* check current state */
4213         current_state = _mmcamcorder_get_state(handle);
4214         if (current_state < MM_CAMCORDER_STATE_READY) {
4215                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4216                 return TRUE;
4217         }
4218
4219         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4220
4221         /* Get videosink name */
4222         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4223         if (videosink_name == NULL) {
4224                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4225                 return FALSE;
4226         }
4227
4228         zoom = value->value.i_val;
4229         if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4230                 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4231
4232                 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4233                 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4234
4235                 return TRUE;
4236         } else {
4237                 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4238                 return FALSE;
4239         }
4240 }
4241
4242
4243 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4244 {
4245         int current_state = MM_CAMCORDER_STATE_NONE;
4246         int do_scaling = 0;
4247         const char *videosink_name = NULL;
4248
4249         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4250         _MMCamcorderSubContext *sc = NULL;
4251
4252         mmf_return_val_if_fail(handle && value, FALSE);
4253
4254         /* check type */
4255         if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4256                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4257                 return FALSE;
4258         }
4259
4260         /* check current state */
4261         current_state = _mmcamcorder_get_state(handle);
4262         if (current_state < MM_CAMCORDER_STATE_READY) {
4263                 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4264                 return TRUE;
4265         }
4266
4267         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4268
4269         do_scaling = value->value.i_val;
4270
4271         /* Get videosink name */
4272         _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4273         if (videosink_name == NULL) {
4274                 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4275                 return FALSE;
4276         }
4277
4278         if (!strcmp(videosink_name, "evaspixmapsink")) {
4279                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4280                 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4281                 return TRUE;
4282         } else {
4283                 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4284                 return FALSE;
4285         }
4286 }
4287
4288
4289 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4290 {
4291         _MMCamcorderSubContext *sc = NULL;
4292         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4293         int strobe_type, mslVal, newVal, cur_value;
4294         int current_state = MM_CAMCORDER_STATE_NONE;
4295
4296         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4297
4298         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4299         if (!sc)
4300                 return TRUE;
4301
4302         /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4303
4304         mslVal = value->value.i_val;
4305
4306         /* check flash state */
4307         if (attr_idx == MM_CAM_STROBE_MODE) {
4308                 int led_brightness = 0;
4309
4310                 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4311                         MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4312                         hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4313                         return FALSE;
4314                 }
4315
4316                 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4317
4318                 if (led_brightness > 0 &&
4319                     mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4320                         /* other module already turned on LED */
4321                         hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4322                         MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4323                         return FALSE;
4324                 }
4325
4326                 MMCAM_LOG_INFO("keep going");
4327         }
4328
4329         /* check state */
4330         current_state = _mmcamcorder_get_state(handle);
4331         if (current_state < MM_CAMCORDER_STATE_READY) {
4332                 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4333                 return TRUE;
4334         } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4335                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4336                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4337                 return FALSE;
4338         }
4339
4340         switch (attr_idx) {
4341         case MM_CAM_STROBE_CONTROL:
4342                 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4343                 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4344                 break;
4345         case MM_CAM_STROBE_CAPABILITIES:
4346                 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4347                 newVal = mslVal;
4348                 break;
4349         case MM_CAM_STROBE_MODE:
4350                 /* check whether set or not */
4351                 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4352                         MMCAM_LOG_INFO("skip set value %d", mslVal);
4353                         return TRUE;
4354                 }
4355
4356                 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4357                 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4358                 break;
4359         case MM_CAM_STROBE_BRIGHTNESS:
4360                 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4361                 newVal = mslVal;
4362                 break;
4363         default:
4364                 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4365                 return FALSE;
4366         }
4367
4368         GstCameraControl *control = NULL;
4369         if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4370                 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4371                 return FALSE;
4372         }
4373
4374         control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4375         if (control == NULL) {
4376                 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4377                 return FALSE;
4378         }
4379
4380         if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4381                 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4382                 return FALSE;
4383         }
4384
4385         if (newVal == cur_value) {
4386                 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4387                 return TRUE;
4388         }
4389
4390         if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4391                 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4392                 return FALSE;
4393         }
4394
4395         MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4396
4397         return TRUE;
4398 }
4399
4400
4401 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4402 {
4403         int ret = 0;
4404         int current_state = MM_CAMCORDER_STATE_NONE;
4405         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4406
4407         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4408
4409         MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4410
4411         /* state check */
4412         current_state = _mmcamcorder_get_state(handle);
4413         if (current_state > MM_CAMCORDER_STATE_READY) {
4414                 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4415                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4416                 return FALSE;
4417         } else if (current_state < MM_CAMCORDER_STATE_READY) {
4418                 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4419                 return TRUE;
4420         }
4421
4422         ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4423
4424         MMCAM_LOG_INFO("ret %d", ret);
4425
4426         return ret;
4427 }
4428
4429
4430 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4431 {
4432         int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4433         int current_state = MM_CAMCORDER_STATE_NONE;
4434         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4435         _MMCamcorderSubContext *sc = NULL;
4436
4437         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4438
4439         /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4440
4441         /* check whether set or not */
4442         if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4443                 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4444                 return TRUE;
4445         }
4446
4447         /* state check */
4448         current_state = _mmcamcorder_get_state(handle);
4449         if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4450                 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4451                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4452                 return FALSE;
4453         }
4454
4455         if (current_state >= MM_CAMCORDER_STATE_READY) {
4456                 int current_value = 0;
4457
4458                 set_hdr_mode = value->value.i_val;
4459                 mm_camcorder_get_attributes(handle, NULL,
4460                         MMCAM_CAMERA_HDR_CAPTURE, &current_value,
4461                         NULL);
4462
4463                 if (set_hdr_mode == current_value) {
4464                         MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4465                         return TRUE;
4466                 }
4467
4468                 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4469                 if (sc) {
4470                         if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4471                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4472                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4473
4474                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4475
4476                                 /* check decoder recreation */
4477                                 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4478                                         MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4479                                         return FALSE;
4480                                 }
4481
4482                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4483                                 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4484                         }
4485
4486                         set_hdr_mode = value->value.i_val;
4487                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4488                         sc->info_image->hdr_capture_mode = set_hdr_mode;
4489                         MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4490
4491                         if (current_state == MM_CAMCORDER_STATE_PREPARE)
4492                                 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4493                 } else {
4494                         MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4495                         return FALSE;
4496                 }
4497         }
4498
4499         return TRUE;
4500 }
4501
4502
4503 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4504 {
4505         bool bret = FALSE;
4506         _MMCamcorderSubContext *sc = NULL;
4507         int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4508         int set_value = 0;
4509         int current_value = 0;
4510         int current_state = MM_CAMCORDER_STATE_NONE;
4511         GstCameraControl *control = NULL;
4512
4513         mmf_return_val_if_fail(handle && value, FALSE);
4514
4515         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4516         if (!sc)
4517                 return TRUE;
4518
4519         /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4520
4521         /* state check */
4522         current_state = _mmcamcorder_get_state(handle);
4523         if (current_state < MM_CAMCORDER_STATE_READY) {
4524                 MMCAM_LOG_INFO("will be applied when preview starts");
4525                 return TRUE;
4526         }
4527
4528         set_value = value->value.i_val;
4529
4530         switch (attr_idx) {
4531         case MM_CAM_DETECT_MODE:
4532                 /* check whether set or not */
4533                 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4534                         MMCAM_LOG_INFO("skip set value %d", set_value);
4535                         return TRUE;
4536                 }
4537
4538                 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4539                 break;
4540         case MM_CAM_DETECT_NUMBER:
4541                 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4542                 break;
4543         case MM_CAM_DETECT_FOCUS_SELECT:
4544                 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4545                 break;
4546         case MM_CAM_DETECT_SELECT_NUMBER:
4547                 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4548                 break;
4549         case MM_CAM_DETECT_STATUS:
4550                 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4551                 break;
4552         default:
4553                 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4554                 return FALSE;
4555         }
4556
4557         if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4558                 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4559                 bret = FALSE;
4560         } else {
4561                 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4562                 if (control == NULL) {
4563                         MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4564                         return FALSE;
4565                 }
4566
4567                 if (gst_camera_control_get_detect(control, detect_type, &current_value)) {
4568                         if (current_value == set_value) {
4569                                 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4570                                 bret = TRUE;
4571                         } else {
4572                                 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4573                                         MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4574                                                 detect_type, set_value);
4575                                         bret = FALSE;
4576                                 } else {
4577                                         MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4578                                                 detect_type, set_value);
4579                                         bret = TRUE;
4580                                 }
4581                         }
4582                 } else {
4583                         MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4584                         bret = FALSE;
4585                 }
4586         }
4587
4588         return bret;
4589 }
4590
4591
4592 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4593 {
4594         int current_state = MM_CAMCORDER_STATE_NONE;
4595         int preview_format = MM_PIXEL_FORMAT_NV12;
4596
4597         mmf_return_val_if_fail(handle && value, FALSE);
4598
4599         MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4600
4601         /* check preview format */
4602         mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4603         if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4604                 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4605                 return FALSE;
4606         }
4607
4608         /* check state */
4609         current_state = _mmcamcorder_get_state(handle);
4610         if (current_state < MM_CAMCORDER_STATE_READY) {
4611                 MMCAM_LOG_INFO("will be applied when preview starts");
4612                 return TRUE;
4613         }
4614
4615         return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4616 }
4617
4618
4619 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4620 {
4621         int current_state = MM_CAMCORDER_STATE_NONE;
4622         int preview_format = MM_PIXEL_FORMAT_NV12;
4623
4624         mmf_return_val_if_fail(handle && value, FALSE);
4625
4626         MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4627
4628         /* check preview format */
4629         mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4630         if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4631                 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4632                 return FALSE;
4633         }
4634
4635         /* check state */
4636         current_state = _mmcamcorder_get_state(handle);
4637         if (current_state < MM_CAMCORDER_STATE_READY) {
4638                 MMCAM_LOG_INFO("will be applied when preview starts");
4639                 return TRUE;
4640         }
4641
4642         return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4643 }
4644
4645
4646 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4647 {
4648         int stream_index = 0;
4649         char *stream_type = NULL;
4650         _MMCamcorderSubContext *sc = NULL;
4651
4652         mmf_return_val_if_fail(handle && value, FALSE);
4653
4654         stream_type = value->value.s_val;
4655         if (!stream_type) {
4656                 MMCAM_LOG_ERROR("NULL string");
4657                 return FALSE;
4658         }
4659
4660         mm_camcorder_get_attributes(handle, NULL,
4661                 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4662                 NULL);
4663         if (stream_index < 0) {
4664                 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4665                 return FALSE;
4666         }
4667
4668         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4669         if (!sc || !sc->encode_element ||
4670             !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4671                 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4672                 return TRUE;
4673         }
4674
4675         MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4676
4677         return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4678 }
4679
4680
4681 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4682 {
4683         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4684         int current_state = MM_CAMCORDER_STATE_NONE;
4685
4686         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4687
4688         current_state = _mmcamcorder_get_state(handle);
4689         if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4690                 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4691                 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4692                 return FALSE;
4693         }
4694
4695         return TRUE;
4696 }
4697
4698 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4699 {
4700         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4701
4702         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4703
4704         if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4705                 /* Replay gain enable */
4706                 int current_state = MM_CAMCORDER_STATE_NONE;
4707                 int audio_disable = FALSE;
4708
4709                 current_state = _mmcamcorder_get_state(handle);
4710                 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4711                         MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4712                         hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4713                         return FALSE;
4714                 }
4715
4716                 mm_camcorder_get_attributes(handle, NULL,
4717                         MMCAM_AUDIO_DISABLE, &audio_disable,
4718                         NULL);
4719
4720                 if (audio_disable) {
4721                         MMCAM_LOG_ERROR("audio is disabled");
4722                         hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4723                         return FALSE;
4724                 }
4725
4726                 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4727         } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4728                 /* Replay gain reference level */
4729                 int replay_gain_enable = FALSE;
4730
4731                 mm_camcorder_get_attributes(handle, NULL,
4732                         MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4733                         NULL);
4734
4735                 if (replay_gain_enable == FALSE) {
4736                         MMCAM_LOG_ERROR("replay gain is disabled");
4737                         hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4738                         return FALSE;
4739                 }
4740
4741                 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4742         } else {
4743                 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4744                 return FALSE;
4745         }
4746
4747         return TRUE;
4748 }
4749
4750
4751 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4752 {
4753         int current_state = MM_CAMCORDER_STATE_NONE;
4754         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4755         _MMCamcorderSubContext *sc = NULL;
4756
4757         mmf_return_val_if_fail(hcamcorder && value, FALSE);
4758
4759         if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4760                 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4761                 return FALSE;
4762         }
4763
4764         MMCAM_LOG_INFO("Enable extra preview(%d)", value->value.i_val);
4765
4766         current_state = _mmcamcorder_get_state(handle);
4767         if (current_state < MM_CAMCORDER_STATE_READY) {
4768                 MMCAM_LOG_INFO("will be set when preview is started");
4769                 return TRUE;
4770         }
4771
4772         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4773         mmf_return_val_if_fail(sc, FALSE);
4774
4775         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", value->value.i_val);
4776
4777         return TRUE;
4778 }
4779
4780
4781 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4782 {
4783         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4784         MMHandleType attrs;
4785
4786         int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4787
4788         unsigned int i = 0;
4789         int ret = TRUE;
4790         int attr_idxs_default[] = {
4791                 MM_CAM_CAMERA_DIGITAL_ZOOM,
4792                 MM_CAM_CAMERA_OPTICAL_ZOOM,
4793                 MM_CAM_CAMERA_WDR,
4794                 MM_CAM_FILTER_CONTRAST,
4795                 MM_CAM_FILTER_HUE,
4796                 MM_CAM_DETECT_MODE,
4797                 MM_CAM_STROBE_BRIGHTNESS
4798         };
4799
4800         int attr_idxs_extra[] = {
4801                 MM_CAM_CAMERA_ISO,
4802                 MM_CAM_FILTER_BRIGHTNESS,
4803                 MM_CAM_FILTER_WB,
4804                 MM_CAM_FILTER_SATURATION,
4805                 MM_CAM_FILTER_SHARPNESS,
4806                 MM_CAM_FILTER_COLOR_TONE,
4807                 MM_CAM_CAMERA_EXPOSURE_MODE
4808         };
4809
4810         mmf_return_val_if_fail(hcamcorder, FALSE);
4811
4812         MMCAM_LOG_INFO("commit some attributes again");
4813
4814         attrs = MMF_CAMCORDER_ATTRS(handle);
4815         if (attrs == NULL) {
4816                 MMCAM_LOG_ERROR("Get attribute handle failed.");
4817                 return FALSE;
4818         }
4819
4820         /* Get Scene mode */
4821         mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4822
4823         for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4824                 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4825                         mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4826         }
4827
4828         /* Set extra if scene mode is NORMAL */
4829         if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4830                 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4831                         if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4832                                 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4833                 }
4834         } else {
4835                 /* Set scene mode if scene mode is NOT NORMAL */
4836                 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4837                         mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
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 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4852 {
4853         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4854         MMHandleType attrs;
4855         unsigned int i = 0;
4856         int ret = TRUE;
4857         int attr_idxs[] = {
4858                 MM_CAM_STROBE_MODE,
4859                 MM_CAM_CAMERA_PTZ_TYPE,
4860                 MM_CAM_CAMERA_PAN_MECHA,
4861                 MM_CAM_CAMERA_PAN_ELEC,
4862                 MM_CAM_CAMERA_TILT_MECHA,
4863                 MM_CAM_CAMERA_TILT_ELEC
4864         };
4865
4866         mmf_return_val_if_fail(hcamcorder, FALSE);
4867
4868         MMCAM_LOG_INFO("commit some attribute again[2]");
4869
4870         attrs = MMF_CAMCORDER_ATTRS(handle);
4871         if (attrs == NULL) {
4872                 MMCAM_LOG_ERROR("Get attribute handle failed.");
4873                 return FALSE;
4874         }
4875
4876         for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4877                 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4878                         mm_attrs_set_modified(attrs, attr_idxs[i]);
4879         }
4880
4881         if (mm_attrs_commit_all(attrs) == -1)
4882                 ret = FALSE;
4883         else
4884                 ret = TRUE;
4885
4886         MMCAM_LOG_INFO("Done.");
4887
4888         return ret;
4889 }
4890
4891
4892 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4893 {
4894         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4895         MMHandleType attrs;
4896         int table_size = 0;
4897         int i = 0;
4898         int nerror = MM_ERROR_NONE;
4899
4900         mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4901
4902         attrs = MMF_CAMCORDER_ATTRS(handle);
4903         mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4904
4905         MMCAM_LOG_INFO("");
4906
4907         table_size = ARRAY_SIZE(readonly_attributes);
4908         MMCAM_LOG_INFO("%d", table_size);
4909         for (i = 0; i < table_size; i++) {
4910                 int sCategory = readonly_attributes[i];
4911
4912                 mm_attrs_set_readonly(attrs, sCategory);
4913         }
4914
4915         return nerror;
4916 }
4917
4918
4919 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4920 {
4921         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4922         MMHandleType attrs;
4923         int i = 0;
4924         type_string_array * disabled_attr = NULL;
4925         int cnt_str = 0;
4926         int nerror = MM_ERROR_NONE ;
4927
4928         mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4929
4930         attrs = MMF_CAMCORDER_ATTRS(handle);
4931         mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4932
4933         MMCAM_LOG_INFO("");
4934
4935         /* add gst_param */
4936         _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4937                 CONFIGURE_CATEGORY_MAIN_GENERAL,
4938                 "DisabledAttributes",
4939                 &disabled_attr);
4940         if (disabled_attr != NULL && disabled_attr->value) {
4941                 cnt_str = disabled_attr->count;
4942                 for (i = 0; i < cnt_str; i++) {
4943                         int idx = 0;
4944                         MMCAM_LOG_INFO("[%d]%s", i, disabled_attr->value[i]);
4945                         nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
4946
4947                         if (nerror == MM_ERROR_NONE)
4948                                 mm_attrs_set_disabled(attrs, idx);
4949                         else
4950                                 MMCAM_LOG_WARNING("No ATTR named %s[%d]", disabled_attr->value[i], i);
4951                 }
4952         }
4953
4954         return nerror;
4955 }
4956
4957
4958 /*---------------------------------------------------------------------------------------
4959 |    INTERNAL FUNCTION DEFINITIONS:                                                     |
4960 ---------------------------------------------------------------------------------------*/
4961 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4962 {
4963         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4964         _MMCamcorderSubContext *sc = NULL;
4965         int current_state = MM_CAMCORDER_STATE_NULL;
4966
4967         mmf_return_val_if_fail(hcamcorder, FALSE);
4968
4969         sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4970         if (!sc)
4971                 return TRUE;
4972
4973         current_state = _mmcamcorder_get_state(handle);
4974
4975         if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4976                 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4977                         MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
4978                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4979                         MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4980                 } else {
4981                         MMCAM_LOG_WARNING("invalid state[%d]", current_state);
4982                         return FALSE;
4983                 }
4984         } else {
4985                 MMCAM_LOG_INFO("element is not created yet");
4986         }
4987
4988         return TRUE;
4989 }
4990
4991
4992 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4993 {
4994         #define INIT_VALUE            -1
4995         #define CHECK_COUNT           3
4996
4997         mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4998         MMHandleType attrs = 0;
4999
5000         int ret = MM_ERROR_NONE;
5001         int i = 0;
5002         int j = 0;
5003         const char *name = NULL;
5004         const char *check_pair_name[CHECK_COUNT][3] = {
5005                 {MMCAM_CAMERA_WIDTH,  MMCAM_CAMERA_HEIGHT,  "MMCAM_CAMERA_WIDTH and HEIGHT"},
5006                 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
5007                 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
5008         };
5009
5010         int check_pair_value[CHECK_COUNT][2] = {
5011                 {INIT_VALUE, INIT_VALUE},
5012                 {INIT_VALUE, INIT_VALUE},
5013                 {INIT_VALUE, INIT_VALUE},
5014         };
5015
5016         if (hcamcorder == NULL || attribute_name == NULL) {
5017                 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
5018                         hcamcorder, attribute_name);
5019                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5020         }
5021
5022         if (err_attr_name)
5023                 *err_attr_name = NULL;
5024
5025         /*MMCAM_LOG_INFO( "ENTER" );*/
5026
5027         attrs = MMF_CAMCORDER_ATTRS(handle);
5028
5029         name = attribute_name;
5030
5031         while (name) {
5032                 int idx = -1;
5033                 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
5034
5035                 /*MMCAM_LOG_INFO("NAME : %s", name);*/
5036
5037                 /* attribute name check */
5038                 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
5039                         if (err_attr_name)
5040                                 *err_attr_name = strdup(name);
5041
5042                         if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
5043                                 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5044                         else
5045                                 return ret;
5046                 }
5047
5048                 /* type check */
5049                 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5050                         return ret;
5051
5052                 switch (attr_type) {
5053                 case MM_ATTRS_TYPE_INT:
5054                 {
5055                         gboolean matched = FALSE;
5056                         for (i = 0 ; i < CHECK_COUNT ; i++) {
5057                                 for (j = 0 ; j < 2 ; j++) {
5058                                         if (!strcmp(name, check_pair_name[i][j])) {
5059                                                 check_pair_value[i][j] = va_arg((var_args), int);
5060                                                 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5061                                                 matched = TRUE;
5062                                                 break;
5063                                         }
5064                                 }
5065                                 if (matched)
5066                                         break;
5067                         }
5068                         if (matched == FALSE)
5069                                 va_arg((var_args), int);
5070                         break;
5071                 }
5072                 case MM_ATTRS_TYPE_DOUBLE:
5073                         va_arg((var_args), double);
5074                         break;
5075                 case MM_ATTRS_TYPE_STRING:
5076                         va_arg((var_args), char*); /* string */
5077                         va_arg((var_args), int);   /* size */
5078                         break;
5079                 case MM_ATTRS_TYPE_DATA:
5080                         va_arg((var_args), void*); /* data */
5081                         va_arg((var_args), int);   /* size */
5082                         break;
5083                 case MM_ATTRS_TYPE_INVALID:
5084                 default:
5085                         MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5086                         if (err_attr_name)
5087                                 *err_attr_name = strdup(name);
5088
5089                         return  MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5090                 }
5091
5092                 /* next name */
5093                 name = va_arg(var_args, const char*);
5094         }
5095
5096         for (i = 0 ; i < CHECK_COUNT ; i++) {
5097                 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5098                         gboolean check_result = FALSE;
5099                         char *err_name = NULL;
5100                         MMCamAttrsInfo attr_info_0, attr_info_1;
5101
5102                         if (check_pair_value[i][0] == INIT_VALUE) {
5103                                 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5104                                 err_name = strdup(check_pair_name[i][1]);
5105                         } else if (check_pair_value[i][1] == INIT_VALUE) {
5106                                 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5107                                 err_name = strdup(check_pair_name[i][0]);
5108                         } else {
5109                                 err_name = strdup(check_pair_name[i][2]);
5110                         }
5111
5112                         mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5113                         mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5114
5115                         check_result = FALSE;
5116
5117                         for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5118                                 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5119                                     attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5120                                         /*
5121                                         MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5122                                                 check_pair_name[i][0], check_pair_name[i][1],
5123                                                 check_pair_value[i][0], check_pair_value[i][1], i);
5124                                         */
5125                                         check_result = TRUE;
5126                                         break;
5127                                 }
5128                         }
5129
5130                         if (check_result == FALSE) {
5131                                 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5132                                         check_pair_name[i][0], check_pair_name[i][1],
5133                                         check_pair_value[i][0], check_pair_value[i][1]);
5134                                 if (err_attr_name) {
5135                                         *err_attr_name = err_name;
5136                                 } else {
5137                                         if (err_name) {
5138                                                 free(err_name);
5139                                                 err_name = NULL;
5140                                         }
5141                                 }
5142
5143                                 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5144                         }
5145
5146                         if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5147                                 int current_width = 0;
5148                                 int current_height = 0;
5149
5150                                 mm_camcorder_get_attributes(handle, NULL,
5151                                         MMCAM_CAMERA_WIDTH, &current_width,
5152                                         MMCAM_CAMERA_HEIGHT, &current_height,
5153                                         NULL);
5154
5155                                 if (current_width != check_pair_value[i][0] ||
5156                                     current_height != check_pair_value[i][1]) {
5157                                         hcamcorder->resolution_changed = TRUE;
5158                                 } else {
5159                                         hcamcorder->resolution_changed = FALSE;
5160                                 }
5161
5162                                 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5163                         }
5164
5165                         if (err_name) {
5166                                 free(err_name);
5167                                 err_name = NULL;
5168                         }
5169                 }
5170         }
5171
5172         /*MMCAM_LOG_INFO("DONE");*/
5173
5174         return MM_ERROR_NONE;
5175 }
5176
5177
5178 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5179 {
5180         MMAttrsInfo info;
5181
5182         if ((void *)handle == NULL) {
5183                 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5184                 return FALSE;
5185         }
5186
5187         memset(&info, 0x0, sizeof(MMAttrsInfo));
5188
5189         mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5190
5191         switch (info.validity_type) {
5192         case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5193                 /*
5194                 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5195                 */
5196                 if (info.int_array.count < 1)
5197                         return FALSE;
5198                 break;
5199         case MM_ATTRS_VALID_TYPE_INT_RANGE:
5200                 /*
5201                 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5202                 */
5203                 if (info.int_range.min > info.int_range.max)
5204                         return FALSE;
5205                 break;
5206         case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5207                 /*
5208                 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5209                 */
5210                 if (info.double_array.count < 1)
5211                         return FALSE;
5212                 break;
5213         case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5214                 /*
5215                 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5216                 */
5217                 if (info.double_range.min >= info.double_range.max)
5218                         return FALSE;
5219                 break;
5220         default:
5221                 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);
5222                 return FALSE;
5223         }
5224
5225         return TRUE;
5226 }