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,
67 MM_CAM_VIDEOSRC_ELEMENT_NAME,
68 MM_CAM_AUDIOSRC_ELEMENT_NAME
71 /*-----------------------------------------------------------------------
72 | LOCAL FUNCTION PROTOTYPES: |
73 -----------------------------------------------------------------------*/
74 /* STATIC INTERNAL FUNCTION */
75 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height);
76 static int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle);
77 static int __mmcamcorder_release_conf_valid_info(MMHandleType handle);
78 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
80 /*=======================================================================
81 | FUNCTION DEFINITIONS |
82 =======================================================================*/
83 /*-----------------------------------------------------------------------
84 | GLOBAL FUNCTION DEFINITIONS: |
85 -----------------------------------------------------------------------*/
87 _mmcamcorder_alloc_attribute(MMHandleType handle)
91 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
92 MMHandleType attrs = NULL;
93 MMAttrsConstructInfo *attrs_const_info;
94 unsigned int attr_count = 0;
96 int ret = MM_ERROR_NONE;
98 static int depth[] = {MM_CAMCORDER_AUDIO_FORMAT_PCM_U8, MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE};
99 static int flip_list[] = { MM_FLIP_NONE };
100 static int rotation_list[] = { MM_VIDEO_INPUT_ROTATION_NONE };
101 static int visible_values[] = { 0, 1 }; /*0: off, 1:on*/
102 static int tag_orientation_values[] = {
103 1, /*The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.*/
104 2, /*the 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.*/
105 3, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.*/
106 4, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.*/
107 5, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual top.*/
108 6, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual top.*/
109 7, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.*/
110 8, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.*/
113 if (hcamcorder == NULL) {
114 MMCAM_LOG_ERROR("handle is NULL");
118 /* Create attribute constructor */
119 MMCAM_LOG_INFO("start");
121 /* alloc 'MMAttrsConstructInfo' */
122 attr_count = MM_CAM_ATTRIBUTE_NUM;
123 attrs_const_info = malloc(attr_count * sizeof(MMAttrsConstructInfo));
124 if (!attrs_const_info) {
125 MMCAM_LOG_ERROR("Fail to alloc constructor.");
129 /* alloc default attribute info */
130 hcamcorder->cam_attrs_const_info = (mm_cam_attr_construct_info *)malloc(sizeof(mm_cam_attr_construct_info) * attr_count);
131 if (hcamcorder->cam_attrs_const_info == NULL) {
132 MMCAM_LOG_ERROR("failed to alloc default attribute info");
133 free(attrs_const_info);
134 attrs_const_info = NULL;
138 /* basic attributes' info */
139 mm_cam_attr_construct_info temp_info[] = {
142 MM_CAM_MODE, /* ID */
144 MM_ATTRS_TYPE_INT, /* Type */
145 MM_ATTRS_FLAG_RW, /* Flag */
146 {(void*)MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Default value */
147 MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */
148 {.int_min = MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Validity val1 (min, *array,...) */
149 {.int_max = MM_CAMCORDER_MODE_AUDIO}, /* Validity val2 (max, count, ...) */
150 NULL, /* Runtime setting function of the attribute */
157 {(void*)MM_AUDIO_DEVICE_MIC},
158 MM_ATTRS_VALID_TYPE_INT_ARRAY,
164 MM_CAM_CAMERA_DEVICE_COUNT,
165 "camera-device-count",
168 {(void*)MM_VIDEO_DEVICE_NUM},
169 MM_ATTRS_VALID_TYPE_INT_RANGE,
170 {.int_min = MM_VIDEO_DEVICE_NONE},
171 {.int_max = MM_VIDEO_DEVICE_NUM},
175 MM_CAM_AUDIO_ENCODER,
179 {(void*)MM_AUDIO_CODEC_AMR},
180 MM_ATTRS_VALID_TYPE_INT_ARRAY,
186 MM_CAM_VIDEO_ENCODER,
190 {(void*)MM_VIDEO_CODEC_MPEG4},
191 MM_ATTRS_VALID_TYPE_INT_ARRAY,
197 MM_CAM_IMAGE_ENCODER,
201 {(void*)MM_IMAGE_CODEC_JPEG},
202 MM_ATTRS_VALID_TYPE_INT_ARRAY,
212 {(void*)MM_FILE_FORMAT_MP4},
213 MM_ATTRS_VALID_TYPE_INT_ARRAY,
219 MM_CAM_CAMERA_DEVICE_NAME,
220 "camera-device-name",
221 MM_ATTRS_TYPE_STRING,
224 MM_ATTRS_VALID_TYPE_NONE,
230 MM_CAM_AUDIO_SAMPLERATE,
235 MM_ATTRS_VALID_TYPE_INT_RANGE,
237 {.int_max = _MMCAMCORDER_MAX_INT},
245 {(void*)MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE},
246 MM_ATTRS_VALID_TYPE_INT_ARRAY,
253 MM_CAM_AUDIO_CHANNEL,
258 MM_ATTRS_VALID_TYPE_INT_RANGE,
266 MM_ATTRS_TYPE_DOUBLE,
268 {.value_double = 1.0},
269 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
271 {.double_max = 10.0},
272 _mmcamcorder_commit_audio_volume,
275 MM_CAM_AUDIO_INPUT_ROUTE,
279 {(void*)MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
280 MM_ATTRS_VALID_TYPE_INT_RANGE,
281 {.int_min = MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
282 {.int_max = MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY},
283 _mmcamcorder_commit_audio_input_route,
286 MM_CAM_FILTER_SCENE_MODE,
291 MM_ATTRS_VALID_TYPE_INT_ARRAY,
294 _mmcamcorder_commit_filter_scene_mode,
297 MM_CAM_FILTER_BRIGHTNESS,
302 MM_ATTRS_VALID_TYPE_INT_RANGE,
305 _mmcamcorder_commit_filter,
308 MM_CAM_FILTER_CONTRAST,
313 MM_ATTRS_VALID_TYPE_INT_RANGE,
316 _mmcamcorder_commit_filter,
324 MM_ATTRS_VALID_TYPE_INT_ARRAY,
327 _mmcamcorder_commit_filter,
330 MM_CAM_FILTER_COLOR_TONE,
335 MM_ATTRS_VALID_TYPE_INT_ARRAY,
338 _mmcamcorder_commit_filter,
341 MM_CAM_FILTER_SATURATION,
346 MM_ATTRS_VALID_TYPE_INT_RANGE,
349 _mmcamcorder_commit_filter,
357 MM_ATTRS_VALID_TYPE_INT_RANGE,
360 _mmcamcorder_commit_filter,
364 MM_CAM_FILTER_SHARPNESS,
369 MM_ATTRS_VALID_TYPE_INT_RANGE,
372 _mmcamcorder_commit_filter,
375 MM_CAM_CAMERA_FORMAT,
379 {(void*)MM_PIXEL_FORMAT_YUYV},
380 MM_ATTRS_VALID_TYPE_INT_ARRAY,
383 _mmcamcorder_commit_camera_format,
386 MM_CAM_CAMERA_RECORDING_MOTION_RATE,
387 "camera-recording-motion-rate",
388 MM_ATTRS_TYPE_DOUBLE,
390 {.value_double = 1.0},
391 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
393 {.double_max = _MMCAMCORDER_MAX_DOUBLE},
394 _mmcamcorder_commit_camera_recording_motion_rate,
402 MM_ATTRS_VALID_TYPE_INT_RANGE,
405 _mmcamcorder_commit_camera_fps,
412 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
413 MM_ATTRS_VALID_TYPE_INT_ARRAY,
416 _mmcamcorder_commit_camera_width,
419 MM_CAM_CAMERA_HEIGHT,
423 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
424 MM_ATTRS_VALID_TYPE_INT_ARRAY,
427 _mmcamcorder_commit_camera_height,
430 MM_CAM_CAMERA_DIGITAL_ZOOM,
431 "camera-digital-zoom",
435 MM_ATTRS_VALID_TYPE_INT_RANGE,
438 _mmcamcorder_commit_camera_zoom,
441 MM_CAM_CAMERA_OPTICAL_ZOOM,
442 "camera-optical-zoom",
446 MM_ATTRS_VALID_TYPE_INT_RANGE,
449 _mmcamcorder_commit_camera_zoom,
452 MM_CAM_CAMERA_FOCUS_MODE,
456 {(void*)MM_CAMCORDER_FOCUS_MODE_NONE},
457 MM_ATTRS_VALID_TYPE_INT_ARRAY,
460 _mmcamcorder_commit_camera_focus_mode,
463 MM_CAM_CAMERA_AF_SCAN_RANGE,
464 "camera-af-scan-range",
468 MM_ATTRS_VALID_TYPE_INT_ARRAY,
471 _mmcamcorder_commit_camera_af_scan_range,
475 MM_CAM_CAMERA_EXPOSURE_MODE,
476 "camera-exposure-mode",
480 MM_ATTRS_VALID_TYPE_INT_ARRAY,
483 _mmcamcorder_commit_camera_capture_mode,
486 MM_CAM_CAMERA_EXPOSURE_VALUE,
487 "camera-exposure-value",
491 MM_ATTRS_VALID_TYPE_INT_RANGE,
494 _mmcamcorder_commit_camera_capture_mode,
497 MM_CAM_CAMERA_F_NUMBER,
502 MM_ATTRS_VALID_TYPE_INT_ARRAY,
505 _mmcamcorder_commit_camera_capture_mode,
508 MM_CAM_CAMERA_SHUTTER_SPEED,
509 "camera-shutter-speed",
513 MM_ATTRS_VALID_TYPE_INT_ARRAY,
516 _mmcamcorder_commit_camera_capture_mode,
524 MM_ATTRS_VALID_TYPE_INT_ARRAY,
527 _mmcamcorder_commit_camera_capture_mode,
535 MM_ATTRS_VALID_TYPE_INT_ARRAY,
538 _mmcamcorder_commit_camera_wdr,
541 MM_CAM_CAMERA_ANTI_HANDSHAKE,
542 "camera-anti-handshake",
546 MM_ATTRS_VALID_TYPE_INT_ARRAY,
549 _mmcamcorder_commit_camera_anti_handshake,
552 MM_CAM_CAMERA_FPS_AUTO,
557 MM_ATTRS_VALID_TYPE_INT_RANGE,
560 _mmcamcorder_commit_camera_fps,
563 MM_CAM_CAMERA_DELAY_ATTR_SETTING,
564 "camera-delay-attr-setting",
568 MM_ATTRS_VALID_TYPE_INT_RANGE,
574 MM_CAM_AUDIO_ENCODER_BITRATE,
575 "audio-encoder-bitrate",
579 MM_ATTRS_VALID_TYPE_INT_RANGE,
581 {.int_max = _MMCAMCORDER_MAX_INT},
582 _mmcamcorder_commit_encoder_bitrate,
586 MM_CAM_VIDEO_ENCODER_BITRATE,
587 "video-encoder-bitrate",
591 MM_ATTRS_VALID_TYPE_INT_RANGE,
593 {.int_max = _MMCAMCORDER_MAX_INT},
594 _mmcamcorder_commit_encoder_bitrate,
597 MM_CAM_IMAGE_ENCODER_QUALITY,
598 "image-encoder-quality",
602 MM_ATTRS_VALID_TYPE_INT_RANGE,
605 _mmcamcorder_commit_image_encoder_quality,
608 MM_CAM_CAPTURE_FORMAT,
612 {(void*)MM_PIXEL_FORMAT_ENCODED},
613 MM_ATTRS_VALID_TYPE_INT_ARRAY,
619 MM_CAM_CAPTURE_WIDTH,
624 MM_ATTRS_VALID_TYPE_INT_ARRAY,
627 _mmcamcorder_commit_capture_width ,
630 MM_CAM_CAPTURE_HEIGHT,
635 MM_ATTRS_VALID_TYPE_INT_ARRAY,
638 _mmcamcorder_commit_capture_height,
641 MM_CAM_CAPTURE_COUNT,
646 MM_ATTRS_VALID_TYPE_INT_RANGE,
649 _mmcamcorder_commit_capture_count,
652 MM_CAM_CAPTURE_INTERVAL,
657 MM_ATTRS_VALID_TYPE_INT_RANGE,
659 {.int_max = _MMCAMCORDER_MAX_INT},
663 MM_CAM_CAPTURE_BREAK_CONTINUOUS_SHOT,
664 "capture-break-cont-shot",
668 MM_ATTRS_VALID_TYPE_INT_RANGE,
671 _mmcamcorder_commit_capture_break_cont_shot,
674 MM_CAM_DISPLAY_HANDLE,
679 MM_ATTRS_VALID_TYPE_NONE,
682 _mmcamcorder_commit_display_handle,
685 MM_CAM_DISPLAY_DEVICE,
689 {(void*)MM_DISPLAY_DEVICE_MAINLCD},
690 MM_ATTRS_VALID_TYPE_INT_ARRAY,
697 MM_CAM_DISPLAY_SURFACE,
701 {(void*)MM_DISPLAY_SURFACE_OVERLAY},
702 MM_ATTRS_VALID_TYPE_INT_ARRAY,
708 MM_CAM_DISPLAY_RECT_X,
713 MM_ATTRS_VALID_TYPE_INT_RANGE,
715 {.int_max = _MMCAMCORDER_MAX_INT},
716 _mmcamcorder_commit_display_rect,
719 MM_CAM_DISPLAY_RECT_Y,
724 MM_ATTRS_VALID_TYPE_INT_RANGE,
726 {.int_max = _MMCAMCORDER_MAX_INT},
727 _mmcamcorder_commit_display_rect,
730 MM_CAM_DISPLAY_RECT_WIDTH,
731 "display-rect-width",
735 MM_ATTRS_VALID_TYPE_INT_RANGE,
737 {.int_max = _MMCAMCORDER_MAX_INT},
738 _mmcamcorder_commit_display_rect,
741 MM_CAM_DISPLAY_RECT_HEIGHT,
742 "display-rect-height",
746 MM_ATTRS_VALID_TYPE_INT_RANGE,
748 {.int_max = _MMCAMCORDER_MAX_INT},
749 _mmcamcorder_commit_display_rect,
752 MM_CAM_DISPLAY_SOURCE_X,
757 MM_ATTRS_VALID_TYPE_INT_RANGE,
759 {.int_max = _MMCAMCORDER_MAX_INT},
763 MM_CAM_DISPLAY_SOURCE_Y,
768 MM_ATTRS_VALID_TYPE_INT_RANGE,
770 {.int_max = _MMCAMCORDER_MAX_INT},
774 MM_CAM_DISPLAY_SOURCE_WIDTH,
779 MM_ATTRS_VALID_TYPE_INT_RANGE,
781 {.int_max = _MMCAMCORDER_MAX_INT},
785 MM_CAM_DISPLAY_SOURCE_HEIGHT,
786 "display-src-height",
790 MM_ATTRS_VALID_TYPE_INT_RANGE,
792 {.int_max = _MMCAMCORDER_MAX_INT},
796 MM_CAM_DISPLAY_ROTATION,
800 {(void*)MM_DISPLAY_ROTATION_NONE},
801 MM_ATTRS_VALID_TYPE_INT_RANGE,
802 {.int_min = MM_DISPLAY_ROTATION_NONE},
803 {.int_max = MM_DISPLAY_ROTATION_270},
804 _mmcamcorder_commit_display_rotation,
808 MM_CAM_DISPLAY_VISIBLE,
813 MM_ATTRS_VALID_TYPE_INT_ARRAY,
815 {ARRAY_SIZE(visible_values)},
816 _mmcamcorder_commit_display_visible,
819 MM_CAM_DISPLAY_SCALE,
824 MM_ATTRS_VALID_TYPE_INT_RANGE,
825 {.int_min = MM_DISPLAY_SCALE_DEFAULT},
826 {.int_max = MM_DISPLAY_SCALE_TRIPLE_LENGTH},
827 _mmcamcorder_commit_display_scale,
830 MM_CAM_DISPLAY_GEOMETRY_METHOD,
831 "display-geometry-method",
835 MM_ATTRS_VALID_TYPE_INT_RANGE,
836 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
837 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
838 _mmcamcorder_commit_display_geometry_method,
841 MM_CAM_TARGET_FILENAME,
843 MM_ATTRS_TYPE_STRING,
846 MM_ATTRS_VALID_TYPE_NONE,
849 _mmcamcorder_commit_target_filename,
852 MM_CAM_TARGET_MAX_SIZE,
857 MM_ATTRS_VALID_TYPE_INT_RANGE,
859 {.int_max = _MMCAMCORDER_MAX_INT},
860 _mmcamcorder_commit_recording_max_limit,
863 MM_CAM_TARGET_TIME_LIMIT,
868 MM_ATTRS_VALID_TYPE_INT_RANGE,
870 {.int_max = _MMCAMCORDER_MAX_INT},
871 _mmcamcorder_commit_recording_max_limit,
879 MM_ATTRS_VALID_TYPE_INT_RANGE,
882 _mmcamcorder_commit_tag,
885 MM_CAM_TAG_IMAGE_DESCRIPTION,
886 "tag-image-description",
887 MM_ATTRS_TYPE_STRING,
890 MM_ATTRS_VALID_TYPE_NONE,
893 _mmcamcorder_commit_tag,
896 MM_CAM_TAG_ORIENTATION,
901 MM_ATTRS_VALID_TYPE_INT_ARRAY,
902 {tag_orientation_values},
903 {ARRAY_SIZE(tag_orientation_values)},
904 _mmcamcorder_commit_tag,
909 MM_ATTRS_TYPE_STRING,
912 MM_ATTRS_VALID_TYPE_NONE,
915 _mmcamcorder_commit_tag,
921 MM_ATTRS_TYPE_DOUBLE,
923 {.value_double = 0.0},
924 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
925 {.double_min = -360.0},
926 {.double_max = 360.0},
927 _mmcamcorder_commit_tag,
930 MM_CAM_TAG_LONGITUDE,
932 MM_ATTRS_TYPE_DOUBLE,
934 {.value_double = 0.0},
935 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
936 {.double_min = -360.0},
937 {.double_max = 360.0},
938 _mmcamcorder_commit_tag,
943 MM_ATTRS_TYPE_DOUBLE,
945 {.value_double = 0.0},
946 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
947 {.double_min = -999999.0},
948 {.double_max = 999999.0},
949 _mmcamcorder_commit_tag,
952 MM_CAM_STROBE_CONTROL,
957 MM_ATTRS_VALID_TYPE_INT_RANGE,
960 _mmcamcorder_commit_strobe,
963 MM_CAM_STROBE_CAPABILITIES,
964 "strobe-capabilities",
968 MM_ATTRS_VALID_TYPE_INT_RANGE,
971 _mmcamcorder_commit_strobe,
979 MM_ATTRS_VALID_TYPE_INT_ARRAY,
982 _mmcamcorder_commit_strobe,
990 MM_ATTRS_VALID_TYPE_INT_ARRAY,
993 _mmcamcorder_commit_detect,
996 MM_CAM_DETECT_NUMBER,
1001 MM_ATTRS_VALID_TYPE_INT_RANGE,
1004 _mmcamcorder_commit_detect,
1007 MM_CAM_DETECT_FOCUS_SELECT,
1008 "detect-focus-select",
1012 MM_ATTRS_VALID_TYPE_INT_RANGE,
1015 _mmcamcorder_commit_detect,
1018 MM_CAM_DETECT_SELECT_NUMBER,
1019 "detect-select-number",
1023 MM_ATTRS_VALID_TYPE_INT_RANGE,
1026 _mmcamcorder_commit_detect,
1030 MM_CAM_DETECT_STATUS,
1035 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1038 _mmcamcorder_commit_detect,
1041 MM_CAM_CAPTURE_ZERO_SYSTEMLAG,
1042 "capture-zero-systemlag",
1046 MM_ATTRS_VALID_TYPE_INT_RANGE,
1052 MM_CAM_CAMERA_AF_TOUCH_X,
1053 "camera-af-touch-x",
1057 MM_ATTRS_VALID_TYPE_INT_RANGE,
1059 {.int_max = _MMCAMCORDER_MAX_INT},
1060 _mmcamcorder_commit_camera_af_touch_area,
1063 MM_CAM_CAMERA_AF_TOUCH_Y,
1064 "camera-af-touch-y",
1068 MM_ATTRS_VALID_TYPE_INT_RANGE,
1070 {.int_max = _MMCAMCORDER_MAX_INT},
1071 _mmcamcorder_commit_camera_af_touch_area,
1074 MM_CAM_CAMERA_AF_TOUCH_WIDTH,
1075 "camera-af-touch-width",
1079 MM_ATTRS_VALID_TYPE_INT_RANGE,
1081 {.int_max = _MMCAMCORDER_MAX_INT},
1082 _mmcamcorder_commit_camera_af_touch_area,
1085 MM_CAM_CAMERA_AF_TOUCH_HEIGHT,
1086 "camera-af-touch-height",
1090 MM_ATTRS_VALID_TYPE_INT_RANGE,
1092 {.int_max = _MMCAMCORDER_MAX_INT},
1093 _mmcamcorder_commit_camera_af_touch_area,
1096 MM_CAM_CAMERA_FOCAL_LENGTH,
1097 "camera-focal-length",
1098 MM_ATTRS_TYPE_DOUBLE,
1100 {.value_double = 0.0},
1101 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1102 {.double_min = 0.0},
1103 {.double_max = 1000.0},
1104 _mmcamcorder_commit_camera_capture_mode,
1107 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
1108 "recommend-preview-format-for-capture",
1111 {(void*)MM_PIXEL_FORMAT_YUYV},
1112 MM_ATTRS_VALID_TYPE_INT_RANGE,
1113 {.int_min = MM_PIXEL_FORMAT_NV12},
1114 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1118 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
1119 "recommend-preview-format-for-recording",
1122 {(void*)MM_PIXEL_FORMAT_NV12},
1123 MM_ATTRS_VALID_TYPE_INT_RANGE,
1124 {.int_min = MM_PIXEL_FORMAT_NV12},
1125 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1129 MM_CAM_TAG_GPS_ENABLE,
1134 MM_ATTRS_VALID_TYPE_INT_RANGE,
1137 _mmcamcorder_commit_tag,
1141 MM_CAM_TAG_GPS_TIME_STAMP,
1142 "tag-gps-time-stamp",
1143 MM_ATTRS_TYPE_DOUBLE,
1145 {.value_double = 0.0},
1146 MM_ATTRS_VALID_TYPE_NONE,
1149 _mmcamcorder_commit_tag,
1152 MM_CAM_TAG_GPS_DATE_STAMP,
1153 "tag-gps-date-stamp",
1154 MM_ATTRS_TYPE_STRING,
1157 MM_ATTRS_VALID_TYPE_NONE,
1160 _mmcamcorder_commit_tag,
1163 MM_CAM_TAG_GPS_PROCESSING_METHOD,
1164 "tag-gps-processing-method",
1165 MM_ATTRS_TYPE_STRING,
1168 MM_ATTRS_VALID_TYPE_NONE,
1171 _mmcamcorder_commit_tag,
1174 MM_CAM_CAMERA_ROTATION,
1178 {(void*)MM_VIDEO_INPUT_ROTATION_NONE},
1179 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1181 {ARRAY_SIZE(rotation_list)},
1182 _mmcamcorder_commit_camera_rotate,
1185 MM_CAM_CAPTURED_SCREENNAIL,
1186 "captured-screennail",
1190 MM_ATTRS_VALID_TYPE_NONE,
1196 MM_CAM_CAPTURE_SOUND_ENABLE,
1197 "capture-sound-enable",
1201 MM_ATTRS_VALID_TYPE_INT_RANGE,
1204 _mmcamcorder_commit_capture_sound_enable,
1207 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
1208 "recommend-display-rotation",
1211 {(void*)MM_DISPLAY_ROTATION_270},
1212 MM_ATTRS_VALID_TYPE_INT_RANGE,
1213 {.int_min = MM_DISPLAY_ROTATION_NONE},
1214 {.int_max = MM_DISPLAY_ROTATION_270},
1222 {(void*)MM_FLIP_NONE},
1223 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1225 {ARRAY_SIZE(flip_list)},
1226 _mmcamcorder_commit_camera_flip,
1229 MM_CAM_CAMERA_HDR_CAPTURE,
1230 "camera-hdr-capture",
1234 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1237 _mmcamcorder_commit_camera_hdr_capture,
1240 MM_CAM_DISPLAY_MODE,
1244 {(void*)MM_DISPLAY_MODE_DEFAULT},
1245 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1248 _mmcamcorder_commit_display_mode,
1252 MM_CAM_AUDIO_DISABLE,
1257 MM_ATTRS_VALID_TYPE_INT_RANGE,
1260 _mmcamcorder_commit_audio_disable,
1263 MM_CAM_RECOMMEND_CAMERA_WIDTH,
1264 "recommend-camera-width",
1267 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
1268 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1274 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
1275 "recommend-camera-height",
1278 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
1279 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1285 MM_CAM_CAPTURED_EXIF_RAW_DATA,
1286 "captured-exif-raw-data",
1290 MM_ATTRS_VALID_TYPE_NONE,
1296 MM_CAM_DISPLAY_EVAS_SURFACE_SINK,
1297 "display-evas-surface-sink",
1298 MM_ATTRS_TYPE_STRING,
1301 MM_ATTRS_VALID_TYPE_NONE,
1307 MM_CAM_DISPLAY_EVAS_DO_SCALING,
1308 "display-evas-do-scaling",
1312 MM_ATTRS_VALID_TYPE_INT_RANGE,
1315 _mmcamcorder_commit_display_evas_do_scaling,
1318 MM_CAM_CAMERA_FACING_DIRECTION,
1319 "camera-facing-direction",
1322 {(void*)MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1323 MM_ATTRS_VALID_TYPE_INT_RANGE,
1324 {.int_min = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1325 {.int_max = MM_CAMCORDER_CAMERA_FACING_DIRECTION_FRONT},
1329 MM_CAM_DISPLAY_FLIP,
1333 {(void*)MM_FLIP_NONE},
1334 MM_ATTRS_VALID_TYPE_INT_RANGE,
1335 {.int_min = MM_FLIP_NONE},
1336 {.int_max = MM_FLIP_BOTH},
1337 _mmcamcorder_commit_display_flip,
1340 MM_CAM_CAMERA_VIDEO_STABILIZATION,
1341 "camera-video-stabilization",
1344 {(void*)MM_CAMCORDER_VIDEO_STABILIZATION_OFF},
1345 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1348 _mmcamcorder_commit_camera_video_stabilization,
1351 MM_CAM_TAG_VIDEO_ORIENTATION,
1352 "tag-video-orientation",
1355 {(void*)MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1356 MM_ATTRS_VALID_TYPE_INT_RANGE,
1357 {.int_min = MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1358 {.int_max = MM_CAMCORDER_TAG_VIDEO_ORT_270},
1363 MM_CAM_CAMERA_PAN_MECHA,
1368 MM_ATTRS_VALID_TYPE_INT_RANGE,
1371 _mmcamcorder_commit_camera_pan,
1374 MM_CAM_CAMERA_PAN_ELEC,
1379 MM_ATTRS_VALID_TYPE_INT_RANGE,
1382 _mmcamcorder_commit_camera_pan,
1385 MM_CAM_CAMERA_TILT_MECHA,
1386 "camera-tilt-mecha",
1390 MM_ATTRS_VALID_TYPE_INT_RANGE,
1393 _mmcamcorder_commit_camera_tilt,
1396 MM_CAM_CAMERA_TILT_ELEC,
1401 MM_ATTRS_VALID_TYPE_INT_RANGE,
1404 _mmcamcorder_commit_camera_tilt,
1407 MM_CAM_CAMERA_PTZ_TYPE,
1412 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1415 _mmcamcorder_commit_camera_ptz_type,
1423 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1426 _mmcamcorder_commit_video_size,
1429 MM_CAM_VIDEO_HEIGHT,
1434 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1437 _mmcamcorder_commit_video_size,
1440 MM_CAM_SUPPORT_ZSL_CAPTURE,
1441 "support-zsl-capture",
1445 MM_ATTRS_VALID_TYPE_INT_RANGE,
1451 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
1452 "support-zero-copy-format",
1456 MM_ATTRS_VALID_TYPE_INT_RANGE,
1462 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
1463 "support-media-packet-preview-cb",
1467 MM_ATTRS_VALID_TYPE_INT_RANGE,
1474 MM_CAM_ENCODED_PREVIEW_BITRATE,
1475 "encoded-preview-bitrate",
1478 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE},
1479 MM_ATTRS_VALID_TYPE_INT_RANGE,
1481 {.int_max = _MMCAMCORDER_MAX_INT},
1482 _mmcamcorder_commit_encoded_preview_bitrate,
1485 MM_CAM_ENCODED_PREVIEW_GOP_INTERVAL,
1486 "encoded-preview-gop-interval",
1489 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL},
1490 MM_ATTRS_VALID_TYPE_INT_RANGE,
1492 {.int_max = _MMCAMCORDER_MAX_INT},
1493 _mmcamcorder_commit_encoded_preview_gop_interval,
1496 MM_CAM_RECORDER_TAG_ENABLE,
1497 "recorder-tag-enable",
1501 MM_ATTRS_VALID_TYPE_INT_RANGE,
1507 MM_CAM_DISPLAY_SOCKET_PATH,
1508 "display-socket-path",
1509 MM_ATTRS_TYPE_STRING,
1512 MM_ATTRS_VALID_TYPE_NONE,
1523 MM_ATTRS_VALID_TYPE_INT_RANGE,
1525 {.int_max = _MMCAMCORDER_MAX_INT},
1529 MM_CAM_ROOT_DIRECTORY,
1531 MM_ATTRS_TYPE_STRING,
1534 MM_ATTRS_VALID_TYPE_NONE,
1540 MM_CAM_SOUND_STREAM_INDEX,
1541 "sound-stream-index",
1545 MM_ATTRS_VALID_TYPE_INT_RANGE,
1547 {.int_max = _MMCAMCORDER_MAX_INT},
1551 MM_CAM_SOUND_STREAM_TYPE,
1552 "sound-stream-type",
1553 MM_ATTRS_TYPE_STRING,
1556 MM_ATTRS_VALID_TYPE_NONE,
1559 _mmcamcorder_commit_sound_stream_info,
1562 MM_CAM_DISPLAY_REUSE_HINT,
1563 "display-reuse-hint",
1567 MM_ATTRS_VALID_TYPE_INT_RANGE,
1573 MM_CAM_DISPLAY_REUSE_ELEMENT,
1574 "display-reuse-element",
1578 MM_ATTRS_VALID_TYPE_NONE,
1584 MM_CAM_GDBUS_CONNECTION,
1589 MM_ATTRS_VALID_TYPE_NONE,
1595 MM_CAM_AUDIO_REPLAY_GAIN_ENABLE,
1596 "audio-replay-gain-enable",
1600 MM_ATTRS_VALID_TYPE_INT_RANGE,
1603 _mmcamcorder_commit_audio_replay_gain,
1606 MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL,
1607 "audio-replay-gain-reference-level",
1608 MM_ATTRS_TYPE_DOUBLE,
1610 {.value_double = MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL},
1611 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1612 {.double_min = 0.0},
1613 {.double_max = 150.0},
1614 _mmcamcorder_commit_audio_replay_gain,
1617 MM_CAM_SUPPORT_USER_BUFFER,
1618 "support-user-buffer",
1622 MM_ATTRS_VALID_TYPE_INT_RANGE,
1628 MM_CAM_USER_BUFFER_FD,
1633 MM_ATTRS_VALID_TYPE_NONE,
1639 MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
1640 "platform-privilege-camera",
1641 MM_ATTRS_TYPE_STRING,
1644 MM_ATTRS_VALID_TYPE_NONE,
1650 MM_CAM_STROBE_BRIGHTNESS,
1651 "strobe-brightness",
1655 MM_ATTRS_VALID_TYPE_INT_RANGE,
1658 _mmcamcorder_commit_strobe,
1661 MM_CAM_VIDEOSRC_ELEMENT_NAME,
1662 "videosrc-element-name",
1663 MM_ATTRS_TYPE_STRING,
1666 MM_ATTRS_VALID_TYPE_NONE,
1672 MM_CAM_AUDIOSRC_ELEMENT_NAME,
1673 "audiosrc-element-name",
1674 MM_ATTRS_TYPE_STRING,
1677 MM_ATTRS_VALID_TYPE_NONE,
1683 MM_CAM_EXTRA_PREVIEW_ENABLE,
1684 "extra-preview-enable",
1688 MM_ATTRS_VALID_TYPE_INT_RANGE,
1691 _mmcamcorder_commit_extra_preview,
1695 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1697 for (idx = 0 ; idx < attr_count ; idx++) {
1698 /* attribute order check. This should be same. */
1699 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1700 MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1701 free(attrs_const_info);
1702 attrs_const_info = NULL;
1703 free(hcamcorder->cam_attrs_const_info);
1704 hcamcorder->cam_attrs_const_info = NULL;
1708 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1709 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1710 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1711 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1714 /* Camcorder Attributes */
1715 MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1717 ret = mm_attrs_new(attrs_const_info,
1719 "Camcorder_Attributes",
1720 _mmcamcorder_commit_camcorder_attrs,
1724 free(attrs_const_info);
1725 attrs_const_info = NULL;
1727 if (ret != MM_ERROR_NONE) {
1728 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1729 free(hcamcorder->cam_attrs_const_info);
1730 hcamcorder->cam_attrs_const_info = NULL;
1734 __mmcamcorder_set_conf_to_valid_info(handle);
1736 for (idx = 0; idx < attr_count; idx++) {
1737 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1739 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1741 switch (attr_info->validity_type) {
1742 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1743 if (attr_info->validity_value_1.int_array &&
1744 attr_info->validity_value_2.count > 0) {
1745 mm_attrs_set_valid_array(attrs, idx,
1746 (const int *)(attr_info->validity_value_1.int_array),
1747 attr_info->validity_value_2.count,
1748 attr_info->default_value.value_int);
1751 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1752 mm_attrs_set_valid_range(attrs, idx,
1753 attr_info->validity_value_1.int_min,
1754 attr_info->validity_value_2.int_max,
1755 attr_info->default_value.value_int);
1757 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1758 if (attr_info->validity_value_1.double_array &&
1759 attr_info->validity_value_2.count > 0) {
1760 mm_attrs_set_valid_double_array(attrs, idx,
1761 (const double *)(attr_info->validity_value_1.double_array),
1762 attr_info->validity_value_2.count,
1763 attr_info->default_value.value_double);
1766 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1767 mm_attrs_set_valid_double_range(attrs, idx,
1768 attr_info->validity_value_1.double_min,
1769 attr_info->validity_value_2.double_max,
1770 attr_info->default_value.value_double);
1772 case MM_ATTRS_VALID_TYPE_NONE:
1774 case MM_ATTRS_VALID_TYPE_INVALID:
1776 MMCAM_LOG_ERROR("Valid type error.");
1781 __mmcamcorder_release_conf_valid_info(handle);
1788 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1790 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1792 if (hcamcorder == NULL) {
1793 MMCAM_LOG_ERROR("handle is NULL");
1800 mm_attrs_free(attrs);
1801 MMCAM_LOG_INFO("released attribute");
1804 if (hcamcorder->cam_attrs_const_info) {
1805 free(hcamcorder->cam_attrs_const_info);
1806 hcamcorder->cam_attrs_const_info = NULL;
1807 MMCAM_LOG_INFO("released attribute info");
1815 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1817 MMHandleType attrs = 0;
1818 int ret = MM_ERROR_NONE;
1820 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1821 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1823 attrs = MMF_CAMCORDER_ATTRS(handle);
1824 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1826 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1833 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1835 MMHandleType attrs = 0;
1836 int ret = MM_ERROR_NONE;
1838 char *tmp_err_attr_name = NULL;
1839 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1840 va_list var_args_copy;
1842 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1844 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1845 MMCAM_LOG_ERROR("Another command is running.");
1846 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1849 /* copy var_args to keep original var_args */
1850 va_copy(var_args_copy, var_args);
1852 attrs = MMF_CAMCORDER_ATTRS(handle);
1854 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1856 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1857 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1860 if (ret == MM_ERROR_NONE) {
1861 hcamcorder->error_code = MM_ERROR_NONE;
1862 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1863 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1866 va_end(var_args_copy);
1868 _MMCAMCORDER_UNLOCK_CMD(handle);
1870 if (ret != MM_ERROR_NONE) {
1871 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1872 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1873 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1874 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1875 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1876 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1880 if (hcamcorder->error_code != MM_ERROR_NONE) {
1881 MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1882 ret = hcamcorder->error_code;
1883 hcamcorder->error_code = MM_ERROR_NONE;
1886 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1889 if (tmp_err_attr_name) {
1890 if (!err_attr_name) {
1891 MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1892 free(tmp_err_attr_name);
1893 tmp_err_attr_name = NULL;
1895 *err_attr_name = tmp_err_attr_name;
1904 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1906 MMHandleType attrs = 0;
1907 MMAttrsInfo attrinfo;
1908 int ret = MM_ERROR_NONE;
1910 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1911 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1912 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1914 attrs = MMF_CAMCORDER_ATTRS(handle);
1915 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1917 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1919 if (ret == MM_ERROR_NONE) {
1920 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1921 info->type = attrinfo.type;
1922 info->flag = attrinfo.flag;
1923 info->validity_type = attrinfo.validity_type;
1925 switch (attrinfo.validity_type) {
1926 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1927 info->int_array.array = attrinfo.int_array.array;
1928 info->int_array.count = attrinfo.int_array.count;
1929 info->int_array.def = attrinfo.int_array.dval;
1931 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1932 info->int_range.min = attrinfo.int_range.min;
1933 info->int_range.max = attrinfo.int_range.max;
1934 info->int_range.def = attrinfo.int_range.dval;
1936 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1937 info->double_array.array = attrinfo.double_array.array;
1938 info->double_array.count = attrinfo.double_array.count;
1939 info->double_array.def = attrinfo.double_array.dval;
1941 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1942 info->double_range.min = attrinfo.double_range.min;
1943 info->double_range.max = attrinfo.double_range.max;
1944 info->double_range.def = attrinfo.double_range.dval;
1946 case MM_ATTRS_VALID_TYPE_NONE:
1948 case MM_ATTRS_VALID_TYPE_INVALID:
1959 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1962 mmf_camcorder_t *hcamcorder = NULL;
1964 mmf_return_val_if_fail(commit_param, FALSE);
1965 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1966 mmf_return_val_if_fail(attr_name, FALSE);
1967 mmf_return_val_if_fail(value, FALSE);
1969 hcamcorder = MMF_CAMCORDER(commit_param);
1971 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1972 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1980 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1983 int total_count = 0;
1985 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1987 if (hcamcorder == NULL) {
1988 MMCAM_LOG_ERROR("handle is NULL");
1989 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1993 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
1994 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
1995 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
1998 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
1999 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
2000 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
2003 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
2004 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
2005 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
2008 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
2009 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
2010 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
2012 return MM_ERROR_NONE;
2016 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
2018 int *allocated_memory = NULL;
2020 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2022 if (hcamcorder == NULL) {
2023 MMCAM_LOG_ERROR("handle is NULL");
2024 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2027 MMCAM_LOG_INFO("START");
2029 /* Audio encoder info */
2030 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2031 if (allocated_memory) {
2032 g_free(allocated_memory);
2033 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2034 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2037 /* Video encoder info */
2038 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2039 if (allocated_memory) {
2040 g_free(allocated_memory);
2041 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2042 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2045 /* Image encoder info */
2046 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2047 if (allocated_memory) {
2048 g_free(allocated_memory);
2049 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2050 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2053 /* File format info */
2054 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2055 if (allocated_memory) {
2056 g_free(allocated_memory);
2057 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2058 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2061 MMCAM_LOG_INFO("DONE");
2063 return MM_ERROR_NONE;
2067 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2069 MMHandleType attr = 0;
2070 int current_state = MM_CAMCORDER_STATE_NONE;
2072 mmf_return_val_if_fail(handle && value, FALSE);
2074 attr = MMF_CAMCORDER_ATTRS(handle);
2075 mmf_return_val_if_fail(attr, FALSE);
2077 /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2079 current_state = _mmcamcorder_get_state(handle);
2080 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2081 int flags = MM_ATTRS_FLAG_NONE;
2082 int capture_width, capture_height;
2083 MMCamAttrsInfo info;
2085 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2088 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2089 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2090 capture_width = value->value.i_val;
2092 /* Check whether they are valid pair */
2093 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2098 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2104 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2106 int current_state = MM_CAMCORDER_STATE_NONE;
2108 current_state = _mmcamcorder_get_state(handle);
2110 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2111 int capture_width, capture_height;
2113 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2114 capture_height = value->value.i_val;
2116 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2118 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2125 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2127 int current_state = 0;
2129 _MMCamcorderSubContext *sc = NULL;
2130 _MMCamcorderImageInfo *info = NULL;
2131 GstCameraControl *control = NULL;
2133 mmf_return_val_if_fail(handle && value, FALSE);
2135 current_state = _mmcamcorder_get_state(handle);
2136 ivalue = value->value.i_val;
2138 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2142 info = sc->info_image;
2144 MMCAM_LOG_ERROR("info image is NULL");
2148 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2149 if (info->capture_send_count > 0) {
2150 info->capturing = FALSE;
2151 MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2154 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2155 MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2159 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2161 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2162 MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2164 MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2167 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2174 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2176 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2177 int current_state = MM_CAMCORDER_STATE_NONE;
2178 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2180 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2182 current_state = _mmcamcorder_get_state(handle);
2183 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2185 MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2186 current_state, mode, value->value.i_val);
2188 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2189 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2192 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2198 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2200 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2202 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2204 MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2206 /* return error when disable shutter sound if policy is TRUE */
2207 if (!value->value.i_val &&
2208 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2209 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2212 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2218 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2220 int current_state = MM_CAMCORDER_STATE_NONE;
2221 _MMCamcorderSubContext *sc = NULL;
2224 mmf_return_val_if_fail(handle && value, FALSE);
2226 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2230 current_state = _mmcamcorder_get_state(handle);
2232 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2233 double mslNewVal = 0;
2234 mslNewVal = value->value.d_val;
2236 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2237 if (mslNewVal == 0.0) {
2238 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2239 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2241 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2242 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2246 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2249 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2257 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2259 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2260 int current_state = MM_CAMCORDER_STATE_NONE;
2262 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2264 current_state = _mmcamcorder_get_state(handle);
2265 if (current_state > MM_CAMCORDER_STATE_READY) {
2266 MMCAM_LOG_ERROR("invalid state %d", current_state);
2267 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2275 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2277 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2278 MMCamAttrsInfo fps_info;
2279 int resolution_width = 0;
2280 int resolution_height = 0;
2283 int current_state = MM_CAMCORDER_STATE_NONE;
2285 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2287 current_state = _mmcamcorder_get_state(handle);
2288 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2289 MMCAM_LOG_ERROR("invalid state %d", current_state);
2290 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2294 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2297 MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2299 ret = mm_camcorder_get_attributes(handle, NULL,
2300 MMCAM_CAMERA_WIDTH, &resolution_width,
2301 MMCAM_CAMERA_HEIGHT, &resolution_height,
2304 if (ret != MM_ERROR_NONE) {
2305 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2309 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2310 if (ret != MM_ERROR_NONE) {
2311 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2315 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2316 if (value->value.i_val == fps_info.int_array.array[i])
2320 MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2326 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2328 int current_state = MM_CAMCORDER_STATE_NONE;
2329 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2330 _MMCamcorderSubContext *sc = NULL;
2332 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2334 current_state = _mmcamcorder_get_state(handle);
2335 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2336 MMCAM_LOG_WARNING("invalid state %d", current_state);
2337 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2341 /* Verify recording motion rate */
2342 if (value->value.d_val > 0.0) {
2343 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2347 /* set is_slow flag */
2348 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2349 sc->is_modified_rate = TRUE;
2351 sc->is_modified_rate = FALSE;
2353 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2356 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2362 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2364 MMHandleType attr = 0;
2365 int current_state = MM_CAMCORDER_STATE_NONE;
2367 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2368 _MMCamcorderSubContext *sc = NULL;
2370 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2372 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2376 attr = MMF_CAMCORDER_ATTRS(handle);
2377 mmf_return_val_if_fail(attr, FALSE);
2379 MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2381 current_state = _mmcamcorder_get_state(handle);
2383 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2384 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2387 int flags = MM_ATTRS_FLAG_NONE;
2388 MMCamAttrsInfo info;
2389 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2392 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2393 int width = value->value.i_val;
2395 int preview_format = MM_PIXEL_FORMAT_NV12;
2396 int codec_type = MM_IMAGE_CODEC_JPEG;
2398 mm_camcorder_get_attributes(handle, NULL,
2399 MMCAM_CAMERA_HEIGHT, &height,
2400 MMCAM_CAMERA_FORMAT, &preview_format,
2401 MMCAM_IMAGE_ENCODER, &codec_type,
2404 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2405 if (hcamcorder->resolution_changed == FALSE) {
2406 MMCAM_LOG_INFO("no need to restart preview");
2410 hcamcorder->resolution_changed = FALSE;
2412 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2413 MMCAM_LOG_INFO("restart preview");
2415 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2416 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2418 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2419 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2421 /* check decoder recreation */
2422 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2423 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2424 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2428 /* get preview format */
2429 sc->info_image->preview_format = preview_format;
2430 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2431 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2433 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2434 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2436 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2437 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2440 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2442 MMCAM_LOG_ERROR("currently locked for preview restart");
2446 /* get preview format */
2447 sc->info_image->preview_format = preview_format;
2448 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2449 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2460 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2463 int current_state = MM_CAMCORDER_STATE_NONE;
2464 MMHandleType attr = 0;
2465 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2466 _MMCamcorderSubContext *sc = NULL;
2468 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2470 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2474 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2475 mmf_return_val_if_fail(attr, FALSE);
2477 MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2478 current_state = _mmcamcorder_get_state(handle);
2480 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2481 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2482 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2486 int height = value->value.i_val;
2487 int preview_format = MM_PIXEL_FORMAT_NV12;
2488 int codec_type = MM_IMAGE_CODEC_JPEG;
2489 int video_stabilization = 0;
2491 mm_camcorder_get_attributes(handle, NULL,
2492 MMCAM_CAMERA_WIDTH, &width,
2493 MMCAM_CAMERA_FORMAT, &preview_format,
2494 MMCAM_IMAGE_ENCODER, &codec_type,
2495 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2498 sc->info_video->preview_width = width;
2499 sc->info_video->preview_height = height;
2501 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2502 if (hcamcorder->resolution_changed == FALSE) {
2503 MMCAM_LOG_INFO("no need to restart preview");
2507 hcamcorder->resolution_changed = FALSE;
2509 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2510 MMCAM_LOG_INFO("restart preview");
2512 MMCAM_LOG_INFO("set empty buffers");
2514 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2515 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2517 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2518 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2520 /* check decoder recreation */
2521 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2522 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2523 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2527 /* get preview format */
2528 sc->info_image->preview_format = preview_format;
2529 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2531 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2533 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2534 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2536 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2537 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2540 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2542 MMCAM_LOG_ERROR("currently locked for preview restart");
2546 /* get preview format */
2547 sc->info_image->preview_format = preview_format;
2548 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2549 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2557 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2559 int current_state = MM_CAMCORDER_STATE_NONE;
2560 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2562 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2564 current_state = _mmcamcorder_get_state(handle);
2565 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2566 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2567 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2570 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2571 value->value.i_val, attr_idx);
2577 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2579 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2580 _MMCamcorderSubContext *sc = NULL;
2581 int current_state = MM_CAMCORDER_STATE_NONE;
2582 GstCameraControl *control = NULL;
2586 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2588 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2592 zoom_level = value->value.i_val;
2594 MMCAM_LOG_INFO("(%d)", attr_idx);
2596 current_state = _mmcamcorder_get_state(handle);
2597 if (current_state < MM_CAMCORDER_STATE_READY) {
2598 MMCAM_LOG_INFO("will be applied when preview starts");
2600 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2601 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2602 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2606 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2607 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2609 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2611 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2614 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2615 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2619 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2620 if (control == NULL) {
2621 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2625 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2627 MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2630 MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2633 MMCAM_LOG_INFO("pointer of video src is null");
2640 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2642 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2643 _MMCamcorderSubContext *sc = NULL;
2644 int current_state = MM_CAMCORDER_STATE_NONE;
2646 GstCameraControl *CameraControl = NULL;
2647 GstCameraControlChannel *CameraControlChannel = NULL;
2648 const GList *controls = NULL;
2649 const GList *item = NULL;
2651 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2653 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2654 mmf_return_val_if_fail(sc, TRUE);
2656 MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2658 current_state = _mmcamcorder_get_state(handle);
2659 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2660 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2661 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2662 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2666 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2667 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2668 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2672 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2673 if (CameraControl == NULL) {
2674 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2678 controls = gst_camera_control_list_channels(CameraControl);
2679 if (controls == NULL) {
2680 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2684 for (item = controls ; item && item->data ; item = item->next) {
2685 CameraControlChannel = item->data;
2686 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2687 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2688 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2689 MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2692 MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2698 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2705 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2707 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2708 _MMCamcorderSubContext *sc = NULL;
2709 int current_state = MM_CAMCORDER_STATE_NONE;
2711 GstCameraControl *CameraControl = NULL;
2712 GstCameraControlChannel *CameraControlChannel = NULL;
2713 const GList *controls = NULL;
2714 const GList *item = NULL;
2716 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2718 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2719 mmf_return_val_if_fail(sc, TRUE);
2721 MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2723 current_state = _mmcamcorder_get_state(handle);
2724 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2725 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2726 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2727 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2731 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2732 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2733 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2737 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2738 if (CameraControl == NULL) {
2739 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2743 controls = gst_camera_control_list_channels(CameraControl);
2744 if (controls == NULL) {
2745 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2749 for (item = controls ; item && item->data ; item = item->next) {
2750 CameraControlChannel = item->data;
2751 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2752 if (!strcmp(CameraControlChannel->label, "pan")) {
2753 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2754 MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2757 MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2763 MMCAM_LOG_WARNING("failed to find pan control channel");
2770 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2772 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2773 _MMCamcorderSubContext *sc = NULL;
2774 int current_state = MM_CAMCORDER_STATE_NONE;
2776 GstCameraControl *CameraControl = NULL;
2777 GstCameraControlChannel *CameraControlChannel = NULL;
2778 const GList *controls = NULL;
2779 const GList *item = NULL;
2781 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2783 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2784 mmf_return_val_if_fail(sc, TRUE);
2786 MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2788 current_state = _mmcamcorder_get_state(handle);
2789 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2790 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2791 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2792 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2796 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2797 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2798 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2802 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2803 if (CameraControl == NULL) {
2804 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2808 controls = gst_camera_control_list_channels(CameraControl);
2809 if (controls == NULL) {
2810 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2814 for (item = controls ; item && item->data ; item = item->next) {
2815 CameraControlChannel = item->data;
2816 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2817 if (!strcmp(CameraControlChannel->label, "tilt")) {
2818 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2819 MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2822 MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2828 MMCAM_LOG_WARNING("failed to find tilt control channel");
2835 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2837 MMHandleType attr = 0;
2838 int current_state = MM_CAMCORDER_STATE_NONE;
2839 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2840 _MMCamcorderSubContext *sc = NULL;
2841 GstCameraControl *control = NULL;
2843 int set_focus_mode = 0;
2844 int cur_focus_mode = 0;
2845 int cur_focus_range = 0;
2847 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2849 attr = MMF_CAMCORDER_ATTRS(handle);
2850 mmf_return_val_if_fail(attr, FALSE);
2852 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2856 MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2858 /* check whether set or not */
2859 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2860 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2864 current_state = _mmcamcorder_get_state(handle);
2865 if (current_state < MM_CAMCORDER_STATE_NULL) {
2866 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2868 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2869 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2870 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2874 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2875 int flags = MM_ATTRS_FLAG_NONE;
2876 MMCamAttrsInfo info;
2878 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2879 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2883 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2884 if (control == NULL) {
2885 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2889 mslVal = value->value.i_val;
2890 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2892 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2895 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2896 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2897 if (set_focus_mode != cur_focus_mode) {
2898 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2899 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2902 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2905 MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2909 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2913 MMCAM_LOG_INFO("pointer of video src is null");
2920 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2922 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2923 _MMCamcorderSubContext *sc = NULL;
2924 GstCameraControl *control = NULL;
2925 int current_state = MM_CAMCORDER_STATE_NONE;
2928 int cur_focus_mode = 0;
2929 int cur_focus_range = 0;
2930 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2931 int converted_mode = 0;
2933 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2935 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2939 MMCAM_LOG_INFO("(%d)", attr_idx);
2941 /* check whether set or not */
2942 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2943 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2947 mslVal = value->value.i_val;
2948 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2950 current_state = _mmcamcorder_get_state(handle);
2951 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2952 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
2954 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2955 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2956 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2960 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2961 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2962 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2966 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2967 if (control == NULL) {
2968 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2972 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
2973 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
2975 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2976 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
2977 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
2978 /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
2981 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2984 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
2988 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2991 MMCAM_LOG_INFO("pointer of video src is null");
2998 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3000 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3001 _MMCamcorderSubContext *sc = NULL;
3002 GstCameraControl *control = NULL;
3003 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
3004 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
3006 int current_state = MM_CAMCORDER_STATE_NONE;
3008 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3010 gboolean do_set = FALSE;
3012 MMCamAttrsInfo info_y;
3013 MMCamAttrsInfo info_w;
3014 MMCamAttrsInfo info_h;
3016 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3018 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3022 MMCAM_LOG_INFO("(%d)", attr_idx);
3024 current_state = _mmcamcorder_get_state(handle);
3025 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3026 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3028 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3029 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3030 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3034 ret = mm_camcorder_get_attributes(handle, NULL,
3035 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3037 if (ret != MM_ERROR_NONE) {
3038 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3042 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3043 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3047 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3048 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3049 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3053 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3054 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3055 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3058 case MM_CAM_CAMERA_AF_TOUCH_X:
3059 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3060 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3061 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3062 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3063 set_area.x = value->value.i_val;
3064 mm_camcorder_get_attributes(handle, NULL,
3065 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3066 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3067 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3071 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3075 case MM_CAM_CAMERA_AF_TOUCH_Y:
3076 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3077 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3078 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3079 set_area.y = value->value.i_val;
3080 mm_camcorder_get_attributes(handle, NULL,
3081 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3082 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3083 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3087 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3091 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3092 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3093 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3094 set_area.width = value->value.i_val;
3095 mm_camcorder_get_attributes(handle, NULL,
3096 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3097 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3098 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3102 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3106 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3107 set_area.height = value->value.i_val;
3108 mm_camcorder_get_attributes(handle, NULL,
3109 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3110 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3111 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3120 _MMCamcorderVideoInfo *info = sc->info_video;
3123 MMCAM_LOG_ERROR("video info is NULL");
3127 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3128 if (control == NULL) {
3129 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3134 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3135 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3136 float ratio_width = 0.0;
3137 float ratio_height = 0.0;
3139 if (info->preview_width != 0 && info->preview_height != 0) {
3140 ratio_width = (float)info->video_width / (float)info->preview_width;
3141 ratio_height = (float)info->video_height / (float)info->preview_height;
3143 MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3144 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3146 set_area.x = (int)((float)set_area.x * ratio_width);
3147 set_area.y = (int)((float)set_area.y * ratio_height);
3148 set_area.width = (int)((float)set_area.width * ratio_width);
3149 set_area.height = (int)((float)set_area.height * ratio_height);
3151 if (set_area.width <= 0)
3154 if (set_area.height <= 0)
3155 set_area.height = 1;
3157 MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3158 set_area.x, set_area.y, set_area.width, set_area.height);
3160 MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3161 info->preview_width, info->preview_height);
3165 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3167 MMCAM_LOG_WARNING("Failed to get AF area");
3171 /* width and height are not supported now */
3172 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3173 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3174 get_area.x, get_area.y);
3178 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3180 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3181 set_area.x, set_area.y, set_area.width, set_area.height);
3184 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3185 set_area.x, set_area.y, set_area.width, set_area.height);
3189 MMCAM_LOG_INFO("pointer of video src is null");
3196 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3198 GstCameraControl *control = NULL;
3204 int exposure_type = 0;
3205 int current_state = MM_CAMCORDER_STATE_NONE;
3206 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3207 _MMCamcorderSubContext *sc = NULL;
3209 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3210 gboolean check_scene_mode = FALSE;
3212 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3214 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3218 /* check whether set or not */
3219 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3220 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3224 current_state = _mmcamcorder_get_state(handle);
3225 if (current_state < MM_CAMCORDER_STATE_READY) {
3226 MMCAM_LOG_INFO("will be applied when preview starts");
3228 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3229 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3230 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3234 ivalue = value->value.i_val;
3236 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3237 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3238 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3239 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3240 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3241 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3242 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3243 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3244 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3245 exposure_type = GST_CAMERA_CONTROL_ISO;
3247 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3248 check_scene_mode = TRUE;
3249 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3250 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3252 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3253 check_scene_mode = TRUE;
3254 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3255 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3256 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3257 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3260 if (check_scene_mode) {
3261 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3262 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3263 MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3268 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3271 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3272 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3276 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3277 if (control == NULL) {
3278 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3282 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3284 MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3287 MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3290 MMCAM_LOG_INFO("pointer of video src is null");
3297 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3299 GstCameraControl *control = NULL;
3303 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3304 _MMCamcorderSubContext *sc = NULL;
3305 int current_state = MM_CAMCORDER_STATE_NONE;
3307 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3309 /* check whether set or not */
3310 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3311 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3315 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3319 /* check current state */
3320 current_state = _mmcamcorder_get_state(handle);
3321 if (current_state < MM_CAMCORDER_STATE_READY) {
3322 MMCAM_LOG_INFO("will be applied when preview starts");
3324 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3325 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3326 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3330 mslVal = value->value.i_val;
3331 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3333 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3334 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3335 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3339 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3340 if (control == NULL) {
3341 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3345 if (gst_camera_control_get_wdr(control, &cur_value)) {
3346 if (newVal != cur_value) {
3347 if (gst_camera_control_set_wdr(control, newVal)) {
3348 MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3351 MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3354 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3358 MMCAM_LOG_WARNING("Failed to get WDR.");
3361 MMCAM_LOG_INFO("pointer of video src is null");
3368 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3370 int current_state = MM_CAMCORDER_STATE_NONE;
3371 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3373 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3375 /* check whether set or not */
3376 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3377 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3381 current_state = _mmcamcorder_get_state(handle);
3382 if (current_state < MM_CAMCORDER_STATE_READY) {
3383 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3385 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3386 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3387 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3391 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3395 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3399 int current_state = MM_CAMCORDER_STATE_NONE;
3400 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3401 _MMCamcorderSubContext *sc = NULL;
3403 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3405 bitrate = value->value.i_val;
3407 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3408 if (!sc || !sc->encode_element) {
3409 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3413 current_state = _mmcamcorder_get_state(handle);
3414 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3415 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3416 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3420 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3421 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3423 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3424 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3426 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3427 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3434 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3436 int current_state = MM_CAMCORDER_STATE_NONE;
3437 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3439 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3441 current_state = _mmcamcorder_get_state(handle);
3442 if (current_state < MM_CAMCORDER_STATE_READY) {
3443 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3445 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3446 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3447 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3451 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3455 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3457 int current_state = MM_CAMCORDER_STATE_NONE;
3458 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3460 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3462 MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3464 current_state = _mmcamcorder_get_state(handle);
3466 if (current_state > MM_CAMCORDER_STATE_READY) {
3467 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3468 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3471 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3476 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3478 int current_state = MM_CAMCORDER_STATE_NONE;
3480 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3481 _MMCamcorderSubContext *sc = NULL;
3483 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3486 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3487 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3491 /* check current state */
3492 current_state = _mmcamcorder_get_state(handle);
3493 if (current_state < MM_CAMCORDER_STATE_READY) {
3494 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3496 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3497 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3498 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3502 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3504 MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3506 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3507 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3510 MMCAM_LOG_ERROR("invalid state %d", current_state);
3516 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3518 mmf_return_val_if_fail(handle && value, FALSE);
3521 if (!value->value.s_val) {
3522 MMCAM_LOG_ERROR("NULL filename");
3526 MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3532 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3534 int current_state = MM_CAMCORDER_STATE_NONE;
3535 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3537 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3539 current_state = _mmcamcorder_get_state(handle);
3540 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3541 MMCAM_LOG_ERROR("Can not set while RECORDING");
3542 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3550 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3552 GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3553 MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3554 return strcmp(Colorchannel->label, user_data);
3557 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3559 GstColorBalance *balance = NULL;
3560 GstColorBalanceChannel *Colorchannel = NULL;
3561 GList *controls = NULL;
3565 int current_state = MM_CAMCORDER_STATE_NONE;
3566 const char *control_label = NULL;
3567 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3568 _MMCamcorderSubContext *sc = NULL;
3570 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3571 gboolean check_scene_mode = FALSE;
3573 int wb_temp_table[] = {
3574 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3575 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3576 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3577 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3578 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3579 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3582 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3584 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3588 /* check whether set or not */
3589 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3590 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3594 current_state = _mmcamcorder_get_state(handle);
3595 if (current_state < MM_CAMCORDER_STATE_READY) {
3596 MMCAM_LOG_INFO("will be applied when preview starts");
3598 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3599 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3600 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3604 if (value->type != MM_ATTRS_TYPE_INT) {
3605 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3609 mslVal = value->value.i_val;
3612 case MM_CAM_FILTER_BRIGHTNESS:
3613 control_label = "brightness";
3614 check_scene_mode = TRUE;
3616 case MM_CAM_FILTER_CONTRAST:
3617 control_label = "contrast";
3619 case MM_CAM_FILTER_WB:
3620 control_label = "white balance";
3621 check_scene_mode = TRUE;
3623 case MM_CAM_FILTER_COLOR_TONE:
3624 control_label = "color tone";
3626 case MM_CAM_FILTER_SATURATION:
3627 control_label = "saturation";
3628 check_scene_mode = TRUE;
3630 case MM_CAM_FILTER_HUE:
3631 control_label = "hue";
3633 case MM_CAM_FILTER_SHARPNESS:
3634 control_label = "sharpness";
3635 check_scene_mode = TRUE;
3638 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3642 if (check_scene_mode) {
3643 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3644 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3645 MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3650 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3651 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3654 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3655 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3659 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3660 if (balance == NULL) {
3661 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3665 controls = (GList *)gst_color_balance_list_channels(balance);
3666 if (controls == NULL) {
3667 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3672 MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3673 attr_idx, control_label, mslVal, newVal);
3675 item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3677 Colorchannel = item->data;
3678 gst_color_balance_set_value(balance, Colorchannel, newVal);
3679 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3683 if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3684 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3686 control_label = "white_balance_temperature_auto";
3689 newVal = wb_temp_table[mslVal];
3690 control_label = "white_balance_temperature";
3695 MMCAM_LOG_ERROR("failed to find color channel item");
3701 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3705 int current_state = MM_CAMCORDER_STATE_NONE;
3706 GstCameraControl *control = NULL;
3707 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3708 _MMCamcorderSubContext *sc = NULL;
3710 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3712 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3716 mslVal = value->value.i_val;
3717 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3719 /* check whether set or not */
3720 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3721 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3725 current_state = _mmcamcorder_get_state(handle);
3726 if (current_state < MM_CAMCORDER_STATE_READY) {
3727 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3729 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3730 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3731 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3735 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3738 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3739 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3743 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3744 if (control == NULL) {
3745 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3749 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3751 MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3753 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3757 MM_CAM_FILTER_BRIGHTNESS,
3759 MM_CAM_FILTER_SATURATION,
3760 MM_CAM_FILTER_SHARPNESS,
3761 MM_CAM_FILTER_COLOR_TONE,
3762 MM_CAM_CAMERA_EXPOSURE_MODE
3764 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3766 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3767 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3768 mm_attrs_set_modified(attrs, attr_idxs[i]);
3774 MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3777 MMCAM_LOG_WARNING("pointer of video src is null");
3784 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3786 mmf_return_val_if_fail(handle && value, FALSE);
3788 MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3794 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3796 mmf_return_val_if_fail(handle && value, FALSE);
3798 MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3804 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3806 int current_state = MM_CAMCORDER_STATE_NONE;
3807 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3809 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3811 current_state = _mmcamcorder_get_state(handle);
3812 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3813 MMCAM_LOG_WARNING("Can NOT Disable AUDIO. invalid state %d", current_state);
3814 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3817 MMCAM_LOG_INFO("Disable AUDIO when Recording");
3823 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3825 int current_state = MM_CAMCORDER_STATE_NONE;
3826 const char *videosink_name = NULL;
3827 void *dp_handle = NULL;
3828 MMCamWindowInfo *window_info = NULL;
3830 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3831 _MMCamcorderSubContext *sc = NULL;
3833 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3836 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3837 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3841 /* check current state */
3842 current_state = _mmcamcorder_get_state(handle);
3843 if (current_state < MM_CAMCORDER_STATE_READY) {
3844 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3848 dp_handle = value->value.p_val;
3850 MMCAM_LOG_WARNING("Display handle is NULL");
3854 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3856 /* get videosink name */
3857 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3858 if (!videosink_name) {
3859 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3863 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3865 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3866 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
3867 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
3868 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3869 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
3870 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
3871 } else if (!strcmp(videosink_name, "tizenwlsink")) {
3872 window_info = (MMCamWindowInfo *)dp_handle;
3873 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
3874 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3875 } else if (!strcmp(videosink_name, "directvideosink")) {
3876 window_info = (MMCamWindowInfo *)dp_handle;
3877 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
3878 window_info->surface_id,
3879 window_info->rect.x,
3880 window_info->rect.y,
3881 window_info->rect.width,
3882 window_info->rect.height);
3883 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3884 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3885 window_info->rect.x,
3886 window_info->rect.y,
3887 window_info->rect.width,
3888 window_info->rect.height);
3890 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
3898 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3900 int current_state = MM_CAMCORDER_STATE_NONE;
3901 const char *videosink_name = NULL;
3903 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3904 _MMCamcorderSubContext *sc = NULL;
3906 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3909 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3910 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3914 /* check current state */
3915 current_state = _mmcamcorder_get_state(handle);
3916 if (current_state < MM_CAMCORDER_STATE_READY) {
3917 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3921 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3923 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3924 if (videosink_name == NULL) {
3925 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3929 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3931 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3932 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
3933 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3935 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
3942 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3944 int current_state = MM_CAMCORDER_STATE_NONE;
3946 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3948 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3951 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3952 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3956 /* check current state */
3957 current_state = _mmcamcorder_get_state(handle);
3958 if (current_state < MM_CAMCORDER_STATE_READY) {
3959 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3963 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3967 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3969 int current_state = MM_CAMCORDER_STATE_NONE;
3971 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3973 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3976 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3977 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3981 /* check current state */
3982 current_state = _mmcamcorder_get_state(handle);
3983 if (current_state < MM_CAMCORDER_STATE_READY) {
3984 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3988 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3992 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3994 int current_state = MM_CAMCORDER_STATE_NONE;
3995 const char *videosink_name = NULL;
3997 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3998 _MMCamcorderSubContext *sc = NULL;
4000 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4003 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4004 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4008 /* check current state */
4009 current_state = _mmcamcorder_get_state(handle);
4010 if (current_state < MM_CAMCORDER_STATE_READY) {
4011 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4015 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4017 /* Get videosink name */
4018 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4019 if (videosink_name == NULL) {
4020 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4024 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4025 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4026 !strcmp(videosink_name, "directvideosink")) {
4027 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4028 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4030 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4037 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4040 int current_state = MM_CAMCORDER_STATE_NONE;
4041 const char *videosink_name = NULL;
4043 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4044 _MMCamcorderSubContext *sc = NULL;
4046 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4049 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4050 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4054 /* check current state */
4055 current_state = _mmcamcorder_get_state(handle);
4056 if (current_state < MM_CAMCORDER_STATE_READY) {
4057 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4061 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4063 /* Get videosink name */
4064 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4065 if (videosink_name == NULL) {
4066 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4070 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4071 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4072 !strcmp(videosink_name, "directvideosink")) {
4073 method = value->value.i_val;
4074 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4076 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4083 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4085 int current_state = MM_CAMCORDER_STATE_NONE;
4086 int ret = MM_ERROR_NONE;
4087 const char *videosink_name = NULL;
4089 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4090 _MMCamcorderSubContext *sc = NULL;
4092 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4095 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4096 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4100 /* check current state */
4101 current_state = _mmcamcorder_get_state(handle);
4102 if (current_state < MM_CAMCORDER_STATE_READY) {
4103 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4107 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4109 /* Get videosink name */
4110 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4111 if (videosink_name == NULL) {
4112 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4116 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4117 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4121 int rect_height = 0;
4122 int flags = MM_ATTRS_FLAG_NONE;
4123 MMCamAttrsInfo info;
4125 mm_camcorder_get_attributes(handle, NULL,
4126 MMCAM_DISPLAY_RECT_X, &rect_x,
4127 MMCAM_DISPLAY_RECT_Y, &rect_y,
4128 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4129 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4132 case MM_CAM_DISPLAY_RECT_X:
4133 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4135 memset(&info, 0x00, sizeof(info));
4136 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4138 memset(&info, 0x00, sizeof(info));
4139 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4142 rect_x = value->value.i_val;
4144 case MM_CAM_DISPLAY_RECT_Y:
4145 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4147 memset(&info, 0x00, sizeof(info));
4148 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4151 rect_y = value->value.i_val;
4153 case MM_CAM_DISPLAY_RECT_WIDTH:
4154 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4157 rect_width = value->value.i_val;
4159 case MM_CAM_DISPLAY_RECT_HEIGHT:
4160 rect_height = value->value.i_val;
4163 MMCAM_LOG_ERROR("Wrong attr_idx!");
4167 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4168 MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4170 if (!strcmp(videosink_name, "tizenwlsink")) {
4171 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4172 rect_x, rect_y, rect_width, rect_height);
4174 MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4178 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4179 "dst-roi-x", rect_x,
4180 "dst-roi-y", rect_y,
4181 "dst-roi-w", rect_width,
4182 "dst-roi-h", rect_height,
4187 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4194 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4197 int current_state = MM_CAMCORDER_STATE_NONE;
4198 const char *videosink_name = NULL;
4199 GstElement *vs_element = NULL;
4201 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4202 _MMCamcorderSubContext *sc = NULL;
4204 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4207 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4208 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4212 /* check current state */
4213 current_state = _mmcamcorder_get_state(handle);
4214 if (current_state < MM_CAMCORDER_STATE_READY) {
4215 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4219 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4221 /* Get videosink name */
4222 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4223 if (videosink_name == NULL) {
4224 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4228 zoom = value->value.i_val;
4229 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4230 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4232 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4233 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4237 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4243 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4245 int current_state = MM_CAMCORDER_STATE_NONE;
4247 const char *videosink_name = NULL;
4249 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4250 _MMCamcorderSubContext *sc = NULL;
4252 mmf_return_val_if_fail(handle && value, FALSE);
4255 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4256 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4260 /* check current state */
4261 current_state = _mmcamcorder_get_state(handle);
4262 if (current_state < MM_CAMCORDER_STATE_READY) {
4263 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4267 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4269 do_scaling = value->value.i_val;
4271 /* Get videosink name */
4272 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4273 if (videosink_name == NULL) {
4274 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4278 if (!strcmp(videosink_name, "evaspixmapsink")) {
4279 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4280 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4283 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4289 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4291 _MMCamcorderSubContext *sc = NULL;
4292 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4293 int strobe_type, mslVal, newVal, cur_value;
4294 int current_state = MM_CAMCORDER_STATE_NONE;
4296 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4298 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4302 /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4304 mslVal = value->value.i_val;
4306 /* check flash state */
4307 if (attr_idx == MM_CAM_STROBE_MODE) {
4308 int led_brightness = 0;
4310 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4311 MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4312 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4316 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4318 if (led_brightness > 0 &&
4319 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4320 /* other module already turned on LED */
4321 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4322 MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4326 MMCAM_LOG_INFO("keep going");
4330 current_state = _mmcamcorder_get_state(handle);
4331 if (current_state < MM_CAMCORDER_STATE_READY) {
4332 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4334 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4335 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4336 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4341 case MM_CAM_STROBE_CONTROL:
4342 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4343 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4345 case MM_CAM_STROBE_CAPABILITIES:
4346 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4349 case MM_CAM_STROBE_MODE:
4350 /* check whether set or not */
4351 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4352 MMCAM_LOG_INFO("skip set value %d", mslVal);
4356 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4357 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4359 case MM_CAM_STROBE_BRIGHTNESS:
4360 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4364 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4368 GstCameraControl *control = NULL;
4369 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4370 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4374 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4375 if (control == NULL) {
4376 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4380 if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4381 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4385 if (newVal == cur_value) {
4386 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4390 if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4391 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4395 MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4401 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4404 int current_state = MM_CAMCORDER_STATE_NONE;
4405 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4407 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4409 MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4412 current_state = _mmcamcorder_get_state(handle);
4413 if (current_state > MM_CAMCORDER_STATE_READY) {
4414 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4415 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4417 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4418 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4422 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4424 MMCAM_LOG_INFO("ret %d", ret);
4430 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4432 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4433 int current_state = MM_CAMCORDER_STATE_NONE;
4434 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4435 _MMCamcorderSubContext *sc = NULL;
4437 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4439 /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4441 /* check whether set or not */
4442 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4443 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4448 current_state = _mmcamcorder_get_state(handle);
4449 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4450 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4451 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4455 if (current_state >= MM_CAMCORDER_STATE_READY) {
4456 int current_value = 0;
4458 set_hdr_mode = value->value.i_val;
4459 mm_camcorder_get_attributes(handle, NULL,
4460 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4463 if (set_hdr_mode == current_value) {
4464 MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4468 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4470 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4471 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4472 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4474 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4476 /* check decoder recreation */
4477 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4478 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4482 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4483 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4486 set_hdr_mode = value->value.i_val;
4487 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4488 sc->info_image->hdr_capture_mode = set_hdr_mode;
4489 MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4491 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4492 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4494 MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4503 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4506 _MMCamcorderSubContext *sc = NULL;
4507 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4509 int current_value = 0;
4510 int current_state = MM_CAMCORDER_STATE_NONE;
4511 GstCameraControl *control = NULL;
4513 mmf_return_val_if_fail(handle && value, FALSE);
4515 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4519 /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4522 current_state = _mmcamcorder_get_state(handle);
4523 if (current_state < MM_CAMCORDER_STATE_READY) {
4524 MMCAM_LOG_INFO("will be applied when preview starts");
4528 set_value = value->value.i_val;
4531 case MM_CAM_DETECT_MODE:
4532 /* check whether set or not */
4533 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4534 MMCAM_LOG_INFO("skip set value %d", set_value);
4538 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4540 case MM_CAM_DETECT_NUMBER:
4541 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4543 case MM_CAM_DETECT_FOCUS_SELECT:
4544 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4546 case MM_CAM_DETECT_SELECT_NUMBER:
4547 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4549 case MM_CAM_DETECT_STATUS:
4550 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4553 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4557 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4558 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4561 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4562 if (control == NULL) {
4563 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4567 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4568 if (current_value == set_value) {
4569 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4572 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4573 MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4574 detect_type, set_value);
4577 MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4578 detect_type, set_value);
4583 MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4592 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4594 int current_state = MM_CAMCORDER_STATE_NONE;
4595 int preview_format = MM_PIXEL_FORMAT_NV12;
4597 mmf_return_val_if_fail(handle && value, FALSE);
4599 MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4601 /* check preview format */
4602 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4603 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4604 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4609 current_state = _mmcamcorder_get_state(handle);
4610 if (current_state < MM_CAMCORDER_STATE_READY) {
4611 MMCAM_LOG_INFO("will be applied when preview starts");
4615 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4619 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4621 int current_state = MM_CAMCORDER_STATE_NONE;
4622 int preview_format = MM_PIXEL_FORMAT_NV12;
4624 mmf_return_val_if_fail(handle && value, FALSE);
4626 MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4628 /* check preview format */
4629 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4630 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4631 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4636 current_state = _mmcamcorder_get_state(handle);
4637 if (current_state < MM_CAMCORDER_STATE_READY) {
4638 MMCAM_LOG_INFO("will be applied when preview starts");
4642 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4646 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4648 int stream_index = 0;
4649 char *stream_type = NULL;
4650 _MMCamcorderSubContext *sc = NULL;
4652 mmf_return_val_if_fail(handle && value, FALSE);
4654 stream_type = value->value.s_val;
4656 MMCAM_LOG_ERROR("NULL string");
4660 mm_camcorder_get_attributes(handle, NULL,
4661 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4663 if (stream_index < 0) {
4664 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4668 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4669 if (!sc || !sc->encode_element ||
4670 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4671 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4675 MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4677 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4681 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4683 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4684 int current_state = MM_CAMCORDER_STATE_NONE;
4686 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4688 current_state = _mmcamcorder_get_state(handle);
4689 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4690 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4691 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4698 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4700 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4702 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4704 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4705 /* Replay gain enable */
4706 int current_state = MM_CAMCORDER_STATE_NONE;
4707 int audio_disable = FALSE;
4709 current_state = _mmcamcorder_get_state(handle);
4710 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4711 MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4712 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4716 mm_camcorder_get_attributes(handle, NULL,
4717 MMCAM_AUDIO_DISABLE, &audio_disable,
4720 if (audio_disable) {
4721 MMCAM_LOG_ERROR("audio is disabled");
4722 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4726 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4727 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4728 /* Replay gain reference level */
4729 int replay_gain_enable = FALSE;
4731 mm_camcorder_get_attributes(handle, NULL,
4732 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4735 if (replay_gain_enable == FALSE) {
4736 MMCAM_LOG_ERROR("replay gain is disabled");
4737 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4741 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4743 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4751 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4753 int current_state = MM_CAMCORDER_STATE_NONE;
4754 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4755 _MMCamcorderSubContext *sc = NULL;
4757 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4759 if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4760 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4764 MMCAM_LOG_INFO("Enable extra preview(%d)", value->value.i_val);
4766 current_state = _mmcamcorder_get_state(handle);
4767 if (current_state < MM_CAMCORDER_STATE_READY) {
4768 MMCAM_LOG_INFO("will be set when preview is started");
4772 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4773 mmf_return_val_if_fail(sc, FALSE);
4775 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", value->value.i_val);
4781 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4783 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4786 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4790 int attr_idxs_default[] = {
4791 MM_CAM_CAMERA_DIGITAL_ZOOM,
4792 MM_CAM_CAMERA_OPTICAL_ZOOM,
4794 MM_CAM_FILTER_CONTRAST,
4797 MM_CAM_STROBE_BRIGHTNESS
4800 int attr_idxs_extra[] = {
4802 MM_CAM_FILTER_BRIGHTNESS,
4804 MM_CAM_FILTER_SATURATION,
4805 MM_CAM_FILTER_SHARPNESS,
4806 MM_CAM_FILTER_COLOR_TONE,
4807 MM_CAM_CAMERA_EXPOSURE_MODE
4810 mmf_return_val_if_fail(hcamcorder, FALSE);
4812 MMCAM_LOG_INFO("commit some attributes again");
4814 attrs = MMF_CAMCORDER_ATTRS(handle);
4815 if (attrs == NULL) {
4816 MMCAM_LOG_ERROR("Get attribute handle failed.");
4820 /* Get Scene mode */
4821 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4823 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4824 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4825 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4828 /* Set extra if scene mode is NORMAL */
4829 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4830 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4831 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4832 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4835 /* Set scene mode if scene mode is NOT NORMAL */
4836 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4837 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4840 if (mm_attrs_commit_all(attrs) == -1)
4845 MMCAM_LOG_INFO("Done.");
4851 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4853 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4859 MM_CAM_CAMERA_PTZ_TYPE,
4860 MM_CAM_CAMERA_PAN_MECHA,
4861 MM_CAM_CAMERA_PAN_ELEC,
4862 MM_CAM_CAMERA_TILT_MECHA,
4863 MM_CAM_CAMERA_TILT_ELEC
4866 mmf_return_val_if_fail(hcamcorder, FALSE);
4868 MMCAM_LOG_INFO("commit some attribute again[2]");
4870 attrs = MMF_CAMCORDER_ATTRS(handle);
4871 if (attrs == NULL) {
4872 MMCAM_LOG_ERROR("Get attribute handle failed.");
4876 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4877 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4878 mm_attrs_set_modified(attrs, attr_idxs[i]);
4881 if (mm_attrs_commit_all(attrs) == -1)
4886 MMCAM_LOG_INFO("Done.");
4892 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4894 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4898 int nerror = MM_ERROR_NONE;
4900 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4902 attrs = MMF_CAMCORDER_ATTRS(handle);
4903 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4907 table_size = ARRAY_SIZE(readonly_attributes);
4908 MMCAM_LOG_INFO("%d", table_size);
4909 for (i = 0; i < table_size; i++) {
4910 int sCategory = readonly_attributes[i];
4912 mm_attrs_set_readonly(attrs, sCategory);
4919 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4921 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4924 type_string_array * disabled_attr = NULL;
4926 int nerror = MM_ERROR_NONE ;
4928 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4930 attrs = MMF_CAMCORDER_ATTRS(handle);
4931 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4936 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4937 CONFIGURE_CATEGORY_MAIN_GENERAL,
4938 "DisabledAttributes",
4940 if (disabled_attr != NULL && disabled_attr->value) {
4941 cnt_str = disabled_attr->count;
4942 for (i = 0; i < cnt_str; i++) {
4944 MMCAM_LOG_INFO("[%d]%s", i, disabled_attr->value[i]);
4945 nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
4947 if (nerror == MM_ERROR_NONE)
4948 mm_attrs_set_disabled(attrs, idx);
4950 MMCAM_LOG_WARNING("No ATTR named %s[%d]", disabled_attr->value[i], i);
4958 /*---------------------------------------------------------------------------------------
4959 | INTERNAL FUNCTION DEFINITIONS: |
4960 ---------------------------------------------------------------------------------------*/
4961 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4963 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4964 _MMCamcorderSubContext *sc = NULL;
4965 int current_state = MM_CAMCORDER_STATE_NULL;
4967 mmf_return_val_if_fail(hcamcorder, FALSE);
4969 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4973 current_state = _mmcamcorder_get_state(handle);
4975 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4976 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4977 MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
4978 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4979 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4981 MMCAM_LOG_WARNING("invalid state[%d]", current_state);
4985 MMCAM_LOG_INFO("element is not created yet");
4992 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4994 #define INIT_VALUE -1
4995 #define CHECK_COUNT 3
4997 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4998 MMHandleType attrs = 0;
5000 int ret = MM_ERROR_NONE;
5003 const char *name = NULL;
5004 const char *check_pair_name[CHECK_COUNT][3] = {
5005 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
5006 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
5007 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
5010 int check_pair_value[CHECK_COUNT][2] = {
5011 {INIT_VALUE, INIT_VALUE},
5012 {INIT_VALUE, INIT_VALUE},
5013 {INIT_VALUE, INIT_VALUE},
5016 if (hcamcorder == NULL || attribute_name == NULL) {
5017 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
5018 hcamcorder, attribute_name);
5019 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5023 *err_attr_name = NULL;
5025 /*MMCAM_LOG_INFO( "ENTER" );*/
5027 attrs = MMF_CAMCORDER_ATTRS(handle);
5029 name = attribute_name;
5033 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
5035 /*MMCAM_LOG_INFO("NAME : %s", name);*/
5037 /* attribute name check */
5038 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
5040 *err_attr_name = strdup(name);
5042 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
5043 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5049 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5052 switch (attr_type) {
5053 case MM_ATTRS_TYPE_INT:
5055 gboolean matched = FALSE;
5056 for (i = 0 ; i < CHECK_COUNT ; i++) {
5057 for (j = 0 ; j < 2 ; j++) {
5058 if (!strcmp(name, check_pair_name[i][j])) {
5059 check_pair_value[i][j] = va_arg((var_args), int);
5060 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5068 if (matched == FALSE)
5069 va_arg((var_args), int);
5072 case MM_ATTRS_TYPE_DOUBLE:
5073 va_arg((var_args), double);
5075 case MM_ATTRS_TYPE_STRING:
5076 va_arg((var_args), char*); /* string */
5077 va_arg((var_args), int); /* size */
5079 case MM_ATTRS_TYPE_DATA:
5080 va_arg((var_args), void*); /* data */
5081 va_arg((var_args), int); /* size */
5083 case MM_ATTRS_TYPE_INVALID:
5085 MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5087 *err_attr_name = strdup(name);
5089 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5093 name = va_arg(var_args, const char*);
5096 for (i = 0 ; i < CHECK_COUNT ; i++) {
5097 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5098 gboolean check_result = FALSE;
5099 char *err_name = NULL;
5100 MMCamAttrsInfo attr_info_0, attr_info_1;
5102 if (check_pair_value[i][0] == INIT_VALUE) {
5103 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5104 err_name = strdup(check_pair_name[i][1]);
5105 } else if (check_pair_value[i][1] == INIT_VALUE) {
5106 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5107 err_name = strdup(check_pair_name[i][0]);
5109 err_name = strdup(check_pair_name[i][2]);
5112 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5113 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5115 check_result = FALSE;
5117 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5118 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5119 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5121 MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5122 check_pair_name[i][0], check_pair_name[i][1],
5123 check_pair_value[i][0], check_pair_value[i][1], i);
5125 check_result = TRUE;
5130 if (check_result == FALSE) {
5131 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5132 check_pair_name[i][0], check_pair_name[i][1],
5133 check_pair_value[i][0], check_pair_value[i][1]);
5134 if (err_attr_name) {
5135 *err_attr_name = err_name;
5143 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5146 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5147 int current_width = 0;
5148 int current_height = 0;
5150 mm_camcorder_get_attributes(handle, NULL,
5151 MMCAM_CAMERA_WIDTH, ¤t_width,
5152 MMCAM_CAMERA_HEIGHT, ¤t_height,
5155 if (current_width != check_pair_value[i][0] ||
5156 current_height != check_pair_value[i][1]) {
5157 hcamcorder->resolution_changed = TRUE;
5159 hcamcorder->resolution_changed = FALSE;
5162 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5172 /*MMCAM_LOG_INFO("DONE");*/
5174 return MM_ERROR_NONE;
5178 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5182 if ((void *)handle == NULL) {
5183 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5187 memset(&info, 0x0, sizeof(MMAttrsInfo));
5189 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5191 switch (info.validity_type) {
5192 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5194 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5196 if (info.int_array.count < 1)
5199 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5201 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5203 if (info.int_range.min > info.int_range.max)
5206 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5208 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5210 if (info.double_array.count < 1)
5213 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5215 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5217 if (info.double_range.min >= info.double_range.max)
5221 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);