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,
1715 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1717 for (idx = 0 ; idx < attr_count ; idx++) {
1718 /* attribute order check. This should be same. */
1719 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1720 MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1721 free(attrs_const_info);
1722 attrs_const_info = NULL;
1723 free(hcamcorder->cam_attrs_const_info);
1724 hcamcorder->cam_attrs_const_info = NULL;
1728 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1729 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1730 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1731 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1734 /* Camcorder Attributes */
1735 MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1737 ret = mm_attrs_new(attrs_const_info,
1739 "Camcorder_Attributes",
1740 _mmcamcorder_commit_camcorder_attrs,
1744 free(attrs_const_info);
1745 attrs_const_info = NULL;
1747 if (ret != MM_ERROR_NONE) {
1748 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1749 free(hcamcorder->cam_attrs_const_info);
1750 hcamcorder->cam_attrs_const_info = NULL;
1754 __mmcamcorder_set_conf_to_valid_info(handle);
1756 for (idx = 0; idx < attr_count; idx++) {
1757 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1759 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1761 switch (attr_info->validity_type) {
1762 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1763 if (attr_info->validity_value_1.int_array &&
1764 attr_info->validity_value_2.count > 0) {
1765 mm_attrs_set_valid_array(attrs, idx,
1766 (const int *)(attr_info->validity_value_1.int_array),
1767 attr_info->validity_value_2.count,
1768 attr_info->default_value.value_int);
1771 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1772 mm_attrs_set_valid_range(attrs, idx,
1773 attr_info->validity_value_1.int_min,
1774 attr_info->validity_value_2.int_max,
1775 attr_info->default_value.value_int);
1777 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1778 if (attr_info->validity_value_1.double_array &&
1779 attr_info->validity_value_2.count > 0) {
1780 mm_attrs_set_valid_double_array(attrs, idx,
1781 (const double *)(attr_info->validity_value_1.double_array),
1782 attr_info->validity_value_2.count,
1783 attr_info->default_value.value_double);
1786 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1787 mm_attrs_set_valid_double_range(attrs, idx,
1788 attr_info->validity_value_1.double_min,
1789 attr_info->validity_value_2.double_max,
1790 attr_info->default_value.value_double);
1792 case MM_ATTRS_VALID_TYPE_NONE:
1794 case MM_ATTRS_VALID_TYPE_INVALID:
1796 MMCAM_LOG_ERROR("Valid type error.");
1801 __mmcamcorder_release_conf_valid_info(handle);
1808 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1810 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1812 if (hcamcorder == NULL) {
1813 MMCAM_LOG_ERROR("handle is NULL");
1820 mm_attrs_free(attrs);
1821 MMCAM_LOG_INFO("released attribute");
1824 if (hcamcorder->cam_attrs_const_info) {
1825 free(hcamcorder->cam_attrs_const_info);
1826 hcamcorder->cam_attrs_const_info = NULL;
1827 MMCAM_LOG_INFO("released attribute info");
1835 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1837 MMHandleType attrs = 0;
1838 int ret = MM_ERROR_NONE;
1840 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1841 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1843 attrs = MMF_CAMCORDER_ATTRS(handle);
1844 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1846 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1853 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1855 MMHandleType attrs = 0;
1856 int ret = MM_ERROR_NONE;
1858 char *tmp_err_attr_name = NULL;
1859 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1860 va_list var_args_copy;
1862 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1864 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1865 MMCAM_LOG_ERROR("Another command is running.");
1866 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1869 /* copy var_args to keep original var_args */
1870 va_copy(var_args_copy, var_args);
1872 attrs = MMF_CAMCORDER_ATTRS(handle);
1874 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1876 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1877 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1880 if (ret == MM_ERROR_NONE) {
1881 hcamcorder->error_code = MM_ERROR_NONE;
1882 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1883 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1886 va_end(var_args_copy);
1888 _MMCAMCORDER_UNLOCK_CMD(handle);
1890 if (ret != MM_ERROR_NONE) {
1891 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1892 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1893 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1894 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1895 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1896 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1900 if (hcamcorder->error_code != MM_ERROR_NONE) {
1901 MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1902 ret = hcamcorder->error_code;
1903 hcamcorder->error_code = MM_ERROR_NONE;
1906 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1909 if (tmp_err_attr_name) {
1910 if (!err_attr_name) {
1911 MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1912 free(tmp_err_attr_name);
1913 tmp_err_attr_name = NULL;
1915 *err_attr_name = tmp_err_attr_name;
1924 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1926 MMHandleType attrs = 0;
1927 MMAttrsInfo attrinfo;
1928 int ret = MM_ERROR_NONE;
1930 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1931 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1932 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1934 attrs = MMF_CAMCORDER_ATTRS(handle);
1935 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1937 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1939 if (ret == MM_ERROR_NONE) {
1940 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1941 info->type = attrinfo.type;
1942 info->flag = attrinfo.flag;
1943 info->validity_type = attrinfo.validity_type;
1945 switch (attrinfo.validity_type) {
1946 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1947 info->int_array.array = attrinfo.int_array.array;
1948 info->int_array.count = attrinfo.int_array.count;
1949 info->int_array.def = attrinfo.int_array.dval;
1951 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1952 info->int_range.min = attrinfo.int_range.min;
1953 info->int_range.max = attrinfo.int_range.max;
1954 info->int_range.def = attrinfo.int_range.dval;
1956 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1957 info->double_array.array = attrinfo.double_array.array;
1958 info->double_array.count = attrinfo.double_array.count;
1959 info->double_array.def = attrinfo.double_array.dval;
1961 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1962 info->double_range.min = attrinfo.double_range.min;
1963 info->double_range.max = attrinfo.double_range.max;
1964 info->double_range.def = attrinfo.double_range.dval;
1966 case MM_ATTRS_VALID_TYPE_NONE:
1968 case MM_ATTRS_VALID_TYPE_INVALID:
1979 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1982 mmf_camcorder_t *hcamcorder = NULL;
1984 mmf_return_val_if_fail(commit_param, FALSE);
1985 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1986 mmf_return_val_if_fail(attr_name, FALSE);
1987 mmf_return_val_if_fail(value, FALSE);
1989 hcamcorder = MMF_CAMCORDER(commit_param);
1991 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1992 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
2000 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
2003 int total_count = 0;
2005 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2007 if (hcamcorder == NULL) {
2008 MMCAM_LOG_ERROR("handle is NULL");
2009 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2013 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
2014 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
2015 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
2018 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
2019 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
2020 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
2023 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
2024 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
2025 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
2028 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
2029 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
2030 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
2032 return MM_ERROR_NONE;
2036 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
2038 int *allocated_memory = NULL;
2040 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2042 if (hcamcorder == NULL) {
2043 MMCAM_LOG_ERROR("handle is NULL");
2044 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2047 MMCAM_LOG_INFO("START");
2049 /* Audio encoder info */
2050 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2051 if (allocated_memory) {
2052 g_free(allocated_memory);
2053 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2054 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2057 /* Video encoder info */
2058 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2059 if (allocated_memory) {
2060 g_free(allocated_memory);
2061 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2062 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2065 /* Image encoder info */
2066 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2067 if (allocated_memory) {
2068 g_free(allocated_memory);
2069 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2070 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2073 /* File format info */
2074 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2075 if (allocated_memory) {
2076 g_free(allocated_memory);
2077 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2078 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2081 MMCAM_LOG_INFO("DONE");
2083 return MM_ERROR_NONE;
2087 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2089 MMHandleType attr = 0;
2090 int current_state = MM_CAMCORDER_STATE_NONE;
2092 mmf_return_val_if_fail(handle && value, FALSE);
2094 attr = MMF_CAMCORDER_ATTRS(handle);
2095 mmf_return_val_if_fail(attr, FALSE);
2097 /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2099 current_state = _mmcamcorder_get_state(handle);
2100 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2101 int flags = MM_ATTRS_FLAG_NONE;
2102 int capture_width, capture_height;
2103 MMCamAttrsInfo info;
2105 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2108 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2109 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2110 capture_width = value->value.i_val;
2112 /* Check whether they are valid pair */
2113 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2118 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2124 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2126 int current_state = MM_CAMCORDER_STATE_NONE;
2128 current_state = _mmcamcorder_get_state(handle);
2130 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2131 int capture_width, capture_height;
2133 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2134 capture_height = value->value.i_val;
2136 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2138 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2145 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2147 int current_state = 0;
2149 _MMCamcorderSubContext *sc = NULL;
2150 _MMCamcorderImageInfo *info = NULL;
2151 GstCameraControl *control = NULL;
2153 mmf_return_val_if_fail(handle && value, FALSE);
2155 current_state = _mmcamcorder_get_state(handle);
2156 ivalue = value->value.i_val;
2158 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2162 info = sc->info_image;
2164 MMCAM_LOG_ERROR("info image is NULL");
2168 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2169 if (info->capture_send_count > 0) {
2170 info->capturing = FALSE;
2171 MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2174 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2175 MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2179 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2181 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2182 MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2184 MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2187 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2194 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2196 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2197 int current_state = MM_CAMCORDER_STATE_NONE;
2198 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2200 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2202 current_state = _mmcamcorder_get_state(handle);
2203 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2205 MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2206 current_state, mode, value->value.i_val);
2208 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2209 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2212 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2218 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2220 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2222 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2224 MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2226 /* return error when disable shutter sound if policy is TRUE */
2227 if (!value->value.i_val &&
2228 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2229 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2232 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2238 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2240 int current_state = MM_CAMCORDER_STATE_NONE;
2241 _MMCamcorderSubContext *sc = NULL;
2244 mmf_return_val_if_fail(handle && value, FALSE);
2246 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2250 current_state = _mmcamcorder_get_state(handle);
2252 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2253 double mslNewVal = 0;
2254 mslNewVal = value->value.d_val;
2256 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2257 if (mslNewVal == 0.0) {
2258 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2259 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2261 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2262 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2266 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2269 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2277 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2279 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2280 int current_state = MM_CAMCORDER_STATE_NONE;
2282 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2284 current_state = _mmcamcorder_get_state(handle);
2285 if (current_state > MM_CAMCORDER_STATE_READY) {
2286 MMCAM_LOG_ERROR("invalid state %d", current_state);
2287 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2295 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2297 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2298 MMCamAttrsInfo fps_info;
2299 int resolution_width = 0;
2300 int resolution_height = 0;
2303 int current_state = MM_CAMCORDER_STATE_NONE;
2305 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2307 current_state = _mmcamcorder_get_state(handle);
2308 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2309 MMCAM_LOG_ERROR("invalid state %d", current_state);
2310 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2314 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2317 MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2319 ret = mm_camcorder_get_attributes(handle, NULL,
2320 MMCAM_CAMERA_WIDTH, &resolution_width,
2321 MMCAM_CAMERA_HEIGHT, &resolution_height,
2324 if (ret != MM_ERROR_NONE) {
2325 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2329 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2330 if (ret != MM_ERROR_NONE) {
2331 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2335 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2336 if (value->value.i_val == fps_info.int_array.array[i])
2340 MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2346 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2348 int current_state = MM_CAMCORDER_STATE_NONE;
2349 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2350 _MMCamcorderSubContext *sc = NULL;
2352 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2354 current_state = _mmcamcorder_get_state(handle);
2355 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2356 MMCAM_LOG_WARNING("invalid state %d", current_state);
2357 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2361 /* Verify recording motion rate */
2362 if (value->value.d_val > 0.0) {
2363 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2367 /* set is_slow flag */
2368 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2369 sc->is_modified_rate = TRUE;
2371 sc->is_modified_rate = FALSE;
2373 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2376 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2382 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2384 MMHandleType attr = 0;
2385 int current_state = MM_CAMCORDER_STATE_NONE;
2387 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2388 _MMCamcorderSubContext *sc = NULL;
2390 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2392 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2396 attr = MMF_CAMCORDER_ATTRS(handle);
2397 mmf_return_val_if_fail(attr, FALSE);
2399 MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2401 current_state = _mmcamcorder_get_state(handle);
2403 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2404 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2407 int flags = MM_ATTRS_FLAG_NONE;
2408 MMCamAttrsInfo info;
2409 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2412 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2413 int width = value->value.i_val;
2415 int preview_format = MM_PIXEL_FORMAT_NV12;
2416 int codec_type = MM_IMAGE_CODEC_JPEG;
2418 mm_camcorder_get_attributes(handle, NULL,
2419 MMCAM_CAMERA_HEIGHT, &height,
2420 MMCAM_CAMERA_FORMAT, &preview_format,
2421 MMCAM_IMAGE_ENCODER, &codec_type,
2424 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2425 if (hcamcorder->resolution_changed == FALSE) {
2426 MMCAM_LOG_INFO("no need to restart preview");
2430 hcamcorder->resolution_changed = FALSE;
2432 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2433 MMCAM_LOG_INFO("restart preview");
2435 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2436 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2438 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2439 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2441 /* check decoder recreation */
2442 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2443 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2444 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2448 /* get preview format */
2449 sc->info_image->preview_format = preview_format;
2450 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2451 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2453 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2454 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2456 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2457 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2460 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2462 MMCAM_LOG_ERROR("currently locked for preview restart");
2466 /* get preview format */
2467 sc->info_image->preview_format = preview_format;
2468 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2469 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2480 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2483 int current_state = MM_CAMCORDER_STATE_NONE;
2484 MMHandleType attr = 0;
2485 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2486 _MMCamcorderSubContext *sc = NULL;
2488 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2490 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2494 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2495 mmf_return_val_if_fail(attr, FALSE);
2497 MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2498 current_state = _mmcamcorder_get_state(handle);
2500 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2501 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2502 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2506 int height = value->value.i_val;
2507 int preview_format = MM_PIXEL_FORMAT_NV12;
2508 int codec_type = MM_IMAGE_CODEC_JPEG;
2509 int video_stabilization = 0;
2511 mm_camcorder_get_attributes(handle, NULL,
2512 MMCAM_CAMERA_WIDTH, &width,
2513 MMCAM_CAMERA_FORMAT, &preview_format,
2514 MMCAM_IMAGE_ENCODER, &codec_type,
2515 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2518 sc->info_video->preview_width = width;
2519 sc->info_video->preview_height = height;
2521 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2522 if (hcamcorder->resolution_changed == FALSE) {
2523 MMCAM_LOG_INFO("no need to restart preview");
2527 hcamcorder->resolution_changed = FALSE;
2529 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2530 MMCAM_LOG_INFO("restart preview");
2532 MMCAM_LOG_INFO("set empty buffers");
2534 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2535 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2537 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2538 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2540 /* check decoder recreation */
2541 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2542 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2543 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2547 /* get preview format */
2548 sc->info_image->preview_format = preview_format;
2549 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2551 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2553 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2554 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2556 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2557 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2560 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2562 MMCAM_LOG_ERROR("currently locked for preview restart");
2566 /* get preview format */
2567 sc->info_image->preview_format = preview_format;
2568 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2569 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2577 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2579 int current_state = MM_CAMCORDER_STATE_NONE;
2580 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2582 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2584 current_state = _mmcamcorder_get_state(handle);
2585 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2586 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2587 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2590 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2591 value->value.i_val, attr_idx);
2597 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2599 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2600 _MMCamcorderSubContext *sc = NULL;
2601 int current_state = MM_CAMCORDER_STATE_NONE;
2602 GstCameraControl *control = NULL;
2606 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2608 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2612 zoom_level = value->value.i_val;
2614 MMCAM_LOG_INFO("(%d)", attr_idx);
2616 current_state = _mmcamcorder_get_state(handle);
2617 if (current_state < MM_CAMCORDER_STATE_READY) {
2618 MMCAM_LOG_INFO("will be applied when preview starts");
2620 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2621 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2622 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2626 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2627 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2629 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2631 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2634 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2635 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2639 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2640 if (control == NULL) {
2641 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2645 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2647 MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2650 MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2653 MMCAM_LOG_INFO("pointer of video src is null");
2660 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2662 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2663 _MMCamcorderSubContext *sc = NULL;
2664 int current_state = MM_CAMCORDER_STATE_NONE;
2666 GstCameraControl *CameraControl = NULL;
2667 GstCameraControlChannel *CameraControlChannel = NULL;
2668 const GList *controls = NULL;
2669 const GList *item = NULL;
2671 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2673 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2674 mmf_return_val_if_fail(sc, TRUE);
2676 MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2678 current_state = _mmcamcorder_get_state(handle);
2679 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2680 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2681 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2682 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2686 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2687 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2688 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2692 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2693 if (CameraControl == NULL) {
2694 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2698 controls = gst_camera_control_list_channels(CameraControl);
2699 if (controls == NULL) {
2700 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2704 for (item = controls ; item && item->data ; item = item->next) {
2705 CameraControlChannel = item->data;
2706 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2707 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2708 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2709 MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2712 MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2718 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2725 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2727 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2728 _MMCamcorderSubContext *sc = NULL;
2729 int current_state = MM_CAMCORDER_STATE_NONE;
2731 GstCameraControl *CameraControl = NULL;
2732 GstCameraControlChannel *CameraControlChannel = NULL;
2733 const GList *controls = NULL;
2734 const GList *item = NULL;
2736 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2738 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2739 mmf_return_val_if_fail(sc, TRUE);
2741 MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2743 current_state = _mmcamcorder_get_state(handle);
2744 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2745 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2746 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2747 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2751 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2752 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2753 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2757 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2758 if (CameraControl == NULL) {
2759 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2763 controls = gst_camera_control_list_channels(CameraControl);
2764 if (controls == NULL) {
2765 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2769 for (item = controls ; item && item->data ; item = item->next) {
2770 CameraControlChannel = item->data;
2771 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2772 if (!strcmp(CameraControlChannel->label, "pan")) {
2773 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2774 MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2777 MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2783 MMCAM_LOG_WARNING("failed to find pan control channel");
2790 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2792 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2793 _MMCamcorderSubContext *sc = NULL;
2794 int current_state = MM_CAMCORDER_STATE_NONE;
2796 GstCameraControl *CameraControl = NULL;
2797 GstCameraControlChannel *CameraControlChannel = NULL;
2798 const GList *controls = NULL;
2799 const GList *item = NULL;
2801 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2803 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2804 mmf_return_val_if_fail(sc, TRUE);
2806 MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2808 current_state = _mmcamcorder_get_state(handle);
2809 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2810 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2811 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2812 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2816 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2817 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2818 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2822 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2823 if (CameraControl == NULL) {
2824 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2828 controls = gst_camera_control_list_channels(CameraControl);
2829 if (controls == NULL) {
2830 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2834 for (item = controls ; item && item->data ; item = item->next) {
2835 CameraControlChannel = item->data;
2836 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2837 if (!strcmp(CameraControlChannel->label, "tilt")) {
2838 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2839 MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2842 MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2848 MMCAM_LOG_WARNING("failed to find tilt control channel");
2855 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2857 MMHandleType attr = 0;
2858 int current_state = MM_CAMCORDER_STATE_NONE;
2859 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2860 _MMCamcorderSubContext *sc = NULL;
2861 GstCameraControl *control = NULL;
2863 int set_focus_mode = 0;
2864 int cur_focus_mode = 0;
2865 int cur_focus_range = 0;
2867 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2869 attr = MMF_CAMCORDER_ATTRS(handle);
2870 mmf_return_val_if_fail(attr, FALSE);
2872 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2876 MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2878 /* check whether set or not */
2879 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2880 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2884 current_state = _mmcamcorder_get_state(handle);
2885 if (current_state < MM_CAMCORDER_STATE_NULL) {
2886 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2888 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2889 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2890 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2894 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2895 int flags = MM_ATTRS_FLAG_NONE;
2896 MMCamAttrsInfo info;
2898 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2899 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2903 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2904 if (control == NULL) {
2905 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2909 mslVal = value->value.i_val;
2910 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2912 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2915 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2916 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2917 if (set_focus_mode != cur_focus_mode) {
2918 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2919 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2922 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2925 MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2929 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2933 MMCAM_LOG_INFO("pointer of video src is null");
2940 bool _mmcamcorder_commit_camera_focus_level(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2942 int current_state = MM_CAMCORDER_STATE_NONE;
2943 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2944 _MMCamcorderSubContext *sc = NULL;
2945 GstCameraControl *control = NULL;
2947 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2949 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2953 MMCAM_LOG_INFO("Focus level[%d]", value->value.i_val);
2955 current_state = _mmcamcorder_get_state(handle);
2956 if (current_state < MM_CAMCORDER_STATE_READY) {
2957 MMCAM_LOG_INFO("Focus level will be set later.(state=%d)", current_state);
2959 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2960 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2961 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2965 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2966 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
2970 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2971 if (control == NULL) {
2972 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2976 if (!gst_camera_control_set_focus_level(control, value->value.i_val)) {
2977 MMCAM_LOG_ERROR("set focus level[%d[ failed", value->value.i_val);
2985 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2987 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2988 _MMCamcorderSubContext *sc = NULL;
2989 GstCameraControl *control = NULL;
2990 int current_state = MM_CAMCORDER_STATE_NONE;
2993 int cur_focus_mode = 0;
2994 int cur_focus_range = 0;
2995 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2996 int converted_mode = 0;
2998 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3000 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3004 MMCAM_LOG_INFO("(%d)", attr_idx);
3006 /* check whether set or not */
3007 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3008 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3012 mslVal = value->value.i_val;
3013 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3015 current_state = _mmcamcorder_get_state(handle);
3016 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3017 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3019 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3020 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3021 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3025 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3026 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3027 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3031 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3032 if (control == NULL) {
3033 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3037 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
3038 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
3040 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
3041 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
3042 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
3043 /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
3046 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
3049 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
3053 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
3056 MMCAM_LOG_INFO("pointer of video src is null");
3063 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3065 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3066 _MMCamcorderSubContext *sc = NULL;
3067 GstCameraControl *control = NULL;
3068 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
3069 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
3071 int current_state = MM_CAMCORDER_STATE_NONE;
3073 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3075 gboolean do_set = FALSE;
3077 MMCamAttrsInfo info_y;
3078 MMCamAttrsInfo info_w;
3079 MMCamAttrsInfo info_h;
3081 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3083 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3087 MMCAM_LOG_INFO("(%d)", attr_idx);
3089 current_state = _mmcamcorder_get_state(handle);
3090 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3091 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3093 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3094 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3095 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3099 ret = mm_camcorder_get_attributes(handle, NULL,
3100 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3102 if (ret != MM_ERROR_NONE) {
3103 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3107 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3108 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3112 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3113 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3114 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3118 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3119 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3120 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3123 case MM_CAM_CAMERA_AF_TOUCH_X:
3124 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3125 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3126 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3127 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3128 set_area.x = value->value.i_val;
3129 mm_camcorder_get_attributes(handle, NULL,
3130 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3131 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3132 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3136 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3140 case MM_CAM_CAMERA_AF_TOUCH_Y:
3141 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3142 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3143 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3144 set_area.y = value->value.i_val;
3145 mm_camcorder_get_attributes(handle, NULL,
3146 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3147 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3148 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3152 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3156 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3157 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3158 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3159 set_area.width = value->value.i_val;
3160 mm_camcorder_get_attributes(handle, NULL,
3161 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3162 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3163 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3167 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3171 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3172 set_area.height = value->value.i_val;
3173 mm_camcorder_get_attributes(handle, NULL,
3174 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3175 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3176 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3185 _MMCamcorderVideoInfo *info = sc->info_video;
3188 MMCAM_LOG_ERROR("video info is NULL");
3192 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3193 if (control == NULL) {
3194 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3199 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3200 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3201 float ratio_width = 0.0;
3202 float ratio_height = 0.0;
3204 if (info->preview_width != 0 && info->preview_height != 0) {
3205 ratio_width = (float)info->video_width / (float)info->preview_width;
3206 ratio_height = (float)info->video_height / (float)info->preview_height;
3208 MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3209 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3211 set_area.x = (int)((float)set_area.x * ratio_width);
3212 set_area.y = (int)((float)set_area.y * ratio_height);
3213 set_area.width = (int)((float)set_area.width * ratio_width);
3214 set_area.height = (int)((float)set_area.height * ratio_height);
3216 if (set_area.width <= 0)
3219 if (set_area.height <= 0)
3220 set_area.height = 1;
3222 MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3223 set_area.x, set_area.y, set_area.width, set_area.height);
3225 MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3226 info->preview_width, info->preview_height);
3230 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3232 MMCAM_LOG_WARNING("Failed to get AF area");
3236 /* width and height are not supported now */
3237 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3238 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3239 get_area.x, get_area.y);
3243 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3245 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3246 set_area.x, set_area.y, set_area.width, set_area.height);
3249 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3250 set_area.x, set_area.y, set_area.width, set_area.height);
3254 MMCAM_LOG_INFO("pointer of video src is null");
3261 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3263 GstCameraControl *control = NULL;
3269 int exposure_type = 0;
3270 int current_state = MM_CAMCORDER_STATE_NONE;
3271 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3272 _MMCamcorderSubContext *sc = NULL;
3274 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3275 gboolean check_scene_mode = FALSE;
3277 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3279 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3283 /* check whether set or not */
3284 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3285 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3289 current_state = _mmcamcorder_get_state(handle);
3290 if (current_state < MM_CAMCORDER_STATE_READY) {
3291 MMCAM_LOG_INFO("will be applied when preview starts");
3293 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3294 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3295 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3299 ivalue = value->value.i_val;
3301 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3302 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3303 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3304 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3305 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3306 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3307 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3308 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3309 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3310 exposure_type = GST_CAMERA_CONTROL_ISO;
3312 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3313 check_scene_mode = TRUE;
3314 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3315 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3317 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3318 check_scene_mode = TRUE;
3319 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3320 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3321 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3322 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3325 if (check_scene_mode) {
3326 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3327 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3328 MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3333 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3336 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3337 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3341 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3342 if (control == NULL) {
3343 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3347 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3349 MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3352 MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3355 MMCAM_LOG_INFO("pointer of video src is null");
3362 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3364 GstCameraControl *control = NULL;
3368 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3369 _MMCamcorderSubContext *sc = NULL;
3370 int current_state = MM_CAMCORDER_STATE_NONE;
3372 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3374 /* check whether set or not */
3375 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3376 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3380 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3384 /* check current state */
3385 current_state = _mmcamcorder_get_state(handle);
3386 if (current_state < MM_CAMCORDER_STATE_READY) {
3387 MMCAM_LOG_INFO("will be applied when preview starts");
3389 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3390 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3391 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3395 mslVal = value->value.i_val;
3396 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3398 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3399 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3400 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3404 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3405 if (control == NULL) {
3406 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3410 if (gst_camera_control_get_wdr(control, &cur_value)) {
3411 if (newVal != cur_value) {
3412 if (gst_camera_control_set_wdr(control, newVal)) {
3413 MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3416 MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3419 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3423 MMCAM_LOG_WARNING("Failed to get WDR.");
3426 MMCAM_LOG_INFO("pointer of video src is null");
3433 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3435 int current_state = MM_CAMCORDER_STATE_NONE;
3436 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3438 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3440 /* check whether set or not */
3441 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3442 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3446 current_state = _mmcamcorder_get_state(handle);
3447 if (current_state < MM_CAMCORDER_STATE_READY) {
3448 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3450 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3451 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3452 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3456 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3460 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3464 int current_state = MM_CAMCORDER_STATE_NONE;
3465 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3466 _MMCamcorderSubContext *sc = NULL;
3468 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3470 bitrate = value->value.i_val;
3472 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3473 if (!sc || !sc->encode_element) {
3474 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3478 current_state = _mmcamcorder_get_state(handle);
3479 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3480 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3481 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3485 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3486 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3488 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3489 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3491 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3492 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3499 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3501 int current_state = MM_CAMCORDER_STATE_NONE;
3502 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3504 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3506 current_state = _mmcamcorder_get_state(handle);
3507 if (current_state < MM_CAMCORDER_STATE_READY) {
3508 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3510 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3511 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3512 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3516 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3520 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3522 int current_state = MM_CAMCORDER_STATE_NONE;
3523 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3525 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3527 MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3529 current_state = _mmcamcorder_get_state(handle);
3531 if (current_state > MM_CAMCORDER_STATE_READY) {
3532 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3533 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3536 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3541 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3543 int current_state = MM_CAMCORDER_STATE_NONE;
3545 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3546 _MMCamcorderSubContext *sc = NULL;
3548 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3551 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3552 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3556 /* check current state */
3557 current_state = _mmcamcorder_get_state(handle);
3558 if (current_state < MM_CAMCORDER_STATE_READY) {
3559 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3561 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3562 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3563 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3567 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3569 MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3571 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3572 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3575 MMCAM_LOG_ERROR("invalid state %d", current_state);
3581 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3583 mmf_return_val_if_fail(handle && value, FALSE);
3586 if (!value->value.s_val) {
3587 MMCAM_LOG_ERROR("NULL filename");
3591 MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3597 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3599 int current_state = MM_CAMCORDER_STATE_NONE;
3600 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3602 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3604 current_state = _mmcamcorder_get_state(handle);
3605 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3606 MMCAM_LOG_ERROR("Can not set while RECORDING");
3607 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3615 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3617 GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3618 MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3619 return strcmp(Colorchannel->label, user_data);
3622 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3624 GstColorBalance *balance = NULL;
3625 GstColorBalanceChannel *Colorchannel = NULL;
3626 GList *controls = NULL;
3630 int current_state = MM_CAMCORDER_STATE_NONE;
3631 const char *control_label = NULL;
3632 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3633 _MMCamcorderSubContext *sc = NULL;
3635 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3636 gboolean check_scene_mode = FALSE;
3638 int wb_temp_table[] = {
3639 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3640 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3641 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3642 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3643 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3644 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3647 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3649 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3653 /* check whether set or not */
3654 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3655 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3659 current_state = _mmcamcorder_get_state(handle);
3660 if (current_state < MM_CAMCORDER_STATE_READY) {
3661 MMCAM_LOG_INFO("will be applied when preview starts");
3663 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3664 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3665 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3669 if (value->type != MM_ATTRS_TYPE_INT) {
3670 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3674 mslVal = value->value.i_val;
3677 case MM_CAM_FILTER_BRIGHTNESS:
3678 control_label = "brightness";
3679 check_scene_mode = TRUE;
3681 case MM_CAM_FILTER_CONTRAST:
3682 control_label = "contrast";
3684 case MM_CAM_FILTER_WB:
3685 control_label = "white balance";
3686 check_scene_mode = TRUE;
3688 case MM_CAM_FILTER_COLOR_TONE:
3689 control_label = "color tone";
3691 case MM_CAM_FILTER_SATURATION:
3692 control_label = "saturation";
3693 check_scene_mode = TRUE;
3695 case MM_CAM_FILTER_HUE:
3696 control_label = "hue";
3698 case MM_CAM_FILTER_SHARPNESS:
3699 control_label = "sharpness";
3700 check_scene_mode = TRUE;
3703 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3707 if (check_scene_mode) {
3708 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3709 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3710 MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3715 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3716 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3719 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3720 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3724 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3725 if (balance == NULL) {
3726 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3730 controls = (GList *)gst_color_balance_list_channels(balance);
3731 if (controls == NULL) {
3732 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3737 MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3738 attr_idx, control_label, mslVal, newVal);
3740 item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3742 Colorchannel = item->data;
3743 gst_color_balance_set_value(balance, Colorchannel, newVal);
3744 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3748 if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3749 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3751 control_label = "white_balance_temperature_auto";
3754 newVal = wb_temp_table[mslVal];
3755 control_label = "white_balance_temperature";
3760 MMCAM_LOG_ERROR("failed to find color channel item");
3766 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3770 int current_state = MM_CAMCORDER_STATE_NONE;
3771 GstCameraControl *control = NULL;
3772 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3773 _MMCamcorderSubContext *sc = NULL;
3775 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3777 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3781 mslVal = value->value.i_val;
3782 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3784 /* check whether set or not */
3785 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3786 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3790 current_state = _mmcamcorder_get_state(handle);
3791 if (current_state < MM_CAMCORDER_STATE_READY) {
3792 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3794 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3795 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3796 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3800 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3803 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3804 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3808 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3809 if (control == NULL) {
3810 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3814 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3816 MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3818 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3822 MM_CAM_FILTER_BRIGHTNESS,
3824 MM_CAM_FILTER_SATURATION,
3825 MM_CAM_FILTER_SHARPNESS,
3826 MM_CAM_FILTER_COLOR_TONE,
3827 MM_CAM_CAMERA_EXPOSURE_MODE
3829 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3831 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3832 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3833 mm_attrs_set_modified(attrs, attr_idxs[i]);
3839 MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3842 MMCAM_LOG_WARNING("pointer of video src is null");
3849 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3851 mmf_return_val_if_fail(handle && value, FALSE);
3853 MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3859 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3861 mmf_return_val_if_fail(handle && value, FALSE);
3863 MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3869 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3871 int current_state = MM_CAMCORDER_STATE_NONE;
3872 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3874 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3876 current_state = _mmcamcorder_get_state(handle);
3877 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3878 MMCAM_LOG_WARNING("Can NOT Disable AUDIO. invalid state %d", current_state);
3879 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3882 MMCAM_LOG_INFO("Disable AUDIO when Recording");
3888 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3890 int current_state = MM_CAMCORDER_STATE_NONE;
3891 const char *videosink_name = NULL;
3892 void *dp_handle = NULL;
3893 MMCamWindowInfo *window_info = NULL;
3895 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3896 _MMCamcorderSubContext *sc = NULL;
3898 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3901 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3902 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3906 /* check current state */
3907 current_state = _mmcamcorder_get_state(handle);
3908 if (current_state < MM_CAMCORDER_STATE_READY) {
3909 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3913 dp_handle = value->value.p_val;
3915 MMCAM_LOG_WARNING("Display handle is NULL");
3919 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3921 /* get videosink name */
3922 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3923 if (!videosink_name) {
3924 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3928 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3930 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3931 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
3932 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
3933 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3934 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
3935 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
3936 } else if (!strcmp(videosink_name, "tizenwlsink")) {
3937 window_info = (MMCamWindowInfo *)dp_handle;
3938 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
3939 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3940 } else if (!strcmp(videosink_name, "directvideosink")) {
3941 window_info = (MMCamWindowInfo *)dp_handle;
3942 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
3943 window_info->surface_id,
3944 window_info->rect.x,
3945 window_info->rect.y,
3946 window_info->rect.width,
3947 window_info->rect.height);
3948 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3949 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3950 window_info->rect.x,
3951 window_info->rect.y,
3952 window_info->rect.width,
3953 window_info->rect.height);
3955 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
3963 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3965 int current_state = MM_CAMCORDER_STATE_NONE;
3966 const char *videosink_name = NULL;
3968 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3969 _MMCamcorderSubContext *sc = NULL;
3971 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3974 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3975 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3979 /* check current state */
3980 current_state = _mmcamcorder_get_state(handle);
3981 if (current_state < MM_CAMCORDER_STATE_READY) {
3982 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3986 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3988 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3989 if (videosink_name == NULL) {
3990 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3994 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3996 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3997 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
3998 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
4000 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
4007 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4009 int current_state = MM_CAMCORDER_STATE_NONE;
4011 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4013 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4016 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4017 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4021 /* check current state */
4022 current_state = _mmcamcorder_get_state(handle);
4023 if (current_state < MM_CAMCORDER_STATE_READY) {
4024 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
4028 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4032 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4034 int current_state = MM_CAMCORDER_STATE_NONE;
4036 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4038 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4041 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4042 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4046 /* check current state */
4047 current_state = _mmcamcorder_get_state(handle);
4048 if (current_state < MM_CAMCORDER_STATE_READY) {
4049 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
4053 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4057 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4059 int current_state = MM_CAMCORDER_STATE_NONE;
4060 const char *videosink_name = NULL;
4062 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4063 _MMCamcorderSubContext *sc = NULL;
4065 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4068 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4069 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4073 /* check current state */
4074 current_state = _mmcamcorder_get_state(handle);
4075 if (current_state < MM_CAMCORDER_STATE_READY) {
4076 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4080 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4082 /* Get videosink name */
4083 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4084 if (videosink_name == NULL) {
4085 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4089 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4090 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4091 !strcmp(videosink_name, "directvideosink")) {
4092 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4093 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4095 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4102 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4105 int current_state = MM_CAMCORDER_STATE_NONE;
4106 const char *videosink_name = NULL;
4108 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4109 _MMCamcorderSubContext *sc = NULL;
4111 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4114 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4115 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4119 /* check current state */
4120 current_state = _mmcamcorder_get_state(handle);
4121 if (current_state < MM_CAMCORDER_STATE_READY) {
4122 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4126 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4128 /* Get videosink name */
4129 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4130 if (videosink_name == NULL) {
4131 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4135 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4136 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4137 !strcmp(videosink_name, "directvideosink")) {
4138 method = value->value.i_val;
4139 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4141 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4148 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4150 int current_state = MM_CAMCORDER_STATE_NONE;
4151 int ret = MM_ERROR_NONE;
4152 const char *videosink_name = NULL;
4154 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4155 _MMCamcorderSubContext *sc = NULL;
4157 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4160 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4161 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4165 /* check current state */
4166 current_state = _mmcamcorder_get_state(handle);
4167 if (current_state < MM_CAMCORDER_STATE_READY) {
4168 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4172 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4174 /* Get videosink name */
4175 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4176 if (videosink_name == NULL) {
4177 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4181 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4182 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4186 int rect_height = 0;
4187 int flags = MM_ATTRS_FLAG_NONE;
4188 MMCamAttrsInfo info;
4190 mm_camcorder_get_attributes(handle, NULL,
4191 MMCAM_DISPLAY_RECT_X, &rect_x,
4192 MMCAM_DISPLAY_RECT_Y, &rect_y,
4193 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4194 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4197 case MM_CAM_DISPLAY_RECT_X:
4198 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4200 memset(&info, 0x00, sizeof(info));
4201 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4203 memset(&info, 0x00, sizeof(info));
4204 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4207 rect_x = value->value.i_val;
4209 case MM_CAM_DISPLAY_RECT_Y:
4210 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4212 memset(&info, 0x00, sizeof(info));
4213 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4216 rect_y = value->value.i_val;
4218 case MM_CAM_DISPLAY_RECT_WIDTH:
4219 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4222 rect_width = value->value.i_val;
4224 case MM_CAM_DISPLAY_RECT_HEIGHT:
4225 rect_height = value->value.i_val;
4228 MMCAM_LOG_ERROR("Wrong attr_idx!");
4232 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4233 MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4235 if (!strcmp(videosink_name, "tizenwlsink")) {
4236 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4237 rect_x, rect_y, rect_width, rect_height);
4239 MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4243 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4244 "dst-roi-x", rect_x,
4245 "dst-roi-y", rect_y,
4246 "dst-roi-w", rect_width,
4247 "dst-roi-h", rect_height,
4252 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4259 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4262 int current_state = MM_CAMCORDER_STATE_NONE;
4263 const char *videosink_name = NULL;
4264 GstElement *vs_element = NULL;
4266 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4267 _MMCamcorderSubContext *sc = NULL;
4269 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4272 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4273 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4277 /* check current state */
4278 current_state = _mmcamcorder_get_state(handle);
4279 if (current_state < MM_CAMCORDER_STATE_READY) {
4280 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4284 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4286 /* Get videosink name */
4287 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4288 if (videosink_name == NULL) {
4289 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4293 zoom = value->value.i_val;
4294 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4295 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4297 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4298 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4302 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4308 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4310 int current_state = MM_CAMCORDER_STATE_NONE;
4312 const char *videosink_name = NULL;
4314 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4315 _MMCamcorderSubContext *sc = NULL;
4317 mmf_return_val_if_fail(handle && value, FALSE);
4320 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4321 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4325 /* check current state */
4326 current_state = _mmcamcorder_get_state(handle);
4327 if (current_state < MM_CAMCORDER_STATE_READY) {
4328 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4332 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4334 do_scaling = value->value.i_val;
4336 /* Get videosink name */
4337 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4338 if (videosink_name == NULL) {
4339 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4343 if (!strcmp(videosink_name, "evaspixmapsink")) {
4344 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4345 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4348 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4354 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4356 _MMCamcorderSubContext *sc = NULL;
4357 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4358 int strobe_type, mslVal, newVal, cur_value;
4359 int current_state = MM_CAMCORDER_STATE_NONE;
4361 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4363 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4367 /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4369 mslVal = value->value.i_val;
4371 /* check flash state */
4372 if (attr_idx == MM_CAM_STROBE_MODE) {
4373 int led_brightness = 0;
4375 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4376 MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4377 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4381 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4383 if (led_brightness > 0 &&
4384 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4385 /* other module already turned on LED */
4386 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4387 MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4391 MMCAM_LOG_INFO("keep going");
4395 current_state = _mmcamcorder_get_state(handle);
4396 if (current_state < MM_CAMCORDER_STATE_READY) {
4397 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4399 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4400 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4401 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4406 case MM_CAM_STROBE_CONTROL:
4407 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4408 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4410 case MM_CAM_STROBE_CAPABILITIES:
4411 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4414 case MM_CAM_STROBE_MODE:
4415 /* check whether set or not */
4416 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4417 MMCAM_LOG_INFO("skip set value %d", mslVal);
4421 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4422 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4424 case MM_CAM_STROBE_BRIGHTNESS:
4425 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4429 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4433 GstCameraControl *control = NULL;
4434 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4435 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4439 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4440 if (control == NULL) {
4441 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4445 if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4446 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4450 if (newVal == cur_value) {
4451 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4455 if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4456 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4460 MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4466 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4469 int current_state = MM_CAMCORDER_STATE_NONE;
4470 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4472 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4474 MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4477 current_state = _mmcamcorder_get_state(handle);
4478 if (current_state > MM_CAMCORDER_STATE_READY) {
4479 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4480 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4482 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4483 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4487 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4489 MMCAM_LOG_INFO("ret %d", ret);
4495 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4497 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4498 int current_state = MM_CAMCORDER_STATE_NONE;
4499 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4500 _MMCamcorderSubContext *sc = NULL;
4502 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4504 /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4506 /* check whether set or not */
4507 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4508 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4513 current_state = _mmcamcorder_get_state(handle);
4514 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4515 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4516 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4520 if (current_state >= MM_CAMCORDER_STATE_READY) {
4521 int current_value = 0;
4523 set_hdr_mode = value->value.i_val;
4524 mm_camcorder_get_attributes(handle, NULL,
4525 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4528 if (set_hdr_mode == current_value) {
4529 MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4533 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4535 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4536 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4537 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4539 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4541 /* check decoder recreation */
4542 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4543 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4547 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4548 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4551 set_hdr_mode = value->value.i_val;
4552 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4553 sc->info_image->hdr_capture_mode = set_hdr_mode;
4554 MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4556 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4557 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4559 MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4568 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4571 _MMCamcorderSubContext *sc = NULL;
4572 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4574 int current_value = 0;
4575 int current_state = MM_CAMCORDER_STATE_NONE;
4576 GstCameraControl *control = NULL;
4578 mmf_return_val_if_fail(handle && value, FALSE);
4580 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4584 /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4587 current_state = _mmcamcorder_get_state(handle);
4588 if (current_state < MM_CAMCORDER_STATE_READY) {
4589 MMCAM_LOG_INFO("will be applied when preview starts");
4593 set_value = value->value.i_val;
4596 case MM_CAM_DETECT_MODE:
4597 /* check whether set or not */
4598 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4599 MMCAM_LOG_INFO("skip set value %d", set_value);
4603 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4605 case MM_CAM_DETECT_NUMBER:
4606 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4608 case MM_CAM_DETECT_FOCUS_SELECT:
4609 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4611 case MM_CAM_DETECT_SELECT_NUMBER:
4612 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4614 case MM_CAM_DETECT_STATUS:
4615 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4618 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4622 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4623 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4626 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4627 if (control == NULL) {
4628 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4632 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4633 if (current_value == set_value) {
4634 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4637 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4638 MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4639 detect_type, set_value);
4642 MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4643 detect_type, set_value);
4648 MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4657 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4659 int current_state = MM_CAMCORDER_STATE_NONE;
4661 mmf_return_val_if_fail(handle && value, FALSE);
4663 MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4666 current_state = _mmcamcorder_get_state(handle);
4667 if (current_state < MM_CAMCORDER_STATE_READY) {
4668 MMCAM_LOG_INFO("will be applied when preview starts");
4672 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4676 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4678 int current_state = MM_CAMCORDER_STATE_NONE;
4679 int preview_format = MM_PIXEL_FORMAT_NV12;
4681 mmf_return_val_if_fail(handle && value, FALSE);
4683 MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4685 /* check preview format */
4686 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4687 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
4688 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4693 current_state = _mmcamcorder_get_state(handle);
4694 if (current_state < MM_CAMCORDER_STATE_READY) {
4695 MMCAM_LOG_INFO("will be applied when preview starts");
4699 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4703 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4705 int stream_index = 0;
4706 char *stream_type = NULL;
4707 _MMCamcorderSubContext *sc = NULL;
4709 mmf_return_val_if_fail(handle && value, FALSE);
4711 stream_type = value->value.s_val;
4713 MMCAM_LOG_ERROR("NULL string");
4717 mm_camcorder_get_attributes(handle, NULL,
4718 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4720 if (stream_index < 0) {
4721 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4725 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4726 if (!sc || !sc->encode_element ||
4727 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4728 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4732 MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4734 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4738 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4740 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4741 int current_state = MM_CAMCORDER_STATE_NONE;
4743 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4745 current_state = _mmcamcorder_get_state(handle);
4746 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4747 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4748 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4755 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4757 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4759 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4761 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4762 /* Replay gain enable */
4763 int current_state = MM_CAMCORDER_STATE_NONE;
4764 int audio_disable = FALSE;
4766 current_state = _mmcamcorder_get_state(handle);
4767 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4768 MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4769 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4773 mm_camcorder_get_attributes(handle, NULL,
4774 MMCAM_AUDIO_DISABLE, &audio_disable,
4777 if (audio_disable) {
4778 MMCAM_LOG_ERROR("audio is disabled");
4779 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4783 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4784 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4785 /* Replay gain reference level */
4786 int replay_gain_enable = FALSE;
4788 mm_camcorder_get_attributes(handle, NULL,
4789 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4792 if (replay_gain_enable == FALSE) {
4793 MMCAM_LOG_ERROR("replay gain is disabled");
4794 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4798 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4800 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4808 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4810 int current_state = MM_CAMCORDER_STATE_NONE;
4811 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4812 _MMCamcorderSubContext *sc = NULL;
4814 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4816 if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4817 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4821 MMCAM_LOG_INFO("Enable extra preview(%d)", value->value.i_val);
4823 current_state = _mmcamcorder_get_state(handle);
4824 if (current_state < MM_CAMCORDER_STATE_READY) {
4825 MMCAM_LOG_INFO("will be set when preview is started");
4829 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4830 mmf_return_val_if_fail(sc, FALSE);
4832 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", value->value.i_val);
4834 MMCAM_LOG_INFO("done");
4840 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4842 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4845 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4849 int attr_idxs_default[] = {
4850 MM_CAM_CAMERA_DIGITAL_ZOOM,
4851 MM_CAM_CAMERA_OPTICAL_ZOOM,
4853 MM_CAM_FILTER_CONTRAST,
4856 MM_CAM_STROBE_BRIGHTNESS
4859 int attr_idxs_extra[] = {
4861 MM_CAM_FILTER_BRIGHTNESS,
4863 MM_CAM_FILTER_SATURATION,
4864 MM_CAM_FILTER_SHARPNESS,
4865 MM_CAM_FILTER_COLOR_TONE,
4866 MM_CAM_CAMERA_EXPOSURE_MODE
4869 mmf_return_val_if_fail(hcamcorder, FALSE);
4871 MMCAM_LOG_INFO("commit some attributes again");
4873 attrs = MMF_CAMCORDER_ATTRS(handle);
4874 if (attrs == NULL) {
4875 MMCAM_LOG_ERROR("Get attribute handle failed.");
4879 /* Get Scene mode */
4880 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4882 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4883 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4884 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4887 /* Set extra if scene mode is NORMAL */
4888 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4889 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4890 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4891 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4894 /* Set scene mode if scene mode is NOT NORMAL */
4895 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4896 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4899 if (mm_attrs_commit_all(attrs) == -1)
4904 MMCAM_LOG_INFO("Done.");
4910 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4912 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4918 MM_CAM_CAMERA_PTZ_TYPE,
4919 MM_CAM_CAMERA_PAN_MECHA,
4920 MM_CAM_CAMERA_PAN_ELEC,
4921 MM_CAM_CAMERA_TILT_MECHA,
4922 MM_CAM_CAMERA_TILT_ELEC
4925 mmf_return_val_if_fail(hcamcorder, FALSE);
4927 MMCAM_LOG_INFO("commit some attribute again[2]");
4929 attrs = MMF_CAMCORDER_ATTRS(handle);
4930 if (attrs == NULL) {
4931 MMCAM_LOG_ERROR("Get attribute handle failed.");
4935 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4936 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4937 mm_attrs_set_modified(attrs, attr_idxs[i]);
4940 if (mm_attrs_commit_all(attrs) == -1)
4945 MMCAM_LOG_INFO("Done.");
4951 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4953 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4957 int nerror = MM_ERROR_NONE;
4959 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4961 attrs = MMF_CAMCORDER_ATTRS(handle);
4962 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4966 table_size = ARRAY_SIZE(readonly_attributes);
4967 MMCAM_LOG_INFO("%d", table_size);
4968 for (i = 0; i < table_size; i++) {
4969 int sCategory = readonly_attributes[i];
4971 mm_attrs_set_readonly(attrs, sCategory);
4978 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4980 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4983 type_string_array * disabled_attr = NULL;
4985 int nerror = MM_ERROR_NONE ;
4987 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4989 attrs = MMF_CAMCORDER_ATTRS(handle);
4990 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4995 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4996 CONFIGURE_CATEGORY_MAIN_GENERAL,
4997 "DisabledAttributes",
4999 if (disabled_attr != NULL && disabled_attr->value) {
5000 cnt_str = disabled_attr->count;
5001 for (i = 0; i < cnt_str; i++) {
5003 MMCAM_LOG_INFO("[%d]%s", i, disabled_attr->value[i]);
5004 nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
5006 if (nerror == MM_ERROR_NONE)
5007 mm_attrs_set_disabled(attrs, idx);
5009 MMCAM_LOG_WARNING("No ATTR named %s[%d]", disabled_attr->value[i], i);
5017 /*---------------------------------------------------------------------------------------
5018 | INTERNAL FUNCTION DEFINITIONS: |
5019 ---------------------------------------------------------------------------------------*/
5020 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
5022 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5023 _MMCamcorderSubContext *sc = NULL;
5024 int current_state = MM_CAMCORDER_STATE_NULL;
5026 mmf_return_val_if_fail(hcamcorder, FALSE);
5028 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
5032 current_state = _mmcamcorder_get_state(handle);
5034 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
5035 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
5036 MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
5037 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
5038 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
5040 MMCAM_LOG_WARNING("invalid state[%d]", current_state);
5044 MMCAM_LOG_INFO("element is not created yet");
5051 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
5053 #define INIT_VALUE -1
5054 #define CHECK_COUNT 3
5056 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5057 MMHandleType attrs = 0;
5059 int ret = MM_ERROR_NONE;
5062 const char *name = NULL;
5063 const char *check_pair_name[CHECK_COUNT][3] = {
5064 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
5065 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
5066 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
5069 int check_pair_value[CHECK_COUNT][2] = {
5070 {INIT_VALUE, INIT_VALUE},
5071 {INIT_VALUE, INIT_VALUE},
5072 {INIT_VALUE, INIT_VALUE},
5075 if (hcamcorder == NULL || attribute_name == NULL) {
5076 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
5077 hcamcorder, attribute_name);
5078 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5082 *err_attr_name = NULL;
5084 /*MMCAM_LOG_INFO( "ENTER" );*/
5086 attrs = MMF_CAMCORDER_ATTRS(handle);
5088 name = attribute_name;
5092 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
5094 /*MMCAM_LOG_INFO("NAME : %s", name);*/
5096 /* attribute name check */
5097 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
5099 *err_attr_name = strdup(name);
5101 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
5102 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5108 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5111 switch (attr_type) {
5112 case MM_ATTRS_TYPE_INT:
5114 gboolean matched = FALSE;
5115 for (i = 0 ; i < CHECK_COUNT ; i++) {
5116 for (j = 0 ; j < 2 ; j++) {
5117 if (!strcmp(name, check_pair_name[i][j])) {
5118 check_pair_value[i][j] = va_arg((var_args), int);
5119 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5127 if (matched == FALSE)
5128 va_arg((var_args), int);
5131 case MM_ATTRS_TYPE_DOUBLE:
5132 va_arg((var_args), double);
5134 case MM_ATTRS_TYPE_STRING:
5135 va_arg((var_args), char*); /* string */
5136 va_arg((var_args), int); /* size */
5138 case MM_ATTRS_TYPE_DATA:
5139 va_arg((var_args), void*); /* data */
5140 va_arg((var_args), int); /* size */
5142 case MM_ATTRS_TYPE_INVALID:
5144 MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5146 *err_attr_name = strdup(name);
5148 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5152 name = va_arg(var_args, const char*);
5155 for (i = 0 ; i < CHECK_COUNT ; i++) {
5156 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5157 gboolean check_result = FALSE;
5158 char *err_name = NULL;
5159 MMCamAttrsInfo attr_info_0, attr_info_1;
5161 if (check_pair_value[i][0] == INIT_VALUE) {
5162 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5163 err_name = strdup(check_pair_name[i][1]);
5164 } else if (check_pair_value[i][1] == INIT_VALUE) {
5165 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5166 err_name = strdup(check_pair_name[i][0]);
5168 err_name = strdup(check_pair_name[i][2]);
5171 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5172 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5174 check_result = FALSE;
5176 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5177 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5178 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5180 MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5181 check_pair_name[i][0], check_pair_name[i][1],
5182 check_pair_value[i][0], check_pair_value[i][1], i);
5184 check_result = TRUE;
5189 if (check_result == FALSE) {
5190 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5191 check_pair_name[i][0], check_pair_name[i][1],
5192 check_pair_value[i][0], check_pair_value[i][1]);
5193 if (err_attr_name) {
5194 *err_attr_name = err_name;
5202 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5205 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5206 int current_width = 0;
5207 int current_height = 0;
5209 mm_camcorder_get_attributes(handle, NULL,
5210 MMCAM_CAMERA_WIDTH, ¤t_width,
5211 MMCAM_CAMERA_HEIGHT, ¤t_height,
5214 if (current_width != check_pair_value[i][0] ||
5215 current_height != check_pair_value[i][1]) {
5216 hcamcorder->resolution_changed = TRUE;
5218 hcamcorder->resolution_changed = FALSE;
5221 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5231 /*MMCAM_LOG_INFO("DONE");*/
5233 return MM_ERROR_NONE;
5237 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5241 if ((void *)handle == NULL) {
5242 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5246 memset(&info, 0x0, sizeof(MMAttrsInfo));
5248 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5250 switch (info.validity_type) {
5251 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5253 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5255 if (info.int_array.count < 1)
5258 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5260 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5262 if (info.int_range.min > info.int_range.max)
5265 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5267 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5269 if (info.double_array.count < 1)
5272 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5274 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5276 if (info.double_range.min >= info.double_range.max)
5280 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);