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/cameracontrol.h>
31 #include <gst/video/videooverlay.h>
33 /*-----------------------------------------------------------------------
34 | MACRO DEFINITIONS: |
35 -----------------------------------------------------------------------*/
36 #define MMCAMCORDER_DEFAULT_CAMERA_WIDTH 640
37 #define MMCAMCORDER_DEFAULT_CAMERA_HEIGHT 480
38 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE (1024*1024*10)
39 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL 1000
40 #define MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL 89.0
42 /*---------------------------------------------------------------------------------------
43 | GLOBAL VARIABLE DEFINITIONS for internal |
44 ---------------------------------------------------------------------------------------*/
46 /*-----------------------------------------------------------------------
47 | LOCAL VARIABLE DEFINITIONS for internal |
48 -----------------------------------------------------------------------*/
49 /* Readonly attributes list.
50 * If you want to make some attributes read only, write down here.
51 * It will make them read only after composing whole attributes.
54 static int readonly_attributes[] = {
55 MM_CAM_CAMERA_DEVICE_COUNT,
56 MM_CAM_CAMERA_DEVICE_NAME,
57 MM_CAM_CAMERA_FACING_DIRECTION,
58 MM_CAM_CAMERA_SHUTTER_SPEED,
59 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
60 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
61 MM_CAM_CAPTURED_SCREENNAIL,
62 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
63 MM_CAM_SUPPORT_ZSL_CAPTURE,
64 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
65 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
66 MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
70 /*-----------------------------------------------------------------------
71 | LOCAL FUNCTION PROTOTYPES: |
72 -----------------------------------------------------------------------*/
73 /* STATIC INTERNAL FUNCTION */
74 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height);
75 static int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle);
76 static int __mmcamcorder_release_conf_valid_info(MMHandleType handle);
77 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
79 /*=======================================================================
80 | FUNCTION DEFINITIONS |
81 =======================================================================*/
82 /*-----------------------------------------------------------------------
83 | GLOBAL FUNCTION DEFINITIONS: |
84 -----------------------------------------------------------------------*/
86 _mmcamcorder_alloc_attribute(MMHandleType handle)
90 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
91 MMHandleType attrs = NULL;
92 MMAttrsConstructInfo *attrs_const_info;
93 unsigned int attr_count = 0;
95 int ret = MM_ERROR_NONE;
97 static int depth[] = {MM_CAMCORDER_AUDIO_FORMAT_PCM_U8, MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE};
98 static int flip_list[] = { MM_FLIP_NONE };
99 static int rotation_list[] = { MM_VIDEO_INPUT_ROTATION_NONE };
100 static int visible_values[] = { 0, 1 }; /*0: off, 1:on*/
101 static int tag_orientation_values[] = {
102 1, /*The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.*/
103 2, /*the 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.*/
104 3, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.*/
105 4, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.*/
106 5, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual top.*/
107 6, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual top.*/
108 7, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.*/
109 8, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.*/
112 if (hcamcorder == NULL) {
113 MMCAM_LOG_ERROR("handle is NULL");
117 /* Create attribute constructor */
118 MMCAM_LOG_INFO("start");
120 /* alloc 'MMAttrsConstructInfo' */
121 attr_count = MM_CAM_ATTRIBUTE_NUM;
122 attrs_const_info = malloc(attr_count * sizeof(MMAttrsConstructInfo));
123 if (!attrs_const_info) {
124 MMCAM_LOG_ERROR("Fail to alloc constructor.");
128 /* alloc default attribute info */
129 hcamcorder->cam_attrs_const_info = (mm_cam_attr_construct_info *)malloc(sizeof(mm_cam_attr_construct_info) * attr_count);
130 if (hcamcorder->cam_attrs_const_info == NULL) {
131 MMCAM_LOG_ERROR("failed to alloc default attribute info");
132 free(attrs_const_info);
133 attrs_const_info = NULL;
137 /* basic attributes' info */
138 mm_cam_attr_construct_info temp_info[] = {
141 MM_CAM_MODE, /* ID */
143 MM_ATTRS_TYPE_INT, /* Type */
144 MM_ATTRS_FLAG_RW, /* Flag */
145 {(void*)MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Default value */
146 MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */
147 {.int_min = MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Validity val1 (min, *array,...) */
148 {.int_max = MM_CAMCORDER_MODE_AUDIO}, /* Validity val2 (max, count, ...) */
149 NULL, /* Runtime setting function of the attribute */
156 {(void*)MM_AUDIO_DEVICE_MIC},
157 MM_ATTRS_VALID_TYPE_INT_ARRAY,
163 MM_CAM_CAMERA_DEVICE_COUNT,
164 "camera-device-count",
167 {(void*)MM_VIDEO_DEVICE_NUM},
168 MM_ATTRS_VALID_TYPE_INT_RANGE,
169 {.int_min = MM_VIDEO_DEVICE_NONE},
170 {.int_max = MM_VIDEO_DEVICE_NUM},
174 MM_CAM_AUDIO_ENCODER,
178 {(void*)MM_AUDIO_CODEC_AMR},
179 MM_ATTRS_VALID_TYPE_INT_ARRAY,
185 MM_CAM_VIDEO_ENCODER,
189 {(void*)MM_VIDEO_CODEC_MPEG4},
190 MM_ATTRS_VALID_TYPE_INT_ARRAY,
196 MM_CAM_IMAGE_ENCODER,
200 {(void*)MM_IMAGE_CODEC_JPEG},
201 MM_ATTRS_VALID_TYPE_INT_ARRAY,
211 {(void*)MM_FILE_FORMAT_MP4},
212 MM_ATTRS_VALID_TYPE_INT_ARRAY,
218 MM_CAM_CAMERA_DEVICE_NAME,
219 "camera-device-name",
220 MM_ATTRS_TYPE_STRING,
223 MM_ATTRS_VALID_TYPE_NONE,
229 MM_CAM_AUDIO_SAMPLERATE,
234 MM_ATTRS_VALID_TYPE_INT_RANGE,
236 {.int_max = _MMCAMCORDER_MAX_INT},
244 {(void*)MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE},
245 MM_ATTRS_VALID_TYPE_INT_ARRAY,
252 MM_CAM_AUDIO_CHANNEL,
257 MM_ATTRS_VALID_TYPE_INT_RANGE,
265 MM_ATTRS_TYPE_DOUBLE,
267 {.value_double = 1.0},
268 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
270 {.double_max = 10.0},
271 _mmcamcorder_commit_audio_volume,
274 MM_CAM_AUDIO_INPUT_ROUTE,
278 {(void*)MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
279 MM_ATTRS_VALID_TYPE_INT_RANGE,
280 {.int_min = MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
281 {.int_max = MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY},
282 _mmcamcorder_commit_audio_input_route,
285 MM_CAM_FILTER_SCENE_MODE,
290 MM_ATTRS_VALID_TYPE_INT_ARRAY,
293 _mmcamcorder_commit_filter_scene_mode,
296 MM_CAM_FILTER_BRIGHTNESS,
301 MM_ATTRS_VALID_TYPE_INT_RANGE,
304 _mmcamcorder_commit_filter,
307 MM_CAM_FILTER_CONTRAST,
312 MM_ATTRS_VALID_TYPE_INT_RANGE,
315 _mmcamcorder_commit_filter,
323 MM_ATTRS_VALID_TYPE_INT_ARRAY,
326 _mmcamcorder_commit_filter,
329 MM_CAM_FILTER_COLOR_TONE,
334 MM_ATTRS_VALID_TYPE_INT_ARRAY,
337 _mmcamcorder_commit_filter,
340 MM_CAM_FILTER_SATURATION,
345 MM_ATTRS_VALID_TYPE_INT_RANGE,
348 _mmcamcorder_commit_filter,
356 MM_ATTRS_VALID_TYPE_INT_RANGE,
359 _mmcamcorder_commit_filter,
363 MM_CAM_FILTER_SHARPNESS,
368 MM_ATTRS_VALID_TYPE_INT_RANGE,
371 _mmcamcorder_commit_filter,
374 MM_CAM_CAMERA_FORMAT,
378 {(void*)MM_PIXEL_FORMAT_YUYV},
379 MM_ATTRS_VALID_TYPE_INT_ARRAY,
382 _mmcamcorder_commit_camera_format,
385 MM_CAM_CAMERA_RECORDING_MOTION_RATE,
386 "camera-recording-motion-rate",
387 MM_ATTRS_TYPE_DOUBLE,
389 {.value_double = 1.0},
390 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
392 {.double_max = _MMCAMCORDER_MAX_DOUBLE},
393 _mmcamcorder_commit_camera_recording_motion_rate,
401 MM_ATTRS_VALID_TYPE_INT_RANGE,
404 _mmcamcorder_commit_camera_fps,
411 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
412 MM_ATTRS_VALID_TYPE_INT_ARRAY,
415 _mmcamcorder_commit_camera_width,
418 MM_CAM_CAMERA_HEIGHT,
422 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
423 MM_ATTRS_VALID_TYPE_INT_ARRAY,
426 _mmcamcorder_commit_camera_height,
429 MM_CAM_CAMERA_DIGITAL_ZOOM,
430 "camera-digital-zoom",
434 MM_ATTRS_VALID_TYPE_INT_RANGE,
437 _mmcamcorder_commit_camera_zoom,
440 MM_CAM_CAMERA_OPTICAL_ZOOM,
441 "camera-optical-zoom",
445 MM_ATTRS_VALID_TYPE_INT_RANGE,
448 _mmcamcorder_commit_camera_zoom,
451 MM_CAM_CAMERA_FOCUS_MODE,
455 {(void*)MM_CAMCORDER_FOCUS_MODE_NONE},
456 MM_ATTRS_VALID_TYPE_INT_ARRAY,
459 _mmcamcorder_commit_camera_focus_mode,
462 MM_CAM_CAMERA_AF_SCAN_RANGE,
463 "camera-af-scan-range",
467 MM_ATTRS_VALID_TYPE_INT_ARRAY,
470 _mmcamcorder_commit_camera_af_scan_range,
474 MM_CAM_CAMERA_EXPOSURE_MODE,
475 "camera-exposure-mode",
479 MM_ATTRS_VALID_TYPE_INT_ARRAY,
482 _mmcamcorder_commit_camera_capture_mode,
485 MM_CAM_CAMERA_EXPOSURE_VALUE,
486 "camera-exposure-value",
490 MM_ATTRS_VALID_TYPE_INT_RANGE,
493 _mmcamcorder_commit_camera_capture_mode,
496 MM_CAM_CAMERA_F_NUMBER,
501 MM_ATTRS_VALID_TYPE_INT_ARRAY,
504 _mmcamcorder_commit_camera_capture_mode,
507 MM_CAM_CAMERA_SHUTTER_SPEED,
508 "camera-shutter-speed",
512 MM_ATTRS_VALID_TYPE_INT_ARRAY,
515 _mmcamcorder_commit_camera_capture_mode,
523 MM_ATTRS_VALID_TYPE_INT_ARRAY,
526 _mmcamcorder_commit_camera_capture_mode,
534 MM_ATTRS_VALID_TYPE_INT_ARRAY,
537 _mmcamcorder_commit_camera_wdr,
540 MM_CAM_CAMERA_ANTI_HANDSHAKE,
541 "camera-anti-handshake",
545 MM_ATTRS_VALID_TYPE_INT_ARRAY,
548 _mmcamcorder_commit_camera_anti_handshake,
551 MM_CAM_CAMERA_FPS_AUTO,
556 MM_ATTRS_VALID_TYPE_INT_RANGE,
559 _mmcamcorder_commit_camera_fps,
562 MM_CAM_CAMERA_DELAY_ATTR_SETTING,
563 "camera-delay-attr-setting",
567 MM_ATTRS_VALID_TYPE_INT_RANGE,
573 MM_CAM_AUDIO_ENCODER_BITRATE,
574 "audio-encoder-bitrate",
578 MM_ATTRS_VALID_TYPE_INT_RANGE,
580 {.int_max = _MMCAMCORDER_MAX_INT},
581 _mmcamcorder_commit_encoder_bitrate,
585 MM_CAM_VIDEO_ENCODER_BITRATE,
586 "video-encoder-bitrate",
590 MM_ATTRS_VALID_TYPE_INT_RANGE,
592 {.int_max = _MMCAMCORDER_MAX_INT},
593 _mmcamcorder_commit_encoder_bitrate,
596 MM_CAM_IMAGE_ENCODER_QUALITY,
597 "image-encoder-quality",
601 MM_ATTRS_VALID_TYPE_INT_RANGE,
604 _mmcamcorder_commit_image_encoder_quality,
607 MM_CAM_CAPTURE_FORMAT,
611 {(void*)MM_PIXEL_FORMAT_ENCODED},
612 MM_ATTRS_VALID_TYPE_INT_ARRAY,
618 MM_CAM_CAPTURE_WIDTH,
623 MM_ATTRS_VALID_TYPE_INT_ARRAY,
626 _mmcamcorder_commit_capture_width ,
629 MM_CAM_CAPTURE_HEIGHT,
634 MM_ATTRS_VALID_TYPE_INT_ARRAY,
637 _mmcamcorder_commit_capture_height,
640 MM_CAM_CAPTURE_COUNT,
645 MM_ATTRS_VALID_TYPE_INT_RANGE,
648 _mmcamcorder_commit_capture_count,
651 MM_CAM_CAPTURE_INTERVAL,
656 MM_ATTRS_VALID_TYPE_INT_RANGE,
658 {.int_max = _MMCAMCORDER_MAX_INT},
662 MM_CAM_CAPTURE_BREAK_CONTINUOUS_SHOT,
663 "capture-break-cont-shot",
667 MM_ATTRS_VALID_TYPE_INT_RANGE,
670 _mmcamcorder_commit_capture_break_cont_shot,
673 MM_CAM_DISPLAY_HANDLE,
678 MM_ATTRS_VALID_TYPE_NONE,
681 _mmcamcorder_commit_display_handle,
684 MM_CAM_DISPLAY_DEVICE,
688 {(void*)MM_DISPLAY_DEVICE_MAINLCD},
689 MM_ATTRS_VALID_TYPE_INT_ARRAY,
696 MM_CAM_DISPLAY_SURFACE,
700 {(void*)MM_DISPLAY_SURFACE_OVERLAY},
701 MM_ATTRS_VALID_TYPE_INT_ARRAY,
707 MM_CAM_DISPLAY_RECT_X,
712 MM_ATTRS_VALID_TYPE_INT_RANGE,
714 {.int_max = _MMCAMCORDER_MAX_INT},
715 _mmcamcorder_commit_display_rect,
718 MM_CAM_DISPLAY_RECT_Y,
723 MM_ATTRS_VALID_TYPE_INT_RANGE,
725 {.int_max = _MMCAMCORDER_MAX_INT},
726 _mmcamcorder_commit_display_rect,
729 MM_CAM_DISPLAY_RECT_WIDTH,
730 "display-rect-width",
734 MM_ATTRS_VALID_TYPE_INT_RANGE,
736 {.int_max = _MMCAMCORDER_MAX_INT},
737 _mmcamcorder_commit_display_rect,
740 MM_CAM_DISPLAY_RECT_HEIGHT,
741 "display-rect-height",
745 MM_ATTRS_VALID_TYPE_INT_RANGE,
747 {.int_max = _MMCAMCORDER_MAX_INT},
748 _mmcamcorder_commit_display_rect,
751 MM_CAM_DISPLAY_SOURCE_X,
756 MM_ATTRS_VALID_TYPE_INT_RANGE,
758 {.int_max = _MMCAMCORDER_MAX_INT},
762 MM_CAM_DISPLAY_SOURCE_Y,
767 MM_ATTRS_VALID_TYPE_INT_RANGE,
769 {.int_max = _MMCAMCORDER_MAX_INT},
773 MM_CAM_DISPLAY_SOURCE_WIDTH,
778 MM_ATTRS_VALID_TYPE_INT_RANGE,
780 {.int_max = _MMCAMCORDER_MAX_INT},
784 MM_CAM_DISPLAY_SOURCE_HEIGHT,
785 "display-src-height",
789 MM_ATTRS_VALID_TYPE_INT_RANGE,
791 {.int_max = _MMCAMCORDER_MAX_INT},
795 MM_CAM_DISPLAY_ROTATION,
799 {(void*)MM_DISPLAY_ROTATION_NONE},
800 MM_ATTRS_VALID_TYPE_INT_RANGE,
801 {.int_min = MM_DISPLAY_ROTATION_NONE},
802 {.int_max = MM_DISPLAY_ROTATION_270},
803 _mmcamcorder_commit_display_rotation,
807 MM_CAM_DISPLAY_VISIBLE,
812 MM_ATTRS_VALID_TYPE_INT_ARRAY,
814 {ARRAY_SIZE(visible_values)},
815 _mmcamcorder_commit_display_visible,
818 MM_CAM_DISPLAY_SCALE,
823 MM_ATTRS_VALID_TYPE_INT_RANGE,
824 {.int_min = MM_DISPLAY_SCALE_DEFAULT},
825 {.int_max = MM_DISPLAY_SCALE_TRIPLE_LENGTH},
826 _mmcamcorder_commit_display_scale,
829 MM_CAM_DISPLAY_GEOMETRY_METHOD,
830 "display-geometry-method",
834 MM_ATTRS_VALID_TYPE_INT_RANGE,
835 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
836 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
837 _mmcamcorder_commit_display_geometry_method,
840 MM_CAM_TARGET_FILENAME,
842 MM_ATTRS_TYPE_STRING,
845 MM_ATTRS_VALID_TYPE_NONE,
848 _mmcamcorder_commit_target_filename,
851 MM_CAM_TARGET_MAX_SIZE,
856 MM_ATTRS_VALID_TYPE_INT_RANGE,
858 {.int_max = _MMCAMCORDER_MAX_INT},
859 _mmcamcorder_commit_recording_max_limit,
862 MM_CAM_TARGET_TIME_LIMIT,
867 MM_ATTRS_VALID_TYPE_INT_RANGE,
869 {.int_max = _MMCAMCORDER_MAX_INT},
870 _mmcamcorder_commit_recording_max_limit,
878 MM_ATTRS_VALID_TYPE_INT_RANGE,
881 _mmcamcorder_commit_tag,
884 MM_CAM_TAG_IMAGE_DESCRIPTION,
885 "tag-image-description",
886 MM_ATTRS_TYPE_STRING,
889 MM_ATTRS_VALID_TYPE_NONE,
892 _mmcamcorder_commit_tag,
895 MM_CAM_TAG_ORIENTATION,
900 MM_ATTRS_VALID_TYPE_INT_ARRAY,
901 {tag_orientation_values},
902 {ARRAY_SIZE(tag_orientation_values)},
903 _mmcamcorder_commit_tag,
908 MM_ATTRS_TYPE_STRING,
911 MM_ATTRS_VALID_TYPE_NONE,
914 _mmcamcorder_commit_tag,
920 MM_ATTRS_TYPE_DOUBLE,
922 {.value_double = 0.0},
923 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
924 {.double_min = -360.0},
925 {.double_max = 360.0},
926 _mmcamcorder_commit_tag,
929 MM_CAM_TAG_LONGITUDE,
931 MM_ATTRS_TYPE_DOUBLE,
933 {.value_double = 0.0},
934 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
935 {.double_min = -360.0},
936 {.double_max = 360.0},
937 _mmcamcorder_commit_tag,
942 MM_ATTRS_TYPE_DOUBLE,
944 {.value_double = 0.0},
945 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
946 {.double_min = -999999.0},
947 {.double_max = 999999.0},
948 _mmcamcorder_commit_tag,
951 MM_CAM_STROBE_CONTROL,
956 MM_ATTRS_VALID_TYPE_INT_RANGE,
959 _mmcamcorder_commit_strobe,
962 MM_CAM_STROBE_CAPABILITIES,
963 "strobe-capabilities",
967 MM_ATTRS_VALID_TYPE_INT_RANGE,
970 _mmcamcorder_commit_strobe,
978 MM_ATTRS_VALID_TYPE_INT_ARRAY,
981 _mmcamcorder_commit_strobe,
989 MM_ATTRS_VALID_TYPE_INT_ARRAY,
992 _mmcamcorder_commit_detect,
995 MM_CAM_DETECT_NUMBER,
1000 MM_ATTRS_VALID_TYPE_INT_RANGE,
1003 _mmcamcorder_commit_detect,
1006 MM_CAM_DETECT_FOCUS_SELECT,
1007 "detect-focus-select",
1011 MM_ATTRS_VALID_TYPE_INT_RANGE,
1014 _mmcamcorder_commit_detect,
1017 MM_CAM_DETECT_SELECT_NUMBER,
1018 "detect-select-number",
1022 MM_ATTRS_VALID_TYPE_INT_RANGE,
1025 _mmcamcorder_commit_detect,
1029 MM_CAM_DETECT_STATUS,
1034 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1037 _mmcamcorder_commit_detect,
1040 MM_CAM_CAPTURE_ZERO_SYSTEMLAG,
1041 "capture-zero-systemlag",
1045 MM_ATTRS_VALID_TYPE_INT_RANGE,
1051 MM_CAM_CAMERA_AF_TOUCH_X,
1052 "camera-af-touch-x",
1056 MM_ATTRS_VALID_TYPE_INT_RANGE,
1058 {.int_max = _MMCAMCORDER_MAX_INT},
1059 _mmcamcorder_commit_camera_af_touch_area,
1062 MM_CAM_CAMERA_AF_TOUCH_Y,
1063 "camera-af-touch-y",
1067 MM_ATTRS_VALID_TYPE_INT_RANGE,
1069 {.int_max = _MMCAMCORDER_MAX_INT},
1070 _mmcamcorder_commit_camera_af_touch_area,
1073 MM_CAM_CAMERA_AF_TOUCH_WIDTH,
1074 "camera-af-touch-width",
1078 MM_ATTRS_VALID_TYPE_INT_RANGE,
1080 {.int_max = _MMCAMCORDER_MAX_INT},
1081 _mmcamcorder_commit_camera_af_touch_area,
1084 MM_CAM_CAMERA_AF_TOUCH_HEIGHT,
1085 "camera-af-touch-height",
1089 MM_ATTRS_VALID_TYPE_INT_RANGE,
1091 {.int_max = _MMCAMCORDER_MAX_INT},
1092 _mmcamcorder_commit_camera_af_touch_area,
1095 MM_CAM_CAMERA_FOCAL_LENGTH,
1096 "camera-focal-length",
1097 MM_ATTRS_TYPE_DOUBLE,
1099 {.value_double = 0.0},
1100 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1101 {.double_min = 0.0},
1102 {.double_max = 1000.0},
1103 _mmcamcorder_commit_camera_capture_mode,
1106 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
1107 "recommend-preview-format-for-capture",
1110 {(void*)MM_PIXEL_FORMAT_YUYV},
1111 MM_ATTRS_VALID_TYPE_INT_RANGE,
1112 {.int_min = MM_PIXEL_FORMAT_NV12},
1113 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1117 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
1118 "recommend-preview-format-for-recording",
1121 {(void*)MM_PIXEL_FORMAT_NV12},
1122 MM_ATTRS_VALID_TYPE_INT_RANGE,
1123 {.int_min = MM_PIXEL_FORMAT_NV12},
1124 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1128 MM_CAM_TAG_GPS_ENABLE,
1133 MM_ATTRS_VALID_TYPE_INT_RANGE,
1136 _mmcamcorder_commit_tag,
1140 MM_CAM_TAG_GPS_TIME_STAMP,
1141 "tag-gps-time-stamp",
1142 MM_ATTRS_TYPE_DOUBLE,
1144 {.value_double = 0.0},
1145 MM_ATTRS_VALID_TYPE_NONE,
1148 _mmcamcorder_commit_tag,
1151 MM_CAM_TAG_GPS_DATE_STAMP,
1152 "tag-gps-date-stamp",
1153 MM_ATTRS_TYPE_STRING,
1156 MM_ATTRS_VALID_TYPE_NONE,
1159 _mmcamcorder_commit_tag,
1162 MM_CAM_TAG_GPS_PROCESSING_METHOD,
1163 "tag-gps-processing-method",
1164 MM_ATTRS_TYPE_STRING,
1167 MM_ATTRS_VALID_TYPE_NONE,
1170 _mmcamcorder_commit_tag,
1173 MM_CAM_CAMERA_ROTATION,
1177 {(void*)MM_VIDEO_INPUT_ROTATION_NONE},
1178 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1180 {ARRAY_SIZE(rotation_list)},
1181 _mmcamcorder_commit_camera_rotate,
1184 MM_CAM_CAPTURED_SCREENNAIL,
1185 "captured-screennail",
1189 MM_ATTRS_VALID_TYPE_NONE,
1195 MM_CAM_CAPTURE_SOUND_ENABLE,
1196 "capture-sound-enable",
1200 MM_ATTRS_VALID_TYPE_INT_RANGE,
1203 _mmcamcorder_commit_capture_sound_enable,
1206 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
1207 "recommend-display-rotation",
1210 {(void*)MM_DISPLAY_ROTATION_270},
1211 MM_ATTRS_VALID_TYPE_INT_RANGE,
1212 {.int_min = MM_DISPLAY_ROTATION_NONE},
1213 {.int_max = MM_DISPLAY_ROTATION_270},
1221 {(void*)MM_FLIP_NONE},
1222 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1224 {ARRAY_SIZE(flip_list)},
1225 _mmcamcorder_commit_camera_flip,
1228 MM_CAM_CAMERA_HDR_CAPTURE,
1229 "camera-hdr-capture",
1233 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1236 _mmcamcorder_commit_camera_hdr_capture,
1239 MM_CAM_DISPLAY_MODE,
1243 {(void*)MM_DISPLAY_MODE_DEFAULT},
1244 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1247 _mmcamcorder_commit_display_mode,
1251 MM_CAM_AUDIO_DISABLE,
1256 MM_ATTRS_VALID_TYPE_INT_RANGE,
1259 _mmcamcorder_commit_audio_disable,
1262 MM_CAM_RECOMMEND_CAMERA_WIDTH,
1263 "recommend-camera-width",
1266 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
1267 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1273 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
1274 "recommend-camera-height",
1277 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
1278 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1284 MM_CAM_CAPTURED_EXIF_RAW_DATA,
1285 "captured-exif-raw-data",
1289 MM_ATTRS_VALID_TYPE_NONE,
1295 MM_CAM_DISPLAY_EVAS_SURFACE_SINK,
1296 "display-evas-surface-sink",
1297 MM_ATTRS_TYPE_STRING,
1300 MM_ATTRS_VALID_TYPE_NONE,
1306 MM_CAM_DISPLAY_EVAS_DO_SCALING,
1307 "display-evas-do-scaling",
1311 MM_ATTRS_VALID_TYPE_INT_RANGE,
1314 _mmcamcorder_commit_display_evas_do_scaling,
1317 MM_CAM_CAMERA_FACING_DIRECTION,
1318 "camera-facing-direction",
1321 {(void*)MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1322 MM_ATTRS_VALID_TYPE_INT_RANGE,
1323 {.int_min = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1324 {.int_max = MM_CAMCORDER_CAMERA_FACING_DIRECTION_FRONT},
1328 MM_CAM_DISPLAY_FLIP,
1332 {(void*)MM_FLIP_NONE},
1333 MM_ATTRS_VALID_TYPE_INT_RANGE,
1334 {.int_min = MM_FLIP_NONE},
1335 {.int_max = MM_FLIP_BOTH},
1336 _mmcamcorder_commit_display_flip,
1339 MM_CAM_CAMERA_VIDEO_STABILIZATION,
1340 "camera-video-stabilization",
1343 {(void*)MM_CAMCORDER_VIDEO_STABILIZATION_OFF},
1344 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1347 _mmcamcorder_commit_camera_video_stabilization,
1350 MM_CAM_TAG_VIDEO_ORIENTATION,
1351 "tag-video-orientation",
1354 {(void*)MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1355 MM_ATTRS_VALID_TYPE_INT_RANGE,
1356 {.int_min = MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1357 {.int_max = MM_CAMCORDER_TAG_VIDEO_ORT_270},
1362 MM_CAM_CAMERA_PAN_MECHA,
1367 MM_ATTRS_VALID_TYPE_INT_RANGE,
1370 _mmcamcorder_commit_camera_pan,
1373 MM_CAM_CAMERA_PAN_ELEC,
1378 MM_ATTRS_VALID_TYPE_INT_RANGE,
1381 _mmcamcorder_commit_camera_pan,
1384 MM_CAM_CAMERA_TILT_MECHA,
1385 "camera-tilt-mecha",
1389 MM_ATTRS_VALID_TYPE_INT_RANGE,
1392 _mmcamcorder_commit_camera_tilt,
1395 MM_CAM_CAMERA_TILT_ELEC,
1400 MM_ATTRS_VALID_TYPE_INT_RANGE,
1403 _mmcamcorder_commit_camera_tilt,
1406 MM_CAM_CAMERA_PTZ_TYPE,
1411 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1414 _mmcamcorder_commit_camera_ptz_type,
1422 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1425 _mmcamcorder_commit_video_size,
1428 MM_CAM_VIDEO_HEIGHT,
1433 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1436 _mmcamcorder_commit_video_size,
1439 MM_CAM_SUPPORT_ZSL_CAPTURE,
1440 "support-zsl-capture",
1444 MM_ATTRS_VALID_TYPE_INT_RANGE,
1450 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
1451 "support-zero-copy-format",
1455 MM_ATTRS_VALID_TYPE_INT_RANGE,
1461 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
1462 "support-media-packet-preview-cb",
1466 MM_ATTRS_VALID_TYPE_INT_RANGE,
1473 MM_CAM_ENCODED_PREVIEW_BITRATE,
1474 "encoded-preview-bitrate",
1477 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE},
1478 MM_ATTRS_VALID_TYPE_INT_RANGE,
1480 {.int_max = _MMCAMCORDER_MAX_INT},
1481 _mmcamcorder_commit_encoded_preview_bitrate,
1484 MM_CAM_ENCODED_PREVIEW_GOP_INTERVAL,
1485 "encoded-preview-gop-interval",
1488 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL},
1489 MM_ATTRS_VALID_TYPE_INT_RANGE,
1491 {.int_max = _MMCAMCORDER_MAX_INT},
1492 _mmcamcorder_commit_encoded_preview_gop_interval,
1495 MM_CAM_RECORDER_TAG_ENABLE,
1496 "recorder-tag-enable",
1500 MM_ATTRS_VALID_TYPE_INT_RANGE,
1506 MM_CAM_DISPLAY_SOCKET_PATH,
1507 "display-socket-path",
1508 MM_ATTRS_TYPE_STRING,
1511 MM_ATTRS_VALID_TYPE_NONE,
1522 MM_ATTRS_VALID_TYPE_INT_RANGE,
1524 {.int_max = _MMCAMCORDER_MAX_INT},
1528 MM_CAM_ROOT_DIRECTORY,
1530 MM_ATTRS_TYPE_STRING,
1533 MM_ATTRS_VALID_TYPE_NONE,
1539 MM_CAM_SOUND_STREAM_INDEX,
1540 "sound-stream-index",
1544 MM_ATTRS_VALID_TYPE_INT_RANGE,
1546 {.int_max = _MMCAMCORDER_MAX_INT},
1550 MM_CAM_SOUND_STREAM_TYPE,
1551 "sound-stream-type",
1552 MM_ATTRS_TYPE_STRING,
1555 MM_ATTRS_VALID_TYPE_NONE,
1558 _mmcamcorder_commit_sound_stream_info,
1561 MM_CAM_DISPLAY_REUSE_HINT,
1562 "display-reuse-hint",
1566 MM_ATTRS_VALID_TYPE_INT_RANGE,
1572 MM_CAM_DISPLAY_REUSE_ELEMENT,
1573 "display-reuse-element",
1577 MM_ATTRS_VALID_TYPE_NONE,
1583 MM_CAM_GDBUS_CONNECTION,
1588 MM_ATTRS_VALID_TYPE_NONE,
1594 MM_CAM_AUDIO_REPLAY_GAIN_ENABLE,
1595 "audio-replay-gain-enable",
1599 MM_ATTRS_VALID_TYPE_INT_RANGE,
1602 _mmcamcorder_commit_audio_replay_gain,
1605 MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL,
1606 "audio-replay-gain-reference-level",
1607 MM_ATTRS_TYPE_DOUBLE,
1609 {.value_double = MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL},
1610 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1611 {.double_min = 0.0},
1612 {.double_max = 150.0},
1613 _mmcamcorder_commit_audio_replay_gain,
1616 MM_CAM_SUPPORT_USER_BUFFER,
1617 "support-user-buffer",
1621 MM_ATTRS_VALID_TYPE_INT_RANGE,
1627 MM_CAM_USER_BUFFER_FD,
1632 MM_ATTRS_VALID_TYPE_NONE,
1638 MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
1639 "platform-privilege-camera",
1640 MM_ATTRS_TYPE_STRING,
1643 MM_ATTRS_VALID_TYPE_NONE,
1653 {(void*)MM_CAMCORDER_LOG_LEVEL_INFO},
1654 MM_ATTRS_VALID_TYPE_INT_RANGE,
1655 {.int_min = MM_CAMCORDER_LOG_LEVEL_CRITICAL},
1656 {.int_max = MM_CAMCORDER_LOG_LEVEL_VERBOSE},
1661 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1663 for (idx = 0 ; idx < attr_count ; idx++) {
1664 /* attribute order check. This should be same. */
1665 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1666 MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1667 free(attrs_const_info);
1668 attrs_const_info = NULL;
1669 free(hcamcorder->cam_attrs_const_info);
1670 hcamcorder->cam_attrs_const_info = NULL;
1674 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1675 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1676 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1677 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1680 /* Camcorder Attributes */
1681 MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1683 ret = mm_attrs_new(attrs_const_info,
1685 "Camcorder_Attributes",
1686 _mmcamcorder_commit_camcorder_attrs,
1690 free(attrs_const_info);
1691 attrs_const_info = NULL;
1693 if (ret != MM_ERROR_NONE) {
1694 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1695 free(hcamcorder->cam_attrs_const_info);
1696 hcamcorder->cam_attrs_const_info = NULL;
1700 __mmcamcorder_set_conf_to_valid_info(handle);
1702 for (idx = 0; idx < attr_count; idx++) {
1703 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1705 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1707 switch (attr_info->validity_type) {
1708 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1709 if (attr_info->validity_value_1.int_array &&
1710 attr_info->validity_value_2.count > 0) {
1711 mm_attrs_set_valid_array(attrs, idx,
1712 (const int *)(attr_info->validity_value_1.int_array),
1713 attr_info->validity_value_2.count,
1714 attr_info->default_value.value_int);
1717 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1718 mm_attrs_set_valid_range(attrs, idx,
1719 attr_info->validity_value_1.int_min,
1720 attr_info->validity_value_2.int_max,
1721 attr_info->default_value.value_int);
1723 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1724 if (attr_info->validity_value_1.double_array &&
1725 attr_info->validity_value_2.count > 0) {
1726 mm_attrs_set_valid_double_array(attrs, idx,
1727 (const double *)(attr_info->validity_value_1.double_array),
1728 attr_info->validity_value_2.count,
1729 attr_info->default_value.value_double);
1732 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1733 mm_attrs_set_valid_double_range(attrs, idx,
1734 attr_info->validity_value_1.double_min,
1735 attr_info->validity_value_2.double_max,
1736 attr_info->default_value.value_double);
1738 case MM_ATTRS_VALID_TYPE_NONE:
1740 case MM_ATTRS_VALID_TYPE_INVALID:
1742 MMCAM_LOG_ERROR("Valid type error.");
1747 __mmcamcorder_release_conf_valid_info(handle);
1754 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1756 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1758 if (hcamcorder == NULL) {
1759 MMCAM_LOG_ERROR("handle is NULL");
1766 mm_attrs_free(attrs);
1767 MMCAM_LOG_INFO("released attribute");
1770 if (hcamcorder->cam_attrs_const_info) {
1771 free(hcamcorder->cam_attrs_const_info);
1772 hcamcorder->cam_attrs_const_info = NULL;
1773 MMCAM_LOG_INFO("released attribute info");
1781 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1783 MMHandleType attrs = 0;
1784 int ret = MM_ERROR_NONE;
1786 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1787 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1789 attrs = MMF_CAMCORDER_ATTRS(handle);
1790 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1792 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1799 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1801 MMHandleType attrs = 0;
1802 int ret = MM_ERROR_NONE;
1804 char *tmp_err_attr_name = NULL;
1805 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1806 va_list var_args_copy;
1808 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1810 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1811 MMCAM_LOG_ERROR("Another command is running.");
1812 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1815 /* copy var_args to keep original var_args */
1816 va_copy(var_args_copy, var_args);
1818 attrs = MMF_CAMCORDER_ATTRS(handle);
1820 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1822 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1823 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1826 if (ret == MM_ERROR_NONE) {
1827 hcamcorder->error_code = MM_ERROR_NONE;
1828 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1829 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1832 va_end(var_args_copy);
1834 _MMCAMCORDER_UNLOCK_CMD(handle);
1836 if (ret != MM_ERROR_NONE) {
1837 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1838 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1839 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1840 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1841 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1842 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1846 if (hcamcorder->error_code != MM_ERROR_NONE) {
1847 MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1848 ret = hcamcorder->error_code;
1849 hcamcorder->error_code = MM_ERROR_NONE;
1852 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1855 if (tmp_err_attr_name) {
1856 if (!err_attr_name) {
1857 MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1858 free(tmp_err_attr_name);
1859 tmp_err_attr_name = NULL;
1861 *err_attr_name = tmp_err_attr_name;
1870 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1872 MMHandleType attrs = 0;
1873 MMAttrsInfo attrinfo;
1874 int ret = MM_ERROR_NONE;
1876 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1877 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1878 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1880 attrs = MMF_CAMCORDER_ATTRS(handle);
1881 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1883 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1885 if (ret == MM_ERROR_NONE) {
1886 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1887 info->type = attrinfo.type;
1888 info->flag = attrinfo.flag;
1889 info->validity_type = attrinfo.validity_type;
1891 switch (attrinfo.validity_type) {
1892 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1893 info->int_array.array = attrinfo.int_array.array;
1894 info->int_array.count = attrinfo.int_array.count;
1895 info->int_array.def = attrinfo.int_array.dval;
1897 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1898 info->int_range.min = attrinfo.int_range.min;
1899 info->int_range.max = attrinfo.int_range.max;
1900 info->int_range.def = attrinfo.int_range.dval;
1902 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1903 info->double_array.array = attrinfo.double_array.array;
1904 info->double_array.count = attrinfo.double_array.count;
1905 info->double_array.def = attrinfo.double_array.dval;
1907 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1908 info->double_range.min = attrinfo.double_range.min;
1909 info->double_range.max = attrinfo.double_range.max;
1910 info->double_range.def = attrinfo.double_range.dval;
1912 case MM_ATTRS_VALID_TYPE_NONE:
1914 case MM_ATTRS_VALID_TYPE_INVALID:
1925 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1928 mmf_camcorder_t *hcamcorder = NULL;
1930 mmf_return_val_if_fail(commit_param, FALSE);
1931 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1932 mmf_return_val_if_fail(attr_name, FALSE);
1933 mmf_return_val_if_fail(value, FALSE);
1935 hcamcorder = MMF_CAMCORDER(commit_param);
1937 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1938 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1946 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1949 int total_count = 0;
1951 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1953 if (hcamcorder == NULL) {
1954 MMCAM_LOG_ERROR("handle is NULL");
1955 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1959 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
1960 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
1961 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
1964 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
1965 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
1966 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
1969 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
1970 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
1971 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
1974 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
1975 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
1976 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
1978 return MM_ERROR_NONE;
1982 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
1984 int *allocated_memory = NULL;
1986 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1988 if (hcamcorder == NULL) {
1989 MMCAM_LOG_ERROR("handle is NULL");
1990 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1993 MMCAM_LOG_INFO("START");
1995 /* Audio encoder info */
1996 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
1997 if (allocated_memory) {
1998 g_free(allocated_memory);
1999 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2000 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2003 /* Video encoder info */
2004 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2005 if (allocated_memory) {
2006 g_free(allocated_memory);
2007 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2008 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2011 /* Image encoder info */
2012 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2013 if (allocated_memory) {
2014 g_free(allocated_memory);
2015 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2016 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2019 /* File format info */
2020 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2021 if (allocated_memory) {
2022 g_free(allocated_memory);
2023 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2024 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2027 MMCAM_LOG_INFO("DONE");
2029 return MM_ERROR_NONE;
2033 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2035 MMHandleType attr = 0;
2036 int current_state = MM_CAMCORDER_STATE_NONE;
2038 mmf_return_val_if_fail(handle && value, FALSE);
2040 attr = MMF_CAMCORDER_ATTRS(handle);
2041 mmf_return_val_if_fail(attr, FALSE);
2043 /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2045 current_state = _mmcamcorder_get_state(handle);
2046 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2047 int flags = MM_ATTRS_FLAG_NONE;
2048 int capture_width, capture_height;
2049 MMCamAttrsInfo info;
2051 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2054 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2055 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2056 capture_width = value->value.i_val;
2058 /* Check whether they are valid pair */
2059 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2064 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2070 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2072 int current_state = MM_CAMCORDER_STATE_NONE;
2074 current_state = _mmcamcorder_get_state(handle);
2076 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2077 int capture_width, capture_height;
2079 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2080 capture_height = value->value.i_val;
2082 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2084 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2091 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2093 int current_state = 0;
2095 const char *videosrc_name = NULL;
2096 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2097 _MMCamcorderSubContext *sc = NULL;
2098 _MMCamcorderImageInfo *info = NULL;
2099 GstCameraControl *control = NULL;
2100 type_element *VideosrcElement = NULL;
2102 mmf_return_val_if_fail(handle && value, FALSE);
2104 current_state = _mmcamcorder_get_state(handle);
2105 ivalue = value->value.i_val;
2107 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2108 CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
2111 _mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
2113 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2117 info = sc->info_image;
2119 MMCAM_LOG_ERROR("info image is NULL");
2123 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2124 if (info->capture_send_count > 0) {
2125 info->capturing = FALSE;
2126 MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2129 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2130 MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2134 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2136 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2137 MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2139 MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2142 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2149 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2151 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2152 int current_state = MM_CAMCORDER_STATE_NONE;
2153 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2155 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2157 current_state = _mmcamcorder_get_state(handle);
2158 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2160 MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2161 current_state, mode, value->value.i_val);
2163 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2164 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2167 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2173 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2175 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2177 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2179 MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2181 /* return error when disable shutter sound if policy is TRUE */
2182 if (!value->value.i_val &&
2183 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2184 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2187 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2193 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2195 int current_state = MM_CAMCORDER_STATE_NONE;
2196 _MMCamcorderSubContext *sc = NULL;
2199 mmf_return_val_if_fail(handle && value, FALSE);
2201 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2205 current_state = _mmcamcorder_get_state(handle);
2207 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2208 double mslNewVal = 0;
2209 mslNewVal = value->value.d_val;
2211 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2212 if (mslNewVal == 0.0) {
2213 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2214 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2216 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2217 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2221 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2224 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2232 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2234 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2235 int current_state = MM_CAMCORDER_STATE_NONE;
2237 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2239 current_state = _mmcamcorder_get_state(handle);
2240 if (current_state > MM_CAMCORDER_STATE_READY) {
2241 MMCAM_LOG_ERROR("invalid state %d", current_state);
2242 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2250 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2252 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2253 MMCamAttrsInfo fps_info;
2254 int resolution_width = 0;
2255 int resolution_height = 0;
2258 int current_state = MM_CAMCORDER_STATE_NONE;
2260 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2262 current_state = _mmcamcorder_get_state(handle);
2263 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2264 MMCAM_LOG_ERROR("invalid state %d", current_state);
2265 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2269 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2272 MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2274 ret = mm_camcorder_get_attributes(handle, NULL,
2275 MMCAM_CAMERA_WIDTH, &resolution_width,
2276 MMCAM_CAMERA_HEIGHT, &resolution_height,
2279 if (ret != MM_ERROR_NONE) {
2280 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2284 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2285 if (ret != MM_ERROR_NONE) {
2286 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2290 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2291 if (value->value.i_val == fps_info.int_array.array[i])
2295 MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2301 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2303 int current_state = MM_CAMCORDER_STATE_NONE;
2304 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2305 _MMCamcorderSubContext *sc = NULL;
2307 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2309 current_state = _mmcamcorder_get_state(handle);
2310 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2311 MMCAM_LOG_WARNING("invalid state %d", current_state);
2312 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2316 /* Verify recording motion rate */
2317 if (value->value.d_val > 0.0) {
2318 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2322 /* set is_slow flag */
2323 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2324 sc->is_modified_rate = TRUE;
2326 sc->is_modified_rate = FALSE;
2328 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2331 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2337 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2339 MMHandleType attr = 0;
2340 int current_state = MM_CAMCORDER_STATE_NONE;
2342 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2343 _MMCamcorderSubContext *sc = NULL;
2345 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2347 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2351 attr = MMF_CAMCORDER_ATTRS(handle);
2352 mmf_return_val_if_fail(attr, FALSE);
2354 MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2356 current_state = _mmcamcorder_get_state(handle);
2358 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2359 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2362 int flags = MM_ATTRS_FLAG_NONE;
2363 MMCamAttrsInfo info;
2364 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2367 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2368 int width = value->value.i_val;
2370 int preview_format = MM_PIXEL_FORMAT_NV12;
2371 int codec_type = MM_IMAGE_CODEC_JPEG;
2373 mm_camcorder_get_attributes(handle, NULL,
2374 MMCAM_CAMERA_HEIGHT, &height,
2375 MMCAM_CAMERA_FORMAT, &preview_format,
2376 MMCAM_IMAGE_ENCODER, &codec_type,
2379 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2380 if (hcamcorder->resolution_changed == FALSE) {
2381 MMCAM_LOG_INFO("no need to restart preview");
2385 hcamcorder->resolution_changed = FALSE;
2387 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2388 MMCAM_LOG_INFO("restart preview");
2390 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2391 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2393 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2394 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2396 /* check decoder recreation */
2397 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2398 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2399 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2403 /* get preview format */
2404 sc->info_image->preview_format = preview_format;
2405 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2406 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2408 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2409 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2411 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2412 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2415 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2417 MMCAM_LOG_ERROR("currently locked for preview restart");
2421 /* get preview format */
2422 sc->info_image->preview_format = preview_format;
2423 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2424 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2435 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2438 int current_state = MM_CAMCORDER_STATE_NONE;
2439 MMHandleType attr = 0;
2440 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2441 _MMCamcorderSubContext *sc = NULL;
2443 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2445 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2449 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2450 mmf_return_val_if_fail(attr, FALSE);
2452 MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2453 current_state = _mmcamcorder_get_state(handle);
2455 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2456 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2457 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2461 int height = value->value.i_val;
2462 int preview_format = MM_PIXEL_FORMAT_NV12;
2463 int codec_type = MM_IMAGE_CODEC_JPEG;
2464 int video_stabilization = 0;
2466 mm_camcorder_get_attributes(handle, NULL,
2467 MMCAM_CAMERA_WIDTH, &width,
2468 MMCAM_CAMERA_FORMAT, &preview_format,
2469 MMCAM_IMAGE_ENCODER, &codec_type,
2470 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2473 sc->info_video->preview_width = width;
2474 sc->info_video->preview_height = height;
2476 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2477 if (hcamcorder->resolution_changed == FALSE) {
2478 MMCAM_LOG_INFO("no need to restart preview");
2482 hcamcorder->resolution_changed = FALSE;
2484 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2485 MMCAM_LOG_INFO("restart preview");
2487 MMCAM_LOG_INFO("set empty buffers");
2489 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2490 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2492 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2493 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2495 /* check decoder recreation */
2496 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2497 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2498 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2502 /* get preview format */
2503 sc->info_image->preview_format = preview_format;
2504 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2506 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2508 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2509 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2511 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2512 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2515 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2517 MMCAM_LOG_ERROR("currently locked for preview restart");
2521 /* get preview format */
2522 sc->info_image->preview_format = preview_format;
2523 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2524 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2532 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2534 int current_state = MM_CAMCORDER_STATE_NONE;
2535 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2537 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2539 current_state = _mmcamcorder_get_state(handle);
2540 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2541 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2542 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2545 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2546 value->value.i_val, attr_idx);
2552 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2554 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2555 _MMCamcorderSubContext *sc = NULL;
2556 int current_state = MM_CAMCORDER_STATE_NONE;
2557 GstCameraControl *control = NULL;
2561 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2563 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2567 zoom_level = value->value.i_val;
2569 MMCAM_LOG_INFO("(%d)", attr_idx);
2571 current_state = _mmcamcorder_get_state(handle);
2572 if (current_state < MM_CAMCORDER_STATE_READY) {
2573 MMCAM_LOG_INFO("will be applied when preview starts");
2575 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2576 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2577 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2581 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2582 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2584 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2586 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2589 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2590 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2594 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2595 if (control == NULL) {
2596 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2600 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2602 MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2605 MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2608 MMCAM_LOG_INFO("pointer of video src is null");
2615 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2617 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2618 _MMCamcorderSubContext *sc = NULL;
2619 int current_state = MM_CAMCORDER_STATE_NONE;
2621 GstCameraControl *CameraControl = NULL;
2622 GstCameraControlChannel *CameraControlChannel = NULL;
2623 const GList *controls = NULL;
2624 const GList *item = NULL;
2626 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2628 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2629 mmf_return_val_if_fail(sc, TRUE);
2631 MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2633 current_state = _mmcamcorder_get_state(handle);
2634 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2635 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2636 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2637 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2641 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2642 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2643 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2647 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2648 if (CameraControl == NULL) {
2649 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2653 controls = gst_camera_control_list_channels(CameraControl);
2654 if (controls == NULL) {
2655 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2659 for (item = controls ; item && item->data ; item = item->next) {
2660 CameraControlChannel = item->data;
2661 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2662 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2663 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2664 MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2667 MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2673 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2680 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2682 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2683 _MMCamcorderSubContext *sc = NULL;
2684 int current_state = MM_CAMCORDER_STATE_NONE;
2686 GstCameraControl *CameraControl = NULL;
2687 GstCameraControlChannel *CameraControlChannel = NULL;
2688 const GList *controls = NULL;
2689 const GList *item = NULL;
2691 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2693 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2694 mmf_return_val_if_fail(sc, TRUE);
2696 MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2698 current_state = _mmcamcorder_get_state(handle);
2699 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2700 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2701 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2702 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2706 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2707 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2708 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2712 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2713 if (CameraControl == NULL) {
2714 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2718 controls = gst_camera_control_list_channels(CameraControl);
2719 if (controls == NULL) {
2720 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2724 for (item = controls ; item && item->data ; item = item->next) {
2725 CameraControlChannel = item->data;
2726 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2727 if (!strcmp(CameraControlChannel->label, "pan")) {
2728 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2729 MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2732 MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2738 MMCAM_LOG_WARNING("failed to find pan control channel");
2745 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2747 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2748 _MMCamcorderSubContext *sc = NULL;
2749 int current_state = MM_CAMCORDER_STATE_NONE;
2751 GstCameraControl *CameraControl = NULL;
2752 GstCameraControlChannel *CameraControlChannel = NULL;
2753 const GList *controls = NULL;
2754 const GList *item = NULL;
2756 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2758 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2759 mmf_return_val_if_fail(sc, TRUE);
2761 MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2763 current_state = _mmcamcorder_get_state(handle);
2764 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2765 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2766 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2767 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2771 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2772 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2773 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2777 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2778 if (CameraControl == NULL) {
2779 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2783 controls = gst_camera_control_list_channels(CameraControl);
2784 if (controls == NULL) {
2785 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2789 for (item = controls ; item && item->data ; item = item->next) {
2790 CameraControlChannel = item->data;
2791 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2792 if (!strcmp(CameraControlChannel->label, "tilt")) {
2793 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2794 MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2797 MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2803 MMCAM_LOG_WARNING("failed to find tilt control channel");
2810 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2812 MMHandleType attr = 0;
2813 int current_state = MM_CAMCORDER_STATE_NONE;
2814 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2815 _MMCamcorderSubContext *sc = NULL;
2816 GstCameraControl *control = NULL;
2818 int set_focus_mode = 0;
2819 int cur_focus_mode = 0;
2820 int cur_focus_range = 0;
2822 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2824 attr = MMF_CAMCORDER_ATTRS(handle);
2825 mmf_return_val_if_fail(attr, FALSE);
2827 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2831 MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2833 /* check whether set or not */
2834 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2835 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2839 current_state = _mmcamcorder_get_state(handle);
2840 if (current_state < MM_CAMCORDER_STATE_NULL) {
2841 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2843 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2844 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2845 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2849 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2850 int flags = MM_ATTRS_FLAG_NONE;
2851 MMCamAttrsInfo info;
2853 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2854 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2858 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2859 if (control == NULL) {
2860 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2864 mslVal = value->value.i_val;
2865 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2867 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2870 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2871 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2872 if (set_focus_mode != cur_focus_mode) {
2873 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2874 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2877 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2880 MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2884 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2888 MMCAM_LOG_INFO("pointer of video src is null");
2895 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2897 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2898 _MMCamcorderSubContext *sc = NULL;
2899 GstCameraControl *control = NULL;
2900 int current_state = MM_CAMCORDER_STATE_NONE;
2903 int cur_focus_mode = 0;
2904 int cur_focus_range = 0;
2905 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2906 int converted_mode = 0;
2908 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2910 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2914 MMCAM_LOG_INFO("(%d)", attr_idx);
2916 /* check whether set or not */
2917 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2918 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2922 mslVal = value->value.i_val;
2923 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2925 current_state = _mmcamcorder_get_state(handle);
2926 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2927 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
2929 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2930 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2931 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2935 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2936 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2937 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2941 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2942 if (control == NULL) {
2943 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2947 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
2948 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
2950 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2951 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
2952 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
2953 /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
2956 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2959 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
2963 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2966 MMCAM_LOG_INFO("pointer of video src is null");
2973 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2975 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2976 _MMCamcorderSubContext *sc = NULL;
2977 GstCameraControl *control = NULL;
2978 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
2979 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
2981 int current_state = MM_CAMCORDER_STATE_NONE;
2983 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2985 gboolean do_set = FALSE;
2987 MMCamAttrsInfo info_y;
2988 MMCamAttrsInfo info_w;
2989 MMCamAttrsInfo info_h;
2991 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2993 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2997 MMCAM_LOG_INFO("(%d)", attr_idx);
2999 current_state = _mmcamcorder_get_state(handle);
3000 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3001 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3003 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3004 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3005 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3009 ret = mm_camcorder_get_attributes(handle, NULL,
3010 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3012 if (ret != MM_ERROR_NONE) {
3013 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3017 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3018 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3022 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3023 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3024 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3028 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3029 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3030 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3033 case MM_CAM_CAMERA_AF_TOUCH_X:
3034 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3035 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3036 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3037 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3038 set_area.x = value->value.i_val;
3039 mm_camcorder_get_attributes(handle, NULL,
3040 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3041 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3042 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3046 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3050 case MM_CAM_CAMERA_AF_TOUCH_Y:
3051 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3052 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3053 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3054 set_area.y = value->value.i_val;
3055 mm_camcorder_get_attributes(handle, NULL,
3056 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3057 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3058 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3062 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3066 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3067 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3068 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3069 set_area.width = value->value.i_val;
3070 mm_camcorder_get_attributes(handle, NULL,
3071 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3072 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3073 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3077 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3081 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3082 set_area.height = value->value.i_val;
3083 mm_camcorder_get_attributes(handle, NULL,
3084 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3085 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3086 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3095 _MMCamcorderVideoInfo *info = sc->info_video;
3098 MMCAM_LOG_ERROR("video info is NULL");
3102 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3103 if (control == NULL) {
3104 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3109 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3110 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3111 float ratio_width = 0.0;
3112 float ratio_height = 0.0;
3114 if (info->preview_width != 0 && info->preview_height != 0) {
3115 ratio_width = (float)info->video_width / (float)info->preview_width;
3116 ratio_height = (float)info->video_height / (float)info->preview_height;
3118 MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3119 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3121 set_area.x = (int)((float)set_area.x * ratio_width);
3122 set_area.y = (int)((float)set_area.y * ratio_height);
3123 set_area.width = (int)((float)set_area.width * ratio_width);
3124 set_area.height = (int)((float)set_area.height * ratio_height);
3126 if (set_area.width <= 0)
3129 if (set_area.height <= 0)
3130 set_area.height = 1;
3132 MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3133 set_area.x, set_area.y, set_area.width, set_area.height);
3135 MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3136 info->preview_width, info->preview_height);
3140 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3142 MMCAM_LOG_WARNING("Failed to get AF area");
3146 /* width and height are not supported now */
3147 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3148 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3149 get_area.x, get_area.y);
3153 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3155 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3156 set_area.x, set_area.y, set_area.width, set_area.height);
3159 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3160 set_area.x, set_area.y, set_area.width, set_area.height);
3164 MMCAM_LOG_INFO("pointer of video src is null");
3171 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3173 GstCameraControl *control = NULL;
3179 int exposure_type = 0;
3180 int current_state = MM_CAMCORDER_STATE_NONE;
3181 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3182 _MMCamcorderSubContext *sc = NULL;
3184 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3185 gboolean check_scene_mode = FALSE;
3187 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3189 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3193 /* check whether set or not */
3194 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3195 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3199 current_state = _mmcamcorder_get_state(handle);
3200 if (current_state < MM_CAMCORDER_STATE_READY) {
3201 MMCAM_LOG_INFO("will be applied when preview starts");
3203 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3204 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3205 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3209 ivalue = value->value.i_val;
3211 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3212 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3213 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3214 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3215 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3216 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3217 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3218 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3219 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3220 exposure_type = GST_CAMERA_CONTROL_ISO;
3222 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3223 check_scene_mode = TRUE;
3224 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3225 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3227 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3228 check_scene_mode = TRUE;
3229 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3230 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3231 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3232 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3235 if (check_scene_mode) {
3236 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3237 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3238 MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3243 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3246 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3247 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3251 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3252 if (control == NULL) {
3253 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3257 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3259 MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3262 MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3265 MMCAM_LOG_INFO("pointer of video src is null");
3272 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3274 GstCameraControl *control = NULL;
3278 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3279 _MMCamcorderSubContext *sc = NULL;
3280 int current_state = MM_CAMCORDER_STATE_NONE;
3282 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3284 /* check whether set or not */
3285 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3286 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3290 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3294 /* check current state */
3295 current_state = _mmcamcorder_get_state(handle);
3296 if (current_state < MM_CAMCORDER_STATE_READY) {
3297 MMCAM_LOG_INFO("will be applied when preview starts");
3299 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3300 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3301 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3305 mslVal = value->value.i_val;
3306 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3308 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3309 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3310 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3314 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3315 if (control == NULL) {
3316 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3320 if (gst_camera_control_get_wdr(control, &cur_value)) {
3321 if (newVal != cur_value) {
3322 if (gst_camera_control_set_wdr(control, newVal)) {
3323 MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3326 MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3329 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3333 MMCAM_LOG_WARNING("Failed to get WDR.");
3336 MMCAM_LOG_INFO("pointer of video src is null");
3343 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3345 int current_state = MM_CAMCORDER_STATE_NONE;
3346 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3348 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3350 /* check whether set or not */
3351 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3352 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3356 current_state = _mmcamcorder_get_state(handle);
3357 if (current_state < MM_CAMCORDER_STATE_READY) {
3358 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3360 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3361 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3362 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3366 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3370 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3374 int current_state = MM_CAMCORDER_STATE_NONE;
3375 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3376 _MMCamcorderSubContext *sc = NULL;
3378 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3380 bitrate = value->value.i_val;
3382 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3383 if (!sc || !sc->encode_element) {
3384 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3388 current_state = _mmcamcorder_get_state(handle);
3389 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3390 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3391 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3395 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3396 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3398 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3399 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3401 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3402 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3409 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3411 int current_state = MM_CAMCORDER_STATE_NONE;
3412 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3414 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3416 current_state = _mmcamcorder_get_state(handle);
3417 if (current_state < MM_CAMCORDER_STATE_READY) {
3418 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3420 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3421 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3422 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3426 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3430 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3432 int current_state = MM_CAMCORDER_STATE_NONE;
3433 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3435 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3437 MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3439 current_state = _mmcamcorder_get_state(handle);
3441 if (current_state > MM_CAMCORDER_STATE_READY) {
3442 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3443 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3446 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3451 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3453 int current_state = MM_CAMCORDER_STATE_NONE;
3455 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3456 _MMCamcorderSubContext *sc = NULL;
3458 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3461 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3462 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3466 /* check current state */
3467 current_state = _mmcamcorder_get_state(handle);
3468 if (current_state < MM_CAMCORDER_STATE_READY) {
3469 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3471 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3472 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3473 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3477 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3479 MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3481 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3482 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3485 MMCAM_LOG_ERROR("invalid state %d", current_state);
3491 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3493 mmf_return_val_if_fail(handle && value, FALSE);
3496 if (!value->value.s_val) {
3497 MMCAM_LOG_ERROR("NULL filename");
3501 MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3507 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3509 int current_state = MM_CAMCORDER_STATE_NONE;
3510 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3512 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3514 current_state = _mmcamcorder_get_state(handle);
3515 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3516 MMCAM_LOG_ERROR("Can not set while RECORDING");
3517 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3525 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3527 GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3528 MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3529 return strcmp(Colorchannel->label, user_data);
3532 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3534 GstColorBalance *balance = NULL;
3535 GstColorBalanceChannel *Colorchannel = NULL;
3536 GList *controls = NULL;
3540 int current_state = MM_CAMCORDER_STATE_NONE;
3541 const char *control_label = NULL;
3542 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3543 _MMCamcorderSubContext *sc = NULL;
3545 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3546 gboolean check_scene_mode = FALSE;
3548 int wb_temp_table[] = {
3549 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3550 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3551 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3552 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3553 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3554 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3557 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3559 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3563 /* check whether set or not */
3564 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3565 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3569 current_state = _mmcamcorder_get_state(handle);
3570 if (current_state < MM_CAMCORDER_STATE_READY) {
3571 MMCAM_LOG_INFO("will be applied when preview starts");
3573 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3574 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3575 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3579 if (value->type != MM_ATTRS_TYPE_INT) {
3580 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3584 mslVal = value->value.i_val;
3587 case MM_CAM_FILTER_BRIGHTNESS:
3588 control_label = "brightness";
3589 check_scene_mode = TRUE;
3591 case MM_CAM_FILTER_CONTRAST:
3592 control_label = "contrast";
3594 case MM_CAM_FILTER_WB:
3595 control_label = "white balance";
3596 check_scene_mode = TRUE;
3598 case MM_CAM_FILTER_COLOR_TONE:
3599 control_label = "color tone";
3601 case MM_CAM_FILTER_SATURATION:
3602 control_label = "saturation";
3603 check_scene_mode = TRUE;
3605 case MM_CAM_FILTER_HUE:
3606 control_label = "hue";
3608 case MM_CAM_FILTER_SHARPNESS:
3609 control_label = "sharpness";
3610 check_scene_mode = TRUE;
3613 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3617 if (check_scene_mode) {
3618 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3619 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3620 MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3625 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3626 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3629 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3630 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3634 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3635 if (balance == NULL) {
3636 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3640 controls = (GList *)gst_color_balance_list_channels(balance);
3641 if (controls == NULL) {
3642 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3647 MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3648 attr_idx, control_label, mslVal, newVal);
3650 item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3652 Colorchannel = item->data;
3653 gst_color_balance_set_value(balance, Colorchannel, newVal);
3654 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3658 if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3659 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3661 control_label = "white_balance_temperature_auto";
3664 newVal = wb_temp_table[mslVal];
3665 control_label = "white_balance_temperature";
3670 MMCAM_LOG_ERROR("failed to find color channel item");
3676 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3680 int current_state = MM_CAMCORDER_STATE_NONE;
3681 GstCameraControl *control = NULL;
3682 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3683 _MMCamcorderSubContext *sc = NULL;
3685 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3687 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3691 mslVal = value->value.i_val;
3692 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3694 /* check whether set or not */
3695 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3696 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3700 current_state = _mmcamcorder_get_state(handle);
3701 if (current_state < MM_CAMCORDER_STATE_READY) {
3702 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3704 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3705 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3706 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3710 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3713 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3714 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3718 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3719 if (control == NULL) {
3720 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3724 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3726 MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3728 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3732 MM_CAM_FILTER_BRIGHTNESS,
3734 MM_CAM_FILTER_SATURATION,
3735 MM_CAM_FILTER_SHARPNESS,
3736 MM_CAM_FILTER_COLOR_TONE,
3737 MM_CAM_CAMERA_EXPOSURE_MODE
3739 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3741 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3742 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3743 mm_attrs_set_modified(attrs, attr_idxs[i]);
3749 MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3752 MMCAM_LOG_WARNING("pointer of video src is null");
3759 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3761 mmf_return_val_if_fail(handle && value, FALSE);
3763 MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3769 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3771 mmf_return_val_if_fail(handle && value, FALSE);
3773 MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3779 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3781 int current_state = MM_CAMCORDER_STATE_NONE;
3782 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3784 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3786 current_state = _mmcamcorder_get_state(handle);
3787 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3788 MMCAM_LOG_WARNING("Can NOT Disable AUDIO. invalid state %d", current_state);
3789 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3792 MMCAM_LOG_INFO("Disable AUDIO when Recording");
3798 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3800 int current_state = MM_CAMCORDER_STATE_NONE;
3801 const char *videosink_name = NULL;
3802 void *dp_handle = NULL;
3803 MMCamWindowInfo *window_info = NULL;
3805 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3806 _MMCamcorderSubContext *sc = NULL;
3808 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3811 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3812 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3816 /* check current state */
3817 current_state = _mmcamcorder_get_state(handle);
3818 if (current_state < MM_CAMCORDER_STATE_READY) {
3819 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3823 dp_handle = value->value.p_val;
3825 MMCAM_LOG_WARNING("Display handle is NULL");
3829 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3831 /* get videosink name */
3832 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3833 if (!videosink_name) {
3834 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3838 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3840 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3841 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
3842 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
3843 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3844 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
3845 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
3846 } else if (!strcmp(videosink_name, "tizenwlsink")) {
3847 window_info = (MMCamWindowInfo *)dp_handle;
3848 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
3849 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3850 } else if (!strcmp(videosink_name, "directvideosink")) {
3851 window_info = (MMCamWindowInfo *)dp_handle;
3852 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
3853 window_info->surface_id,
3854 window_info->rect.x,
3855 window_info->rect.y,
3856 window_info->rect.width,
3857 window_info->rect.height);
3858 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3859 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3860 window_info->rect.x,
3861 window_info->rect.y,
3862 window_info->rect.width,
3863 window_info->rect.height);
3865 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
3873 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3875 int current_state = MM_CAMCORDER_STATE_NONE;
3876 const char *videosink_name = NULL;
3878 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3879 _MMCamcorderSubContext *sc = NULL;
3881 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3884 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3885 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3889 /* check current state */
3890 current_state = _mmcamcorder_get_state(handle);
3891 if (current_state < MM_CAMCORDER_STATE_READY) {
3892 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3896 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3898 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3899 if (videosink_name == NULL) {
3900 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3904 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3906 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3907 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
3908 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3910 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
3917 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3919 int current_state = MM_CAMCORDER_STATE_NONE;
3921 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3923 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3926 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3927 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3931 /* check current state */
3932 current_state = _mmcamcorder_get_state(handle);
3933 if (current_state < MM_CAMCORDER_STATE_READY) {
3934 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3938 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3942 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3944 int current_state = MM_CAMCORDER_STATE_NONE;
3946 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3948 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3951 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3952 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3956 /* check current state */
3957 current_state = _mmcamcorder_get_state(handle);
3958 if (current_state < MM_CAMCORDER_STATE_READY) {
3959 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3963 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3967 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3969 int current_state = MM_CAMCORDER_STATE_NONE;
3970 const char *videosink_name = NULL;
3972 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3973 _MMCamcorderSubContext *sc = NULL;
3975 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3978 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3979 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3983 /* check current state */
3984 current_state = _mmcamcorder_get_state(handle);
3985 if (current_state < MM_CAMCORDER_STATE_READY) {
3986 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3990 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3992 /* Get videosink name */
3993 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3994 if (videosink_name == NULL) {
3995 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3999 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4000 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4001 !strcmp(videosink_name, "directvideosink")) {
4002 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4003 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4005 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4012 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4015 int current_state = MM_CAMCORDER_STATE_NONE;
4016 const char *videosink_name = NULL;
4018 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4019 _MMCamcorderSubContext *sc = NULL;
4021 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4024 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4025 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4029 /* check current state */
4030 current_state = _mmcamcorder_get_state(handle);
4031 if (current_state < MM_CAMCORDER_STATE_READY) {
4032 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4036 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4038 /* Get videosink name */
4039 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4040 if (videosink_name == NULL) {
4041 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4045 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4046 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4047 !strcmp(videosink_name, "directvideosink")) {
4048 method = value->value.i_val;
4049 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4051 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4058 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4060 int current_state = MM_CAMCORDER_STATE_NONE;
4061 int ret = MM_ERROR_NONE;
4062 const char *videosink_name = NULL;
4064 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4065 _MMCamcorderSubContext *sc = NULL;
4067 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4070 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4071 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4075 /* check current state */
4076 current_state = _mmcamcorder_get_state(handle);
4077 if (current_state < MM_CAMCORDER_STATE_READY) {
4078 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4082 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4084 /* Get videosink name */
4085 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4086 if (videosink_name == NULL) {
4087 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4091 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4092 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4096 int rect_height = 0;
4097 int flags = MM_ATTRS_FLAG_NONE;
4098 MMCamAttrsInfo info;
4100 mm_camcorder_get_attributes(handle, NULL,
4101 MMCAM_DISPLAY_RECT_X, &rect_x,
4102 MMCAM_DISPLAY_RECT_Y, &rect_y,
4103 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4104 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4107 case MM_CAM_DISPLAY_RECT_X:
4108 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4110 memset(&info, 0x00, sizeof(info));
4111 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4113 memset(&info, 0x00, sizeof(info));
4114 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4117 rect_x = value->value.i_val;
4119 case MM_CAM_DISPLAY_RECT_Y:
4120 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4122 memset(&info, 0x00, sizeof(info));
4123 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4126 rect_y = value->value.i_val;
4128 case MM_CAM_DISPLAY_RECT_WIDTH:
4129 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4132 rect_width = value->value.i_val;
4134 case MM_CAM_DISPLAY_RECT_HEIGHT:
4135 rect_height = value->value.i_val;
4138 MMCAM_LOG_ERROR("Wrong attr_idx!");
4142 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4143 MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4145 if (!strcmp(videosink_name, "tizenwlsink")) {
4146 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4147 rect_x, rect_y, rect_width, rect_height);
4149 MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4153 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4154 "dst-roi-x", rect_x,
4155 "dst-roi-y", rect_y,
4156 "dst-roi-w", rect_width,
4157 "dst-roi-h", rect_height,
4162 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4169 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4172 int current_state = MM_CAMCORDER_STATE_NONE;
4173 const char *videosink_name = NULL;
4174 GstElement *vs_element = NULL;
4176 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4177 _MMCamcorderSubContext *sc = NULL;
4179 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4182 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4183 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4187 /* check current state */
4188 current_state = _mmcamcorder_get_state(handle);
4189 if (current_state < MM_CAMCORDER_STATE_READY) {
4190 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4194 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4196 /* Get videosink name */
4197 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4198 if (videosink_name == NULL) {
4199 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4203 zoom = value->value.i_val;
4204 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4205 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4207 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4208 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4212 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4218 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4220 int current_state = MM_CAMCORDER_STATE_NONE;
4222 const char *videosink_name = NULL;
4224 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4225 _MMCamcorderSubContext *sc = NULL;
4227 mmf_return_val_if_fail(handle && value, FALSE);
4230 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4231 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4235 /* check current state */
4236 current_state = _mmcamcorder_get_state(handle);
4237 if (current_state < MM_CAMCORDER_STATE_READY) {
4238 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4242 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4244 do_scaling = value->value.i_val;
4246 /* Get videosink name */
4247 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4248 if (videosink_name == NULL) {
4249 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4253 if (!strcmp(videosink_name, "evaspixmapsink")) {
4254 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4255 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4258 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4264 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4267 _MMCamcorderSubContext *sc = NULL;
4268 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4269 int strobe_type, mslVal, newVal, cur_value;
4270 int current_state = MM_CAMCORDER_STATE_NONE;
4272 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4274 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4278 /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4280 mslVal = value->value.i_val;
4282 /* check flash state */
4283 if (attr_idx == MM_CAM_STROBE_MODE) {
4284 int flash_brightness = 0;
4286 /* get current flash brightness */
4287 if (_mmcamcorder_get_device_flash_brightness(hcamcorder->gdbus_conn, &flash_brightness) != MM_ERROR_NONE) {
4288 MMCAM_LOG_ERROR("_mmcamcorder_get_device_flash_brightness failed");
4289 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4293 MMCAM_LOG_INFO("flash brightness %d", flash_brightness);
4295 if (flash_brightness > 0 &&
4296 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4297 /* other module already turned on flash */
4298 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4299 MMCAM_LOG_ERROR("other module already turned on flash. avoid to set flash mode here.");
4302 MMCAM_LOG_INFO("keep going");
4307 current_state = _mmcamcorder_get_state(handle);
4308 if (current_state < MM_CAMCORDER_STATE_READY) {
4309 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4311 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4312 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4313 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4318 case MM_CAM_STROBE_CONTROL:
4319 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4320 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4322 case MM_CAM_STROBE_CAPABILITIES:
4323 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4326 case MM_CAM_STROBE_MODE:
4327 /* check whether set or not */
4328 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4329 MMCAM_LOG_INFO("skip set value %d", mslVal);
4333 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4334 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4337 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4341 GstCameraControl *control = NULL;
4342 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4343 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4346 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4347 if (control == NULL) {
4348 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4352 if (gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4353 if (newVal != cur_value) {
4354 if (gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4355 MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4358 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4362 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4366 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4375 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4378 int current_state = MM_CAMCORDER_STATE_NONE;
4379 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4381 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4383 MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4386 current_state = _mmcamcorder_get_state(handle);
4387 if (current_state > MM_CAMCORDER_STATE_READY) {
4388 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4389 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4391 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4392 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4396 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4398 MMCAM_LOG_INFO("ret %d", ret);
4404 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4406 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4407 int current_state = MM_CAMCORDER_STATE_NONE;
4408 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4409 _MMCamcorderSubContext *sc = NULL;
4411 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4413 /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4415 /* check whether set or not */
4416 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4417 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4422 current_state = _mmcamcorder_get_state(handle);
4423 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4424 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4425 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4429 if (current_state >= MM_CAMCORDER_STATE_READY) {
4430 int current_value = 0;
4432 set_hdr_mode = value->value.i_val;
4433 mm_camcorder_get_attributes(handle, NULL,
4434 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4437 if (set_hdr_mode == current_value) {
4438 MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4442 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4444 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4445 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4446 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4448 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4450 /* check decoder recreation */
4451 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4452 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4456 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4457 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4460 set_hdr_mode = value->value.i_val;
4461 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4462 sc->info_image->hdr_capture_mode = set_hdr_mode;
4463 MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4465 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4466 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4468 MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4477 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4480 _MMCamcorderSubContext *sc = NULL;
4481 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4483 int current_value = 0;
4484 int current_state = MM_CAMCORDER_STATE_NONE;
4485 GstCameraControl *control = NULL;
4487 mmf_return_val_if_fail(handle && value, FALSE);
4489 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4493 /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4496 current_state = _mmcamcorder_get_state(handle);
4497 if (current_state < MM_CAMCORDER_STATE_READY) {
4498 MMCAM_LOG_INFO("will be applied when preview starts");
4502 set_value = value->value.i_val;
4505 case MM_CAM_DETECT_MODE:
4506 /* check whether set or not */
4507 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4508 MMCAM_LOG_INFO("skip set value %d", set_value);
4512 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4514 case MM_CAM_DETECT_NUMBER:
4515 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4517 case MM_CAM_DETECT_FOCUS_SELECT:
4518 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4520 case MM_CAM_DETECT_SELECT_NUMBER:
4521 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4523 case MM_CAM_DETECT_STATUS:
4524 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4527 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4531 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4532 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4535 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4536 if (control == NULL) {
4537 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4541 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4542 if (current_value == set_value) {
4543 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4546 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4547 MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4548 detect_type, set_value);
4551 MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4552 detect_type, set_value);
4557 MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4566 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4568 int current_state = MM_CAMCORDER_STATE_NONE;
4569 int preview_format = MM_PIXEL_FORMAT_NV12;
4571 mmf_return_val_if_fail(handle && value, FALSE);
4573 MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4575 /* check preview format */
4576 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4577 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4578 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4583 current_state = _mmcamcorder_get_state(handle);
4584 if (current_state < MM_CAMCORDER_STATE_READY) {
4585 MMCAM_LOG_INFO("will be applied when preview starts");
4589 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4593 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4595 int current_state = MM_CAMCORDER_STATE_NONE;
4596 int preview_format = MM_PIXEL_FORMAT_NV12;
4598 mmf_return_val_if_fail(handle && value, FALSE);
4600 MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4602 /* check preview format */
4603 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4604 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4605 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4610 current_state = _mmcamcorder_get_state(handle);
4611 if (current_state < MM_CAMCORDER_STATE_READY) {
4612 MMCAM_LOG_INFO("will be applied when preview starts");
4616 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4620 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4622 int stream_index = 0;
4623 char *stream_type = NULL;
4624 _MMCamcorderSubContext *sc = NULL;
4626 mmf_return_val_if_fail(handle && value, FALSE);
4628 stream_type = value->value.s_val;
4630 MMCAM_LOG_ERROR("NULL string");
4634 mm_camcorder_get_attributes(handle, NULL,
4635 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4637 if (stream_index < 0) {
4638 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4642 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4643 if (!sc || !sc->encode_element ||
4644 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4645 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4649 MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4651 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4655 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4657 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4658 int current_state = MM_CAMCORDER_STATE_NONE;
4660 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4662 current_state = _mmcamcorder_get_state(handle);
4663 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4664 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4665 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4672 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4674 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4676 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4678 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4679 /* Replay gain enable */
4680 int current_state = MM_CAMCORDER_STATE_NONE;
4681 int audio_disable = FALSE;
4683 current_state = _mmcamcorder_get_state(handle);
4684 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4685 MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4686 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4690 mm_camcorder_get_attributes(handle, NULL,
4691 MMCAM_AUDIO_DISABLE, &audio_disable,
4694 if (audio_disable) {
4695 MMCAM_LOG_ERROR("audio is disabled");
4696 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4700 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4701 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4702 /* Replay gain reference level */
4703 int replay_gain_enable = FALSE;
4705 mm_camcorder_get_attributes(handle, NULL,
4706 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4709 if (replay_gain_enable == FALSE) {
4710 MMCAM_LOG_ERROR("replay gain is disabled");
4711 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4715 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4717 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4725 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4727 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4730 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4734 int attr_idxs_default[] = {
4735 MM_CAM_CAMERA_DIGITAL_ZOOM,
4736 MM_CAM_CAMERA_OPTICAL_ZOOM,
4738 MM_CAM_FILTER_CONTRAST,
4743 int attr_idxs_extra[] = {
4745 MM_CAM_FILTER_BRIGHTNESS,
4747 MM_CAM_FILTER_SATURATION,
4748 MM_CAM_FILTER_SHARPNESS,
4749 MM_CAM_FILTER_COLOR_TONE,
4750 MM_CAM_CAMERA_EXPOSURE_MODE
4753 mmf_return_val_if_fail(hcamcorder, FALSE);
4755 MMCAM_LOG_INFO("commit some attributes again");
4757 attrs = MMF_CAMCORDER_ATTRS(handle);
4758 if (attrs == NULL) {
4759 MMCAM_LOG_ERROR("Get attribute handle failed.");
4763 /* Get Scene mode */
4764 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4766 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4767 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4768 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4771 /* Set extra if scene mode is NORMAL */
4772 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4773 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4774 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4775 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4778 /* Set scene mode if scene mode is NOT NORMAL */
4779 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4780 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4783 if (mm_attrs_commit_all(attrs) == -1)
4788 MMCAM_LOG_INFO("Done.");
4794 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4796 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4802 MM_CAM_CAMERA_PTZ_TYPE,
4803 MM_CAM_CAMERA_PAN_MECHA,
4804 MM_CAM_CAMERA_PAN_ELEC,
4805 MM_CAM_CAMERA_TILT_MECHA,
4806 MM_CAM_CAMERA_TILT_ELEC
4809 mmf_return_val_if_fail(hcamcorder, FALSE);
4811 MMCAM_LOG_INFO("commit some attribute again[2]");
4813 attrs = MMF_CAMCORDER_ATTRS(handle);
4814 if (attrs == NULL) {
4815 MMCAM_LOG_ERROR("Get attribute handle failed.");
4819 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4820 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4821 mm_attrs_set_modified(attrs, attr_idxs[i]);
4824 if (mm_attrs_commit_all(attrs) == -1)
4829 MMCAM_LOG_INFO("Done.");
4835 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4837 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4841 int nerror = MM_ERROR_NONE;
4843 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4845 attrs = MMF_CAMCORDER_ATTRS(handle);
4846 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4850 table_size = ARRAY_SIZE(readonly_attributes);
4851 MMCAM_LOG_INFO("%d", table_size);
4852 for (i = 0; i < table_size; i++) {
4853 int sCategory = readonly_attributes[i];
4855 mm_attrs_set_readonly(attrs, sCategory);
4862 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4864 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4867 type_string_array * disabled_attr = NULL;
4869 int nerror = MM_ERROR_NONE ;
4871 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4873 attrs = MMF_CAMCORDER_ATTRS(handle);
4874 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4879 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4880 CONFIGURE_CATEGORY_MAIN_GENERAL,
4881 "DisabledAttributes",
4883 if (disabled_attr != NULL && disabled_attr->value) {
4884 cnt_str = disabled_attr->count;
4885 for (i = 0; i < cnt_str; i++) {
4887 MMCAM_LOG_INFO("[%d]%s", i, disabled_attr->value[i]);
4888 nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
4890 if (nerror == MM_ERROR_NONE)
4891 mm_attrs_set_disabled(attrs, idx);
4893 MMCAM_LOG_WARNING("No ATTR named %s[%d]", disabled_attr->value[i], i);
4901 /*---------------------------------------------------------------------------------------
4902 | INTERNAL FUNCTION DEFINITIONS: |
4903 ---------------------------------------------------------------------------------------*/
4904 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4906 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4907 _MMCamcorderSubContext *sc = NULL;
4908 int current_state = MM_CAMCORDER_STATE_NULL;
4910 mmf_return_val_if_fail(hcamcorder, FALSE);
4912 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4916 current_state = _mmcamcorder_get_state(handle);
4918 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4919 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4920 MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
4921 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4922 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4924 MMCAM_LOG_WARNING("invalid state[%d]", current_state);
4928 MMCAM_LOG_INFO("element is not created yet");
4935 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4937 #define INIT_VALUE -1
4938 #define CHECK_COUNT 3
4940 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4941 MMHandleType attrs = 0;
4943 int ret = MM_ERROR_NONE;
4946 const char *name = NULL;
4947 const char *check_pair_name[CHECK_COUNT][3] = {
4948 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
4949 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
4950 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
4953 int check_pair_value[CHECK_COUNT][2] = {
4954 {INIT_VALUE, INIT_VALUE},
4955 {INIT_VALUE, INIT_VALUE},
4956 {INIT_VALUE, INIT_VALUE},
4959 if (hcamcorder == NULL || attribute_name == NULL) {
4960 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
4961 hcamcorder, attribute_name);
4962 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4966 *err_attr_name = NULL;
4968 /*MMCAM_LOG_INFO( "ENTER" );*/
4970 attrs = MMF_CAMCORDER_ATTRS(handle);
4972 name = attribute_name;
4976 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
4978 /*MMCAM_LOG_INFO("NAME : %s", name);*/
4980 /* attribute name check */
4981 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
4983 *err_attr_name = strdup(name);
4985 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
4986 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
4992 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
4995 switch (attr_type) {
4996 case MM_ATTRS_TYPE_INT:
4998 gboolean matched = FALSE;
4999 for (i = 0 ; i < CHECK_COUNT ; i++) {
5000 for (j = 0 ; j < 2 ; j++) {
5001 if (!strcmp(name, check_pair_name[i][j])) {
5002 check_pair_value[i][j] = va_arg((var_args), int);
5003 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5011 if (matched == FALSE)
5012 va_arg((var_args), int);
5015 case MM_ATTRS_TYPE_DOUBLE:
5016 va_arg((var_args), double);
5018 case MM_ATTRS_TYPE_STRING:
5019 va_arg((var_args), char*); /* string */
5020 va_arg((var_args), int); /* size */
5022 case MM_ATTRS_TYPE_DATA:
5023 va_arg((var_args), void*); /* data */
5024 va_arg((var_args), int); /* size */
5026 case MM_ATTRS_TYPE_INVALID:
5028 MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5030 *err_attr_name = strdup(name);
5032 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5036 name = va_arg(var_args, const char*);
5039 for (i = 0 ; i < CHECK_COUNT ; i++) {
5040 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5041 gboolean check_result = FALSE;
5042 char *err_name = NULL;
5043 MMCamAttrsInfo attr_info_0, attr_info_1;
5045 if (check_pair_value[i][0] == INIT_VALUE) {
5046 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5047 err_name = strdup(check_pair_name[i][1]);
5048 } else if (check_pair_value[i][1] == INIT_VALUE) {
5049 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5050 err_name = strdup(check_pair_name[i][0]);
5052 err_name = strdup(check_pair_name[i][2]);
5055 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5056 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5058 check_result = FALSE;
5060 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5061 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5062 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5064 MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5065 check_pair_name[i][0], check_pair_name[i][1],
5066 check_pair_value[i][0], check_pair_value[i][1], i);
5068 check_result = TRUE;
5073 if (check_result == FALSE) {
5074 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5075 check_pair_name[i][0], check_pair_name[i][1],
5076 check_pair_value[i][0], check_pair_value[i][1]);
5077 if (err_attr_name) {
5078 *err_attr_name = err_name;
5086 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5089 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5090 int current_width = 0;
5091 int current_height = 0;
5093 mm_camcorder_get_attributes(handle, NULL,
5094 MMCAM_CAMERA_WIDTH, ¤t_width,
5095 MMCAM_CAMERA_HEIGHT, ¤t_height,
5098 if (current_width != check_pair_value[i][0] ||
5099 current_height != check_pair_value[i][1]) {
5100 hcamcorder->resolution_changed = TRUE;
5102 hcamcorder->resolution_changed = FALSE;
5105 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5115 /*MMCAM_LOG_INFO("DONE");*/
5117 return MM_ERROR_NONE;
5121 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5125 if ((void *)handle == NULL) {
5126 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5130 memset(&info, 0x0, sizeof(MMAttrsInfo));
5132 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5134 switch (info.validity_type) {
5135 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5137 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5139 if (info.int_array.count < 1)
5142 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5144 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5146 if (info.int_range.min > info.int_range.max)
5149 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5151 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5153 if (info.double_array.count < 1)
5156 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5158 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5160 if (info.double_range.min >= info.double_range.max)
5164 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);