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,
1684 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1686 for (idx = 0 ; idx < attr_count ; idx++) {
1687 /* attribute order check. This should be same. */
1688 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1689 MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1690 free(attrs_const_info);
1691 attrs_const_info = NULL;
1692 free(hcamcorder->cam_attrs_const_info);
1693 hcamcorder->cam_attrs_const_info = NULL;
1697 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1698 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1699 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1700 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1703 /* Camcorder Attributes */
1704 MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1706 ret = mm_attrs_new(attrs_const_info,
1708 "Camcorder_Attributes",
1709 _mmcamcorder_commit_camcorder_attrs,
1713 free(attrs_const_info);
1714 attrs_const_info = NULL;
1716 if (ret != MM_ERROR_NONE) {
1717 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1718 free(hcamcorder->cam_attrs_const_info);
1719 hcamcorder->cam_attrs_const_info = NULL;
1723 __mmcamcorder_set_conf_to_valid_info(handle);
1725 for (idx = 0; idx < attr_count; idx++) {
1726 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1728 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1730 switch (attr_info->validity_type) {
1731 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1732 if (attr_info->validity_value_1.int_array &&
1733 attr_info->validity_value_2.count > 0) {
1734 mm_attrs_set_valid_array(attrs, idx,
1735 (const int *)(attr_info->validity_value_1.int_array),
1736 attr_info->validity_value_2.count,
1737 attr_info->default_value.value_int);
1740 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1741 mm_attrs_set_valid_range(attrs, idx,
1742 attr_info->validity_value_1.int_min,
1743 attr_info->validity_value_2.int_max,
1744 attr_info->default_value.value_int);
1746 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1747 if (attr_info->validity_value_1.double_array &&
1748 attr_info->validity_value_2.count > 0) {
1749 mm_attrs_set_valid_double_array(attrs, idx,
1750 (const double *)(attr_info->validity_value_1.double_array),
1751 attr_info->validity_value_2.count,
1752 attr_info->default_value.value_double);
1755 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1756 mm_attrs_set_valid_double_range(attrs, idx,
1757 attr_info->validity_value_1.double_min,
1758 attr_info->validity_value_2.double_max,
1759 attr_info->default_value.value_double);
1761 case MM_ATTRS_VALID_TYPE_NONE:
1763 case MM_ATTRS_VALID_TYPE_INVALID:
1765 MMCAM_LOG_ERROR("Valid type error.");
1770 __mmcamcorder_release_conf_valid_info(handle);
1777 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1779 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1781 if (hcamcorder == NULL) {
1782 MMCAM_LOG_ERROR("handle is NULL");
1789 mm_attrs_free(attrs);
1790 MMCAM_LOG_INFO("released attribute");
1793 if (hcamcorder->cam_attrs_const_info) {
1794 free(hcamcorder->cam_attrs_const_info);
1795 hcamcorder->cam_attrs_const_info = NULL;
1796 MMCAM_LOG_INFO("released attribute info");
1804 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1806 MMHandleType attrs = 0;
1807 int ret = MM_ERROR_NONE;
1809 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1810 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1812 attrs = MMF_CAMCORDER_ATTRS(handle);
1813 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1815 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1822 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1824 MMHandleType attrs = 0;
1825 int ret = MM_ERROR_NONE;
1827 char *tmp_err_attr_name = NULL;
1828 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1829 va_list var_args_copy;
1831 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1833 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1834 MMCAM_LOG_ERROR("Another command is running.");
1835 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1838 /* copy var_args to keep original var_args */
1839 va_copy(var_args_copy, var_args);
1841 attrs = MMF_CAMCORDER_ATTRS(handle);
1843 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1845 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1846 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1849 if (ret == MM_ERROR_NONE) {
1850 hcamcorder->error_code = MM_ERROR_NONE;
1851 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1852 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1855 va_end(var_args_copy);
1857 _MMCAMCORDER_UNLOCK_CMD(handle);
1859 if (ret != MM_ERROR_NONE) {
1860 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1861 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1862 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1863 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1864 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1865 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1869 if (hcamcorder->error_code != MM_ERROR_NONE) {
1870 MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1871 ret = hcamcorder->error_code;
1872 hcamcorder->error_code = MM_ERROR_NONE;
1875 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1878 if (tmp_err_attr_name) {
1879 if (!err_attr_name) {
1880 MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1881 free(tmp_err_attr_name);
1882 tmp_err_attr_name = NULL;
1884 *err_attr_name = tmp_err_attr_name;
1893 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1895 MMHandleType attrs = 0;
1896 MMAttrsInfo attrinfo;
1897 int ret = MM_ERROR_NONE;
1899 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1900 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1901 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1903 attrs = MMF_CAMCORDER_ATTRS(handle);
1904 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1906 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1908 if (ret == MM_ERROR_NONE) {
1909 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1910 info->type = attrinfo.type;
1911 info->flag = attrinfo.flag;
1912 info->validity_type = attrinfo.validity_type;
1914 switch (attrinfo.validity_type) {
1915 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1916 info->int_array.array = attrinfo.int_array.array;
1917 info->int_array.count = attrinfo.int_array.count;
1918 info->int_array.def = attrinfo.int_array.dval;
1920 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1921 info->int_range.min = attrinfo.int_range.min;
1922 info->int_range.max = attrinfo.int_range.max;
1923 info->int_range.def = attrinfo.int_range.dval;
1925 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1926 info->double_array.array = attrinfo.double_array.array;
1927 info->double_array.count = attrinfo.double_array.count;
1928 info->double_array.def = attrinfo.double_array.dval;
1930 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1931 info->double_range.min = attrinfo.double_range.min;
1932 info->double_range.max = attrinfo.double_range.max;
1933 info->double_range.def = attrinfo.double_range.dval;
1935 case MM_ATTRS_VALID_TYPE_NONE:
1937 case MM_ATTRS_VALID_TYPE_INVALID:
1948 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1951 mmf_camcorder_t *hcamcorder = NULL;
1953 mmf_return_val_if_fail(commit_param, FALSE);
1954 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1955 mmf_return_val_if_fail(attr_name, FALSE);
1956 mmf_return_val_if_fail(value, FALSE);
1958 hcamcorder = MMF_CAMCORDER(commit_param);
1960 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1961 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1969 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1972 int total_count = 0;
1974 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1976 if (hcamcorder == NULL) {
1977 MMCAM_LOG_ERROR("handle is NULL");
1978 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1982 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
1983 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
1984 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
1987 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
1988 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
1989 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
1992 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
1993 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
1994 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
1997 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
1998 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
1999 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
2001 return MM_ERROR_NONE;
2005 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
2007 int *allocated_memory = NULL;
2009 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2011 if (hcamcorder == NULL) {
2012 MMCAM_LOG_ERROR("handle is NULL");
2013 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2016 MMCAM_LOG_INFO("START");
2018 /* Audio encoder info */
2019 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2020 if (allocated_memory) {
2021 g_free(allocated_memory);
2022 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2023 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2026 /* Video encoder info */
2027 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2028 if (allocated_memory) {
2029 g_free(allocated_memory);
2030 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2031 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2034 /* Image encoder info */
2035 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2036 if (allocated_memory) {
2037 g_free(allocated_memory);
2038 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2039 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2042 /* File format info */
2043 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2044 if (allocated_memory) {
2045 g_free(allocated_memory);
2046 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2047 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2050 MMCAM_LOG_INFO("DONE");
2052 return MM_ERROR_NONE;
2056 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2058 MMHandleType attr = 0;
2059 int current_state = MM_CAMCORDER_STATE_NONE;
2061 mmf_return_val_if_fail(handle && value, FALSE);
2063 attr = MMF_CAMCORDER_ATTRS(handle);
2064 mmf_return_val_if_fail(attr, FALSE);
2066 /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2068 current_state = _mmcamcorder_get_state(handle);
2069 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2070 int flags = MM_ATTRS_FLAG_NONE;
2071 int capture_width, capture_height;
2072 MMCamAttrsInfo info;
2074 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2077 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2078 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2079 capture_width = value->value.i_val;
2081 /* Check whether they are valid pair */
2082 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2087 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2093 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2095 int current_state = MM_CAMCORDER_STATE_NONE;
2097 current_state = _mmcamcorder_get_state(handle);
2099 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2100 int capture_width, capture_height;
2102 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2103 capture_height = value->value.i_val;
2105 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2107 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2114 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2116 int current_state = 0;
2118 _MMCamcorderSubContext *sc = NULL;
2119 _MMCamcorderImageInfo *info = NULL;
2120 GstCameraControl *control = NULL;
2122 mmf_return_val_if_fail(handle && value, FALSE);
2124 current_state = _mmcamcorder_get_state(handle);
2125 ivalue = value->value.i_val;
2127 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2131 info = sc->info_image;
2133 MMCAM_LOG_ERROR("info image is NULL");
2137 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2138 if (info->capture_send_count > 0) {
2139 info->capturing = FALSE;
2140 MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2143 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2144 MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2148 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2150 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2151 MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2153 MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2156 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2163 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2165 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2166 int current_state = MM_CAMCORDER_STATE_NONE;
2167 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2169 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2171 current_state = _mmcamcorder_get_state(handle);
2172 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2174 MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2175 current_state, mode, value->value.i_val);
2177 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2178 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2181 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2187 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2189 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2191 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2193 MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2195 /* return error when disable shutter sound if policy is TRUE */
2196 if (!value->value.i_val &&
2197 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2198 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2201 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2207 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2209 int current_state = MM_CAMCORDER_STATE_NONE;
2210 _MMCamcorderSubContext *sc = NULL;
2213 mmf_return_val_if_fail(handle && value, FALSE);
2215 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2219 current_state = _mmcamcorder_get_state(handle);
2221 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2222 double mslNewVal = 0;
2223 mslNewVal = value->value.d_val;
2225 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2226 if (mslNewVal == 0.0) {
2227 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2228 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2230 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2231 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2235 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2238 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2246 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2248 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2249 int current_state = MM_CAMCORDER_STATE_NONE;
2251 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2253 current_state = _mmcamcorder_get_state(handle);
2254 if (current_state > MM_CAMCORDER_STATE_READY) {
2255 MMCAM_LOG_ERROR("invalid state %d", current_state);
2256 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2264 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2266 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2267 MMCamAttrsInfo fps_info;
2268 int resolution_width = 0;
2269 int resolution_height = 0;
2272 int current_state = MM_CAMCORDER_STATE_NONE;
2274 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2276 current_state = _mmcamcorder_get_state(handle);
2277 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2278 MMCAM_LOG_ERROR("invalid state %d", current_state);
2279 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2283 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2286 MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2288 ret = mm_camcorder_get_attributes(handle, NULL,
2289 MMCAM_CAMERA_WIDTH, &resolution_width,
2290 MMCAM_CAMERA_HEIGHT, &resolution_height,
2293 if (ret != MM_ERROR_NONE) {
2294 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2298 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2299 if (ret != MM_ERROR_NONE) {
2300 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2304 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2305 if (value->value.i_val == fps_info.int_array.array[i])
2309 MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2315 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2317 int current_state = MM_CAMCORDER_STATE_NONE;
2318 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2319 _MMCamcorderSubContext *sc = NULL;
2321 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2323 current_state = _mmcamcorder_get_state(handle);
2324 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2325 MMCAM_LOG_WARNING("invalid state %d", current_state);
2326 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2330 /* Verify recording motion rate */
2331 if (value->value.d_val > 0.0) {
2332 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2336 /* set is_slow flag */
2337 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2338 sc->is_modified_rate = TRUE;
2340 sc->is_modified_rate = FALSE;
2342 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2345 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2351 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2353 MMHandleType attr = 0;
2354 int current_state = MM_CAMCORDER_STATE_NONE;
2356 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2357 _MMCamcorderSubContext *sc = NULL;
2359 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2361 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2365 attr = MMF_CAMCORDER_ATTRS(handle);
2366 mmf_return_val_if_fail(attr, FALSE);
2368 MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2370 current_state = _mmcamcorder_get_state(handle);
2372 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2373 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2376 int flags = MM_ATTRS_FLAG_NONE;
2377 MMCamAttrsInfo info;
2378 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2381 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2382 int width = value->value.i_val;
2384 int preview_format = MM_PIXEL_FORMAT_NV12;
2385 int codec_type = MM_IMAGE_CODEC_JPEG;
2387 mm_camcorder_get_attributes(handle, NULL,
2388 MMCAM_CAMERA_HEIGHT, &height,
2389 MMCAM_CAMERA_FORMAT, &preview_format,
2390 MMCAM_IMAGE_ENCODER, &codec_type,
2393 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2394 if (hcamcorder->resolution_changed == FALSE) {
2395 MMCAM_LOG_INFO("no need to restart preview");
2399 hcamcorder->resolution_changed = FALSE;
2401 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2402 MMCAM_LOG_INFO("restart preview");
2404 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2405 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2407 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2408 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2410 /* check decoder recreation */
2411 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2412 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2413 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2417 /* get preview format */
2418 sc->info_image->preview_format = preview_format;
2419 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2420 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2422 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2423 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2425 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2426 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2429 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2431 MMCAM_LOG_ERROR("currently locked for preview restart");
2435 /* get preview format */
2436 sc->info_image->preview_format = preview_format;
2437 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2438 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2449 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2452 int current_state = MM_CAMCORDER_STATE_NONE;
2453 MMHandleType attr = 0;
2454 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2455 _MMCamcorderSubContext *sc = NULL;
2457 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2459 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2463 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2464 mmf_return_val_if_fail(attr, FALSE);
2466 MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2467 current_state = _mmcamcorder_get_state(handle);
2469 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2470 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2471 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2475 int height = value->value.i_val;
2476 int preview_format = MM_PIXEL_FORMAT_NV12;
2477 int codec_type = MM_IMAGE_CODEC_JPEG;
2478 int video_stabilization = 0;
2480 mm_camcorder_get_attributes(handle, NULL,
2481 MMCAM_CAMERA_WIDTH, &width,
2482 MMCAM_CAMERA_FORMAT, &preview_format,
2483 MMCAM_IMAGE_ENCODER, &codec_type,
2484 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2487 sc->info_video->preview_width = width;
2488 sc->info_video->preview_height = height;
2490 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2491 if (hcamcorder->resolution_changed == FALSE) {
2492 MMCAM_LOG_INFO("no need to restart preview");
2496 hcamcorder->resolution_changed = FALSE;
2498 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2499 MMCAM_LOG_INFO("restart preview");
2501 MMCAM_LOG_INFO("set empty buffers");
2503 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2504 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2506 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2507 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2509 /* check decoder recreation */
2510 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2511 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2512 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2516 /* get preview format */
2517 sc->info_image->preview_format = preview_format;
2518 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2520 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2522 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2523 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2525 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2526 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2529 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2531 MMCAM_LOG_ERROR("currently locked for preview restart");
2535 /* get preview format */
2536 sc->info_image->preview_format = preview_format;
2537 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2538 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2546 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2548 int current_state = MM_CAMCORDER_STATE_NONE;
2549 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2551 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2553 current_state = _mmcamcorder_get_state(handle);
2554 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2555 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2556 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2559 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2560 value->value.i_val, attr_idx);
2566 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2568 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2569 _MMCamcorderSubContext *sc = NULL;
2570 int current_state = MM_CAMCORDER_STATE_NONE;
2571 GstCameraControl *control = NULL;
2575 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2577 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2581 zoom_level = value->value.i_val;
2583 MMCAM_LOG_INFO("(%d)", attr_idx);
2585 current_state = _mmcamcorder_get_state(handle);
2586 if (current_state < MM_CAMCORDER_STATE_READY) {
2587 MMCAM_LOG_INFO("will be applied when preview starts");
2589 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2590 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2591 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2595 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2596 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2598 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2600 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2603 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2604 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2608 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2609 if (control == NULL) {
2610 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2614 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2616 MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2619 MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2622 MMCAM_LOG_INFO("pointer of video src is null");
2629 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2631 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2632 _MMCamcorderSubContext *sc = NULL;
2633 int current_state = MM_CAMCORDER_STATE_NONE;
2635 GstCameraControl *CameraControl = NULL;
2636 GstCameraControlChannel *CameraControlChannel = NULL;
2637 const GList *controls = NULL;
2638 const GList *item = NULL;
2640 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2642 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2643 mmf_return_val_if_fail(sc, TRUE);
2645 MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2647 current_state = _mmcamcorder_get_state(handle);
2648 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2649 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2650 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2651 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2655 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2656 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2657 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2661 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2662 if (CameraControl == NULL) {
2663 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2667 controls = gst_camera_control_list_channels(CameraControl);
2668 if (controls == NULL) {
2669 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2673 for (item = controls ; item && item->data ; item = item->next) {
2674 CameraControlChannel = item->data;
2675 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2676 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2677 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2678 MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2681 MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2687 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2694 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2696 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2697 _MMCamcorderSubContext *sc = NULL;
2698 int current_state = MM_CAMCORDER_STATE_NONE;
2700 GstCameraControl *CameraControl = NULL;
2701 GstCameraControlChannel *CameraControlChannel = NULL;
2702 const GList *controls = NULL;
2703 const GList *item = NULL;
2705 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2707 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2708 mmf_return_val_if_fail(sc, TRUE);
2710 MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2712 current_state = _mmcamcorder_get_state(handle);
2713 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2714 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2715 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2716 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2720 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2721 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2722 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2726 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2727 if (CameraControl == NULL) {
2728 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2732 controls = gst_camera_control_list_channels(CameraControl);
2733 if (controls == NULL) {
2734 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2738 for (item = controls ; item && item->data ; item = item->next) {
2739 CameraControlChannel = item->data;
2740 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2741 if (!strcmp(CameraControlChannel->label, "pan")) {
2742 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2743 MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2746 MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2752 MMCAM_LOG_WARNING("failed to find pan control channel");
2759 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2761 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2762 _MMCamcorderSubContext *sc = NULL;
2763 int current_state = MM_CAMCORDER_STATE_NONE;
2765 GstCameraControl *CameraControl = NULL;
2766 GstCameraControlChannel *CameraControlChannel = NULL;
2767 const GList *controls = NULL;
2768 const GList *item = NULL;
2770 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2772 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2773 mmf_return_val_if_fail(sc, TRUE);
2775 MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2777 current_state = _mmcamcorder_get_state(handle);
2778 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2779 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2780 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2781 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2785 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2786 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2787 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2791 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2792 if (CameraControl == NULL) {
2793 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2797 controls = gst_camera_control_list_channels(CameraControl);
2798 if (controls == NULL) {
2799 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2803 for (item = controls ; item && item->data ; item = item->next) {
2804 CameraControlChannel = item->data;
2805 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2806 if (!strcmp(CameraControlChannel->label, "tilt")) {
2807 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2808 MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2811 MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2817 MMCAM_LOG_WARNING("failed to find tilt control channel");
2824 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2826 MMHandleType attr = 0;
2827 int current_state = MM_CAMCORDER_STATE_NONE;
2828 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2829 _MMCamcorderSubContext *sc = NULL;
2830 GstCameraControl *control = NULL;
2832 int set_focus_mode = 0;
2833 int cur_focus_mode = 0;
2834 int cur_focus_range = 0;
2836 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2838 attr = MMF_CAMCORDER_ATTRS(handle);
2839 mmf_return_val_if_fail(attr, FALSE);
2841 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2845 MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2847 /* check whether set or not */
2848 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2849 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2853 current_state = _mmcamcorder_get_state(handle);
2854 if (current_state < MM_CAMCORDER_STATE_NULL) {
2855 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2857 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2858 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2859 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2863 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2864 int flags = MM_ATTRS_FLAG_NONE;
2865 MMCamAttrsInfo info;
2867 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2868 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2872 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2873 if (control == NULL) {
2874 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2878 mslVal = value->value.i_val;
2879 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2881 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2884 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2885 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2886 if (set_focus_mode != cur_focus_mode) {
2887 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2888 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2891 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2894 MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2898 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2902 MMCAM_LOG_INFO("pointer of video src is null");
2909 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2911 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2912 _MMCamcorderSubContext *sc = NULL;
2913 GstCameraControl *control = NULL;
2914 int current_state = MM_CAMCORDER_STATE_NONE;
2917 int cur_focus_mode = 0;
2918 int cur_focus_range = 0;
2919 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2920 int converted_mode = 0;
2922 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2924 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2928 MMCAM_LOG_INFO("(%d)", attr_idx);
2930 /* check whether set or not */
2931 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2932 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2936 mslVal = value->value.i_val;
2937 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2939 current_state = _mmcamcorder_get_state(handle);
2940 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2941 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
2943 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2944 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2945 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2949 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2950 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2951 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2955 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2956 if (control == NULL) {
2957 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2961 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
2962 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
2964 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2965 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
2966 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
2967 /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
2970 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2973 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
2977 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2980 MMCAM_LOG_INFO("pointer of video src is null");
2987 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2989 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2990 _MMCamcorderSubContext *sc = NULL;
2991 GstCameraControl *control = NULL;
2992 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
2993 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
2995 int current_state = MM_CAMCORDER_STATE_NONE;
2997 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2999 gboolean do_set = FALSE;
3001 MMCamAttrsInfo info_y;
3002 MMCamAttrsInfo info_w;
3003 MMCamAttrsInfo info_h;
3005 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3007 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3011 MMCAM_LOG_INFO("(%d)", attr_idx);
3013 current_state = _mmcamcorder_get_state(handle);
3014 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3015 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3017 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3018 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3019 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3023 ret = mm_camcorder_get_attributes(handle, NULL,
3024 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3026 if (ret != MM_ERROR_NONE) {
3027 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3031 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3032 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3036 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3037 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3038 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3042 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3043 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3044 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3047 case MM_CAM_CAMERA_AF_TOUCH_X:
3048 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3049 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3050 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3051 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3052 set_area.x = value->value.i_val;
3053 mm_camcorder_get_attributes(handle, NULL,
3054 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3055 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3056 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3060 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3064 case MM_CAM_CAMERA_AF_TOUCH_Y:
3065 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3066 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3067 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3068 set_area.y = value->value.i_val;
3069 mm_camcorder_get_attributes(handle, NULL,
3070 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3071 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3072 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3076 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3080 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3081 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3082 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3083 set_area.width = value->value.i_val;
3084 mm_camcorder_get_attributes(handle, NULL,
3085 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3086 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3087 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3091 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3095 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3096 set_area.height = value->value.i_val;
3097 mm_camcorder_get_attributes(handle, NULL,
3098 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3099 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3100 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3109 _MMCamcorderVideoInfo *info = sc->info_video;
3112 MMCAM_LOG_ERROR("video info is NULL");
3116 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3117 if (control == NULL) {
3118 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3123 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3124 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3125 float ratio_width = 0.0;
3126 float ratio_height = 0.0;
3128 if (info->preview_width != 0 && info->preview_height != 0) {
3129 ratio_width = (float)info->video_width / (float)info->preview_width;
3130 ratio_height = (float)info->video_height / (float)info->preview_height;
3132 MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3133 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3135 set_area.x = (int)((float)set_area.x * ratio_width);
3136 set_area.y = (int)((float)set_area.y * ratio_height);
3137 set_area.width = (int)((float)set_area.width * ratio_width);
3138 set_area.height = (int)((float)set_area.height * ratio_height);
3140 if (set_area.width <= 0)
3143 if (set_area.height <= 0)
3144 set_area.height = 1;
3146 MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3147 set_area.x, set_area.y, set_area.width, set_area.height);
3149 MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3150 info->preview_width, info->preview_height);
3154 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3156 MMCAM_LOG_WARNING("Failed to get AF area");
3160 /* width and height are not supported now */
3161 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3162 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3163 get_area.x, get_area.y);
3167 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3169 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3170 set_area.x, set_area.y, set_area.width, set_area.height);
3173 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3174 set_area.x, set_area.y, set_area.width, set_area.height);
3178 MMCAM_LOG_INFO("pointer of video src is null");
3185 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3187 GstCameraControl *control = NULL;
3193 int exposure_type = 0;
3194 int current_state = MM_CAMCORDER_STATE_NONE;
3195 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3196 _MMCamcorderSubContext *sc = NULL;
3198 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3199 gboolean check_scene_mode = FALSE;
3201 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3203 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3207 /* check whether set or not */
3208 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3209 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3213 current_state = _mmcamcorder_get_state(handle);
3214 if (current_state < MM_CAMCORDER_STATE_READY) {
3215 MMCAM_LOG_INFO("will be applied when preview starts");
3217 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3218 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3219 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3223 ivalue = value->value.i_val;
3225 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3226 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3227 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3228 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3229 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3230 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3231 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3232 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3233 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3234 exposure_type = GST_CAMERA_CONTROL_ISO;
3236 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3237 check_scene_mode = TRUE;
3238 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3239 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3241 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3242 check_scene_mode = TRUE;
3243 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3244 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3245 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3246 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3249 if (check_scene_mode) {
3250 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3251 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3252 MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3257 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3260 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3261 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3265 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3266 if (control == NULL) {
3267 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3271 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3273 MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3276 MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3279 MMCAM_LOG_INFO("pointer of video src is null");
3286 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3288 GstCameraControl *control = NULL;
3292 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3293 _MMCamcorderSubContext *sc = NULL;
3294 int current_state = MM_CAMCORDER_STATE_NONE;
3296 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3298 /* check whether set or not */
3299 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3300 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3304 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3308 /* check current state */
3309 current_state = _mmcamcorder_get_state(handle);
3310 if (current_state < MM_CAMCORDER_STATE_READY) {
3311 MMCAM_LOG_INFO("will be applied when preview starts");
3313 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3314 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3315 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3319 mslVal = value->value.i_val;
3320 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3322 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3323 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3324 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3328 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3329 if (control == NULL) {
3330 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3334 if (gst_camera_control_get_wdr(control, &cur_value)) {
3335 if (newVal != cur_value) {
3336 if (gst_camera_control_set_wdr(control, newVal)) {
3337 MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3340 MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3343 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3347 MMCAM_LOG_WARNING("Failed to get WDR.");
3350 MMCAM_LOG_INFO("pointer of video src is null");
3357 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3359 int current_state = MM_CAMCORDER_STATE_NONE;
3360 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3362 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3364 /* check whether set or not */
3365 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3366 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3370 current_state = _mmcamcorder_get_state(handle);
3371 if (current_state < MM_CAMCORDER_STATE_READY) {
3372 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3374 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3375 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3376 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3380 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3384 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3388 int current_state = MM_CAMCORDER_STATE_NONE;
3389 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3390 _MMCamcorderSubContext *sc = NULL;
3392 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3394 bitrate = value->value.i_val;
3396 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3397 if (!sc || !sc->encode_element) {
3398 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3402 current_state = _mmcamcorder_get_state(handle);
3403 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3404 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3405 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3409 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3410 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3412 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3413 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3415 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3416 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3423 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3425 int current_state = MM_CAMCORDER_STATE_NONE;
3426 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3428 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3430 current_state = _mmcamcorder_get_state(handle);
3431 if (current_state < MM_CAMCORDER_STATE_READY) {
3432 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3434 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3435 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3436 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3440 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3444 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3446 int current_state = MM_CAMCORDER_STATE_NONE;
3447 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3449 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3451 MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3453 current_state = _mmcamcorder_get_state(handle);
3455 if (current_state > MM_CAMCORDER_STATE_READY) {
3456 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3457 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3460 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3465 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3467 int current_state = MM_CAMCORDER_STATE_NONE;
3469 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3470 _MMCamcorderSubContext *sc = NULL;
3472 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3475 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3476 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3480 /* check current state */
3481 current_state = _mmcamcorder_get_state(handle);
3482 if (current_state < MM_CAMCORDER_STATE_READY) {
3483 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3485 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3486 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3487 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3491 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3493 MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3495 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3496 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3499 MMCAM_LOG_ERROR("invalid state %d", current_state);
3505 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3507 mmf_return_val_if_fail(handle && value, FALSE);
3510 if (!value->value.s_val) {
3511 MMCAM_LOG_ERROR("NULL filename");
3515 MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3521 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3523 int current_state = MM_CAMCORDER_STATE_NONE;
3524 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3526 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3528 current_state = _mmcamcorder_get_state(handle);
3529 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3530 MMCAM_LOG_ERROR("Can not set while RECORDING");
3531 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3539 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3541 GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3542 MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3543 return strcmp(Colorchannel->label, user_data);
3546 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3548 GstColorBalance *balance = NULL;
3549 GstColorBalanceChannel *Colorchannel = NULL;
3550 GList *controls = NULL;
3554 int current_state = MM_CAMCORDER_STATE_NONE;
3555 const char *control_label = NULL;
3556 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3557 _MMCamcorderSubContext *sc = NULL;
3559 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3560 gboolean check_scene_mode = FALSE;
3562 int wb_temp_table[] = {
3563 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3564 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3565 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3566 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3567 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3568 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3571 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3573 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3577 /* check whether set or not */
3578 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3579 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3583 current_state = _mmcamcorder_get_state(handle);
3584 if (current_state < MM_CAMCORDER_STATE_READY) {
3585 MMCAM_LOG_INFO("will be applied when preview starts");
3587 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3588 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3589 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3593 if (value->type != MM_ATTRS_TYPE_INT) {
3594 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3598 mslVal = value->value.i_val;
3601 case MM_CAM_FILTER_BRIGHTNESS:
3602 control_label = "brightness";
3603 check_scene_mode = TRUE;
3605 case MM_CAM_FILTER_CONTRAST:
3606 control_label = "contrast";
3608 case MM_CAM_FILTER_WB:
3609 control_label = "white balance";
3610 check_scene_mode = TRUE;
3612 case MM_CAM_FILTER_COLOR_TONE:
3613 control_label = "color tone";
3615 case MM_CAM_FILTER_SATURATION:
3616 control_label = "saturation";
3617 check_scene_mode = TRUE;
3619 case MM_CAM_FILTER_HUE:
3620 control_label = "hue";
3622 case MM_CAM_FILTER_SHARPNESS:
3623 control_label = "sharpness";
3624 check_scene_mode = TRUE;
3627 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3631 if (check_scene_mode) {
3632 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3633 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3634 MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3639 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3640 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3643 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3644 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3648 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3649 if (balance == NULL) {
3650 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3654 controls = (GList *)gst_color_balance_list_channels(balance);
3655 if (controls == NULL) {
3656 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3661 MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3662 attr_idx, control_label, mslVal, newVal);
3664 item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3666 Colorchannel = item->data;
3667 gst_color_balance_set_value(balance, Colorchannel, newVal);
3668 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3672 if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3673 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3675 control_label = "white_balance_temperature_auto";
3678 newVal = wb_temp_table[mslVal];
3679 control_label = "white_balance_temperature";
3684 MMCAM_LOG_ERROR("failed to find color channel item");
3690 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3694 int current_state = MM_CAMCORDER_STATE_NONE;
3695 GstCameraControl *control = NULL;
3696 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3697 _MMCamcorderSubContext *sc = NULL;
3699 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3701 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3705 mslVal = value->value.i_val;
3706 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3708 /* check whether set or not */
3709 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3710 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3714 current_state = _mmcamcorder_get_state(handle);
3715 if (current_state < MM_CAMCORDER_STATE_READY) {
3716 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3718 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3719 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3720 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3724 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3727 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3728 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3732 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3733 if (control == NULL) {
3734 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3738 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3740 MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3742 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3746 MM_CAM_FILTER_BRIGHTNESS,
3748 MM_CAM_FILTER_SATURATION,
3749 MM_CAM_FILTER_SHARPNESS,
3750 MM_CAM_FILTER_COLOR_TONE,
3751 MM_CAM_CAMERA_EXPOSURE_MODE
3753 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3755 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3756 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3757 mm_attrs_set_modified(attrs, attr_idxs[i]);
3763 MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3766 MMCAM_LOG_WARNING("pointer of video src is null");
3773 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3775 mmf_return_val_if_fail(handle && value, FALSE);
3777 MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3783 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3785 mmf_return_val_if_fail(handle && value, FALSE);
3787 MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3793 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3795 int current_state = MM_CAMCORDER_STATE_NONE;
3796 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3798 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3800 current_state = _mmcamcorder_get_state(handle);
3801 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3802 MMCAM_LOG_WARNING("Can NOT Disable AUDIO. invalid state %d", current_state);
3803 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3806 MMCAM_LOG_INFO("Disable AUDIO when Recording");
3812 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3814 int current_state = MM_CAMCORDER_STATE_NONE;
3815 const char *videosink_name = NULL;
3816 void *dp_handle = NULL;
3817 MMCamWindowInfo *window_info = NULL;
3819 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3820 _MMCamcorderSubContext *sc = NULL;
3822 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3825 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3826 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3830 /* check current state */
3831 current_state = _mmcamcorder_get_state(handle);
3832 if (current_state < MM_CAMCORDER_STATE_READY) {
3833 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3837 dp_handle = value->value.p_val;
3839 MMCAM_LOG_WARNING("Display handle is NULL");
3843 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3845 /* get videosink name */
3846 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3847 if (!videosink_name) {
3848 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3852 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3854 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3855 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
3856 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
3857 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3858 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
3859 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
3860 } else if (!strcmp(videosink_name, "tizenwlsink")) {
3861 window_info = (MMCamWindowInfo *)dp_handle;
3862 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
3863 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3864 } else if (!strcmp(videosink_name, "directvideosink")) {
3865 window_info = (MMCamWindowInfo *)dp_handle;
3866 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
3867 window_info->surface_id,
3868 window_info->rect.x,
3869 window_info->rect.y,
3870 window_info->rect.width,
3871 window_info->rect.height);
3872 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3873 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3874 window_info->rect.x,
3875 window_info->rect.y,
3876 window_info->rect.width,
3877 window_info->rect.height);
3879 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
3887 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3889 int current_state = MM_CAMCORDER_STATE_NONE;
3890 const char *videosink_name = NULL;
3892 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3893 _MMCamcorderSubContext *sc = NULL;
3895 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3898 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3899 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3903 /* check current state */
3904 current_state = _mmcamcorder_get_state(handle);
3905 if (current_state < MM_CAMCORDER_STATE_READY) {
3906 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3910 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3912 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3913 if (videosink_name == NULL) {
3914 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3918 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3920 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3921 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
3922 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3924 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
3931 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3933 int current_state = MM_CAMCORDER_STATE_NONE;
3935 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3937 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3940 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3941 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3945 /* check current state */
3946 current_state = _mmcamcorder_get_state(handle);
3947 if (current_state < MM_CAMCORDER_STATE_READY) {
3948 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3952 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3956 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3958 int current_state = MM_CAMCORDER_STATE_NONE;
3960 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3962 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3965 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3966 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3970 /* check current state */
3971 current_state = _mmcamcorder_get_state(handle);
3972 if (current_state < MM_CAMCORDER_STATE_READY) {
3973 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3977 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3981 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3983 int current_state = MM_CAMCORDER_STATE_NONE;
3984 const char *videosink_name = NULL;
3986 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3987 _MMCamcorderSubContext *sc = NULL;
3989 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3992 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3993 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3997 /* check current state */
3998 current_state = _mmcamcorder_get_state(handle);
3999 if (current_state < MM_CAMCORDER_STATE_READY) {
4000 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4004 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4006 /* Get videosink name */
4007 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4008 if (videosink_name == NULL) {
4009 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4013 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4014 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4015 !strcmp(videosink_name, "directvideosink")) {
4016 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4017 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4019 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4026 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4029 int current_state = MM_CAMCORDER_STATE_NONE;
4030 const char *videosink_name = NULL;
4032 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4033 _MMCamcorderSubContext *sc = NULL;
4035 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4038 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4039 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4043 /* check current state */
4044 current_state = _mmcamcorder_get_state(handle);
4045 if (current_state < MM_CAMCORDER_STATE_READY) {
4046 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4050 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4052 /* Get videosink name */
4053 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4054 if (videosink_name == NULL) {
4055 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4059 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4060 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4061 !strcmp(videosink_name, "directvideosink")) {
4062 method = value->value.i_val;
4063 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4065 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4072 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4074 int current_state = MM_CAMCORDER_STATE_NONE;
4075 int ret = MM_ERROR_NONE;
4076 const char *videosink_name = NULL;
4078 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4079 _MMCamcorderSubContext *sc = NULL;
4081 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4084 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4085 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4089 /* check current state */
4090 current_state = _mmcamcorder_get_state(handle);
4091 if (current_state < MM_CAMCORDER_STATE_READY) {
4092 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4096 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4098 /* Get videosink name */
4099 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4100 if (videosink_name == NULL) {
4101 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4105 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4106 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4110 int rect_height = 0;
4111 int flags = MM_ATTRS_FLAG_NONE;
4112 MMCamAttrsInfo info;
4114 mm_camcorder_get_attributes(handle, NULL,
4115 MMCAM_DISPLAY_RECT_X, &rect_x,
4116 MMCAM_DISPLAY_RECT_Y, &rect_y,
4117 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4118 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4121 case MM_CAM_DISPLAY_RECT_X:
4122 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4124 memset(&info, 0x00, sizeof(info));
4125 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4127 memset(&info, 0x00, sizeof(info));
4128 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4131 rect_x = value->value.i_val;
4133 case MM_CAM_DISPLAY_RECT_Y:
4134 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4136 memset(&info, 0x00, sizeof(info));
4137 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4140 rect_y = value->value.i_val;
4142 case MM_CAM_DISPLAY_RECT_WIDTH:
4143 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4146 rect_width = value->value.i_val;
4148 case MM_CAM_DISPLAY_RECT_HEIGHT:
4149 rect_height = value->value.i_val;
4152 MMCAM_LOG_ERROR("Wrong attr_idx!");
4156 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4157 MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4159 if (!strcmp(videosink_name, "tizenwlsink")) {
4160 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4161 rect_x, rect_y, rect_width, rect_height);
4163 MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4167 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4168 "dst-roi-x", rect_x,
4169 "dst-roi-y", rect_y,
4170 "dst-roi-w", rect_width,
4171 "dst-roi-h", rect_height,
4176 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4183 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4186 int current_state = MM_CAMCORDER_STATE_NONE;
4187 const char *videosink_name = NULL;
4188 GstElement *vs_element = NULL;
4190 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4191 _MMCamcorderSubContext *sc = NULL;
4193 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4196 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4197 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4201 /* check current state */
4202 current_state = _mmcamcorder_get_state(handle);
4203 if (current_state < MM_CAMCORDER_STATE_READY) {
4204 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4208 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4210 /* Get videosink name */
4211 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4212 if (videosink_name == NULL) {
4213 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4217 zoom = value->value.i_val;
4218 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4219 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4221 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4222 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4226 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4232 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4234 int current_state = MM_CAMCORDER_STATE_NONE;
4236 const char *videosink_name = NULL;
4238 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4239 _MMCamcorderSubContext *sc = NULL;
4241 mmf_return_val_if_fail(handle && value, FALSE);
4244 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4245 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4249 /* check current state */
4250 current_state = _mmcamcorder_get_state(handle);
4251 if (current_state < MM_CAMCORDER_STATE_READY) {
4252 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4256 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4258 do_scaling = value->value.i_val;
4260 /* Get videosink name */
4261 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4262 if (videosink_name == NULL) {
4263 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4267 if (!strcmp(videosink_name, "evaspixmapsink")) {
4268 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4269 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4272 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4278 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4280 _MMCamcorderSubContext *sc = NULL;
4281 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4282 int strobe_type, mslVal, newVal, cur_value;
4283 int current_state = MM_CAMCORDER_STATE_NONE;
4285 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4287 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4291 /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4293 mslVal = value->value.i_val;
4295 /* check flash state */
4296 if (attr_idx == MM_CAM_STROBE_MODE) {
4297 int led_brightness = 0;
4299 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4300 MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4301 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4305 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4307 if (led_brightness > 0 &&
4308 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4309 /* other module already turned on LED */
4310 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4311 MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4315 MMCAM_LOG_INFO("keep going");
4319 current_state = _mmcamcorder_get_state(handle);
4320 if (current_state < MM_CAMCORDER_STATE_READY) {
4321 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4323 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4324 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4325 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4330 case MM_CAM_STROBE_CONTROL:
4331 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4332 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4334 case MM_CAM_STROBE_CAPABILITIES:
4335 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4338 case MM_CAM_STROBE_MODE:
4339 /* check whether set or not */
4340 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4341 MMCAM_LOG_INFO("skip set value %d", mslVal);
4345 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4346 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4348 case MM_CAM_STROBE_BRIGHTNESS:
4349 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4353 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4357 GstCameraControl *control = NULL;
4358 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4359 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4363 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4364 if (control == NULL) {
4365 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4369 if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4370 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4374 if (newVal == cur_value) {
4375 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4379 if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4380 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4384 MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4390 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4393 int current_state = MM_CAMCORDER_STATE_NONE;
4394 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4396 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4398 MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4401 current_state = _mmcamcorder_get_state(handle);
4402 if (current_state > MM_CAMCORDER_STATE_READY) {
4403 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4404 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4406 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4407 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4411 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4413 MMCAM_LOG_INFO("ret %d", ret);
4419 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4421 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4422 int current_state = MM_CAMCORDER_STATE_NONE;
4423 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4424 _MMCamcorderSubContext *sc = NULL;
4426 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4428 /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4430 /* check whether set or not */
4431 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4432 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4437 current_state = _mmcamcorder_get_state(handle);
4438 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4439 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4440 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4444 if (current_state >= MM_CAMCORDER_STATE_READY) {
4445 int current_value = 0;
4447 set_hdr_mode = value->value.i_val;
4448 mm_camcorder_get_attributes(handle, NULL,
4449 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4452 if (set_hdr_mode == current_value) {
4453 MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4457 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4459 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4460 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4461 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4463 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4465 /* check decoder recreation */
4466 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4467 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4471 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4472 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4475 set_hdr_mode = value->value.i_val;
4476 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4477 sc->info_image->hdr_capture_mode = set_hdr_mode;
4478 MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4480 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4481 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4483 MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4492 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4495 _MMCamcorderSubContext *sc = NULL;
4496 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4498 int current_value = 0;
4499 int current_state = MM_CAMCORDER_STATE_NONE;
4500 GstCameraControl *control = NULL;
4502 mmf_return_val_if_fail(handle && value, FALSE);
4504 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4508 /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4511 current_state = _mmcamcorder_get_state(handle);
4512 if (current_state < MM_CAMCORDER_STATE_READY) {
4513 MMCAM_LOG_INFO("will be applied when preview starts");
4517 set_value = value->value.i_val;
4520 case MM_CAM_DETECT_MODE:
4521 /* check whether set or not */
4522 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4523 MMCAM_LOG_INFO("skip set value %d", set_value);
4527 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4529 case MM_CAM_DETECT_NUMBER:
4530 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4532 case MM_CAM_DETECT_FOCUS_SELECT:
4533 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4535 case MM_CAM_DETECT_SELECT_NUMBER:
4536 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4538 case MM_CAM_DETECT_STATUS:
4539 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4542 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4546 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4547 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4550 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4551 if (control == NULL) {
4552 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4556 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4557 if (current_value == set_value) {
4558 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4561 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4562 MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4563 detect_type, set_value);
4566 MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4567 detect_type, set_value);
4572 MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4581 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4583 int current_state = MM_CAMCORDER_STATE_NONE;
4584 int preview_format = MM_PIXEL_FORMAT_NV12;
4586 mmf_return_val_if_fail(handle && value, FALSE);
4588 MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4590 /* check preview format */
4591 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4592 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4593 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4598 current_state = _mmcamcorder_get_state(handle);
4599 if (current_state < MM_CAMCORDER_STATE_READY) {
4600 MMCAM_LOG_INFO("will be applied when preview starts");
4604 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4608 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4610 int current_state = MM_CAMCORDER_STATE_NONE;
4611 int preview_format = MM_PIXEL_FORMAT_NV12;
4613 mmf_return_val_if_fail(handle && value, FALSE);
4615 MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4617 /* check preview format */
4618 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4619 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4620 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4625 current_state = _mmcamcorder_get_state(handle);
4626 if (current_state < MM_CAMCORDER_STATE_READY) {
4627 MMCAM_LOG_INFO("will be applied when preview starts");
4631 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4635 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4637 int stream_index = 0;
4638 char *stream_type = NULL;
4639 _MMCamcorderSubContext *sc = NULL;
4641 mmf_return_val_if_fail(handle && value, FALSE);
4643 stream_type = value->value.s_val;
4645 MMCAM_LOG_ERROR("NULL string");
4649 mm_camcorder_get_attributes(handle, NULL,
4650 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4652 if (stream_index < 0) {
4653 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4657 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4658 if (!sc || !sc->encode_element ||
4659 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4660 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4664 MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4666 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4670 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4672 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4673 int current_state = MM_CAMCORDER_STATE_NONE;
4675 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4677 current_state = _mmcamcorder_get_state(handle);
4678 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4679 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4680 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4687 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4689 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4691 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4693 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4694 /* Replay gain enable */
4695 int current_state = MM_CAMCORDER_STATE_NONE;
4696 int audio_disable = FALSE;
4698 current_state = _mmcamcorder_get_state(handle);
4699 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4700 MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4701 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4705 mm_camcorder_get_attributes(handle, NULL,
4706 MMCAM_AUDIO_DISABLE, &audio_disable,
4709 if (audio_disable) {
4710 MMCAM_LOG_ERROR("audio is disabled");
4711 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4715 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4716 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4717 /* Replay gain reference level */
4718 int replay_gain_enable = FALSE;
4720 mm_camcorder_get_attributes(handle, NULL,
4721 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4724 if (replay_gain_enable == FALSE) {
4725 MMCAM_LOG_ERROR("replay gain is disabled");
4726 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4730 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4732 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4740 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4742 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4745 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4749 int attr_idxs_default[] = {
4750 MM_CAM_CAMERA_DIGITAL_ZOOM,
4751 MM_CAM_CAMERA_OPTICAL_ZOOM,
4753 MM_CAM_FILTER_CONTRAST,
4756 MM_CAM_STROBE_BRIGHTNESS
4759 int attr_idxs_extra[] = {
4761 MM_CAM_FILTER_BRIGHTNESS,
4763 MM_CAM_FILTER_SATURATION,
4764 MM_CAM_FILTER_SHARPNESS,
4765 MM_CAM_FILTER_COLOR_TONE,
4766 MM_CAM_CAMERA_EXPOSURE_MODE
4769 mmf_return_val_if_fail(hcamcorder, FALSE);
4771 MMCAM_LOG_INFO("commit some attributes again");
4773 attrs = MMF_CAMCORDER_ATTRS(handle);
4774 if (attrs == NULL) {
4775 MMCAM_LOG_ERROR("Get attribute handle failed.");
4779 /* Get Scene mode */
4780 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4782 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4783 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4784 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4787 /* Set extra if scene mode is NORMAL */
4788 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4789 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4790 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4791 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4794 /* Set scene mode if scene mode is NOT NORMAL */
4795 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4796 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4799 if (mm_attrs_commit_all(attrs) == -1)
4804 MMCAM_LOG_INFO("Done.");
4810 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4812 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4818 MM_CAM_CAMERA_PTZ_TYPE,
4819 MM_CAM_CAMERA_PAN_MECHA,
4820 MM_CAM_CAMERA_PAN_ELEC,
4821 MM_CAM_CAMERA_TILT_MECHA,
4822 MM_CAM_CAMERA_TILT_ELEC
4825 mmf_return_val_if_fail(hcamcorder, FALSE);
4827 MMCAM_LOG_INFO("commit some attribute again[2]");
4829 attrs = MMF_CAMCORDER_ATTRS(handle);
4830 if (attrs == NULL) {
4831 MMCAM_LOG_ERROR("Get attribute handle failed.");
4835 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4836 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4837 mm_attrs_set_modified(attrs, attr_idxs[i]);
4840 if (mm_attrs_commit_all(attrs) == -1)
4845 MMCAM_LOG_INFO("Done.");
4851 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4853 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4857 int nerror = MM_ERROR_NONE;
4859 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4861 attrs = MMF_CAMCORDER_ATTRS(handle);
4862 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4866 table_size = ARRAY_SIZE(readonly_attributes);
4867 MMCAM_LOG_INFO("%d", table_size);
4868 for (i = 0; i < table_size; i++) {
4869 int sCategory = readonly_attributes[i];
4871 mm_attrs_set_readonly(attrs, sCategory);
4878 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4880 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4883 type_string_array * disabled_attr = NULL;
4885 int nerror = MM_ERROR_NONE ;
4887 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4889 attrs = MMF_CAMCORDER_ATTRS(handle);
4890 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4895 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4896 CONFIGURE_CATEGORY_MAIN_GENERAL,
4897 "DisabledAttributes",
4899 if (disabled_attr != NULL && disabled_attr->value) {
4900 cnt_str = disabled_attr->count;
4901 for (i = 0; i < cnt_str; i++) {
4903 MMCAM_LOG_INFO("[%d]%s", i, disabled_attr->value[i]);
4904 nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
4906 if (nerror == MM_ERROR_NONE)
4907 mm_attrs_set_disabled(attrs, idx);
4909 MMCAM_LOG_WARNING("No ATTR named %s[%d]", disabled_attr->value[i], i);
4917 /*---------------------------------------------------------------------------------------
4918 | INTERNAL FUNCTION DEFINITIONS: |
4919 ---------------------------------------------------------------------------------------*/
4920 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4922 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4923 _MMCamcorderSubContext *sc = NULL;
4924 int current_state = MM_CAMCORDER_STATE_NULL;
4926 mmf_return_val_if_fail(hcamcorder, FALSE);
4928 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4932 current_state = _mmcamcorder_get_state(handle);
4934 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4935 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4936 MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
4937 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4938 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4940 MMCAM_LOG_WARNING("invalid state[%d]", current_state);
4944 MMCAM_LOG_INFO("element is not created yet");
4951 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4953 #define INIT_VALUE -1
4954 #define CHECK_COUNT 3
4956 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4957 MMHandleType attrs = 0;
4959 int ret = MM_ERROR_NONE;
4962 const char *name = NULL;
4963 const char *check_pair_name[CHECK_COUNT][3] = {
4964 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
4965 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
4966 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
4969 int check_pair_value[CHECK_COUNT][2] = {
4970 {INIT_VALUE, INIT_VALUE},
4971 {INIT_VALUE, INIT_VALUE},
4972 {INIT_VALUE, INIT_VALUE},
4975 if (hcamcorder == NULL || attribute_name == NULL) {
4976 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
4977 hcamcorder, attribute_name);
4978 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4982 *err_attr_name = NULL;
4984 /*MMCAM_LOG_INFO( "ENTER" );*/
4986 attrs = MMF_CAMCORDER_ATTRS(handle);
4988 name = attribute_name;
4992 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
4994 /*MMCAM_LOG_INFO("NAME : %s", name);*/
4996 /* attribute name check */
4997 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
4999 *err_attr_name = strdup(name);
5001 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
5002 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5008 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5011 switch (attr_type) {
5012 case MM_ATTRS_TYPE_INT:
5014 gboolean matched = FALSE;
5015 for (i = 0 ; i < CHECK_COUNT ; i++) {
5016 for (j = 0 ; j < 2 ; j++) {
5017 if (!strcmp(name, check_pair_name[i][j])) {
5018 check_pair_value[i][j] = va_arg((var_args), int);
5019 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5027 if (matched == FALSE)
5028 va_arg((var_args), int);
5031 case MM_ATTRS_TYPE_DOUBLE:
5032 va_arg((var_args), double);
5034 case MM_ATTRS_TYPE_STRING:
5035 va_arg((var_args), char*); /* string */
5036 va_arg((var_args), int); /* size */
5038 case MM_ATTRS_TYPE_DATA:
5039 va_arg((var_args), void*); /* data */
5040 va_arg((var_args), int); /* size */
5042 case MM_ATTRS_TYPE_INVALID:
5044 MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5046 *err_attr_name = strdup(name);
5048 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5052 name = va_arg(var_args, const char*);
5055 for (i = 0 ; i < CHECK_COUNT ; i++) {
5056 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5057 gboolean check_result = FALSE;
5058 char *err_name = NULL;
5059 MMCamAttrsInfo attr_info_0, attr_info_1;
5061 if (check_pair_value[i][0] == INIT_VALUE) {
5062 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5063 err_name = strdup(check_pair_name[i][1]);
5064 } else if (check_pair_value[i][1] == INIT_VALUE) {
5065 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5066 err_name = strdup(check_pair_name[i][0]);
5068 err_name = strdup(check_pair_name[i][2]);
5071 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5072 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5074 check_result = FALSE;
5076 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5077 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5078 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5080 MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5081 check_pair_name[i][0], check_pair_name[i][1],
5082 check_pair_value[i][0], check_pair_value[i][1], i);
5084 check_result = TRUE;
5089 if (check_result == FALSE) {
5090 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5091 check_pair_name[i][0], check_pair_name[i][1],
5092 check_pair_value[i][0], check_pair_value[i][1]);
5093 if (err_attr_name) {
5094 *err_attr_name = err_name;
5102 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5105 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5106 int current_width = 0;
5107 int current_height = 0;
5109 mm_camcorder_get_attributes(handle, NULL,
5110 MMCAM_CAMERA_WIDTH, ¤t_width,
5111 MMCAM_CAMERA_HEIGHT, ¤t_height,
5114 if (current_width != check_pair_value[i][0] ||
5115 current_height != check_pair_value[i][1]) {
5116 hcamcorder->resolution_changed = TRUE;
5118 hcamcorder->resolution_changed = FALSE;
5121 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5131 /*MMCAM_LOG_INFO("DONE");*/
5133 return MM_ERROR_NONE;
5137 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5141 if ((void *)handle == NULL) {
5142 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5146 memset(&info, 0x0, sizeof(MMAttrsInfo));
5148 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5150 switch (info.validity_type) {
5151 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5153 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5155 if (info.int_array.count < 1)
5158 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5160 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5162 if (info.int_range.min > info.int_range.max)
5165 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5167 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5169 if (info.double_array.count < 1)
5172 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5174 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5176 if (info.double_range.min >= info.double_range.max)
5180 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);