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