4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 /*=======================================================================================
25 =======================================================================================*/
26 #include "mm_camcorder_internal.h"
27 #include "mm_camcorder_gstcommon.h"
29 #include <gst/video/colorbalance.h>
30 #include <gst/video/videooverlay.h>
32 /*-----------------------------------------------------------------------
33 | MACRO DEFINITIONS: |
34 -----------------------------------------------------------------------*/
35 #define MMCAMCORDER_DEFAULT_CAMERA_WIDTH 640
36 #define MMCAMCORDER_DEFAULT_CAMERA_HEIGHT 480
37 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL 1000
38 #define MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL 89.0
40 /*---------------------------------------------------------------------------------------
41 | GLOBAL VARIABLE DEFINITIONS for internal |
42 ---------------------------------------------------------------------------------------*/
44 /*-----------------------------------------------------------------------
45 | LOCAL VARIABLE DEFINITIONS for internal |
46 -----------------------------------------------------------------------*/
47 /* Readonly attributes list.
48 * If you want to make some attributes read only, write down here.
49 * It will make them read only after composing whole attributes.
52 static int readonly_attributes[] = {
53 MM_CAM_CAMERA_DEVICE_COUNT,
54 MM_CAM_CAMERA_DEVICE_NAME,
55 MM_CAM_CAMERA_FACING_DIRECTION,
56 MM_CAM_CAMERA_SHUTTER_SPEED,
57 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
58 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
59 MM_CAM_CAPTURED_SCREENNAIL,
60 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
61 MM_CAM_SUPPORT_ZSL_CAPTURE,
62 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
63 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
64 MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
65 MM_CAM_VIDEOSRC_ELEMENT_NAME,
66 MM_CAM_AUDIOSRC_ELEMENT_NAME
69 /*-----------------------------------------------------------------------
70 | LOCAL FUNCTION PROTOTYPES: |
71 -----------------------------------------------------------------------*/
72 /* STATIC INTERNAL FUNCTION */
73 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height);
74 static int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle);
75 static int __mmcamcorder_release_conf_valid_info(MMHandleType handle);
76 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
78 /*=======================================================================
79 | FUNCTION DEFINITIONS |
80 =======================================================================*/
81 /*-----------------------------------------------------------------------
82 | GLOBAL FUNCTION DEFINITIONS: |
83 -----------------------------------------------------------------------*/
85 _mmcamcorder_alloc_attribute(MMHandleType handle)
89 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
90 MMHandleType attrs = NULL;
91 MMAttrsConstructInfo *attrs_const_info;
92 unsigned int attr_count = 0;
94 int ret = MM_ERROR_NONE;
96 static int depth[] = {MM_CAMCORDER_AUDIO_FORMAT_PCM_U8, MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE};
97 static int flip_list[] = { MM_FLIP_NONE };
98 static int rotation_list[] = { MM_VIDEO_INPUT_ROTATION_NONE };
99 static int visible_values[] = { 0, 1 }; /*0: off, 1:on*/
100 static int tag_orientation_values[] = {
101 1, /*The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.*/
102 2, /*the 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.*/
103 3, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.*/
104 4, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.*/
105 5, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual top.*/
106 6, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual top.*/
107 7, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.*/
108 8, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.*/
111 if (hcamcorder == NULL) {
112 MMCAM_LOG_ERROR("handle is NULL");
116 /* Create attribute constructor */
117 MMCAM_LOG_INFO("start");
119 /* alloc 'MMAttrsConstructInfo' */
120 attr_count = MM_CAM_ATTRIBUTE_NUM;
121 attrs_const_info = malloc(attr_count * sizeof(MMAttrsConstructInfo));
122 if (!attrs_const_info) {
123 MMCAM_LOG_ERROR("Fail to alloc constructor.");
127 /* alloc default attribute info */
128 hcamcorder->cam_attrs_const_info = (mm_cam_attr_construct_info *)malloc(sizeof(mm_cam_attr_construct_info) * attr_count);
129 if (hcamcorder->cam_attrs_const_info == NULL) {
130 MMCAM_LOG_ERROR("failed to alloc default attribute info");
131 free(attrs_const_info);
132 attrs_const_info = NULL;
136 /* basic attributes' info */
137 mm_cam_attr_construct_info temp_info[] = {
140 MM_CAM_MODE, /* ID */
142 MM_ATTRS_TYPE_INT, /* Type */
143 MM_ATTRS_FLAG_RW, /* Flag */
144 {(void*)MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Default value */
145 MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */
146 {.int_min = MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Validity val1 (min, *array,...) */
147 {.int_max = MM_CAMCORDER_MODE_AUDIO}, /* Validity val2 (max, count, ...) */
148 NULL, /* Runtime setting function of the attribute */
155 {(void*)MM_AUDIO_DEVICE_MIC},
156 MM_ATTRS_VALID_TYPE_INT_ARRAY,
162 MM_CAM_CAMERA_DEVICE_COUNT,
163 "camera-device-count",
166 {(void*)MM_VIDEO_DEVICE_NUM},
167 MM_ATTRS_VALID_TYPE_INT_RANGE,
168 {.int_min = MM_VIDEO_DEVICE_NONE},
169 {.int_max = MM_VIDEO_DEVICE_NUM},
173 MM_CAM_AUDIO_ENCODER,
177 {(void*)MM_AUDIO_CODEC_AMR},
178 MM_ATTRS_VALID_TYPE_INT_ARRAY,
184 MM_CAM_VIDEO_ENCODER,
188 {(void*)MM_VIDEO_CODEC_MPEG4},
189 MM_ATTRS_VALID_TYPE_INT_ARRAY,
195 MM_CAM_IMAGE_ENCODER,
199 {(void*)MM_IMAGE_CODEC_JPEG},
200 MM_ATTRS_VALID_TYPE_INT_ARRAY,
210 {(void*)MM_FILE_FORMAT_MP4},
211 MM_ATTRS_VALID_TYPE_INT_ARRAY,
217 MM_CAM_CAMERA_DEVICE_NAME,
218 "camera-device-name",
219 MM_ATTRS_TYPE_STRING,
222 MM_ATTRS_VALID_TYPE_NONE,
228 MM_CAM_AUDIO_SAMPLERATE,
233 MM_ATTRS_VALID_TYPE_INT_RANGE,
235 {.int_max = _MMCAMCORDER_MAX_INT},
243 {(void*)MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE},
244 MM_ATTRS_VALID_TYPE_INT_ARRAY,
251 MM_CAM_AUDIO_CHANNEL,
256 MM_ATTRS_VALID_TYPE_INT_RANGE,
264 MM_ATTRS_TYPE_DOUBLE,
266 {.value_double = 1.0},
267 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
269 {.double_max = 10.0},
270 _mmcamcorder_commit_audio_volume,
273 MM_CAM_AUDIO_INPUT_ROUTE,
277 {(void*)MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
278 MM_ATTRS_VALID_TYPE_INT_RANGE,
279 {.int_min = MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
280 {.int_max = MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY},
281 _mmcamcorder_commit_audio_input_route,
284 MM_CAM_FILTER_SCENE_MODE,
289 MM_ATTRS_VALID_TYPE_INT_ARRAY,
292 _mmcamcorder_commit_filter_scene_mode,
295 MM_CAM_FILTER_BRIGHTNESS,
300 MM_ATTRS_VALID_TYPE_INT_RANGE,
303 _mmcamcorder_commit_filter,
306 MM_CAM_FILTER_CONTRAST,
311 MM_ATTRS_VALID_TYPE_INT_RANGE,
314 _mmcamcorder_commit_filter,
322 MM_ATTRS_VALID_TYPE_INT_ARRAY,
325 _mmcamcorder_commit_filter,
328 MM_CAM_FILTER_COLOR_TONE,
333 MM_ATTRS_VALID_TYPE_INT_ARRAY,
336 _mmcamcorder_commit_filter,
339 MM_CAM_FILTER_SATURATION,
344 MM_ATTRS_VALID_TYPE_INT_RANGE,
347 _mmcamcorder_commit_filter,
355 MM_ATTRS_VALID_TYPE_INT_RANGE,
358 _mmcamcorder_commit_filter,
362 MM_CAM_FILTER_SHARPNESS,
367 MM_ATTRS_VALID_TYPE_INT_RANGE,
370 _mmcamcorder_commit_filter,
373 MM_CAM_CAMERA_FORMAT,
377 {(void*)MM_PIXEL_FORMAT_YUYV},
378 MM_ATTRS_VALID_TYPE_INT_ARRAY,
381 _mmcamcorder_commit_camera_format,
384 MM_CAM_CAMERA_RECORDING_MOTION_RATE,
385 "camera-recording-motion-rate",
386 MM_ATTRS_TYPE_DOUBLE,
388 {.value_double = 1.0},
389 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
391 {.double_max = _MMCAMCORDER_MAX_DOUBLE},
392 _mmcamcorder_commit_camera_recording_motion_rate,
400 MM_ATTRS_VALID_TYPE_INT_RANGE,
403 _mmcamcorder_commit_camera_fps,
410 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
411 MM_ATTRS_VALID_TYPE_INT_ARRAY,
414 _mmcamcorder_commit_camera_width,
417 MM_CAM_CAMERA_HEIGHT,
421 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
422 MM_ATTRS_VALID_TYPE_INT_ARRAY,
425 _mmcamcorder_commit_camera_height,
428 MM_CAM_CAMERA_DIGITAL_ZOOM,
429 "camera-digital-zoom",
433 MM_ATTRS_VALID_TYPE_INT_RANGE,
436 _mmcamcorder_commit_camera_zoom,
439 MM_CAM_CAMERA_OPTICAL_ZOOM,
440 "camera-optical-zoom",
444 MM_ATTRS_VALID_TYPE_INT_RANGE,
447 _mmcamcorder_commit_camera_zoom,
450 MM_CAM_CAMERA_FOCUS_MODE,
454 {(void*)MM_CAMCORDER_FOCUS_MODE_NONE},
455 MM_ATTRS_VALID_TYPE_INT_ARRAY,
458 _mmcamcorder_commit_camera_focus_mode,
461 MM_CAM_CAMERA_AF_SCAN_RANGE,
462 "camera-af-scan-range",
466 MM_ATTRS_VALID_TYPE_INT_ARRAY,
469 _mmcamcorder_commit_camera_af_scan_range,
473 MM_CAM_CAMERA_EXPOSURE_MODE,
474 "camera-exposure-mode",
478 MM_ATTRS_VALID_TYPE_INT_ARRAY,
481 _mmcamcorder_commit_camera_capture_mode,
484 MM_CAM_CAMERA_EXPOSURE_VALUE,
485 "camera-exposure-value",
489 MM_ATTRS_VALID_TYPE_INT_RANGE,
492 _mmcamcorder_commit_camera_capture_mode,
495 MM_CAM_CAMERA_F_NUMBER,
500 MM_ATTRS_VALID_TYPE_INT_ARRAY,
503 _mmcamcorder_commit_camera_capture_mode,
506 MM_CAM_CAMERA_SHUTTER_SPEED,
507 "camera-shutter-speed",
511 MM_ATTRS_VALID_TYPE_INT_ARRAY,
514 _mmcamcorder_commit_camera_capture_mode,
522 MM_ATTRS_VALID_TYPE_INT_ARRAY,
525 _mmcamcorder_commit_camera_capture_mode,
533 MM_ATTRS_VALID_TYPE_INT_ARRAY,
536 _mmcamcorder_commit_camera_wdr,
539 MM_CAM_CAMERA_ANTI_HANDSHAKE,
540 "camera-anti-handshake",
544 MM_ATTRS_VALID_TYPE_INT_ARRAY,
547 _mmcamcorder_commit_camera_anti_handshake,
550 MM_CAM_CAMERA_FPS_AUTO,
555 MM_ATTRS_VALID_TYPE_INT_RANGE,
558 _mmcamcorder_commit_camera_fps,
561 MM_CAM_CAMERA_DELAY_ATTR_SETTING,
562 "camera-delay-attr-setting",
566 MM_ATTRS_VALID_TYPE_INT_RANGE,
572 MM_CAM_AUDIO_ENCODER_BITRATE,
573 "audio-encoder-bitrate",
577 MM_ATTRS_VALID_TYPE_INT_RANGE,
579 {.int_max = _MMCAMCORDER_MAX_INT},
580 _mmcamcorder_commit_encoder_bitrate,
584 MM_CAM_VIDEO_ENCODER_BITRATE,
585 "video-encoder-bitrate",
589 MM_ATTRS_VALID_TYPE_INT_RANGE,
591 {.int_max = _MMCAMCORDER_MAX_INT},
592 _mmcamcorder_commit_encoder_bitrate,
595 MM_CAM_IMAGE_ENCODER_QUALITY,
596 "image-encoder-quality",
600 MM_ATTRS_VALID_TYPE_INT_RANGE,
603 _mmcamcorder_commit_image_encoder_quality,
606 MM_CAM_CAPTURE_FORMAT,
610 {(void*)MM_PIXEL_FORMAT_ENCODED},
611 MM_ATTRS_VALID_TYPE_INT_ARRAY,
617 MM_CAM_CAPTURE_WIDTH,
622 MM_ATTRS_VALID_TYPE_INT_ARRAY,
625 _mmcamcorder_commit_capture_width ,
628 MM_CAM_CAPTURE_HEIGHT,
633 MM_ATTRS_VALID_TYPE_INT_ARRAY,
636 _mmcamcorder_commit_capture_height,
639 MM_CAM_CAPTURE_COUNT,
644 MM_ATTRS_VALID_TYPE_INT_RANGE,
647 _mmcamcorder_commit_capture_count,
650 MM_CAM_CAPTURE_INTERVAL,
655 MM_ATTRS_VALID_TYPE_INT_RANGE,
657 {.int_max = _MMCAMCORDER_MAX_INT},
661 MM_CAM_CAPTURE_BREAK_CONTINUOUS_SHOT,
662 "capture-break-cont-shot",
666 MM_ATTRS_VALID_TYPE_INT_RANGE,
669 _mmcamcorder_commit_capture_break_cont_shot,
672 MM_CAM_DISPLAY_HANDLE,
677 MM_ATTRS_VALID_TYPE_NONE,
680 _mmcamcorder_commit_display_handle,
683 MM_CAM_DISPLAY_DEVICE,
687 {(void*)MM_DISPLAY_DEVICE_MAINLCD},
688 MM_ATTRS_VALID_TYPE_INT_ARRAY,
695 MM_CAM_DISPLAY_SURFACE,
699 {(void*)MM_DISPLAY_SURFACE_OVERLAY},
700 MM_ATTRS_VALID_TYPE_INT_ARRAY,
706 MM_CAM_DISPLAY_RECT_X,
711 MM_ATTRS_VALID_TYPE_INT_RANGE,
713 {.int_max = _MMCAMCORDER_MAX_INT},
714 _mmcamcorder_commit_display_rect,
717 MM_CAM_DISPLAY_RECT_Y,
722 MM_ATTRS_VALID_TYPE_INT_RANGE,
724 {.int_max = _MMCAMCORDER_MAX_INT},
725 _mmcamcorder_commit_display_rect,
728 MM_CAM_DISPLAY_RECT_WIDTH,
729 "display-rect-width",
733 MM_ATTRS_VALID_TYPE_INT_RANGE,
735 {.int_max = _MMCAMCORDER_MAX_INT},
736 _mmcamcorder_commit_display_rect,
739 MM_CAM_DISPLAY_RECT_HEIGHT,
740 "display-rect-height",
744 MM_ATTRS_VALID_TYPE_INT_RANGE,
746 {.int_max = _MMCAMCORDER_MAX_INT},
747 _mmcamcorder_commit_display_rect,
750 MM_CAM_DISPLAY_SOURCE_X,
755 MM_ATTRS_VALID_TYPE_INT_RANGE,
757 {.int_max = _MMCAMCORDER_MAX_INT},
761 MM_CAM_DISPLAY_SOURCE_Y,
766 MM_ATTRS_VALID_TYPE_INT_RANGE,
768 {.int_max = _MMCAMCORDER_MAX_INT},
772 MM_CAM_DISPLAY_SOURCE_WIDTH,
777 MM_ATTRS_VALID_TYPE_INT_RANGE,
779 {.int_max = _MMCAMCORDER_MAX_INT},
783 MM_CAM_DISPLAY_SOURCE_HEIGHT,
784 "display-src-height",
788 MM_ATTRS_VALID_TYPE_INT_RANGE,
790 {.int_max = _MMCAMCORDER_MAX_INT},
794 MM_CAM_DISPLAY_ROTATION,
798 {(void*)MM_DISPLAY_ROTATION_NONE},
799 MM_ATTRS_VALID_TYPE_INT_RANGE,
800 {.int_min = MM_DISPLAY_ROTATION_NONE},
801 {.int_max = MM_DISPLAY_ROTATION_270},
802 _mmcamcorder_commit_display_rotation,
806 MM_CAM_DISPLAY_VISIBLE,
811 MM_ATTRS_VALID_TYPE_INT_ARRAY,
813 {ARRAY_SIZE(visible_values)},
814 _mmcamcorder_commit_display_visible,
817 MM_CAM_DISPLAY_SCALE,
822 MM_ATTRS_VALID_TYPE_INT_RANGE,
823 {.int_min = MM_DISPLAY_SCALE_DEFAULT},
824 {.int_max = MM_DISPLAY_SCALE_TRIPLE_LENGTH},
825 _mmcamcorder_commit_display_scale,
828 MM_CAM_DISPLAY_GEOMETRY_METHOD,
829 "display-geometry-method",
833 MM_ATTRS_VALID_TYPE_INT_RANGE,
834 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
835 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
836 _mmcamcorder_commit_display_geometry_method,
839 MM_CAM_TARGET_FILENAME,
841 MM_ATTRS_TYPE_STRING,
844 MM_ATTRS_VALID_TYPE_NONE,
847 _mmcamcorder_commit_target_filename,
850 MM_CAM_TARGET_MAX_SIZE,
855 MM_ATTRS_VALID_TYPE_INT_RANGE,
857 {.int_max = _MMCAMCORDER_MAX_INT},
858 _mmcamcorder_commit_recording_max_limit,
861 MM_CAM_TARGET_TIME_LIMIT,
866 MM_ATTRS_VALID_TYPE_INT_RANGE,
868 {.int_max = _MMCAMCORDER_MAX_INT},
869 _mmcamcorder_commit_recording_max_limit,
877 MM_ATTRS_VALID_TYPE_INT_RANGE,
880 _mmcamcorder_commit_tag,
883 MM_CAM_TAG_IMAGE_DESCRIPTION,
884 "tag-image-description",
885 MM_ATTRS_TYPE_STRING,
888 MM_ATTRS_VALID_TYPE_NONE,
891 _mmcamcorder_commit_tag,
894 MM_CAM_TAG_ORIENTATION,
899 MM_ATTRS_VALID_TYPE_INT_ARRAY,
900 {tag_orientation_values},
901 {ARRAY_SIZE(tag_orientation_values)},
902 _mmcamcorder_commit_tag,
907 MM_ATTRS_TYPE_STRING,
910 MM_ATTRS_VALID_TYPE_NONE,
913 _mmcamcorder_commit_tag,
919 MM_ATTRS_TYPE_DOUBLE,
921 {.value_double = 0.0},
922 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
923 {.double_min = -360.0},
924 {.double_max = 360.0},
925 _mmcamcorder_commit_tag,
928 MM_CAM_TAG_LONGITUDE,
930 MM_ATTRS_TYPE_DOUBLE,
932 {.value_double = 0.0},
933 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
934 {.double_min = -360.0},
935 {.double_max = 360.0},
936 _mmcamcorder_commit_tag,
941 MM_ATTRS_TYPE_DOUBLE,
943 {.value_double = 0.0},
944 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
945 {.double_min = -999999.0},
946 {.double_max = 999999.0},
947 _mmcamcorder_commit_tag,
950 MM_CAM_STROBE_CONTROL,
955 MM_ATTRS_VALID_TYPE_INT_RANGE,
958 _mmcamcorder_commit_strobe,
961 MM_CAM_STROBE_CAPABILITIES,
962 "strobe-capabilities",
966 MM_ATTRS_VALID_TYPE_INT_RANGE,
969 _mmcamcorder_commit_strobe,
977 MM_ATTRS_VALID_TYPE_INT_ARRAY,
980 _mmcamcorder_commit_strobe,
988 MM_ATTRS_VALID_TYPE_INT_ARRAY,
991 _mmcamcorder_commit_detect,
994 MM_CAM_DETECT_NUMBER,
999 MM_ATTRS_VALID_TYPE_INT_RANGE,
1002 _mmcamcorder_commit_detect,
1005 MM_CAM_DETECT_FOCUS_SELECT,
1006 "detect-focus-select",
1010 MM_ATTRS_VALID_TYPE_INT_RANGE,
1013 _mmcamcorder_commit_detect,
1016 MM_CAM_DETECT_SELECT_NUMBER,
1017 "detect-select-number",
1021 MM_ATTRS_VALID_TYPE_INT_RANGE,
1024 _mmcamcorder_commit_detect,
1028 MM_CAM_DETECT_STATUS,
1033 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1036 _mmcamcorder_commit_detect,
1039 MM_CAM_CAPTURE_ZERO_SYSTEMLAG,
1040 "capture-zero-systemlag",
1044 MM_ATTRS_VALID_TYPE_INT_RANGE,
1050 MM_CAM_CAMERA_AF_TOUCH_X,
1051 "camera-af-touch-x",
1055 MM_ATTRS_VALID_TYPE_INT_RANGE,
1057 {.int_max = _MMCAMCORDER_MAX_INT},
1058 _mmcamcorder_commit_camera_af_touch_area,
1061 MM_CAM_CAMERA_AF_TOUCH_Y,
1062 "camera-af-touch-y",
1066 MM_ATTRS_VALID_TYPE_INT_RANGE,
1068 {.int_max = _MMCAMCORDER_MAX_INT},
1069 _mmcamcorder_commit_camera_af_touch_area,
1072 MM_CAM_CAMERA_AF_TOUCH_WIDTH,
1073 "camera-af-touch-width",
1077 MM_ATTRS_VALID_TYPE_INT_RANGE,
1079 {.int_max = _MMCAMCORDER_MAX_INT},
1080 _mmcamcorder_commit_camera_af_touch_area,
1083 MM_CAM_CAMERA_AF_TOUCH_HEIGHT,
1084 "camera-af-touch-height",
1088 MM_ATTRS_VALID_TYPE_INT_RANGE,
1090 {.int_max = _MMCAMCORDER_MAX_INT},
1091 _mmcamcorder_commit_camera_af_touch_area,
1094 MM_CAM_CAMERA_FOCAL_LENGTH,
1095 "camera-focal-length",
1096 MM_ATTRS_TYPE_DOUBLE,
1098 {.value_double = 0.0},
1099 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1100 {.double_min = 0.0},
1101 {.double_max = 1000.0},
1102 _mmcamcorder_commit_camera_capture_mode,
1105 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
1106 "recommend-preview-format-for-capture",
1109 {(void*)MM_PIXEL_FORMAT_YUYV},
1110 MM_ATTRS_VALID_TYPE_INT_RANGE,
1111 {.int_min = MM_PIXEL_FORMAT_NV12},
1112 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1116 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
1117 "recommend-preview-format-for-recording",
1120 {(void*)MM_PIXEL_FORMAT_NV12},
1121 MM_ATTRS_VALID_TYPE_INT_RANGE,
1122 {.int_min = MM_PIXEL_FORMAT_NV12},
1123 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1127 MM_CAM_TAG_GPS_ENABLE,
1132 MM_ATTRS_VALID_TYPE_INT_RANGE,
1135 _mmcamcorder_commit_tag,
1139 MM_CAM_TAG_GPS_TIME_STAMP,
1140 "tag-gps-time-stamp",
1141 MM_ATTRS_TYPE_DOUBLE,
1143 {.value_double = 0.0},
1144 MM_ATTRS_VALID_TYPE_NONE,
1147 _mmcamcorder_commit_tag,
1150 MM_CAM_TAG_GPS_DATE_STAMP,
1151 "tag-gps-date-stamp",
1152 MM_ATTRS_TYPE_STRING,
1155 MM_ATTRS_VALID_TYPE_NONE,
1158 _mmcamcorder_commit_tag,
1161 MM_CAM_TAG_GPS_PROCESSING_METHOD,
1162 "tag-gps-processing-method",
1163 MM_ATTRS_TYPE_STRING,
1166 MM_ATTRS_VALID_TYPE_NONE,
1169 _mmcamcorder_commit_tag,
1172 MM_CAM_CAMERA_ROTATION,
1176 {(void*)MM_VIDEO_INPUT_ROTATION_NONE},
1177 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1179 {ARRAY_SIZE(rotation_list)},
1180 _mmcamcorder_commit_camera_rotate,
1183 MM_CAM_CAPTURED_SCREENNAIL,
1184 "captured-screennail",
1188 MM_ATTRS_VALID_TYPE_NONE,
1194 MM_CAM_CAPTURE_SOUND_ENABLE,
1195 "capture-sound-enable",
1199 MM_ATTRS_VALID_TYPE_INT_RANGE,
1202 _mmcamcorder_commit_capture_sound_enable,
1205 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
1206 "recommend-display-rotation",
1209 {(void*)MM_DISPLAY_ROTATION_270},
1210 MM_ATTRS_VALID_TYPE_INT_RANGE,
1211 {.int_min = MM_DISPLAY_ROTATION_NONE},
1212 {.int_max = MM_DISPLAY_ROTATION_270},
1220 {(void*)MM_FLIP_NONE},
1221 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1223 {ARRAY_SIZE(flip_list)},
1224 _mmcamcorder_commit_camera_flip,
1227 MM_CAM_CAMERA_HDR_CAPTURE,
1228 "camera-hdr-capture",
1232 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1235 _mmcamcorder_commit_camera_hdr_capture,
1238 MM_CAM_DISPLAY_MODE,
1242 {(void*)MM_DISPLAY_MODE_DEFAULT},
1243 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1246 _mmcamcorder_commit_display_mode,
1250 MM_CAM_AUDIO_DISABLE,
1255 MM_ATTRS_VALID_TYPE_INT_RANGE,
1258 _mmcamcorder_commit_audio_disable,
1261 MM_CAM_RECOMMEND_CAMERA_WIDTH,
1262 "recommend-camera-width",
1265 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
1266 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1272 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
1273 "recommend-camera-height",
1276 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
1277 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1283 MM_CAM_CAPTURED_EXIF_RAW_DATA,
1284 "captured-exif-raw-data",
1288 MM_ATTRS_VALID_TYPE_NONE,
1294 MM_CAM_DISPLAY_EVAS_SURFACE_SINK,
1295 "display-evas-surface-sink",
1296 MM_ATTRS_TYPE_STRING,
1299 MM_ATTRS_VALID_TYPE_NONE,
1305 MM_CAM_DISPLAY_EVAS_DO_SCALING,
1306 "display-evas-do-scaling",
1310 MM_ATTRS_VALID_TYPE_INT_RANGE,
1313 _mmcamcorder_commit_display_evas_do_scaling,
1316 MM_CAM_CAMERA_FACING_DIRECTION,
1317 "camera-facing-direction",
1320 {(void*)MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1321 MM_ATTRS_VALID_TYPE_INT_RANGE,
1322 {.int_min = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1323 {.int_max = MM_CAMCORDER_CAMERA_FACING_DIRECTION_FRONT},
1327 MM_CAM_DISPLAY_FLIP,
1331 {(void*)MM_FLIP_NONE},
1332 MM_ATTRS_VALID_TYPE_INT_RANGE,
1333 {.int_min = MM_FLIP_NONE},
1334 {.int_max = MM_FLIP_BOTH},
1335 _mmcamcorder_commit_display_flip,
1338 MM_CAM_CAMERA_VIDEO_STABILIZATION,
1339 "camera-video-stabilization",
1342 {(void*)MM_CAMCORDER_VIDEO_STABILIZATION_OFF},
1343 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1346 _mmcamcorder_commit_camera_video_stabilization,
1349 MM_CAM_TAG_VIDEO_ORIENTATION,
1350 "tag-video-orientation",
1353 {(void*)MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1354 MM_ATTRS_VALID_TYPE_INT_RANGE,
1355 {.int_min = MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1356 {.int_max = MM_CAMCORDER_TAG_VIDEO_ORT_270},
1361 MM_CAM_CAMERA_PAN_MECHA,
1366 MM_ATTRS_VALID_TYPE_INT_RANGE,
1369 _mmcamcorder_commit_camera_pan,
1372 MM_CAM_CAMERA_PAN_ELEC,
1377 MM_ATTRS_VALID_TYPE_INT_RANGE,
1380 _mmcamcorder_commit_camera_pan,
1383 MM_CAM_CAMERA_TILT_MECHA,
1384 "camera-tilt-mecha",
1388 MM_ATTRS_VALID_TYPE_INT_RANGE,
1391 _mmcamcorder_commit_camera_tilt,
1394 MM_CAM_CAMERA_TILT_ELEC,
1399 MM_ATTRS_VALID_TYPE_INT_RANGE,
1402 _mmcamcorder_commit_camera_tilt,
1405 MM_CAM_CAMERA_PTZ_TYPE,
1410 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1413 _mmcamcorder_commit_camera_ptz_type,
1421 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1424 _mmcamcorder_commit_video_size,
1427 MM_CAM_VIDEO_HEIGHT,
1432 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1435 _mmcamcorder_commit_video_size,
1438 MM_CAM_SUPPORT_ZSL_CAPTURE,
1439 "support-zsl-capture",
1443 MM_ATTRS_VALID_TYPE_INT_RANGE,
1449 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
1450 "support-zero-copy-format",
1454 MM_ATTRS_VALID_TYPE_INT_RANGE,
1460 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
1461 "support-media-packet-preview-cb",
1465 MM_ATTRS_VALID_TYPE_INT_RANGE,
1472 MM_CAM_ENCODED_PREVIEW_BITRATE,
1473 "encoded-preview-bitrate",
1477 MM_ATTRS_VALID_TYPE_INT_RANGE,
1479 {.int_max = _MMCAMCORDER_MAX_INT},
1480 _mmcamcorder_commit_encoded_preview_bitrate,
1483 MM_CAM_ENCODED_PREVIEW_GOP_INTERVAL,
1484 "encoded-preview-gop-interval",
1487 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL},
1488 MM_ATTRS_VALID_TYPE_INT_RANGE,
1490 {.int_max = _MMCAMCORDER_MAX_INT},
1491 _mmcamcorder_commit_encoded_preview_gop_interval,
1494 MM_CAM_RECORDER_TAG_ENABLE,
1495 "recorder-tag-enable",
1499 MM_ATTRS_VALID_TYPE_INT_RANGE,
1505 MM_CAM_DISPLAY_SOCKET_PATH,
1506 "display-socket-path",
1507 MM_ATTRS_TYPE_STRING,
1510 MM_ATTRS_VALID_TYPE_NONE,
1521 MM_ATTRS_VALID_TYPE_INT_RANGE,
1523 {.int_max = _MMCAMCORDER_MAX_INT},
1527 MM_CAM_ROOT_DIRECTORY,
1529 MM_ATTRS_TYPE_STRING,
1532 MM_ATTRS_VALID_TYPE_NONE,
1538 MM_CAM_SOUND_STREAM_INDEX,
1539 "sound-stream-index",
1543 MM_ATTRS_VALID_TYPE_INT_RANGE,
1545 {.int_max = _MMCAMCORDER_MAX_INT},
1549 MM_CAM_SOUND_STREAM_TYPE,
1550 "sound-stream-type",
1551 MM_ATTRS_TYPE_STRING,
1554 MM_ATTRS_VALID_TYPE_NONE,
1557 _mmcamcorder_commit_sound_stream_info,
1560 MM_CAM_DISPLAY_REUSE_HINT,
1561 "display-reuse-hint",
1565 MM_ATTRS_VALID_TYPE_INT_RANGE,
1571 MM_CAM_DISPLAY_REUSE_ELEMENT,
1572 "display-reuse-element",
1576 MM_ATTRS_VALID_TYPE_NONE,
1582 MM_CAM_GDBUS_CONNECTION,
1587 MM_ATTRS_VALID_TYPE_NONE,
1593 MM_CAM_AUDIO_REPLAY_GAIN_ENABLE,
1594 "audio-replay-gain-enable",
1598 MM_ATTRS_VALID_TYPE_INT_RANGE,
1601 _mmcamcorder_commit_audio_replay_gain,
1604 MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL,
1605 "audio-replay-gain-reference-level",
1606 MM_ATTRS_TYPE_DOUBLE,
1608 {.value_double = MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL},
1609 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1610 {.double_min = 0.0},
1611 {.double_max = 150.0},
1612 _mmcamcorder_commit_audio_replay_gain,
1615 MM_CAM_SUPPORT_USER_BUFFER,
1616 "support-user-buffer",
1620 MM_ATTRS_VALID_TYPE_INT_RANGE,
1626 MM_CAM_USER_BUFFER_FD,
1631 MM_ATTRS_VALID_TYPE_NONE,
1637 MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
1638 "platform-privilege-camera",
1639 MM_ATTRS_TYPE_STRING,
1642 MM_ATTRS_VALID_TYPE_NONE,
1648 MM_CAM_STROBE_BRIGHTNESS,
1649 "strobe-brightness",
1653 MM_ATTRS_VALID_TYPE_INT_RANGE,
1656 _mmcamcorder_commit_strobe,
1659 MM_CAM_VIDEOSRC_ELEMENT_NAME,
1660 "videosrc-element-name",
1661 MM_ATTRS_TYPE_STRING,
1664 MM_ATTRS_VALID_TYPE_NONE,
1670 MM_CAM_AUDIOSRC_ELEMENT_NAME,
1671 "audiosrc-element-name",
1672 MM_ATTRS_TYPE_STRING,
1675 MM_ATTRS_VALID_TYPE_NONE,
1681 MM_CAM_EXTRA_PREVIEW_ENABLE,
1682 "extra-preview-enable",
1686 MM_ATTRS_VALID_TYPE_INT_RANGE,
1689 _mmcamcorder_commit_extra_preview,
1692 MM_CAM_CAMERA_FOCUS_LEVEL,
1693 "camera-focus-level",
1697 MM_ATTRS_VALID_TYPE_INT_RANGE,
1700 _mmcamcorder_commit_camera_focus_level,
1703 MM_CAM_SUPPORT_EXTRA_PREVIEW,
1704 "support-extra-preview",
1708 MM_ATTRS_VALID_TYPE_INT_RANGE,
1714 MM_CAM_REQUEST_CODEC_CONFIG,
1715 "request-codec-config",
1719 MM_ATTRS_VALID_TYPE_INT_RANGE,
1722 _mmcamcorder_commit_request_codec_config,
1725 MM_CAM_FILTER_WB_TEMPERATURE,
1726 "filter-wb-temperature",
1730 MM_ATTRS_VALID_TYPE_INT_RANGE,
1733 _mmcamcorder_commit_filter,
1736 MM_CAM_FILTER_WB_TEMPERATURE_STEP,
1737 "filter-wb-temperature-step",
1741 MM_ATTRS_VALID_TYPE_INT_RANGE,
1743 {.int_max = _MMCAMCORDER_MAX_INT},
1752 MM_ATTRS_VALID_TYPE_INT_RANGE,
1755 _mmcamcorder_commit_camera_capture_mode,
1758 MM_CAM_CAMERA_GAIN_STEP,
1763 MM_ATTRS_VALID_TYPE_INT_RANGE,
1765 {.int_max = _MMCAMCORDER_MAX_INT},
1770 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1772 for (idx = 0 ; idx < attr_count ; idx++) {
1773 /* attribute order check. This should be same. */
1774 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1775 MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1776 free(attrs_const_info);
1777 attrs_const_info = NULL;
1778 free(hcamcorder->cam_attrs_const_info);
1779 hcamcorder->cam_attrs_const_info = NULL;
1783 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1784 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1785 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1786 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1789 /* Camcorder Attributes */
1790 MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1792 ret = mm_attrs_new(attrs_const_info,
1794 "Camcorder_Attributes",
1795 _mmcamcorder_commit_camcorder_attrs,
1799 free(attrs_const_info);
1800 attrs_const_info = NULL;
1802 if (ret != MM_ERROR_NONE) {
1803 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1804 free(hcamcorder->cam_attrs_const_info);
1805 hcamcorder->cam_attrs_const_info = NULL;
1809 __mmcamcorder_set_conf_to_valid_info(handle);
1811 for (idx = 0; idx < attr_count; idx++) {
1812 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1814 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1816 switch (attr_info->validity_type) {
1817 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1818 if (attr_info->validity_value_1.int_array &&
1819 attr_info->validity_value_2.count > 0) {
1820 mm_attrs_set_valid_array(attrs, idx,
1821 (const int *)(attr_info->validity_value_1.int_array),
1822 attr_info->validity_value_2.count,
1823 attr_info->default_value.value_int);
1826 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1827 mm_attrs_set_valid_range(attrs, idx,
1828 attr_info->validity_value_1.int_min,
1829 attr_info->validity_value_2.int_max,
1830 attr_info->default_value.value_int);
1832 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1833 if (attr_info->validity_value_1.double_array &&
1834 attr_info->validity_value_2.count > 0) {
1835 mm_attrs_set_valid_double_array(attrs, idx,
1836 (const double *)(attr_info->validity_value_1.double_array),
1837 attr_info->validity_value_2.count,
1838 attr_info->default_value.value_double);
1841 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1842 mm_attrs_set_valid_double_range(attrs, idx,
1843 attr_info->validity_value_1.double_min,
1844 attr_info->validity_value_2.double_max,
1845 attr_info->default_value.value_double);
1847 case MM_ATTRS_VALID_TYPE_NONE:
1849 case MM_ATTRS_VALID_TYPE_INVALID:
1851 MMCAM_LOG_ERROR("Valid type error.");
1856 __mmcamcorder_release_conf_valid_info(handle);
1863 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1865 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1867 if (hcamcorder == NULL) {
1868 MMCAM_LOG_ERROR("handle is NULL");
1875 mm_attrs_free(attrs);
1876 MMCAM_LOG_INFO("released attribute");
1879 if (hcamcorder->cam_attrs_const_info) {
1880 free(hcamcorder->cam_attrs_const_info);
1881 hcamcorder->cam_attrs_const_info = NULL;
1882 MMCAM_LOG_INFO("released attribute info");
1890 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1892 MMHandleType attrs = 0;
1893 int ret = MM_ERROR_NONE;
1895 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1896 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1898 attrs = MMF_CAMCORDER_ATTRS(handle);
1899 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1901 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1908 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1910 MMHandleType attrs = 0;
1911 int ret = MM_ERROR_NONE;
1913 char *tmp_err_attr_name = NULL;
1914 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1915 va_list var_args_copy;
1917 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1919 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1920 MMCAM_LOG_ERROR("Another command is running.");
1921 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1924 /* copy var_args to keep original var_args */
1925 va_copy(var_args_copy, var_args);
1927 attrs = MMF_CAMCORDER_ATTRS(handle);
1929 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1931 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1932 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1935 if (ret == MM_ERROR_NONE) {
1936 hcamcorder->error_code = MM_ERROR_NONE;
1937 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1938 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1941 va_end(var_args_copy);
1943 _MMCAMCORDER_UNLOCK_CMD(handle);
1945 if (ret != MM_ERROR_NONE) {
1946 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1947 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1948 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1949 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1950 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1951 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1955 if (hcamcorder->error_code != MM_ERROR_NONE) {
1956 MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1957 ret = hcamcorder->error_code;
1958 hcamcorder->error_code = MM_ERROR_NONE;
1961 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1964 if (tmp_err_attr_name) {
1965 if (!err_attr_name) {
1966 MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1967 free(tmp_err_attr_name);
1968 tmp_err_attr_name = NULL;
1970 *err_attr_name = tmp_err_attr_name;
1979 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1981 MMHandleType attrs = 0;
1982 MMAttrsInfo attrinfo;
1983 int ret = MM_ERROR_NONE;
1985 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1986 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1987 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1989 attrs = MMF_CAMCORDER_ATTRS(handle);
1990 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1992 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1994 if (ret == MM_ERROR_NONE) {
1995 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1996 info->type = attrinfo.type;
1997 info->flag = attrinfo.flag;
1998 info->validity_type = attrinfo.validity_type;
2000 switch (attrinfo.validity_type) {
2001 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
2002 info->int_array.array = attrinfo.int_array.array;
2003 info->int_array.count = attrinfo.int_array.count;
2004 info->int_array.def = attrinfo.int_array.dval;
2006 case MM_ATTRS_VALID_TYPE_INT_RANGE:
2007 info->int_range.min = attrinfo.int_range.min;
2008 info->int_range.max = attrinfo.int_range.max;
2009 info->int_range.def = attrinfo.int_range.dval;
2011 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
2012 info->double_array.array = attrinfo.double_array.array;
2013 info->double_array.count = attrinfo.double_array.count;
2014 info->double_array.def = attrinfo.double_array.dval;
2016 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
2017 info->double_range.min = attrinfo.double_range.min;
2018 info->double_range.max = attrinfo.double_range.max;
2019 info->double_range.def = attrinfo.double_range.dval;
2021 case MM_ATTRS_VALID_TYPE_NONE:
2023 case MM_ATTRS_VALID_TYPE_INVALID:
2034 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
2037 mmf_camcorder_t *hcamcorder = NULL;
2039 mmf_return_val_if_fail(commit_param, FALSE);
2040 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
2041 mmf_return_val_if_fail(attr_name, FALSE);
2042 mmf_return_val_if_fail(value, FALSE);
2044 hcamcorder = MMF_CAMCORDER(commit_param);
2046 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
2047 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
2055 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
2058 int total_count = 0;
2060 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2062 if (hcamcorder == NULL) {
2063 MMCAM_LOG_ERROR("handle is NULL");
2064 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2068 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
2069 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
2070 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
2073 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
2074 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
2075 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
2078 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
2079 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
2080 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
2083 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
2084 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
2085 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
2087 return MM_ERROR_NONE;
2091 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
2093 int *allocated_memory = NULL;
2095 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2097 if (hcamcorder == NULL) {
2098 MMCAM_LOG_ERROR("handle is NULL");
2099 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2102 MMCAM_LOG_INFO("START");
2104 /* Audio encoder info */
2105 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2106 if (allocated_memory) {
2107 g_free(allocated_memory);
2108 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2109 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2112 /* Video encoder info */
2113 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2114 if (allocated_memory) {
2115 g_free(allocated_memory);
2116 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2117 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2120 /* Image encoder info */
2121 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2122 if (allocated_memory) {
2123 g_free(allocated_memory);
2124 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2125 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2128 /* File format info */
2129 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2130 if (allocated_memory) {
2131 g_free(allocated_memory);
2132 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2133 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2136 MMCAM_LOG_INFO("DONE");
2138 return MM_ERROR_NONE;
2142 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2144 MMHandleType attr = 0;
2145 int current_state = MM_CAMCORDER_STATE_NONE;
2147 mmf_return_val_if_fail(handle && value, FALSE);
2149 attr = MMF_CAMCORDER_ATTRS(handle);
2150 mmf_return_val_if_fail(attr, FALSE);
2152 /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2154 current_state = _mmcamcorder_get_state(handle);
2155 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2156 int flags = MM_ATTRS_FLAG_NONE;
2157 int capture_width, capture_height;
2158 MMCamAttrsInfo info;
2160 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2163 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2164 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2165 capture_width = value->value.i_val;
2167 /* Check whether they are valid pair */
2168 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2173 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2179 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2181 int current_state = MM_CAMCORDER_STATE_NONE;
2183 current_state = _mmcamcorder_get_state(handle);
2185 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2186 int capture_width, capture_height;
2188 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2189 capture_height = value->value.i_val;
2191 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2193 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2200 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2202 int current_state = 0;
2204 _MMCamcorderSubContext *sc = NULL;
2205 _MMCamcorderImageInfo *info = NULL;
2206 GstCameraControl *control = NULL;
2208 mmf_return_val_if_fail(handle && value, FALSE);
2210 current_state = _mmcamcorder_get_state(handle);
2211 ivalue = value->value.i_val;
2213 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2217 info = sc->info_image;
2219 MMCAM_LOG_ERROR("info image is NULL");
2223 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2224 if (info->capture_send_count > 0) {
2225 info->capturing = FALSE;
2226 MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2229 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2230 MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2234 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2236 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2237 MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2239 MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2242 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2249 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2251 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2252 int current_state = MM_CAMCORDER_STATE_NONE;
2253 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2255 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2257 current_state = _mmcamcorder_get_state(handle);
2258 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2260 MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2261 current_state, mode, value->value.i_val);
2263 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2264 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2267 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2273 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2275 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2277 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2279 MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2281 /* return error when disable shutter sound if policy is TRUE */
2282 if (!value->value.i_val &&
2283 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2284 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2287 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2293 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2295 int current_state = MM_CAMCORDER_STATE_NONE;
2296 _MMCamcorderSubContext *sc = NULL;
2299 mmf_return_val_if_fail(handle && value, FALSE);
2301 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2305 current_state = _mmcamcorder_get_state(handle);
2307 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2308 double mslNewVal = 0;
2309 mslNewVal = value->value.d_val;
2311 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2312 if (mslNewVal == 0.0) {
2313 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2314 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2316 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2317 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2321 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2324 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2332 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2334 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2335 int current_state = MM_CAMCORDER_STATE_NONE;
2337 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2339 current_state = _mmcamcorder_get_state(handle);
2340 if (current_state > MM_CAMCORDER_STATE_READY) {
2341 MMCAM_LOG_ERROR("invalid state %d", current_state);
2342 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2350 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2352 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2353 MMCamAttrsInfo fps_info;
2354 int resolution_width = 0;
2355 int resolution_height = 0;
2358 int current_state = MM_CAMCORDER_STATE_NONE;
2360 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2362 current_state = _mmcamcorder_get_state(handle);
2363 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2364 MMCAM_LOG_ERROR("invalid state %d", current_state);
2365 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2369 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2372 MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2374 ret = mm_camcorder_get_attributes(handle, NULL,
2375 MMCAM_CAMERA_WIDTH, &resolution_width,
2376 MMCAM_CAMERA_HEIGHT, &resolution_height,
2379 if (ret != MM_ERROR_NONE) {
2380 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2384 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2385 if (ret != MM_ERROR_NONE) {
2386 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2390 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2391 if (value->value.i_val == fps_info.int_array.array[i])
2395 MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2401 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2403 int current_state = MM_CAMCORDER_STATE_NONE;
2404 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2405 _MMCamcorderSubContext *sc = NULL;
2407 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2409 current_state = _mmcamcorder_get_state(handle);
2410 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2411 MMCAM_LOG_WARNING("invalid state %d", current_state);
2412 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2416 /* Verify recording motion rate */
2417 if (value->value.d_val > 0.0) {
2418 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2422 /* set is_slow flag */
2423 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2424 sc->is_modified_rate = TRUE;
2426 sc->is_modified_rate = FALSE;
2428 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2431 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2437 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2439 MMHandleType attr = 0;
2440 int current_state = MM_CAMCORDER_STATE_NONE;
2442 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2443 _MMCamcorderSubContext *sc = NULL;
2445 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2447 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2451 attr = MMF_CAMCORDER_ATTRS(handle);
2452 mmf_return_val_if_fail(attr, FALSE);
2454 MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2456 current_state = _mmcamcorder_get_state(handle);
2458 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2459 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2462 int flags = MM_ATTRS_FLAG_NONE;
2463 MMCamAttrsInfo info;
2464 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2467 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2468 int width = value->value.i_val;
2470 int preview_format = MM_PIXEL_FORMAT_NV12;
2471 int codec_type = MM_IMAGE_CODEC_JPEG;
2473 mm_camcorder_get_attributes(handle, NULL,
2474 MMCAM_CAMERA_HEIGHT, &height,
2475 MMCAM_CAMERA_FORMAT, &preview_format,
2476 MMCAM_IMAGE_ENCODER, &codec_type,
2479 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2480 if (hcamcorder->resolution_changed == FALSE) {
2481 MMCAM_LOG_INFO("no need to restart preview");
2485 hcamcorder->resolution_changed = FALSE;
2487 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2488 MMCAM_LOG_INFO("restart preview");
2490 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2491 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2493 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2494 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2496 /* check decoder recreation */
2497 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2498 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2499 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2503 /* get preview format */
2504 sc->info_image->preview_format = preview_format;
2505 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2506 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2508 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2509 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2511 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2512 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2515 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2517 MMCAM_LOG_ERROR("currently locked for preview restart");
2521 /* get preview format */
2522 sc->info_image->preview_format = preview_format;
2523 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2524 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2535 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2538 int current_state = MM_CAMCORDER_STATE_NONE;
2539 MMHandleType attr = 0;
2540 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2541 _MMCamcorderSubContext *sc = NULL;
2543 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2545 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2549 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2550 mmf_return_val_if_fail(attr, FALSE);
2552 MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2553 current_state = _mmcamcorder_get_state(handle);
2555 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2556 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2557 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2561 int height = value->value.i_val;
2562 int preview_format = MM_PIXEL_FORMAT_NV12;
2563 int codec_type = MM_IMAGE_CODEC_JPEG;
2564 int video_stabilization = 0;
2566 mm_camcorder_get_attributes(handle, NULL,
2567 MMCAM_CAMERA_WIDTH, &width,
2568 MMCAM_CAMERA_FORMAT, &preview_format,
2569 MMCAM_IMAGE_ENCODER, &codec_type,
2570 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2573 sc->info_video->preview_width = width;
2574 sc->info_video->preview_height = height;
2576 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2577 if (hcamcorder->resolution_changed == FALSE) {
2578 MMCAM_LOG_INFO("no need to restart preview");
2582 hcamcorder->resolution_changed = FALSE;
2584 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2585 MMCAM_LOG_INFO("restart preview");
2587 MMCAM_LOG_INFO("set empty buffers");
2589 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2590 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2592 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2593 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2595 /* check decoder recreation */
2596 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2597 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2598 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2602 /* get preview format */
2603 sc->info_image->preview_format = preview_format;
2604 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2606 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2608 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2609 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2611 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2612 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2615 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2617 MMCAM_LOG_ERROR("currently locked for preview restart");
2621 /* get preview format */
2622 sc->info_image->preview_format = preview_format;
2623 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2624 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2632 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2634 int current_state = MM_CAMCORDER_STATE_NONE;
2635 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2637 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2639 current_state = _mmcamcorder_get_state(handle);
2640 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2641 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2642 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2645 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2646 value->value.i_val, attr_idx);
2652 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2654 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2655 _MMCamcorderSubContext *sc = NULL;
2656 int current_state = MM_CAMCORDER_STATE_NONE;
2657 GstCameraControl *control = NULL;
2661 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2663 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2667 zoom_level = value->value.i_val;
2669 MMCAM_LOG_INFO("(%d)", attr_idx);
2671 current_state = _mmcamcorder_get_state(handle);
2672 if (current_state < MM_CAMCORDER_STATE_READY) {
2673 MMCAM_LOG_INFO("will be applied when preview starts");
2675 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2676 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2677 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2681 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2682 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2684 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2686 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2689 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2690 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2694 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2695 if (control == NULL) {
2696 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2700 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2702 MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2705 MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2708 MMCAM_LOG_INFO("pointer of video src is null");
2715 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2717 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2718 _MMCamcorderSubContext *sc = NULL;
2719 int current_state = MM_CAMCORDER_STATE_NONE;
2721 GstCameraControl *CameraControl = NULL;
2722 GstCameraControlChannel *CameraControlChannel = NULL;
2723 const GList *controls = NULL;
2724 const GList *item = NULL;
2726 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2728 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2729 mmf_return_val_if_fail(sc, TRUE);
2731 MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2733 current_state = _mmcamcorder_get_state(handle);
2734 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2735 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2736 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2737 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2741 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2742 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2743 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2747 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2748 if (CameraControl == NULL) {
2749 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2753 controls = gst_camera_control_list_channels(CameraControl);
2754 if (controls == NULL) {
2755 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2759 for (item = controls ; item && item->data ; item = item->next) {
2760 CameraControlChannel = item->data;
2761 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2762 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2763 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2764 MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2767 MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2773 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2780 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2782 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2783 _MMCamcorderSubContext *sc = NULL;
2784 int current_state = MM_CAMCORDER_STATE_NONE;
2786 GstCameraControl *CameraControl = NULL;
2787 GstCameraControlChannel *CameraControlChannel = NULL;
2788 const GList *controls = NULL;
2789 const GList *item = NULL;
2791 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2793 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2794 mmf_return_val_if_fail(sc, TRUE);
2796 MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2798 current_state = _mmcamcorder_get_state(handle);
2799 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2800 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2801 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2802 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2806 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2807 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2808 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2812 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2813 if (CameraControl == NULL) {
2814 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2818 controls = gst_camera_control_list_channels(CameraControl);
2819 if (controls == NULL) {
2820 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2824 for (item = controls ; item && item->data ; item = item->next) {
2825 CameraControlChannel = item->data;
2826 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2827 if (!strcmp(CameraControlChannel->label, "pan")) {
2828 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2829 MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2832 MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2838 MMCAM_LOG_WARNING("failed to find pan control channel");
2845 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2847 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2848 _MMCamcorderSubContext *sc = NULL;
2849 int current_state = MM_CAMCORDER_STATE_NONE;
2851 GstCameraControl *CameraControl = NULL;
2852 GstCameraControlChannel *CameraControlChannel = NULL;
2853 const GList *controls = NULL;
2854 const GList *item = NULL;
2856 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2858 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2859 mmf_return_val_if_fail(sc, TRUE);
2861 MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2863 current_state = _mmcamcorder_get_state(handle);
2864 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2865 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2866 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2867 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2871 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2872 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2873 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2877 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2878 if (CameraControl == NULL) {
2879 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2883 controls = gst_camera_control_list_channels(CameraControl);
2884 if (controls == NULL) {
2885 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2889 for (item = controls ; item && item->data ; item = item->next) {
2890 CameraControlChannel = item->data;
2891 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2892 if (!strcmp(CameraControlChannel->label, "tilt")) {
2893 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2894 MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2897 MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2903 MMCAM_LOG_WARNING("failed to find tilt control channel");
2910 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2912 MMHandleType attr = 0;
2913 int current_state = MM_CAMCORDER_STATE_NONE;
2914 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2915 _MMCamcorderSubContext *sc = NULL;
2916 GstCameraControl *control = NULL;
2918 int set_focus_mode = 0;
2919 int cur_focus_mode = 0;
2920 int cur_focus_range = 0;
2922 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2924 attr = MMF_CAMCORDER_ATTRS(handle);
2925 mmf_return_val_if_fail(attr, FALSE);
2927 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2931 MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2933 /* check whether set or not */
2934 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2935 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2939 current_state = _mmcamcorder_get_state(handle);
2940 if (current_state < MM_CAMCORDER_STATE_NULL) {
2941 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2943 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2944 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2945 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2949 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2950 int flags = MM_ATTRS_FLAG_NONE;
2951 MMCamAttrsInfo info;
2953 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2954 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2958 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2959 if (control == NULL) {
2960 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2964 mslVal = value->value.i_val;
2965 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2967 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2970 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2971 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2972 if (set_focus_mode != cur_focus_mode) {
2973 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2974 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2977 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2980 MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2984 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2988 MMCAM_LOG_INFO("pointer of video src is null");
2995 bool _mmcamcorder_commit_camera_focus_level(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2997 int current_state = MM_CAMCORDER_STATE_NONE;
2998 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2999 _MMCamcorderSubContext *sc = NULL;
3000 GstCameraControl *control = NULL;
3002 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3004 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3008 MMCAM_LOG_INFO("Focus level[%d]", value->value.i_val);
3010 current_state = _mmcamcorder_get_state(handle);
3011 if (current_state < MM_CAMCORDER_STATE_READY) {
3012 MMCAM_LOG_INFO("Focus level will be set later.(state=%d)", current_state);
3014 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3015 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3016 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3020 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3021 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
3025 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3026 if (control == NULL) {
3027 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3031 if (!gst_camera_control_set_focus_level(control, value->value.i_val)) {
3032 MMCAM_LOG_ERROR("set focus level[%d[ failed", value->value.i_val);
3040 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3042 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3043 _MMCamcorderSubContext *sc = NULL;
3044 GstCameraControl *control = NULL;
3045 int current_state = MM_CAMCORDER_STATE_NONE;
3048 int cur_focus_mode = 0;
3049 int cur_focus_range = 0;
3050 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3051 int converted_mode = 0;
3053 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3055 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3059 MMCAM_LOG_INFO("(%d)", attr_idx);
3061 /* check whether set or not */
3062 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3063 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3067 mslVal = value->value.i_val;
3068 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3070 current_state = _mmcamcorder_get_state(handle);
3071 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3072 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3074 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3075 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3076 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3080 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3081 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3082 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3086 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3087 if (control == NULL) {
3088 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3092 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
3093 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
3095 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
3096 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
3097 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
3098 /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
3101 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
3104 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
3108 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
3111 MMCAM_LOG_INFO("pointer of video src is null");
3118 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3120 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3121 _MMCamcorderSubContext *sc = NULL;
3122 GstCameraControl *control = NULL;
3123 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
3124 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
3126 int current_state = MM_CAMCORDER_STATE_NONE;
3128 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3130 gboolean do_set = FALSE;
3132 MMCamAttrsInfo info_y;
3133 MMCamAttrsInfo info_w;
3134 MMCamAttrsInfo info_h;
3136 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3138 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3142 MMCAM_LOG_INFO("(%d)", attr_idx);
3144 current_state = _mmcamcorder_get_state(handle);
3145 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3146 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3148 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3149 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3150 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3154 ret = mm_camcorder_get_attributes(handle, NULL,
3155 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3157 if (ret != MM_ERROR_NONE) {
3158 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3162 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3163 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3167 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3168 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3169 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3173 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3174 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3175 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3178 case MM_CAM_CAMERA_AF_TOUCH_X:
3179 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3180 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3181 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3182 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3183 set_area.x = value->value.i_val;
3184 mm_camcorder_get_attributes(handle, NULL,
3185 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3186 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3187 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3191 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3195 case MM_CAM_CAMERA_AF_TOUCH_Y:
3196 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3197 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3198 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3199 set_area.y = value->value.i_val;
3200 mm_camcorder_get_attributes(handle, NULL,
3201 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3202 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3203 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3207 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3211 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3212 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3213 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3214 set_area.width = value->value.i_val;
3215 mm_camcorder_get_attributes(handle, NULL,
3216 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3217 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3218 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3222 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3226 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3227 set_area.height = value->value.i_val;
3228 mm_camcorder_get_attributes(handle, NULL,
3229 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3230 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3231 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3240 _MMCamcorderVideoInfo *info = sc->info_video;
3243 MMCAM_LOG_ERROR("video info is NULL");
3247 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3248 if (control == NULL) {
3249 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3254 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3255 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3256 float ratio_width = 0.0;
3257 float ratio_height = 0.0;
3259 if (info->preview_width != 0 && info->preview_height != 0) {
3260 ratio_width = (float)info->video_width / (float)info->preview_width;
3261 ratio_height = (float)info->video_height / (float)info->preview_height;
3263 MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3264 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3266 set_area.x = (int)((float)set_area.x * ratio_width);
3267 set_area.y = (int)((float)set_area.y * ratio_height);
3268 set_area.width = (int)((float)set_area.width * ratio_width);
3269 set_area.height = (int)((float)set_area.height * ratio_height);
3271 if (set_area.width <= 0)
3274 if (set_area.height <= 0)
3275 set_area.height = 1;
3277 MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3278 set_area.x, set_area.y, set_area.width, set_area.height);
3280 MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3281 info->preview_width, info->preview_height);
3285 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3287 MMCAM_LOG_WARNING("Failed to get AF area");
3291 /* width and height are not supported now */
3292 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3293 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3294 get_area.x, get_area.y);
3298 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3300 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3301 set_area.x, set_area.y, set_area.width, set_area.height);
3304 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3305 set_area.x, set_area.y, set_area.width, set_area.height);
3309 MMCAM_LOG_INFO("pointer of video src is null");
3316 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3318 GstCameraControl *control = NULL;
3324 int exposure_type = 0;
3325 int current_state = MM_CAMCORDER_STATE_NONE;
3326 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3327 _MMCamcorderSubContext *sc = NULL;
3329 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3330 gboolean check_scene_mode = FALSE;
3332 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3334 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3338 /* check whether set or not */
3339 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3340 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3344 current_state = _mmcamcorder_get_state(handle);
3345 if (current_state < MM_CAMCORDER_STATE_READY) {
3346 MMCAM_LOG_INFO("will be applied when preview starts");
3348 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3349 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3350 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3354 ivalue = value->value.i_val;
3357 case MM_CAM_CAMERA_F_NUMBER:
3358 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3359 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3360 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3362 case MM_CAM_CAMERA_SHUTTER_SPEED:
3363 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3364 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3365 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3367 case MM_CAM_CAMERA_ISO:
3368 exposure_type = GST_CAMERA_CONTROL_ISO;
3370 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3371 check_scene_mode = TRUE;
3373 case MM_CAM_CAMERA_EXPOSURE_MODE:
3374 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3376 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3377 check_scene_mode = TRUE;
3379 case MM_CAM_CAMERA_EXPOSURE_VALUE:
3380 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3381 mslVal1 = newVal1 = ivalue;
3383 case MM_CAM_CAMERA_GAIN:
3384 exposure_type = GST_CAMERA_CONTROL_GAIN;
3385 mslVal1 = newVal1 = ivalue;
3388 MMCAM_LOG_ERROR("unknown attr idx[%d]", attr_idx);
3392 if (check_scene_mode) {
3393 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3394 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3395 MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3400 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3403 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3404 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3408 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3409 if (control == NULL) {
3410 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3414 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3416 MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3419 MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3422 MMCAM_LOG_INFO("pointer of video src is null");
3429 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3431 GstCameraControl *control = NULL;
3435 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3436 _MMCamcorderSubContext *sc = NULL;
3437 int current_state = MM_CAMCORDER_STATE_NONE;
3439 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3441 /* check whether set or not */
3442 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3443 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3447 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3451 /* check current state */
3452 current_state = _mmcamcorder_get_state(handle);
3453 if (current_state < MM_CAMCORDER_STATE_READY) {
3454 MMCAM_LOG_INFO("will be applied when preview starts");
3456 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3457 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3458 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3462 mslVal = value->value.i_val;
3463 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3465 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3466 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3467 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3471 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3472 if (control == NULL) {
3473 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3477 if (gst_camera_control_get_wdr(control, &cur_value)) {
3478 if (newVal != cur_value) {
3479 if (gst_camera_control_set_wdr(control, newVal)) {
3480 MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3483 MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3486 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3490 MMCAM_LOG_WARNING("Failed to get WDR.");
3493 MMCAM_LOG_INFO("pointer of video src is null");
3500 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3502 int current_state = MM_CAMCORDER_STATE_NONE;
3503 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3505 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3507 /* check whether set or not */
3508 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3509 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3513 current_state = _mmcamcorder_get_state(handle);
3514 if (current_state < MM_CAMCORDER_STATE_READY) {
3515 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3517 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3518 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3519 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3523 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3527 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3531 int current_state = MM_CAMCORDER_STATE_NONE;
3532 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3533 _MMCamcorderSubContext *sc = NULL;
3535 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3537 bitrate = value->value.i_val;
3539 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3540 if (!sc || !sc->encode_element) {
3541 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3545 current_state = _mmcamcorder_get_state(handle);
3546 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3547 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3548 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3552 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3553 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3555 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3556 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3558 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3559 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3566 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3568 int current_state = MM_CAMCORDER_STATE_NONE;
3569 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3571 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3573 current_state = _mmcamcorder_get_state(handle);
3574 if (current_state < MM_CAMCORDER_STATE_READY) {
3575 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3577 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3578 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3579 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3583 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3587 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3589 int current_state = MM_CAMCORDER_STATE_NONE;
3590 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3592 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3594 MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3596 current_state = _mmcamcorder_get_state(handle);
3598 if (current_state > MM_CAMCORDER_STATE_READY) {
3599 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3600 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3603 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3608 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3610 int current_state = MM_CAMCORDER_STATE_NONE;
3612 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3613 _MMCamcorderSubContext *sc = NULL;
3615 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3618 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3619 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3623 /* check current state */
3624 current_state = _mmcamcorder_get_state(handle);
3625 if (current_state < MM_CAMCORDER_STATE_READY) {
3626 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3628 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3629 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3630 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3634 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3636 MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3638 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3639 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3642 MMCAM_LOG_ERROR("invalid state %d", current_state);
3648 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3650 mmf_return_val_if_fail(handle && value, FALSE);
3653 if (!value->value.s_val) {
3654 MMCAM_LOG_ERROR("NULL filename");
3658 MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3664 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3666 int current_state = MM_CAMCORDER_STATE_NONE;
3667 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3669 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3671 current_state = _mmcamcorder_get_state(handle);
3672 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3673 MMCAM_LOG_ERROR("Can not set while RECORDING");
3674 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3682 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3684 GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3685 MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3686 return strcmp(Colorchannel->label, user_data);
3689 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3691 GstColorBalance *balance = NULL;
3692 GstColorBalanceChannel *Colorchannel = NULL;
3693 GList *controls = NULL;
3697 int current_state = MM_CAMCORDER_STATE_NONE;
3698 const char *control_label = NULL;
3699 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3700 _MMCamcorderSubContext *sc = NULL;
3702 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3703 gboolean check_scene_mode = FALSE;
3705 int wb_temp_table[] = {
3706 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3707 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3708 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3709 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3710 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3711 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3714 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3716 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3720 /* check whether set or not */
3721 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3722 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3726 current_state = _mmcamcorder_get_state(handle);
3727 if (current_state < MM_CAMCORDER_STATE_READY) {
3728 MMCAM_LOG_INFO("will be applied when preview starts");
3730 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3731 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3732 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3736 if (value->type != MM_ATTRS_TYPE_INT) {
3737 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3741 mslVal = value->value.i_val;
3744 case MM_CAM_FILTER_BRIGHTNESS:
3745 control_label = "brightness";
3746 check_scene_mode = TRUE;
3748 case MM_CAM_FILTER_CONTRAST:
3749 control_label = "contrast";
3751 case MM_CAM_FILTER_WB:
3752 control_label = "white balance";
3753 check_scene_mode = TRUE;
3755 case MM_CAM_FILTER_WB_TEMPERATURE:
3756 control_label = "white balance temperature";
3757 check_scene_mode = TRUE;
3759 case MM_CAM_FILTER_COLOR_TONE:
3760 control_label = "color tone";
3762 case MM_CAM_FILTER_SATURATION:
3763 control_label = "saturation";
3764 check_scene_mode = TRUE;
3766 case MM_CAM_FILTER_HUE:
3767 control_label = "hue";
3769 case MM_CAM_FILTER_SHARPNESS:
3770 control_label = "sharpness";
3771 check_scene_mode = TRUE;
3774 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3778 if (check_scene_mode) {
3779 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3780 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3781 MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3786 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3787 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3790 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3791 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3795 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3796 if (balance == NULL) {
3797 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3801 controls = (GList *)gst_color_balance_list_channels(balance);
3802 if (controls == NULL) {
3803 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3808 MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3809 attr_idx, control_label, mslVal, newVal);
3811 item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3813 Colorchannel = item->data;
3814 gst_color_balance_set_value(balance, Colorchannel, newVal);
3815 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3819 if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3820 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3822 control_label = "white_balance_temperature_auto";
3825 newVal = wb_temp_table[mslVal];
3826 control_label = "white_balance_temperature";
3831 MMCAM_LOG_ERROR("failed to find color channel item");
3837 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3841 int current_state = MM_CAMCORDER_STATE_NONE;
3842 GstCameraControl *control = NULL;
3843 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3844 _MMCamcorderSubContext *sc = NULL;
3846 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3848 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3852 mslVal = value->value.i_val;
3853 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3855 /* check whether set or not */
3856 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3857 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3861 current_state = _mmcamcorder_get_state(handle);
3862 if (current_state < MM_CAMCORDER_STATE_READY) {
3863 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3865 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3866 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3867 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3871 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3874 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3875 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3879 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3880 if (control == NULL) {
3881 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3885 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3887 MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3889 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3893 MM_CAM_FILTER_BRIGHTNESS,
3895 MM_CAM_FILTER_SATURATION,
3896 MM_CAM_FILTER_SHARPNESS,
3897 MM_CAM_FILTER_COLOR_TONE,
3898 MM_CAM_CAMERA_EXPOSURE_MODE
3900 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3902 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3903 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3904 mm_attrs_set_modified(attrs, attr_idxs[i]);
3910 MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3913 MMCAM_LOG_WARNING("pointer of video src is null");
3920 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3922 mmf_return_val_if_fail(handle && value, FALSE);
3924 MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3930 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3932 mmf_return_val_if_fail(handle && value, FALSE);
3934 MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3940 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3942 int current_state = MM_CAMCORDER_STATE_NONE;
3943 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3945 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3947 current_state = _mmcamcorder_get_state(handle);
3948 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3949 MMCAM_LOG_WARNING("Can NOT set disable[%d] AUDIO. invalid state %d",
3950 value->value.i_val, current_state);
3951 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3954 MMCAM_LOG_INFO("Set disable[%d] AUDIO when Recording", value->value.i_val);
3960 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3962 int current_state = MM_CAMCORDER_STATE_NONE;
3963 const char *videosink_name = NULL;
3964 void *dp_handle = NULL;
3965 MMCamWindowInfo *window_info = NULL;
3967 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3968 _MMCamcorderSubContext *sc = NULL;
3970 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3973 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3974 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3978 /* check current state */
3979 current_state = _mmcamcorder_get_state(handle);
3980 if (current_state < MM_CAMCORDER_STATE_READY) {
3981 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3985 dp_handle = value->value.p_val;
3987 MMCAM_LOG_WARNING("Display handle is NULL");
3991 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3993 /* get videosink name */
3994 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3995 if (!videosink_name) {
3996 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4000 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
4002 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
4003 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
4004 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
4005 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
4006 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
4007 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
4008 } else if (!strcmp(videosink_name, "tizenwlsink")) {
4009 window_info = (MMCamWindowInfo *)dp_handle;
4010 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
4011 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
4012 } else if (!strcmp(videosink_name, "directvideosink")) {
4013 window_info = (MMCamWindowInfo *)dp_handle;
4014 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
4015 window_info->surface_id,
4016 window_info->rect.x,
4017 window_info->rect.y,
4018 window_info->rect.width,
4019 window_info->rect.height);
4020 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
4021 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4022 window_info->rect.x,
4023 window_info->rect.y,
4024 window_info->rect.width,
4025 window_info->rect.height);
4027 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
4035 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4037 int current_state = MM_CAMCORDER_STATE_NONE;
4038 const char *videosink_name = NULL;
4040 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4041 _MMCamcorderSubContext *sc = NULL;
4043 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4046 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4047 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4051 /* check current state */
4052 current_state = _mmcamcorder_get_state(handle);
4053 if (current_state < MM_CAMCORDER_STATE_READY) {
4054 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4058 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4060 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4061 if (videosink_name == NULL) {
4062 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4066 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
4068 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4069 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
4070 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
4072 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
4079 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4081 int current_state = MM_CAMCORDER_STATE_NONE;
4083 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4085 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4088 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4089 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4093 /* check current state */
4094 current_state = _mmcamcorder_get_state(handle);
4095 if (current_state < MM_CAMCORDER_STATE_READY) {
4096 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
4100 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4104 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4106 int current_state = MM_CAMCORDER_STATE_NONE;
4108 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4110 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4113 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4114 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4118 /* check current state */
4119 current_state = _mmcamcorder_get_state(handle);
4120 if (current_state < MM_CAMCORDER_STATE_READY) {
4121 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
4125 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4129 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4131 int current_state = MM_CAMCORDER_STATE_NONE;
4132 const char *videosink_name = NULL;
4134 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4135 _MMCamcorderSubContext *sc = NULL;
4137 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4140 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4141 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4145 /* check current state */
4146 current_state = _mmcamcorder_get_state(handle);
4147 if (current_state < MM_CAMCORDER_STATE_READY) {
4148 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4152 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4154 /* Get videosink name */
4155 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4156 if (videosink_name == NULL) {
4157 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4161 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4162 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4163 !strcmp(videosink_name, "directvideosink")) {
4164 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4165 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4167 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4174 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4177 int current_state = MM_CAMCORDER_STATE_NONE;
4178 const char *videosink_name = NULL;
4180 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4181 _MMCamcorderSubContext *sc = NULL;
4183 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4186 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4187 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4191 /* check current state */
4192 current_state = _mmcamcorder_get_state(handle);
4193 if (current_state < MM_CAMCORDER_STATE_READY) {
4194 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4198 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4200 /* Get videosink name */
4201 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4202 if (videosink_name == NULL) {
4203 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4207 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4208 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4209 !strcmp(videosink_name, "directvideosink")) {
4210 method = value->value.i_val;
4211 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4213 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4220 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4222 int current_state = MM_CAMCORDER_STATE_NONE;
4223 int ret = MM_ERROR_NONE;
4224 const char *videosink_name = NULL;
4226 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4227 _MMCamcorderSubContext *sc = NULL;
4229 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4232 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4233 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4237 /* check current state */
4238 current_state = _mmcamcorder_get_state(handle);
4239 if (current_state < MM_CAMCORDER_STATE_READY) {
4240 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4244 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4246 /* Get videosink name */
4247 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4248 if (videosink_name == NULL) {
4249 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4253 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4254 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4258 int rect_height = 0;
4259 int flags = MM_ATTRS_FLAG_NONE;
4260 MMCamAttrsInfo info;
4262 mm_camcorder_get_attributes(handle, NULL,
4263 MMCAM_DISPLAY_RECT_X, &rect_x,
4264 MMCAM_DISPLAY_RECT_Y, &rect_y,
4265 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4266 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4269 case MM_CAM_DISPLAY_RECT_X:
4270 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4272 memset(&info, 0x00, sizeof(info));
4273 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4275 memset(&info, 0x00, sizeof(info));
4276 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4279 rect_x = value->value.i_val;
4281 case MM_CAM_DISPLAY_RECT_Y:
4282 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4284 memset(&info, 0x00, sizeof(info));
4285 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4288 rect_y = value->value.i_val;
4290 case MM_CAM_DISPLAY_RECT_WIDTH:
4291 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4294 rect_width = value->value.i_val;
4296 case MM_CAM_DISPLAY_RECT_HEIGHT:
4297 rect_height = value->value.i_val;
4300 MMCAM_LOG_ERROR("Wrong attr_idx!");
4304 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4305 MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4307 if (!strcmp(videosink_name, "tizenwlsink")) {
4308 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4309 rect_x, rect_y, rect_width, rect_height);
4311 MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4315 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4316 "dst-roi-x", rect_x,
4317 "dst-roi-y", rect_y,
4318 "dst-roi-w", rect_width,
4319 "dst-roi-h", rect_height,
4324 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4331 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4334 int current_state = MM_CAMCORDER_STATE_NONE;
4335 const char *videosink_name = NULL;
4336 GstElement *vs_element = NULL;
4338 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4339 _MMCamcorderSubContext *sc = NULL;
4341 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4344 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4345 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4349 /* check current state */
4350 current_state = _mmcamcorder_get_state(handle);
4351 if (current_state < MM_CAMCORDER_STATE_READY) {
4352 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4356 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4358 /* Get videosink name */
4359 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4360 if (videosink_name == NULL) {
4361 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4365 zoom = value->value.i_val;
4366 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4367 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4369 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4370 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4374 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4380 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4382 int current_state = MM_CAMCORDER_STATE_NONE;
4384 const char *videosink_name = NULL;
4386 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4387 _MMCamcorderSubContext *sc = NULL;
4389 mmf_return_val_if_fail(handle && value, FALSE);
4392 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4393 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4397 /* check current state */
4398 current_state = _mmcamcorder_get_state(handle);
4399 if (current_state < MM_CAMCORDER_STATE_READY) {
4400 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4404 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4406 do_scaling = value->value.i_val;
4408 /* Get videosink name */
4409 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4410 if (videosink_name == NULL) {
4411 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4415 if (!strcmp(videosink_name, "evaspixmapsink")) {
4416 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4417 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4420 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4426 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4428 _MMCamcorderSubContext *sc = NULL;
4429 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4430 int strobe_type, mslVal, newVal, cur_value;
4431 int current_state = MM_CAMCORDER_STATE_NONE;
4433 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4435 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4439 /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4441 mslVal = value->value.i_val;
4443 /* check flash state */
4444 if (attr_idx == MM_CAM_STROBE_MODE) {
4445 int led_brightness = 0;
4447 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4448 MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4449 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4453 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4455 if (led_brightness > 0 &&
4456 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4457 /* other module already turned on LED */
4458 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4459 MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4463 MMCAM_LOG_INFO("keep going");
4467 current_state = _mmcamcorder_get_state(handle);
4468 if (current_state < MM_CAMCORDER_STATE_READY) {
4469 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4471 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4472 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4473 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4478 case MM_CAM_STROBE_CONTROL:
4479 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4480 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4482 case MM_CAM_STROBE_CAPABILITIES:
4483 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4486 case MM_CAM_STROBE_MODE:
4487 /* check whether set or not */
4488 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4489 MMCAM_LOG_INFO("skip set value %d", mslVal);
4493 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4494 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4496 case MM_CAM_STROBE_BRIGHTNESS:
4497 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4501 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4505 GstCameraControl *control = NULL;
4506 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4507 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4511 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4512 if (control == NULL) {
4513 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4517 if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4518 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4522 if (newVal == cur_value) {
4523 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4527 if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4528 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4532 MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4538 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4541 int current_state = MM_CAMCORDER_STATE_NONE;
4542 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4544 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4546 MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4549 current_state = _mmcamcorder_get_state(handle);
4550 if (current_state > MM_CAMCORDER_STATE_READY) {
4551 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4552 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4554 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4555 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4559 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4561 MMCAM_LOG_INFO("ret %d", ret);
4567 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4569 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4570 int current_state = MM_CAMCORDER_STATE_NONE;
4571 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4572 _MMCamcorderSubContext *sc = NULL;
4574 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4576 /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4578 /* check whether set or not */
4579 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4580 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4585 current_state = _mmcamcorder_get_state(handle);
4586 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4587 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4588 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4592 if (current_state >= MM_CAMCORDER_STATE_READY) {
4593 int current_value = 0;
4595 set_hdr_mode = value->value.i_val;
4596 mm_camcorder_get_attributes(handle, NULL,
4597 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4600 if (set_hdr_mode == current_value) {
4601 MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4605 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4607 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4608 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4609 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4611 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4613 /* check decoder recreation */
4614 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4615 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4619 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4620 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4623 set_hdr_mode = value->value.i_val;
4624 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4625 sc->info_image->hdr_capture_mode = set_hdr_mode;
4626 MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4628 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4629 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4631 MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4640 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4643 _MMCamcorderSubContext *sc = NULL;
4644 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4646 int current_value = 0;
4647 int current_state = MM_CAMCORDER_STATE_NONE;
4648 GstCameraControl *control = NULL;
4650 mmf_return_val_if_fail(handle && value, FALSE);
4652 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4656 /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4659 current_state = _mmcamcorder_get_state(handle);
4660 if (current_state < MM_CAMCORDER_STATE_READY) {
4661 MMCAM_LOG_INFO("will be applied when preview starts");
4665 set_value = value->value.i_val;
4668 case MM_CAM_DETECT_MODE:
4669 /* check whether set or not */
4670 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4671 MMCAM_LOG_INFO("skip set value %d", set_value);
4675 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4677 case MM_CAM_DETECT_NUMBER:
4678 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4680 case MM_CAM_DETECT_FOCUS_SELECT:
4681 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4683 case MM_CAM_DETECT_SELECT_NUMBER:
4684 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4686 case MM_CAM_DETECT_STATUS:
4687 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4690 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4694 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4695 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4698 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4699 if (control == NULL) {
4700 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4704 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4705 if (current_value == set_value) {
4706 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4709 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4710 MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4711 detect_type, set_value);
4714 MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4715 detect_type, set_value);
4720 MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4729 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4731 int current_state = MM_CAMCORDER_STATE_NONE;
4733 mmf_return_val_if_fail(handle && value, FALSE);
4735 MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4738 current_state = _mmcamcorder_get_state(handle);
4739 if (current_state < MM_CAMCORDER_STATE_READY) {
4740 MMCAM_LOG_INFO("will be applied when preview starts");
4744 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4748 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4750 int current_state = MM_CAMCORDER_STATE_NONE;
4751 int preview_format = MM_PIXEL_FORMAT_NV12;
4753 mmf_return_val_if_fail(handle && value, FALSE);
4755 MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4757 /* check preview format */
4758 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4759 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
4760 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4765 current_state = _mmcamcorder_get_state(handle);
4766 if (current_state < MM_CAMCORDER_STATE_READY) {
4767 MMCAM_LOG_INFO("will be applied when preview starts");
4771 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4775 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4777 int stream_index = 0;
4778 char *stream_type = NULL;
4779 _MMCamcorderSubContext *sc = NULL;
4781 mmf_return_val_if_fail(handle && value, FALSE);
4783 stream_type = value->value.s_val;
4785 MMCAM_LOG_ERROR("NULL string");
4789 mm_camcorder_get_attributes(handle, NULL,
4790 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4792 if (stream_index < 0) {
4793 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4797 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4798 if (!sc || !sc->encode_element ||
4799 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4800 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4804 MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4806 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4810 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4812 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4813 int current_state = MM_CAMCORDER_STATE_NONE;
4815 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4817 current_state = _mmcamcorder_get_state(handle);
4818 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4819 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4820 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4827 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4829 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4831 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4833 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4834 /* Replay gain enable */
4835 int current_state = MM_CAMCORDER_STATE_NONE;
4836 int audio_disable = FALSE;
4838 current_state = _mmcamcorder_get_state(handle);
4839 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4840 MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4841 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4845 mm_camcorder_get_attributes(handle, NULL,
4846 MMCAM_AUDIO_DISABLE, &audio_disable,
4849 if (audio_disable) {
4850 MMCAM_LOG_ERROR("audio is disabled");
4851 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4855 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4856 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4857 /* Replay gain reference level */
4858 int replay_gain_enable = FALSE;
4860 mm_camcorder_get_attributes(handle, NULL,
4861 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4864 if (replay_gain_enable == FALSE) {
4865 MMCAM_LOG_ERROR("replay gain is disabled");
4866 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4870 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4872 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4880 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4882 int ret = MM_ERROR_NONE;
4883 int current_state = MM_CAMCORDER_STATE_NONE;
4884 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4885 _MMCamcorderSubContext *sc = NULL;
4887 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4889 if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4890 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4894 MMCAM_LOG_INFO("Enable extra preview(%d)", value->value.i_val);
4896 current_state = _mmcamcorder_get_state(handle);
4897 if (current_state < MM_CAMCORDER_STATE_READY) {
4898 MMCAM_LOG_INFO("will be set when preview is started");
4902 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4903 mmf_return_val_if_fail(sc, FALSE);
4905 if (value->value.i_val)
4906 ret = _mmcamcorder_initialize_extra_preview_mode(handle);
4908 ret = _mmcamcorder_deinitialize_extra_preview_mode(handle);
4910 if (ret != MM_ERROR_NONE) {
4911 MMCAM_LOG_ERROR("set[%d] failed[0x%x]", value->value.i_val, ret);
4915 MMCAM_LOG_INFO("done");
4921 bool _mmcamcorder_commit_request_codec_config(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4923 int ret = MM_ERROR_NONE;
4924 int current_state = MM_CAMCORDER_STATE_NONE;
4925 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4926 _MMCamcorderSubContext *sc = NULL;
4928 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4930 if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4931 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4935 MMCAM_LOG_INFO("Request codec config");
4937 current_state = _mmcamcorder_get_state(handle);
4938 if (current_state < MM_CAMCORDER_STATE_READY) {
4939 MMCAM_LOG_INFO("invalid state[%d]", current_state);
4943 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4944 mmf_return_val_if_fail(sc, FALSE);
4946 ret = _mmcamcorder_request_codec_config(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4947 if (ret != MM_ERROR_NONE) {
4948 hcamcorder->error_code = ret;
4956 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4958 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4961 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4965 int attr_idxs_default[] = {
4966 MM_CAM_CAMERA_DIGITAL_ZOOM,
4967 MM_CAM_CAMERA_OPTICAL_ZOOM,
4969 MM_CAM_FILTER_CONTRAST,
4972 MM_CAM_STROBE_BRIGHTNESS
4975 int attr_idxs_extra[] = {
4977 MM_CAM_FILTER_BRIGHTNESS,
4979 MM_CAM_FILTER_SATURATION,
4980 MM_CAM_FILTER_SHARPNESS,
4981 MM_CAM_FILTER_COLOR_TONE,
4982 MM_CAM_CAMERA_EXPOSURE_MODE
4985 mmf_return_val_if_fail(hcamcorder, FALSE);
4987 MMCAM_LOG_INFO("commit some attributes again");
4989 attrs = MMF_CAMCORDER_ATTRS(handle);
4990 if (attrs == NULL) {
4991 MMCAM_LOG_ERROR("Get attribute handle failed.");
4995 /* Get Scene mode */
4996 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4998 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4999 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
5000 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
5003 /* Set extra if scene mode is NORMAL */
5004 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
5005 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
5006 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
5007 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
5010 /* Set scene mode if scene mode is NOT NORMAL */
5011 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
5012 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
5015 if (mm_attrs_commit_all(attrs) == -1)
5020 MMCAM_LOG_INFO("Done.");
5026 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
5028 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5034 MM_CAM_CAMERA_PTZ_TYPE,
5035 MM_CAM_CAMERA_PAN_MECHA,
5036 MM_CAM_CAMERA_PAN_ELEC,
5037 MM_CAM_CAMERA_TILT_MECHA,
5038 MM_CAM_CAMERA_TILT_ELEC
5041 mmf_return_val_if_fail(hcamcorder, FALSE);
5043 MMCAM_LOG_INFO("commit some attribute again[2]");
5045 attrs = MMF_CAMCORDER_ATTRS(handle);
5046 if (attrs == NULL) {
5047 MMCAM_LOG_ERROR("Get attribute handle failed.");
5051 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
5052 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
5053 mm_attrs_set_modified(attrs, attr_idxs[i]);
5056 if (mm_attrs_commit_all(attrs) == -1)
5061 MMCAM_LOG_INFO("Done.");
5067 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
5069 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5073 int nerror = MM_ERROR_NONE;
5075 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
5077 attrs = MMF_CAMCORDER_ATTRS(handle);
5078 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
5082 table_size = ARRAY_SIZE(readonly_attributes);
5083 MMCAM_LOG_INFO("%d", table_size);
5084 for (i = 0; i < table_size; i++) {
5085 int sCategory = readonly_attributes[i];
5087 mm_attrs_set_readonly(attrs, sCategory);
5094 /*---------------------------------------------------------------------------------------
5095 | INTERNAL FUNCTION DEFINITIONS: |
5096 ---------------------------------------------------------------------------------------*/
5097 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
5099 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5100 _MMCamcorderSubContext *sc = NULL;
5101 int current_state = MM_CAMCORDER_STATE_NULL;
5103 mmf_return_val_if_fail(hcamcorder, FALSE);
5105 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
5109 current_state = _mmcamcorder_get_state(handle);
5111 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
5112 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
5113 MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
5114 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
5115 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
5117 MMCAM_LOG_WARNING("invalid state[%d]", current_state);
5121 MMCAM_LOG_INFO("element is not created yet");
5128 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
5130 #define INIT_VALUE -1
5131 #define CHECK_COUNT 3
5133 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5134 MMHandleType attrs = 0;
5136 int ret = MM_ERROR_NONE;
5139 const char *name = NULL;
5140 const char *check_pair_name[CHECK_COUNT][3] = {
5141 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
5142 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
5143 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
5146 int check_pair_value[CHECK_COUNT][2] = {
5147 {INIT_VALUE, INIT_VALUE},
5148 {INIT_VALUE, INIT_VALUE},
5149 {INIT_VALUE, INIT_VALUE},
5152 if (hcamcorder == NULL || attribute_name == NULL) {
5153 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
5154 hcamcorder, attribute_name);
5155 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5159 *err_attr_name = NULL;
5161 /*MMCAM_LOG_INFO( "ENTER" );*/
5163 attrs = MMF_CAMCORDER_ATTRS(handle);
5165 name = attribute_name;
5169 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
5171 /*MMCAM_LOG_INFO("NAME : %s", name);*/
5173 /* attribute name check */
5174 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
5176 *err_attr_name = strdup(name);
5178 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
5179 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5185 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5188 switch (attr_type) {
5189 case MM_ATTRS_TYPE_INT:
5191 gboolean matched = FALSE;
5192 for (i = 0 ; i < CHECK_COUNT ; i++) {
5193 for (j = 0 ; j < 2 ; j++) {
5194 if (!strcmp(name, check_pair_name[i][j])) {
5195 check_pair_value[i][j] = va_arg((var_args), int);
5196 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5204 if (matched == FALSE)
5205 va_arg((var_args), int);
5208 case MM_ATTRS_TYPE_DOUBLE:
5209 va_arg((var_args), double);
5211 case MM_ATTRS_TYPE_STRING:
5212 va_arg((var_args), char*); /* string */
5213 va_arg((var_args), int); /* size */
5215 case MM_ATTRS_TYPE_DATA:
5216 va_arg((var_args), void*); /* data */
5217 va_arg((var_args), int); /* size */
5219 case MM_ATTRS_TYPE_INVALID:
5221 MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5223 *err_attr_name = strdup(name);
5225 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5229 name = va_arg(var_args, const char*);
5232 for (i = 0 ; i < CHECK_COUNT ; i++) {
5233 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5234 gboolean check_result = FALSE;
5235 char *err_name = NULL;
5236 MMCamAttrsInfo attr_info_0, attr_info_1;
5238 if (check_pair_value[i][0] == INIT_VALUE) {
5239 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5240 err_name = strdup(check_pair_name[i][1]);
5241 } else if (check_pair_value[i][1] == INIT_VALUE) {
5242 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5243 err_name = strdup(check_pair_name[i][0]);
5245 err_name = strdup(check_pair_name[i][2]);
5248 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5249 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5251 check_result = FALSE;
5253 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5254 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5255 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5257 MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5258 check_pair_name[i][0], check_pair_name[i][1],
5259 check_pair_value[i][0], check_pair_value[i][1], i);
5261 check_result = TRUE;
5266 if (check_result == FALSE) {
5267 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5268 check_pair_name[i][0], check_pair_name[i][1],
5269 check_pair_value[i][0], check_pair_value[i][1]);
5270 if (err_attr_name) {
5271 *err_attr_name = err_name;
5279 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5282 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5283 int current_width = 0;
5284 int current_height = 0;
5286 mm_camcorder_get_attributes(handle, NULL,
5287 MMCAM_CAMERA_WIDTH, ¤t_width,
5288 MMCAM_CAMERA_HEIGHT, ¤t_height,
5291 if (current_width != check_pair_value[i][0] ||
5292 current_height != check_pair_value[i][1]) {
5293 hcamcorder->resolution_changed = TRUE;
5295 hcamcorder->resolution_changed = FALSE;
5298 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5308 /*MMCAM_LOG_INFO("DONE");*/
5310 return MM_ERROR_NONE;
5314 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5318 if ((void *)handle == NULL) {
5319 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5323 memset(&info, 0x0, sizeof(MMAttrsInfo));
5325 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5327 switch (info.validity_type) {
5328 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5330 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5332 if (info.int_array.count < 1)
5335 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5337 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5339 if (info.int_range.min > info.int_range.max)
5342 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5344 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5346 if (info.double_array.count < 1)
5349 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5351 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5353 if (info.double_range.min >= info.double_range.max)
5357 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);