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",
1185 MM_ATTRS_FLAG_READABLE,
1187 MM_ATTRS_VALID_TYPE_NONE,
1193 MM_CAM_CAPTURE_SOUND_ENABLE,
1194 "capture-sound-enable",
1198 MM_ATTRS_VALID_TYPE_INT_RANGE,
1201 _mmcamcorder_commit_capture_sound_enable,
1204 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
1205 "recommend-display-rotation",
1208 {(void*)MM_DISPLAY_ROTATION_270},
1209 MM_ATTRS_VALID_TYPE_INT_RANGE,
1210 {.int_min = MM_DISPLAY_ROTATION_NONE},
1211 {.int_max = MM_DISPLAY_ROTATION_270},
1219 {(void*)MM_FLIP_NONE},
1220 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1222 {ARRAY_SIZE(flip_list)},
1223 _mmcamcorder_commit_camera_flip,
1226 MM_CAM_CAMERA_HDR_CAPTURE,
1227 "camera-hdr-capture",
1231 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1234 _mmcamcorder_commit_camera_hdr_capture,
1237 MM_CAM_DISPLAY_MODE,
1241 {(void*)MM_DISPLAY_MODE_DEFAULT},
1242 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1245 _mmcamcorder_commit_display_mode,
1249 MM_CAM_AUDIO_DISABLE,
1254 MM_ATTRS_VALID_TYPE_INT_RANGE,
1257 _mmcamcorder_commit_audio_disable,
1260 MM_CAM_RECOMMEND_CAMERA_WIDTH,
1261 "recommend-camera-width",
1264 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
1265 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1271 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
1272 "recommend-camera-height",
1275 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
1276 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1282 MM_CAM_CAPTURED_EXIF_RAW_DATA,
1283 "captured-exif-raw-data",
1285 MM_ATTRS_FLAG_READABLE,
1287 MM_ATTRS_VALID_TYPE_NONE,
1293 MM_CAM_DISPLAY_EVAS_SURFACE_SINK,
1294 "display-evas-surface-sink",
1295 MM_ATTRS_TYPE_STRING,
1296 MM_ATTRS_FLAG_READABLE,
1298 MM_ATTRS_VALID_TYPE_NONE,
1304 MM_CAM_DISPLAY_EVAS_DO_SCALING,
1305 "display-evas-do-scaling",
1309 MM_ATTRS_VALID_TYPE_INT_RANGE,
1312 _mmcamcorder_commit_display_evas_do_scaling,
1315 MM_CAM_CAMERA_FACING_DIRECTION,
1316 "camera-facing-direction",
1319 {(void*)MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1320 MM_ATTRS_VALID_TYPE_INT_RANGE,
1321 {.int_min = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1322 {.int_max = MM_CAMCORDER_CAMERA_FACING_DIRECTION_FRONT},
1326 MM_CAM_DISPLAY_FLIP,
1330 {(void*)MM_FLIP_NONE},
1331 MM_ATTRS_VALID_TYPE_INT_RANGE,
1332 {.int_min = MM_FLIP_NONE},
1333 {.int_max = MM_FLIP_BOTH},
1334 _mmcamcorder_commit_display_flip,
1337 MM_CAM_CAMERA_VIDEO_STABILIZATION,
1338 "camera-video-stabilization",
1341 {(void*)MM_CAMCORDER_VIDEO_STABILIZATION_OFF},
1342 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1345 _mmcamcorder_commit_camera_video_stabilization,
1348 MM_CAM_TAG_VIDEO_ORIENTATION,
1349 "tag-video-orientation",
1352 {(void*)MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1353 MM_ATTRS_VALID_TYPE_INT_RANGE,
1354 {.int_min = MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1355 {.int_max = MM_CAMCORDER_TAG_VIDEO_ORT_270},
1360 MM_CAM_CAMERA_PAN_MECHA,
1365 MM_ATTRS_VALID_TYPE_INT_RANGE,
1368 _mmcamcorder_commit_camera_pan,
1371 MM_CAM_CAMERA_PAN_ELEC,
1376 MM_ATTRS_VALID_TYPE_INT_RANGE,
1379 _mmcamcorder_commit_camera_pan,
1382 MM_CAM_CAMERA_TILT_MECHA,
1383 "camera-tilt-mecha",
1387 MM_ATTRS_VALID_TYPE_INT_RANGE,
1390 _mmcamcorder_commit_camera_tilt,
1393 MM_CAM_CAMERA_TILT_ELEC,
1398 MM_ATTRS_VALID_TYPE_INT_RANGE,
1401 _mmcamcorder_commit_camera_tilt,
1404 MM_CAM_CAMERA_PTZ_TYPE,
1409 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1412 _mmcamcorder_commit_camera_ptz_type,
1420 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1423 _mmcamcorder_commit_video_size,
1426 MM_CAM_VIDEO_HEIGHT,
1431 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1434 _mmcamcorder_commit_video_size,
1437 MM_CAM_SUPPORT_ZSL_CAPTURE,
1438 "support-zsl-capture",
1442 MM_ATTRS_VALID_TYPE_INT_RANGE,
1448 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
1449 "support-zero-copy-format",
1453 MM_ATTRS_VALID_TYPE_INT_RANGE,
1459 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
1460 "support-media-packet-preview-cb",
1464 MM_ATTRS_VALID_TYPE_INT_RANGE,
1471 MM_CAM_ENCODED_PREVIEW_BITRATE,
1472 "encoded-preview-bitrate",
1475 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE},
1476 MM_ATTRS_VALID_TYPE_INT_RANGE,
1478 {.int_max = _MMCAMCORDER_MAX_INT},
1479 _mmcamcorder_commit_encoded_preview_bitrate,
1482 MM_CAM_ENCODED_PREVIEW_GOP_INTERVAL,
1483 "encoded-preview-gop-interval",
1486 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL},
1487 MM_ATTRS_VALID_TYPE_INT_RANGE,
1489 {.int_max = _MMCAMCORDER_MAX_INT},
1490 _mmcamcorder_commit_encoded_preview_gop_interval,
1493 MM_CAM_RECORDER_TAG_ENABLE,
1494 "recorder-tag-enable",
1498 MM_ATTRS_VALID_TYPE_INT_RANGE,
1504 MM_CAM_DISPLAY_SOCKET_PATH,
1505 "display-socket-path",
1506 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,
1615 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1617 for (idx = 0 ; idx < attr_count ; idx++) {
1618 /* attribute order check. This should be same. */
1619 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1620 _mmcam_dbg_err("Please check attributes order. Is the idx same with enum val?");
1621 free(attrs_const_info);
1622 attrs_const_info = NULL;
1623 free(hcamcorder->cam_attrs_const_info);
1624 hcamcorder->cam_attrs_const_info = NULL;
1628 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1629 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1630 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1631 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1634 /* Camcorder Attributes */
1635 _mmcam_dbg_log("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1637 ret = mm_attrs_new(attrs_const_info,
1639 "Camcorder_Attributes",
1640 _mmcamcorder_commit_camcorder_attrs,
1644 free(attrs_const_info);
1645 attrs_const_info = NULL;
1647 if (ret != MM_ERROR_NONE) {
1648 _mmcam_dbg_err("Fail to alloc attribute handle");
1649 free(hcamcorder->cam_attrs_const_info);
1650 hcamcorder->cam_attrs_const_info = NULL;
1654 __mmcamcorder_set_conf_to_valid_info(handle);
1656 for (idx = 0; idx < attr_count; idx++) {
1657 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1660 _mmcam_dbg_log("Valid type [%s:%d, %d, %d]",
1661 attr_info->name, attr_info->validity_type,
1662 attr_info->validity_value1, attr_info->validity_value2);
1664 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1666 switch (attr_info->validity_type) {
1667 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1668 if (attr_info->validity_value_1.int_array &&
1669 attr_info->validity_value_2.count > 0) {
1670 mm_attrs_set_valid_array(attrs, idx,
1671 (const int *)(attr_info->validity_value_1.int_array),
1672 attr_info->validity_value_2.count,
1673 attr_info->default_value.value_int);
1676 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1677 mm_attrs_set_valid_range(attrs, idx,
1678 attr_info->validity_value_1.int_min,
1679 attr_info->validity_value_2.int_max,
1680 attr_info->default_value.value_int);
1682 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1683 if (attr_info->validity_value_1.double_array &&
1684 attr_info->validity_value_2.count > 0) {
1685 mm_attrs_set_valid_double_array(attrs, idx,
1686 (const double *)(attr_info->validity_value_1.double_array),
1687 attr_info->validity_value_2.count,
1688 attr_info->default_value.value_double);
1691 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1692 mm_attrs_set_valid_double_range(attrs, idx,
1693 attr_info->validity_value_1.double_min,
1694 attr_info->validity_value_2.double_max,
1695 attr_info->default_value.value_double);
1697 case MM_ATTRS_VALID_TYPE_NONE:
1699 case MM_ATTRS_VALID_TYPE_INVALID:
1701 _mmcam_dbg_err("Valid type error.");
1706 __mmcamcorder_release_conf_valid_info(handle);
1713 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1715 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1717 if (hcamcorder == NULL) {
1718 _mmcam_dbg_err("handle is NULL");
1725 mm_attrs_free(attrs);
1726 _mmcam_dbg_log("released attribute");
1729 if (hcamcorder->cam_attrs_const_info) {
1730 free(hcamcorder->cam_attrs_const_info);
1731 hcamcorder->cam_attrs_const_info = NULL;
1732 _mmcam_dbg_log("released attribute info");
1740 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1742 MMHandleType attrs = 0;
1743 int ret = MM_ERROR_NONE;
1745 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1746 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1748 attrs = MMF_CAMCORDER_ATTRS(handle);
1749 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1751 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1758 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1760 MMHandleType attrs = 0;
1761 int ret = MM_ERROR_NONE;
1763 char *tmp_err_attr_name = NULL;
1764 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1765 va_list var_args_copy;
1767 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1769 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1770 _mmcam_dbg_err("Another command is running.");
1771 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1774 /* copy var_args to keep original var_args */
1775 va_copy(var_args_copy, var_args);
1777 attrs = MMF_CAMCORDER_ATTRS(handle);
1779 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1781 _mmcam_dbg_err("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1782 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1785 if (ret == MM_ERROR_NONE) {
1786 hcamcorder->error_code = MM_ERROR_NONE;
1787 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1788 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1791 va_end(var_args_copy);
1793 _MMCAMCORDER_UNLOCK_CMD(handle);
1795 if (ret != MM_ERROR_NONE) {
1796 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1797 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1798 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1799 _mmcam_dbg_err("[%s] is supported, but value is invalid",
1800 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1801 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1805 if (hcamcorder->error_code != MM_ERROR_NONE) {
1806 _mmcam_dbg_err("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1807 ret = hcamcorder->error_code;
1808 hcamcorder->error_code = MM_ERROR_NONE;
1811 _mmcam_dbg_err("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1814 if (tmp_err_attr_name) {
1815 if (!err_attr_name) {
1816 _mmcam_dbg_err("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1817 free(tmp_err_attr_name);
1818 tmp_err_attr_name = NULL;
1820 *err_attr_name = tmp_err_attr_name;
1829 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1831 MMHandleType attrs = 0;
1832 MMAttrsInfo attrinfo;
1833 int ret = MM_ERROR_NONE;
1835 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1836 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1837 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1839 attrs = MMF_CAMCORDER_ATTRS(handle);
1840 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1842 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1844 if (ret == MM_ERROR_NONE) {
1845 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1846 info->type = attrinfo.type;
1847 info->flag = attrinfo.flag;
1848 info->validity_type = attrinfo.validity_type;
1850 switch (attrinfo.validity_type) {
1851 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1852 info->int_array.array = attrinfo.int_array.array;
1853 info->int_array.count = attrinfo.int_array.count;
1854 info->int_array.def = attrinfo.int_array.dval;
1856 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1857 info->int_range.min = attrinfo.int_range.min;
1858 info->int_range.max = attrinfo.int_range.max;
1859 info->int_range.def = attrinfo.int_range.dval;
1861 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1862 info->double_array.array = attrinfo.double_array.array;
1863 info->double_array.count = attrinfo.double_array.count;
1864 info->double_array.def = attrinfo.double_array.dval;
1866 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1867 info->double_range.min = attrinfo.double_range.min;
1868 info->double_range.max = attrinfo.double_range.max;
1869 info->double_range.def = attrinfo.double_range.dval;
1871 case MM_ATTRS_VALID_TYPE_NONE:
1873 case MM_ATTRS_VALID_TYPE_INVALID:
1884 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1887 mmf_camcorder_t *hcamcorder = NULL;
1889 mmf_return_val_if_fail(commit_param, FALSE);
1890 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1891 mmf_return_val_if_fail(attr_name, FALSE);
1892 mmf_return_val_if_fail(value, FALSE);
1894 hcamcorder = MMF_CAMCORDER(commit_param);
1896 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1897 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1905 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1908 int total_count = 0;
1910 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1912 if (hcamcorder == NULL) {
1913 _mmcam_dbg_err("handle is NULL");
1914 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1918 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
1919 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
1920 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
1923 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
1924 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
1925 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
1928 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
1929 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
1930 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
1933 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
1934 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
1935 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
1937 return MM_ERROR_NONE;
1941 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
1943 int *allocated_memory = NULL;
1945 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1947 if (hcamcorder == NULL) {
1948 _mmcam_dbg_err("handle is NULL");
1949 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1952 _mmcam_dbg_log("START");
1954 /* Audio encoder info */
1955 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
1956 if (allocated_memory) {
1957 free(allocated_memory);
1958 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
1959 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
1962 /* Video encoder info */
1963 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
1964 if (allocated_memory) {
1965 free(allocated_memory);
1966 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
1967 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
1970 /* Image encoder info */
1971 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
1972 if (allocated_memory) {
1973 free(allocated_memory);
1974 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
1975 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
1978 /* File format info */
1979 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
1980 if (allocated_memory) {
1981 free(allocated_memory);
1982 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
1983 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
1986 _mmcam_dbg_log("DONE");
1988 return MM_ERROR_NONE;
1992 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
1994 MMHandleType attr = 0;
1995 int current_state = MM_CAMCORDER_STATE_NONE;
1997 mmf_return_val_if_fail(handle && value, FALSE);
1999 attr = MMF_CAMCORDER_ATTRS(handle);
2000 mmf_return_val_if_fail(attr, FALSE);
2002 /*_mmcam_dbg_log("(%d)", attr_idx);*/
2004 current_state = _mmcamcorder_get_state(handle);
2005 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2006 int flags = MM_ATTRS_FLAG_NONE;
2007 int capture_width, capture_height;
2008 MMCamAttrsInfo info;
2010 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2013 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2014 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2015 capture_width = value->value.i_val;
2017 /* Check whether they are valid pair */
2018 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2023 _mmcam_dbg_log("Capture resolution can't be set.(state=%d)", current_state);
2029 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2031 int current_state = MM_CAMCORDER_STATE_NONE;
2033 current_state = _mmcamcorder_get_state(handle);
2035 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2036 int capture_width, capture_height;
2038 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2039 capture_height = value->value.i_val;
2041 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2043 _mmcam_dbg_log("Capture resolution can't be set.(state=%d)", current_state);
2050 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2052 int current_state = 0;
2054 const char *videosrc_name = NULL;
2055 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2056 _MMCamcorderSubContext *sc = NULL;
2057 _MMCamcorderImageInfo *info = NULL;
2058 GstCameraControl *control = NULL;
2059 type_element *VideosrcElement = NULL;
2061 mmf_return_val_if_fail(handle && value, FALSE);
2063 current_state = _mmcamcorder_get_state(handle);
2064 ivalue = value->value.i_val;
2066 _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
2067 CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
2070 _mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
2072 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2076 info = sc->info_image;
2078 _mmcam_dbg_err("info image is NULL");
2082 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2083 if (info->capture_send_count > 0) {
2084 info->capturing = FALSE;
2085 _mmcam_dbg_warn("capturing -> FALSE and skip capture callback since now");
2088 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2089 _mmcam_dbg_warn("Can't cast Video source into camera control.");
2093 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2095 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2096 _mmcam_dbg_warn("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2098 _mmcam_dbg_warn("cast CAMERA_CONTROL failed");
2101 _mmcam_dbg_warn("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2108 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2110 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2111 int current_state = MM_CAMCORDER_STATE_NONE;
2112 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2114 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2116 current_state = _mmcamcorder_get_state(handle);
2117 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2119 _mmcam_dbg_log("current state %d, mode %d, set count %d",
2120 current_state, mode, value->value.i_val);
2122 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2123 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2126 _mmcam_dbg_err("Invalid mode[%d] or state[%d]", mode, current_state);
2132 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2134 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2136 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2138 _mmcam_dbg_log("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2140 /* return error when disable shutter sound if policy is TRUE */
2141 if (!value->value.i_val &&
2142 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2143 _mmcam_dbg_err("not permitted DISABLE SHUTTER SOUND");
2146 _mmcam_dbg_log("set value [%d] success", value->value.i_val);
2152 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2154 int current_state = MM_CAMCORDER_STATE_NONE;
2155 _MMCamcorderSubContext *sc = NULL;
2158 mmf_return_val_if_fail(handle && value, FALSE);
2160 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2164 current_state = _mmcamcorder_get_state(handle);
2166 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2167 double mslNewVal = 0;
2168 mslNewVal = value->value.d_val;
2170 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2171 if (mslNewVal == 0.0) {
2172 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2173 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2175 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2176 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2180 _mmcam_dbg_log("Commit : volume(%f)", mslNewVal);
2183 _mmcam_dbg_log("Commit : nothing to commit. status(%d)", current_state);
2191 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2193 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2194 int current_state = MM_CAMCORDER_STATE_NONE;
2196 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2198 current_state = _mmcamcorder_get_state(handle);
2199 if (current_state > MM_CAMCORDER_STATE_READY) {
2200 _mmcam_dbg_err("invalid state %d", current_state);
2201 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2209 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2211 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2212 MMCamAttrsInfo fps_info;
2213 int resolution_width = 0;
2214 int resolution_height = 0;
2217 int current_state = MM_CAMCORDER_STATE_NONE;
2219 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2221 current_state = _mmcamcorder_get_state(handle);
2222 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2223 _mmcam_dbg_err("invalid state %d", current_state);
2224 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2228 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2231 _mmcam_dbg_log("FPS(%d)", value->value.i_val);
2233 ret = mm_camcorder_get_attributes(handle, NULL,
2234 MMCAM_CAMERA_WIDTH, &resolution_width,
2235 MMCAM_CAMERA_HEIGHT, &resolution_height,
2238 if (ret != MM_ERROR_NONE) {
2239 _mmcam_dbg_err("FAILED : coult not get resolution values.");
2243 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2244 if (ret != MM_ERROR_NONE) {
2245 _mmcam_dbg_err("FAILED : coult not get FPS values by resolution.");
2249 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2250 if (value->value.i_val == fps_info.int_array.array[i])
2254 _mmcam_dbg_err("FAILED : %d is not supported FPS", value->value.i_val);
2260 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2262 int current_state = MM_CAMCORDER_STATE_NONE;
2263 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2264 _MMCamcorderSubContext *sc = NULL;
2266 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2268 current_state = _mmcamcorder_get_state(handle);
2269 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2270 _mmcam_dbg_warn("invalid state %d", current_state);
2271 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2275 /* Verify recording motion rate */
2276 if (value->value.d_val > 0.0) {
2277 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2281 /* set is_slow flag */
2282 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2283 sc->is_modified_rate = TRUE;
2285 sc->is_modified_rate = FALSE;
2287 _mmcam_dbg_log("Set slow motion rate %lf", value->value.d_val);
2290 _mmcam_dbg_warn("Failed to set recording motion rate %lf", value->value.d_val);
2296 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2298 MMHandleType attr = 0;
2299 int current_state = MM_CAMCORDER_STATE_NONE;
2301 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2302 _MMCamcorderSubContext *sc = NULL;
2304 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2306 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2310 attr = MMF_CAMCORDER_ATTRS(handle);
2311 mmf_return_val_if_fail(attr, FALSE);
2313 _mmcam_dbg_log("Width(%d)", value->value.i_val);
2315 current_state = _mmcamcorder_get_state(handle);
2317 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2318 _mmcam_dbg_log("Resolution can't be changed.(state=%d)", current_state);
2321 int flags = MM_ATTRS_FLAG_NONE;
2322 MMCamAttrsInfo info;
2323 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2326 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2327 int width = value->value.i_val;
2329 int preview_format = MM_PIXEL_FORMAT_NV12;
2330 int codec_type = MM_IMAGE_CODEC_JPEG;
2332 mm_camcorder_get_attributes(handle, NULL,
2333 MMCAM_CAMERA_HEIGHT, &height,
2334 MMCAM_CAMERA_FORMAT, &preview_format,
2335 MMCAM_IMAGE_ENCODER, &codec_type,
2338 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2339 if (hcamcorder->resolution_changed == FALSE) {
2340 _mmcam_dbg_log("no need to restart preview");
2344 hcamcorder->resolution_changed = FALSE;
2346 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2347 _mmcam_dbg_log("restart preview");
2349 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2350 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2352 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2354 /* check decoder recreation */
2355 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2356 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2357 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2361 /* get preview format */
2362 sc->info_image->preview_format = preview_format;
2363 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2364 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2366 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2367 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2369 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2372 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2374 _mmcam_dbg_err("currently locked for preview restart");
2378 /* get preview format */
2379 sc->info_image->preview_format = preview_format;
2380 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2381 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2392 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2395 int current_state = MM_CAMCORDER_STATE_NONE;
2396 MMHandleType attr = 0;
2397 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2398 _MMCamcorderSubContext *sc = NULL;
2400 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2402 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2406 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2407 mmf_return_val_if_fail(attr, FALSE);
2409 _mmcam_dbg_log("Height(%d)", value->value.i_val);
2410 current_state = _mmcamcorder_get_state(handle);
2412 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2413 _mmcam_dbg_log("Resolution can't be changed.(state=%d)", current_state);
2414 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2418 int height = value->value.i_val;
2419 int preview_format = MM_PIXEL_FORMAT_NV12;
2420 int codec_type = MM_IMAGE_CODEC_JPEG;
2421 int video_stabilization = 0;
2423 mm_camcorder_get_attributes(handle, NULL,
2424 MMCAM_CAMERA_WIDTH, &width,
2425 MMCAM_CAMERA_FORMAT, &preview_format,
2426 MMCAM_IMAGE_ENCODER, &codec_type,
2427 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2430 sc->info_video->preview_width = width;
2431 sc->info_video->preview_height = height;
2433 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2434 if (hcamcorder->resolution_changed == FALSE) {
2435 _mmcam_dbg_log("no need to restart preview");
2439 hcamcorder->resolution_changed = FALSE;
2441 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2442 _mmcam_dbg_log("restart preview");
2444 _mmcam_dbg_log("set empty buffers");
2446 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2447 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2449 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2451 /* check decoder recreation */
2452 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2453 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2454 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2458 /* get preview format */
2459 sc->info_image->preview_format = preview_format;
2460 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2462 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2464 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2465 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2467 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2470 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2472 _mmcam_dbg_err("currently locked for preview restart");
2476 /* get preview format */
2477 sc->info_image->preview_format = preview_format;
2478 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2479 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2487 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2489 int current_state = MM_CAMCORDER_STATE_NONE;
2490 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2492 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2494 current_state = _mmcamcorder_get_state(handle);
2495 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2496 _mmcam_dbg_err("Video Resolution can't be changed.(state=%d)", current_state);
2497 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2500 _mmcam_dbg_warn("Video Resolution %d [attr_idx %d] ",
2501 value->value.i_val, attr_idx);
2507 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2509 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2510 _MMCamcorderSubContext *sc = NULL;
2511 int current_state = MM_CAMCORDER_STATE_NONE;
2512 GstCameraControl *control = NULL;
2516 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2518 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2522 zoom_level = value->value.i_val;
2524 _mmcam_dbg_log("(%d)", attr_idx);
2526 current_state = _mmcamcorder_get_state(handle);
2527 if (current_state < MM_CAMCORDER_STATE_READY) {
2528 _mmcam_dbg_log("will be applied when preview starts");
2530 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2531 _mmcam_dbg_err("Can not set while CAPTURING");
2532 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2536 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2537 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2539 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2541 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2544 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2545 _mmcam_dbg_log("Can't cast Video source into camera control.");
2549 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2550 if (control == NULL) {
2551 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2555 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2557 _mmcam_dbg_log("Succeed in operating Zoom[%d].", zoom_level);
2560 _mmcam_dbg_warn("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2563 _mmcam_dbg_log("pointer of video src is null");
2570 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2572 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2573 _MMCamcorderSubContext *sc = NULL;
2574 int current_state = MM_CAMCORDER_STATE_NONE;
2576 GstCameraControl *CameraControl = NULL;
2577 GstCameraControlChannel *CameraControlChannel = NULL;
2578 const GList *controls = NULL;
2579 const GList *item = NULL;
2581 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2583 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2584 mmf_return_val_if_fail(sc, TRUE);
2586 _mmcam_dbg_log("ptz type : %d", value->value.i_val);
2588 current_state = _mmcamcorder_get_state(handle);
2589 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2590 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2591 _mmcam_dbg_err("invalid state[%d]", current_state);
2592 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2596 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2597 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2598 _mmcam_dbg_log("Can't cast Video source into camera control.");
2602 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2603 if (CameraControl == NULL) {
2604 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2608 controls = gst_camera_control_list_channels(CameraControl);
2609 if (controls == NULL) {
2610 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2614 for (item = controls ; item && item->data ; item = item->next) {
2615 CameraControlChannel = item->data;
2616 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2617 if (!strcmp(CameraControlChannel->label, "ptz")) {
2618 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2619 _mmcam_dbg_warn("set ptz type %d done", value->value.i_val);
2622 _mmcam_dbg_err("failed to set ptz type %d", value->value.i_val);
2628 _mmcam_dbg_warn("failed to find tilt control channel");
2635 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2637 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2638 _MMCamcorderSubContext *sc = NULL;
2639 int current_state = MM_CAMCORDER_STATE_NONE;
2641 GstCameraControl *CameraControl = NULL;
2642 GstCameraControlChannel *CameraControlChannel = NULL;
2643 const GList *controls = NULL;
2644 const GList *item = NULL;
2646 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2648 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2649 mmf_return_val_if_fail(sc, TRUE);
2651 _mmcam_dbg_log("pan : %d", value->value.i_val);
2653 current_state = _mmcamcorder_get_state(handle);
2654 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2655 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2656 _mmcam_dbg_err("invalid state[%d]", current_state);
2657 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2661 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2662 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2663 _mmcam_dbg_log("Can't cast Video source into camera control.");
2667 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2668 if (CameraControl == NULL) {
2669 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2673 controls = gst_camera_control_list_channels(CameraControl);
2674 if (controls == NULL) {
2675 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2679 for (item = controls ; item && item->data ; item = item->next) {
2680 CameraControlChannel = item->data;
2681 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2682 if (!strcmp(CameraControlChannel->label, "pan")) {
2683 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2684 _mmcam_dbg_warn("set pan %d done", value->value.i_val);
2687 _mmcam_dbg_err("failed to set pan %d", value->value.i_val);
2693 _mmcam_dbg_warn("failed to find pan control channel");
2700 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2702 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2703 _MMCamcorderSubContext *sc = NULL;
2704 int current_state = MM_CAMCORDER_STATE_NONE;
2706 GstCameraControl *CameraControl = NULL;
2707 GstCameraControlChannel *CameraControlChannel = NULL;
2708 const GList *controls = NULL;
2709 const GList *item = NULL;
2711 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2713 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2714 mmf_return_val_if_fail(sc, TRUE);
2716 _mmcam_dbg_log("tilt : %d", value->value.i_val);
2718 current_state = _mmcamcorder_get_state(handle);
2719 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2720 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2721 _mmcam_dbg_err("invalid state[%d]", current_state);
2722 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2726 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2727 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2728 _mmcam_dbg_log("Can't cast Video source into camera control.");
2732 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2733 if (CameraControl == NULL) {
2734 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2738 controls = gst_camera_control_list_channels(CameraControl);
2739 if (controls == NULL) {
2740 _mmcam_dbg_err("gst_camera_control_list_channels failed");
2744 for (item = controls ; item && item->data ; item = item->next) {
2745 CameraControlChannel = item->data;
2746 _mmcam_dbg_log("CameraControlChannel->label %s", CameraControlChannel->label);
2747 if (!strcmp(CameraControlChannel->label, "tilt")) {
2748 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2749 _mmcam_dbg_warn("set tilt %d done", value->value.i_val);
2752 _mmcam_dbg_err("failed to set tilt %d", value->value.i_val);
2758 _mmcam_dbg_warn("failed to find tilt control channel");
2765 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2767 MMHandleType attr = 0;
2768 int current_state = MM_CAMCORDER_STATE_NONE;
2769 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2770 _MMCamcorderSubContext *sc = NULL;
2771 GstCameraControl *control = NULL;
2773 int set_focus_mode = 0;
2774 int cur_focus_mode = 0;
2775 int cur_focus_range = 0;
2777 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2779 attr = MMF_CAMCORDER_ATTRS(handle);
2780 mmf_return_val_if_fail(attr, FALSE);
2782 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2786 _mmcam_dbg_log("Focus mode(%d)", value->value.i_val);
2788 /* check whether set or not */
2789 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2790 _mmcam_dbg_log("skip set value %d", value->value.i_val);
2794 current_state = _mmcamcorder_get_state(handle);
2795 if (current_state < MM_CAMCORDER_STATE_NULL) {
2796 _mmcam_dbg_log("Focus mode will be changed later.(state=%d)", current_state);
2798 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2799 _mmcam_dbg_err("Can not set while CAPTURING");
2800 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2804 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2805 int flags = MM_ATTRS_FLAG_NONE;
2806 MMCamAttrsInfo info;
2808 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2809 _mmcam_dbg_log("Can't cast Video source into camera control.");
2813 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2814 if (control == NULL) {
2815 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2819 mslVal = value->value.i_val;
2820 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2822 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2825 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2826 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2827 if (set_focus_mode != cur_focus_mode) {
2828 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2829 _mmcam_dbg_log("Succeed in setting AF mode[%d]", mslVal);
2832 _mmcam_dbg_warn("Failed to set AF mode[%d]", mslVal);
2835 _mmcam_dbg_log("No need to set AF mode. Current[%d]", mslVal);
2839 _mmcam_dbg_warn("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2843 _mmcam_dbg_log("pointer of video src is null");
2850 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2852 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2853 _MMCamcorderSubContext *sc = NULL;
2854 GstCameraControl *control = NULL;
2855 int current_state = MM_CAMCORDER_STATE_NONE;
2858 int cur_focus_mode = 0;
2859 int cur_focus_range = 0;
2860 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2861 int converted_mode = 0;
2863 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2865 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2869 _mmcam_dbg_log("(%d)", attr_idx);
2871 /* check whether set or not */
2872 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2873 _mmcam_dbg_log("skip set value %d", value->value.i_val);
2877 mslVal = value->value.i_val;
2878 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2880 current_state = _mmcamcorder_get_state(handle);
2881 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2882 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
2884 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2885 _mmcam_dbg_err("Can not set while CAPTURING");
2886 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2890 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2891 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2892 _mmcam_dbg_log("Can't cast Video source into camera control.");
2896 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2897 if (control == NULL) {
2898 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
2902 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
2903 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
2905 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2906 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
2907 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
2908 /*_mmcam_dbg_log("Succeed in setting AF mode[%d]", mslVal);*/
2911 _mmcam_dbg_warn("Failed to set AF mode[%d]", mslVal);
2914 /*_mmcam_dbg_log("No need to set AF mode. Current[%d]", mslVal);*/
2918 _mmcam_dbg_warn("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2921 _mmcam_dbg_log("pointer of video src is null");
2928 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2930 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2931 _MMCamcorderSubContext *sc = NULL;
2932 GstCameraControl *control = NULL;
2933 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
2934 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
2936 int current_state = MM_CAMCORDER_STATE_NONE;
2938 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2940 gboolean do_set = FALSE;
2942 MMCamAttrsInfo info_y;
2943 MMCamAttrsInfo info_w;
2944 MMCamAttrsInfo info_h;
2946 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2948 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2952 _mmcam_dbg_log("(%d)", attr_idx);
2954 current_state = _mmcamcorder_get_state(handle);
2955 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
2956 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
2958 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2959 _mmcam_dbg_err("Can not set while CAPTURING");
2960 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2964 ret = mm_camcorder_get_attributes(handle, NULL,
2965 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
2967 if (ret != MM_ERROR_NONE) {
2968 _mmcam_dbg_warn("Failed to get FOCUS MODE.[%x]", ret);
2972 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
2973 _mmcam_dbg_warn("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
2977 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2978 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2979 _mmcam_dbg_log("Can't cast Video source into camera control.");
2983 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
2984 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
2985 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
2988 case MM_CAM_CAMERA_AF_TOUCH_X:
2989 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
2990 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
2991 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
2992 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
2993 set_area.x = value->value.i_val;
2994 mm_camcorder_get_attributes(handle, NULL,
2995 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
2996 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
2997 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3001 _mmcam_dbg_log("Just store AF area[x:%d]", value->value.i_val);
3005 case MM_CAM_CAMERA_AF_TOUCH_Y:
3006 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3007 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3008 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3009 set_area.y = value->value.i_val;
3010 mm_camcorder_get_attributes(handle, NULL,
3011 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3012 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3013 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3017 _mmcam_dbg_log("Just store AF area[y:%d]", value->value.i_val);
3021 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3022 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3023 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3024 set_area.width = value->value.i_val;
3025 mm_camcorder_get_attributes(handle, NULL,
3026 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3027 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3028 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3032 _mmcam_dbg_log("Just store AF area[width:%d]", value->value.i_val);
3036 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3037 set_area.height = value->value.i_val;
3038 mm_camcorder_get_attributes(handle, NULL,
3039 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3040 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3041 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3050 _MMCamcorderVideoInfo *info = sc->info_video;
3053 _mmcam_dbg_err("video info is NULL");
3057 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3058 if (control == NULL) {
3059 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3064 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3065 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3066 float ratio_width = 0.0;
3067 float ratio_height = 0.0;
3069 if (info->preview_width != 0 && info->preview_height != 0) {
3070 ratio_width = (float)info->video_width / (float)info->preview_width;
3071 ratio_height = (float)info->video_height / (float)info->preview_height;
3073 _mmcam_dbg_log("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3074 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3076 set_area.x = (int)((float)set_area.x * ratio_width);
3077 set_area.y = (int)((float)set_area.y * ratio_height);
3078 set_area.width = (int)((float)set_area.width * ratio_width);
3079 set_area.height = (int)((float)set_area.height * ratio_height);
3081 if (set_area.width <= 0)
3084 if (set_area.height <= 0)
3085 set_area.height = 1;
3087 _mmcam_dbg_log("converted area %d,%d,%dx%d",
3088 set_area.x, set_area.y, set_area.width, set_area.height);
3090 _mmcam_dbg_warn("invalid preview size %dx%d, skip AF area converting",
3091 info->preview_width, info->preview_height);
3095 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3097 _mmcam_dbg_warn("Failed to get AF area");
3101 /* width and height are not supported now */
3102 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3103 _mmcam_dbg_log("No need to set AF area[x,y:%d,%d]",
3104 get_area.x, get_area.y);
3108 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3110 _mmcam_dbg_log("Succeed to set AF area[%d,%d,%dx%d]",
3111 set_area.x, set_area.y, set_area.width, set_area.height);
3114 _mmcam_dbg_warn("Failed to set AF area[%d,%d,%dx%d]",
3115 set_area.x, set_area.y, set_area.width, set_area.height);
3119 _mmcam_dbg_log("pointer of video src is null");
3126 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3128 GstCameraControl *control = NULL;
3134 int exposure_type = 0;
3135 int current_state = MM_CAMCORDER_STATE_NONE;
3136 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3137 _MMCamcorderSubContext *sc = NULL;
3139 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3140 gboolean check_scene_mode = FALSE;
3142 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3144 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3148 /* check whether set or not */
3149 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3150 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3154 current_state = _mmcamcorder_get_state(handle);
3155 if (current_state < MM_CAMCORDER_STATE_READY) {
3156 _mmcam_dbg_log("will be applied when preview starts");
3158 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3159 _mmcam_dbg_err("Can not set while CAPTURING");
3160 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3164 ivalue = value->value.i_val;
3166 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3167 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3168 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3169 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3170 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3171 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3172 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3173 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3174 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3175 exposure_type = GST_CAMERA_CONTROL_ISO;
3177 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3178 check_scene_mode = TRUE;
3179 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3180 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3182 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3183 check_scene_mode = TRUE;
3184 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3185 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3186 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3187 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3190 if (check_scene_mode) {
3191 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3192 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3193 _mmcam_dbg_warn("can not set [%d] when scene mode is NOT normal.", attr_idx);
3198 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3201 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3202 _mmcam_dbg_log("Can't cast Video source into camera control.");
3206 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3207 if (control == NULL) {
3208 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3212 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3214 _mmcam_dbg_log("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3217 _mmcam_dbg_warn("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3220 _mmcam_dbg_log("pointer of video src is null");
3227 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3229 GstCameraControl *control = NULL;
3233 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3234 _MMCamcorderSubContext *sc = NULL;
3235 int current_state = MM_CAMCORDER_STATE_NONE;
3237 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3239 /* check whether set or not */
3240 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3241 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3245 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3249 /* check current state */
3250 current_state = _mmcamcorder_get_state(handle);
3251 if (current_state < MM_CAMCORDER_STATE_READY) {
3252 _mmcam_dbg_log("will be applied when preview starts");
3254 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3255 _mmcam_dbg_err("Can not set while CAPTURING");
3256 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3260 mslVal = value->value.i_val;
3261 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3263 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3264 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3265 _mmcam_dbg_log("Can't cast Video source into camera control.");
3269 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3270 if (control == NULL) {
3271 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3275 if (gst_camera_control_get_wdr(control, &cur_value)) {
3276 if (newVal != cur_value) {
3277 if (gst_camera_control_set_wdr(control, newVal)) {
3278 _mmcam_dbg_log("Success - set wdr[%d]", mslVal);
3281 _mmcam_dbg_warn("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3284 _mmcam_dbg_log("No need to set new WDR. Current[%d]", mslVal);
3288 _mmcam_dbg_warn("Failed to get WDR.");
3291 _mmcam_dbg_log("pointer of video src is null");
3298 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3300 int current_state = MM_CAMCORDER_STATE_NONE;
3301 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3303 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3305 /* check whether set or not */
3306 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3307 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3311 current_state = _mmcamcorder_get_state(handle);
3312 if (current_state < MM_CAMCORDER_STATE_READY) {
3313 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3315 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3316 _mmcam_dbg_err("Invaild state (state %d)", current_state);
3317 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3321 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3325 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3329 int current_state = MM_CAMCORDER_STATE_NONE;
3330 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3331 _MMCamcorderSubContext *sc = NULL;
3333 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3335 bitrate = value->value.i_val;
3337 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3338 if (!sc || !sc->encode_element) {
3339 _mmcam_dbg_log("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3343 current_state = _mmcamcorder_get_state(handle);
3344 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3345 _mmcam_dbg_err("Can not set while RECORDING - attr idx %d", attr_idx);
3346 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3350 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3351 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3353 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3354 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3356 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3357 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3364 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3366 int current_state = MM_CAMCORDER_STATE_NONE;
3367 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3369 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3371 current_state = _mmcamcorder_get_state(handle);
3372 if (current_state < MM_CAMCORDER_STATE_READY) {
3373 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3375 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3376 _mmcam_dbg_err("Invaild state (state %d)", current_state);
3377 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3381 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3385 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3387 int current_state = MM_CAMCORDER_STATE_NONE;
3388 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3390 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3392 _mmcam_dbg_log("rotate(%d)", value->value.i_val);
3394 current_state = _mmcamcorder_get_state(handle);
3396 if (current_state > MM_CAMCORDER_STATE_READY) {
3397 _mmcam_dbg_err("camera rotation setting failed.(state=%d)", current_state);
3398 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3401 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3406 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3408 int current_state = MM_CAMCORDER_STATE_NONE;
3410 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3411 _MMCamcorderSubContext *sc = NULL;
3413 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3416 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3417 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3421 /* check current state */
3422 current_state = _mmcamcorder_get_state(handle);
3423 if (current_state < MM_CAMCORDER_STATE_READY) {
3424 _mmcam_dbg_log("NOT initialized. this will be applied later");
3426 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3427 _mmcam_dbg_err("Can not set while CAPTURING");
3428 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3432 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3434 _mmcam_dbg_log("Image encoder quality(%d)", value->value.i_val);
3436 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3437 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3440 _mmcam_dbg_err("invalid state %d", current_state);
3446 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3448 mmf_return_val_if_fail(handle && value, FALSE);
3451 if (!value->value.s_val) {
3452 _mmcam_dbg_err("NULL filename");
3456 _mmcam_dbg_log("set filename [%s]", value->value.s_val);
3462 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3464 int current_state = MM_CAMCORDER_STATE_NONE;
3465 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3467 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3469 current_state = _mmcamcorder_get_state(handle);
3470 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3471 _mmcam_dbg_err("Can not set while RECORDING");
3472 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3480 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3482 GstColorBalance *balance = NULL;
3483 GstColorBalanceChannel *Colorchannel = NULL;
3484 const GList *controls = NULL;
3485 const GList *item = NULL;
3488 int current_state = MM_CAMCORDER_STATE_NONE;
3489 const char *control_label = NULL;
3490 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3491 _MMCamcorderSubContext *sc = NULL;
3493 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3494 gboolean check_scene_mode = FALSE;
3496 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3498 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3502 /* check whether set or not */
3503 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3504 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3508 current_state = _mmcamcorder_get_state(handle);
3509 if (current_state < MM_CAMCORDER_STATE_READY) {
3510 _mmcam_dbg_log("will be applied when preview starts");
3512 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3513 _mmcam_dbg_err("Can not set while CAPTURING");
3514 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3518 if (value->type != MM_ATTRS_TYPE_INT) {
3519 _mmcam_dbg_warn("Mismatched value type (%d)", value->type);
3522 mslNewVal = value->value.i_val;
3526 case MM_CAM_FILTER_BRIGHTNESS:
3527 control_label = "brightness";
3528 check_scene_mode = TRUE;
3531 case MM_CAM_FILTER_CONTRAST:
3532 control_label = "contrast";
3535 case MM_CAM_FILTER_WB:
3536 control_label = "white balance";
3537 check_scene_mode = TRUE;
3540 case MM_CAM_FILTER_COLOR_TONE:
3541 control_label = "color tone";
3544 case MM_CAM_FILTER_SATURATION:
3545 control_label = "saturation";
3546 check_scene_mode = TRUE;
3549 case MM_CAM_FILTER_HUE:
3550 control_label = "hue";
3553 case MM_CAM_FILTER_SHARPNESS:
3554 control_label = "sharpness";
3555 check_scene_mode = TRUE;
3558 _mmcam_dbg_err("unknown attribute index %d", attr_idx);
3562 if (check_scene_mode) {
3563 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3564 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3565 _mmcam_dbg_warn("can not set %s when scene mode is NOT normal.", control_label);
3570 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslNewVal);
3571 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3574 /*_mmcam_dbg_log("label(%s): MSL(%d)->Sensor(%d)", control_label, mslNewVal, newVal);*/
3576 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3577 _mmcam_dbg_log("Can't cast Video source into color balance.");
3581 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3582 if (balance == NULL) {
3583 _mmcam_dbg_err("cast COLOR_BALANCE failed");
3587 controls = gst_color_balance_list_channels(balance);
3588 if (controls == NULL) {
3589 _mmcam_dbg_log("There is no list of colorbalance controls");
3593 for (item = controls ; item && item->data ; item = item->next) {
3594 Colorchannel = item->data;
3595 /*_mmcam_dbg_log("Getting name of CID=(%s), input CID=(%s)", Colorchannel->label, control_label);*/
3597 if (!strcmp(Colorchannel->label, control_label)) {
3598 gst_color_balance_set_value(balance, Colorchannel, newVal);
3599 _mmcam_dbg_log("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslNewVal, newVal);
3605 _mmcam_dbg_err("failed to find color channel item");
3613 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3617 int current_state = MM_CAMCORDER_STATE_NONE;
3618 GstCameraControl *control = NULL;
3619 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3620 _MMCamcorderSubContext *sc = NULL;
3622 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3624 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3628 mslVal = value->value.i_val;
3629 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3631 /* check whether set or not */
3632 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3633 _mmcam_dbg_log("skip set value %d", value->value.i_val);
3637 current_state = _mmcamcorder_get_state(handle);
3638 if (current_state < MM_CAMCORDER_STATE_READY) {
3639 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
3641 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3642 _mmcam_dbg_err("Can not set while CAPTURING");
3643 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3647 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3650 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3651 _mmcam_dbg_log("Can't cast Video source into camera control.");
3655 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3656 if (control == NULL) {
3657 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
3661 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3663 _mmcam_dbg_log("Succeed in setting program mode[%d].", mslVal);
3665 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3669 MM_CAM_FILTER_BRIGHTNESS,
3671 MM_CAM_FILTER_SATURATION,
3672 MM_CAM_FILTER_SHARPNESS,
3673 MM_CAM_FILTER_COLOR_TONE,
3674 MM_CAM_CAMERA_EXPOSURE_MODE
3676 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3678 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3679 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3680 mm_attrs_set_modified(attrs, attr_idxs[i]);
3686 _mmcam_dbg_log("Failed to set program mode[%d].", mslVal);
3689 _mmcam_dbg_warn("pointer of video src is null");
3696 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3698 mmf_return_val_if_fail(handle && value, FALSE);
3700 _mmcam_dbg_warn("Filter Flip(%d)", value->value.i_val);
3706 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3708 mmf_return_val_if_fail(handle && value, FALSE);
3710 _mmcam_dbg_log("Commit : Do nothing. this attr will be removed soon.");
3716 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3718 int current_state = MM_CAMCORDER_STATE_NONE;
3719 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3721 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3723 current_state = _mmcamcorder_get_state(handle);
3724 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3725 _mmcam_dbg_warn("Can NOT Disable AUDIO. invalid state %d", current_state);
3726 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3729 _mmcam_dbg_log("Disable AUDIO when Recording");
3735 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3737 int current_state = MM_CAMCORDER_STATE_NONE;
3738 const char *videosink_name = NULL;
3739 void *p_handle = NULL;
3741 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3742 _MMCamcorderSubContext *sc = NULL;
3744 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3747 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3748 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3752 /* check current state */
3753 current_state = _mmcamcorder_get_state(handle);
3754 if (current_state < MM_CAMCORDER_STATE_READY) {
3755 _mmcam_dbg_log("NOT initialized. this will be applied later");
3759 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3761 p_handle = value->value.p_val;
3763 /* get videosink name */
3764 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3765 if (videosink_name == NULL) {
3766 _mmcam_dbg_err("Please check videosink element in configuration file");
3770 _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name);
3772 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3773 _mmcam_dbg_log("Commit : Set XID[%x]", *(int *)(p_handle));
3774 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(p_handle));
3775 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3776 _mmcam_dbg_log("Commit : Set evas object [%p]", p_handle);
3777 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", p_handle);
3778 } else if (!strcmp(videosink_name, "tizenwlsink")) {
3779 _mmcam_dbg_log("wayland global surface id : %d", *(int *)(p_handle));
3780 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)*(int *)(p_handle));
3782 _mmcam_dbg_warn("Commit : Nothing to commit with this element[%s]", videosink_name);
3786 _mmcam_dbg_warn("Display handle is NULL");
3794 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3796 int current_state = MM_CAMCORDER_STATE_NONE;
3797 const char *videosink_name = NULL;
3799 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3800 _MMCamcorderSubContext *sc = NULL;
3802 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3805 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3806 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3810 /* check current state */
3811 current_state = _mmcamcorder_get_state(handle);
3812 if (current_state < MM_CAMCORDER_STATE_READY) {
3813 _mmcam_dbg_log("NOT initialized. this will be applied later");
3817 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3819 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3820 if (videosink_name == NULL) {
3821 _mmcam_dbg_err("Please check videosink element in configuration file");
3825 _mmcam_dbg_log("Commit : videosinkname[%s]", videosink_name);
3827 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3828 _mmcam_dbg_log("Commit : display mode [%d]", value->value.i_val);
3829 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3831 _mmcam_dbg_warn("[%s] does not support display mode, but no error", videosink_name);
3838 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3840 int current_state = MM_CAMCORDER_STATE_NONE;
3842 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3844 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3847 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3848 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3852 /* check current state */
3853 current_state = _mmcamcorder_get_state(handle);
3854 if (current_state < MM_CAMCORDER_STATE_READY) {
3855 _mmcam_dbg_log("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
3859 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3863 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3865 int current_state = MM_CAMCORDER_STATE_NONE;
3867 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3869 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3872 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3873 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3877 /* check current state */
3878 current_state = _mmcamcorder_get_state(handle);
3879 if (current_state < MM_CAMCORDER_STATE_READY) {
3880 _mmcam_dbg_log("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
3884 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
3888 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3890 int current_state = MM_CAMCORDER_STATE_NONE;
3891 const char *videosink_name = NULL;
3893 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3894 _MMCamcorderSubContext *sc = NULL;
3896 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3899 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3900 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3904 /* check current state */
3905 current_state = _mmcamcorder_get_state(handle);
3906 if (current_state < MM_CAMCORDER_STATE_READY) {
3907 _mmcam_dbg_log("NOT initialized. this will be applied later");
3911 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3913 /* Get videosink name */
3914 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3915 if (videosink_name == NULL) {
3916 _mmcam_dbg_err("Please check videosink element in configuration file");
3920 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
3921 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
3922 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
3923 _mmcam_dbg_log("Set visible [%d] done.", value->value.i_val);
3925 _mmcam_dbg_warn("[%s] does not support VISIBLE, but no error", videosink_name);
3932 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3935 int current_state = MM_CAMCORDER_STATE_NONE;
3936 const char *videosink_name = NULL;
3938 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3939 _MMCamcorderSubContext *sc = NULL;
3941 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3944 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3945 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3949 /* check current state */
3950 current_state = _mmcamcorder_get_state(handle);
3951 if (current_state < MM_CAMCORDER_STATE_READY) {
3952 _mmcam_dbg_log("NOT initialized. this will be applied later");
3956 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3958 /* Get videosink name */
3959 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3960 if (videosink_name == NULL) {
3961 _mmcam_dbg_err("Please check videosink element in configuration file");
3965 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
3966 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink")) {
3967 method = value->value.i_val;
3968 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
3970 _mmcam_dbg_warn("[%s] does not support geometry method, but no error", videosink_name);
3977 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3979 int current_state = MM_CAMCORDER_STATE_NONE;
3980 int ret = MM_ERROR_NONE;
3981 const char *videosink_name = NULL;
3983 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3984 _MMCamcorderSubContext *sc = NULL;
3986 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3989 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3990 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
3994 /* check current state */
3995 current_state = _mmcamcorder_get_state(handle);
3996 if (current_state < MM_CAMCORDER_STATE_READY) {
3997 _mmcam_dbg_log("NOT initialized. this will be applied later");
4001 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4003 /* Get videosink name */
4004 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4005 if (videosink_name == NULL) {
4006 _mmcam_dbg_err("Please check videosink element in configuration file");
4010 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4011 !strcmp(videosink_name, "evaspixmapsink")) {
4015 int rect_height = 0;
4016 int flags = MM_ATTRS_FLAG_NONE;
4017 MMCamAttrsInfo info;
4019 mm_camcorder_get_attributes(handle, NULL,
4020 MMCAM_DISPLAY_RECT_X, &rect_x,
4021 MMCAM_DISPLAY_RECT_Y, &rect_y,
4022 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4023 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4026 case MM_CAM_DISPLAY_RECT_X:
4027 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4029 memset(&info, 0x00, sizeof(info));
4030 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4032 memset(&info, 0x00, sizeof(info));
4033 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4036 rect_x = value->value.i_val;
4038 case MM_CAM_DISPLAY_RECT_Y:
4039 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4041 memset(&info, 0x00, sizeof(info));
4042 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4045 rect_y = value->value.i_val;
4047 case MM_CAM_DISPLAY_RECT_WIDTH:
4048 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4051 rect_width = value->value.i_val;
4053 case MM_CAM_DISPLAY_RECT_HEIGHT:
4054 rect_height = value->value.i_val;
4057 _mmcam_dbg_err("Wrong attr_idx!");
4061 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4062 _mmcam_dbg_log("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4064 if (!strcmp(videosink_name, "tizenwlsink")) {
4065 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4066 rect_x, rect_y, rect_width, rect_height);
4068 _mmcam_dbg_err("FAILED : could not set display roi area.");
4072 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4073 "dst-roi-x", rect_x,
4074 "dst-roi-y", rect_y,
4075 "dst-roi-w", rect_width,
4076 "dst-roi-h", rect_height,
4081 _mmcam_dbg_warn("[%s] does not support display rect, but no error", videosink_name);
4088 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4091 int current_state = MM_CAMCORDER_STATE_NONE;
4092 const char *videosink_name = NULL;
4093 GstElement *vs_element = NULL;
4095 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4096 _MMCamcorderSubContext *sc = NULL;
4098 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4101 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4102 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
4106 /* check current state */
4107 current_state = _mmcamcorder_get_state(handle);
4108 if (current_state < MM_CAMCORDER_STATE_READY) {
4109 _mmcam_dbg_log("NOT initialized. this will be applied later");
4113 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4115 /* Get videosink name */
4116 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4117 if (videosink_name == NULL) {
4118 _mmcam_dbg_err("Please check videosink element in configuration file");
4122 zoom = value->value.i_val;
4123 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4124 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4126 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4127 _mmcam_dbg_log("Set display zoom to %d", zoom + 1);
4131 _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name);
4137 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4139 int current_state = MM_CAMCORDER_STATE_NONE;
4141 const char *videosink_name = NULL;
4143 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4144 _MMCamcorderSubContext *sc = NULL;
4146 mmf_return_val_if_fail(handle && value, FALSE);
4149 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4150 _mmcam_dbg_err("invalid mode %d", hcamcorder->type);
4154 /* check current state */
4155 current_state = _mmcamcorder_get_state(handle);
4156 if (current_state < MM_CAMCORDER_STATE_READY) {
4157 _mmcam_dbg_log("NOT initialized. this will be applied later");
4161 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4163 do_scaling = value->value.i_val;
4165 /* Get videosink name */
4166 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4167 if (videosink_name == NULL) {
4168 _mmcam_dbg_err("Please check videosink element in configuration file");
4172 if (!strcmp(videosink_name, "evaspixmapsink")) {
4173 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4174 _mmcam_dbg_log("Set origin-size to %d", !(value->value.i_val));
4177 _mmcam_dbg_warn("videosink[%s] does not support scale", videosink_name);
4183 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4186 _MMCamcorderSubContext *sc = NULL;
4187 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4188 int strobe_type, mslVal, newVal, cur_value;
4189 int current_state = MM_CAMCORDER_STATE_NONE;
4191 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4193 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4197 /*_mmcam_dbg_log( "Commit : strobe attribute(%d)", attr_idx );*/
4199 mslVal = value->value.i_val;
4201 /* check flash state */
4202 if (attr_idx == MM_CAM_STROBE_MODE) {
4203 int flash_brightness = 0;
4205 /* get current flash brightness */
4206 if (_mmcamcorder_get_device_flash_brightness(hcamcorder->gdbus_conn, &flash_brightness) != MM_ERROR_NONE) {
4207 _mmcam_dbg_err("_mmcamcorder_get_device_flash_brightness failed");
4208 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4212 _mmcam_dbg_log("flash brightness %d", flash_brightness);
4214 if (flash_brightness > 0 &&
4215 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4216 /* other module already turned on flash */
4217 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4218 _mmcam_dbg_err("other module already turned on flash. avoid to set flash mode here.");
4221 _mmcam_dbg_log("keep going");
4226 current_state = _mmcamcorder_get_state(handle);
4227 if (current_state < MM_CAMCORDER_STATE_READY) {
4228 _mmcam_dbg_log("It doesn't need to change dynamically.(state=%d)", current_state);
4230 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4231 _mmcam_dbg_err("Can not set while CAPTURING");
4232 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4237 case MM_CAM_STROBE_CONTROL:
4238 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4239 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4241 case MM_CAM_STROBE_CAPABILITIES:
4242 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4245 case MM_CAM_STROBE_MODE:
4246 /* check whether set or not */
4247 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4248 _mmcam_dbg_log("skip set value %d", mslVal);
4252 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4253 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4256 _mmcam_dbg_err("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4260 GstCameraControl *control = NULL;
4261 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4262 _mmcam_dbg_err("Can't cast Video source into camera control.");
4265 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4266 if (control == NULL) {
4267 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
4271 if (gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4272 if (newVal != cur_value) {
4273 if (gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4274 _mmcam_dbg_log("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4277 _mmcam_dbg_warn("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4281 _mmcam_dbg_log("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4285 _mmcam_dbg_warn("Failed to get strobe. Type[%d]", strobe_type);
4294 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4297 int current_state = MM_CAMCORDER_STATE_NONE;
4298 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4300 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4302 _mmcam_dbg_log("Commit : flip %d", value->value.i_val);
4305 current_state = _mmcamcorder_get_state(handle);
4306 if (current_state > MM_CAMCORDER_STATE_READY) {
4307 _mmcam_dbg_err("Can not set camera FLIP horizontal at state %d", current_state);
4308 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4310 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4311 _mmcam_dbg_log("Pipeline is not created yet. This will be set when create pipeline.");
4315 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4317 _mmcam_dbg_log("ret %d", ret);
4323 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4325 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4326 int current_state = MM_CAMCORDER_STATE_NONE;
4327 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4328 _MMCamcorderSubContext *sc = NULL;
4330 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4332 /*_mmcam_dbg_log("Commit : HDR Capture %d", value->value.i_val);*/
4334 /* check whether set or not */
4335 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4336 _mmcam_dbg_log("skip set value %d", value->value.i_val);
4341 current_state = _mmcamcorder_get_state(handle);
4342 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4343 _mmcam_dbg_err("can NOT set HDR capture at state %d", current_state);
4344 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4348 if (current_state >= MM_CAMCORDER_STATE_READY) {
4349 int current_value = 0;
4351 set_hdr_mode = value->value.i_val;
4352 mm_camcorder_get_attributes(handle, NULL,
4353 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4356 if (set_hdr_mode == current_value) {
4357 _mmcam_dbg_log("same HDR value : %d, do nothing", set_hdr_mode);
4361 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4363 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4364 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4365 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4367 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4369 /* check decoder recreation */
4370 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4371 _mmcam_dbg_err("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4375 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4376 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4379 set_hdr_mode = value->value.i_val;
4380 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4381 sc->info_image->hdr_capture_mode = set_hdr_mode;
4382 _mmcam_dbg_log("set HDR mode : %d", set_hdr_mode);
4384 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4385 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4387 _mmcam_dbg_err("sc is NULL. can not set HDR capture");
4396 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4399 _MMCamcorderSubContext *sc = NULL;
4400 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4402 int current_value = 0;
4403 int current_state = MM_CAMCORDER_STATE_NONE;
4404 GstCameraControl *control = NULL;
4406 mmf_return_val_if_fail(handle && value, FALSE);
4408 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4412 /*_mmcam_dbg_log("Commit : detect attribute(%d)", attr_idx);*/
4415 current_state = _mmcamcorder_get_state(handle);
4416 if (current_state < MM_CAMCORDER_STATE_READY) {
4417 _mmcam_dbg_log("will be applied when preview starts");
4421 set_value = value->value.i_val;
4424 case MM_CAM_DETECT_MODE:
4425 /* check whether set or not */
4426 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4427 _mmcam_dbg_log("skip set value %d", set_value);
4431 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4433 case MM_CAM_DETECT_NUMBER:
4434 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4436 case MM_CAM_DETECT_FOCUS_SELECT:
4437 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4439 case MM_CAM_DETECT_SELECT_NUMBER:
4440 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4442 case MM_CAM_DETECT_STATUS:
4443 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4446 _mmcam_dbg_err("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4450 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4451 _mmcam_dbg_err("Can't cast Video source into camera control.");
4454 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4455 if (control == NULL) {
4456 _mmcam_dbg_err("cast CAMERA_CONTROL failed");
4460 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4461 if (current_value == set_value) {
4462 _mmcam_dbg_log("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4465 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4466 _mmcam_dbg_warn("Set detect failed. Type[%d],value[%d]",
4467 detect_type, set_value);
4470 _mmcam_dbg_log("Set detect success. Type[%d],value[%d]",
4471 detect_type, set_value);
4476 _mmcam_dbg_warn("Get detect failed. Type[%d]", detect_type);
4485 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4487 int current_state = MM_CAMCORDER_STATE_NONE;
4488 int preview_format = MM_PIXEL_FORMAT_NV12;
4490 mmf_return_val_if_fail(handle && value, FALSE);
4492 _mmcam_dbg_log("Commit : encoded preview bitrate - %d", value->value.i_val);
4494 /* check preview format */
4495 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4496 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4497 _mmcam_dbg_err("current preview format[%d] is not encoded format", preview_format);
4502 current_state = _mmcamcorder_get_state(handle);
4503 if (current_state < MM_CAMCORDER_STATE_READY) {
4504 _mmcam_dbg_log("will be applied when preview starts");
4508 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4512 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4514 int current_state = MM_CAMCORDER_STATE_NONE;
4515 int preview_format = MM_PIXEL_FORMAT_NV12;
4517 mmf_return_val_if_fail(handle && value, FALSE);
4519 _mmcam_dbg_log("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4521 /* check preview format */
4522 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4523 if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
4524 _mmcam_dbg_err("current preview format[%d] is not encoded format", preview_format);
4529 current_state = _mmcamcorder_get_state(handle);
4530 if (current_state < MM_CAMCORDER_STATE_READY) {
4531 _mmcam_dbg_log("will be applied when preview starts");
4535 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4539 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4541 int stream_index = 0;
4542 char *stream_type = NULL;
4543 _MMCamcorderSubContext *sc = NULL;
4545 mmf_return_val_if_fail(handle && value, FALSE);
4547 stream_type = value->value.s_val;
4549 _mmcam_dbg_err("NULL string");
4553 mm_camcorder_get_attributes(handle, NULL,
4554 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4556 if (stream_index < 0) {
4557 _mmcam_dbg_err("invalid stream index %d", stream_index);
4561 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4562 if (!sc || !sc->encode_element ||
4563 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4564 _mmcam_dbg_warn("audiosrc element is not initialized, it will be set later");
4568 _mmcam_dbg_warn("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4570 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4574 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4576 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4577 int current_state = MM_CAMCORDER_STATE_NONE;
4579 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4581 current_state = _mmcamcorder_get_state(handle);
4582 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4583 _mmcam_dbg_err("Can not set while CAPTURING");
4584 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4591 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4593 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4595 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4597 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4598 /* Replay gain enable */
4599 int current_state = MM_CAMCORDER_STATE_NONE;
4600 int audio_disable = FALSE;
4602 current_state = _mmcamcorder_get_state(handle);
4603 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4604 _mmcam_dbg_err("Can not set replay gain enable [state : %d]", current_state);
4605 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4609 mm_camcorder_get_attributes(handle, NULL,
4610 MMCAM_AUDIO_DISABLE, &audio_disable,
4613 if (audio_disable) {
4614 _mmcam_dbg_err("audio is disabled");
4615 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4619 _mmcam_dbg_log("set replay gain enable : %d", value->value.i_val);
4620 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4621 /* Replay gain reference level */
4622 int replay_gain_enable = FALSE;
4624 mm_camcorder_get_attributes(handle, NULL,
4625 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4628 if (replay_gain_enable == FALSE) {
4629 _mmcam_dbg_err("replay gain is disabled");
4630 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4634 _mmcam_dbg_log("set reference level for replay gain : %lf dB", value->value.d_val);
4636 _mmcam_dbg_err("unknown attribute id %d", attr_idx);
4644 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4646 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4649 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4653 int attr_idxs_default[] = {
4654 MM_CAM_CAMERA_DIGITAL_ZOOM,
4655 MM_CAM_CAMERA_OPTICAL_ZOOM,
4657 MM_CAM_FILTER_CONTRAST,
4662 int attr_idxs_extra[] = {
4664 MM_CAM_FILTER_BRIGHTNESS,
4666 MM_CAM_FILTER_SATURATION,
4667 MM_CAM_FILTER_SHARPNESS,
4668 MM_CAM_FILTER_COLOR_TONE,
4669 MM_CAM_CAMERA_EXPOSURE_MODE
4672 mmf_return_val_if_fail(hcamcorder, FALSE);
4674 _mmcam_dbg_log("commit some attributes again");
4676 attrs = MMF_CAMCORDER_ATTRS(handle);
4677 if (attrs == NULL) {
4678 _mmcam_dbg_err("Get attribute handle failed.");
4682 /* Get Scene mode */
4683 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4685 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4686 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4687 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4690 /* Set extra if scene mode is NORMAL */
4691 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4692 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4693 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4694 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4697 /* Set scene mode if scene mode is NOT NORMAL */
4698 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4699 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4702 if (mm_attrs_commit_all(attrs) == -1)
4707 _mmcam_dbg_log("Done.");
4713 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4715 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4723 mmf_return_val_if_fail(hcamcorder, FALSE);
4725 _mmcam_dbg_log("commit some attribute again[2]");
4727 attrs = MMF_CAMCORDER_ATTRS(handle);
4728 if (attrs == NULL) {
4729 _mmcam_dbg_err("Get attribute handle failed.");
4733 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4734 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4735 mm_attrs_set_modified(attrs, attr_idxs[i]);
4738 if (mm_attrs_commit_all(attrs) == -1)
4743 _mmcam_dbg_log("Done.");
4749 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4751 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4755 int nerror = MM_ERROR_NONE;
4757 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4759 attrs = MMF_CAMCORDER_ATTRS(handle);
4760 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4764 table_size = ARRAY_SIZE(readonly_attributes);
4765 _mmcam_dbg_log("%d", table_size);
4766 for (i = 0; i < table_size; i++) {
4767 int sCategory = readonly_attributes[i];
4769 mm_attrs_set_readonly(attrs, sCategory);
4776 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4778 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4781 type_string_array * disabled_attr = NULL;
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);
4793 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4794 CONFIGURE_CATEGORY_MAIN_GENERAL,
4795 "DisabledAttributes",
4797 if (disabled_attr != NULL && disabled_attr->value) {
4798 cnt_str = disabled_attr->count;
4799 for (i = 0; i < cnt_str; i++) {
4801 _mmcam_dbg_log("[%d]%s", i, disabled_attr->value[i]);
4802 nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
4804 if (nerror == MM_ERROR_NONE)
4805 mm_attrs_set_disabled(attrs, idx);
4807 _mmcam_dbg_warn("No ATTR named %s[%d]", disabled_attr->value[i], i);
4815 /*---------------------------------------------------------------------------------------
4816 | INTERNAL FUNCTION DEFINITIONS: |
4817 ---------------------------------------------------------------------------------------*/
4818 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
4820 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4821 _MMCamcorderSubContext *sc = NULL;
4822 int current_state = MM_CAMCORDER_STATE_NULL;
4824 mmf_return_val_if_fail(hcamcorder, FALSE);
4826 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4830 current_state = _mmcamcorder_get_state(handle);
4832 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
4833 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
4834 _mmcam_dbg_log("set capture width and height [%dx%d] to camera plugin", width, height);
4835 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
4836 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
4838 _mmcam_dbg_warn("invalid state[%d]", current_state);
4842 _mmcam_dbg_log("element is not created yet");
4849 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
4851 #define INIT_VALUE -1
4852 #define CHECK_COUNT 3
4854 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4855 MMHandleType attrs = 0;
4857 int ret = MM_ERROR_NONE;
4860 const char *name = NULL;
4861 const char *check_pair_name[CHECK_COUNT][3] = {
4862 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
4863 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
4864 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
4867 int check_pair_value[CHECK_COUNT][2] = {
4868 {INIT_VALUE, INIT_VALUE},
4869 {INIT_VALUE, INIT_VALUE},
4870 {INIT_VALUE, INIT_VALUE},
4873 if (hcamcorder == NULL || attribute_name == NULL) {
4874 _mmcam_dbg_warn("handle[%p] or attribute_name[%p] is NULL.",
4875 hcamcorder, attribute_name);
4876 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4880 *err_attr_name = NULL;
4882 /*_mmcam_dbg_log( "ENTER" );*/
4884 attrs = MMF_CAMCORDER_ATTRS(handle);
4886 name = attribute_name;
4890 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
4892 /*_mmcam_dbg_log("NAME : %s", name);*/
4894 /* attribute name check */
4895 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
4897 *err_attr_name = strdup(name);
4899 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
4900 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
4906 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
4909 switch (attr_type) {
4910 case MM_ATTRS_TYPE_INT:
4912 gboolean matched = FALSE;
4913 for (i = 0 ; i < CHECK_COUNT ; i++) {
4914 for (j = 0 ; j < 2 ; j++) {
4915 if (!strcmp(name, check_pair_name[i][j])) {
4916 check_pair_value[i][j] = va_arg((var_args), int);
4917 _mmcam_dbg_log("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
4925 if (matched == FALSE)
4926 va_arg((var_args), int);
4929 case MM_ATTRS_TYPE_DOUBLE:
4930 va_arg((var_args), double);
4932 case MM_ATTRS_TYPE_STRING:
4933 va_arg((var_args), char*); /* string */
4934 va_arg((var_args), int); /* size */
4936 case MM_ATTRS_TYPE_DATA:
4937 va_arg((var_args), void*); /* data */
4938 va_arg((var_args), int); /* size */
4940 case MM_ATTRS_TYPE_INVALID:
4942 _mmcam_dbg_err("Not supported attribute type(%d, name:%s)", attr_type, name);
4944 *err_attr_name = strdup(name);
4946 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
4950 name = va_arg(var_args, const char*);
4953 for (i = 0 ; i < CHECK_COUNT ; i++) {
4954 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
4955 gboolean check_result = FALSE;
4956 char *err_name = NULL;
4957 MMCamAttrsInfo attr_info_0, attr_info_1;
4959 if (check_pair_value[i][0] == INIT_VALUE) {
4960 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
4961 err_name = strdup(check_pair_name[i][1]);
4962 } else if (check_pair_value[i][1] == INIT_VALUE) {
4963 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
4964 err_name = strdup(check_pair_name[i][0]);
4966 err_name = strdup(check_pair_name[i][2]);
4969 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
4970 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
4972 check_result = FALSE;
4974 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
4975 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
4976 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
4978 _mmcam_dbg_log("Valid Pair[%s,%s] existed %dx%d[index:%d]",
4979 check_pair_name[i][0], check_pair_name[i][1],
4980 check_pair_value[i][0], check_pair_value[i][1], i);
4982 check_result = TRUE;
4987 if (check_result == FALSE) {
4988 _mmcam_dbg_err("INVALID pair[%s,%s] %dx%d",
4989 check_pair_name[i][0], check_pair_name[i][1],
4990 check_pair_value[i][0], check_pair_value[i][1]);
4991 if (err_attr_name) {
4992 *err_attr_name = err_name;
5000 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5003 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5004 int current_width = 0;
5005 int current_height = 0;
5007 mm_camcorder_get_attributes(handle, NULL,
5008 MMCAM_CAMERA_WIDTH, ¤t_width,
5009 MMCAM_CAMERA_HEIGHT, ¤t_height,
5012 if (current_width != check_pair_value[i][0] ||
5013 current_height != check_pair_value[i][1]) {
5014 hcamcorder->resolution_changed = TRUE;
5016 hcamcorder->resolution_changed = FALSE;
5019 _mmcam_dbg_log("resolution changed : %d", hcamcorder->resolution_changed);
5029 /*_mmcam_dbg_log("DONE");*/
5031 return MM_ERROR_NONE;
5035 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5039 if ((void *)handle == NULL) {
5040 _mmcam_dbg_warn("handle %p is NULL", handle);
5044 memset(&info, 0x0, sizeof(MMAttrsInfo));
5046 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5048 switch (info.validity_type) {
5049 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5051 _mmcam_dbg_log("int array count %d", info.int_array.count);
5053 if (info.int_array.count < 1)
5056 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5058 _mmcam_dbg_log("int range min %d, max %d",info.int_range.min, info.int_range.max);
5060 if (info.int_range.min > info.int_range.max)
5063 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5065 _mmcam_dbg_log("double array count %d", info.double_array.count);
5067 if (info.double_array.count < 1)
5070 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5072 _mmcam_dbg_log("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5074 if (info.double_range.min >= info.double_range.max)
5078 _mmcam_dbg_warn("invalid type %d", info.validity_type);