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