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[] = {
100 1, /*The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.*/
101 2, /*the 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.*/
102 3, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.*/
103 4, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.*/
104 5, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual top.*/
105 6, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual top.*/
106 7, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.*/
107 8, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.*/
110 if (hcamcorder == NULL) {
111 _mmcam_dbg_err("handle is NULL");
115 /* Create attribute constructor */
116 _mmcam_dbg_log("start");
118 /* alloc 'mmf_attrs_construct_info_t' */
119 attr_count = MM_CAM_ATTRIBUTE_NUM;
120 attrs_const_info = malloc(attr_count * sizeof(mmf_attrs_construct_info_t));
121 if (!attrs_const_info) {
122 _mmcam_dbg_err("Fail to alloc constructor.");
126 /* alloc default attribute info */
127 hcamcorder->cam_attrs_const_info = (mm_cam_attr_construct_info *)malloc(sizeof(mm_cam_attr_construct_info) * attr_count);
128 if (hcamcorder->cam_attrs_const_info == NULL) {
129 _mmcam_dbg_err("failed to alloc default attribute info");
130 free(attrs_const_info);
131 attrs_const_info = NULL;
135 /* basic attributes' info */
136 mm_cam_attr_construct_info temp_info[] = {
139 MM_CAM_MODE, /* ID */
141 MMF_VALUE_TYPE_INT, /* Type */
142 MM_ATTRS_FLAG_RW, /* Flag */
143 {(void*)MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Default value */
144 MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */
145 {.int_min = MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Validity val1 (min, *array,...) */
146 {.int_max = MM_CAMCORDER_MODE_AUDIO}, /* Validity val2 (max, count, ...) */
147 NULL, /* Runtime setting function of the attribute */
154 {(void*)MM_AUDIO_DEVICE_MIC},
155 MM_ATTRS_VALID_TYPE_INT_ARRAY,
161 MM_CAM_CAMERA_DEVICE_COUNT,
162 "camera-device-count",
165 {(void*)MM_VIDEO_DEVICE_NUM},
166 MM_ATTRS_VALID_TYPE_INT_RANGE,
167 {.int_min = MM_VIDEO_DEVICE_NONE},
168 {.int_max = MM_VIDEO_DEVICE_NUM},
172 MM_CAM_AUDIO_ENCODER,
176 {(void*)MM_AUDIO_CODEC_AMR},
177 MM_ATTRS_VALID_TYPE_INT_ARRAY,
183 MM_CAM_VIDEO_ENCODER,
187 {(void*)MM_VIDEO_CODEC_MPEG4},
188 MM_ATTRS_VALID_TYPE_INT_ARRAY,
194 MM_CAM_IMAGE_ENCODER,
198 {(void*)MM_IMAGE_CODEC_JPEG},
199 MM_ATTRS_VALID_TYPE_INT_ARRAY,
209 {(void*)MM_FILE_FORMAT_MP4},
210 MM_ATTRS_VALID_TYPE_INT_ARRAY,
216 MM_CAM_CAMERA_DEVICE_NAME,
217 "camera-device-name",
218 MMF_VALUE_TYPE_STRING,
221 MM_ATTRS_VALID_TYPE_NONE,
227 MM_CAM_AUDIO_SAMPLERATE,
232 MM_ATTRS_VALID_TYPE_INT_RANGE,
234 {.int_max = _MMCAMCORDER_MAX_INT},
242 {(void*)MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE},
243 MM_ATTRS_VALID_TYPE_INT_ARRAY,
250 MM_CAM_AUDIO_CHANNEL,
255 MM_ATTRS_VALID_TYPE_INT_RANGE,
263 MMF_VALUE_TYPE_DOUBLE,
266 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
268 {.double_max = 10.0},
269 _mmcamcorder_commit_audio_volume,
272 MM_CAM_AUDIO_INPUT_ROUTE,
276 {(void*)MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
277 MM_ATTRS_VALID_TYPE_INT_RANGE,
278 {.int_min = MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
279 {.int_max = MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY},
280 _mmcamcorder_commit_audio_input_route,
283 MM_CAM_FILTER_SCENE_MODE,
288 MM_ATTRS_VALID_TYPE_INT_ARRAY,
291 _mmcamcorder_commit_filter_scene_mode,
294 MM_CAM_FILTER_BRIGHTNESS,
299 MM_ATTRS_VALID_TYPE_INT_RANGE,
302 _mmcamcorder_commit_filter,
305 MM_CAM_FILTER_CONTRAST,
310 MM_ATTRS_VALID_TYPE_INT_RANGE,
313 _mmcamcorder_commit_filter,
321 MM_ATTRS_VALID_TYPE_INT_ARRAY,
324 _mmcamcorder_commit_filter,
327 MM_CAM_FILTER_COLOR_TONE,
332 MM_ATTRS_VALID_TYPE_INT_ARRAY,
335 _mmcamcorder_commit_filter,
338 MM_CAM_FILTER_SATURATION,
343 MM_ATTRS_VALID_TYPE_INT_RANGE,
346 _mmcamcorder_commit_filter,
354 MM_ATTRS_VALID_TYPE_INT_RANGE,
357 _mmcamcorder_commit_filter,
361 MM_CAM_FILTER_SHARPNESS,
366 MM_ATTRS_VALID_TYPE_INT_RANGE,
369 _mmcamcorder_commit_filter,
372 MM_CAM_CAMERA_FORMAT,
376 {(void*)MM_PIXEL_FORMAT_YUYV},
377 MM_ATTRS_VALID_TYPE_INT_ARRAY,
380 _mmcamcorder_commit_camera_format,
383 MM_CAM_CAMERA_RECORDING_MOTION_RATE,
384 "camera-recording-motion-rate",
385 MMF_VALUE_TYPE_DOUBLE,
388 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
390 {.double_max = _MMCAMCORDER_MAX_DOUBLE},
391 _mmcamcorder_commit_camera_recording_motion_rate,
399 MM_ATTRS_VALID_TYPE_INT_RANGE,
402 _mmcamcorder_commit_camera_fps,
409 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
410 MM_ATTRS_VALID_TYPE_INT_ARRAY,
413 _mmcamcorder_commit_camera_width,
416 MM_CAM_CAMERA_HEIGHT,
420 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
421 MM_ATTRS_VALID_TYPE_INT_ARRAY,
424 _mmcamcorder_commit_camera_height,
427 MM_CAM_CAMERA_DIGITAL_ZOOM,
428 "camera-digital-zoom",
432 MM_ATTRS_VALID_TYPE_INT_RANGE,
435 _mmcamcorder_commit_camera_zoom,
438 MM_CAM_CAMERA_OPTICAL_ZOOM,
439 "camera-optical-zoom",
443 MM_ATTRS_VALID_TYPE_INT_RANGE,
446 _mmcamcorder_commit_camera_zoom,
449 MM_CAM_CAMERA_FOCUS_MODE,
453 {(void*)MM_CAMCORDER_FOCUS_MODE_NONE},
454 MM_ATTRS_VALID_TYPE_INT_ARRAY,
457 _mmcamcorder_commit_camera_focus_mode,
460 MM_CAM_CAMERA_AF_SCAN_RANGE,
461 "camera-af-scan-range",
465 MM_ATTRS_VALID_TYPE_INT_ARRAY,
468 _mmcamcorder_commit_camera_af_scan_range,
472 MM_CAM_CAMERA_EXPOSURE_MODE,
473 "camera-exposure-mode",
477 MM_ATTRS_VALID_TYPE_INT_ARRAY,
480 _mmcamcorder_commit_camera_capture_mode,
483 MM_CAM_CAMERA_EXPOSURE_VALUE,
484 "camera-exposure-value",
488 MM_ATTRS_VALID_TYPE_INT_RANGE,
491 _mmcamcorder_commit_camera_capture_mode,
494 MM_CAM_CAMERA_F_NUMBER,
499 MM_ATTRS_VALID_TYPE_INT_ARRAY,
502 _mmcamcorder_commit_camera_capture_mode,
505 MM_CAM_CAMERA_SHUTTER_SPEED,
506 "camera-shutter-speed",
510 MM_ATTRS_VALID_TYPE_INT_ARRAY,
513 _mmcamcorder_commit_camera_capture_mode,
521 MM_ATTRS_VALID_TYPE_INT_ARRAY,
524 _mmcamcorder_commit_camera_capture_mode,
532 MM_ATTRS_VALID_TYPE_INT_ARRAY,
535 _mmcamcorder_commit_camera_wdr,
538 MM_CAM_CAMERA_ANTI_HANDSHAKE,
539 "camera-anti-handshake",
543 MM_ATTRS_VALID_TYPE_INT_ARRAY,
546 _mmcamcorder_commit_camera_anti_handshake,
549 MM_CAM_CAMERA_FPS_AUTO,
554 MM_ATTRS_VALID_TYPE_INT_RANGE,
557 _mmcamcorder_commit_camera_fps,
560 MM_CAM_CAMERA_DELAY_ATTR_SETTING,
561 "camera-delay-attr-setting",
565 MM_ATTRS_VALID_TYPE_INT_RANGE,
571 MM_CAM_AUDIO_ENCODER_BITRATE,
572 "audio-encoder-bitrate",
576 MM_ATTRS_VALID_TYPE_INT_RANGE,
578 {.int_max = _MMCAMCORDER_MAX_INT},
579 _mmcamcorder_commit_encoder_bitrate,
583 MM_CAM_VIDEO_ENCODER_BITRATE,
584 "video-encoder-bitrate",
588 MM_ATTRS_VALID_TYPE_INT_RANGE,
590 {.int_max = _MMCAMCORDER_MAX_INT},
591 _mmcamcorder_commit_encoder_bitrate,
594 MM_CAM_IMAGE_ENCODER_QUALITY,
595 "image-encoder-quality",
599 MM_ATTRS_VALID_TYPE_INT_RANGE,
602 _mmcamcorder_commit_image_encoder_quality,
605 MM_CAM_CAPTURE_FORMAT,
609 {(void*)MM_PIXEL_FORMAT_ENCODED},
610 MM_ATTRS_VALID_TYPE_INT_ARRAY,
616 MM_CAM_CAPTURE_WIDTH,
621 MM_ATTRS_VALID_TYPE_INT_ARRAY,
624 _mmcamcorder_commit_capture_width ,
627 MM_CAM_CAPTURE_HEIGHT,
632 MM_ATTRS_VALID_TYPE_INT_ARRAY,
635 _mmcamcorder_commit_capture_height,
638 MM_CAM_CAPTURE_COUNT,
643 MM_ATTRS_VALID_TYPE_INT_RANGE,
646 _mmcamcorder_commit_capture_count,
649 MM_CAM_CAPTURE_INTERVAL,
654 MM_ATTRS_VALID_TYPE_INT_RANGE,
656 {.int_max = _MMCAMCORDER_MAX_INT},
660 MM_CAM_CAPTURE_BREAK_CONTINUOUS_SHOT,
661 "capture-break-cont-shot",
665 MM_ATTRS_VALID_TYPE_INT_RANGE,
668 _mmcamcorder_commit_capture_break_cont_shot,
671 MM_CAM_DISPLAY_HANDLE,
676 MM_ATTRS_VALID_TYPE_NONE,
679 _mmcamcorder_commit_display_handle,
682 MM_CAM_DISPLAY_DEVICE,
686 {(void*)MM_DISPLAY_DEVICE_MAINLCD},
687 MM_ATTRS_VALID_TYPE_INT_ARRAY,
694 MM_CAM_DISPLAY_SURFACE,
698 {(void*)MM_DISPLAY_SURFACE_OVERLAY},
699 MM_ATTRS_VALID_TYPE_INT_ARRAY,
705 MM_CAM_DISPLAY_RECT_X,
710 MM_ATTRS_VALID_TYPE_INT_RANGE,
712 {.int_max = _MMCAMCORDER_MAX_INT},
713 _mmcamcorder_commit_display_rect,
716 MM_CAM_DISPLAY_RECT_Y,
721 MM_ATTRS_VALID_TYPE_INT_RANGE,
723 {.int_max = _MMCAMCORDER_MAX_INT},
724 _mmcamcorder_commit_display_rect,
727 MM_CAM_DISPLAY_RECT_WIDTH,
728 "display-rect-width",
732 MM_ATTRS_VALID_TYPE_INT_RANGE,
734 {.int_max = _MMCAMCORDER_MAX_INT},
735 _mmcamcorder_commit_display_rect,
738 MM_CAM_DISPLAY_RECT_HEIGHT,
739 "display-rect-height",
743 MM_ATTRS_VALID_TYPE_INT_RANGE,
745 {.int_max = _MMCAMCORDER_MAX_INT},
746 _mmcamcorder_commit_display_rect,
749 MM_CAM_DISPLAY_SOURCE_X,
754 MM_ATTRS_VALID_TYPE_INT_RANGE,
756 {.int_max = _MMCAMCORDER_MAX_INT},
760 MM_CAM_DISPLAY_SOURCE_Y,
765 MM_ATTRS_VALID_TYPE_INT_RANGE,
767 {.int_max = _MMCAMCORDER_MAX_INT},
771 MM_CAM_DISPLAY_SOURCE_WIDTH,
776 MM_ATTRS_VALID_TYPE_INT_RANGE,
778 {.int_max = _MMCAMCORDER_MAX_INT},
782 MM_CAM_DISPLAY_SOURCE_HEIGHT,
783 "display-src-height",
787 MM_ATTRS_VALID_TYPE_INT_RANGE,
789 {.int_max = _MMCAMCORDER_MAX_INT},
793 MM_CAM_DISPLAY_ROTATION,
797 {(void*)MM_DISPLAY_ROTATION_NONE},
798 MM_ATTRS_VALID_TYPE_INT_RANGE,
799 {.int_min = MM_DISPLAY_ROTATION_NONE},
800 {.int_max = MM_DISPLAY_ROTATION_270},
801 _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},
857 _mmcamcorder_commit_recording_max_limit,
860 MM_CAM_TARGET_TIME_LIMIT,
865 MM_ATTRS_VALID_TYPE_INT_RANGE,
867 {.int_max = _MMCAMCORDER_MAX_INT},
868 _mmcamcorder_commit_recording_max_limit,
876 MM_ATTRS_VALID_TYPE_INT_RANGE,
879 _mmcamcorder_commit_tag,
882 MM_CAM_TAG_IMAGE_DESCRIPTION,
883 "tag-image-description",
884 MMF_VALUE_TYPE_STRING,
887 MM_ATTRS_VALID_TYPE_NONE,
890 _mmcamcorder_commit_tag,
893 MM_CAM_TAG_ORIENTATION,
898 MM_ATTRS_VALID_TYPE_INT_ARRAY,
899 {tag_orientation_values},
900 {ARRAY_SIZE(tag_orientation_values)},
901 _mmcamcorder_commit_tag,
906 MMF_VALUE_TYPE_STRING,
909 MM_ATTRS_VALID_TYPE_NONE,
912 _mmcamcorder_commit_tag,
918 MMF_VALUE_TYPE_DOUBLE,
921 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
922 {.double_min = -360.0},
923 {.double_max = 360.0},
924 _mmcamcorder_commit_tag,
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},
935 _mmcamcorder_commit_tag,
940 MMF_VALUE_TYPE_DOUBLE,
943 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
944 {.double_min = -999999.0},
945 {.double_max = 999999.0},
946 _mmcamcorder_commit_tag,
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,
1134 _mmcamcorder_commit_tag,
1138 MM_CAM_TAG_GPS_TIME_STAMP,
1139 "tag-gps-time-stamp",
1140 MMF_VALUE_TYPE_DOUBLE,
1143 MM_ATTRS_VALID_TYPE_NONE,
1146 _mmcamcorder_commit_tag,
1149 MM_CAM_TAG_GPS_DATE_STAMP,
1150 "tag-gps-date-stamp",
1151 MMF_VALUE_TYPE_STRING,
1154 MM_ATTRS_VALID_TYPE_NONE,
1157 _mmcamcorder_commit_tag,
1160 MM_CAM_TAG_GPS_PROCESSING_METHOD,
1161 "tag-gps-processing-method",
1162 MMF_VALUE_TYPE_STRING,
1165 MM_ATTRS_VALID_TYPE_NONE,
1168 _mmcamcorder_commit_tag,
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,
1471 MM_CAM_ENCODED_PREVIEW_BITRATE,
1472 "encoded-preview-bitrate",
1475 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE},
1476 MM_ATTRS_VALID_TYPE_INT_RANGE,
1478 {.int_max = _MMCAMCORDER_MAX_INT},
1479 _mmcamcorder_commit_encoded_preview_bitrate,
1482 MM_CAM_ENCODED_PREVIEW_GOP_INTERVAL,
1483 "encoded-preview-gop-interval",
1486 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL},
1487 MM_ATTRS_VALID_TYPE_INT_RANGE,
1489 {.int_max = _MMCAMCORDER_MAX_INT},
1490 _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++) {
1623 /* _mmcam_dbg_log("Valid type [%s:%d, %d, %d]", cam_attrs_const_info[idx].name, cam_attrs_const_info[idx].validity_type
1624 , cam_attrs_const_info[idx].validity_value1, cam_attrs_const_info[idx].validity_value2);
1626 mmf_attrs_set_valid_type(attrs, idx, hcamcorder->cam_attrs_const_info[idx].validity_type);
1628 switch (hcamcorder->cam_attrs_const_info[idx].validity_type) {
1629 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1630 if (hcamcorder->cam_attrs_const_info[idx].validity_value_1.int_array &&
1631 hcamcorder->cam_attrs_const_info[idx].validity_value_2.count > 0) {
1632 mmf_attrs_set_valid_array(attrs, idx,
1633 (const int *)(hcamcorder->cam_attrs_const_info[idx].validity_value_1.int_array),
1634 hcamcorder->cam_attrs_const_info[idx].validity_value_2.count,
1635 hcamcorder->cam_attrs_const_info[idx].default_value.value_int);
1638 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1639 mmf_attrs_set_valid_range(attrs, idx,
1640 hcamcorder->cam_attrs_const_info[idx].validity_value_1.int_min,
1641 hcamcorder->cam_attrs_const_info[idx].validity_value_2.int_max,
1642 hcamcorder->cam_attrs_const_info[idx].default_value.value_int);
1644 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1645 if (hcamcorder->cam_attrs_const_info[idx].validity_value_1.double_array &&
1646 hcamcorder->cam_attrs_const_info[idx].validity_value_2.count > 0) {
1647 mmf_attrs_set_valid_double_array(attrs, idx,
1648 (const double *)(hcamcorder->cam_attrs_const_info[idx].validity_value_1.double_array),
1649 hcamcorder->cam_attrs_const_info[idx].validity_value_2.count,
1650 hcamcorder->cam_attrs_const_info[idx].default_value.value_double);
1653 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1654 mmf_attrs_set_valid_double_range(attrs, idx,
1655 hcamcorder->cam_attrs_const_info[idx].validity_value_1.double_min,
1656 hcamcorder->cam_attrs_const_info[idx].validity_value_2.double_max,
1657 hcamcorder->cam_attrs_const_info[idx].default_value.value_double);
1659 case MM_ATTRS_VALID_TYPE_NONE:
1661 case MM_ATTRS_VALID_TYPE_INVALID:
1663 _mmcam_dbg_err("Valid type error.");
1668 __mmcamcorder_release_conf_valid_info(handle);
1675 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1677 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1679 if (hcamcorder == NULL) {
1680 _mmcam_dbg_err("handle is NULL");
1687 mmf_attrs_free(attrs);
1688 _mmcam_dbg_log("released attribute");
1691 if (hcamcorder->cam_attrs_const_info) {
1692 free(hcamcorder->cam_attrs_const_info);
1693 hcamcorder->cam_attrs_const_info = NULL;
1694 _mmcam_dbg_log("released attribute info");
1700 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1702 MMHandleType attrs = 0;
1703 int ret = MM_ERROR_NONE;
1705 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1706 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1708 attrs = MMF_CAMCORDER_ATTRS(handle);
1709 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1711 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1718 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1720 MMHandleType attrs = 0;
1721 int ret = MM_ERROR_NONE;
1722 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1724 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1725 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1727 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1728 _mmcam_dbg_err("Another command is running.");
1729 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1732 attrs = MMF_CAMCORDER_ATTRS(handle);
1734 ret = __mmcamcorder_check_valid_pair(handle, err_attr_name, attribute_name, var_args);
1736 _mmcam_dbg_err("handle 0x%x, attrs is NULL, attr name [%s]", handle, attribute_name);
1737 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1740 if (ret == MM_ERROR_NONE) {
1741 hcamcorder->error_code = MM_ERROR_NONE;
1742 ret = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, var_args);
1745 _MMCAMCORDER_UNLOCK_CMD(handle);
1747 if (ret != MM_ERROR_NONE) {
1748 if (hcamcorder->error_code != MM_ERROR_NONE) {
1749 _mmcam_dbg_err("error_code is not NONE. origin 0x%x, modified 0x%x", ret, hcamcorder->error_code);
1750 ret = hcamcorder->error_code;
1751 hcamcorder->error_code = MM_ERROR_NONE;
1754 _mmcam_dbg_err("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1762 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1764 MMHandleType attrs = 0;
1765 MMAttrsInfo attrinfo;
1766 int ret = MM_ERROR_NONE;
1768 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1769 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1770 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1772 attrs = MMF_CAMCORDER_ATTRS(handle);
1773 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1775 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1777 if (ret == MM_ERROR_NONE) {
1778 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1779 info->type = attrinfo.type;
1780 info->flag = attrinfo.flag;
1781 info->validity_type = attrinfo.validity_type;
1783 switch (attrinfo.validity_type) {
1784 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1785 info->int_array.array = attrinfo.int_array.array;
1786 info->int_array.count = attrinfo.int_array.count;
1787 info->int_array.def = attrinfo.int_array.dval;
1789 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1790 info->int_range.min = attrinfo.int_range.min;
1791 info->int_range.max = attrinfo.int_range.max;
1792 info->int_range.def = attrinfo.int_range.dval;
1794 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1795 info->double_array.array = attrinfo.double_array.array;
1796 info->double_array.count = attrinfo.double_array.count;
1797 info->double_array.def = attrinfo.double_array.dval;
1799 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1800 info->double_range.min = attrinfo.double_range.min;
1801 info->double_range.max = attrinfo.double_range.max;
1802 info->double_range.def = attrinfo.double_range.dval;
1804 case MM_ATTRS_VALID_TYPE_NONE:
1806 case MM_ATTRS_VALID_TYPE_INVALID:
1817 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const mmf_value_t *value, void *commit_param)
1820 mmf_camcorder_t *hcamcorder = NULL;
1822 mmf_return_val_if_fail(commit_param, FALSE);
1823 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1824 mmf_return_val_if_fail(attr_name, FALSE);
1825 mmf_return_val_if_fail(value, FALSE);
1827 hcamcorder = MMF_CAMCORDER(commit_param);
1829 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1830 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1838 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1841 int total_count = 0;
1843 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1845 if (hcamcorder == NULL) {
1846 _mmcam_dbg_err("handle is NULL");
1847 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1851 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
1852 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
1853 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
1856 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
1857 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
1858 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
1861 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
1862 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
1863 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
1866 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
1867 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
1868 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
1870 return MM_ERROR_NONE;
1874 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
1876 int *allocated_memory = NULL;
1878 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1880 if (hcamcorder == NULL) {
1881 _mmcam_dbg_err("handle is NULL");
1882 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1885 _mmcam_dbg_log("START");
1887 /* Audio encoder info */
1888 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
1889 if (allocated_memory) {
1890 free(allocated_memory);
1891 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
1892 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
1895 /* Video encoder info */
1896 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
1897 if (allocated_memory) {
1898 free(allocated_memory);
1899 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
1900 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
1903 /* Image encoder info */
1904 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
1905 if (allocated_memory) {
1906 free(allocated_memory);
1907 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
1908 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
1911 /* File format info */
1912 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
1913 if (allocated_memory) {
1914 free(allocated_memory);
1915 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
1916 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
1919 _mmcam_dbg_log("DONE");
1921 return MM_ERROR_NONE;
1925 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const mmf_value_t *value)
1927 MMHandleType attr = 0;
1928 int current_state = MM_CAMCORDER_STATE_NONE;
1930 mmf_return_val_if_fail(handle && value, FALSE);
1932 attr = MMF_CAMCORDER_ATTRS(handle);
1933 mmf_return_val_if_fail(attr, FALSE);
1935 /*_mmcam_dbg_log("(%d)", attr_idx);*/
1937 current_state = _mmcamcorder_get_state(handle);
1938 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
1939 int flags = MM_ATTRS_FLAG_NONE;
1940 int capture_width, capture_height;
1941 MMCamAttrsInfo info;
1943 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
1946 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
1947 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
1948 capture_width = value->value.i_val;
1950 /* Check whether they are valid pair */
1951 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
1956 _mmcam_dbg_log("Capture resolution can't be set.(state=%d)", current_state);
1962 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const mmf_value_t *value)
1964 int current_state = MM_CAMCORDER_STATE_NONE;
1966 current_state = _mmcamcorder_get_state(handle);
1968 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
1969 int capture_width, capture_height;
1971 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
1972 capture_height = value->value.i_val;
1974 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
1976 _mmcam_dbg_log("Capture resolution can't be set.(state=%d)", current_state);
1983 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const mmf_value_t *value)
1985 int current_state = 0;
1987 const char *videosrc_name = NULL;
1988 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1989 _MMCamcorderSubContext *sc = NULL;
1990 GstCameraControl *control = NULL;
1991 type_element *VideosrcElement = NULL;
1993 mmf_return_val_if_fail(handle && value, FALSE);
1995 current_state = _mmcamcorder_get_state(handle);
1996 ivalue = value->value.i_val;
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;
2033 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2035 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2037 current_state = _mmcamcorder_get_state(handle);
2038 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2040 _mmcam_dbg_log("current state %d, mode %d, set count %d",
2041 current_state, mode, value->value.i_val);
2043 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2044 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2047 _mmcam_dbg_err("Invalid mode[%d] or state[%d]", mode, current_state);
2053 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2055 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2057 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2059 _mmcam_dbg_log("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2061 /* return error when disable shutter sound if policy is TRUE */
2062 if (!value->value.i_val &&
2063 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2064 _mmcam_dbg_err("not permitted DISABLE SHUTTER SOUND");
2067 _mmcam_dbg_log("set value [%d] success", value->value.i_val);
2073 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2075 int current_state = MM_CAMCORDER_STATE_NONE;
2076 _MMCamcorderSubContext *sc = NULL;
2079 mmf_return_val_if_fail(handle && value, FALSE);
2081 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_format(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2114 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2115 int current_state = MM_CAMCORDER_STATE_NONE;
2117 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2119 current_state = _mmcamcorder_get_state(handle);
2120 if (current_state > MM_CAMCORDER_STATE_READY) {
2121 _mmcam_dbg_err("invalid state %d", current_state);
2122 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2130 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2132 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2133 MMCamAttrsInfo fps_info;
2134 int resolution_width = 0;
2135 int resolution_height = 0;
2138 int current_state = MM_CAMCORDER_STATE_NONE;
2140 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2142 current_state = _mmcamcorder_get_state(handle);
2143 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2144 _mmcam_dbg_err("invalid state %d", current_state);
2145 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2149 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2152 _mmcam_dbg_log("FPS(%d)", value->value.i_val);
2154 ret = mm_camcorder_get_attributes(handle, NULL,
2155 MMCAM_CAMERA_WIDTH, &resolution_width,
2156 MMCAM_CAMERA_HEIGHT, &resolution_height,
2159 if (ret != MM_ERROR_NONE) {
2160 _mmcam_dbg_err("FAILED : coult not get resolution values.");
2164 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2165 if (ret != MM_ERROR_NONE) {
2166 _mmcam_dbg_err("FAILED : coult not get FPS values by resolution.");
2170 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2171 if (value->value.i_val == fps_info.int_array.array[i])
2175 _mmcam_dbg_err("FAILED : %d is not supported FPS", value->value.i_val);
2181 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2183 int current_state = MM_CAMCORDER_STATE_NONE;
2184 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2185 _MMCamcorderSubContext *sc = NULL;
2187 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2189 current_state = _mmcamcorder_get_state(handle);
2190 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2191 _mmcam_dbg_warn("invalid state %d", current_state);
2192 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2196 /* Verify recording motion rate */
2197 if (value->value.d_val > 0.0) {
2198 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2202 /* set is_slow flag */
2203 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2204 sc->is_modified_rate = TRUE;
2206 sc->is_modified_rate = FALSE;
2208 _mmcam_dbg_log("Set slow motion rate %lf", value->value.d_val);
2211 _mmcam_dbg_warn("Failed to set recording motion rate %lf", value->value.d_val);
2217 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2219 MMHandleType attr = 0;
2220 int current_state = MM_CAMCORDER_STATE_NONE;
2222 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2223 _MMCamcorderSubContext *sc = NULL;
2225 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2227 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2231 attr = MMF_CAMCORDER_ATTRS(handle);
2232 mmf_return_val_if_fail(attr, FALSE);
2234 _mmcam_dbg_log("Width(%d)", value->value.i_val);
2236 current_state = _mmcamcorder_get_state(handle);
2238 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2239 _mmcam_dbg_log("Resolution can't be changed.(state=%d)", current_state);
2242 int flags = MM_ATTRS_FLAG_NONE;
2243 MMCamAttrsInfo info;
2244 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2247 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2248 int width = value->value.i_val;
2250 int preview_format = MM_PIXEL_FORMAT_NV12;
2251 int codec_type = MM_IMAGE_CODEC_JPEG;
2253 mm_camcorder_get_attributes(handle, NULL,
2254 MMCAM_CAMERA_HEIGHT, &height,
2255 MMCAM_CAMERA_FORMAT, &preview_format,
2256 MMCAM_IMAGE_ENCODER, &codec_type,
2259 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2260 if (hcamcorder->resolution_changed == FALSE) {
2261 _mmcam_dbg_log("no need to restart preview");
2265 hcamcorder->resolution_changed = FALSE;
2267 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2268 _mmcam_dbg_log("restart preview");
2270 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2271 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2273 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2275 /* check decoder recreation */
2276 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2277 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2278 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2282 /* get preview format */
2283 sc->info_image->preview_format = preview_format;
2284 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2285 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2287 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2288 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2290 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2293 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2295 _mmcam_dbg_err("currently locked for preview restart");
2299 /* get preview format */
2300 sc->info_image->preview_format = preview_format;
2301 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2302 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2313 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2316 int current_state = MM_CAMCORDER_STATE_NONE;
2317 MMHandleType attr = 0;
2318 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2319 _MMCamcorderSubContext *sc = NULL;
2321 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2323 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2327 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2328 mmf_return_val_if_fail(attr, FALSE);
2330 _mmcam_dbg_log("Height(%d)", value->value.i_val);
2331 current_state = _mmcamcorder_get_state(handle);
2333 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2334 _mmcam_dbg_log("Resolution can't be changed.(state=%d)", current_state);
2335 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2339 int height = value->value.i_val;
2340 int preview_format = MM_PIXEL_FORMAT_NV12;
2341 int codec_type = MM_IMAGE_CODEC_JPEG;
2342 int video_stabilization = 0;
2344 mm_camcorder_get_attributes(handle, NULL,
2345 MMCAM_CAMERA_WIDTH, &width,
2346 MMCAM_CAMERA_FORMAT, &preview_format,
2347 MMCAM_IMAGE_ENCODER, &codec_type,
2348 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2351 sc->info_video->preview_width = width;
2352 sc->info_video->preview_height = height;
2354 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2355 if (hcamcorder->resolution_changed == FALSE) {
2356 _mmcam_dbg_log("no need to restart preview");
2360 hcamcorder->resolution_changed = FALSE;
2362 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2363 _mmcam_dbg_log("restart preview");
2365 _mmcam_dbg_log("set empty buffers");
2367 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2368 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2370 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2372 /* check decoder recreation */
2373 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2374 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2375 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2379 /* get preview format */
2380 sc->info_image->preview_format = preview_format;
2381 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2383 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2385 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2386 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2388 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2391 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2393 _mmcam_dbg_err("currently locked for preview restart");
2397 /* get preview format */
2398 sc->info_image->preview_format = preview_format;
2399 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2400 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2408 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2410 int current_state = MM_CAMCORDER_STATE_NONE;
2411 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2413 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2415 current_state = _mmcamcorder_get_state(handle);
2416 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2417 _mmcam_dbg_err("Video Resolution can't be changed.(state=%d)", current_state);
2418 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2421 _mmcam_dbg_warn("Video Resolution %d [attr_idx %d] ",
2422 value->value.i_val, attr_idx);
2428 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2430 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2431 _MMCamcorderSubContext *sc = NULL;
2432 int current_state = MM_CAMCORDER_STATE_NONE;
2433 GstCameraControl *control = NULL;
2437 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2439 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2443 zoom_level = value->value.i_val;
2445 _mmcam_dbg_log("(%d)", attr_idx);
2447 current_state = _mmcamcorder_get_state(handle);
2448 if (current_state < MM_CAMCORDER_STATE_READY) {
2449 _mmcam_dbg_log("will be applied when preview starts");
2451 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2452 _mmcam_dbg_err("Can not set while CAPTURING");
2453 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2457 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2458 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2460 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2462 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2465 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2466 _mmcam_dbg_log("Can't cast Video source into camera control.");
2470 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2471 if (control == NULL) {
2472 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2476 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2478 _mmcam_dbg_log("Succeed in operating Zoom[%d].", zoom_level);
2481 _mmcam_dbg_warn("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2484 _mmcam_dbg_log("pointer of video src is null");
2491 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2493 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2494 _MMCamcorderSubContext *sc = NULL;
2495 int current_state = MM_CAMCORDER_STATE_NONE;
2497 GstCameraControl *CameraControl = NULL;
2498 GstCameraControlChannel *CameraControlChannel = NULL;
2499 const GList *controls = NULL;
2500 const GList *item = NULL;
2502 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2504 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2505 mmf_return_val_if_fail(sc, TRUE);
2507 _mmcam_dbg_log("ptz type : %d", value->value.i_val);
2509 current_state = _mmcamcorder_get_state(handle);
2510 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2511 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2512 _mmcam_dbg_err("invalid state[%d]", current_state);
2513 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2517 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2518 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2519 _mmcam_dbg_log("Can't cast Video source into camera control.");
2523 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2524 if (CameraControl == NULL) {
2525 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2529 controls = gst_camera_control_list_channels(CameraControl);
2530 if (controls == NULL) {
2531 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2535 for (item = controls ; item && item->data ; item = item->next) {
2536 CameraControlChannel = item->data;
2537 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2538 if (!strcmp(CameraControlChannel->label, "ptz")) {
2539 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2540 _mmcam_dbg_warn("set ptz type %d done", value->value.i_val);
2543 _mmcam_dbg_err("failed to set ptz type %d", value->value.i_val);
2550 _mmcam_dbg_warn("failed to find tilt control channel");
2558 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2560 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2561 _MMCamcorderSubContext *sc = NULL;
2562 int current_state = MM_CAMCORDER_STATE_NONE;
2564 GstCameraControl *CameraControl = NULL;
2565 GstCameraControlChannel *CameraControlChannel = NULL;
2566 const GList *controls = NULL;
2567 const GList *item = NULL;
2569 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2571 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2572 mmf_return_val_if_fail(sc, TRUE);
2574 _mmcam_dbg_log("pan : %d", value->value.i_val);
2576 current_state = _mmcamcorder_get_state(handle);
2577 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2578 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2579 _mmcam_dbg_err("invalid state[%d]", current_state);
2580 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2584 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2585 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2586 _mmcam_dbg_log("Can't cast Video source into camera control.");
2590 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2591 if (CameraControl == NULL) {
2592 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2596 controls = gst_camera_control_list_channels(CameraControl);
2597 if (controls == NULL) {
2598 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2602 for (item = controls ; item && item->data ; item = item->next) {
2603 CameraControlChannel = item->data;
2604 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2605 if (!strcmp(CameraControlChannel->label, "pan")) {
2606 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2607 _mmcam_dbg_warn("set pan %d done", value->value.i_val);
2610 _mmcam_dbg_err("failed to set pan %d", value->value.i_val);
2617 _mmcam_dbg_warn("failed to find pan control channel");
2625 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2627 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2628 _MMCamcorderSubContext *sc = NULL;
2629 int current_state = MM_CAMCORDER_STATE_NONE;
2631 GstCameraControl *CameraControl = NULL;
2632 GstCameraControlChannel *CameraControlChannel = NULL;
2633 const GList *controls = NULL;
2634 const GList *item = NULL;
2636 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2638 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2639 mmf_return_val_if_fail(sc, TRUE);
2641 _mmcam_dbg_log("tilt : %d", value->value.i_val);
2643 current_state = _mmcamcorder_get_state(handle);
2644 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2645 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2646 _mmcam_dbg_err("invalid state[%d]", current_state);
2647 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2651 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2652 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2653 _mmcam_dbg_log("Can't cast Video source into camera control.");
2657 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2658 if (CameraControl == NULL) {
2659 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2663 controls = gst_camera_control_list_channels(CameraControl);
2664 if (controls == NULL) {
2665 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2669 for (item = controls ; item && item->data ; item = item->next) {
2670 CameraControlChannel = item->data;
2671 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2672 if (!strcmp(CameraControlChannel->label, "tilt")) {
2673 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2674 _mmcam_dbg_warn("set tilt %d done", value->value.i_val);
2677 _mmcam_dbg_err("failed to set tilt %d", value->value.i_val);
2684 _mmcam_dbg_warn("failed to find tilt control channel");
2692 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2694 MMHandleType attr = 0;
2695 int current_state = MM_CAMCORDER_STATE_NONE;
2696 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2697 _MMCamcorderSubContext *sc = NULL;
2698 GstCameraControl *control = NULL;
2700 int set_focus_mode = 0;
2701 int cur_focus_mode = 0;
2702 int cur_focus_range = 0;
2704 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2706 attr = MMF_CAMCORDER_ATTRS(handle);
2707 mmf_return_val_if_fail(attr, FALSE);
2709 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2713 _mmcam_dbg_log("Focus mode(%d)", value->value.i_val);
2715 /* check whether set or not */
2716 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2717 _mmcam_dbg_log("skip set value %d", value->value.i_val);
2721 current_state = _mmcamcorder_get_state(handle);
2722 if (current_state < MM_CAMCORDER_STATE_NULL) {
2723 _mmcam_dbg_log("Focus mode will be changed later.(state=%d)", current_state);
2725 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2726 _mmcam_dbg_err("Can not set while CAPTURING");
2727 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2731 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2732 int flags = MM_ATTRS_FLAG_NONE;
2733 MMCamAttrsInfo info;
2735 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2736 _mmcam_dbg_log("Can't cast Video source into camera control.");
2740 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2741 if (control == NULL) {
2742 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2746 mslVal = value->value.i_val;
2747 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2749 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2752 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2753 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2754 if (set_focus_mode != cur_focus_mode) {
2755 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2756 _mmcam_dbg_log("Succeed in setting AF mode[%d]", mslVal);
2759 _mmcam_dbg_warn("Failed to set AF mode[%d]", mslVal);
2762 _mmcam_dbg_log("No need to set AF mode. Current[%d]", mslVal);
2766 _mmcam_dbg_warn("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2770 _mmcam_dbg_log("pointer of video src is null");
2777 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2779 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2780 _MMCamcorderSubContext *sc = NULL;
2781 GstCameraControl *control = NULL;
2782 int current_state = MM_CAMCORDER_STATE_NONE;
2785 int cur_focus_mode = 0;
2786 int cur_focus_range = 0;
2787 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2788 int converted_mode = 0;
2790 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2792 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2796 _mmcam_dbg_log("(%d)", attr_idx);
2798 /* check whether set or not */
2799 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2800 _mmcam_dbg_log("skip set value %d", value->value.i_val);
2804 mslVal = value->value.i_val;
2805 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2807 current_state = _mmcamcorder_get_state(handle);
2808 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2809 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
2811 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2812 _mmcam_dbg_err("Can not set while CAPTURING");
2813 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2817 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2818 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2819 _mmcam_dbg_log("Can't cast Video source into camera control.");
2823 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2824 if (control == NULL) {
2825 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2829 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
2830 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
2832 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2833 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
2834 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
2835 /*_mmcam_dbg_log("Succeed in setting AF mode[%d]", mslVal);*/
2838 _mmcam_dbg_warn("Failed to set AF mode[%d]", mslVal);
2841 /*_mmcam_dbg_log("No need to set AF mode. Current[%d]", mslVal);*/
2845 _mmcam_dbg_warn("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2848 _mmcam_dbg_log("pointer of video src is null");
2855 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const mmf_value_t *value)
2857 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2858 _MMCamcorderSubContext *sc = NULL;
2859 GstCameraControl *control = NULL;
2860 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
2861 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
2863 int current_state = MM_CAMCORDER_STATE_NONE;
2865 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2867 gboolean do_set = FALSE;
2869 MMCamAttrsInfo info_y;
2870 MMCamAttrsInfo info_w;
2871 MMCamAttrsInfo info_h;
2873 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2875 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2879 _mmcam_dbg_log("(%d)", attr_idx);
2881 current_state = _mmcamcorder_get_state(handle);
2882 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2883 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
2885 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2886 _mmcam_dbg_err("Can not set while CAPTURING");
2887 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2891 ret = mm_camcorder_get_attributes(handle, NULL,
2892 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2894 if (ret != MM_ERROR_NONE) {
2895 _mmcam_dbg_warn("Failed to get FOCUS MODE.[%x]", ret);
2899 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
2900 _mmcam_dbg_warn("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
2904 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2905 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2906 _mmcam_dbg_log("Can't cast Video source into camera control.");
2910 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
2911 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
2912 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
2915 case MM_CAM_CAMERA_AF_TOUCH_X:
2916 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
2917 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
2918 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
2919 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
2920 set_area.x = value->value.i_val;
2921 mm_camcorder_get_attributes(handle, NULL,
2922 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
2923 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
2924 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
2928 _mmcam_dbg_log("Just store AF area[x:%d]", value->value.i_val);
2932 case MM_CAM_CAMERA_AF_TOUCH_Y:
2933 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
2934 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
2935 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
2936 set_area.y = value->value.i_val;
2937 mm_camcorder_get_attributes(handle, NULL,
2938 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
2939 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
2940 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
2944 _mmcam_dbg_log("Just store AF area[y:%d]", value->value.i_val);
2948 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
2949 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
2950 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
2951 set_area.width = value->value.i_val;
2952 mm_camcorder_get_attributes(handle, NULL,
2953 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
2954 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
2955 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
2959 _mmcam_dbg_log("Just store AF area[width:%d]", value->value.i_val);
2963 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
2964 set_area.height = value->value.i_val;
2965 mm_camcorder_get_attributes(handle, NULL,
2966 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
2967 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
2968 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
2977 _MMCamcorderVideoInfo *info = sc->info_video;
2980 _mmcam_dbg_err("video info is NULL");
2984 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2985 if (control == NULL) {
2986 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2991 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
2992 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
2993 float ratio_width = 0.0;
2994 float ratio_height = 0.0;
2996 if (info->preview_width != 0 && info->preview_height != 0) {
2997 ratio_width = (float)info->video_width / (float)info->preview_width;
2998 ratio_height = (float)info->video_height / (float)info->preview_height;
3000 _mmcam_dbg_log("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3001 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3003 set_area.x = (int)((float)set_area.x * ratio_width);
3004 set_area.y = (int)((float)set_area.y * ratio_height);
3005 set_area.width = (int)((float)set_area.width * ratio_width);
3006 set_area.height = (int)((float)set_area.height * ratio_height);
3008 if (set_area.width <= 0)
3011 if (set_area.height <= 0)
3012 set_area.height = 1;
3014 _mmcam_dbg_log("converted area %d,%d,%dx%d",
3015 set_area.x, set_area.y, set_area.width, set_area.height);
3017 _mmcam_dbg_warn("invalid preview size %dx%d, skip AF area converting",
3018 info->preview_width, info->preview_height);
3022 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3024 _mmcam_dbg_warn("Failed to get AF area");
3028 /* width and height are not supported now */
3029 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3030 _mmcam_dbg_log("No need to set AF area[x,y:%d,%d]",
3031 get_area.x, get_area.y);
3035 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3037 _mmcam_dbg_log("Succeed to set AF area[%d,%d,%dx%d]",
3038 set_area.x, set_area.y, set_area.width, set_area.height);
3041 _mmcam_dbg_warn("Failed to set AF area[%d,%d,%dx%d]",
3042 set_area.x, set_area.y, set_area.width, set_area.height);
3046 _mmcam_dbg_log("pointer of video src is null");
3053 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3055 GstCameraControl *control = NULL;
3061 int exposure_type = 0;
3062 int current_state = MM_CAMCORDER_STATE_NONE;
3063 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3064 _MMCamcorderSubContext *sc = NULL;
3066 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3067 gboolean check_scene_mode = FALSE;
3069 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3071 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3075 /* check whether set or not */
3076 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3077 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3081 current_state = _mmcamcorder_get_state(handle);
3082 if (current_state < MM_CAMCORDER_STATE_READY) {
3083 _mmcam_dbg_log("will be applied when preview starts");
3085 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3086 _mmcam_dbg_err("Can not set while CAPTURING");
3087 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3091 ivalue = value->value.i_val;
3093 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3094 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3095 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3096 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3097 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3098 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3099 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3100 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3101 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3102 exposure_type = GST_CAMERA_CONTROL_ISO;
3104 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3105 check_scene_mode = TRUE;
3106 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3107 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3109 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3110 check_scene_mode = TRUE;
3111 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3112 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3113 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3114 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3117 if (check_scene_mode) {
3118 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3119 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3120 _mmcam_dbg_warn("can not set [%d] when scene mode is NOT normal.", attr_idx);
3125 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3128 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3129 _mmcam_dbg_log("Can't cast Video source into camera control.");
3133 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3134 if (control == NULL) {
3135 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3139 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3141 _mmcam_dbg_log("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3144 _mmcam_dbg_warn("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3147 _mmcam_dbg_log("pointer of video src is null");
3154 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3156 GstCameraControl *control = NULL;
3160 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3161 _MMCamcorderSubContext *sc = NULL;
3162 int current_state = MM_CAMCORDER_STATE_NONE;
3164 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3166 /* check whether set or not */
3167 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3168 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3172 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3176 /* check current state */
3177 current_state = _mmcamcorder_get_state(handle);
3178 if (current_state < MM_CAMCORDER_STATE_READY) {
3179 _mmcam_dbg_log("will be applied when preview starts");
3181 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3182 _mmcam_dbg_err("Can not set while CAPTURING");
3183 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3187 mslVal = value->value.i_val;
3188 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3190 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3191 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3192 _mmcam_dbg_log("Can't cast Video source into camera control.");
3196 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3197 if (control == NULL) {
3198 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3202 if (gst_camera_control_get_wdr(control, &cur_value)) {
3203 if (newVal != cur_value) {
3204 if (gst_camera_control_set_wdr(control, newVal)) {
3205 _mmcam_dbg_log("Success - set wdr[%d]", mslVal);
3208 _mmcam_dbg_warn("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3211 _mmcam_dbg_log("No need to set new WDR. Current[%d]", mslVal);
3215 _mmcam_dbg_warn("Failed to get WDR.");
3218 _mmcam_dbg_log("pointer of video src is null");
3225 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3227 int current_state = MM_CAMCORDER_STATE_NONE;
3228 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3230 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3232 /* check whether set or not */
3233 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3234 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3238 current_state = _mmcamcorder_get_state(handle);
3239 if (current_state < MM_CAMCORDER_STATE_READY) {
3240 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3242 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3243 _mmcam_dbg_err("Invaild state (state %d)", current_state);
3244 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3248 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3252 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3256 int current_state = MM_CAMCORDER_STATE_NONE;
3257 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3258 _MMCamcorderSubContext *sc = NULL;
3260 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3262 bitrate = value->value.i_val;
3264 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3265 if (!sc || !sc->encode_element) {
3266 _mmcam_dbg_log("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3270 current_state = _mmcamcorder_get_state(handle);
3271 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3272 _mmcam_dbg_err("Can not set while RECORDING - attr idx %d", attr_idx);
3273 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3277 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3278 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3280 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3281 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3283 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3284 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3291 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3293 int current_state = MM_CAMCORDER_STATE_NONE;
3294 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3296 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3298 current_state = _mmcamcorder_get_state(handle);
3299 if (current_state < MM_CAMCORDER_STATE_READY) {
3300 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3302 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3303 _mmcam_dbg_err("Invaild state (state %d)", current_state);
3304 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3308 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3312 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3314 int current_state = MM_CAMCORDER_STATE_NONE;
3315 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3317 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3319 _mmcam_dbg_log("rotate(%d)", value->value.i_val);
3321 current_state = _mmcamcorder_get_state(handle);
3323 if (current_state > MM_CAMCORDER_STATE_READY) {
3324 _mmcam_dbg_err("camera rotation setting failed.(state=%d)", current_state);
3325 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3328 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3333 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3335 int current_state = MM_CAMCORDER_STATE_NONE;
3337 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3338 _MMCamcorderSubContext *sc = NULL;
3340 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3343 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3344 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3348 /* check current state */
3349 current_state = _mmcamcorder_get_state(handle);
3350 if (current_state < MM_CAMCORDER_STATE_READY) {
3351 _mmcam_dbg_log("NOT initialized. this will be applied later");
3353 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3354 _mmcam_dbg_err("Can not set while CAPTURING");
3355 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3359 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3361 _mmcam_dbg_log("Image encoder quality(%d)", value->value.i_val);
3363 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3364 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3367 _mmcam_dbg_err("invalid state %d", current_state);
3373 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3375 _MMCamcorderSubContext *sc = NULL;
3376 const char *filename = NULL;
3379 mmf_return_val_if_fail(handle && value, FALSE);
3381 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3386 filename = mmf_value_get_string(value, &size);
3387 if (filename == NULL) {
3388 _mmcam_dbg_err("NULL filename");
3392 if (sc->info_video) {
3393 SAFE_G_FREE(sc->info_video->filename);
3394 sc->info_video->filename = g_strdup(filename);
3395 if (sc->info_video->filename == NULL) {
3396 _mmcam_dbg_err("failed to strdup filename [%s]", filename);
3401 if (sc->encode_element && sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst) {
3402 _mmcam_dbg_log("new file location set.[%s] filesink %p", filename, sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst);
3403 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, "location", filename);
3404 _mmcam_dbg_log("new file location set.(%s)", filename);
3406 _mmcam_dbg_log("element is not created yet. [%s] will be set later...", filename);
3413 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3415 int current_state = MM_CAMCORDER_STATE_NONE;
3416 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3418 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3420 current_state = _mmcamcorder_get_state(handle);
3421 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3422 _mmcam_dbg_err("Can not set while RECORDING");
3423 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3431 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3433 GstColorBalance *balance = NULL;
3434 GstColorBalanceChannel *Colorchannel = NULL;
3435 const GList *controls = NULL;
3436 const GList *item = NULL;
3439 int current_state = MM_CAMCORDER_STATE_NONE;
3440 const char *control_label = NULL;
3441 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3442 _MMCamcorderSubContext *sc = NULL;
3444 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3445 gboolean check_scene_mode = FALSE;
3447 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3449 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3453 /* check whether set or not */
3454 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3455 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3459 current_state = _mmcamcorder_get_state(handle);
3460 if (current_state < MM_CAMCORDER_STATE_READY) {
3461 _mmcam_dbg_log("will be applied when preview starts");
3463 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3464 _mmcam_dbg_err("Can not set while CAPTURING");
3465 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3469 if (value->type != MM_ATTRS_TYPE_INT) {
3470 _mmcam_dbg_warn("Mismatched value type (%d)", value->type);
3473 mslNewVal = value->value.i_val;
3477 case MM_CAM_FILTER_BRIGHTNESS:
3478 control_label = "brightness";
3479 check_scene_mode = TRUE;
3482 case MM_CAM_FILTER_CONTRAST:
3483 control_label = "contrast";
3486 case MM_CAM_FILTER_WB:
3487 control_label = "white balance";
3488 check_scene_mode = TRUE;
3491 case MM_CAM_FILTER_COLOR_TONE:
3492 control_label = "color tone";
3495 case MM_CAM_FILTER_SATURATION:
3496 control_label = "saturation";
3497 check_scene_mode = TRUE;
3500 case MM_CAM_FILTER_HUE:
3501 control_label = "hue";
3504 case MM_CAM_FILTER_SHARPNESS:
3505 control_label = "sharpness";
3506 check_scene_mode = TRUE;
3509 _mmcam_dbg_err("unknown attribute index %d", attr_idx);
3513 if (check_scene_mode) {
3514 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3515 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3516 _mmcam_dbg_warn("can not set %s when scene mode is NOT normal.", control_label);
3521 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslNewVal);
3522 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3525 /*_mmcam_dbg_log("label(%s): MSL(%d)->Sensor(%d)", control_label, mslNewVal, newVal);*/
3527 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3528 _mmcam_dbg_log("Can't cast Video source into color balance.");
3532 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3533 if (balance == NULL) {
3534 _mmcam_dbg_err("cast COLOR_BALANCE failed");
3538 controls = gst_color_balance_list_channels(balance);
3539 if (controls == NULL) {
3540 _mmcam_dbg_log("There is no list of colorbalance controls");
3544 for (item = controls ; item && item->data ; item = item->next) {
3545 Colorchannel = item->data;
3546 /*_mmcam_dbg_log("Getting name of CID=(%s), input CID=(%s)", Colorchannel->label, control_label);*/
3548 if (!strcmp(Colorchannel->label, control_label)) {
3549 gst_color_balance_set_value(balance, Colorchannel, newVal);
3550 _mmcam_dbg_log("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslNewVal, newVal);
3556 _mmcam_dbg_err("failed to find color channel item");
3564 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3568 int current_state = MM_CAMCORDER_STATE_NONE;
3569 GstCameraControl *control = NULL;
3570 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3571 _MMCamcorderSubContext *sc = NULL;
3573 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3575 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3579 mslVal = value->value.i_val;
3580 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3582 /* check whether set or not */
3583 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3584 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3588 current_state = _mmcamcorder_get_state(handle);
3589 if (current_state < MM_CAMCORDER_STATE_READY) {
3590 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3592 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3593 _mmcam_dbg_err("Can not set while CAPTURING");
3594 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3598 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3601 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3602 _mmcam_dbg_log("Can't cast Video source into camera control.");
3606 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3607 if (control == NULL) {
3608 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3612 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3614 _mmcam_dbg_log("Succeed in setting program mode[%d].", mslVal);
3616 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3620 MM_CAM_FILTER_BRIGHTNESS,
3622 MM_CAM_FILTER_SATURATION,
3623 MM_CAM_FILTER_SHARPNESS,
3624 MM_CAM_FILTER_COLOR_TONE,
3625 MM_CAM_CAMERA_EXPOSURE_MODE
3627 mmf_attrs_t *attr = (mmf_attrs_t *)MMF_CAMCORDER_ATTRS(handle);
3629 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3630 if (__mmcamcorder_attrs_is_supported((MMHandleType)attr, attr_idxs[i]))
3631 mmf_attribute_set_modified(&(attr->items[attr_idxs[i]]));
3637 _mmcam_dbg_log("Failed to set program mode[%d].", mslVal);
3640 _mmcam_dbg_warn("pointer of video src is null");
3647 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3649 mmf_return_val_if_fail(handle && value, FALSE);
3651 _mmcam_dbg_warn("Filter Flip(%d)", value->value.i_val);
3657 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3659 mmf_return_val_if_fail(handle && value, FALSE);
3661 _mmcam_dbg_log("Commit : Do nothing. this attr will be removed soon.");
3667 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3669 int current_state = MM_CAMCORDER_STATE_NONE;
3670 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3672 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3674 current_state = _mmcamcorder_get_state(handle);
3675 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3676 _mmcam_dbg_warn("Can NOT Disable AUDIO. invalid state %d", current_state);
3677 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3680 _mmcam_dbg_log("Disable AUDIO when Recording");
3686 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3688 int current_state = MM_CAMCORDER_STATE_NONE;
3689 const char *videosink_name = NULL;
3690 void *p_handle = NULL;
3692 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3693 _MMCamcorderSubContext *sc = NULL;
3695 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3698 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3699 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3703 /* check current state */
3704 current_state = _mmcamcorder_get_state(handle);
3705 if (current_state < MM_CAMCORDER_STATE_READY) {
3706 _mmcam_dbg_log("NOT initialized. this will be applied later");
3710 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3712 p_handle = value->value.p_val;
3714 /* get videosink name */
3715 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3716 if (videosink_name == NULL) {
3717 _mmcam_dbg_err("Please check videosink element in configuration file");
3721 _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name);
3723 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3724 _mmcam_dbg_log("Commit : Set XID[%x]", *(int*)(p_handle));
3725 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int*)(p_handle));
3726 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3727 _mmcam_dbg_log("Commit : Set evas object [%p]", p_handle);
3728 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", p_handle);
3729 } else if (!strcmp(videosink_name, "waylandsink")) {
3730 MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)p_handle;
3732 _mmcam_dbg_log("wayland global surface id : %d", wl_info->global_surface_id);
3734 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)wl_info->global_surface_id);
3735 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3736 wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
3738 _mmcam_dbg_warn("Commit : Nothing to commit with this element[%s]", videosink_name);
3742 _mmcam_dbg_warn("Display handle is NULL");
3750 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3752 int current_state = MM_CAMCORDER_STATE_NONE;
3753 const char *videosink_name = NULL;
3755 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3756 _MMCamcorderSubContext *sc = NULL;
3758 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3761 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3762 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3766 /* check current state */
3767 current_state = _mmcamcorder_get_state(handle);
3768 if (current_state < MM_CAMCORDER_STATE_READY) {
3769 _mmcam_dbg_log("NOT initialized. this will be applied later");
3773 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3775 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3776 if (videosink_name == NULL) {
3777 _mmcam_dbg_err("Please check videosink element in configuration file");
3781 _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name);
3783 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink")) {
3784 _mmcam_dbg_log("Commit : display mode [%d]", value->value.i_val);
3785 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3788 _mmcam_dbg_warn("Commit : This element [%s] does not support display mode", videosink_name);
3794 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3796 int current_state = MM_CAMCORDER_STATE_NONE;
3798 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3800 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3803 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3804 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3808 /* check current state */
3809 current_state = _mmcamcorder_get_state(handle);
3810 if (current_state < MM_CAMCORDER_STATE_READY) {
3811 _mmcam_dbg_log("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3815 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3819 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3821 int current_state = MM_CAMCORDER_STATE_NONE;
3823 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3825 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3828 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3829 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3833 /* check current state */
3834 current_state = _mmcamcorder_get_state(handle);
3835 if (current_state < MM_CAMCORDER_STATE_READY) {
3836 _mmcam_dbg_log("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3840 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3844 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3846 int current_state = MM_CAMCORDER_STATE_NONE;
3847 const char *videosink_name = NULL;
3849 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3850 _MMCamcorderSubContext *sc = NULL;
3852 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3855 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3856 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3860 /* check current state */
3861 current_state = _mmcamcorder_get_state(handle);
3862 if (current_state < MM_CAMCORDER_STATE_READY) {
3863 _mmcam_dbg_log("NOT initialized. this will be applied later");
3867 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3869 /* Get videosink name */
3870 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3871 if (videosink_name == NULL) {
3872 _mmcam_dbg_err("Please check videosink element in configuration file");
3876 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink") ||
3877 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
3878 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
3879 _mmcam_dbg_log("Set visible [%d] done.", value->value.i_val);
3882 _mmcam_dbg_warn("videosink[%s] does not support VISIBLE.", videosink_name);
3888 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3891 int current_state = MM_CAMCORDER_STATE_NONE;
3892 const char *videosink_name = NULL;
3894 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3895 _MMCamcorderSubContext *sc = NULL;
3897 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3900 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3901 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3905 /* check current state */
3906 current_state = _mmcamcorder_get_state(handle);
3907 if (current_state < MM_CAMCORDER_STATE_READY) {
3908 _mmcam_dbg_log("NOT initialized. this will be applied later");
3912 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3914 /* Get videosink name */
3915 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3916 if (videosink_name == NULL) {
3917 _mmcam_dbg_err("Please check videosink element in configuration file");
3921 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink") ||
3922 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
3923 method = value->value.i_val;
3924 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
3927 _mmcam_dbg_warn("videosink[%s] does not support geometry method.", videosink_name);
3933 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const mmf_value_t *value)
3935 int current_state = MM_CAMCORDER_STATE_NONE;
3937 int ret = MM_ERROR_NONE;
3938 const char *videosink_name = NULL;
3940 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3941 _MMCamcorderSubContext *sc = NULL;
3943 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3946 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3947 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3951 /* check current state */
3952 current_state = _mmcamcorder_get_state(handle);
3953 if (current_state < MM_CAMCORDER_STATE_READY) {
3954 _mmcam_dbg_log("NOT initialized. this will be applied later");
3958 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3960 /* check current method */
3961 mm_camcorder_get_attributes(handle, NULL,
3962 MMCAM_DISPLAY_GEOMETRY_METHOD, &method,
3964 if (method != MM_DISPLAY_METHOD_CUSTOM_ROI) {
3965 _mmcam_dbg_log("current method[%d] is not supported rect", method);
3969 /* Get videosink name */
3970 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3971 if (videosink_name == NULL) {
3972 _mmcam_dbg_err("Please check videosink element in configuration file");
3976 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink") ||
3977 !strcmp(videosink_name, "evaspixmapsink")) {
3981 int rect_height = 0;
3982 int flags = MM_ATTRS_FLAG_NONE;
3983 MMCamAttrsInfo info;
3985 mm_camcorder_get_attributes(handle, NULL,
3986 MMCAM_DISPLAY_RECT_X, &rect_x,
3987 MMCAM_DISPLAY_RECT_Y, &rect_y,
3988 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
3989 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
3992 case MM_CAM_DISPLAY_RECT_X:
3993 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
3995 memset(&info, 0x00, sizeof(info));
3996 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
3998 memset(&info, 0x00, sizeof(info));
3999 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4002 rect_x = value->value.i_val;
4004 case MM_CAM_DISPLAY_RECT_Y:
4005 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4007 memset(&info, 0x00, sizeof(info));
4008 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4011 rect_y = value->value.i_val;
4013 case MM_CAM_DISPLAY_RECT_WIDTH:
4014 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4017 rect_width = value->value.i_val;
4019 case MM_CAM_DISPLAY_RECT_HEIGHT:
4020 rect_height = value->value.i_val;
4023 _mmcam_dbg_err("Wrong attr_idx!");
4027 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4028 _mmcam_dbg_log("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4030 if (!strcmp(videosink_name, "waylandsink")) {
4031 ret = gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4032 rect_x, rect_y, rect_width, rect_height);
4034 _mmcam_dbg_err("FAILED : could not set render rectangle.");
4038 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4039 "dst-roi-x", rect_x,
4040 "dst-roi-y", rect_y,
4041 "dst-roi-w", rect_width,
4042 "dst-roi-h", rect_height,
4049 _mmcam_dbg_warn("videosink[%s] does not support display rect.", videosink_name);
4055 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4058 int current_state = MM_CAMCORDER_STATE_NONE;
4059 const char *videosink_name = NULL;
4060 GstElement *vs_element = NULL;
4062 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4063 _MMCamcorderSubContext *sc = NULL;
4065 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4068 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4069 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
4073 /* check current state */
4074 current_state = _mmcamcorder_get_state(handle);
4075 if (current_state < MM_CAMCORDER_STATE_READY) {
4076 _mmcam_dbg_log("NOT initialized. this will be applied later");
4080 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4082 /* Get videosink name */
4083 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4084 if (videosink_name == NULL) {
4085 _mmcam_dbg_err("Please check videosink element in configuration file");
4089 zoom = value->value.i_val;
4090 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink")) {
4091 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4093 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4094 _mmcam_dbg_log("Set display zoom to %d", zoom + 1);
4098 _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name);
4104 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4106 int current_state = MM_CAMCORDER_STATE_NONE;
4108 const char *videosink_name = NULL;
4110 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4111 _MMCamcorderSubContext *sc = NULL;
4113 mmf_return_val_if_fail(handle && value, FALSE);
4116 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4117 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
4121 /* check current state */
4122 current_state = _mmcamcorder_get_state(handle);
4123 if (current_state < MM_CAMCORDER_STATE_READY) {
4124 _mmcam_dbg_log("NOT initialized. this will be applied later");
4128 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4130 do_scaling = value->value.i_val;
4132 /* Get videosink name */
4133 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4134 if (videosink_name == NULL) {
4135 _mmcam_dbg_err("Please check videosink element in configuration file");
4139 if (!strcmp(videosink_name, "evaspixmapsink")) {
4140 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4141 _mmcam_dbg_log("Set origin-size to %d", !(value->value.i_val));
4144 _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name);
4150 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4153 _MMCamcorderSubContext *sc = NULL;
4154 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4155 int strobe_type, mslVal, newVal, cur_value;
4156 int current_state = MM_CAMCORDER_STATE_NONE;
4158 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4160 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4164 /*_mmcam_dbg_log( "Commit : strobe attribute(%d)", attr_idx );*/
4166 mslVal = value->value.i_val;
4168 /* check flash state */
4169 if (attr_idx == MM_CAM_STROBE_MODE) {
4170 int flash_brightness = 0;
4172 /* get current flash brightness */
4173 if (_mmcamcorder_get_device_flash_brightness(hcamcorder->gdbus_conn, &flash_brightness) != MM_ERROR_NONE) {
4174 _mmcam_dbg_err("_mmcamcorder_get_device_flash_brightness failed");
4175 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4179 _mmcam_dbg_log("flash brightness %d", flash_brightness);
4181 if (flash_brightness > 0 &&
4182 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4183 /* other module already turned on flash */
4184 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4185 _mmcam_dbg_err("other module already turned on flash. avoid to set flash mode here.");
4188 _mmcam_dbg_log("keep going");
4193 current_state = _mmcamcorder_get_state(handle);
4194 if (current_state < MM_CAMCORDER_STATE_READY) {
4195 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
4197 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4198 _mmcam_dbg_err("Can not set while CAPTURING");
4199 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4204 case MM_CAM_STROBE_CONTROL:
4205 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4206 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4208 case MM_CAM_STROBE_CAPABILITIES:
4209 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4212 case MM_CAM_STROBE_MODE:
4213 /* check whether set or not */
4214 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4215 _mmcam_dbg_log("skip set value %d", mslVal);
4219 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4220 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4223 _mmcam_dbg_err("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4227 GstCameraControl *control = NULL;
4228 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4229 _mmcam_dbg_err("Can't cast Video source into camera control.");
4232 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4233 if (control == NULL) {
4234 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
4238 if (gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4239 if (newVal != cur_value) {
4240 if (gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4241 _mmcam_dbg_log("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4244 _mmcam_dbg_warn("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4248 _mmcam_dbg_log("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4252 _mmcam_dbg_warn("Failed to get strobe. Type[%d]", strobe_type);
4261 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4264 int current_state = MM_CAMCORDER_STATE_NONE;
4265 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4267 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4269 _mmcam_dbg_log("Commit : flip %d", value->value.i_val);
4272 current_state = _mmcamcorder_get_state(handle);
4273 if (current_state > MM_CAMCORDER_STATE_READY) {
4274 _mmcam_dbg_err("Can not set camera FLIP horizontal at state %d", current_state);
4275 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4277 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4278 _mmcam_dbg_log("Pipeline is not created yet. This will be set when create pipeline.");
4282 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4284 _mmcam_dbg_log("ret %d", ret);
4290 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4292 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4293 int current_state = MM_CAMCORDER_STATE_NONE;
4294 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4295 _MMCamcorderSubContext *sc = NULL;
4297 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4299 /*_mmcam_dbg_log("Commit : HDR Capture %d", value->value.i_val);*/
4301 /* check whether set or not */
4302 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4303 _mmcam_dbg_log("skip set value %d", value->value.i_val);
4308 current_state = _mmcamcorder_get_state(handle);
4309 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4310 _mmcam_dbg_err("can NOT set HDR capture at state %d", current_state);
4311 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4315 if (current_state >= MM_CAMCORDER_STATE_READY) {
4316 int current_value = 0;
4318 set_hdr_mode = value->value.i_val;
4319 mm_camcorder_get_attributes(handle, NULL,
4320 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4323 if (set_hdr_mode == current_value) {
4324 _mmcam_dbg_log("same HDR value : %d, do nothing", set_hdr_mode);
4328 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4330 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4331 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4332 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4334 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4336 /* check decoder recreation */
4337 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4338 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4342 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4343 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4346 set_hdr_mode = value->value.i_val;
4347 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4348 sc->info_image->hdr_capture_mode = set_hdr_mode;
4349 _mmcam_dbg_log("set HDR mode : %d", set_hdr_mode);
4351 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4352 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4354 _mmcam_dbg_err("sc is NULL. can not set HDR capture");
4363 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4366 _MMCamcorderSubContext *sc = NULL;
4367 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4369 int current_value = 0;
4370 int current_state = MM_CAMCORDER_STATE_NONE;
4371 GstCameraControl *control = NULL;
4373 mmf_return_val_if_fail(handle && value, FALSE);
4375 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4379 /*_mmcam_dbg_log("Commit : detect attribute(%d)", attr_idx);*/
4382 current_state = _mmcamcorder_get_state(handle);
4383 if (current_state < MM_CAMCORDER_STATE_READY) {
4384 _mmcam_dbg_log("will be applied when preview starts");
4388 set_value = value->value.i_val;
4391 case MM_CAM_DETECT_MODE:
4392 /* check whether set or not */
4393 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4394 _mmcam_dbg_log("skip set value %d", set_value);
4398 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4400 case MM_CAM_DETECT_NUMBER:
4401 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4403 case MM_CAM_DETECT_FOCUS_SELECT:
4404 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4406 case MM_CAM_DETECT_SELECT_NUMBER:
4407 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4409 case MM_CAM_DETECT_STATUS:
4410 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4413 _mmcam_dbg_err("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4417 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4418 _mmcam_dbg_err("Can't cast Video source into camera control.");
4421 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4422 if (control == NULL) {
4423 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
4427 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4428 if (current_value == set_value) {
4429 _mmcam_dbg_log("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4432 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4433 _mmcam_dbg_warn("Set detect failed. Type[%d],value[%d]",
4434 detect_type, set_value);
4437 _mmcam_dbg_log("Set detect success. Type[%d],value[%d]",
4438 detect_type, set_value);
4443 _mmcam_dbg_warn("Get detect failed. Type[%d]", detect_type);
4452 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4454 int current_state = MM_CAMCORDER_STATE_NONE;
4455 int preview_format = MM_PIXEL_FORMAT_NV12;
4457 mmf_return_val_if_fail(handle && value, FALSE);
4459 _mmcam_dbg_log("Commit : encoded preview bitrate - %d", value->value.i_val);
4461 /* check preview format */
4462 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4463 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4464 _mmcam_dbg_err("current preview format[%d] is not encoded format", preview_format);
4469 current_state = _mmcamcorder_get_state(handle);
4470 if (current_state < MM_CAMCORDER_STATE_READY) {
4471 _mmcam_dbg_log("will be applied when preview starts");
4475 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4479 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4481 int current_state = MM_CAMCORDER_STATE_NONE;
4482 int preview_format = MM_PIXEL_FORMAT_NV12;
4484 mmf_return_val_if_fail(handle && value, FALSE);
4486 _mmcam_dbg_log("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4488 /* check preview format */
4489 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4490 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4491 _mmcam_dbg_err("current preview format[%d] is not encoded format", preview_format);
4496 current_state = _mmcamcorder_get_state(handle);
4497 if (current_state < MM_CAMCORDER_STATE_READY) {
4498 _mmcam_dbg_log("will be applied when preview starts");
4502 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4506 bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4510 int current_state = MM_CAMCORDER_STATE_NONE;
4511 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4513 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4516 current_state = _mmcamcorder_get_state(handle);
4517 if (current_state > MM_CAMCORDER_STATE_NULL) {
4518 _mmcam_dbg_log("invalid state %d", current_state);
4519 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4523 new_pid = value->value.i_val;
4525 _mmcam_dbg_log("Commit : pid %d, current focus id %d, subscribe id %u",
4526 new_pid, hcamcorder->sound_focus_id, hcamcorder->sound_focus_subscribe_id);
4528 /* unregister sound focus and unsubscribe sound signal before set new one */
4529 if (hcamcorder->sound_focus_id > 0) {
4530 mm_sound_unregister_focus(hcamcorder->sound_focus_id);
4531 _mmcam_dbg_log("unregister sound focus done");
4532 hcamcorder->sound_focus_id = 0;
4535 if (hcamcorder->sound_focus_subscribe_id > 0) {
4536 mm_sound_unsubscribe_signal(hcamcorder->sound_focus_subscribe_id);
4537 _mmcam_dbg_log("unsubscribe sound signal done");
4538 hcamcorder->sound_focus_subscribe_id = 0;
4541 ret = _mm_session_util_read_information(new_pid, &hcamcorder->session_type, &hcamcorder->session_flags);
4542 if (ret == MM_ERROR_NONE) {
4543 if (hcamcorder->session_type == MM_SESSION_TYPE_REPLACED_BY_STREAM) {
4544 hcamcorder->sound_focus_register = FALSE;
4545 _mmcam_dbg_warn("no need to use sound focus internally");
4547 ret = mm_sound_focus_get_id(&hcamcorder->sound_focus_id);
4548 if (ret != MM_ERROR_NONE) {
4549 _mmcam_dbg_err("mm_sound_focus_get_id failed");
4550 hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED;
4554 ret = mm_sound_register_focus_for_session(hcamcorder->sound_focus_id,
4555 new_pid, "media", _mmcamcorder_sound_focus_cb, hcamcorder);
4556 if (ret != MM_ERROR_NONE) {
4557 _mmcam_dbg_err("mm_sound_register_focus_for_session failed 0x%x", ret);
4558 hcamcorder->sound_focus_id = 0;
4559 hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED;
4563 hcamcorder->sound_focus_register = TRUE;
4565 _mmcam_dbg_log("mm_sound_register_focus_for_session done - id %d, session type %d, flags 0x%x",
4566 hcamcorder->sound_focus_id, hcamcorder->session_type, hcamcorder->session_flags);
4569 hcamcorder->session_type = 0;
4570 hcamcorder->session_flags = 0;
4571 hcamcorder->sound_focus_register = TRUE;
4573 _mmcam_dbg_warn("read session info failed. sound focus watch cb will be set.");
4575 ret = mm_sound_subscribe_signal_for_daemon(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS,
4576 new_pid, &hcamcorder->sound_focus_subscribe_id,
4577 (mm_sound_signal_callback)_mmcamcorder_sound_signal_callback, (void*)hcamcorder);
4578 if (ret != MM_ERROR_NONE) {
4579 _mmcam_dbg_err("subscribe sound signal failed [0x%x]", ret);
4580 hcamcorder->error_code = MM_ERROR_POLICY_BLOCKED;
4589 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4591 char *stream_type = NULL;
4592 int stream_type_len = 0;
4593 _MMCamcorderSubContext *sc = NULL;
4595 mmf_return_val_if_fail(handle && value, FALSE);
4597 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4598 if (!sc || !sc->encode_element ||
4599 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4600 _mmcam_dbg_log("audiosrc element is not initialized, it will be set later");
4604 mm_camcorder_get_attributes(handle, NULL,
4605 MMCAM_SOUND_STREAM_TYPE, &stream_type, &stream_type_len,
4608 if (stream_type == NULL) {
4609 _mmcam_dbg_err("stream type is not set");
4613 _mmcam_dbg_log("Commit : sound stream info - type %s", stream_type);
4615 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, value->value.i_val);
4619 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const mmf_value_t *value)
4621 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4622 int current_state = MM_CAMCORDER_STATE_NONE;
4624 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4626 current_state = _mmcamcorder_get_state(handle);
4627 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4628 _mmcam_dbg_err("Can not set while CAPTURING");
4629 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4637 static bool __mmcamcorder_attrs_is_supported(MMHandleType handle, int idx)
4639 mmf_attrs_t *attr = (mmf_attrs_t*)handle;
4642 if (mm_attrs_get_flags(handle, idx, &flag) == MM_ERROR_NONE) {
4643 if (flag == MM_ATTRS_FLAG_NONE)
4649 if (attr->items[idx].value_spec.type == MM_ATTRS_VALID_TYPE_INT_RANGE) {
4651 mm_attrs_get_valid_range((MMHandleType)attr, idx, &min, &max);
4654 } else if (attr->items[idx].value_spec.type == MM_ATTRS_VALID_TYPE_INT_ARRAY) {
4657 mm_attrs_get_valid_array((MMHandleType)attr, idx, &count, &array);
4666 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4668 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4669 mmf_attrs_t *attr = NULL;
4671 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4675 int attr_idxs_default[] = {
4676 MM_CAM_CAMERA_DIGITAL_ZOOM,
4677 MM_CAM_CAMERA_OPTICAL_ZOOM,
4679 MM_CAM_FILTER_CONTRAST,
4685 int attr_idxs_extra[] = {
4687 MM_CAM_FILTER_BRIGHTNESS,
4689 MM_CAM_FILTER_SATURATION,
4690 MM_CAM_FILTER_SHARPNESS,
4691 MM_CAM_FILTER_COLOR_TONE,
4692 MM_CAM_CAMERA_EXPOSURE_MODE
4695 mmf_return_val_if_fail(hcamcorder, FALSE);
4697 _mmcam_dbg_log("Set all attribute again.");
4699 attr = (mmf_attrs_t *)MMF_CAMCORDER_ATTRS(handle);
4701 _mmcam_dbg_err("Get attribute handle failed.");
4704 /* Get Scene mode */
4705 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4707 _mmcam_dbg_log("attribute count(%d)", attr->count);
4709 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4710 if (__mmcamcorder_attrs_is_supported((MMHandleType)attr, attr_idxs_default[i]))
4711 mmf_attribute_set_modified(&(attr->items[attr_idxs_default[i]]));
4714 /* Set extra if scene mode is NORMAL */
4715 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4716 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4717 if (__mmcamcorder_attrs_is_supported((MMHandleType)attr, attr_idxs_extra[i]))
4718 mmf_attribute_set_modified(&(attr->items[attr_idxs_extra[i]]));
4721 /* Set scene mode if scene mode is NOT NORMAL */
4722 if (__mmcamcorder_attrs_is_supported((MMHandleType)attr, MM_CAM_FILTER_SCENE_MODE))
4723 mmf_attribute_set_modified(&(attr->items[MM_CAM_FILTER_SCENE_MODE]));
4726 if (mmf_attrs_commit((MMHandleType)attr) == -1)
4732 _mmcam_dbg_log("Done.");
4738 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4740 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4743 mmf_attrs_t *attr = NULL;
4744 int nerror = MM_ERROR_NONE;
4746 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4748 attr = (mmf_attrs_t*) MMF_CAMCORDER_ATTRS(handle);
4749 mmf_return_val_if_fail(attr, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4753 table_size = ARRAY_SIZE(readonly_attributes);
4754 _mmcam_dbg_log("%d", table_size);
4755 for (i = 0; i < table_size; i++) {
4756 int sCategory = readonly_attributes[i];
4758 mmf_attribute_set_readonly(&(attr->items[sCategory]));
4765 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4767 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4769 mmf_attrs_t *attr = NULL;
4770 type_string_array * disabled_attr = NULL;
4772 int nerror = MM_ERROR_NONE ;
4774 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4776 attr = (mmf_attrs_t*) MMF_CAMCORDER_ATTRS(handle);
4777 mmf_return_val_if_fail(attr, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4782 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4783 CONFIGURE_CATEGORY_MAIN_GENERAL,
4784 "DisabledAttributes",
4786 if (disabled_attr != NULL && disabled_attr->value) {
4787 cnt_str = disabled_attr->count;
4788 for (i = 0; i < cnt_str; i++) {
4790 _mmcam_dbg_log("[%d]%s", i, disabled_attr->value[i]);
4791 nerror = mm_attrs_get_index((MMHandleType)attr, disabled_attr->value[i], &idx);
4793 if (nerror == MM_ERROR_NONE)
4794 mmf_attribute_set_disabled(&(attr->items[idx]));
4796 _mmcam_dbg_warn("No ATTR named %s[%d]", disabled_attr->value[i], i);
4804 /*---------------------------------------------------------------------------------------
4805 | INTERNAL FUNCTION DEFINITIONS: |
4806 ---------------------------------------------------------------------------------------*/
4807 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4809 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4810 _MMCamcorderSubContext *sc = NULL;
4811 int current_state = MM_CAMCORDER_STATE_NULL;
4813 mmf_return_val_if_fail(hcamcorder, FALSE);
4815 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4819 current_state = _mmcamcorder_get_state(handle);
4821 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4822 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4823 _mmcam_dbg_log("set capture width and height [%dx%d] to camera plugin", width, height);
4824 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4825 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4827 _mmcam_dbg_warn("invalid state[%d]", current_state);
4831 _mmcam_dbg_log("element is not created yet");
4838 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4840 #define INIT_VALUE -1
4841 #define CHECK_COUNT 3
4843 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4844 MMHandleType attrs = 0;
4846 int ret = MM_ERROR_NONE;
4849 const char *name = NULL;
4850 const char *check_pair_name[CHECK_COUNT][3] = {
4851 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
4852 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
4853 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
4856 int check_pair_value[CHECK_COUNT][2] = {
4857 {INIT_VALUE, INIT_VALUE},
4858 {INIT_VALUE, INIT_VALUE},
4859 {INIT_VALUE, INIT_VALUE},
4862 if (hcamcorder == NULL || attribute_name == NULL) {
4863 _mmcam_dbg_warn("handle[%p] or attribute_name[%p] is NULL.",
4864 hcamcorder, attribute_name);
4865 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4869 *err_attr_name = NULL;
4871 /*_mmcam_dbg_log( "ENTER" );*/
4873 attrs = MMF_CAMCORDER_ATTRS(handle);
4875 name = attribute_name;
4879 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
4881 /*_mmcam_dbg_log("NAME : %s", name);*/
4883 /* attribute name check */
4884 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
4886 *err_attr_name = strdup(name);
4888 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
4889 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
4895 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
4898 switch (attr_type) {
4899 case MM_ATTRS_TYPE_INT:
4901 gboolean matched = FALSE;
4902 for (i = 0 ; i < CHECK_COUNT ; i++) {
4903 for (j = 0 ; j < 2 ; j++) {
4904 if (!strcmp(name, check_pair_name[i][j])) {
4905 check_pair_value[i][j] = va_arg((var_args), int);
4906 _mmcam_dbg_log("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
4914 if (matched == FALSE)
4915 va_arg((var_args), int);
4918 case MM_ATTRS_TYPE_DOUBLE:
4919 va_arg((var_args), double);
4921 case MM_ATTRS_TYPE_STRING:
4922 va_arg((var_args), char*); /* string */
4923 va_arg((var_args), int); /* size */
4925 case MM_ATTRS_TYPE_DATA:
4926 va_arg((var_args), void*); /* data */
4927 va_arg((var_args), int); /* size */
4929 case MM_ATTRS_TYPE_INVALID:
4931 _mmcam_dbg_err("Not supported attribute type(%d, name:%s)", attr_type, name);
4933 *err_attr_name = strdup(name);
4935 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4939 name = va_arg(var_args, const char*);
4942 for (i = 0 ; i < CHECK_COUNT ; i++) {
4943 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
4944 gboolean check_result = FALSE;
4945 char *err_name = NULL;
4946 MMCamAttrsInfo attr_info_0, attr_info_1;
4948 if (check_pair_value[i][0] == INIT_VALUE) {
4949 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
4950 err_name = strdup(check_pair_name[i][1]);
4951 } else if (check_pair_value[i][1] == INIT_VALUE) {
4952 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
4953 err_name = strdup(check_pair_name[i][0]);
4955 err_name = strdup(check_pair_name[i][2]);
4958 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
4959 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
4961 check_result = FALSE;
4963 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
4964 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
4965 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
4967 _mmcam_dbg_log("Valid Pair[%s,%s] existed %dx%d[index:%d]",
4968 check_pair_name[i][0], check_pair_name[i][1],
4969 check_pair_value[i][0], check_pair_value[i][1], i);
4971 check_result = TRUE;
4976 if (check_result == FALSE) {
4977 _mmcam_dbg_err("INVALID pair[%s,%s] %dx%d",
4978 check_pair_name[i][0], check_pair_name[i][1],
4979 check_pair_value[i][0], check_pair_value[i][1]);
4980 if (err_attr_name) {
4981 *err_attr_name = err_name;
4989 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4992 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
4993 int current_width = 0;
4994 int current_height = 0;
4996 mm_camcorder_get_attributes(handle, NULL,
4997 MMCAM_CAMERA_WIDTH, ¤t_width,
4998 MMCAM_CAMERA_HEIGHT, ¤t_height,
5001 if (current_width != check_pair_value[i][0] ||
5002 current_height != check_pair_value[i][1]) {
5003 hcamcorder->resolution_changed = TRUE;
5005 hcamcorder->resolution_changed = FALSE;
5008 _mmcam_dbg_log("resolution changed : %d", hcamcorder->resolution_changed);
5018 /*_mmcam_dbg_log("DONE");*/
5020 return MM_ERROR_NONE;
5024 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5028 if ((void *)handle == NULL) {
5029 _mmcam_dbg_warn("handle %p is NULL", handle);
5033 memset(&info, 0x0, sizeof(MMAttrsInfo));
5035 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5037 switch (info.validity_type) {
5038 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5040 _mmcam_dbg_log("int array count %d", info.int_array.count);
5042 if (info.int_array.count <= 1)
5045 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5047 _mmcam_dbg_log("int range min %d, max %d",info.int_range.min, info.int_range.max);
5049 if (info.int_range.min >= info.int_range.max)
5052 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5054 _mmcam_dbg_log("double array count %d", info.double_array.count);
5056 if (info.double_array.count <= 1)
5059 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5061 _mmcam_dbg_log("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5063 if (info.double_range.min >= info.double_range.max)
5067 _mmcam_dbg_warn("invalid type %d", info.validity_type);