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>
32 #include <gst/wayland/wayland.h>
34 /*-----------------------------------------------------------------------
35 | MACRO DEFINITIONS: |
36 -----------------------------------------------------------------------*/
37 #define MMCAMCORDER_DEFAULT_CAMERA_WIDTH 640
38 #define MMCAMCORDER_DEFAULT_CAMERA_HEIGHT 480
39 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE (1024*1024*10)
40 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL 1000
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
68 /*-----------------------------------------------------------------------
69 | LOCAL FUNCTION PROTOTYPES: |
70 -----------------------------------------------------------------------*/
71 /* STATIC INTERNAL FUNCTION */
72 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height);
73 static int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle);
74 static int __mmcamcorder_release_conf_valid_info(MMHandleType handle);
75 static bool __mmcamcorder_attrs_is_supported(MMHandleType handle, int idx);
76 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
78 /*=======================================================================
79 | FUNCTION DEFINITIONS |
80 =======================================================================*/
81 /*-----------------------------------------------------------------------
82 | GLOBAL FUNCTION DEFINITIONS: |
83 -----------------------------------------------------------------------*/
85 _mmcamcorder_alloc_attribute( MMHandleType handle, MMCamPreset *info )
89 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
90 MMHandleType attrs = 0;
91 mmf_attrs_construct_info_t *attrs_const_info = NULL;
92 unsigned int attr_count = 0;
95 static int depth[] = {MM_CAMCORDER_AUDIO_FORMAT_PCM_U8, MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE};
96 static int flip_list[] = { MM_FLIP_NONE };
97 static int rotation_list[] = { MM_VIDEO_INPUT_ROTATION_NONE };
98 static int visible_values[] = { 0, 1 }; /*0: off, 1:on*/
99 static int tag_orientation_values[] =
101 1, /*The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.*/
102 2, /*the 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.*/
103 3, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.*/
104 4, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.*/
105 5, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual top.*/
106 6, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual top.*/
107 7, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.*/
108 8, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.*/
111 if (hcamcorder == NULL) {
112 _mmcam_dbg_err("handle is NULL");
116 /* Create attribute constructor */
117 _mmcam_dbg_log("start");
119 /* alloc 'mmf_attrs_construct_info_t' */
120 attr_count = MM_CAM_ATTRIBUTE_NUM;
121 attrs_const_info = malloc(attr_count * sizeof(mmf_attrs_construct_info_t));
122 if (!attrs_const_info) {
123 _mmcam_dbg_err("Fail to alloc constructor.");
127 /* alloc default attribute info */
128 hcamcorder->cam_attrs_const_info = (mm_cam_attr_construct_info *)malloc(sizeof(mm_cam_attr_construct_info) * attr_count);
129 if (hcamcorder->cam_attrs_const_info == NULL) {
130 _mmcam_dbg_err("failed to alloc default attribute info");
131 free(attrs_const_info);
132 attrs_const_info = NULL;
136 /* basic attributes' info */
137 mm_cam_attr_construct_info temp_info[] = {
140 MM_CAM_MODE, /* ID */
142 MMF_VALUE_TYPE_INT, /* Type */
143 MM_ATTRS_FLAG_RW, /* Flag */
144 {(void*)MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Default value */
145 MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */
146 {.int_min = MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Validity val1 (min, *array,...) */
147 {.int_max = MM_CAMCORDER_MODE_AUDIO}, /* Validity val2 (max, count, ...) */
148 NULL, /* Runtime setting function of the attribute */
155 {(void*)MM_AUDIO_DEVICE_MIC},
156 MM_ATTRS_VALID_TYPE_INT_ARRAY,
162 MM_CAM_CAMERA_DEVICE_COUNT,
163 "camera-device-count",
166 {(void*)MM_VIDEO_DEVICE_NUM},
167 MM_ATTRS_VALID_TYPE_INT_RANGE,
168 {.int_min = MM_VIDEO_DEVICE_NONE},
169 {.int_max = MM_VIDEO_DEVICE_NUM},
173 MM_CAM_AUDIO_ENCODER,
177 {(void*)MM_AUDIO_CODEC_AMR},
178 MM_ATTRS_VALID_TYPE_INT_ARRAY,
184 MM_CAM_VIDEO_ENCODER,
188 {(void*)MM_VIDEO_CODEC_MPEG4},
189 MM_ATTRS_VALID_TYPE_INT_ARRAY,
195 MM_CAM_IMAGE_ENCODER,
199 {(void*)MM_IMAGE_CODEC_JPEG},
200 MM_ATTRS_VALID_TYPE_INT_ARRAY,
210 {(void*)MM_FILE_FORMAT_MP4},
211 MM_ATTRS_VALID_TYPE_INT_ARRAY,
217 MM_CAM_CAMERA_DEVICE_NAME,
218 "camera-device-name",
219 MMF_VALUE_TYPE_STRING,
222 MM_ATTRS_VALID_TYPE_NONE,
228 MM_CAM_AUDIO_SAMPLERATE,
233 MM_ATTRS_VALID_TYPE_INT_RANGE,
235 {.int_max = _MMCAMCORDER_MAX_INT},
243 {(void*)MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE},
244 MM_ATTRS_VALID_TYPE_INT_ARRAY,
251 MM_CAM_AUDIO_CHANNEL,
256 MM_ATTRS_VALID_TYPE_INT_RANGE,
264 MMF_VALUE_TYPE_DOUBLE,
267 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
269 {.double_max = 10.0},
270 _mmcamcorder_commit_audio_volume,
273 MM_CAM_AUDIO_INPUT_ROUTE,
277 {(void*)MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
278 MM_ATTRS_VALID_TYPE_INT_RANGE,
279 {.int_min = MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
280 {.int_max = MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY},
281 _mmcamcorder_commit_audio_input_route,
284 MM_CAM_FILTER_SCENE_MODE,
289 MM_ATTRS_VALID_TYPE_INT_ARRAY,
292 _mmcamcorder_commit_filter_scene_mode,
295 MM_CAM_FILTER_BRIGHTNESS,
300 MM_ATTRS_VALID_TYPE_INT_RANGE,
303 _mmcamcorder_commit_filter,
306 MM_CAM_FILTER_CONTRAST,
311 MM_ATTRS_VALID_TYPE_INT_RANGE,
314 _mmcamcorder_commit_filter,
322 MM_ATTRS_VALID_TYPE_INT_ARRAY,
325 _mmcamcorder_commit_filter,
328 MM_CAM_FILTER_COLOR_TONE,
333 MM_ATTRS_VALID_TYPE_INT_ARRAY,
336 _mmcamcorder_commit_filter,
339 MM_CAM_FILTER_SATURATION,
344 MM_ATTRS_VALID_TYPE_INT_RANGE,
347 _mmcamcorder_commit_filter,
355 MM_ATTRS_VALID_TYPE_INT_RANGE,
358 _mmcamcorder_commit_filter,
362 MM_CAM_FILTER_SHARPNESS,
367 MM_ATTRS_VALID_TYPE_INT_RANGE,
370 _mmcamcorder_commit_filter,
373 MM_CAM_CAMERA_FORMAT,
377 {(void*)MM_PIXEL_FORMAT_YUYV},
378 MM_ATTRS_VALID_TYPE_INT_ARRAY,
384 MM_CAM_CAMERA_RECORDING_MOTION_RATE,
385 "camera-recording-motion-rate",
386 MMF_VALUE_TYPE_DOUBLE,
389 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
391 {.double_max = _MMCAMCORDER_MAX_DOUBLE},
392 _mmcamcorder_commit_camera_recording_motion_rate,
400 MM_ATTRS_VALID_TYPE_INT_RANGE,
403 _mmcamcorder_commit_camera_fps,
410 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
411 MM_ATTRS_VALID_TYPE_INT_ARRAY,
414 _mmcamcorder_commit_camera_width,
417 MM_CAM_CAMERA_HEIGHT,
421 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
422 MM_ATTRS_VALID_TYPE_INT_ARRAY,
425 _mmcamcorder_commit_camera_height,
428 MM_CAM_CAMERA_DIGITAL_ZOOM,
429 "camera-digital-zoom",
433 MM_ATTRS_VALID_TYPE_INT_RANGE,
436 _mmcamcorder_commit_camera_zoom,
439 MM_CAM_CAMERA_OPTICAL_ZOOM,
440 "camera-optical-zoom",
444 MM_ATTRS_VALID_TYPE_INT_RANGE,
447 _mmcamcorder_commit_camera_zoom,
450 MM_CAM_CAMERA_FOCUS_MODE,
454 {(void*)MM_CAMCORDER_FOCUS_MODE_NONE},
455 MM_ATTRS_VALID_TYPE_INT_ARRAY,
458 _mmcamcorder_commit_camera_focus_mode,
461 MM_CAM_CAMERA_AF_SCAN_RANGE,
462 "camera-af-scan-range",
466 MM_ATTRS_VALID_TYPE_INT_ARRAY,
469 _mmcamcorder_commit_camera_af_scan_range,
473 MM_CAM_CAMERA_EXPOSURE_MODE,
474 "camera-exposure-mode",
478 MM_ATTRS_VALID_TYPE_INT_ARRAY,
481 _mmcamcorder_commit_camera_capture_mode,
484 MM_CAM_CAMERA_EXPOSURE_VALUE,
485 "camera-exposure-value",
489 MM_ATTRS_VALID_TYPE_INT_RANGE,
492 _mmcamcorder_commit_camera_capture_mode,
495 MM_CAM_CAMERA_F_NUMBER,
500 MM_ATTRS_VALID_TYPE_INT_ARRAY,
503 _mmcamcorder_commit_camera_capture_mode,
506 MM_CAM_CAMERA_SHUTTER_SPEED,
507 "camera-shutter-speed",
511 MM_ATTRS_VALID_TYPE_INT_ARRAY,
514 _mmcamcorder_commit_camera_capture_mode,
522 MM_ATTRS_VALID_TYPE_INT_ARRAY,
525 _mmcamcorder_commit_camera_capture_mode,
533 MM_ATTRS_VALID_TYPE_INT_ARRAY,
536 _mmcamcorder_commit_camera_wdr,
539 MM_CAM_CAMERA_ANTI_HANDSHAKE,
540 "camera-anti-handshake",
544 MM_ATTRS_VALID_TYPE_INT_ARRAY,
547 _mmcamcorder_commit_camera_anti_handshake,
550 MM_CAM_CAMERA_FPS_AUTO,
555 MM_ATTRS_VALID_TYPE_INT_RANGE,
561 MM_CAM_CAMERA_DELAY_ATTR_SETTING,
562 "camera-delay-attr-setting",
566 MM_ATTRS_VALID_TYPE_INT_RANGE,
572 MM_CAM_AUDIO_ENCODER_BITRATE,
573 "audio-encoder-bitrate",
577 MM_ATTRS_VALID_TYPE_INT_RANGE,
579 {.int_max = _MMCAMCORDER_MAX_INT},
584 MM_CAM_VIDEO_ENCODER_BITRATE,
585 "video-encoder-bitrate",
589 MM_ATTRS_VALID_TYPE_INT_RANGE,
591 {.int_max = _MMCAMCORDER_MAX_INT},
595 MM_CAM_IMAGE_ENCODER_QUALITY,
596 "image-encoder-quality",
600 MM_ATTRS_VALID_TYPE_INT_RANGE,
603 _mmcamcorder_commit_image_encoder_quality,
606 MM_CAM_CAPTURE_FORMAT,
610 {(void*)MM_PIXEL_FORMAT_ENCODED},
611 MM_ATTRS_VALID_TYPE_INT_ARRAY,
617 MM_CAM_CAPTURE_WIDTH,
622 MM_ATTRS_VALID_TYPE_INT_ARRAY,
625 _mmcamcorder_commit_capture_width ,
628 MM_CAM_CAPTURE_HEIGHT,
633 MM_ATTRS_VALID_TYPE_INT_ARRAY,
636 _mmcamcorder_commit_capture_height,
639 MM_CAM_CAPTURE_COUNT,
644 MM_ATTRS_VALID_TYPE_INT_RANGE,
647 _mmcamcorder_commit_capture_count,
650 MM_CAM_CAPTURE_INTERVAL,
655 MM_ATTRS_VALID_TYPE_INT_RANGE,
657 {.int_max = _MMCAMCORDER_MAX_INT},
661 MM_CAM_CAPTURE_BREAK_CONTINUOUS_SHOT,
662 "capture-break-cont-shot",
666 MM_ATTRS_VALID_TYPE_INT_RANGE,
669 _mmcamcorder_commit_capture_break_cont_shot,
672 MM_CAM_DISPLAY_HANDLE,
677 MM_ATTRS_VALID_TYPE_NONE,
680 _mmcamcorder_commit_display_handle,
683 MM_CAM_DISPLAY_DEVICE,
687 {(void*)MM_DISPLAY_DEVICE_MAINLCD},
688 MM_ATTRS_VALID_TYPE_INT_ARRAY,
695 MM_CAM_DISPLAY_SURFACE,
699 {(void*)MM_DISPLAY_SURFACE_OVERLAY},
700 MM_ATTRS_VALID_TYPE_INT_ARRAY,
706 MM_CAM_DISPLAY_RECT_X,
711 MM_ATTRS_VALID_TYPE_INT_RANGE,
713 {.int_max = _MMCAMCORDER_MAX_INT},
714 _mmcamcorder_commit_display_rect,
717 MM_CAM_DISPLAY_RECT_Y,
722 MM_ATTRS_VALID_TYPE_INT_RANGE,
724 {.int_max = _MMCAMCORDER_MAX_INT},
725 _mmcamcorder_commit_display_rect,
728 MM_CAM_DISPLAY_RECT_WIDTH,
729 "display-rect-width",
733 MM_ATTRS_VALID_TYPE_INT_RANGE,
735 {.int_max = _MMCAMCORDER_MAX_INT},
736 _mmcamcorder_commit_display_rect,
739 MM_CAM_DISPLAY_RECT_HEIGHT,
740 "display-rect-height",
744 MM_ATTRS_VALID_TYPE_INT_RANGE,
746 {.int_max = _MMCAMCORDER_MAX_INT},
747 _mmcamcorder_commit_display_rect,
750 MM_CAM_DISPLAY_SOURCE_X,
755 MM_ATTRS_VALID_TYPE_INT_RANGE,
757 {.int_max = _MMCAMCORDER_MAX_INT},
761 MM_CAM_DISPLAY_SOURCE_Y,
766 MM_ATTRS_VALID_TYPE_INT_RANGE,
768 {.int_max = _MMCAMCORDER_MAX_INT},
772 MM_CAM_DISPLAY_SOURCE_WIDTH,
777 MM_ATTRS_VALID_TYPE_INT_RANGE,
779 {.int_max = _MMCAMCORDER_MAX_INT},
783 MM_CAM_DISPLAY_SOURCE_HEIGHT,
784 "display-src-height",
788 MM_ATTRS_VALID_TYPE_INT_RANGE,
790 {.int_max = _MMCAMCORDER_MAX_INT},
794 MM_CAM_DISPLAY_ROTATION,
798 {(void*)MM_DISPLAY_ROTATION_NONE},
799 MM_ATTRS_VALID_TYPE_INT_RANGE,
800 {.int_min = MM_DISPLAY_ROTATION_NONE},
801 {.int_max = MM_DISPLAY_ROTATION_270},
802 _mmcamcorder_commit_display_rotation,
805 MM_CAM_DISPLAY_VISIBLE,
810 MM_ATTRS_VALID_TYPE_INT_ARRAY,
812 {ARRAY_SIZE(visible_values)},
813 _mmcamcorder_commit_display_visible,
816 MM_CAM_DISPLAY_SCALE,
821 MM_ATTRS_VALID_TYPE_INT_RANGE,
822 {.int_min = MM_DISPLAY_SCALE_DEFAULT},
823 {.int_max = MM_DISPLAY_SCALE_TRIPLE_LENGTH},
824 _mmcamcorder_commit_display_scale,
827 MM_CAM_DISPLAY_GEOMETRY_METHOD,
828 "display-geometry-method",
832 MM_ATTRS_VALID_TYPE_INT_RANGE,
833 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
834 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
835 _mmcamcorder_commit_display_geometry_method,
838 MM_CAM_TARGET_FILENAME,
840 MMF_VALUE_TYPE_STRING,
843 MM_ATTRS_VALID_TYPE_NONE,
846 _mmcamcorder_commit_target_filename,
849 MM_CAM_TARGET_MAX_SIZE,
854 MM_ATTRS_VALID_TYPE_INT_RANGE,
856 {.int_max = _MMCAMCORDER_MAX_INT},
860 MM_CAM_TARGET_TIME_LIMIT,
865 MM_ATTRS_VALID_TYPE_INT_RANGE,
867 {.int_max = _MMCAMCORDER_MAX_INT},
876 MM_ATTRS_VALID_TYPE_INT_RANGE,
882 MM_CAM_TAG_IMAGE_DESCRIPTION,
883 "tag-image-description",
884 MMF_VALUE_TYPE_STRING,
887 MM_ATTRS_VALID_TYPE_NONE,
893 MM_CAM_TAG_ORIENTATION,
898 MM_ATTRS_VALID_TYPE_INT_ARRAY,
899 {tag_orientation_values},
900 {ARRAY_SIZE(tag_orientation_values)},
906 MMF_VALUE_TYPE_STRING,
909 MM_ATTRS_VALID_TYPE_NONE,
918 MMF_VALUE_TYPE_DOUBLE,
921 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
922 {.double_min = -360.0},
923 {.double_max = 360.0},
927 MM_CAM_TAG_LONGITUDE,
929 MMF_VALUE_TYPE_DOUBLE,
932 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
933 {.double_min = -360.0},
934 {.double_max = 360.0},
940 MMF_VALUE_TYPE_DOUBLE,
943 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
944 {.double_min = -999999.0},
945 {.double_max = 999999.0},
949 MM_CAM_STROBE_CONTROL,
954 MM_ATTRS_VALID_TYPE_INT_RANGE,
957 _mmcamcorder_commit_strobe,
960 MM_CAM_STROBE_CAPABILITIES,
961 "strobe-capabilities",
965 MM_ATTRS_VALID_TYPE_INT_RANGE,
968 _mmcamcorder_commit_strobe,
976 MM_ATTRS_VALID_TYPE_INT_ARRAY,
979 _mmcamcorder_commit_strobe,
987 MM_ATTRS_VALID_TYPE_INT_ARRAY,
990 _mmcamcorder_commit_detect,
993 MM_CAM_DETECT_NUMBER,
998 MM_ATTRS_VALID_TYPE_INT_RANGE,
1001 _mmcamcorder_commit_detect,
1004 MM_CAM_DETECT_FOCUS_SELECT,
1005 "detect-focus-select",
1009 MM_ATTRS_VALID_TYPE_INT_RANGE,
1012 _mmcamcorder_commit_detect,
1015 MM_CAM_DETECT_SELECT_NUMBER,
1016 "detect-select-number",
1020 MM_ATTRS_VALID_TYPE_INT_RANGE,
1023 _mmcamcorder_commit_detect,
1027 MM_CAM_DETECT_STATUS,
1032 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1035 _mmcamcorder_commit_detect,
1038 MM_CAM_CAPTURE_ZERO_SYSTEMLAG,
1039 "capture-zero-systemlag",
1043 MM_ATTRS_VALID_TYPE_INT_RANGE,
1049 MM_CAM_CAMERA_AF_TOUCH_X,
1050 "camera-af-touch-x",
1054 MM_ATTRS_VALID_TYPE_INT_RANGE,
1056 {.int_max = _MMCAMCORDER_MAX_INT},
1057 _mmcamcorder_commit_camera_af_touch_area,
1060 MM_CAM_CAMERA_AF_TOUCH_Y,
1061 "camera-af-touch-y",
1065 MM_ATTRS_VALID_TYPE_INT_RANGE,
1067 {.int_max = _MMCAMCORDER_MAX_INT},
1068 _mmcamcorder_commit_camera_af_touch_area,
1071 MM_CAM_CAMERA_AF_TOUCH_WIDTH,
1072 "camera-af-touch-width",
1076 MM_ATTRS_VALID_TYPE_INT_RANGE,
1078 {.int_max = _MMCAMCORDER_MAX_INT},
1079 _mmcamcorder_commit_camera_af_touch_area,
1082 MM_CAM_CAMERA_AF_TOUCH_HEIGHT,
1083 "camera-af-touch-height",
1087 MM_ATTRS_VALID_TYPE_INT_RANGE,
1089 {.int_max = _MMCAMCORDER_MAX_INT},
1090 _mmcamcorder_commit_camera_af_touch_area,
1093 MM_CAM_CAMERA_FOCAL_LENGTH,
1094 "camera-focal-length",
1095 MMF_VALUE_TYPE_DOUBLE,
1098 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1099 {.double_min = 0.0},
1100 {.double_max = 1000.0},
1101 _mmcamcorder_commit_camera_capture_mode,
1104 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
1105 "recommend-preview-format-for-capture",
1108 {(void*)MM_PIXEL_FORMAT_YUYV},
1109 MM_ATTRS_VALID_TYPE_INT_RANGE,
1110 {.int_min = MM_PIXEL_FORMAT_NV12},
1111 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1115 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
1116 "recommend-preview-format-for-recording",
1119 {(void*)MM_PIXEL_FORMAT_NV12},
1120 MM_ATTRS_VALID_TYPE_INT_RANGE,
1121 {.int_min = MM_PIXEL_FORMAT_NV12},
1122 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1126 MM_CAM_TAG_GPS_ENABLE,
1131 MM_ATTRS_VALID_TYPE_INT_RANGE,
1138 MM_CAM_TAG_GPS_TIME_STAMP,
1139 "tag-gps-time-stamp",
1140 MMF_VALUE_TYPE_DOUBLE,
1143 MM_ATTRS_VALID_TYPE_NONE,
1149 MM_CAM_TAG_GPS_DATE_STAMP,
1150 "tag-gps-date-stamp",
1151 MMF_VALUE_TYPE_STRING,
1154 MM_ATTRS_VALID_TYPE_NONE,
1160 MM_CAM_TAG_GPS_PROCESSING_METHOD,
1161 "tag-gps-processing-method",
1162 MMF_VALUE_TYPE_STRING,
1165 MM_ATTRS_VALID_TYPE_NONE,
1171 MM_CAM_CAMERA_ROTATION,
1175 {(void*)MM_VIDEO_INPUT_ROTATION_NONE},
1176 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1178 {ARRAY_SIZE(rotation_list)},
1179 _mmcamcorder_commit_camera_rotate,
1182 MM_CAM_CAPTURED_SCREENNAIL,
1183 "captured-screennail",
1184 MMF_VALUE_TYPE_DATA,
1185 MM_ATTRS_FLAG_READABLE,
1187 MM_ATTRS_VALID_TYPE_NONE,
1193 MM_CAM_CAPTURE_SOUND_ENABLE,
1194 "capture-sound-enable",
1198 MM_ATTRS_VALID_TYPE_INT_RANGE,
1201 _mmcamcorder_commit_capture_sound_enable,
1204 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
1205 "recommend-display-rotation",
1208 {(void*)MM_DISPLAY_ROTATION_270},
1209 MM_ATTRS_VALID_TYPE_INT_RANGE,
1210 {.int_min = MM_DISPLAY_ROTATION_NONE},
1211 {.int_max = MM_DISPLAY_ROTATION_270},
1219 {(void*)MM_FLIP_NONE},
1220 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1222 {ARRAY_SIZE(flip_list)},
1223 _mmcamcorder_commit_camera_flip,
1226 MM_CAM_CAMERA_HDR_CAPTURE,
1227 "camera-hdr-capture",
1231 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1234 _mmcamcorder_commit_camera_hdr_capture,
1237 MM_CAM_DISPLAY_MODE,
1241 {(void*)MM_DISPLAY_MODE_DEFAULT},
1242 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1245 _mmcamcorder_commit_display_mode,
1249 MM_CAM_AUDIO_DISABLE,
1254 MM_ATTRS_VALID_TYPE_INT_RANGE,
1257 _mmcamcorder_commit_audio_disable,
1260 MM_CAM_RECOMMEND_CAMERA_WIDTH,
1261 "recommend-camera-width",
1264 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
1265 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1271 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
1272 "recommend-camera-height",
1275 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
1276 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1282 MM_CAM_CAPTURED_EXIF_RAW_DATA,
1283 "captured-exif-raw-data",
1284 MMF_VALUE_TYPE_DATA,
1285 MM_ATTRS_FLAG_READABLE,
1287 MM_ATTRS_VALID_TYPE_NONE,
1293 MM_CAM_DISPLAY_EVAS_SURFACE_SINK,
1294 "display-evas-surface-sink",
1295 MMF_VALUE_TYPE_STRING,
1296 MM_ATTRS_FLAG_READABLE,
1298 MM_ATTRS_VALID_TYPE_NONE,
1304 MM_CAM_DISPLAY_EVAS_DO_SCALING,
1305 "display-evas-do-scaling",
1309 MM_ATTRS_VALID_TYPE_INT_RANGE,
1312 _mmcamcorder_commit_display_evas_do_scaling,
1315 MM_CAM_CAMERA_FACING_DIRECTION,
1316 "camera-facing-direction",
1319 {(void*)MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1320 MM_ATTRS_VALID_TYPE_INT_RANGE,
1321 {.int_min = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1322 {.int_max = MM_CAMCORDER_CAMERA_FACING_DIRECTION_FRONT},
1326 MM_CAM_DISPLAY_FLIP,
1330 {(void*)MM_FLIP_NONE},
1331 MM_ATTRS_VALID_TYPE_INT_RANGE,
1332 {.int_min = MM_FLIP_NONE},
1333 {.int_max = MM_FLIP_BOTH},
1334 _mmcamcorder_commit_display_flip,
1337 MM_CAM_CAMERA_VIDEO_STABILIZATION,
1338 "camera-video-stabilization",
1341 {(void*)MM_CAMCORDER_VIDEO_STABILIZATION_OFF},
1342 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1345 _mmcamcorder_commit_camera_video_stabilization,
1348 MM_CAM_TAG_VIDEO_ORIENTATION,
1349 "tag-video-orientation",
1352 {(void*)MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1353 MM_ATTRS_VALID_TYPE_INT_RANGE,
1354 {.int_min = MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1355 {.int_max = MM_CAMCORDER_TAG_VIDEO_ORT_270},
1360 MM_CAM_CAMERA_PAN_MECHA,
1365 MM_ATTRS_VALID_TYPE_INT_RANGE,
1368 _mmcamcorder_commit_camera_pan,
1371 MM_CAM_CAMERA_PAN_ELEC,
1376 MM_ATTRS_VALID_TYPE_INT_RANGE,
1379 _mmcamcorder_commit_camera_pan,
1382 MM_CAM_CAMERA_TILT_MECHA,
1383 "camera-tilt-mecha",
1387 MM_ATTRS_VALID_TYPE_INT_RANGE,
1390 _mmcamcorder_commit_camera_tilt,
1393 MM_CAM_CAMERA_TILT_ELEC,
1398 MM_ATTRS_VALID_TYPE_INT_RANGE,
1401 _mmcamcorder_commit_camera_tilt,
1404 MM_CAM_CAMERA_PTZ_TYPE,
1409 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1412 _mmcamcorder_commit_camera_ptz_type,
1420 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1423 _mmcamcorder_commit_video_size,
1426 MM_CAM_VIDEO_HEIGHT,
1431 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1434 _mmcamcorder_commit_video_size,
1437 MM_CAM_SUPPORT_ZSL_CAPTURE,
1438 "support-zsl-capture",
1442 MM_ATTRS_VALID_TYPE_INT_RANGE,
1448 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
1449 "support-zero-copy-format",
1453 MM_ATTRS_VALID_TYPE_INT_RANGE,
1459 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
1460 "support-media-packet-preview-cb",
1464 MM_ATTRS_VALID_TYPE_INT_RANGE,
1470 MM_CAM_ENCODED_PREVIEW_BITRATE,
1471 "encoded-preview-bitrate",
1474 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE},
1475 MM_ATTRS_VALID_TYPE_INT_RANGE,
1477 {.int_max = _MMCAMCORDER_MAX_INT},
1478 _mmcamcorder_commit_encoded_preview_bitrate,
1481 MM_CAM_ENCODED_PREVIEW_GOP_INTERVAL,
1482 "encoded-preview-gop-interval",
1485 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL},
1486 MM_ATTRS_VALID_TYPE_INT_RANGE,
1488 {.int_max = _MMCAMCORDER_MAX_INT},
1489 _mmcamcorder_commit_encoded_preview_gop_interval,
1493 MM_CAM_RECORDER_TAG_ENABLE,
1494 "recorder-tag-enable",
1498 MM_ATTRS_VALID_TYPE_INT_RANGE,
1504 MM_CAM_DISPLAY_SOCKET_PATH,
1505 "display-socket-path",
1506 MMF_VALUE_TYPE_STRING,
1509 MM_ATTRS_VALID_TYPE_NONE,
1515 MM_CAM_PID_FOR_SOUND_FOCUS,
1516 "pid-for-sound-focus",
1520 MM_ATTRS_VALID_TYPE_INT_RANGE,
1522 {.int_max = _MMCAMCORDER_MAX_INT},
1523 _mmcamcorder_commit_pid_for_sound_focus,
1526 MM_CAM_ROOT_DIRECTORY,
1528 MMF_VALUE_TYPE_STRING,
1531 MM_ATTRS_VALID_TYPE_NONE,
1537 MM_CAM_SOUND_STREAM_TYPE,
1538 "sound-stream-type",
1539 MMF_VALUE_TYPE_STRING,
1542 MM_ATTRS_VALID_TYPE_NONE,
1548 MM_CAM_SOUND_STREAM_INDEX,
1549 "sound-stream-index",
1553 MM_ATTRS_VALID_TYPE_INT_RANGE,
1555 {.int_max = _MMCAMCORDER_MAX_INT},
1556 _mmcamcorder_commit_sound_stream_info,
1559 MM_CAM_DISPLAY_REUSE_HINT,
1560 "display-reuse-hint",
1564 MM_ATTRS_VALID_TYPE_INT_RANGE,
1570 MM_CAM_DISPLAY_REUSE_ELEMENT,
1571 "display-reuse-element",
1572 MMF_VALUE_TYPE_DATA,
1575 MM_ATTRS_VALID_TYPE_NONE,
1582 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1584 for (idx = 0 ; idx < attr_count ; idx++) {
1585 /* attribute order check. This should be same. */
1586 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1587 _mmcam_dbg_err("Please check attributes order. Is the idx same with enum val?");
1588 free(attrs_const_info);
1589 attrs_const_info = NULL;
1590 free(hcamcorder->cam_attrs_const_info);
1591 hcamcorder->cam_attrs_const_info = NULL;
1595 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1596 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1597 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1598 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1601 /* Camcorder Attributes */
1602 _mmcam_dbg_log("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1604 attrs = mmf_attrs_new_from_data("Camcorder_Attributes",
1607 _mmcamcorder_commit_camcorder_attrs,
1610 free(attrs_const_info);
1611 attrs_const_info = NULL;
1614 _mmcam_dbg_err("Fail to alloc attribute handle");
1615 free(hcamcorder->cam_attrs_const_info);
1616 hcamcorder->cam_attrs_const_info = NULL;
1620 __mmcamcorder_set_conf_to_valid_info(handle);
1622 for (idx = 0; idx < attr_count; idx++)
1624 /* _mmcam_dbg_log("Valid type [%s:%d, %d, %d]", cam_attrs_const_info[idx].name, cam_attrs_const_info[idx].validity_type
1625 , cam_attrs_const_info[idx].validity_value1, cam_attrs_const_info[idx].validity_value2);
1627 mmf_attrs_set_valid_type (attrs, idx, hcamcorder->cam_attrs_const_info[idx].validity_type);
1629 switch (hcamcorder->cam_attrs_const_info[idx].validity_type)
1631 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1632 if (hcamcorder->cam_attrs_const_info[idx].validity_value_1.int_array &&
1633 hcamcorder->cam_attrs_const_info[idx].validity_value_2.count > 0) {
1634 mmf_attrs_set_valid_array(attrs, idx,
1635 (const int *)(hcamcorder->cam_attrs_const_info[idx].validity_value_1.int_array),
1636 hcamcorder->cam_attrs_const_info[idx].validity_value_2.count,
1637 hcamcorder->cam_attrs_const_info[idx].default_value.value_int);
1640 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1641 mmf_attrs_set_valid_range(attrs, idx,
1642 hcamcorder->cam_attrs_const_info[idx].validity_value_1.int_min,
1643 hcamcorder->cam_attrs_const_info[idx].validity_value_2.int_max,
1644 hcamcorder->cam_attrs_const_info[idx].default_value.value_int);
1646 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1647 if (hcamcorder->cam_attrs_const_info[idx].validity_value_1.double_array &&
1648 hcamcorder->cam_attrs_const_info[idx].validity_value_2.count > 0) {
1649 mmf_attrs_set_valid_double_array(attrs, idx,
1650 (const double *)(hcamcorder->cam_attrs_const_info[idx].validity_value_1.double_array),
1651 hcamcorder->cam_attrs_const_info[idx].validity_value_2.count,
1652 hcamcorder->cam_attrs_const_info[idx].default_value.value_double);
1655 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1656 mmf_attrs_set_valid_double_range(attrs, idx,
1657 hcamcorder->cam_attrs_const_info[idx].validity_value_1.double_min,
1658 hcamcorder->cam_attrs_const_info[idx].validity_value_2.double_max,
1659 hcamcorder->cam_attrs_const_info[idx].default_value.value_double);
1661 case MM_ATTRS_VALID_TYPE_NONE:
1663 case MM_ATTRS_VALID_TYPE_INVALID:
1665 _mmcam_dbg_err("Valid type error.");
1670 __mmcamcorder_release_conf_valid_info(handle);
1677 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1679 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1681 if (hcamcorder == NULL) {
1682 _mmcam_dbg_err("handle is NULL");
1689 mmf_attrs_free(attrs);
1690 _mmcam_dbg_log("released attribute");
1693 if (hcamcorder->cam_attrs_const_info) {
1694 free(hcamcorder->cam_attrs_const_info);
1695 hcamcorder->cam_attrs_const_info = NULL;
1696 _mmcam_dbg_log("released attribute info");
1702 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1704 MMHandleType attrs = 0;
1705 int ret = MM_ERROR_NONE;
1707 mmf_return_val_if_fail( handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT );
1708 // mmf_return_val_if_fail( err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT );
1710 attrs = MMF_CAMCORDER_ATTRS(handle);
1711 mmf_return_val_if_fail( attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED );
1713 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1720 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1722 MMHandleType attrs = 0;
1723 int ret = MM_ERROR_NONE;
1724 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1726 mmf_return_val_if_fail( handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT );
1727 // mmf_return_val_if_fail( err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT );
1729 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1730 _mmcam_dbg_err("Another command is running.");
1731 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1734 attrs = MMF_CAMCORDER_ATTRS(handle);
1736 ret = __mmcamcorder_check_valid_pair( handle, err_attr_name, attribute_name, var_args );
1738 _mmcam_dbg_err("handle 0x%x, attrs is NULL, attr name [%s]", handle, attribute_name);
1739 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1742 if (ret == MM_ERROR_NONE) {
1743 hcamcorder->error_code = MM_ERROR_NONE;
1744 ret = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, var_args);
1747 _MMCAMCORDER_UNLOCK_CMD(handle);
1749 if (ret != MM_ERROR_NONE) {
1750 if (hcamcorder->error_code != MM_ERROR_NONE) {
1751 _mmcam_dbg_err("error_code is not NONE. origin 0x%x, modified 0x%x", ret, hcamcorder->error_code);
1752 ret = hcamcorder->error_code;
1753 hcamcorder->error_code = MM_ERROR_NONE;
1756 _mmcam_dbg_err("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1764 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1766 MMHandleType attrs = 0;
1767 MMAttrsInfo attrinfo;
1768 int ret = MM_ERROR_NONE;
1770 mmf_return_val_if_fail( handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT );
1771 mmf_return_val_if_fail( attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT );
1772 mmf_return_val_if_fail( info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT );
1774 attrs = MMF_CAMCORDER_ATTRS(handle);
1775 mmf_return_val_if_fail( attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1777 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1779 if (ret == MM_ERROR_NONE)
1781 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1782 info->type = attrinfo.type;
1783 info->flag = attrinfo.flag;
1784 info->validity_type= attrinfo.validity_type;
1786 switch(attrinfo.validity_type)
1788 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1789 info->int_array.array = attrinfo.int_array.array;
1790 info->int_array.count = attrinfo.int_array.count;
1791 info->int_array.def = attrinfo.int_array.dval;
1793 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1794 info->int_range.min = attrinfo.int_range.min;
1795 info->int_range.max = attrinfo.int_range.max;
1796 info->int_range.def = attrinfo.int_range.dval;
1798 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1799 info->double_array.array = attrinfo.double_array.array;
1800 info->double_array.count = attrinfo.double_array.count;
1801 info->double_array.def = attrinfo.double_array.dval;
1803 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1804 info->double_range.min = attrinfo.double_range.min;
1805 info->double_range.max = attrinfo.double_range.max;
1806 info->double_range.def = attrinfo.double_range.dval;
1808 case MM_ATTRS_VALID_TYPE_NONE:
1810 case MM_ATTRS_VALID_TYPE_INVALID:
1821 _mmcamcorder_commit_camcorder_attrs (int attr_idx, const char *attr_name, const mmf_value_t *value, void *commit_param)
1824 mmf_camcorder_t *hcamcorder = NULL;
1826 mmf_return_val_if_fail(commit_param, FALSE);
1827 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1828 mmf_return_val_if_fail(attr_name, FALSE);
1829 mmf_return_val_if_fail(value, FALSE);
1831 hcamcorder = MMF_CAMCORDER(commit_param);
1833 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit) {
1834 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1843 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1846 int total_count = 0;
1848 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1850 if (hcamcorder == NULL) {
1851 _mmcam_dbg_err("handle is NULL");
1852 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1856 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
1857 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
1858 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
1861 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
1862 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
1863 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
1866 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
1867 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
1868 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
1871 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
1872 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
1873 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
1875 return MM_ERROR_NONE;
1879 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
1881 int *allocated_memory = NULL;
1883 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1885 if (hcamcorder == NULL) {
1886 _mmcam_dbg_err("handle is NULL");
1887 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1890 _mmcam_dbg_log("START");
1892 /* Audio encoder info */
1893 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
1894 if (allocated_memory) {
1895 free(allocated_memory);
1896 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
1897 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
1900 /* Video encoder info */
1901 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
1902 if (allocated_memory) {
1903 free(allocated_memory);
1904 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
1905 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
1908 /* Image encoder info */
1909 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
1910 if (allocated_memory) {
1911 free(allocated_memory);
1912 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
1913 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
1916 /* File format info */
1917 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
1918 if (allocated_memory) {
1919 free(allocated_memory);
1920 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
1921 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
1924 _mmcam_dbg_log("DONE");
1926 return MM_ERROR_NONE;
1930 bool _mmcamcorder_commit_capture_width (MMHandleType handle, int attr_idx, const mmf_value_t *value)
1932 MMHandleType attr = 0;
1933 int current_state = MM_CAMCORDER_STATE_NONE;
1935 attr = MMF_CAMCORDER_ATTRS(handle);
1936 mmf_return_val_if_fail(attr, FALSE);
1938 /*_mmcam_dbg_log("(%d)", attr_idx);*/
1940 current_state = _mmcamcorder_get_state(handle);
1941 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
1942 int flags = MM_ATTRS_FLAG_NONE;
1943 int capture_width, capture_height;
1944 MMCamAttrsInfo info;
1946 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
1949 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
1950 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
1951 capture_width = value->value.i_val;
1953 /* Check whether they are valid pair */
1954 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
1959 _mmcam_dbg_log("Capture resolution can't be set.(state=%d)", current_state);
1965 bool _mmcamcorder_commit_capture_height (MMHandleType handle, int attr_idx, const mmf_value_t *value)
1967 int current_state = MM_CAMCORDER_STATE_NONE;
1969 current_state = _mmcamcorder_get_state(handle);
1971 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
1972 int capture_width, capture_height;
1974 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
1975 capture_height = value->value.i_val;
1977 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
1979 _mmcam_dbg_log("Capture resolution can't be set.(state=%d)", current_state);
1986 bool _mmcamcorder_commit_capture_break_cont_shot (MMHandleType handle, int attr_idx, const mmf_value_t *value)
1988 int current_state = _mmcamcorder_get_state( handle);
1989 int ivalue = value->value.i_val;
1991 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1992 _MMCamcorderSubContext *sc = NULL;
1993 GstCameraControl *control = NULL;
1994 type_element *VideosrcElement = NULL;
1996 const char *videosrc_name = NULL;
1998 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
1999 CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
2002 _mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
2004 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2008 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2009 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2010 _mmcam_dbg_warn("Can't cast Video source into camera control.");
2014 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2016 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2017 _mmcam_dbg_warn("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2019 _mmcam_dbg_warn("cast CAMERA_CONTROL failed");
2022 _mmcam_dbg_warn( "Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state );
2029 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2031 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2032 int current_state = MM_CAMCORDER_STATE_NONE;
2034 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2036 mmf_return_val_if_fail(hcamcorder, FALSE);
2038 current_state = _mmcamcorder_get_state(handle);
2039 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2041 _mmcam_dbg_log("current state %d, mode %d, set count %d",
2042 current_state, mode, value->value.i_val);
2044 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2045 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2048 _mmcam_dbg_err("Invalid mode[%d] or state[%d]", mode, current_state);
2054 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2056 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2058 mmf_return_val_if_fail(hcamcorder, FALSE);
2060 _mmcam_dbg_log("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2062 /* return error when disable shutter sound if policy is TRUE */
2063 if (!value->value.i_val &&
2064 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2065 _mmcam_dbg_err("not permitted DISABLE SHUTTER SOUND");
2068 _mmcam_dbg_log("set value [%d] success", value->value.i_val);
2074 bool _mmcamcorder_commit_audio_volume (MMHandleType handle, int attr_idx, const mmf_value_t *value)
2076 int current_state = MM_CAMCORDER_STATE_NONE;
2077 _MMCamcorderSubContext *sc = NULL;
2080 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2085 current_state = _mmcamcorder_get_state( handle);
2087 if ((current_state == MM_CAMCORDER_STATE_RECORDING)||(current_state == MM_CAMCORDER_STATE_PAUSED)) {
2088 double mslNewVal = 0;
2089 mslNewVal = value->value.d_val;
2091 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2092 if (mslNewVal == 0.0) {
2093 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2094 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2096 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2097 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2101 _mmcam_dbg_log("Commit : volume(%f)", mslNewVal);
2104 _mmcam_dbg_log("Commit : nothing to commit. status(%d)", current_state);
2112 bool _mmcamcorder_commit_camera_fps (MMHandleType handle, int attr_idx, const mmf_value_t *value)
2114 MMCamAttrsInfo fps_info;
2115 int resolution_width = 0;
2116 int resolution_height = 0;
2120 _mmcam_dbg_log("FPS(%d)", value->value.i_val);
2122 ret = mm_camcorder_get_attributes(handle, NULL,
2123 MMCAM_CAMERA_WIDTH, &resolution_width,
2124 MMCAM_CAMERA_HEIGHT, &resolution_height,
2127 if(ret != MM_ERROR_NONE) {
2128 _mmcam_dbg_err("FAILED : coult not get resolution values.");
2132 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2133 if (ret != MM_ERROR_NONE) {
2134 _mmcam_dbg_err("FAILED : coult not get FPS values by resolution.");
2138 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2139 if(value->value.i_val == fps_info.int_array.array[i]) {
2144 _mmcam_dbg_err("FAILED : %d is not supported FPS", value->value.i_val);
2149 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2151 int current_state = MM_CAMCORDER_STATE_NONE;
2152 _MMCamcorderSubContext *sc = NULL;
2154 mmf_return_val_if_fail(handle, FALSE);
2156 current_state = _mmcamcorder_get_state(handle);
2158 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2159 _mmcam_dbg_warn("invalid state %d", current_state);
2163 /* Verify recording motion rate */
2164 if (value->value.d_val > 0.0) {
2165 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2170 /* set is_slow flag */
2171 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE) {
2172 sc->is_modified_rate = TRUE;
2174 sc->is_modified_rate = FALSE;
2177 _mmcam_dbg_log("Set slow motion rate %lf", value->value.d_val);
2180 _mmcam_dbg_warn("Failed to set recording motion rate %lf", value->value.d_val);
2186 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2188 MMHandleType attr = 0;
2189 int current_state = MM_CAMCORDER_STATE_NONE;
2191 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2192 _MMCamcorderSubContext *sc = NULL;
2194 mmf_return_val_if_fail(hcamcorder, FALSE);
2196 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2201 attr = MMF_CAMCORDER_ATTRS(handle);
2202 mmf_return_val_if_fail(attr, FALSE);
2204 _mmcam_dbg_log("Width(%d)", value->value.i_val);
2206 current_state = _mmcamcorder_get_state(handle);
2208 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2209 _mmcam_dbg_log("Resolution can't be changed.(state=%d)", current_state);
2212 int flags = MM_ATTRS_FLAG_NONE;
2213 MMCamAttrsInfo info;
2214 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2217 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2218 int width = value->value.i_val;
2220 int preview_format = MM_PIXEL_FORMAT_NV12;
2221 int codec_type = MM_IMAGE_CODEC_JPEG;
2223 mm_camcorder_get_attributes(handle, NULL,
2224 MMCAM_CAMERA_HEIGHT, &height,
2225 MMCAM_CAMERA_FORMAT, &preview_format,
2226 MMCAM_IMAGE_ENCODER, &codec_type,
2229 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2230 if (hcamcorder->resolution_changed == FALSE) {
2231 _mmcam_dbg_log("no need to restart preview");
2235 hcamcorder->resolution_changed = FALSE;
2237 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2238 _mmcam_dbg_log("restart preview");
2240 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2241 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2243 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2245 /* check decoder recreation */
2246 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2247 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2248 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2252 /* get preview format */
2253 sc->info_image->preview_format = preview_format;
2254 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2255 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2257 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2258 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2260 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2263 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2265 _mmcam_dbg_err("currently locked for preview restart");
2269 /* get preview format */
2270 sc->info_image->preview_format = preview_format;
2271 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2272 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2283 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2286 int current_state = MM_CAMCORDER_STATE_NONE;
2287 MMHandleType attr = 0;
2288 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2289 _MMCamcorderSubContext *sc = NULL;
2291 mmf_return_val_if_fail(hcamcorder, FALSE);
2293 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2298 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2299 mmf_return_val_if_fail(attr, FALSE);
2301 _mmcam_dbg_log("Height(%d)", value->value.i_val);
2302 current_state = _mmcamcorder_get_state(handle);
2304 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2305 _mmcam_dbg_log("Resolution can't be changed.(state=%d)", current_state);
2309 int height = value->value.i_val;
2310 int preview_format = MM_PIXEL_FORMAT_NV12;
2311 int codec_type = MM_IMAGE_CODEC_JPEG;
2312 int video_stabilization = 0;
2314 mm_camcorder_get_attributes(handle, NULL,
2315 MMCAM_CAMERA_WIDTH, &width,
2316 MMCAM_CAMERA_FORMAT, &preview_format,
2317 MMCAM_IMAGE_ENCODER, &codec_type,
2318 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2321 sc->info_video->preview_width = width;
2322 sc->info_video->preview_height = height;
2324 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2325 if (hcamcorder->resolution_changed == FALSE) {
2326 _mmcam_dbg_log("no need to restart preview");
2330 hcamcorder->resolution_changed = FALSE;
2332 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2333 _mmcam_dbg_log("restart preview");
2335 _mmcam_dbg_log("set empty buffers");
2337 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2338 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2340 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2342 /* check decoder recreation */
2343 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2344 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2345 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2349 /* get preview format */
2350 sc->info_image->preview_format = preview_format;
2351 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2353 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2355 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2356 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2358 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2361 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2363 _mmcam_dbg_err("currently locked for preview restart");
2367 /* get preview format */
2368 sc->info_image->preview_format = preview_format;
2369 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2370 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2378 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2380 int current_state = MM_CAMCORDER_STATE_NONE;
2381 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2383 mmf_return_val_if_fail(hcamcorder, FALSE);
2385 current_state = _mmcamcorder_get_state(handle);
2386 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2387 _mmcam_dbg_err("Video Resolution can't be changed.(state=%d)", current_state);
2390 _mmcam_dbg_warn("Video Resolution %d [attr_idx %d] ",
2391 value->value.i_val, attr_idx);
2397 bool _mmcamcorder_commit_camera_zoom (MMHandleType handle, int attr_idx, const mmf_value_t *value)
2399 _MMCamcorderSubContext *sc = NULL;
2400 int current_state = MM_CAMCORDER_STATE_NONE;
2401 GstCameraControl *control = NULL;
2402 int zoom_level = value->value.i_val;
2405 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2410 _mmcam_dbg_log("(%d)", attr_idx);
2412 current_state = _mmcamcorder_get_state(handle);
2413 if (current_state < MM_CAMCORDER_STATE_READY) {
2414 _mmcam_dbg_log("will be applied when preview starts");
2416 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2417 _mmcam_dbg_warn("Can not set while CAPTURING");
2421 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM) {
2422 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2424 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2427 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2430 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2431 _mmcam_dbg_log("Can't cast Video source into camera control.");
2435 control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2436 if (control == NULL) {
2437 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2441 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2443 _mmcam_dbg_log("Succeed in operating Zoom[%d].", zoom_level);
2446 _mmcam_dbg_warn("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2449 _mmcam_dbg_log("pointer of video src is null");
2456 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2458 _MMCamcorderSubContext *sc = NULL;
2459 int current_state = MM_CAMCORDER_STATE_NONE;
2461 GstCameraControl *CameraControl = NULL;
2462 GstCameraControlChannel *CameraControlChannel = NULL;
2463 const GList *controls = NULL;
2464 const GList *item = NULL;
2466 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2467 mmf_return_val_if_fail(sc, TRUE);
2469 _mmcam_dbg_log("ptz type : %d", value->value.i_val);
2471 current_state = _mmcamcorder_get_state(handle);
2472 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2473 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2474 _mmcam_dbg_err("invalid state[%d]", current_state);
2478 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2479 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2480 _mmcam_dbg_log("Can't cast Video source into camera control.");
2484 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2485 if (CameraControl == NULL) {
2486 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2490 controls = gst_camera_control_list_channels(CameraControl);
2491 if (controls == NULL) {
2492 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2496 for (item = controls ; item && item->data ; item = item->next) {
2497 CameraControlChannel = item->data;
2498 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2499 if (!strcmp(CameraControlChannel->label, "ptz")) {
2500 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2501 _mmcam_dbg_warn("set ptz type %d done", value->value.i_val);
2504 _mmcam_dbg_err("failed to set ptz type %d", value->value.i_val);
2511 _mmcam_dbg_warn("failed to find tilt control channel");
2519 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2521 _MMCamcorderSubContext *sc = NULL;
2522 int current_state = MM_CAMCORDER_STATE_NONE;
2524 GstCameraControl *CameraControl = NULL;
2525 GstCameraControlChannel *CameraControlChannel = NULL;
2526 const GList *controls = NULL;
2527 const GList *item = NULL;
2529 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2530 mmf_return_val_if_fail(sc, TRUE);
2532 _mmcam_dbg_log("pan : %d", value->value.i_val);
2534 current_state = _mmcamcorder_get_state(handle);
2535 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2536 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2537 _mmcam_dbg_err("invalid state[%d]", current_state);
2541 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2542 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2543 _mmcam_dbg_log("Can't cast Video source into camera control.");
2547 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2548 if (CameraControl == NULL) {
2549 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2553 controls = gst_camera_control_list_channels(CameraControl);
2554 if (controls == NULL) {
2555 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2559 for (item = controls ; item && item->data ; item = item->next) {
2560 CameraControlChannel = item->data;
2561 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2562 if (!strcmp(CameraControlChannel->label, "pan")) {
2563 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2564 _mmcam_dbg_warn("set pan %d done", value->value.i_val);
2567 _mmcam_dbg_err("failed to set pan %d", value->value.i_val);
2574 _mmcam_dbg_warn("failed to find pan control channel");
2582 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2584 _MMCamcorderSubContext *sc = NULL;
2585 int current_state = MM_CAMCORDER_STATE_NONE;
2587 GstCameraControl *CameraControl = NULL;
2588 GstCameraControlChannel *CameraControlChannel = NULL;
2589 const GList *controls = NULL;
2590 const GList *item = NULL;
2592 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2593 mmf_return_val_if_fail(sc, TRUE);
2595 _mmcam_dbg_log("tilt : %d", value->value.i_val);
2597 current_state = _mmcamcorder_get_state(handle);
2598 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2599 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2600 _mmcam_dbg_err("invalid state[%d]", current_state);
2604 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2605 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2606 _mmcam_dbg_log("Can't cast Video source into camera control.");
2610 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2611 if (CameraControl == NULL) {
2612 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2616 controls = gst_camera_control_list_channels(CameraControl);
2617 if (controls == NULL) {
2618 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2622 for (item = controls ; item && item->data ; item = item->next) {
2623 CameraControlChannel = item->data;
2624 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2625 if (!strcmp(CameraControlChannel->label, "tilt")) {
2626 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2627 _mmcam_dbg_warn("set tilt %d done", value->value.i_val);
2630 _mmcam_dbg_err("failed to set tilt %d", value->value.i_val);
2637 _mmcam_dbg_warn("failed to find tilt control channel");
2645 bool _mmcamcorder_commit_camera_focus_mode (MMHandleType handle, int attr_idx, const mmf_value_t *value)
2647 MMHandleType attr = 0;
2648 int current_state = MM_CAMCORDER_STATE_NONE;
2649 _MMCamcorderSubContext *sc = NULL;
2650 GstCameraControl *control = NULL;
2652 int set_focus_mode = 0;
2653 int cur_focus_mode = 0;
2654 int cur_focus_range = 0;
2656 attr = MMF_CAMCORDER_ATTRS(handle);
2657 mmf_return_val_if_fail(attr, FALSE);
2659 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2663 _mmcam_dbg_log("Focus mode(%d)", value->value.i_val);
2665 /* check whether set or not */
2666 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2667 _mmcam_dbg_log("skip set value %d", value->value.i_val);
2671 current_state = _mmcamcorder_get_state(handle);
2672 if (current_state < MM_CAMCORDER_STATE_NULL) {
2673 _mmcam_dbg_log("Focus mode will be changed later.(state=%d)", current_state);
2677 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2678 int flags = MM_ATTRS_FLAG_NONE;
2679 MMCamAttrsInfo info;
2681 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2682 _mmcam_dbg_log("Can't cast Video source into camera control.");
2686 control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2687 if (control == NULL) {
2688 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2692 mslVal = value->value.i_val;
2693 set_focus_mode = _mmcamcorder_convert_msl_to_sensor( handle, attr_idx, mslVal );
2695 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2698 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2699 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2700 if (set_focus_mode != cur_focus_mode) {
2701 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2702 _mmcam_dbg_log("Succeed in setting AF mode[%d]", mslVal);
2705 _mmcam_dbg_warn("Failed to set AF mode[%d]", mslVal);
2708 _mmcam_dbg_log("No need to set AF mode. Current[%d]", mslVal);
2712 _mmcam_dbg_warn("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2716 _mmcam_dbg_log("pointer of video src is null");
2723 bool _mmcamcorder_commit_camera_af_scan_range (MMHandleType handle, int attr_idx, const mmf_value_t *value)
2725 _MMCamcorderSubContext *sc = NULL;
2726 GstCameraControl *control = NULL;
2727 int current_state = MM_CAMCORDER_STATE_NONE;
2730 int cur_focus_mode = 0;
2731 int cur_focus_range = 0;
2732 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2733 int converted_mode = 0;
2735 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2739 _mmcam_dbg_log("(%d)", attr_idx);
2741 /* check whether set or not */
2742 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2743 _mmcam_dbg_log("skip set value %d", value->value.i_val);
2747 mslVal = value->value.i_val;
2748 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2750 current_state = _mmcamcorder_get_state(handle);
2751 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2752 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
2756 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2757 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2758 _mmcam_dbg_log("Can't cast Video source into camera control.");
2762 control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2763 if (control == NULL) {
2764 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2768 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
2769 converted_mode = _mmcamcorder_convert_msl_to_sensor( handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode );
2771 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2772 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
2773 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
2774 //_mmcam_dbg_log("Succeed in setting AF mode[%d]", mslVal);
2777 _mmcam_dbg_warn("Failed to set AF mode[%d]", mslVal);
2780 //_mmcam_dbg_log("No need to set AF mode. Current[%d]", mslVal);
2784 _mmcam_dbg_warn("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2787 _mmcam_dbg_log("pointer of video src is null");
2794 bool _mmcamcorder_commit_camera_af_touch_area (MMHandleType handle, int attr_idx, const mmf_value_t *value)
2796 _MMCamcorderSubContext *sc = NULL;
2797 GstCameraControl *control = NULL;
2798 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
2799 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
2801 int current_state = MM_CAMCORDER_STATE_NONE;
2803 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2805 gboolean do_set = FALSE;
2807 MMCamAttrsInfo info_y;
2808 MMCamAttrsInfo info_w;
2809 MMCamAttrsInfo info_h;
2811 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2816 _mmcam_dbg_log("(%d)", attr_idx);
2818 current_state = _mmcamcorder_get_state(handle);
2819 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2820 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
2824 ret = mm_camcorder_get_attributes(handle, NULL,
2825 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2827 if (ret != MM_ERROR_NONE) {
2828 _mmcam_dbg_warn("Failed to get FOCUS MODE.[%x]", ret);
2832 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
2833 _mmcam_dbg_warn("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
2837 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2838 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2839 _mmcam_dbg_log("Can't cast Video source into camera control.");
2843 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
2844 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
2845 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
2848 case MM_CAM_CAMERA_AF_TOUCH_X:
2849 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
2850 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
2851 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
2852 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
2853 set_area.x = value->value.i_val;
2854 mm_camcorder_get_attributes(handle, NULL,
2855 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
2856 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
2857 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
2861 _mmcam_dbg_log("Just store AF area[x:%d]", value->value.i_val);
2865 case MM_CAM_CAMERA_AF_TOUCH_Y:
2866 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
2867 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
2868 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
2869 set_area.y = value->value.i_val;
2870 mm_camcorder_get_attributes(handle, NULL,
2871 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
2872 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
2873 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
2877 _mmcam_dbg_log( "Just store AF area[y:%d]", value->value.i_val );
2881 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
2882 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
2883 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
2884 set_area.width = value->value.i_val;
2885 mm_camcorder_get_attributes(handle, NULL,
2886 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
2887 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
2888 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
2892 _mmcam_dbg_log("Just store AF area[width:%d]", value->value.i_val);
2896 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
2897 set_area.height = value->value.i_val;
2898 mm_camcorder_get_attributes(handle, NULL,
2899 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
2900 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
2901 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
2910 _MMCamcorderVideoInfo *info = sc->info_video;
2913 _mmcam_dbg_err("video info is NULL");
2917 control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2918 if (control == NULL) {
2919 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2924 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
2925 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
2926 float ratio_width = 0.0;
2927 float ratio_height = 0.0;
2929 if (info->preview_width != 0 && info->preview_height != 0) {
2930 ratio_width = (float)info->video_width / (float)info->preview_width;
2931 ratio_height = (float)info->video_height / (float)info->preview_height;
2933 _mmcam_dbg_log("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
2934 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
2936 set_area.x = (int)((float)set_area.x * ratio_width);
2937 set_area.y = (int)((float)set_area.y * ratio_height);
2938 set_area.width = (int)((float)set_area.width * ratio_width);
2939 set_area.height = (int)((float)set_area.height * ratio_height);
2941 if (set_area.width <= 0) {
2944 if (set_area.height <= 0) {
2945 set_area.height = 1;
2948 _mmcam_dbg_log("converted area %d,%d,%dx%d",
2949 set_area.x, set_area.y, set_area.width, set_area.height);
2951 _mmcam_dbg_warn("invalid preview size %dx%d, skip AF area converting",
2952 info->preview_width, info->preview_height);
2956 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
2958 _mmcam_dbg_warn( "Failed to get AF area" );
2962 /* width and height are not supported now */
2963 if (get_area.x == set_area.x && get_area.y == set_area.y) {
2964 _mmcam_dbg_log("No need to set AF area[x,y:%d,%d]",
2965 get_area.x, get_area.y);
2969 ret = gst_camera_control_set_auto_focus_area(control, set_area);
2971 _mmcam_dbg_log("Succeed to set AF area[%d,%d,%dx%d]",
2972 set_area.x, set_area.y, set_area.width, set_area.height);
2975 _mmcam_dbg_warn("Failed to set AF area[%d,%d,%dx%d]",
2976 set_area.x, set_area.y, set_area.width, set_area.height);
2980 _mmcam_dbg_log("pointer of video src is null");
2987 bool _mmcamcorder_commit_camera_capture_mode (MMHandleType handle, int attr_idx, const mmf_value_t *value)
2989 GstCameraControl *control = NULL;
2990 int ivalue = value->value.i_val;
2991 int mslVal1 = 0, mslVal2 = 0;
2992 int newVal1 = 0, newVal2 = 0;
2993 int exposure_type = 0;
2994 int current_state = MM_CAMCORDER_STATE_NONE;
2995 _MMCamcorderSubContext *sc = NULL;
2997 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
2998 gboolean check_scene_mode = FALSE;
3000 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3004 /* check whether set or not */
3005 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3006 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3010 current_state = _mmcamcorder_get_state( handle);
3011 if (current_state < MM_CAMCORDER_STATE_READY) {
3015 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3016 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3017 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR( ivalue );
3018 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR( ivalue );
3019 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3020 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3021 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR( ivalue );
3022 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR( ivalue );
3023 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3024 exposure_type = GST_CAMERA_CONTROL_ISO;
3026 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3027 check_scene_mode = TRUE;
3028 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3029 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3031 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3032 check_scene_mode = TRUE;
3033 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3034 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3035 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR( ivalue );
3036 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR( ivalue );
3039 if (check_scene_mode) {
3040 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3041 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3042 _mmcam_dbg_warn("can not set [%d] when scene mode is NOT normal.", attr_idx);
3047 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3050 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3051 _mmcam_dbg_log("Can't cast Video source into camera control.");
3055 control = GST_CAMERA_CONTROL (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3056 if (control == NULL) {
3057 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3061 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3063 _mmcam_dbg_log("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2 );
3066 _mmcam_dbg_warn("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2 );
3069 _mmcam_dbg_log("pointer of video src is null");
3076 bool _mmcamcorder_commit_camera_wdr (MMHandleType handle, int attr_idx, const mmf_value_t *value)
3078 GstCameraControl *control = NULL;
3082 _MMCamcorderSubContext *sc = NULL;
3083 int current_state = MM_CAMCORDER_STATE_NONE;
3085 mmf_return_val_if_fail(handle && value, FALSE);
3087 /* check whether set or not */
3088 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3089 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3093 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3098 /* check current state */
3099 current_state = _mmcamcorder_get_state( handle);
3100 if (current_state < MM_CAMCORDER_STATE_READY) {
3101 _mmcam_dbg_log("will be applied when preview starts");
3103 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3104 _mmcam_dbg_warn("Can not set while CAPTURING");
3108 mslVal = value->value.i_val;
3109 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3111 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3112 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3113 _mmcam_dbg_log("Can't cast Video source into camera control.");
3117 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3118 if (control == NULL) {
3119 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3123 if (gst_camera_control_get_wdr(control, &cur_value)) {
3124 if (newVal != cur_value) {
3125 if (gst_camera_control_set_wdr(control, newVal)) {
3126 _mmcam_dbg_log( "Success - set wdr[%d]", mslVal );
3129 _mmcam_dbg_warn("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3132 _mmcam_dbg_log( "No need to set new WDR. Current[%d]", mslVal );
3136 _mmcam_dbg_warn( "Failed to get WDR." );
3139 _mmcam_dbg_log("pointer of video src is null");
3146 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3148 int current_state = MM_CAMCORDER_STATE_NONE;
3150 /* check whether set or not */
3151 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3152 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3156 current_state = _mmcamcorder_get_state(handle);
3157 if (current_state < MM_CAMCORDER_STATE_READY) {
3158 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3160 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3161 _mmcam_dbg_err("Invaild state (state %d)", current_state);
3165 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3169 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3171 int current_state = MM_CAMCORDER_STATE_NONE;
3173 current_state = _mmcamcorder_get_state(handle);
3174 if (current_state < MM_CAMCORDER_STATE_READY) {
3175 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3177 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3178 _mmcam_dbg_err("Invaild state (state %d)", current_state);
3182 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3186 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3188 int current_state = MM_CAMCORDER_STATE_NONE;
3190 _mmcam_dbg_log("rotate(%d)", value->value.i_val);
3192 current_state = _mmcamcorder_get_state(handle);
3194 if (current_state > MM_CAMCORDER_STATE_READY) {
3195 _mmcam_dbg_err("camera rotation setting failed.(state=%d)", current_state);
3198 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3203 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3205 int current_state = MM_CAMCORDER_STATE_NONE;
3207 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3208 _MMCamcorderSubContext *sc = NULL;
3210 mmf_return_val_if_fail(handle, FALSE);
3213 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3214 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3218 /* check current state */
3219 current_state = _mmcamcorder_get_state(handle);
3220 if (current_state < MM_CAMCORDER_STATE_READY) {
3221 _mmcam_dbg_log("NOT initialized. this will be applied later");
3225 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3227 _mmcam_dbg_log("Image encoder quality(%d)", value->value.i_val);
3229 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3230 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3233 _mmcam_dbg_err("invalid state %d", current_state);
3239 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3241 _MMCamcorderSubContext *sc = NULL;
3242 const char * filename = NULL;
3245 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3251 filename = mmf_value_get_string(value, &size);
3252 if (filename == NULL) {
3253 _mmcam_dbg_err("NULL filename");
3257 if (sc->info_video) {
3258 SAFE_G_FREE(sc->info_video->filename);
3259 sc->info_video->filename = g_strdup(filename);
3260 if (sc->info_video->filename == NULL) {
3261 _mmcam_dbg_err("failed to strdup filename [%s]", filename);
3266 if (sc->encode_element && sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst) {
3267 _mmcam_dbg_log("new file location set.[%s] filesink %p", filename, sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst);
3268 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "location", filename);
3269 _mmcam_dbg_log("new file location set.(%s)", filename);
3271 _mmcam_dbg_log("element is not created yet. [%s] will be set later...", filename);
3280 bool _mmcamcorder_commit_filter (MMHandleType handle, int attr_idx, const mmf_value_t *value)
3282 GstColorBalance *balance = NULL;
3283 GstColorBalanceChannel *Colorchannel = NULL;
3284 const GList *controls = NULL;
3285 const GList *item = NULL;
3288 int current_state = MM_CAMCORDER_STATE_NONE;
3289 const char *control_label = NULL;
3290 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3291 _MMCamcorderSubContext *sc = NULL;
3293 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3294 gboolean check_scene_mode = FALSE;
3296 if (hcamcorder == NULL) {
3297 _mmcam_dbg_log("handle is NULL");
3301 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3305 /* check whether set or not */
3306 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3307 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3311 current_state = _mmcamcorder_get_state(handle);
3312 if (current_state < MM_CAMCORDER_STATE_READY) {
3313 _mmcam_dbg_log("will be applied when preview starts");
3315 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3316 _mmcam_dbg_warn("Can not set while CAPTURING");
3320 if (value->type != MM_ATTRS_TYPE_INT) {
3321 _mmcam_dbg_warn("Mismatched value type (%d)", value->type);
3324 mslNewVal = value->value.i_val;
3328 case MM_CAM_FILTER_BRIGHTNESS:
3329 control_label = "brightness";
3330 check_scene_mode = TRUE;
3333 case MM_CAM_FILTER_CONTRAST:
3334 control_label = "contrast";
3337 case MM_CAM_FILTER_WB:
3338 control_label = "white balance";
3339 check_scene_mode = TRUE;
3342 case MM_CAM_FILTER_COLOR_TONE:
3343 control_label = "color tone";
3346 case MM_CAM_FILTER_SATURATION:
3347 control_label = "saturation";
3348 check_scene_mode = TRUE;
3351 case MM_CAM_FILTER_HUE:
3352 control_label = "hue";
3355 case MM_CAM_FILTER_SHARPNESS:
3356 control_label = "sharpness";
3357 check_scene_mode = TRUE;
3360 _mmcam_dbg_err("unknown attribute index %d", attr_idx);
3364 if (check_scene_mode) {
3365 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3366 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3367 _mmcam_dbg_warn("can not set %s when scene mode is NOT normal.", control_label);
3372 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslNewVal);
3373 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE) {
3377 /*_mmcam_dbg_log("label(%s): MSL(%d)->Sensor(%d)", control_label, mslNewVal, newVal);*/
3379 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3380 _mmcam_dbg_log("Can't cast Video source into color balance.");
3384 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3385 if (balance == NULL) {
3386 _mmcam_dbg_err("cast COLOR_BALANCE failed");
3390 controls = gst_color_balance_list_channels(balance);
3391 if (controls == NULL) {
3392 _mmcam_dbg_log("There is no list of colorbalance controls");
3396 for (item = controls ; item && item->data ; item = item->next) {
3397 Colorchannel = item->data;
3398 //_mmcam_dbg_log("Getting name of CID=(%s), input CID=(%s)", Colorchannel->label, control_label);
3400 if (!strcmp(Colorchannel->label, control_label)) {
3401 gst_color_balance_set_value (balance, Colorchannel, newVal);
3402 _mmcam_dbg_log("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslNewVal, newVal);
3408 _mmcam_dbg_err("failed to find color channel item");
3416 bool _mmcamcorder_commit_filter_scene_mode (MMHandleType handle, int attr_idx, const mmf_value_t *value)
3418 GstCameraControl *control = NULL;
3419 int mslVal = value->value.i_val;
3420 int newVal = _mmcamcorder_convert_msl_to_sensor( handle, MM_CAM_FILTER_SCENE_MODE, mslVal );
3421 _MMCamcorderSubContext *sc = NULL;
3422 int current_state = MM_CAMCORDER_STATE_NONE;
3424 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3428 /* check whether set or not */
3429 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3430 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3434 current_state = _mmcamcorder_get_state(handle);
3435 if (current_state < MM_CAMCORDER_STATE_READY) {
3436 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3440 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3443 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3444 _mmcam_dbg_log("Can't cast Video source into camera control.");
3448 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3449 if (control == NULL) {
3450 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3454 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3456 _mmcam_dbg_log("Succeed in setting program mode[%d].", mslVal);
3458 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3462 , MM_CAM_FILTER_BRIGHTNESS
3464 , MM_CAM_FILTER_SATURATION
3465 , MM_CAM_FILTER_SHARPNESS
3466 , MM_CAM_FILTER_COLOR_TONE
3467 , MM_CAM_CAMERA_EXPOSURE_MODE
3469 mmf_attrs_t *attr = (mmf_attrs_t *)MMF_CAMCORDER_ATTRS(handle);
3471 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3472 if (__mmcamcorder_attrs_is_supported((MMHandleType)attr, attr_idxs[i])) {
3473 mmf_attribute_set_modified(&(attr->items[attr_idxs[i]]));
3480 _mmcam_dbg_log( "Failed to set program mode[%d].", mslVal );
3483 _mmcam_dbg_warn("pointer of video src is null");
3490 bool _mmcamcorder_commit_filter_flip (MMHandleType handle, int attr_idx, const mmf_value_t *value)
3492 _mmcam_dbg_warn("Filter Flip(%d)", value->value.i_val);
3497 bool _mmcamcorder_commit_audio_input_route (MMHandleType handle, int attr_idx, const mmf_value_t *value)
3499 _mmcam_dbg_log("Commit : Do nothing. this attr will be removed soon.");
3505 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3507 int current_state = MM_CAMCORDER_STATE_NONE;
3509 current_state = _mmcamcorder_get_state(handle);
3510 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3511 _mmcam_dbg_warn("Can NOT Disable AUDIO. invalid state %d", current_state);
3514 _mmcam_dbg_log("Disable AUDIO when Recording");
3520 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3522 int current_state = MM_CAMCORDER_STATE_NONE;
3523 const char *videosink_name = NULL;
3524 void *p_handle = NULL;
3526 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3527 _MMCamcorderSubContext *sc = NULL;
3529 mmf_return_val_if_fail(handle, FALSE);
3532 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3533 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3537 /* check current state */
3538 current_state = _mmcamcorder_get_state(handle);
3539 if (current_state < MM_CAMCORDER_STATE_READY) {
3540 _mmcam_dbg_log("NOT initialized. this will be applied later");
3544 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3546 p_handle = value->value.p_val;
3548 /* get videosink name */
3549 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3550 if (videosink_name == NULL) {
3551 _mmcam_dbg_err("Please check videosink element in configuration file");
3555 _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name);
3557 if (!strcmp(videosink_name, "xvimagesink") ||
3558 !strcmp(videosink_name, "ximagesink")) {
3559 _mmcam_dbg_log("Commit : Set XID[%x]", *(int*)(p_handle));
3560 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int*)(p_handle));
3561 } else if (!strcmp(videosink_name, "evasimagesink") ||
3562 !strcmp(videosink_name, "evaspixmapsink")) {
3563 _mmcam_dbg_log("Commit : Set evas object [%p]", p_handle);
3564 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", p_handle);
3565 } else if (!strcmp(videosink_name, "waylandsink")) {
3566 MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)p_handle;
3568 _mmcam_dbg_log("wayland global surface id : %d", wl_info->global_surface_id);
3570 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)wl_info->global_surface_id);
3571 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3572 wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
3574 _mmcam_dbg_warn("Commit : Nothing to commit with this element[%s]", videosink_name);
3578 _mmcam_dbg_warn("Display handle is NULL");
3586 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3588 int current_state = MM_CAMCORDER_STATE_NONE;
3589 const char *videosink_name = NULL;
3591 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3592 _MMCamcorderSubContext *sc = NULL;
3594 mmf_return_val_if_fail(handle, FALSE);
3597 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3598 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3602 /* check current state */
3603 current_state = _mmcamcorder_get_state(handle);
3604 if (current_state < MM_CAMCORDER_STATE_READY) {
3605 _mmcam_dbg_log("NOT initialized. this will be applied later");
3609 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3611 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3612 if (videosink_name == NULL) {
3613 _mmcam_dbg_err("Please check videosink element in configuration file");
3617 _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name);
3619 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink")) {
3620 _mmcam_dbg_log("Commit : display mode [%d]", value->value.i_val);
3621 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3624 _mmcam_dbg_warn("Commit : This element [%s] does not support display mode", videosink_name);
3630 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3632 int current_state = MM_CAMCORDER_STATE_NONE;
3634 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3636 mmf_return_val_if_fail(handle, FALSE);
3639 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3640 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3644 /* check current state */
3645 current_state = _mmcamcorder_get_state(handle);
3646 if (current_state < MM_CAMCORDER_STATE_READY) {
3647 _mmcam_dbg_log("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3651 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3655 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3657 int current_state = MM_CAMCORDER_STATE_NONE;
3659 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3661 mmf_return_val_if_fail(handle, FALSE);
3664 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3665 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3669 /* check current state */
3670 current_state = _mmcamcorder_get_state(handle);
3671 if (current_state < MM_CAMCORDER_STATE_READY) {
3672 _mmcam_dbg_log("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3676 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3680 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3682 int current_state = MM_CAMCORDER_STATE_NONE;
3683 const char *videosink_name = NULL;
3685 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3686 _MMCamcorderSubContext *sc = NULL;
3688 mmf_return_val_if_fail(handle, FALSE);
3691 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3692 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3696 /* check current state */
3697 current_state = _mmcamcorder_get_state(handle);
3698 if (current_state < MM_CAMCORDER_STATE_READY) {
3699 _mmcam_dbg_log("NOT initialized. this will be applied later");
3703 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3705 /* Get videosink name */
3706 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3707 if (videosink_name == NULL) {
3708 _mmcam_dbg_err("Please check videosink element in configuration file");
3712 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink") ||
3713 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
3714 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
3715 _mmcam_dbg_log("Set visible [%d] done.", value->value.i_val);
3718 _mmcam_dbg_warn("videosink[%s] does not support VISIBLE.", videosink_name);
3724 bool _mmcamcorder_commit_display_geometry_method (MMHandleType handle, int attr_idx, const mmf_value_t *value)
3727 int current_state = MM_CAMCORDER_STATE_NONE;
3728 const char *videosink_name = NULL;
3730 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3731 _MMCamcorderSubContext *sc = NULL;
3733 mmf_return_val_if_fail(handle, FALSE);
3736 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3737 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3741 /* check current state */
3742 current_state = _mmcamcorder_get_state(handle);
3743 if (current_state < MM_CAMCORDER_STATE_READY) {
3744 _mmcam_dbg_log("NOT initialized. this will be applied later");
3748 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3750 /* Get videosink name */
3751 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3752 if (videosink_name == NULL) {
3753 _mmcam_dbg_err("Please check videosink element in configuration file");
3757 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink") ||
3758 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
3759 method = value->value.i_val;
3760 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
3763 _mmcam_dbg_warn("videosink[%s] does not support geometry method.", videosink_name);
3769 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3771 int current_state = MM_CAMCORDER_STATE_NONE;
3773 int ret = MM_ERROR_NONE;
3774 const char *videosink_name = NULL;
3776 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3777 _MMCamcorderSubContext *sc = NULL;
3779 mmf_return_val_if_fail(handle, FALSE);
3782 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3783 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3787 /* check current state */
3788 current_state = _mmcamcorder_get_state(handle);
3789 if (current_state < MM_CAMCORDER_STATE_READY) {
3790 _mmcam_dbg_log("NOT initialized. this will be applied later");
3794 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3796 /* check current method */
3797 mm_camcorder_get_attributes(handle, NULL,
3798 MMCAM_DISPLAY_GEOMETRY_METHOD, &method,
3800 if (method != MM_DISPLAY_METHOD_CUSTOM_ROI) {
3801 _mmcam_dbg_log("current method[%d] is not supported rect", method);
3805 /* Get videosink name */
3806 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3807 if (videosink_name == NULL) {
3808 _mmcam_dbg_err("Please check videosink element in configuration file");
3812 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink") ||
3813 !strcmp(videosink_name, "evaspixmapsink")) {
3817 int rect_height = 0;
3818 int flags = MM_ATTRS_FLAG_NONE;
3819 MMCamAttrsInfo info;
3821 mm_camcorder_get_attributes(handle, NULL,
3822 MMCAM_DISPLAY_RECT_X, &rect_x,
3823 MMCAM_DISPLAY_RECT_Y, &rect_y,
3824 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
3825 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
3828 case MM_CAM_DISPLAY_RECT_X:
3829 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
3831 memset(&info, 0x00, sizeof(info));
3832 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
3834 memset(&info, 0x00, sizeof(info));
3835 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
3838 rect_x = value->value.i_val;
3840 case MM_CAM_DISPLAY_RECT_Y:
3841 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
3843 memset(&info, 0x00, sizeof(info));
3844 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
3847 rect_y = value->value.i_val;
3849 case MM_CAM_DISPLAY_RECT_WIDTH:
3850 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
3853 rect_width = value->value.i_val;
3855 case MM_CAM_DISPLAY_RECT_HEIGHT:
3856 rect_height = value->value.i_val;
3859 _mmcam_dbg_err("Wrong attr_idx!");
3863 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
3864 _mmcam_dbg_log("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
3866 if (!strcmp(videosink_name, "waylandsink")) {
3867 ret = gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3868 rect_x, rect_y, rect_width, rect_height);
3870 _mmcam_dbg_err("FAILED : could not set render rectangle.");
3874 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
3875 "dst-roi-x", rect_x,
3876 "dst-roi-y", rect_y,
3877 "dst-roi-w", rect_width,
3878 "dst-roi-h", rect_height,
3885 _mmcam_dbg_warn("videosink[%s] does not support display rect.", videosink_name);
3891 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3894 int current_state = MM_CAMCORDER_STATE_NONE;
3895 const char *videosink_name = NULL;
3896 GstElement *vs_element = NULL;
3898 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3899 _MMCamcorderSubContext *sc = NULL;
3901 mmf_return_val_if_fail(handle, FALSE);
3904 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3905 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3909 /* check current state */
3910 current_state = _mmcamcorder_get_state(handle);
3911 if (current_state < MM_CAMCORDER_STATE_READY) {
3912 _mmcam_dbg_log("NOT initialized. this will be applied later");
3916 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3918 /* Get videosink name */
3919 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3920 if (videosink_name == NULL) {
3921 _mmcam_dbg_err("Please check videosink element in configuration file");
3925 zoom = value->value.i_val;
3926 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink")) {
3927 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
3929 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
3930 _mmcam_dbg_log("Set display zoom to %d", zoom + 1);
3934 _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name);
3940 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3942 int current_state = MM_CAMCORDER_STATE_NONE;
3944 const char *videosink_name = NULL;
3946 mmf_camcorder_t *hcamcorder= MMF_CAMCORDER( handle);
3947 _MMCamcorderSubContext *sc = NULL;
3949 mmf_return_val_if_fail(handle, FALSE);
3952 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3953 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3957 /* check current state */
3958 current_state = _mmcamcorder_get_state(handle);
3959 if (current_state < MM_CAMCORDER_STATE_READY) {
3960 _mmcam_dbg_log("NOT initialized. this will be applied later");
3964 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3966 do_scaling = value->value.i_val;
3968 /* Get videosink name */
3969 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3970 if (videosink_name == NULL) {
3971 _mmcam_dbg_err("Please check videosink element in configuration file");
3975 if (!strcmp(videosink_name, "evaspixmapsink")) {
3976 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
3977 _mmcam_dbg_log("Set origin-size to %d", !(value->value.i_val));
3980 _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name);
3986 bool _mmcamcorder_commit_strobe (MMHandleType handle, int attr_idx, const mmf_value_t *value)
3989 _MMCamcorderSubContext *sc = NULL;
3990 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3991 int strobe_type, mslVal, newVal, cur_value;
3992 int current_state = MM_CAMCORDER_STATE_NONE;
3994 if (hcamcorder == NULL) {
3995 _mmcam_dbg_err("NULL handle");
3999 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4003 /*_mmcam_dbg_log( "Commit : strobe attribute(%d)", attr_idx );*/
4005 mslVal = value->value.i_val;
4007 /* check flash state */
4008 if (attr_idx == MM_CAM_STROBE_MODE) {
4009 int flash_brightness = 0;
4011 /* get current flash brightness */
4012 if (_mmcamcorder_get_device_flash_brightness(hcamcorder->gdbus_conn, &flash_brightness) != MM_ERROR_NONE) {
4013 _mmcam_dbg_err("_mmcamcorder_get_device_flash_brightness failed");
4014 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4018 _mmcam_dbg_log("flash brightness %d", flash_brightness);
4020 if (flash_brightness > 0 &&
4021 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4022 /* other module already turned on flash */
4023 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4024 _mmcam_dbg_err("other module already turned on flash. avoid to set flash mode here.");
4027 _mmcam_dbg_log("keep going");
4032 current_state = _mmcamcorder_get_state(handle);
4033 if (current_state < MM_CAMCORDER_STATE_READY) {
4034 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
4036 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4037 _mmcam_dbg_warn("invalid state[capturing]");
4038 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4043 case MM_CAM_STROBE_CONTROL:
4044 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4045 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4047 case MM_CAM_STROBE_CAPABILITIES:
4048 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4051 case MM_CAM_STROBE_MODE:
4052 /* check whether set or not */
4053 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4054 _mmcam_dbg_log("skip set value %d", mslVal);
4058 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4059 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4062 _mmcam_dbg_err("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4066 GstCameraControl *control = NULL;
4067 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4068 _mmcam_dbg_err("Can't cast Video source into camera control.");
4071 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4072 if (control == NULL) {
4073 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
4077 if (gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4078 if (newVal != cur_value) {
4079 if (gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4080 _mmcam_dbg_log("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4083 _mmcam_dbg_warn("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4087 _mmcam_dbg_log("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4091 _mmcam_dbg_warn("Failed to get strobe. Type[%d]", strobe_type);
4100 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4103 int current_state = MM_CAMCORDER_STATE_NONE;
4105 if ((void *)handle == NULL) {
4106 _mmcam_dbg_warn("handle is NULL");
4110 _mmcam_dbg_log("Commit : flip %d", value->value.i_val);
4113 current_state = _mmcamcorder_get_state(handle);
4114 if (current_state > MM_CAMCORDER_STATE_READY) {
4115 _mmcam_dbg_err("Can not set camera FLIP horizontal at state %d", current_state);
4117 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4118 _mmcam_dbg_log("Pipeline is not created yet. This will be set when create pipeline.");
4122 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4124 _mmcam_dbg_log("ret %d", ret);
4130 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4132 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4133 int current_state = MM_CAMCORDER_STATE_NONE;
4134 _MMCamcorderSubContext *sc = NULL;
4136 if ((void *)handle == NULL) {
4137 _mmcam_dbg_warn("handle is NULL");
4141 /*_mmcam_dbg_log("Commit : HDR Capture %d", value->value.i_val);*/
4143 /* check whether set or not */
4144 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4145 _mmcam_dbg_log("skip set value %d", value->value.i_val);
4150 current_state = _mmcamcorder_get_state(handle);
4151 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4152 _mmcam_dbg_err("can NOT set HDR capture at state %d", current_state);
4156 if (current_state >= MM_CAMCORDER_STATE_READY) {
4157 int current_value = 0;
4159 set_hdr_mode = value->value.i_val;
4160 mm_camcorder_get_attributes(handle, NULL,
4161 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4164 if (set_hdr_mode == current_value) {
4165 _mmcam_dbg_log("same HDR value : %d, do nothing", set_hdr_mode);
4169 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4171 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4172 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4173 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4175 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4177 /* check decoder recreation */
4178 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4179 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4183 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4184 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4187 set_hdr_mode = value->value.i_val;
4188 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4189 sc->info_image->hdr_capture_mode = set_hdr_mode;
4190 _mmcam_dbg_log("set HDR mode : %d", set_hdr_mode);
4192 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4193 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4196 _mmcam_dbg_err("sc is NULL. can not set HDR capture");
4205 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4208 _MMCamcorderSubContext *sc = NULL;
4209 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4211 int current_value = 0;
4212 int current_state = MM_CAMCORDER_STATE_NONE;
4213 GstCameraControl *control = NULL;
4215 if ((void *)handle == NULL) {
4216 _mmcam_dbg_warn("handle is NULL");
4220 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4225 /*_mmcam_dbg_log("Commit : detect attribute(%d)", attr_idx);*/
4228 current_state = _mmcamcorder_get_state( handle);
4229 if (current_state < MM_CAMCORDER_STATE_READY) {
4230 _mmcam_dbg_log("will be applied when preview starts");
4234 set_value = value->value.i_val;
4237 case MM_CAM_DETECT_MODE:
4238 /* check whether set or not */
4239 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4240 _mmcam_dbg_log("skip set value %d", set_value);
4244 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4246 case MM_CAM_DETECT_NUMBER:
4247 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4249 case MM_CAM_DETECT_FOCUS_SELECT:
4250 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4252 case MM_CAM_DETECT_SELECT_NUMBER:
4253 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4255 case MM_CAM_DETECT_STATUS:
4256 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4259 _mmcam_dbg_err("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4263 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4264 _mmcam_dbg_err("Can't cast Video source into camera control.");
4267 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4268 if (control == NULL) {
4269 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
4273 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4274 if (current_value == set_value) {
4275 _mmcam_dbg_log("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4278 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4279 _mmcam_dbg_warn("Set detect failed. Type[%d],value[%d]",
4280 detect_type, set_value);
4283 _mmcam_dbg_log("Set detect success. Type[%d],value[%d]",
4284 detect_type, set_value);
4289 _mmcam_dbg_warn("Get detect failed. Type[%d]", detect_type);
4298 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4300 int current_state = MM_CAMCORDER_STATE_NONE;
4301 int preview_format = MM_PIXEL_FORMAT_NV12;
4303 if ((void *)handle == NULL) {
4304 _mmcam_dbg_warn("handle is NULL");
4308 _mmcam_dbg_log("Commit : encoded preview bitrate - %d", value->value.i_val);
4310 /* check preview format */
4311 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4312 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4313 _mmcam_dbg_err("current preview format[%d] is not encoded format", preview_format);
4318 current_state = _mmcamcorder_get_state(handle);
4319 if (current_state < MM_CAMCORDER_STATE_READY) {
4320 _mmcam_dbg_log("will be applied when preview starts");
4324 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4328 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4330 int current_state = MM_CAMCORDER_STATE_NONE;
4331 int preview_format = MM_PIXEL_FORMAT_NV12;
4333 if ((void *)handle == NULL) {
4334 _mmcam_dbg_warn("handle is NULL");
4338 _mmcam_dbg_log("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4340 /* check preview format */
4341 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4342 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4343 _mmcam_dbg_err("current preview format[%d] is not encoded format", preview_format);
4348 current_state = _mmcamcorder_get_state(handle);
4349 if (current_state < MM_CAMCORDER_STATE_READY) {
4350 _mmcam_dbg_log("will be applied when preview starts");
4354 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4358 bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4361 int current_state = MM_CAMCORDER_STATE_NONE;
4362 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4364 if (hcamcorder == NULL) {
4365 _mmcam_dbg_warn("handle is NULL");
4370 current_state = _mmcamcorder_get_state( handle);
4371 if (current_state > MM_CAMCORDER_STATE_NULL) {
4372 _mmcam_dbg_log("invalid state %d", current_state);
4376 new_pid = value->value.i_val;
4378 _mmcam_dbg_log("Commit : pid %d, current sound_focus_register %d, sound_focus_id %d",
4379 new_pid, hcamcorder->sound_focus_register, hcamcorder->sound_focus_id);
4381 /* unregister sound focus before set new one */
4382 if (hcamcorder->sound_focus_register && hcamcorder->sound_focus_id > 0) {
4383 if (MM_ERROR_NONE != mm_sound_unregister_focus(hcamcorder->sound_focus_id)) {
4384 _mmcam_dbg_err("mm_sound_unregister_focus[id %d] failed", hcamcorder->sound_focus_id);
4386 _mmcam_dbg_log("mm_sound_unregister_focus[id %d] done", hcamcorder->sound_focus_id);
4389 _mmcam_dbg_log("no need to unregister sound focus");
4392 /* register sound focus */
4393 if (hcamcorder->sound_focus_register) {
4394 hcamcorder->sound_focus_id = 0;
4395 if (MM_ERROR_NONE != mm_sound_focus_get_id(&hcamcorder->sound_focus_id)) {
4396 _mmcam_dbg_err("mm_sound_focus_get_uniq failed");
4397 hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED;
4401 if (MM_ERROR_NONE != mm_sound_register_focus_for_session(hcamcorder->sound_focus_id,
4404 _mmcamcorder_sound_focus_cb,
4406 _mmcam_dbg_err("mm_sound_register_focus failed");
4407 hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED;
4411 _mmcam_dbg_log("mm_sound_register_focus done - id %d, session type %d, flags 0x%x",
4412 hcamcorder->sound_focus_id, hcamcorder->session_type, hcamcorder->session_flags);
4414 _mmcam_dbg_log("no need to register sound focus");
4421 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4423 char *stream_type = NULL;
4424 int stream_type_len = 0;
4425 _MMCamcorderSubContext *sc = NULL;
4427 if ((void *)handle == NULL) {
4428 _mmcam_dbg_warn("handle is NULL");
4432 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4433 if (!sc || !sc->encode_element ||
4434 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4435 _mmcam_dbg_log("audiosrc element is not initialized, it will be set later");
4439 mm_camcorder_get_attributes(handle, NULL,
4440 MMCAM_SOUND_STREAM_TYPE, &stream_type, &stream_type_len,
4443 if (stream_type == NULL) {
4444 _mmcam_dbg_err("stream type is not set");
4448 _mmcam_dbg_log("Commit : sound stream info - type %s", stream_type);
4450 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, value->value.i_val);
4455 __mmcamcorder_attrs_is_supported(MMHandleType handle, int idx)
4457 mmf_attrs_t *attr = (mmf_attrs_t*)handle;
4460 if (mm_attrs_get_flags(handle, idx, &flag) == MM_ERROR_NONE) {
4461 if (flag == MM_ATTRS_FLAG_NONE) {
4468 if (attr->items[idx].value_spec.type == MM_ATTRS_VALID_TYPE_INT_RANGE) {
4470 mm_attrs_get_valid_range((MMHandleType)attr, idx, &min, &max);
4474 } else if (attr->items[idx].value_spec.type == MM_ATTRS_VALID_TYPE_INT_ARRAY) {
4477 mm_attrs_get_valid_array((MMHandleType)attr, idx, &count, &array);
4488 _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4490 mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
4491 mmf_attrs_t *attr = NULL;
4493 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4495 unsigned int i = 0 ;
4497 int attr_idxs_default[] = {
4498 MM_CAM_CAMERA_DIGITAL_ZOOM
4499 , MM_CAM_CAMERA_OPTICAL_ZOOM
4501 , MM_CAM_FILTER_CONTRAST
4503 , MM_CAM_STROBE_MODE
4504 , MM_CAM_DETECT_MODE
4507 int attr_idxs_extra[] = {
4509 , MM_CAM_FILTER_BRIGHTNESS
4511 , MM_CAM_FILTER_SATURATION
4512 , MM_CAM_FILTER_SHARPNESS
4513 , MM_CAM_FILTER_COLOR_TONE
4514 , MM_CAM_CAMERA_EXPOSURE_MODE
4517 mmf_return_val_if_fail(hcamcorder, FALSE);
4519 _mmcam_dbg_log("Set all attribute again.");
4521 attr = (mmf_attrs_t *)MMF_CAMCORDER_ATTRS(handle);
4523 _mmcam_dbg_err("Get attribute handle failed.");
4526 /* Get Scene mode */
4527 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4529 _mmcam_dbg_log("attribute count(%d)", attr->count);
4531 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4532 if (__mmcamcorder_attrs_is_supported((MMHandleType)attr, attr_idxs_default[i])) {
4533 mmf_attribute_set_modified(&(attr->items[attr_idxs_default[i]]));
4537 /* Set extra if scene mode is NORMAL */
4538 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4539 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4540 if (__mmcamcorder_attrs_is_supported((MMHandleType)attr, attr_idxs_extra[i])) {
4541 mmf_attribute_set_modified(&(attr->items[attr_idxs_extra[i]]));
4545 /* Set scene mode if scene mode is NOT NORMAL */
4546 if (__mmcamcorder_attrs_is_supported((MMHandleType)attr, MM_CAM_FILTER_SCENE_MODE)) {
4547 mmf_attribute_set_modified(&(attr->items[MM_CAM_FILTER_SCENE_MODE]));
4551 if (mmf_attrs_commit((MMHandleType)attr) == -1) {
4558 _mmcam_dbg_log("Done.");
4564 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4566 mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
4569 mmf_attrs_t *attr = NULL;
4570 int nerror = MM_ERROR_NONE ;
4572 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4574 attr = (mmf_attrs_t*) MMF_CAMCORDER_ATTRS(handle);
4575 mmf_return_val_if_fail(attr, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4579 table_size = ARRAY_SIZE(readonly_attributes);
4580 _mmcam_dbg_log("%d", table_size);
4581 for (i = 0; i < table_size; i++)
4583 int sCategory = readonly_attributes[i];
4585 mmf_attribute_set_readonly(&(attr->items[sCategory]));
4592 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4594 mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
4595 //int table_size = 0;
4597 mmf_attrs_t *attr = NULL;
4598 type_string_array * disabled_attr = NULL;
4600 int nerror = MM_ERROR_NONE ;
4602 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4604 attr = (mmf_attrs_t*) MMF_CAMCORDER_ATTRS(handle);
4605 mmf_return_val_if_fail(attr, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4610 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4611 CONFIGURE_CATEGORY_MAIN_GENERAL,
4612 "DisabledAttributes",
4614 if (disabled_attr != NULL && disabled_attr->value) {
4615 cnt_str = disabled_attr->count;
4616 for (i = 0; i < cnt_str; i++) {
4618 _mmcam_dbg_log("[%d]%s", i, disabled_attr->value[i] );
4619 nerror = mm_attrs_get_index((MMHandleType)attr, disabled_attr->value[i], &idx);
4620 if (nerror == MM_ERROR_NONE) {
4621 mmf_attribute_set_disabled(&(attr->items[idx]));
4623 _mmcam_dbg_warn("No ATTR named %s[%d]",disabled_attr->value[i], i);
4632 /*---------------------------------------------------------------------------------------
4633 | INTERNAL FUNCTION DEFINITIONS: |
4634 ---------------------------------------------------------------------------------------*/
4635 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4637 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4638 _MMCamcorderSubContext *sc = NULL;
4639 int current_state = MM_CAMCORDER_STATE_NULL;
4641 mmf_return_val_if_fail(hcamcorder, FALSE);
4643 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4648 current_state = _mmcamcorder_get_state(handle);
4650 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4651 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4652 _mmcam_dbg_log("set capture width and height [%dx%d] to camera plugin", width, height);
4653 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4654 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4656 _mmcam_dbg_warn("invalid state[%d]", current_state);
4660 _mmcam_dbg_log("element is not created yet");
4667 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4669 #define INIT_VALUE -1
4670 #define CHECK_COUNT 3
4672 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4673 MMHandleType attrs = 0;
4675 int ret = MM_ERROR_NONE;
4678 const char *name = NULL;
4679 const char *check_pair_name[CHECK_COUNT][3] = {
4680 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
4681 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
4682 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
4685 int check_pair_value[CHECK_COUNT][2] = {
4686 {INIT_VALUE, INIT_VALUE},
4687 {INIT_VALUE, INIT_VALUE},
4688 {INIT_VALUE, INIT_VALUE},
4691 if (hcamcorder == NULL || attribute_name == NULL) {
4692 _mmcam_dbg_warn("handle[%p] or attribute_name[%p] is NULL.",
4693 hcamcorder, attribute_name );
4694 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4697 if (err_attr_name) {
4698 *err_attr_name = NULL;
4701 //_mmcam_dbg_log( "ENTER" );
4703 attrs = MMF_CAMCORDER_ATTRS(handle);
4705 name = attribute_name;
4709 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
4711 /*_mmcam_dbg_log("NAME : %s", name);*/
4713 /* attribute name check */
4714 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
4715 if (err_attr_name) {
4716 *err_attr_name = strdup(name);
4719 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY) { //to avoid confusing
4720 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
4727 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE) {
4731 switch (attr_type) {
4732 case MM_ATTRS_TYPE_INT:
4734 gboolean matched = FALSE;
4735 for (i = 0 ; i < CHECK_COUNT ; i++) {
4736 for (j = 0 ; j < 2 ; j++) {
4737 if (!strcmp(name, check_pair_name[i][j])) {
4738 check_pair_value[i][j] = va_arg((var_args), int);
4739 _mmcam_dbg_log("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
4748 if (matched == FALSE) {
4749 va_arg((var_args), int);
4753 case MM_ATTRS_TYPE_DOUBLE:
4754 va_arg((var_args), double);
4756 case MM_ATTRS_TYPE_STRING:
4757 va_arg((var_args), char*); /* string */
4758 va_arg((var_args), int); /* size */
4760 case MM_ATTRS_TYPE_DATA:
4761 va_arg((var_args), void*); /* data */
4762 va_arg((var_args), int); /* size */
4764 case MM_ATTRS_TYPE_INVALID:
4766 _mmcam_dbg_err("Not supported attribute type(%d, name:%s)", attr_type, name);
4767 if (err_attr_name) {
4768 *err_attr_name = strdup(name);
4770 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4774 name = va_arg(var_args, const char*);
4777 for (i = 0 ; i < CHECK_COUNT ; i++) {
4778 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
4779 gboolean check_result = FALSE;
4780 char *err_name = NULL;
4781 MMCamAttrsInfo attr_info_0, attr_info_1;
4783 if (check_pair_value[i][0] == INIT_VALUE) {
4784 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
4785 err_name = strdup(check_pair_name[i][1]);
4786 } else if (check_pair_value[i][1] == INIT_VALUE) {
4787 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
4788 err_name = strdup(check_pair_name[i][0]);
4790 err_name = strdup(check_pair_name[i][2]);
4793 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
4794 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
4796 check_result = FALSE;
4798 for( j = 0 ; j < attr_info_0.int_array.count ; j++ ) {
4799 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
4800 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
4802 _mmcam_dbg_log("Valid Pair[%s,%s] existed %dx%d[index:%d]",
4803 check_pair_name[i][0], check_pair_name[i][1],
4804 check_pair_value[i][0], check_pair_value[i][1], i);
4806 check_result = TRUE;
4811 if (check_result == FALSE) {
4812 _mmcam_dbg_err("INVALID pair[%s,%s] %dx%d",
4813 check_pair_name[i][0], check_pair_name[i][1],
4814 check_pair_value[i][0], check_pair_value[i][1]);
4815 if (err_attr_name) {
4816 *err_attr_name = err_name;
4824 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4827 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
4828 int current_width = 0;
4829 int current_height = 0;
4831 mm_camcorder_get_attributes(handle, NULL,
4832 MMCAM_CAMERA_WIDTH, ¤t_width,
4833 MMCAM_CAMERA_HEIGHT, ¤t_height,
4836 if (current_width != check_pair_value[i][0] ||
4837 current_height != check_pair_value[i][1]) {
4838 hcamcorder->resolution_changed = TRUE;
4840 hcamcorder->resolution_changed = FALSE;
4843 _mmcam_dbg_log("resolution changed : %d", hcamcorder->resolution_changed);
4853 /*_mmcam_dbg_log("DONE");*/
4855 return MM_ERROR_NONE;
4859 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
4863 if ((void *)handle == NULL) {
4864 _mmcam_dbg_warn("handle %p is NULL", handle);
4868 memset(&info, 0x0, sizeof(MMAttrsInfo));
4870 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
4872 switch (info.validity_type) {
4873 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
4875 _mmcam_dbg_log("int array count %d", info.int_array.count);
4877 if (info.int_array.count <= 1) {
4881 case MM_ATTRS_VALID_TYPE_INT_RANGE:
4883 _mmcam_dbg_log("int range min %d, max %d",info.int_range.min, info.int_range.max);
4885 if (info.int_range.min >= info.int_range.max) {
4889 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
4891 _mmcam_dbg_log("double array count %d", info.double_array.count);
4893 if (info.double_array.count <= 1) {
4897 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
4899 _mmcam_dbg_log("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
4901 if (info.double_range.min >= info.double_range.max) {
4906 _mmcam_dbg_warn("invalid type %d", info.validity_type);