4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 /*=======================================================================================
25 =======================================================================================*/
26 #include "mm_camcorder_internal.h"
27 #include "mm_camcorder_gstcommon.h"
29 #include <gst/video/colorbalance.h>
30 #include <gst/video/cameracontrol.h>
31 #include <gst/video/videooverlay.h>
33 /*-----------------------------------------------------------------------
34 | MACRO DEFINITIONS: |
35 -----------------------------------------------------------------------*/
36 #define MMCAMCORDER_DEFAULT_CAMERA_WIDTH 640
37 #define MMCAMCORDER_DEFAULT_CAMERA_HEIGHT 480
38 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE (1024*1024*10)
39 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL 1000
40 #define MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL 89.0
42 /*---------------------------------------------------------------------------------------
43 | GLOBAL VARIABLE DEFINITIONS for internal |
44 ---------------------------------------------------------------------------------------*/
46 /*-----------------------------------------------------------------------
47 | LOCAL VARIABLE DEFINITIONS for internal |
48 -----------------------------------------------------------------------*/
49 /* Readonly attributes list.
50 * If you want to make some attributes read only, write down here.
51 * It will make them read only after composing whole attributes.
54 static int readonly_attributes[] = {
55 MM_CAM_CAMERA_DEVICE_COUNT,
56 MM_CAM_CAMERA_DEVICE_NAME,
57 MM_CAM_CAMERA_FACING_DIRECTION,
58 MM_CAM_CAMERA_SHUTTER_SPEED,
59 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
60 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
61 MM_CAM_CAPTURED_SCREENNAIL,
62 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
63 MM_CAM_SUPPORT_ZSL_CAPTURE,
64 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
65 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB
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 int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
77 /*=======================================================================
78 | FUNCTION DEFINITIONS |
79 =======================================================================*/
80 /*-----------------------------------------------------------------------
81 | GLOBAL FUNCTION DEFINITIONS: |
82 -----------------------------------------------------------------------*/
84 _mmcamcorder_alloc_attribute(MMHandleType handle)
88 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
89 MMHandleType attrs = NULL;
90 MMAttrsConstructInfo *attrs_const_info;
91 unsigned int attr_count = 0;
93 int ret = MM_ERROR_NONE;
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 'MMAttrsConstructInfo' */
119 attr_count = MM_CAM_ATTRIBUTE_NUM;
120 attrs_const_info = malloc(attr_count * sizeof(MMAttrsConstructInfo));
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 MM_ATTRS_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 MM_ATTRS_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 MM_ATTRS_TYPE_DOUBLE,
265 {.value_double = 1.0},
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 MM_ATTRS_TYPE_DOUBLE,
387 {.value_double = 1.0},
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 MM_ATTRS_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 MM_ATTRS_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 MM_ATTRS_TYPE_STRING,
909 MM_ATTRS_VALID_TYPE_NONE,
912 _mmcamcorder_commit_tag,
918 MM_ATTRS_TYPE_DOUBLE,
920 {.value_double = 0.0},
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 MM_ATTRS_TYPE_DOUBLE,
931 {.value_double = 0.0},
932 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
933 {.double_min = -360.0},
934 {.double_max = 360.0},
935 _mmcamcorder_commit_tag,
940 MM_ATTRS_TYPE_DOUBLE,
942 {.value_double = 0.0},
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 MM_ATTRS_TYPE_DOUBLE,
1097 {.value_double = 0.0},
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 MM_ATTRS_TYPE_DOUBLE,
1142 {.value_double = 0.0},
1143 MM_ATTRS_VALID_TYPE_NONE,
1146 _mmcamcorder_commit_tag,
1149 MM_CAM_TAG_GPS_DATE_STAMP,
1150 "tag-gps-date-stamp",
1151 MM_ATTRS_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 MM_ATTRS_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",
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",
1287 MM_ATTRS_VALID_TYPE_NONE,
1293 MM_CAM_DISPLAY_EVAS_SURFACE_SINK,
1294 "display-evas-surface-sink",
1295 MM_ATTRS_TYPE_STRING,
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 MM_ATTRS_TYPE_STRING,
1509 MM_ATTRS_VALID_TYPE_NONE,
1520 MM_ATTRS_VALID_TYPE_INT_RANGE,
1522 {.int_max = _MMCAMCORDER_MAX_INT},
1526 MM_CAM_ROOT_DIRECTORY,
1528 MM_ATTRS_TYPE_STRING,
1531 MM_ATTRS_VALID_TYPE_NONE,
1537 MM_CAM_SOUND_STREAM_INDEX,
1538 "sound-stream-index",
1542 MM_ATTRS_VALID_TYPE_INT_RANGE,
1544 {.int_max = _MMCAMCORDER_MAX_INT},
1548 MM_CAM_SOUND_STREAM_TYPE,
1549 "sound-stream-type",
1550 MM_ATTRS_TYPE_STRING,
1553 MM_ATTRS_VALID_TYPE_NONE,
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",
1575 MM_ATTRS_VALID_TYPE_NONE,
1581 MM_CAM_GDBUS_CONNECTION,
1586 MM_ATTRS_VALID_TYPE_NONE,
1592 MM_CAM_AUDIO_REPLAY_GAIN_ENABLE,
1593 "audio-replay-gain-enable",
1597 MM_ATTRS_VALID_TYPE_INT_RANGE,
1600 _mmcamcorder_commit_audio_replay_gain,
1603 MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL,
1604 "audio-replay-gain-reference-level",
1605 MM_ATTRS_TYPE_DOUBLE,
1607 {.value_double = MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL},
1608 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1609 {.double_min = 0.0},
1610 {.double_max = 150.0},
1611 _mmcamcorder_commit_audio_replay_gain,
1614 MM_CAM_SUPPORT_USER_BUFFER,
1615 "support-user-buffer",
1619 MM_ATTRS_VALID_TYPE_INT_RANGE,
1625 MM_CAM_USER_BUFFER_FD,
1630 MM_ATTRS_VALID_TYPE_NONE,
1637 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1639 for (idx = 0 ; idx < attr_count ; idx++) {
1640 /* attribute order check. This should be same. */
1641 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1642 _mmcam_dbg_err("Please check attributes order. Is the idx same with enum val?");
1643 free(attrs_const_info);
1644 attrs_const_info = NULL;
1645 free(hcamcorder->cam_attrs_const_info);
1646 hcamcorder->cam_attrs_const_info = NULL;
1650 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1651 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1652 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1653 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1656 /* Camcorder Attributes */
1657 _mmcam_dbg_log("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1659 ret = mm_attrs_new(attrs_const_info,
1661 "Camcorder_Attributes",
1662 _mmcamcorder_commit_camcorder_attrs,
1666 free(attrs_const_info);
1667 attrs_const_info = NULL;
1669 if (ret != MM_ERROR_NONE) {
1670 _mmcam_dbg_err("Fail to alloc attribute handle");
1671 free(hcamcorder->cam_attrs_const_info);
1672 hcamcorder->cam_attrs_const_info = NULL;
1676 __mmcamcorder_set_conf_to_valid_info(handle);
1678 for (idx = 0; idx < attr_count; idx++) {
1679 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1682 _mmcam_dbg_log("Valid type [%s:%d, %d, %d]",
1683 attr_info->name, attr_info->validity_type,
1684 attr_info->validity_value1, attr_info->validity_value2);
1686 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1688 switch (attr_info->validity_type) {
1689 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1690 if (attr_info->validity_value_1.int_array &&
1691 attr_info->validity_value_2.count > 0) {
1692 mm_attrs_set_valid_array(attrs, idx,
1693 (const int *)(attr_info->validity_value_1.int_array),
1694 attr_info->validity_value_2.count,
1695 attr_info->default_value.value_int);
1698 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1699 mm_attrs_set_valid_range(attrs, idx,
1700 attr_info->validity_value_1.int_min,
1701 attr_info->validity_value_2.int_max,
1702 attr_info->default_value.value_int);
1704 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1705 if (attr_info->validity_value_1.double_array &&
1706 attr_info->validity_value_2.count > 0) {
1707 mm_attrs_set_valid_double_array(attrs, idx,
1708 (const double *)(attr_info->validity_value_1.double_array),
1709 attr_info->validity_value_2.count,
1710 attr_info->default_value.value_double);
1713 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1714 mm_attrs_set_valid_double_range(attrs, idx,
1715 attr_info->validity_value_1.double_min,
1716 attr_info->validity_value_2.double_max,
1717 attr_info->default_value.value_double);
1719 case MM_ATTRS_VALID_TYPE_NONE:
1721 case MM_ATTRS_VALID_TYPE_INVALID:
1723 _mmcam_dbg_err("Valid type error.");
1728 __mmcamcorder_release_conf_valid_info(handle);
1735 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1737 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1739 if (hcamcorder == NULL) {
1740 _mmcam_dbg_err("handle is NULL");
1747 mm_attrs_free(attrs);
1748 _mmcam_dbg_log("released attribute");
1751 if (hcamcorder->cam_attrs_const_info) {
1752 free(hcamcorder->cam_attrs_const_info);
1753 hcamcorder->cam_attrs_const_info = NULL;
1754 _mmcam_dbg_log("released attribute info");
1762 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1764 MMHandleType attrs = 0;
1765 int ret = MM_ERROR_NONE;
1767 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1768 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1770 attrs = MMF_CAMCORDER_ATTRS(handle);
1771 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1773 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1780 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1782 MMHandleType attrs = 0;
1783 int ret = MM_ERROR_NONE;
1785 char *tmp_err_attr_name = NULL;
1786 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1787 va_list var_args_copy;
1789 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1791 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1792 _mmcam_dbg_err("Another command is running.");
1793 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1796 /* copy var_args to keep original var_args */
1797 va_copy(var_args_copy, var_args);
1799 attrs = MMF_CAMCORDER_ATTRS(handle);
1801 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1803 _mmcam_dbg_err("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1804 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1807 if (ret == MM_ERROR_NONE) {
1808 hcamcorder->error_code = MM_ERROR_NONE;
1809 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1810 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1813 va_end(var_args_copy);
1815 _MMCAMCORDER_UNLOCK_CMD(handle);
1817 if (ret != MM_ERROR_NONE) {
1818 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1819 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1820 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1821 _mmcam_dbg_err("[%s] is supported, but value is invalid",
1822 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1823 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1827 if (hcamcorder->error_code != MM_ERROR_NONE) {
1828 _mmcam_dbg_err("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1829 ret = hcamcorder->error_code;
1830 hcamcorder->error_code = MM_ERROR_NONE;
1833 _mmcam_dbg_err("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1836 if (tmp_err_attr_name) {
1837 if (!err_attr_name) {
1838 _mmcam_dbg_err("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1839 free(tmp_err_attr_name);
1840 tmp_err_attr_name = NULL;
1842 *err_attr_name = tmp_err_attr_name;
1851 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1853 MMHandleType attrs = 0;
1854 MMAttrsInfo attrinfo;
1855 int ret = MM_ERROR_NONE;
1857 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1858 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1859 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1861 attrs = MMF_CAMCORDER_ATTRS(handle);
1862 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1864 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1866 if (ret == MM_ERROR_NONE) {
1867 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1868 info->type = attrinfo.type;
1869 info->flag = attrinfo.flag;
1870 info->validity_type = attrinfo.validity_type;
1872 switch (attrinfo.validity_type) {
1873 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1874 info->int_array.array = attrinfo.int_array.array;
1875 info->int_array.count = attrinfo.int_array.count;
1876 info->int_array.def = attrinfo.int_array.dval;
1878 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1879 info->int_range.min = attrinfo.int_range.min;
1880 info->int_range.max = attrinfo.int_range.max;
1881 info->int_range.def = attrinfo.int_range.dval;
1883 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1884 info->double_array.array = attrinfo.double_array.array;
1885 info->double_array.count = attrinfo.double_array.count;
1886 info->double_array.def = attrinfo.double_array.dval;
1888 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1889 info->double_range.min = attrinfo.double_range.min;
1890 info->double_range.max = attrinfo.double_range.max;
1891 info->double_range.def = attrinfo.double_range.dval;
1893 case MM_ATTRS_VALID_TYPE_NONE:
1895 case MM_ATTRS_VALID_TYPE_INVALID:
1906 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1909 mmf_camcorder_t *hcamcorder = NULL;
1911 mmf_return_val_if_fail(commit_param, FALSE);
1912 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1913 mmf_return_val_if_fail(attr_name, FALSE);
1914 mmf_return_val_if_fail(value, FALSE);
1916 hcamcorder = MMF_CAMCORDER(commit_param);
1918 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1919 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1927 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1930 int total_count = 0;
1932 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1934 if (hcamcorder == NULL) {
1935 _mmcam_dbg_err("handle is NULL");
1936 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1940 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
1941 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
1942 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
1945 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
1946 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
1947 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
1950 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
1951 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
1952 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
1955 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
1956 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
1957 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
1959 return MM_ERROR_NONE;
1963 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
1965 int *allocated_memory = NULL;
1967 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1969 if (hcamcorder == NULL) {
1970 _mmcam_dbg_err("handle is NULL");
1971 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1974 _mmcam_dbg_log("START");
1976 /* Audio encoder info */
1977 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
1978 if (allocated_memory) {
1979 free(allocated_memory);
1980 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
1981 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
1984 /* Video encoder info */
1985 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
1986 if (allocated_memory) {
1987 free(allocated_memory);
1988 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
1989 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
1992 /* Image encoder info */
1993 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
1994 if (allocated_memory) {
1995 free(allocated_memory);
1996 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
1997 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2000 /* File format info */
2001 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2002 if (allocated_memory) {
2003 free(allocated_memory);
2004 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2005 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2008 _mmcam_dbg_log("DONE");
2010 return MM_ERROR_NONE;
2014 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2016 MMHandleType attr = 0;
2017 int current_state = MM_CAMCORDER_STATE_NONE;
2019 mmf_return_val_if_fail(handle && value, FALSE);
2021 attr = MMF_CAMCORDER_ATTRS(handle);
2022 mmf_return_val_if_fail(attr, FALSE);
2024 /*_mmcam_dbg_log("(%d)", attr_idx);*/
2026 current_state = _mmcamcorder_get_state(handle);
2027 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2028 int flags = MM_ATTRS_FLAG_NONE;
2029 int capture_width, capture_height;
2030 MMCamAttrsInfo info;
2032 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2035 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2036 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2037 capture_width = value->value.i_val;
2039 /* Check whether they are valid pair */
2040 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2045 _mmcam_dbg_log("Capture resolution can't be set.(state=%d)", current_state);
2051 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2053 int current_state = MM_CAMCORDER_STATE_NONE;
2055 current_state = _mmcamcorder_get_state(handle);
2057 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2058 int capture_width, capture_height;
2060 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2061 capture_height = value->value.i_val;
2063 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2065 _mmcam_dbg_log("Capture resolution can't be set.(state=%d)", current_state);
2072 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2074 int current_state = 0;
2076 const char *videosrc_name = NULL;
2077 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2078 _MMCamcorderSubContext *sc = NULL;
2079 _MMCamcorderImageInfo *info = NULL;
2080 GstCameraControl *control = NULL;
2081 type_element *VideosrcElement = NULL;
2083 mmf_return_val_if_fail(handle && value, FALSE);
2085 current_state = _mmcamcorder_get_state(handle);
2086 ivalue = value->value.i_val;
2088 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2089 CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
2092 _mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
2094 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2098 info = sc->info_image;
2100 _mmcam_dbg_err("info image is NULL");
2104 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2105 if (info->capture_send_count > 0) {
2106 info->capturing = FALSE;
2107 _mmcam_dbg_warn("capturing -> FALSE and skip capture callback since now");
2110 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2111 _mmcam_dbg_warn("Can't cast Video source into camera control.");
2115 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2117 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2118 _mmcam_dbg_warn("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2120 _mmcam_dbg_warn("cast CAMERA_CONTROL failed");
2123 _mmcam_dbg_warn("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2130 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2132 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2133 int current_state = MM_CAMCORDER_STATE_NONE;
2134 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2136 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2138 current_state = _mmcamcorder_get_state(handle);
2139 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2141 _mmcam_dbg_log("current state %d, mode %d, set count %d",
2142 current_state, mode, value->value.i_val);
2144 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2145 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2148 _mmcam_dbg_err("Invalid mode[%d] or state[%d]", mode, current_state);
2154 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2156 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2158 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2160 _mmcam_dbg_log("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2162 /* return error when disable shutter sound if policy is TRUE */
2163 if (!value->value.i_val &&
2164 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2165 _mmcam_dbg_err("not permitted DISABLE SHUTTER SOUND");
2168 _mmcam_dbg_log("set value [%d] success", value->value.i_val);
2174 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2176 int current_state = MM_CAMCORDER_STATE_NONE;
2177 _MMCamcorderSubContext *sc = NULL;
2180 mmf_return_val_if_fail(handle && value, FALSE);
2182 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2186 current_state = _mmcamcorder_get_state(handle);
2188 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2189 double mslNewVal = 0;
2190 mslNewVal = value->value.d_val;
2192 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2193 if (mslNewVal == 0.0) {
2194 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2195 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2197 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2198 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2202 _mmcam_dbg_log("Commit : volume(%f)", mslNewVal);
2205 _mmcam_dbg_log("Commit : nothing to commit. status(%d)", current_state);
2213 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2215 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2216 int current_state = MM_CAMCORDER_STATE_NONE;
2218 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2220 current_state = _mmcamcorder_get_state(handle);
2221 if (current_state > MM_CAMCORDER_STATE_READY) {
2222 _mmcam_dbg_err("invalid state %d", current_state);
2223 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2231 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2233 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2234 MMCamAttrsInfo fps_info;
2235 int resolution_width = 0;
2236 int resolution_height = 0;
2239 int current_state = MM_CAMCORDER_STATE_NONE;
2241 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2243 current_state = _mmcamcorder_get_state(handle);
2244 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2245 _mmcam_dbg_err("invalid state %d", current_state);
2246 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2250 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2253 _mmcam_dbg_log("FPS(%d)", value->value.i_val);
2255 ret = mm_camcorder_get_attributes(handle, NULL,
2256 MMCAM_CAMERA_WIDTH, &resolution_width,
2257 MMCAM_CAMERA_HEIGHT, &resolution_height,
2260 if (ret != MM_ERROR_NONE) {
2261 _mmcam_dbg_err("FAILED : coult not get resolution values.");
2265 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2266 if (ret != MM_ERROR_NONE) {
2267 _mmcam_dbg_err("FAILED : coult not get FPS values by resolution.");
2271 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2272 if (value->value.i_val == fps_info.int_array.array[i])
2276 _mmcam_dbg_err("FAILED : %d is not supported FPS", value->value.i_val);
2282 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2284 int current_state = MM_CAMCORDER_STATE_NONE;
2285 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2286 _MMCamcorderSubContext *sc = NULL;
2288 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2290 current_state = _mmcamcorder_get_state(handle);
2291 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2292 _mmcam_dbg_warn("invalid state %d", current_state);
2293 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2297 /* Verify recording motion rate */
2298 if (value->value.d_val > 0.0) {
2299 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2303 /* set is_slow flag */
2304 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2305 sc->is_modified_rate = TRUE;
2307 sc->is_modified_rate = FALSE;
2309 _mmcam_dbg_log("Set slow motion rate %lf", value->value.d_val);
2312 _mmcam_dbg_warn("Failed to set recording motion rate %lf", value->value.d_val);
2318 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2320 MMHandleType attr = 0;
2321 int current_state = MM_CAMCORDER_STATE_NONE;
2323 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2324 _MMCamcorderSubContext *sc = NULL;
2326 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2328 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2332 attr = MMF_CAMCORDER_ATTRS(handle);
2333 mmf_return_val_if_fail(attr, FALSE);
2335 _mmcam_dbg_log("Width(%d)", value->value.i_val);
2337 current_state = _mmcamcorder_get_state(handle);
2339 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2340 _mmcam_dbg_log("Resolution can't be changed.(state=%d)", current_state);
2343 int flags = MM_ATTRS_FLAG_NONE;
2344 MMCamAttrsInfo info;
2345 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2348 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2349 int width = value->value.i_val;
2351 int preview_format = MM_PIXEL_FORMAT_NV12;
2352 int codec_type = MM_IMAGE_CODEC_JPEG;
2354 mm_camcorder_get_attributes(handle, NULL,
2355 MMCAM_CAMERA_HEIGHT, &height,
2356 MMCAM_CAMERA_FORMAT, &preview_format,
2357 MMCAM_IMAGE_ENCODER, &codec_type,
2360 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2361 if (hcamcorder->resolution_changed == FALSE) {
2362 _mmcam_dbg_log("no need to restart preview");
2366 hcamcorder->resolution_changed = FALSE;
2368 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2369 _mmcam_dbg_log("restart preview");
2371 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2372 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2374 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2376 /* check decoder recreation */
2377 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2378 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2379 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2383 /* get preview format */
2384 sc->info_image->preview_format = preview_format;
2385 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2386 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2388 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2389 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2391 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2394 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2396 _mmcam_dbg_err("currently locked for preview restart");
2400 /* get preview format */
2401 sc->info_image->preview_format = preview_format;
2402 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2403 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2414 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2417 int current_state = MM_CAMCORDER_STATE_NONE;
2418 MMHandleType attr = 0;
2419 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2420 _MMCamcorderSubContext *sc = NULL;
2422 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2424 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2428 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2429 mmf_return_val_if_fail(attr, FALSE);
2431 _mmcam_dbg_log("Height(%d)", value->value.i_val);
2432 current_state = _mmcamcorder_get_state(handle);
2434 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2435 _mmcam_dbg_log("Resolution can't be changed.(state=%d)", current_state);
2436 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2440 int height = value->value.i_val;
2441 int preview_format = MM_PIXEL_FORMAT_NV12;
2442 int codec_type = MM_IMAGE_CODEC_JPEG;
2443 int video_stabilization = 0;
2445 mm_camcorder_get_attributes(handle, NULL,
2446 MMCAM_CAMERA_WIDTH, &width,
2447 MMCAM_CAMERA_FORMAT, &preview_format,
2448 MMCAM_IMAGE_ENCODER, &codec_type,
2449 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2452 sc->info_video->preview_width = width;
2453 sc->info_video->preview_height = height;
2455 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2456 if (hcamcorder->resolution_changed == FALSE) {
2457 _mmcam_dbg_log("no need to restart preview");
2461 hcamcorder->resolution_changed = FALSE;
2463 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2464 _mmcam_dbg_log("restart preview");
2466 _mmcam_dbg_log("set empty buffers");
2468 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2469 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2471 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2473 /* check decoder recreation */
2474 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2475 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2476 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2480 /* get preview format */
2481 sc->info_image->preview_format = preview_format;
2482 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2484 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2486 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2487 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2489 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2492 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2494 _mmcam_dbg_err("currently locked for preview restart");
2498 /* get preview format */
2499 sc->info_image->preview_format = preview_format;
2500 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2501 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2509 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2511 int current_state = MM_CAMCORDER_STATE_NONE;
2512 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2514 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2516 current_state = _mmcamcorder_get_state(handle);
2517 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2518 _mmcam_dbg_err("Video Resolution can't be changed.(state=%d)", current_state);
2519 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2522 _mmcam_dbg_warn("Video Resolution %d [attr_idx %d] ",
2523 value->value.i_val, attr_idx);
2529 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2531 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2532 _MMCamcorderSubContext *sc = NULL;
2533 int current_state = MM_CAMCORDER_STATE_NONE;
2534 GstCameraControl *control = NULL;
2538 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2540 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2544 zoom_level = value->value.i_val;
2546 _mmcam_dbg_log("(%d)", attr_idx);
2548 current_state = _mmcamcorder_get_state(handle);
2549 if (current_state < MM_CAMCORDER_STATE_READY) {
2550 _mmcam_dbg_log("will be applied when preview starts");
2552 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2553 _mmcam_dbg_err("Can not set while CAPTURING");
2554 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2558 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2559 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2561 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2563 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2566 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2567 _mmcam_dbg_log("Can't cast Video source into camera control.");
2571 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2572 if (control == NULL) {
2573 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2577 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2579 _mmcam_dbg_log("Succeed in operating Zoom[%d].", zoom_level);
2582 _mmcam_dbg_warn("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2585 _mmcam_dbg_log("pointer of video src is null");
2592 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2594 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2595 _MMCamcorderSubContext *sc = NULL;
2596 int current_state = MM_CAMCORDER_STATE_NONE;
2598 GstCameraControl *CameraControl = NULL;
2599 GstCameraControlChannel *CameraControlChannel = NULL;
2600 const GList *controls = NULL;
2601 const GList *item = NULL;
2603 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2605 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2606 mmf_return_val_if_fail(sc, TRUE);
2608 _mmcam_dbg_log("ptz type : %d", value->value.i_val);
2610 current_state = _mmcamcorder_get_state(handle);
2611 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2612 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2613 _mmcam_dbg_err("invalid state[%d]", current_state);
2614 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2618 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2619 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2620 _mmcam_dbg_log("Can't cast Video source into camera control.");
2624 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2625 if (CameraControl == NULL) {
2626 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2630 controls = gst_camera_control_list_channels(CameraControl);
2631 if (controls == NULL) {
2632 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2636 for (item = controls ; item && item->data ; item = item->next) {
2637 CameraControlChannel = item->data;
2638 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2639 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2640 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2641 _mmcam_dbg_warn("set ptz type %d done", value->value.i_val);
2644 _mmcam_dbg_err("failed to set ptz type %d", value->value.i_val);
2650 _mmcam_dbg_warn("failed to find ptz type control channel");
2657 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2659 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2660 _MMCamcorderSubContext *sc = NULL;
2661 int current_state = MM_CAMCORDER_STATE_NONE;
2663 GstCameraControl *CameraControl = NULL;
2664 GstCameraControlChannel *CameraControlChannel = NULL;
2665 const GList *controls = NULL;
2666 const GList *item = NULL;
2668 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2670 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2671 mmf_return_val_if_fail(sc, TRUE);
2673 _mmcam_dbg_log("pan : %d", value->value.i_val);
2675 current_state = _mmcamcorder_get_state(handle);
2676 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2677 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2678 _mmcam_dbg_err("invalid state[%d]", current_state);
2679 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2683 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2684 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2685 _mmcam_dbg_log("Can't cast Video source into camera control.");
2689 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2690 if (CameraControl == NULL) {
2691 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2695 controls = gst_camera_control_list_channels(CameraControl);
2696 if (controls == NULL) {
2697 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2701 for (item = controls ; item && item->data ; item = item->next) {
2702 CameraControlChannel = item->data;
2703 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2704 if (!strcmp(CameraControlChannel->label, "pan")) {
2705 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2706 _mmcam_dbg_warn("set pan %d done", value->value.i_val);
2709 _mmcam_dbg_err("failed to set pan %d", value->value.i_val);
2715 _mmcam_dbg_warn("failed to find pan control channel");
2722 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2724 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2725 _MMCamcorderSubContext *sc = NULL;
2726 int current_state = MM_CAMCORDER_STATE_NONE;
2728 GstCameraControl *CameraControl = NULL;
2729 GstCameraControlChannel *CameraControlChannel = NULL;
2730 const GList *controls = NULL;
2731 const GList *item = NULL;
2733 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2735 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2736 mmf_return_val_if_fail(sc, TRUE);
2738 _mmcam_dbg_log("tilt : %d", value->value.i_val);
2740 current_state = _mmcamcorder_get_state(handle);
2741 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2742 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2743 _mmcam_dbg_err("invalid state[%d]", current_state);
2744 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2748 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2749 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2750 _mmcam_dbg_log("Can't cast Video source into camera control.");
2754 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2755 if (CameraControl == NULL) {
2756 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2760 controls = gst_camera_control_list_channels(CameraControl);
2761 if (controls == NULL) {
2762 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2766 for (item = controls ; item && item->data ; item = item->next) {
2767 CameraControlChannel = item->data;
2768 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2769 if (!strcmp(CameraControlChannel->label, "tilt")) {
2770 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2771 _mmcam_dbg_warn("set tilt %d done", value->value.i_val);
2774 _mmcam_dbg_err("failed to set tilt %d", value->value.i_val);
2780 _mmcam_dbg_warn("failed to find tilt control channel");
2787 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2789 MMHandleType attr = 0;
2790 int current_state = MM_CAMCORDER_STATE_NONE;
2791 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2792 _MMCamcorderSubContext *sc = NULL;
2793 GstCameraControl *control = NULL;
2795 int set_focus_mode = 0;
2796 int cur_focus_mode = 0;
2797 int cur_focus_range = 0;
2799 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2801 attr = MMF_CAMCORDER_ATTRS(handle);
2802 mmf_return_val_if_fail(attr, FALSE);
2804 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2808 _mmcam_dbg_log("Focus mode(%d)", value->value.i_val);
2810 /* check whether set or not */
2811 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2812 _mmcam_dbg_log("skip set value %d", value->value.i_val);
2816 current_state = _mmcamcorder_get_state(handle);
2817 if (current_state < MM_CAMCORDER_STATE_NULL) {
2818 _mmcam_dbg_log("Focus mode will be changed later.(state=%d)", current_state);
2820 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2821 _mmcam_dbg_err("Can not set while CAPTURING");
2822 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2826 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2827 int flags = MM_ATTRS_FLAG_NONE;
2828 MMCamAttrsInfo info;
2830 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2831 _mmcam_dbg_log("Can't cast Video source into camera control.");
2835 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2836 if (control == NULL) {
2837 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2841 mslVal = value->value.i_val;
2842 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2844 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2847 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2848 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2849 if (set_focus_mode != cur_focus_mode) {
2850 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2851 _mmcam_dbg_log("Succeed in setting AF mode[%d]", mslVal);
2854 _mmcam_dbg_warn("Failed to set AF mode[%d]", mslVal);
2857 _mmcam_dbg_log("No need to set AF mode. Current[%d]", mslVal);
2861 _mmcam_dbg_warn("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2865 _mmcam_dbg_log("pointer of video src is null");
2872 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2874 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2875 _MMCamcorderSubContext *sc = NULL;
2876 GstCameraControl *control = NULL;
2877 int current_state = MM_CAMCORDER_STATE_NONE;
2880 int cur_focus_mode = 0;
2881 int cur_focus_range = 0;
2882 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2883 int converted_mode = 0;
2885 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2887 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2891 _mmcam_dbg_log("(%d)", attr_idx);
2893 /* check whether set or not */
2894 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2895 _mmcam_dbg_log("skip set value %d", value->value.i_val);
2899 mslVal = value->value.i_val;
2900 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2902 current_state = _mmcamcorder_get_state(handle);
2903 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2904 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
2906 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2907 _mmcam_dbg_err("Can not set while CAPTURING");
2908 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2912 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2913 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2914 _mmcam_dbg_log("Can't cast Video source into camera control.");
2918 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2919 if (control == NULL) {
2920 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2924 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
2925 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
2927 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2928 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
2929 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
2930 /*_mmcam_dbg_log("Succeed in setting AF mode[%d]", mslVal);*/
2933 _mmcam_dbg_warn("Failed to set AF mode[%d]", mslVal);
2936 /*_mmcam_dbg_log("No need to set AF mode. Current[%d]", mslVal);*/
2940 _mmcam_dbg_warn("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2943 _mmcam_dbg_log("pointer of video src is null");
2950 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2952 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2953 _MMCamcorderSubContext *sc = NULL;
2954 GstCameraControl *control = NULL;
2955 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
2956 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
2958 int current_state = MM_CAMCORDER_STATE_NONE;
2960 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2962 gboolean do_set = FALSE;
2964 MMCamAttrsInfo info_y;
2965 MMCamAttrsInfo info_w;
2966 MMCamAttrsInfo info_h;
2968 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2970 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2974 _mmcam_dbg_log("(%d)", attr_idx);
2976 current_state = _mmcamcorder_get_state(handle);
2977 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2978 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
2980 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2981 _mmcam_dbg_err("Can not set while CAPTURING");
2982 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2986 ret = mm_camcorder_get_attributes(handle, NULL,
2987 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2989 if (ret != MM_ERROR_NONE) {
2990 _mmcam_dbg_warn("Failed to get FOCUS MODE.[%x]", ret);
2994 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
2995 _mmcam_dbg_warn("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
2999 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3000 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3001 _mmcam_dbg_log("Can't cast Video source into camera control.");
3005 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3006 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3007 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3010 case MM_CAM_CAMERA_AF_TOUCH_X:
3011 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3012 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3013 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3014 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3015 set_area.x = value->value.i_val;
3016 mm_camcorder_get_attributes(handle, NULL,
3017 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3018 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3019 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3023 _mmcam_dbg_log("Just store AF area[x:%d]", value->value.i_val);
3027 case MM_CAM_CAMERA_AF_TOUCH_Y:
3028 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3029 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3030 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3031 set_area.y = value->value.i_val;
3032 mm_camcorder_get_attributes(handle, NULL,
3033 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3034 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3035 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3039 _mmcam_dbg_log("Just store AF area[y:%d]", value->value.i_val);
3043 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3044 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3045 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3046 set_area.width = value->value.i_val;
3047 mm_camcorder_get_attributes(handle, NULL,
3048 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3049 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3050 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3054 _mmcam_dbg_log("Just store AF area[width:%d]", value->value.i_val);
3058 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3059 set_area.height = value->value.i_val;
3060 mm_camcorder_get_attributes(handle, NULL,
3061 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3062 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3063 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3072 _MMCamcorderVideoInfo *info = sc->info_video;
3075 _mmcam_dbg_err("video info is NULL");
3079 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3080 if (control == NULL) {
3081 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3086 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3087 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3088 float ratio_width = 0.0;
3089 float ratio_height = 0.0;
3091 if (info->preview_width != 0 && info->preview_height != 0) {
3092 ratio_width = (float)info->video_width / (float)info->preview_width;
3093 ratio_height = (float)info->video_height / (float)info->preview_height;
3095 _mmcam_dbg_log("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3096 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3098 set_area.x = (int)((float)set_area.x * ratio_width);
3099 set_area.y = (int)((float)set_area.y * ratio_height);
3100 set_area.width = (int)((float)set_area.width * ratio_width);
3101 set_area.height = (int)((float)set_area.height * ratio_height);
3103 if (set_area.width <= 0)
3106 if (set_area.height <= 0)
3107 set_area.height = 1;
3109 _mmcam_dbg_log("converted area %d,%d,%dx%d",
3110 set_area.x, set_area.y, set_area.width, set_area.height);
3112 _mmcam_dbg_warn("invalid preview size %dx%d, skip AF area converting",
3113 info->preview_width, info->preview_height);
3117 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3119 _mmcam_dbg_warn("Failed to get AF area");
3123 /* width and height are not supported now */
3124 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3125 _mmcam_dbg_log("No need to set AF area[x,y:%d,%d]",
3126 get_area.x, get_area.y);
3130 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3132 _mmcam_dbg_log("Succeed to set AF area[%d,%d,%dx%d]",
3133 set_area.x, set_area.y, set_area.width, set_area.height);
3136 _mmcam_dbg_warn("Failed to set AF area[%d,%d,%dx%d]",
3137 set_area.x, set_area.y, set_area.width, set_area.height);
3141 _mmcam_dbg_log("pointer of video src is null");
3148 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3150 GstCameraControl *control = NULL;
3156 int exposure_type = 0;
3157 int current_state = MM_CAMCORDER_STATE_NONE;
3158 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3159 _MMCamcorderSubContext *sc = NULL;
3161 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3162 gboolean check_scene_mode = FALSE;
3164 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3166 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3170 /* check whether set or not */
3171 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3172 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3176 current_state = _mmcamcorder_get_state(handle);
3177 if (current_state < MM_CAMCORDER_STATE_READY) {
3178 _mmcam_dbg_log("will be applied when preview starts");
3180 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3181 _mmcam_dbg_err("Can not set while CAPTURING");
3182 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3186 ivalue = value->value.i_val;
3188 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3189 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3190 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3191 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3192 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3193 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3194 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3195 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3196 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3197 exposure_type = GST_CAMERA_CONTROL_ISO;
3199 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3200 check_scene_mode = TRUE;
3201 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3202 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3204 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3205 check_scene_mode = TRUE;
3206 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3207 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3208 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3209 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3212 if (check_scene_mode) {
3213 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3214 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3215 _mmcam_dbg_warn("can not set [%d] when scene mode is NOT normal.", attr_idx);
3220 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3223 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3224 _mmcam_dbg_log("Can't cast Video source into camera control.");
3228 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3229 if (control == NULL) {
3230 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3234 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3236 _mmcam_dbg_log("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3239 _mmcam_dbg_warn("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3242 _mmcam_dbg_log("pointer of video src is null");
3249 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3251 GstCameraControl *control = NULL;
3255 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3256 _MMCamcorderSubContext *sc = NULL;
3257 int current_state = MM_CAMCORDER_STATE_NONE;
3259 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3261 /* check whether set or not */
3262 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3263 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3267 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3271 /* check current state */
3272 current_state = _mmcamcorder_get_state(handle);
3273 if (current_state < MM_CAMCORDER_STATE_READY) {
3274 _mmcam_dbg_log("will be applied when preview starts");
3276 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3277 _mmcam_dbg_err("Can not set while CAPTURING");
3278 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3282 mslVal = value->value.i_val;
3283 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3285 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3286 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3287 _mmcam_dbg_log("Can't cast Video source into camera control.");
3291 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3292 if (control == NULL) {
3293 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3297 if (gst_camera_control_get_wdr(control, &cur_value)) {
3298 if (newVal != cur_value) {
3299 if (gst_camera_control_set_wdr(control, newVal)) {
3300 _mmcam_dbg_log("Success - set wdr[%d]", mslVal);
3303 _mmcam_dbg_warn("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3306 _mmcam_dbg_log("No need to set new WDR. Current[%d]", mslVal);
3310 _mmcam_dbg_warn("Failed to get WDR.");
3313 _mmcam_dbg_log("pointer of video src is null");
3320 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3322 int current_state = MM_CAMCORDER_STATE_NONE;
3323 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3325 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3327 /* check whether set or not */
3328 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3329 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3333 current_state = _mmcamcorder_get_state(handle);
3334 if (current_state < MM_CAMCORDER_STATE_READY) {
3335 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3337 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3338 _mmcam_dbg_err("Invaild state (state %d)", current_state);
3339 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3343 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3347 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3351 int current_state = MM_CAMCORDER_STATE_NONE;
3352 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3353 _MMCamcorderSubContext *sc = NULL;
3355 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3357 bitrate = value->value.i_val;
3359 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3360 if (!sc || !sc->encode_element) {
3361 _mmcam_dbg_log("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3365 current_state = _mmcamcorder_get_state(handle);
3366 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3367 _mmcam_dbg_err("Can not set while RECORDING - attr idx %d", attr_idx);
3368 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3372 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3373 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3375 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3376 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3378 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3379 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3386 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3388 int current_state = MM_CAMCORDER_STATE_NONE;
3389 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3391 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3393 current_state = _mmcamcorder_get_state(handle);
3394 if (current_state < MM_CAMCORDER_STATE_READY) {
3395 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3397 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3398 _mmcam_dbg_err("Invaild state (state %d)", current_state);
3399 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3403 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3407 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3409 int current_state = MM_CAMCORDER_STATE_NONE;
3410 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3412 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3414 _mmcam_dbg_log("rotate(%d)", value->value.i_val);
3416 current_state = _mmcamcorder_get_state(handle);
3418 if (current_state > MM_CAMCORDER_STATE_READY) {
3419 _mmcam_dbg_err("camera rotation setting failed.(state=%d)", current_state);
3420 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3423 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3428 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3430 int current_state = MM_CAMCORDER_STATE_NONE;
3432 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3433 _MMCamcorderSubContext *sc = NULL;
3435 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3438 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3439 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3443 /* check current state */
3444 current_state = _mmcamcorder_get_state(handle);
3445 if (current_state < MM_CAMCORDER_STATE_READY) {
3446 _mmcam_dbg_log("NOT initialized. this will be applied later");
3448 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3449 _mmcam_dbg_err("Can not set while CAPTURING");
3450 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3454 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3456 _mmcam_dbg_log("Image encoder quality(%d)", value->value.i_val);
3458 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3459 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3462 _mmcam_dbg_err("invalid state %d", current_state);
3468 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3470 mmf_return_val_if_fail(handle && value, FALSE);
3473 if (!value->value.s_val) {
3474 _mmcam_dbg_err("NULL filename");
3478 _mmcam_dbg_log("set filename [%s]", value->value.s_val);
3484 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3486 int current_state = MM_CAMCORDER_STATE_NONE;
3487 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3489 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3491 current_state = _mmcamcorder_get_state(handle);
3492 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3493 _mmcam_dbg_err("Can not set while RECORDING");
3494 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3502 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3504 GstColorBalance *balance = NULL;
3505 GstColorBalanceChannel *Colorchannel = NULL;
3506 const GList *controls = NULL;
3507 const GList *item = NULL;
3510 int current_state = MM_CAMCORDER_STATE_NONE;
3511 const char *control_label = NULL;
3512 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3513 _MMCamcorderSubContext *sc = NULL;
3515 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3516 gboolean check_scene_mode = FALSE;
3518 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3520 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3524 /* check whether set or not */
3525 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3526 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3530 current_state = _mmcamcorder_get_state(handle);
3531 if (current_state < MM_CAMCORDER_STATE_READY) {
3532 _mmcam_dbg_log("will be applied when preview starts");
3534 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3535 _mmcam_dbg_err("Can not set while CAPTURING");
3536 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3540 if (value->type != MM_ATTRS_TYPE_INT) {
3541 _mmcam_dbg_warn("Mismatched value type (%d)", value->type);
3544 mslNewVal = value->value.i_val;
3548 case MM_CAM_FILTER_BRIGHTNESS:
3549 control_label = "brightness";
3550 check_scene_mode = TRUE;
3553 case MM_CAM_FILTER_CONTRAST:
3554 control_label = "contrast";
3557 case MM_CAM_FILTER_WB:
3558 control_label = "white balance";
3559 check_scene_mode = TRUE;
3562 case MM_CAM_FILTER_COLOR_TONE:
3563 control_label = "color tone";
3566 case MM_CAM_FILTER_SATURATION:
3567 control_label = "saturation";
3568 check_scene_mode = TRUE;
3571 case MM_CAM_FILTER_HUE:
3572 control_label = "hue";
3575 case MM_CAM_FILTER_SHARPNESS:
3576 control_label = "sharpness";
3577 check_scene_mode = TRUE;
3580 _mmcam_dbg_err("unknown attribute index %d", attr_idx);
3584 if (check_scene_mode) {
3585 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3586 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3587 _mmcam_dbg_warn("can not set %s when scene mode is NOT normal.", control_label);
3592 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslNewVal);
3593 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3596 /*_mmcam_dbg_log("label(%s): MSL(%d)->Sensor(%d)", control_label, mslNewVal, newVal);*/
3598 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3599 _mmcam_dbg_log("Can't cast Video source into color balance.");
3603 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3604 if (balance == NULL) {
3605 _mmcam_dbg_err("cast COLOR_BALANCE failed");
3609 controls = gst_color_balance_list_channels(balance);
3610 if (controls == NULL) {
3611 _mmcam_dbg_log("There is no list of colorbalance controls");
3615 for (item = controls ; item && item->data ; item = item->next) {
3616 Colorchannel = item->data;
3617 /*_mmcam_dbg_log("Getting name of CID=(%s), input CID=(%s)", Colorchannel->label, control_label);*/
3619 if (!strcmp(Colorchannel->label, control_label)) {
3620 gst_color_balance_set_value(balance, Colorchannel, newVal);
3621 _mmcam_dbg_log("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslNewVal, newVal);
3627 _mmcam_dbg_err("failed to find color channel item");
3635 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3639 int current_state = MM_CAMCORDER_STATE_NONE;
3640 GstCameraControl *control = NULL;
3641 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3642 _MMCamcorderSubContext *sc = NULL;
3644 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3646 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3650 mslVal = value->value.i_val;
3651 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3653 /* check whether set or not */
3654 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3655 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3659 current_state = _mmcamcorder_get_state(handle);
3660 if (current_state < MM_CAMCORDER_STATE_READY) {
3661 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3663 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3664 _mmcam_dbg_err("Can not set while CAPTURING");
3665 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3669 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3672 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3673 _mmcam_dbg_log("Can't cast Video source into camera control.");
3677 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3678 if (control == NULL) {
3679 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3683 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3685 _mmcam_dbg_log("Succeed in setting program mode[%d].", mslVal);
3687 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3691 MM_CAM_FILTER_BRIGHTNESS,
3693 MM_CAM_FILTER_SATURATION,
3694 MM_CAM_FILTER_SHARPNESS,
3695 MM_CAM_FILTER_COLOR_TONE,
3696 MM_CAM_CAMERA_EXPOSURE_MODE
3698 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3700 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3701 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3702 mm_attrs_set_modified(attrs, attr_idxs[i]);
3708 _mmcam_dbg_log("Failed to set program mode[%d].", mslVal);
3711 _mmcam_dbg_warn("pointer of video src is null");
3718 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3720 mmf_return_val_if_fail(handle && value, FALSE);
3722 _mmcam_dbg_warn("Filter Flip(%d)", value->value.i_val);
3728 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3730 mmf_return_val_if_fail(handle && value, FALSE);
3732 _mmcam_dbg_log("Commit : Do nothing. this attr will be removed soon.");
3738 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3740 int current_state = MM_CAMCORDER_STATE_NONE;
3741 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3743 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3745 current_state = _mmcamcorder_get_state(handle);
3746 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3747 _mmcam_dbg_warn("Can NOT Disable AUDIO. invalid state %d", current_state);
3748 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3751 _mmcam_dbg_log("Disable AUDIO when Recording");
3757 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3759 int current_state = MM_CAMCORDER_STATE_NONE;
3760 const char *videosink_name = NULL;
3761 void *p_handle = NULL;
3763 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3764 _MMCamcorderSubContext *sc = NULL;
3766 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3769 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3770 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3774 /* check current state */
3775 current_state = _mmcamcorder_get_state(handle);
3776 if (current_state < MM_CAMCORDER_STATE_READY) {
3777 _mmcam_dbg_log("NOT initialized. this will be applied later");
3781 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3783 p_handle = value->value.p_val;
3785 /* get videosink name */
3786 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3787 if (videosink_name == NULL) {
3788 _mmcam_dbg_err("Please check videosink element in configuration file");
3792 _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name);
3794 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3795 _mmcam_dbg_log("Commit : Set XID[%x]", *(int *)(p_handle));
3796 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(p_handle));
3797 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3798 _mmcam_dbg_log("Commit : Set evas object [%p]", p_handle);
3799 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", p_handle);
3800 } else if (!strcmp(videosink_name, "tizenwlsink")) {
3801 _mmcam_dbg_log("wayland global surface id : %d", *(int *)(p_handle));
3802 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)*(int *)(p_handle));
3804 _mmcam_dbg_warn("Commit : Nothing to commit with this element[%s]", videosink_name);
3808 _mmcam_dbg_warn("Display handle is NULL");
3816 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3818 int current_state = MM_CAMCORDER_STATE_NONE;
3819 const char *videosink_name = NULL;
3821 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3822 _MMCamcorderSubContext *sc = NULL;
3824 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3827 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3828 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3832 /* check current state */
3833 current_state = _mmcamcorder_get_state(handle);
3834 if (current_state < MM_CAMCORDER_STATE_READY) {
3835 _mmcam_dbg_log("NOT initialized. this will be applied later");
3839 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3841 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3842 if (videosink_name == NULL) {
3843 _mmcam_dbg_err("Please check videosink element in configuration file");
3847 _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name);
3849 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3850 _mmcam_dbg_log("Commit : display mode [%d]", value->value.i_val);
3851 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3853 _mmcam_dbg_warn("[%s] does not support display mode, but no error", videosink_name);
3860 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3862 int current_state = MM_CAMCORDER_STATE_NONE;
3864 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3866 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3869 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3870 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3874 /* check current state */
3875 current_state = _mmcamcorder_get_state(handle);
3876 if (current_state < MM_CAMCORDER_STATE_READY) {
3877 _mmcam_dbg_log("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3881 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3885 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3887 int current_state = MM_CAMCORDER_STATE_NONE;
3889 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3891 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3894 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3895 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3899 /* check current state */
3900 current_state = _mmcamcorder_get_state(handle);
3901 if (current_state < MM_CAMCORDER_STATE_READY) {
3902 _mmcam_dbg_log("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3906 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3910 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3912 int current_state = MM_CAMCORDER_STATE_NONE;
3913 const char *videosink_name = NULL;
3915 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3916 _MMCamcorderSubContext *sc = NULL;
3918 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3921 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3922 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3926 /* check current state */
3927 current_state = _mmcamcorder_get_state(handle);
3928 if (current_state < MM_CAMCORDER_STATE_READY) {
3929 _mmcam_dbg_log("NOT initialized. this will be applied later");
3933 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3935 /* Get videosink name */
3936 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3937 if (videosink_name == NULL) {
3938 _mmcam_dbg_err("Please check videosink element in configuration file");
3942 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
3943 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
3944 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
3945 _mmcam_dbg_log("Set visible [%d] done.", value->value.i_val);
3947 _mmcam_dbg_warn("[%s] does not support VISIBLE, but no error", videosink_name);
3954 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3957 int current_state = MM_CAMCORDER_STATE_NONE;
3958 const char *videosink_name = NULL;
3960 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3961 _MMCamcorderSubContext *sc = NULL;
3963 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3966 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3967 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3971 /* check current state */
3972 current_state = _mmcamcorder_get_state(handle);
3973 if (current_state < MM_CAMCORDER_STATE_READY) {
3974 _mmcam_dbg_log("NOT initialized. this will be applied later");
3978 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3980 /* Get videosink name */
3981 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3982 if (videosink_name == NULL) {
3983 _mmcam_dbg_err("Please check videosink element in configuration file");
3987 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
3988 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
3989 !strcmp(videosink_name, "directvideosink")) {
3990 method = value->value.i_val;
3991 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
3993 _mmcam_dbg_warn("[%s] does not support geometry method, but no error", videosink_name);
4000 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4002 int current_state = MM_CAMCORDER_STATE_NONE;
4003 int ret = MM_ERROR_NONE;
4004 const char *videosink_name = NULL;
4006 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4007 _MMCamcorderSubContext *sc = NULL;
4009 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4012 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4013 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
4017 /* check current state */
4018 current_state = _mmcamcorder_get_state(handle);
4019 if (current_state < MM_CAMCORDER_STATE_READY) {
4020 _mmcam_dbg_log("NOT initialized. this will be applied later");
4024 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4026 /* Get videosink name */
4027 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4028 if (videosink_name == NULL) {
4029 _mmcam_dbg_err("Please check videosink element in configuration file");
4033 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4034 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4038 int rect_height = 0;
4039 int flags = MM_ATTRS_FLAG_NONE;
4040 MMCamAttrsInfo info;
4042 mm_camcorder_get_attributes(handle, NULL,
4043 MMCAM_DISPLAY_RECT_X, &rect_x,
4044 MMCAM_DISPLAY_RECT_Y, &rect_y,
4045 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4046 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4049 case MM_CAM_DISPLAY_RECT_X:
4050 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4052 memset(&info, 0x00, sizeof(info));
4053 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4055 memset(&info, 0x00, sizeof(info));
4056 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4059 rect_x = value->value.i_val;
4061 case MM_CAM_DISPLAY_RECT_Y:
4062 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4064 memset(&info, 0x00, sizeof(info));
4065 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4068 rect_y = value->value.i_val;
4070 case MM_CAM_DISPLAY_RECT_WIDTH:
4071 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4074 rect_width = value->value.i_val;
4076 case MM_CAM_DISPLAY_RECT_HEIGHT:
4077 rect_height = value->value.i_val;
4080 _mmcam_dbg_err("Wrong attr_idx!");
4084 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4085 _mmcam_dbg_log("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4087 if (!strcmp(videosink_name, "tizenwlsink")) {
4088 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4089 rect_x, rect_y, rect_width, rect_height);
4091 _mmcam_dbg_err("FAILED : could not set display roi area.");
4095 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4096 "dst-roi-x", rect_x,
4097 "dst-roi-y", rect_y,
4098 "dst-roi-w", rect_width,
4099 "dst-roi-h", rect_height,
4104 _mmcam_dbg_warn("[%s] does not support display rect, but no error", videosink_name);
4111 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4114 int current_state = MM_CAMCORDER_STATE_NONE;
4115 const char *videosink_name = NULL;
4116 GstElement *vs_element = NULL;
4118 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4119 _MMCamcorderSubContext *sc = NULL;
4121 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4124 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4125 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
4129 /* check current state */
4130 current_state = _mmcamcorder_get_state(handle);
4131 if (current_state < MM_CAMCORDER_STATE_READY) {
4132 _mmcam_dbg_log("NOT initialized. this will be applied later");
4136 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4138 /* Get videosink name */
4139 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4140 if (videosink_name == NULL) {
4141 _mmcam_dbg_err("Please check videosink element in configuration file");
4145 zoom = value->value.i_val;
4146 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4147 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4149 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4150 _mmcam_dbg_log("Set display zoom to %d", zoom + 1);
4154 _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name);
4160 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4162 int current_state = MM_CAMCORDER_STATE_NONE;
4164 const char *videosink_name = NULL;
4166 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4167 _MMCamcorderSubContext *sc = NULL;
4169 mmf_return_val_if_fail(handle && value, FALSE);
4172 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4173 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
4177 /* check current state */
4178 current_state = _mmcamcorder_get_state(handle);
4179 if (current_state < MM_CAMCORDER_STATE_READY) {
4180 _mmcam_dbg_log("NOT initialized. this will be applied later");
4184 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4186 do_scaling = value->value.i_val;
4188 /* Get videosink name */
4189 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4190 if (videosink_name == NULL) {
4191 _mmcam_dbg_err("Please check videosink element in configuration file");
4195 if (!strcmp(videosink_name, "evaspixmapsink")) {
4196 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4197 _mmcam_dbg_log("Set origin-size to %d", !(value->value.i_val));
4200 _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name);
4206 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4209 _MMCamcorderSubContext *sc = NULL;
4210 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4211 int strobe_type, mslVal, newVal, cur_value;
4212 int current_state = MM_CAMCORDER_STATE_NONE;
4214 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4216 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4220 /*_mmcam_dbg_log( "Commit : strobe attribute(%d)", attr_idx );*/
4222 mslVal = value->value.i_val;
4224 /* check flash state */
4225 if (attr_idx == MM_CAM_STROBE_MODE) {
4226 int flash_brightness = 0;
4228 /* get current flash brightness */
4229 if (_mmcamcorder_get_device_flash_brightness(hcamcorder->gdbus_conn, &flash_brightness) != MM_ERROR_NONE) {
4230 _mmcam_dbg_err("_mmcamcorder_get_device_flash_brightness failed");
4231 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4235 _mmcam_dbg_log("flash brightness %d", flash_brightness);
4237 if (flash_brightness > 0 &&
4238 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4239 /* other module already turned on flash */
4240 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4241 _mmcam_dbg_err("other module already turned on flash. avoid to set flash mode here.");
4244 _mmcam_dbg_log("keep going");
4249 current_state = _mmcamcorder_get_state(handle);
4250 if (current_state < MM_CAMCORDER_STATE_READY) {
4251 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
4253 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4254 _mmcam_dbg_err("Can not set while CAPTURING");
4255 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4260 case MM_CAM_STROBE_CONTROL:
4261 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4262 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4264 case MM_CAM_STROBE_CAPABILITIES:
4265 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4268 case MM_CAM_STROBE_MODE:
4269 /* check whether set or not */
4270 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4271 _mmcam_dbg_log("skip set value %d", mslVal);
4275 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4276 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4279 _mmcam_dbg_err("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4283 GstCameraControl *control = NULL;
4284 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4285 _mmcam_dbg_err("Can't cast Video source into camera control.");
4288 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4289 if (control == NULL) {
4290 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
4294 if (gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4295 if (newVal != cur_value) {
4296 if (gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4297 _mmcam_dbg_log("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4300 _mmcam_dbg_warn("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4304 _mmcam_dbg_log("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4308 _mmcam_dbg_warn("Failed to get strobe. Type[%d]", strobe_type);
4317 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4320 int current_state = MM_CAMCORDER_STATE_NONE;
4321 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4323 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4325 _mmcam_dbg_log("Commit : flip %d", value->value.i_val);
4328 current_state = _mmcamcorder_get_state(handle);
4329 if (current_state > MM_CAMCORDER_STATE_READY) {
4330 _mmcam_dbg_err("Can not set camera FLIP horizontal at state %d", current_state);
4331 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4333 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4334 _mmcam_dbg_log("Pipeline is not created yet. This will be set when create pipeline.");
4338 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4340 _mmcam_dbg_log("ret %d", ret);
4346 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4348 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4349 int current_state = MM_CAMCORDER_STATE_NONE;
4350 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4351 _MMCamcorderSubContext *sc = NULL;
4353 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4355 /*_mmcam_dbg_log("Commit : HDR Capture %d", value->value.i_val);*/
4357 /* check whether set or not */
4358 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4359 _mmcam_dbg_log("skip set value %d", value->value.i_val);
4364 current_state = _mmcamcorder_get_state(handle);
4365 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4366 _mmcam_dbg_err("can NOT set HDR capture at state %d", current_state);
4367 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4371 if (current_state >= MM_CAMCORDER_STATE_READY) {
4372 int current_value = 0;
4374 set_hdr_mode = value->value.i_val;
4375 mm_camcorder_get_attributes(handle, NULL,
4376 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4379 if (set_hdr_mode == current_value) {
4380 _mmcam_dbg_log("same HDR value : %d, do nothing", set_hdr_mode);
4384 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4386 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4387 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4388 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4390 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4392 /* check decoder recreation */
4393 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4394 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4398 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4399 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4402 set_hdr_mode = value->value.i_val;
4403 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4404 sc->info_image->hdr_capture_mode = set_hdr_mode;
4405 _mmcam_dbg_log("set HDR mode : %d", set_hdr_mode);
4407 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4408 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4410 _mmcam_dbg_err("sc is NULL. can not set HDR capture");
4419 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4422 _MMCamcorderSubContext *sc = NULL;
4423 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4425 int current_value = 0;
4426 int current_state = MM_CAMCORDER_STATE_NONE;
4427 GstCameraControl *control = NULL;
4429 mmf_return_val_if_fail(handle && value, FALSE);
4431 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4435 /*_mmcam_dbg_log("Commit : detect attribute(%d)", attr_idx);*/
4438 current_state = _mmcamcorder_get_state(handle);
4439 if (current_state < MM_CAMCORDER_STATE_READY) {
4440 _mmcam_dbg_log("will be applied when preview starts");
4444 set_value = value->value.i_val;
4447 case MM_CAM_DETECT_MODE:
4448 /* check whether set or not */
4449 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4450 _mmcam_dbg_log("skip set value %d", set_value);
4454 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4456 case MM_CAM_DETECT_NUMBER:
4457 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4459 case MM_CAM_DETECT_FOCUS_SELECT:
4460 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4462 case MM_CAM_DETECT_SELECT_NUMBER:
4463 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4465 case MM_CAM_DETECT_STATUS:
4466 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4469 _mmcam_dbg_err("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4473 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4474 _mmcam_dbg_err("Can't cast Video source into camera control.");
4477 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4478 if (control == NULL) {
4479 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
4483 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4484 if (current_value == set_value) {
4485 _mmcam_dbg_log("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4488 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4489 _mmcam_dbg_warn("Set detect failed. Type[%d],value[%d]",
4490 detect_type, set_value);
4493 _mmcam_dbg_log("Set detect success. Type[%d],value[%d]",
4494 detect_type, set_value);
4499 _mmcam_dbg_warn("Get detect failed. Type[%d]", detect_type);
4508 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4510 int current_state = MM_CAMCORDER_STATE_NONE;
4511 int preview_format = MM_PIXEL_FORMAT_NV12;
4513 mmf_return_val_if_fail(handle && value, FALSE);
4515 _mmcam_dbg_log("Commit : encoded preview bitrate - %d", value->value.i_val);
4517 /* check preview format */
4518 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4519 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4520 _mmcam_dbg_err("current preview format[%d] is not encoded format", preview_format);
4525 current_state = _mmcamcorder_get_state(handle);
4526 if (current_state < MM_CAMCORDER_STATE_READY) {
4527 _mmcam_dbg_log("will be applied when preview starts");
4531 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4535 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4537 int current_state = MM_CAMCORDER_STATE_NONE;
4538 int preview_format = MM_PIXEL_FORMAT_NV12;
4540 mmf_return_val_if_fail(handle && value, FALSE);
4542 _mmcam_dbg_log("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4544 /* check preview format */
4545 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4546 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4547 _mmcam_dbg_err("current preview format[%d] is not encoded format", preview_format);
4552 current_state = _mmcamcorder_get_state(handle);
4553 if (current_state < MM_CAMCORDER_STATE_READY) {
4554 _mmcam_dbg_log("will be applied when preview starts");
4558 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4562 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4564 int stream_index = 0;
4565 char *stream_type = NULL;
4566 _MMCamcorderSubContext *sc = NULL;
4568 mmf_return_val_if_fail(handle && value, FALSE);
4570 stream_type = value->value.s_val;
4572 _mmcam_dbg_err("NULL string");
4576 mm_camcorder_get_attributes(handle, NULL,
4577 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4579 if (stream_index < 0) {
4580 _mmcam_dbg_err("invalid stream index %d", stream_index);
4584 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4585 if (!sc || !sc->encode_element ||
4586 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4587 _mmcam_dbg_warn("audiosrc element is not initialized, it will be set later");
4591 _mmcam_dbg_warn("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4593 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4597 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4599 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4600 int current_state = MM_CAMCORDER_STATE_NONE;
4602 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4604 current_state = _mmcamcorder_get_state(handle);
4605 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4606 _mmcam_dbg_err("Can not set while CAPTURING");
4607 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4614 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4616 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4618 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4620 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4621 /* Replay gain enable */
4622 int current_state = MM_CAMCORDER_STATE_NONE;
4623 int audio_disable = FALSE;
4625 current_state = _mmcamcorder_get_state(handle);
4626 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4627 _mmcam_dbg_err("Can not set replay gain enable [state : %d]", current_state);
4628 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4632 mm_camcorder_get_attributes(handle, NULL,
4633 MMCAM_AUDIO_DISABLE, &audio_disable,
4636 if (audio_disable) {
4637 _mmcam_dbg_err("audio is disabled");
4638 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4642 _mmcam_dbg_log("set replay gain enable : %d", value->value.i_val);
4643 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4644 /* Replay gain reference level */
4645 int replay_gain_enable = FALSE;
4647 mm_camcorder_get_attributes(handle, NULL,
4648 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4651 if (replay_gain_enable == FALSE) {
4652 _mmcam_dbg_err("replay gain is disabled");
4653 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4657 _mmcam_dbg_log("set reference level for replay gain : %lf dB", value->value.d_val);
4659 _mmcam_dbg_err("unknown attribute id %d", attr_idx);
4667 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4669 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4672 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4676 int attr_idxs_default[] = {
4677 MM_CAM_CAMERA_DIGITAL_ZOOM,
4678 MM_CAM_CAMERA_OPTICAL_ZOOM,
4680 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("commit some attributes again");
4699 attrs = MMF_CAMCORDER_ATTRS(handle);
4700 if (attrs == NULL) {
4701 _mmcam_dbg_err("Get attribute handle failed.");
4705 /* Get Scene mode */
4706 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4708 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4709 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4710 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4713 /* Set extra if scene mode is NORMAL */
4714 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4715 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4716 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4717 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4720 /* Set scene mode if scene mode is NOT NORMAL */
4721 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4722 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4725 if (mm_attrs_commit_all(attrs) == -1)
4730 _mmcam_dbg_log("Done.");
4736 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4738 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4744 MM_CAM_CAMERA_PTZ_TYPE,
4745 MM_CAM_CAMERA_PAN_MECHA,
4746 MM_CAM_CAMERA_PAN_ELEC,
4747 MM_CAM_CAMERA_TILT_MECHA,
4748 MM_CAM_CAMERA_TILT_ELEC
4751 mmf_return_val_if_fail(hcamcorder, FALSE);
4753 _mmcam_dbg_log("commit some attribute again[2]");
4755 attrs = MMF_CAMCORDER_ATTRS(handle);
4756 if (attrs == NULL) {
4757 _mmcam_dbg_err("Get attribute handle failed.");
4761 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4762 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4763 mm_attrs_set_modified(attrs, attr_idxs[i]);
4766 if (mm_attrs_commit_all(attrs) == -1)
4771 _mmcam_dbg_log("Done.");
4777 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4779 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4783 int nerror = MM_ERROR_NONE;
4785 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4787 attrs = MMF_CAMCORDER_ATTRS(handle);
4788 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4792 table_size = ARRAY_SIZE(readonly_attributes);
4793 _mmcam_dbg_log("%d", table_size);
4794 for (i = 0; i < table_size; i++) {
4795 int sCategory = readonly_attributes[i];
4797 mm_attrs_set_readonly(attrs, sCategory);
4804 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4806 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4809 type_string_array * disabled_attr = NULL;
4811 int nerror = MM_ERROR_NONE ;
4813 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4815 attrs = MMF_CAMCORDER_ATTRS(handle);
4816 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4821 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4822 CONFIGURE_CATEGORY_MAIN_GENERAL,
4823 "DisabledAttributes",
4825 if (disabled_attr != NULL && disabled_attr->value) {
4826 cnt_str = disabled_attr->count;
4827 for (i = 0; i < cnt_str; i++) {
4829 _mmcam_dbg_log("[%d]%s", i, disabled_attr->value[i]);
4830 nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
4832 if (nerror == MM_ERROR_NONE)
4833 mm_attrs_set_disabled(attrs, idx);
4835 _mmcam_dbg_warn("No ATTR named %s[%d]", disabled_attr->value[i], i);
4843 /*---------------------------------------------------------------------------------------
4844 | INTERNAL FUNCTION DEFINITIONS: |
4845 ---------------------------------------------------------------------------------------*/
4846 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4848 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4849 _MMCamcorderSubContext *sc = NULL;
4850 int current_state = MM_CAMCORDER_STATE_NULL;
4852 mmf_return_val_if_fail(hcamcorder, FALSE);
4854 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4858 current_state = _mmcamcorder_get_state(handle);
4860 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4861 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4862 _mmcam_dbg_log("set capture width and height [%dx%d] to camera plugin", width, height);
4863 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4864 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4866 _mmcam_dbg_warn("invalid state[%d]", current_state);
4870 _mmcam_dbg_log("element is not created yet");
4877 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4879 #define INIT_VALUE -1
4880 #define CHECK_COUNT 3
4882 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4883 MMHandleType attrs = 0;
4885 int ret = MM_ERROR_NONE;
4888 const char *name = NULL;
4889 const char *check_pair_name[CHECK_COUNT][3] = {
4890 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
4891 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
4892 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
4895 int check_pair_value[CHECK_COUNT][2] = {
4896 {INIT_VALUE, INIT_VALUE},
4897 {INIT_VALUE, INIT_VALUE},
4898 {INIT_VALUE, INIT_VALUE},
4901 if (hcamcorder == NULL || attribute_name == NULL) {
4902 _mmcam_dbg_warn("handle[%p] or attribute_name[%p] is NULL.",
4903 hcamcorder, attribute_name);
4904 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4908 *err_attr_name = NULL;
4910 /*_mmcam_dbg_log( "ENTER" );*/
4912 attrs = MMF_CAMCORDER_ATTRS(handle);
4914 name = attribute_name;
4918 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
4920 /*_mmcam_dbg_log("NAME : %s", name);*/
4922 /* attribute name check */
4923 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
4925 *err_attr_name = strdup(name);
4927 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
4928 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
4934 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
4937 switch (attr_type) {
4938 case MM_ATTRS_TYPE_INT:
4940 gboolean matched = FALSE;
4941 for (i = 0 ; i < CHECK_COUNT ; i++) {
4942 for (j = 0 ; j < 2 ; j++) {
4943 if (!strcmp(name, check_pair_name[i][j])) {
4944 check_pair_value[i][j] = va_arg((var_args), int);
4945 _mmcam_dbg_log("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
4953 if (matched == FALSE)
4954 va_arg((var_args), int);
4957 case MM_ATTRS_TYPE_DOUBLE:
4958 va_arg((var_args), double);
4960 case MM_ATTRS_TYPE_STRING:
4961 va_arg((var_args), char*); /* string */
4962 va_arg((var_args), int); /* size */
4964 case MM_ATTRS_TYPE_DATA:
4965 va_arg((var_args), void*); /* data */
4966 va_arg((var_args), int); /* size */
4968 case MM_ATTRS_TYPE_INVALID:
4970 _mmcam_dbg_err("Not supported attribute type(%d, name:%s)", attr_type, name);
4972 *err_attr_name = strdup(name);
4974 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4978 name = va_arg(var_args, const char*);
4981 for (i = 0 ; i < CHECK_COUNT ; i++) {
4982 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
4983 gboolean check_result = FALSE;
4984 char *err_name = NULL;
4985 MMCamAttrsInfo attr_info_0, attr_info_1;
4987 if (check_pair_value[i][0] == INIT_VALUE) {
4988 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
4989 err_name = strdup(check_pair_name[i][1]);
4990 } else if (check_pair_value[i][1] == INIT_VALUE) {
4991 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
4992 err_name = strdup(check_pair_name[i][0]);
4994 err_name = strdup(check_pair_name[i][2]);
4997 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
4998 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5000 check_result = FALSE;
5002 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5003 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5004 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5006 _mmcam_dbg_log("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5007 check_pair_name[i][0], check_pair_name[i][1],
5008 check_pair_value[i][0], check_pair_value[i][1], i);
5010 check_result = TRUE;
5015 if (check_result == FALSE) {
5016 _mmcam_dbg_err("INVALID pair[%s,%s] %dx%d",
5017 check_pair_name[i][0], check_pair_name[i][1],
5018 check_pair_value[i][0], check_pair_value[i][1]);
5019 if (err_attr_name) {
5020 *err_attr_name = err_name;
5028 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5031 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5032 int current_width = 0;
5033 int current_height = 0;
5035 mm_camcorder_get_attributes(handle, NULL,
5036 MMCAM_CAMERA_WIDTH, ¤t_width,
5037 MMCAM_CAMERA_HEIGHT, ¤t_height,
5040 if (current_width != check_pair_value[i][0] ||
5041 current_height != check_pair_value[i][1]) {
5042 hcamcorder->resolution_changed = TRUE;
5044 hcamcorder->resolution_changed = FALSE;
5047 _mmcam_dbg_log("resolution changed : %d", hcamcorder->resolution_changed);
5057 /*_mmcam_dbg_log("DONE");*/
5059 return MM_ERROR_NONE;
5063 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5067 if ((void *)handle == NULL) {
5068 _mmcam_dbg_warn("handle %p is NULL", handle);
5072 memset(&info, 0x0, sizeof(MMAttrsInfo));
5074 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5076 switch (info.validity_type) {
5077 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5079 _mmcam_dbg_log("int array count %d", info.int_array.count);
5081 if (info.int_array.count < 1)
5084 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5086 _mmcam_dbg_log("int range min %d, max %d",info.int_range.min, info.int_range.max);
5088 if (info.int_range.min > info.int_range.max)
5091 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5093 _mmcam_dbg_log("double array count %d", info.double_array.count);
5095 if (info.double_array.count < 1)
5098 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5100 _mmcam_dbg_log("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5102 if (info.double_range.min >= info.double_range.max)
5106 _mmcam_dbg_warn("invalid type %d", info.validity_type);