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},
1660 MM_CAM_STROBE_BRIGHTNESS,
1661 "strobe-brightness",
1665 MM_ATTRS_VALID_TYPE_INT_RANGE,
1668 _mmcamcorder_commit_strobe,
1672 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1674 for (idx = 0 ; idx < attr_count ; idx++) {
1675 /* attribute order check. This should be same. */
1676 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1677 MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1678 free(attrs_const_info);
1679 attrs_const_info = NULL;
1680 free(hcamcorder->cam_attrs_const_info);
1681 hcamcorder->cam_attrs_const_info = NULL;
1685 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1686 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1687 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1688 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1691 /* Camcorder Attributes */
1692 MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1694 ret = mm_attrs_new(attrs_const_info,
1696 "Camcorder_Attributes",
1697 _mmcamcorder_commit_camcorder_attrs,
1701 free(attrs_const_info);
1702 attrs_const_info = NULL;
1704 if (ret != MM_ERROR_NONE) {
1705 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1706 free(hcamcorder->cam_attrs_const_info);
1707 hcamcorder->cam_attrs_const_info = NULL;
1711 __mmcamcorder_set_conf_to_valid_info(handle);
1713 for (idx = 0; idx < attr_count; idx++) {
1714 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1716 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1718 switch (attr_info->validity_type) {
1719 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1720 if (attr_info->validity_value_1.int_array &&
1721 attr_info->validity_value_2.count > 0) {
1722 mm_attrs_set_valid_array(attrs, idx,
1723 (const int *)(attr_info->validity_value_1.int_array),
1724 attr_info->validity_value_2.count,
1725 attr_info->default_value.value_int);
1728 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1729 mm_attrs_set_valid_range(attrs, idx,
1730 attr_info->validity_value_1.int_min,
1731 attr_info->validity_value_2.int_max,
1732 attr_info->default_value.value_int);
1734 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1735 if (attr_info->validity_value_1.double_array &&
1736 attr_info->validity_value_2.count > 0) {
1737 mm_attrs_set_valid_double_array(attrs, idx,
1738 (const double *)(attr_info->validity_value_1.double_array),
1739 attr_info->validity_value_2.count,
1740 attr_info->default_value.value_double);
1743 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1744 mm_attrs_set_valid_double_range(attrs, idx,
1745 attr_info->validity_value_1.double_min,
1746 attr_info->validity_value_2.double_max,
1747 attr_info->default_value.value_double);
1749 case MM_ATTRS_VALID_TYPE_NONE:
1751 case MM_ATTRS_VALID_TYPE_INVALID:
1753 MMCAM_LOG_ERROR("Valid type error.");
1758 __mmcamcorder_release_conf_valid_info(handle);
1765 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1767 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1769 if (hcamcorder == NULL) {
1770 MMCAM_LOG_ERROR("handle is NULL");
1777 mm_attrs_free(attrs);
1778 MMCAM_LOG_INFO("released attribute");
1781 if (hcamcorder->cam_attrs_const_info) {
1782 free(hcamcorder->cam_attrs_const_info);
1783 hcamcorder->cam_attrs_const_info = NULL;
1784 MMCAM_LOG_INFO("released attribute info");
1792 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1794 MMHandleType attrs = 0;
1795 int ret = MM_ERROR_NONE;
1797 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1798 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1800 attrs = MMF_CAMCORDER_ATTRS(handle);
1801 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1803 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1810 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1812 MMHandleType attrs = 0;
1813 int ret = MM_ERROR_NONE;
1815 char *tmp_err_attr_name = NULL;
1816 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1817 va_list var_args_copy;
1819 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1821 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1822 MMCAM_LOG_ERROR("Another command is running.");
1823 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1826 /* copy var_args to keep original var_args */
1827 va_copy(var_args_copy, var_args);
1829 attrs = MMF_CAMCORDER_ATTRS(handle);
1831 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1833 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1834 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1837 if (ret == MM_ERROR_NONE) {
1838 hcamcorder->error_code = MM_ERROR_NONE;
1839 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1840 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1843 va_end(var_args_copy);
1845 _MMCAMCORDER_UNLOCK_CMD(handle);
1847 if (ret != MM_ERROR_NONE) {
1848 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1849 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1850 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1851 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1852 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1853 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1857 if (hcamcorder->error_code != MM_ERROR_NONE) {
1858 MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1859 ret = hcamcorder->error_code;
1860 hcamcorder->error_code = MM_ERROR_NONE;
1863 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1866 if (tmp_err_attr_name) {
1867 if (!err_attr_name) {
1868 MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1869 free(tmp_err_attr_name);
1870 tmp_err_attr_name = NULL;
1872 *err_attr_name = tmp_err_attr_name;
1881 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1883 MMHandleType attrs = 0;
1884 MMAttrsInfo attrinfo;
1885 int ret = MM_ERROR_NONE;
1887 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1888 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1889 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1891 attrs = MMF_CAMCORDER_ATTRS(handle);
1892 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1894 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1896 if (ret == MM_ERROR_NONE) {
1897 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1898 info->type = attrinfo.type;
1899 info->flag = attrinfo.flag;
1900 info->validity_type = attrinfo.validity_type;
1902 switch (attrinfo.validity_type) {
1903 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1904 info->int_array.array = attrinfo.int_array.array;
1905 info->int_array.count = attrinfo.int_array.count;
1906 info->int_array.def = attrinfo.int_array.dval;
1908 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1909 info->int_range.min = attrinfo.int_range.min;
1910 info->int_range.max = attrinfo.int_range.max;
1911 info->int_range.def = attrinfo.int_range.dval;
1913 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1914 info->double_array.array = attrinfo.double_array.array;
1915 info->double_array.count = attrinfo.double_array.count;
1916 info->double_array.def = attrinfo.double_array.dval;
1918 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1919 info->double_range.min = attrinfo.double_range.min;
1920 info->double_range.max = attrinfo.double_range.max;
1921 info->double_range.def = attrinfo.double_range.dval;
1923 case MM_ATTRS_VALID_TYPE_NONE:
1925 case MM_ATTRS_VALID_TYPE_INVALID:
1936 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1939 mmf_camcorder_t *hcamcorder = NULL;
1941 mmf_return_val_if_fail(commit_param, FALSE);
1942 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1943 mmf_return_val_if_fail(attr_name, FALSE);
1944 mmf_return_val_if_fail(value, FALSE);
1946 hcamcorder = MMF_CAMCORDER(commit_param);
1948 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1949 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1957 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1960 int total_count = 0;
1962 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1964 if (hcamcorder == NULL) {
1965 MMCAM_LOG_ERROR("handle is NULL");
1966 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1970 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
1971 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
1972 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
1975 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
1976 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
1977 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
1980 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
1981 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
1982 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
1985 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
1986 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
1987 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
1989 return MM_ERROR_NONE;
1993 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
1995 int *allocated_memory = NULL;
1997 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1999 if (hcamcorder == NULL) {
2000 MMCAM_LOG_ERROR("handle is NULL");
2001 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2004 MMCAM_LOG_INFO("START");
2006 /* Audio encoder info */
2007 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2008 if (allocated_memory) {
2009 g_free(allocated_memory);
2010 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2011 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2014 /* Video encoder info */
2015 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2016 if (allocated_memory) {
2017 g_free(allocated_memory);
2018 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2019 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2022 /* Image encoder info */
2023 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2024 if (allocated_memory) {
2025 g_free(allocated_memory);
2026 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2027 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2030 /* File format info */
2031 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2032 if (allocated_memory) {
2033 g_free(allocated_memory);
2034 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2035 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2038 MMCAM_LOG_INFO("DONE");
2040 return MM_ERROR_NONE;
2044 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2046 MMHandleType attr = 0;
2047 int current_state = MM_CAMCORDER_STATE_NONE;
2049 mmf_return_val_if_fail(handle && value, FALSE);
2051 attr = MMF_CAMCORDER_ATTRS(handle);
2052 mmf_return_val_if_fail(attr, FALSE);
2054 /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2056 current_state = _mmcamcorder_get_state(handle);
2057 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2058 int flags = MM_ATTRS_FLAG_NONE;
2059 int capture_width, capture_height;
2060 MMCamAttrsInfo info;
2062 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2065 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2066 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2067 capture_width = value->value.i_val;
2069 /* Check whether they are valid pair */
2070 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2075 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2081 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2083 int current_state = MM_CAMCORDER_STATE_NONE;
2085 current_state = _mmcamcorder_get_state(handle);
2087 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2088 int capture_width, capture_height;
2090 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2091 capture_height = value->value.i_val;
2093 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2095 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2102 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2104 int current_state = 0;
2106 const char *videosrc_name = NULL;
2107 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2108 _MMCamcorderSubContext *sc = NULL;
2109 _MMCamcorderImageInfo *info = NULL;
2110 GstCameraControl *control = NULL;
2111 type_element *VideosrcElement = NULL;
2113 mmf_return_val_if_fail(handle && value, FALSE);
2115 current_state = _mmcamcorder_get_state(handle);
2116 ivalue = value->value.i_val;
2118 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2119 CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
2122 _mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
2124 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2128 info = sc->info_image;
2130 MMCAM_LOG_ERROR("info image is NULL");
2134 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2135 if (info->capture_send_count > 0) {
2136 info->capturing = FALSE;
2137 MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2140 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2141 MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2145 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2147 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2148 MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2150 MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2153 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2160 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2162 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2163 int current_state = MM_CAMCORDER_STATE_NONE;
2164 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2166 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2168 current_state = _mmcamcorder_get_state(handle);
2169 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2171 MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2172 current_state, mode, value->value.i_val);
2174 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2175 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2178 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2184 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2186 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2188 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2190 MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2192 /* return error when disable shutter sound if policy is TRUE */
2193 if (!value->value.i_val &&
2194 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2195 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2198 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2204 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2206 int current_state = MM_CAMCORDER_STATE_NONE;
2207 _MMCamcorderSubContext *sc = NULL;
2210 mmf_return_val_if_fail(handle && value, FALSE);
2212 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2216 current_state = _mmcamcorder_get_state(handle);
2218 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2219 double mslNewVal = 0;
2220 mslNewVal = value->value.d_val;
2222 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2223 if (mslNewVal == 0.0) {
2224 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2225 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2227 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2228 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2232 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2235 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2243 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2245 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2246 int current_state = MM_CAMCORDER_STATE_NONE;
2248 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2250 current_state = _mmcamcorder_get_state(handle);
2251 if (current_state > MM_CAMCORDER_STATE_READY) {
2252 MMCAM_LOG_ERROR("invalid state %d", current_state);
2253 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2261 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2263 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2264 MMCamAttrsInfo fps_info;
2265 int resolution_width = 0;
2266 int resolution_height = 0;
2269 int current_state = MM_CAMCORDER_STATE_NONE;
2271 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2273 current_state = _mmcamcorder_get_state(handle);
2274 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2275 MMCAM_LOG_ERROR("invalid state %d", current_state);
2276 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2280 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2283 MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2285 ret = mm_camcorder_get_attributes(handle, NULL,
2286 MMCAM_CAMERA_WIDTH, &resolution_width,
2287 MMCAM_CAMERA_HEIGHT, &resolution_height,
2290 if (ret != MM_ERROR_NONE) {
2291 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2295 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2296 if (ret != MM_ERROR_NONE) {
2297 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2301 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2302 if (value->value.i_val == fps_info.int_array.array[i])
2306 MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2312 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2314 int current_state = MM_CAMCORDER_STATE_NONE;
2315 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2316 _MMCamcorderSubContext *sc = NULL;
2318 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2320 current_state = _mmcamcorder_get_state(handle);
2321 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2322 MMCAM_LOG_WARNING("invalid state %d", current_state);
2323 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2327 /* Verify recording motion rate */
2328 if (value->value.d_val > 0.0) {
2329 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2333 /* set is_slow flag */
2334 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2335 sc->is_modified_rate = TRUE;
2337 sc->is_modified_rate = FALSE;
2339 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2342 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2348 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2350 MMHandleType attr = 0;
2351 int current_state = MM_CAMCORDER_STATE_NONE;
2353 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2354 _MMCamcorderSubContext *sc = NULL;
2356 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2358 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2362 attr = MMF_CAMCORDER_ATTRS(handle);
2363 mmf_return_val_if_fail(attr, FALSE);
2365 MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2367 current_state = _mmcamcorder_get_state(handle);
2369 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2370 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2373 int flags = MM_ATTRS_FLAG_NONE;
2374 MMCamAttrsInfo info;
2375 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2378 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2379 int width = value->value.i_val;
2381 int preview_format = MM_PIXEL_FORMAT_NV12;
2382 int codec_type = MM_IMAGE_CODEC_JPEG;
2384 mm_camcorder_get_attributes(handle, NULL,
2385 MMCAM_CAMERA_HEIGHT, &height,
2386 MMCAM_CAMERA_FORMAT, &preview_format,
2387 MMCAM_IMAGE_ENCODER, &codec_type,
2390 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2391 if (hcamcorder->resolution_changed == FALSE) {
2392 MMCAM_LOG_INFO("no need to restart preview");
2396 hcamcorder->resolution_changed = FALSE;
2398 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2399 MMCAM_LOG_INFO("restart preview");
2401 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2402 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2404 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2405 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2407 /* check decoder recreation */
2408 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2409 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2410 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2414 /* get preview format */
2415 sc->info_image->preview_format = preview_format;
2416 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2417 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2419 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2420 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2422 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2423 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2426 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2428 MMCAM_LOG_ERROR("currently locked for preview restart");
2432 /* get preview format */
2433 sc->info_image->preview_format = preview_format;
2434 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2435 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2446 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2449 int current_state = MM_CAMCORDER_STATE_NONE;
2450 MMHandleType attr = 0;
2451 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2452 _MMCamcorderSubContext *sc = NULL;
2454 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2456 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2460 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2461 mmf_return_val_if_fail(attr, FALSE);
2463 MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2464 current_state = _mmcamcorder_get_state(handle);
2466 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2467 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2468 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2472 int height = value->value.i_val;
2473 int preview_format = MM_PIXEL_FORMAT_NV12;
2474 int codec_type = MM_IMAGE_CODEC_JPEG;
2475 int video_stabilization = 0;
2477 mm_camcorder_get_attributes(handle, NULL,
2478 MMCAM_CAMERA_WIDTH, &width,
2479 MMCAM_CAMERA_FORMAT, &preview_format,
2480 MMCAM_IMAGE_ENCODER, &codec_type,
2481 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2484 sc->info_video->preview_width = width;
2485 sc->info_video->preview_height = height;
2487 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2488 if (hcamcorder->resolution_changed == FALSE) {
2489 MMCAM_LOG_INFO("no need to restart preview");
2493 hcamcorder->resolution_changed = FALSE;
2495 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2496 MMCAM_LOG_INFO("restart preview");
2498 MMCAM_LOG_INFO("set empty buffers");
2500 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2501 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2503 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2504 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2506 /* check decoder recreation */
2507 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2508 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2509 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2513 /* get preview format */
2514 sc->info_image->preview_format = preview_format;
2515 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2517 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2519 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2520 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2522 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2523 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2526 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2528 MMCAM_LOG_ERROR("currently locked for preview restart");
2532 /* get preview format */
2533 sc->info_image->preview_format = preview_format;
2534 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2535 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2543 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2545 int current_state = MM_CAMCORDER_STATE_NONE;
2546 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2548 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2550 current_state = _mmcamcorder_get_state(handle);
2551 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2552 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2553 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2556 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2557 value->value.i_val, attr_idx);
2563 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2565 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2566 _MMCamcorderSubContext *sc = NULL;
2567 int current_state = MM_CAMCORDER_STATE_NONE;
2568 GstCameraControl *control = NULL;
2572 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2574 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2578 zoom_level = value->value.i_val;
2580 MMCAM_LOG_INFO("(%d)", attr_idx);
2582 current_state = _mmcamcorder_get_state(handle);
2583 if (current_state < MM_CAMCORDER_STATE_READY) {
2584 MMCAM_LOG_INFO("will be applied when preview starts");
2586 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2587 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2588 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2592 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2593 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2595 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2597 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2600 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2601 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2605 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2606 if (control == NULL) {
2607 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2611 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2613 MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2616 MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2619 MMCAM_LOG_INFO("pointer of video src is null");
2626 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2628 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2629 _MMCamcorderSubContext *sc = NULL;
2630 int current_state = MM_CAMCORDER_STATE_NONE;
2632 GstCameraControl *CameraControl = NULL;
2633 GstCameraControlChannel *CameraControlChannel = NULL;
2634 const GList *controls = NULL;
2635 const GList *item = NULL;
2637 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2639 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2640 mmf_return_val_if_fail(sc, TRUE);
2642 MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2644 current_state = _mmcamcorder_get_state(handle);
2645 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2646 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2647 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2648 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2652 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2653 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2654 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2658 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2659 if (CameraControl == NULL) {
2660 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2664 controls = gst_camera_control_list_channels(CameraControl);
2665 if (controls == NULL) {
2666 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2670 for (item = controls ; item && item->data ; item = item->next) {
2671 CameraControlChannel = item->data;
2672 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2673 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2674 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2675 MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2678 MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2684 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2691 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2693 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2694 _MMCamcorderSubContext *sc = NULL;
2695 int current_state = MM_CAMCORDER_STATE_NONE;
2697 GstCameraControl *CameraControl = NULL;
2698 GstCameraControlChannel *CameraControlChannel = NULL;
2699 const GList *controls = NULL;
2700 const GList *item = NULL;
2702 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2704 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2705 mmf_return_val_if_fail(sc, TRUE);
2707 MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2709 current_state = _mmcamcorder_get_state(handle);
2710 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2711 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2712 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2713 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2717 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2718 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2719 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2723 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2724 if (CameraControl == NULL) {
2725 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2729 controls = gst_camera_control_list_channels(CameraControl);
2730 if (controls == NULL) {
2731 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2735 for (item = controls ; item && item->data ; item = item->next) {
2736 CameraControlChannel = item->data;
2737 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2738 if (!strcmp(CameraControlChannel->label, "pan")) {
2739 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2740 MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2743 MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2749 MMCAM_LOG_WARNING("failed to find pan control channel");
2756 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2758 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2759 _MMCamcorderSubContext *sc = NULL;
2760 int current_state = MM_CAMCORDER_STATE_NONE;
2762 GstCameraControl *CameraControl = NULL;
2763 GstCameraControlChannel *CameraControlChannel = NULL;
2764 const GList *controls = NULL;
2765 const GList *item = NULL;
2767 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2769 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2770 mmf_return_val_if_fail(sc, TRUE);
2772 MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2774 current_state = _mmcamcorder_get_state(handle);
2775 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2776 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2777 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2778 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2782 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2783 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2784 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2788 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2789 if (CameraControl == NULL) {
2790 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2794 controls = gst_camera_control_list_channels(CameraControl);
2795 if (controls == NULL) {
2796 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2800 for (item = controls ; item && item->data ; item = item->next) {
2801 CameraControlChannel = item->data;
2802 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2803 if (!strcmp(CameraControlChannel->label, "tilt")) {
2804 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2805 MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2808 MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2814 MMCAM_LOG_WARNING("failed to find tilt control channel");
2821 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2823 MMHandleType attr = 0;
2824 int current_state = MM_CAMCORDER_STATE_NONE;
2825 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2826 _MMCamcorderSubContext *sc = NULL;
2827 GstCameraControl *control = NULL;
2829 int set_focus_mode = 0;
2830 int cur_focus_mode = 0;
2831 int cur_focus_range = 0;
2833 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2835 attr = MMF_CAMCORDER_ATTRS(handle);
2836 mmf_return_val_if_fail(attr, FALSE);
2838 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2842 MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2844 /* check whether set or not */
2845 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2846 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2850 current_state = _mmcamcorder_get_state(handle);
2851 if (current_state < MM_CAMCORDER_STATE_NULL) {
2852 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2854 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2855 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2856 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2860 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2861 int flags = MM_ATTRS_FLAG_NONE;
2862 MMCamAttrsInfo info;
2864 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2865 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2869 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2870 if (control == NULL) {
2871 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2875 mslVal = value->value.i_val;
2876 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2878 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2881 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2882 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2883 if (set_focus_mode != cur_focus_mode) {
2884 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2885 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2888 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2891 MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2895 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2899 MMCAM_LOG_INFO("pointer of video src is null");
2906 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2908 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2909 _MMCamcorderSubContext *sc = NULL;
2910 GstCameraControl *control = NULL;
2911 int current_state = MM_CAMCORDER_STATE_NONE;
2914 int cur_focus_mode = 0;
2915 int cur_focus_range = 0;
2916 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2917 int converted_mode = 0;
2919 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2921 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2925 MMCAM_LOG_INFO("(%d)", attr_idx);
2927 /* check whether set or not */
2928 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2929 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2933 mslVal = value->value.i_val;
2934 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2936 current_state = _mmcamcorder_get_state(handle);
2937 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2938 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
2940 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2941 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2942 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2946 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2947 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2948 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2952 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2953 if (control == NULL) {
2954 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2958 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
2959 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
2961 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2962 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
2963 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
2964 /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
2967 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2970 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
2974 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2977 MMCAM_LOG_INFO("pointer of video src is null");
2984 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2986 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2987 _MMCamcorderSubContext *sc = NULL;
2988 GstCameraControl *control = NULL;
2989 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
2990 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
2992 int current_state = MM_CAMCORDER_STATE_NONE;
2994 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2996 gboolean do_set = FALSE;
2998 MMCamAttrsInfo info_y;
2999 MMCamAttrsInfo info_w;
3000 MMCamAttrsInfo info_h;
3002 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3004 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3008 MMCAM_LOG_INFO("(%d)", attr_idx);
3010 current_state = _mmcamcorder_get_state(handle);
3011 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3012 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3014 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3015 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3016 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3020 ret = mm_camcorder_get_attributes(handle, NULL,
3021 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3023 if (ret != MM_ERROR_NONE) {
3024 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3028 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3029 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3033 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3034 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3035 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3039 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3040 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3041 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3044 case MM_CAM_CAMERA_AF_TOUCH_X:
3045 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3046 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3047 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3048 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3049 set_area.x = value->value.i_val;
3050 mm_camcorder_get_attributes(handle, NULL,
3051 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3052 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3053 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3057 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3061 case MM_CAM_CAMERA_AF_TOUCH_Y:
3062 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3063 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3064 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3065 set_area.y = value->value.i_val;
3066 mm_camcorder_get_attributes(handle, NULL,
3067 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3068 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3069 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3073 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3077 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3078 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3079 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3080 set_area.width = value->value.i_val;
3081 mm_camcorder_get_attributes(handle, NULL,
3082 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3083 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3084 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3088 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3092 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3093 set_area.height = value->value.i_val;
3094 mm_camcorder_get_attributes(handle, NULL,
3095 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3096 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3097 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3106 _MMCamcorderVideoInfo *info = sc->info_video;
3109 MMCAM_LOG_ERROR("video info is NULL");
3113 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3114 if (control == NULL) {
3115 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3120 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3121 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3122 float ratio_width = 0.0;
3123 float ratio_height = 0.0;
3125 if (info->preview_width != 0 && info->preview_height != 0) {
3126 ratio_width = (float)info->video_width / (float)info->preview_width;
3127 ratio_height = (float)info->video_height / (float)info->preview_height;
3129 MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3130 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3132 set_area.x = (int)((float)set_area.x * ratio_width);
3133 set_area.y = (int)((float)set_area.y * ratio_height);
3134 set_area.width = (int)((float)set_area.width * ratio_width);
3135 set_area.height = (int)((float)set_area.height * ratio_height);
3137 if (set_area.width <= 0)
3140 if (set_area.height <= 0)
3141 set_area.height = 1;
3143 MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3144 set_area.x, set_area.y, set_area.width, set_area.height);
3146 MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3147 info->preview_width, info->preview_height);
3151 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3153 MMCAM_LOG_WARNING("Failed to get AF area");
3157 /* width and height are not supported now */
3158 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3159 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3160 get_area.x, get_area.y);
3164 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3166 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3167 set_area.x, set_area.y, set_area.width, set_area.height);
3170 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3171 set_area.x, set_area.y, set_area.width, set_area.height);
3175 MMCAM_LOG_INFO("pointer of video src is null");
3182 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3184 GstCameraControl *control = NULL;
3190 int exposure_type = 0;
3191 int current_state = MM_CAMCORDER_STATE_NONE;
3192 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3193 _MMCamcorderSubContext *sc = NULL;
3195 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3196 gboolean check_scene_mode = FALSE;
3198 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3200 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3204 /* check whether set or not */
3205 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3206 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3210 current_state = _mmcamcorder_get_state(handle);
3211 if (current_state < MM_CAMCORDER_STATE_READY) {
3212 MMCAM_LOG_INFO("will be applied when preview starts");
3214 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3215 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3216 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3220 ivalue = value->value.i_val;
3222 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3223 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3224 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3225 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3226 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3227 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3228 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3229 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3230 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3231 exposure_type = GST_CAMERA_CONTROL_ISO;
3233 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3234 check_scene_mode = TRUE;
3235 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3236 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3238 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3239 check_scene_mode = TRUE;
3240 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3241 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3242 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3243 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3246 if (check_scene_mode) {
3247 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3248 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3249 MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3254 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3257 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3258 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3262 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3263 if (control == NULL) {
3264 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3268 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3270 MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3273 MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3276 MMCAM_LOG_INFO("pointer of video src is null");
3283 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3285 GstCameraControl *control = NULL;
3289 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3290 _MMCamcorderSubContext *sc = NULL;
3291 int current_state = MM_CAMCORDER_STATE_NONE;
3293 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3295 /* check whether set or not */
3296 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3297 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3301 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3305 /* check current state */
3306 current_state = _mmcamcorder_get_state(handle);
3307 if (current_state < MM_CAMCORDER_STATE_READY) {
3308 MMCAM_LOG_INFO("will be applied when preview starts");
3310 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3311 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3312 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3316 mslVal = value->value.i_val;
3317 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3319 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3320 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3321 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3325 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3326 if (control == NULL) {
3327 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3331 if (gst_camera_control_get_wdr(control, &cur_value)) {
3332 if (newVal != cur_value) {
3333 if (gst_camera_control_set_wdr(control, newVal)) {
3334 MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3337 MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3340 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3344 MMCAM_LOG_WARNING("Failed to get WDR.");
3347 MMCAM_LOG_INFO("pointer of video src is null");
3354 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3356 int current_state = MM_CAMCORDER_STATE_NONE;
3357 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3359 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3361 /* check whether set or not */
3362 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3363 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3367 current_state = _mmcamcorder_get_state(handle);
3368 if (current_state < MM_CAMCORDER_STATE_READY) {
3369 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3371 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3372 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3373 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3377 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3381 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3385 int current_state = MM_CAMCORDER_STATE_NONE;
3386 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3387 _MMCamcorderSubContext *sc = NULL;
3389 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3391 bitrate = value->value.i_val;
3393 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3394 if (!sc || !sc->encode_element) {
3395 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3399 current_state = _mmcamcorder_get_state(handle);
3400 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3401 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3402 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3406 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3407 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3409 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3410 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3412 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3413 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3420 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3422 int current_state = MM_CAMCORDER_STATE_NONE;
3423 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3425 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3427 current_state = _mmcamcorder_get_state(handle);
3428 if (current_state < MM_CAMCORDER_STATE_READY) {
3429 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3431 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3432 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3433 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3437 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3441 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3443 int current_state = MM_CAMCORDER_STATE_NONE;
3444 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3446 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3448 MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3450 current_state = _mmcamcorder_get_state(handle);
3452 if (current_state > MM_CAMCORDER_STATE_READY) {
3453 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3454 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3457 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3462 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3464 int current_state = MM_CAMCORDER_STATE_NONE;
3466 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3467 _MMCamcorderSubContext *sc = NULL;
3469 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3472 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3473 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3477 /* check current state */
3478 current_state = _mmcamcorder_get_state(handle);
3479 if (current_state < MM_CAMCORDER_STATE_READY) {
3480 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3482 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3483 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3484 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3488 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3490 MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3492 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3493 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3496 MMCAM_LOG_ERROR("invalid state %d", current_state);
3502 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3504 mmf_return_val_if_fail(handle && value, FALSE);
3507 if (!value->value.s_val) {
3508 MMCAM_LOG_ERROR("NULL filename");
3512 MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3518 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3520 int current_state = MM_CAMCORDER_STATE_NONE;
3521 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3523 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3525 current_state = _mmcamcorder_get_state(handle);
3526 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3527 MMCAM_LOG_ERROR("Can not set while RECORDING");
3528 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3536 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3538 GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3539 MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3540 return strcmp(Colorchannel->label, user_data);
3543 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3545 GstColorBalance *balance = NULL;
3546 GstColorBalanceChannel *Colorchannel = NULL;
3547 GList *controls = NULL;
3551 int current_state = MM_CAMCORDER_STATE_NONE;
3552 const char *control_label = NULL;
3553 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3554 _MMCamcorderSubContext *sc = NULL;
3556 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3557 gboolean check_scene_mode = FALSE;
3559 int wb_temp_table[] = {
3560 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3561 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3562 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3563 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3564 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3565 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3568 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3570 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3574 /* check whether set or not */
3575 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3576 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3580 current_state = _mmcamcorder_get_state(handle);
3581 if (current_state < MM_CAMCORDER_STATE_READY) {
3582 MMCAM_LOG_INFO("will be applied when preview starts");
3584 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3585 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3586 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3590 if (value->type != MM_ATTRS_TYPE_INT) {
3591 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3595 mslVal = value->value.i_val;
3598 case MM_CAM_FILTER_BRIGHTNESS:
3599 control_label = "brightness";
3600 check_scene_mode = TRUE;
3602 case MM_CAM_FILTER_CONTRAST:
3603 control_label = "contrast";
3605 case MM_CAM_FILTER_WB:
3606 control_label = "white balance";
3607 check_scene_mode = TRUE;
3609 case MM_CAM_FILTER_COLOR_TONE:
3610 control_label = "color tone";
3612 case MM_CAM_FILTER_SATURATION:
3613 control_label = "saturation";
3614 check_scene_mode = TRUE;
3616 case MM_CAM_FILTER_HUE:
3617 control_label = "hue";
3619 case MM_CAM_FILTER_SHARPNESS:
3620 control_label = "sharpness";
3621 check_scene_mode = TRUE;
3624 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3628 if (check_scene_mode) {
3629 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3630 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3631 MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3636 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3637 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3640 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3641 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3645 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3646 if (balance == NULL) {
3647 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3651 controls = (GList *)gst_color_balance_list_channels(balance);
3652 if (controls == NULL) {
3653 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3658 MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3659 attr_idx, control_label, mslVal, newVal);
3661 item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3663 Colorchannel = item->data;
3664 gst_color_balance_set_value(balance, Colorchannel, newVal);
3665 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3669 if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3670 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3672 control_label = "white_balance_temperature_auto";
3675 newVal = wb_temp_table[mslVal];
3676 control_label = "white_balance_temperature";
3681 MMCAM_LOG_ERROR("failed to find color channel item");
3687 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3691 int current_state = MM_CAMCORDER_STATE_NONE;
3692 GstCameraControl *control = NULL;
3693 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3694 _MMCamcorderSubContext *sc = NULL;
3696 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3698 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3702 mslVal = value->value.i_val;
3703 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3705 /* check whether set or not */
3706 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3707 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3711 current_state = _mmcamcorder_get_state(handle);
3712 if (current_state < MM_CAMCORDER_STATE_READY) {
3713 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3715 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3716 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3717 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3721 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3724 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3725 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3729 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3730 if (control == NULL) {
3731 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3735 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3737 MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3739 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3743 MM_CAM_FILTER_BRIGHTNESS,
3745 MM_CAM_FILTER_SATURATION,
3746 MM_CAM_FILTER_SHARPNESS,
3747 MM_CAM_FILTER_COLOR_TONE,
3748 MM_CAM_CAMERA_EXPOSURE_MODE
3750 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3752 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3753 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3754 mm_attrs_set_modified(attrs, attr_idxs[i]);
3760 MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3763 MMCAM_LOG_WARNING("pointer of video src is null");
3770 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3772 mmf_return_val_if_fail(handle && value, FALSE);
3774 MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3780 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3782 mmf_return_val_if_fail(handle && value, FALSE);
3784 MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3790 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3792 int current_state = MM_CAMCORDER_STATE_NONE;
3793 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3795 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3797 current_state = _mmcamcorder_get_state(handle);
3798 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3799 MMCAM_LOG_WARNING("Can NOT Disable AUDIO. invalid state %d", current_state);
3800 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3803 MMCAM_LOG_INFO("Disable AUDIO when Recording");
3809 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3811 int current_state = MM_CAMCORDER_STATE_NONE;
3812 const char *videosink_name = NULL;
3813 void *dp_handle = NULL;
3814 MMCamWindowInfo *window_info = NULL;
3816 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3817 _MMCamcorderSubContext *sc = NULL;
3819 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3822 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3823 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3827 /* check current state */
3828 current_state = _mmcamcorder_get_state(handle);
3829 if (current_state < MM_CAMCORDER_STATE_READY) {
3830 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3834 dp_handle = value->value.p_val;
3836 MMCAM_LOG_WARNING("Display handle is NULL");
3840 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3842 /* get videosink name */
3843 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3844 if (!videosink_name) {
3845 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3849 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3851 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3852 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
3853 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
3854 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3855 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
3856 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
3857 } else if (!strcmp(videosink_name, "tizenwlsink")) {
3858 window_info = (MMCamWindowInfo *)dp_handle;
3859 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
3860 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3861 } else if (!strcmp(videosink_name, "directvideosink")) {
3862 window_info = (MMCamWindowInfo *)dp_handle;
3863 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
3864 window_info->surface_id,
3865 window_info->rect.x,
3866 window_info->rect.y,
3867 window_info->rect.width,
3868 window_info->rect.height);
3869 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3870 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3871 window_info->rect.x,
3872 window_info->rect.y,
3873 window_info->rect.width,
3874 window_info->rect.height);
3876 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
3884 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3886 int current_state = MM_CAMCORDER_STATE_NONE;
3887 const char *videosink_name = NULL;
3889 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3890 _MMCamcorderSubContext *sc = NULL;
3892 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3895 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3896 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3900 /* check current state */
3901 current_state = _mmcamcorder_get_state(handle);
3902 if (current_state < MM_CAMCORDER_STATE_READY) {
3903 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3907 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3909 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3910 if (videosink_name == NULL) {
3911 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3915 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3917 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3918 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
3919 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3921 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
3928 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3930 int current_state = MM_CAMCORDER_STATE_NONE;
3932 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3934 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3937 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3938 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3942 /* check current state */
3943 current_state = _mmcamcorder_get_state(handle);
3944 if (current_state < MM_CAMCORDER_STATE_READY) {
3945 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3949 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3953 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3955 int current_state = MM_CAMCORDER_STATE_NONE;
3957 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3959 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3962 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3963 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3967 /* check current state */
3968 current_state = _mmcamcorder_get_state(handle);
3969 if (current_state < MM_CAMCORDER_STATE_READY) {
3970 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3974 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3978 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3980 int current_state = MM_CAMCORDER_STATE_NONE;
3981 const char *videosink_name = NULL;
3983 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3984 _MMCamcorderSubContext *sc = NULL;
3986 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3989 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3990 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3994 /* check current state */
3995 current_state = _mmcamcorder_get_state(handle);
3996 if (current_state < MM_CAMCORDER_STATE_READY) {
3997 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4001 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4003 /* Get videosink name */
4004 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4005 if (videosink_name == NULL) {
4006 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4010 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4011 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4012 !strcmp(videosink_name, "directvideosink")) {
4013 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4014 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4016 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4023 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4026 int current_state = MM_CAMCORDER_STATE_NONE;
4027 const char *videosink_name = NULL;
4029 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4030 _MMCamcorderSubContext *sc = NULL;
4032 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4035 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4036 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4040 /* check current state */
4041 current_state = _mmcamcorder_get_state(handle);
4042 if (current_state < MM_CAMCORDER_STATE_READY) {
4043 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4047 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4049 /* Get videosink name */
4050 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4051 if (videosink_name == NULL) {
4052 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4056 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4057 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4058 !strcmp(videosink_name, "directvideosink")) {
4059 method = value->value.i_val;
4060 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4062 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4069 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4071 int current_state = MM_CAMCORDER_STATE_NONE;
4072 int ret = MM_ERROR_NONE;
4073 const char *videosink_name = NULL;
4075 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4076 _MMCamcorderSubContext *sc = NULL;
4078 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4081 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4082 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4086 /* check current state */
4087 current_state = _mmcamcorder_get_state(handle);
4088 if (current_state < MM_CAMCORDER_STATE_READY) {
4089 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4093 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4095 /* Get videosink name */
4096 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4097 if (videosink_name == NULL) {
4098 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4102 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4103 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4107 int rect_height = 0;
4108 int flags = MM_ATTRS_FLAG_NONE;
4109 MMCamAttrsInfo info;
4111 mm_camcorder_get_attributes(handle, NULL,
4112 MMCAM_DISPLAY_RECT_X, &rect_x,
4113 MMCAM_DISPLAY_RECT_Y, &rect_y,
4114 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4115 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4118 case MM_CAM_DISPLAY_RECT_X:
4119 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4121 memset(&info, 0x00, sizeof(info));
4122 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4124 memset(&info, 0x00, sizeof(info));
4125 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4128 rect_x = value->value.i_val;
4130 case MM_CAM_DISPLAY_RECT_Y:
4131 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4133 memset(&info, 0x00, sizeof(info));
4134 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4137 rect_y = value->value.i_val;
4139 case MM_CAM_DISPLAY_RECT_WIDTH:
4140 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4143 rect_width = value->value.i_val;
4145 case MM_CAM_DISPLAY_RECT_HEIGHT:
4146 rect_height = value->value.i_val;
4149 MMCAM_LOG_ERROR("Wrong attr_idx!");
4153 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4154 MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4156 if (!strcmp(videosink_name, "tizenwlsink")) {
4157 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4158 rect_x, rect_y, rect_width, rect_height);
4160 MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4164 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4165 "dst-roi-x", rect_x,
4166 "dst-roi-y", rect_y,
4167 "dst-roi-w", rect_width,
4168 "dst-roi-h", rect_height,
4173 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4180 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4183 int current_state = MM_CAMCORDER_STATE_NONE;
4184 const char *videosink_name = NULL;
4185 GstElement *vs_element = NULL;
4187 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4188 _MMCamcorderSubContext *sc = NULL;
4190 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4193 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4194 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4198 /* check current state */
4199 current_state = _mmcamcorder_get_state(handle);
4200 if (current_state < MM_CAMCORDER_STATE_READY) {
4201 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4205 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4207 /* Get videosink name */
4208 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4209 if (videosink_name == NULL) {
4210 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4214 zoom = value->value.i_val;
4215 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4216 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4218 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4219 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4223 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4229 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4231 int current_state = MM_CAMCORDER_STATE_NONE;
4233 const char *videosink_name = NULL;
4235 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4236 _MMCamcorderSubContext *sc = NULL;
4238 mmf_return_val_if_fail(handle && value, FALSE);
4241 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4242 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4246 /* check current state */
4247 current_state = _mmcamcorder_get_state(handle);
4248 if (current_state < MM_CAMCORDER_STATE_READY) {
4249 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4253 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4255 do_scaling = value->value.i_val;
4257 /* Get videosink name */
4258 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4259 if (videosink_name == NULL) {
4260 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4264 if (!strcmp(videosink_name, "evaspixmapsink")) {
4265 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4266 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4269 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4275 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4277 _MMCamcorderSubContext *sc = NULL;
4278 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4279 int strobe_type, mslVal, newVal, cur_value;
4280 int current_state = MM_CAMCORDER_STATE_NONE;
4282 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4284 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4288 /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4290 mslVal = value->value.i_val;
4292 /* check flash state */
4293 if (attr_idx == MM_CAM_STROBE_MODE) {
4294 int led_brightness = 0;
4296 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4297 MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4298 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4302 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4304 if (led_brightness > 0 &&
4305 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4306 /* other module already turned on LED */
4307 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4308 MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4312 MMCAM_LOG_INFO("keep going");
4316 current_state = _mmcamcorder_get_state(handle);
4317 if (current_state < MM_CAMCORDER_STATE_READY) {
4318 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4320 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4321 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4322 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4327 case MM_CAM_STROBE_CONTROL:
4328 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4329 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4331 case MM_CAM_STROBE_CAPABILITIES:
4332 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4335 case MM_CAM_STROBE_MODE:
4336 /* check whether set or not */
4337 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4338 MMCAM_LOG_INFO("skip set value %d", mslVal);
4342 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4343 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4345 case MM_CAM_STROBE_BRIGHTNESS:
4346 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4350 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4354 GstCameraControl *control = NULL;
4355 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4356 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4360 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4361 if (control == NULL) {
4362 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4366 if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4367 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4371 if (newVal == cur_value) {
4372 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4376 if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4377 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4381 MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4387 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4390 int current_state = MM_CAMCORDER_STATE_NONE;
4391 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4393 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4395 MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4398 current_state = _mmcamcorder_get_state(handle);
4399 if (current_state > MM_CAMCORDER_STATE_READY) {
4400 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4401 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4403 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4404 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4408 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4410 MMCAM_LOG_INFO("ret %d", ret);
4416 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4418 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4419 int current_state = MM_CAMCORDER_STATE_NONE;
4420 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4421 _MMCamcorderSubContext *sc = NULL;
4423 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4425 /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4427 /* check whether set or not */
4428 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4429 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4434 current_state = _mmcamcorder_get_state(handle);
4435 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4436 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4437 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4441 if (current_state >= MM_CAMCORDER_STATE_READY) {
4442 int current_value = 0;
4444 set_hdr_mode = value->value.i_val;
4445 mm_camcorder_get_attributes(handle, NULL,
4446 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4449 if (set_hdr_mode == current_value) {
4450 MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4454 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4456 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4457 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4458 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4460 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4462 /* check decoder recreation */
4463 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4464 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4468 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4469 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4472 set_hdr_mode = value->value.i_val;
4473 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4474 sc->info_image->hdr_capture_mode = set_hdr_mode;
4475 MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4477 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4478 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4480 MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4489 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4492 _MMCamcorderSubContext *sc = NULL;
4493 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4495 int current_value = 0;
4496 int current_state = MM_CAMCORDER_STATE_NONE;
4497 GstCameraControl *control = NULL;
4499 mmf_return_val_if_fail(handle && value, FALSE);
4501 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4505 /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4508 current_state = _mmcamcorder_get_state(handle);
4509 if (current_state < MM_CAMCORDER_STATE_READY) {
4510 MMCAM_LOG_INFO("will be applied when preview starts");
4514 set_value = value->value.i_val;
4517 case MM_CAM_DETECT_MODE:
4518 /* check whether set or not */
4519 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4520 MMCAM_LOG_INFO("skip set value %d", set_value);
4524 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4526 case MM_CAM_DETECT_NUMBER:
4527 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4529 case MM_CAM_DETECT_FOCUS_SELECT:
4530 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4532 case MM_CAM_DETECT_SELECT_NUMBER:
4533 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4535 case MM_CAM_DETECT_STATUS:
4536 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4539 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4543 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4544 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4547 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4548 if (control == NULL) {
4549 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4553 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4554 if (current_value == set_value) {
4555 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4558 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4559 MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4560 detect_type, set_value);
4563 MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4564 detect_type, set_value);
4569 MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4578 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4580 int current_state = MM_CAMCORDER_STATE_NONE;
4581 int preview_format = MM_PIXEL_FORMAT_NV12;
4583 mmf_return_val_if_fail(handle && value, FALSE);
4585 MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4587 /* check preview format */
4588 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4589 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4590 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4595 current_state = _mmcamcorder_get_state(handle);
4596 if (current_state < MM_CAMCORDER_STATE_READY) {
4597 MMCAM_LOG_INFO("will be applied when preview starts");
4601 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4605 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4607 int current_state = MM_CAMCORDER_STATE_NONE;
4608 int preview_format = MM_PIXEL_FORMAT_NV12;
4610 mmf_return_val_if_fail(handle && value, FALSE);
4612 MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4614 /* check preview format */
4615 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4616 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4617 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4622 current_state = _mmcamcorder_get_state(handle);
4623 if (current_state < MM_CAMCORDER_STATE_READY) {
4624 MMCAM_LOG_INFO("will be applied when preview starts");
4628 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4632 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4634 int stream_index = 0;
4635 char *stream_type = NULL;
4636 _MMCamcorderSubContext *sc = NULL;
4638 mmf_return_val_if_fail(handle && value, FALSE);
4640 stream_type = value->value.s_val;
4642 MMCAM_LOG_ERROR("NULL string");
4646 mm_camcorder_get_attributes(handle, NULL,
4647 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4649 if (stream_index < 0) {
4650 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4654 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4655 if (!sc || !sc->encode_element ||
4656 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4657 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4661 MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4663 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4667 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4669 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4670 int current_state = MM_CAMCORDER_STATE_NONE;
4672 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4674 current_state = _mmcamcorder_get_state(handle);
4675 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4676 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4677 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4684 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4686 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4688 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4690 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4691 /* Replay gain enable */
4692 int current_state = MM_CAMCORDER_STATE_NONE;
4693 int audio_disable = FALSE;
4695 current_state = _mmcamcorder_get_state(handle);
4696 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4697 MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4698 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4702 mm_camcorder_get_attributes(handle, NULL,
4703 MMCAM_AUDIO_DISABLE, &audio_disable,
4706 if (audio_disable) {
4707 MMCAM_LOG_ERROR("audio is disabled");
4708 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4712 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4713 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4714 /* Replay gain reference level */
4715 int replay_gain_enable = FALSE;
4717 mm_camcorder_get_attributes(handle, NULL,
4718 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4721 if (replay_gain_enable == FALSE) {
4722 MMCAM_LOG_ERROR("replay gain is disabled");
4723 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4727 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4729 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4737 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4739 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4742 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4746 int attr_idxs_default[] = {
4747 MM_CAM_CAMERA_DIGITAL_ZOOM,
4748 MM_CAM_CAMERA_OPTICAL_ZOOM,
4750 MM_CAM_FILTER_CONTRAST,
4753 MM_CAM_STROBE_BRIGHTNESS
4756 int attr_idxs_extra[] = {
4758 MM_CAM_FILTER_BRIGHTNESS,
4760 MM_CAM_FILTER_SATURATION,
4761 MM_CAM_FILTER_SHARPNESS,
4762 MM_CAM_FILTER_COLOR_TONE,
4763 MM_CAM_CAMERA_EXPOSURE_MODE
4766 mmf_return_val_if_fail(hcamcorder, FALSE);
4768 MMCAM_LOG_INFO("commit some attributes again");
4770 attrs = MMF_CAMCORDER_ATTRS(handle);
4771 if (attrs == NULL) {
4772 MMCAM_LOG_ERROR("Get attribute handle failed.");
4776 /* Get Scene mode */
4777 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4779 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4780 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4781 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4784 /* Set extra if scene mode is NORMAL */
4785 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4786 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4787 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4788 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4791 /* Set scene mode if scene mode is NOT NORMAL */
4792 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4793 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4796 if (mm_attrs_commit_all(attrs) == -1)
4801 MMCAM_LOG_INFO("Done.");
4807 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4809 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4815 MM_CAM_CAMERA_PTZ_TYPE,
4816 MM_CAM_CAMERA_PAN_MECHA,
4817 MM_CAM_CAMERA_PAN_ELEC,
4818 MM_CAM_CAMERA_TILT_MECHA,
4819 MM_CAM_CAMERA_TILT_ELEC
4822 mmf_return_val_if_fail(hcamcorder, FALSE);
4824 MMCAM_LOG_INFO("commit some attribute again[2]");
4826 attrs = MMF_CAMCORDER_ATTRS(handle);
4827 if (attrs == NULL) {
4828 MMCAM_LOG_ERROR("Get attribute handle failed.");
4832 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4833 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4834 mm_attrs_set_modified(attrs, attr_idxs[i]);
4837 if (mm_attrs_commit_all(attrs) == -1)
4842 MMCAM_LOG_INFO("Done.");
4848 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4850 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4854 int nerror = MM_ERROR_NONE;
4856 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4858 attrs = MMF_CAMCORDER_ATTRS(handle);
4859 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4863 table_size = ARRAY_SIZE(readonly_attributes);
4864 MMCAM_LOG_INFO("%d", table_size);
4865 for (i = 0; i < table_size; i++) {
4866 int sCategory = readonly_attributes[i];
4868 mm_attrs_set_readonly(attrs, sCategory);
4875 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4877 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4880 type_string_array * disabled_attr = NULL;
4882 int nerror = MM_ERROR_NONE ;
4884 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4886 attrs = MMF_CAMCORDER_ATTRS(handle);
4887 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4892 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4893 CONFIGURE_CATEGORY_MAIN_GENERAL,
4894 "DisabledAttributes",
4896 if (disabled_attr != NULL && disabled_attr->value) {
4897 cnt_str = disabled_attr->count;
4898 for (i = 0; i < cnt_str; i++) {
4900 MMCAM_LOG_INFO("[%d]%s", i, disabled_attr->value[i]);
4901 nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
4903 if (nerror == MM_ERROR_NONE)
4904 mm_attrs_set_disabled(attrs, idx);
4906 MMCAM_LOG_WARNING("No ATTR named %s[%d]", disabled_attr->value[i], i);
4914 /*---------------------------------------------------------------------------------------
4915 | INTERNAL FUNCTION DEFINITIONS: |
4916 ---------------------------------------------------------------------------------------*/
4917 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4919 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4920 _MMCamcorderSubContext *sc = NULL;
4921 int current_state = MM_CAMCORDER_STATE_NULL;
4923 mmf_return_val_if_fail(hcamcorder, FALSE);
4925 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4929 current_state = _mmcamcorder_get_state(handle);
4931 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4932 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4933 MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
4934 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4935 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4937 MMCAM_LOG_WARNING("invalid state[%d]", current_state);
4941 MMCAM_LOG_INFO("element is not created yet");
4948 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4950 #define INIT_VALUE -1
4951 #define CHECK_COUNT 3
4953 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4954 MMHandleType attrs = 0;
4956 int ret = MM_ERROR_NONE;
4959 const char *name = NULL;
4960 const char *check_pair_name[CHECK_COUNT][3] = {
4961 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
4962 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
4963 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
4966 int check_pair_value[CHECK_COUNT][2] = {
4967 {INIT_VALUE, INIT_VALUE},
4968 {INIT_VALUE, INIT_VALUE},
4969 {INIT_VALUE, INIT_VALUE},
4972 if (hcamcorder == NULL || attribute_name == NULL) {
4973 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
4974 hcamcorder, attribute_name);
4975 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4979 *err_attr_name = NULL;
4981 /*MMCAM_LOG_INFO( "ENTER" );*/
4983 attrs = MMF_CAMCORDER_ATTRS(handle);
4985 name = attribute_name;
4989 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
4991 /*MMCAM_LOG_INFO("NAME : %s", name);*/
4993 /* attribute name check */
4994 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
4996 *err_attr_name = strdup(name);
4998 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
4999 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5005 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5008 switch (attr_type) {
5009 case MM_ATTRS_TYPE_INT:
5011 gboolean matched = FALSE;
5012 for (i = 0 ; i < CHECK_COUNT ; i++) {
5013 for (j = 0 ; j < 2 ; j++) {
5014 if (!strcmp(name, check_pair_name[i][j])) {
5015 check_pair_value[i][j] = va_arg((var_args), int);
5016 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5024 if (matched == FALSE)
5025 va_arg((var_args), int);
5028 case MM_ATTRS_TYPE_DOUBLE:
5029 va_arg((var_args), double);
5031 case MM_ATTRS_TYPE_STRING:
5032 va_arg((var_args), char*); /* string */
5033 va_arg((var_args), int); /* size */
5035 case MM_ATTRS_TYPE_DATA:
5036 va_arg((var_args), void*); /* data */
5037 va_arg((var_args), int); /* size */
5039 case MM_ATTRS_TYPE_INVALID:
5041 MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5043 *err_attr_name = strdup(name);
5045 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5049 name = va_arg(var_args, const char*);
5052 for (i = 0 ; i < CHECK_COUNT ; i++) {
5053 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5054 gboolean check_result = FALSE;
5055 char *err_name = NULL;
5056 MMCamAttrsInfo attr_info_0, attr_info_1;
5058 if (check_pair_value[i][0] == INIT_VALUE) {
5059 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5060 err_name = strdup(check_pair_name[i][1]);
5061 } else if (check_pair_value[i][1] == INIT_VALUE) {
5062 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5063 err_name = strdup(check_pair_name[i][0]);
5065 err_name = strdup(check_pair_name[i][2]);
5068 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5069 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5071 check_result = FALSE;
5073 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5074 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5075 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5077 MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5078 check_pair_name[i][0], check_pair_name[i][1],
5079 check_pair_value[i][0], check_pair_value[i][1], i);
5081 check_result = TRUE;
5086 if (check_result == FALSE) {
5087 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5088 check_pair_name[i][0], check_pair_name[i][1],
5089 check_pair_value[i][0], check_pair_value[i][1]);
5090 if (err_attr_name) {
5091 *err_attr_name = err_name;
5099 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5102 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5103 int current_width = 0;
5104 int current_height = 0;
5106 mm_camcorder_get_attributes(handle, NULL,
5107 MMCAM_CAMERA_WIDTH, ¤t_width,
5108 MMCAM_CAMERA_HEIGHT, ¤t_height,
5111 if (current_width != check_pair_value[i][0] ||
5112 current_height != check_pair_value[i][1]) {
5113 hcamcorder->resolution_changed = TRUE;
5115 hcamcorder->resolution_changed = FALSE;
5118 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5128 /*MMCAM_LOG_INFO("DONE");*/
5130 return MM_ERROR_NONE;
5134 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5138 if ((void *)handle == NULL) {
5139 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5143 memset(&info, 0x0, sizeof(MMAttrsInfo));
5145 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5147 switch (info.validity_type) {
5148 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5150 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5152 if (info.int_array.count < 1)
5155 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5157 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5159 if (info.int_range.min > info.int_range.max)
5162 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5164 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5166 if (info.double_array.count < 1)
5169 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5171 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5173 if (info.double_range.min >= info.double_range.max)
5177 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);