4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jeongmo Yang <jm80.yang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 /*=======================================================================================
25 =======================================================================================*/
26 #include "mm_camcorder_internal.h"
27 #include "mm_camcorder_gstcommon.h"
29 #include <gst/video/colorbalance.h>
30 #include <gst/video/cameracontrol.h>
31 #include <gst/video/videooverlay.h>
33 /*-----------------------------------------------------------------------
34 | MACRO DEFINITIONS: |
35 -----------------------------------------------------------------------*/
36 #define MMCAMCORDER_DEFAULT_CAMERA_WIDTH 640
37 #define MMCAMCORDER_DEFAULT_CAMERA_HEIGHT 480
38 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE (1024*1024*10)
39 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL 1000
40 #define MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL 89.0
42 /*---------------------------------------------------------------------------------------
43 | GLOBAL VARIABLE DEFINITIONS for internal |
44 ---------------------------------------------------------------------------------------*/
46 /*-----------------------------------------------------------------------
47 | LOCAL VARIABLE DEFINITIONS for internal |
48 -----------------------------------------------------------------------*/
49 /* Readonly attributes list.
50 * If you want to make some attributes read only, write down here.
51 * It will make them read only after composing whole attributes.
54 static int readonly_attributes[] = {
55 MM_CAM_CAMERA_DEVICE_COUNT,
56 MM_CAM_CAMERA_DEVICE_NAME,
57 MM_CAM_CAMERA_FACING_DIRECTION,
58 MM_CAM_CAMERA_SHUTTER_SPEED,
59 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
60 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
61 MM_CAM_CAPTURED_SCREENNAIL,
62 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
63 MM_CAM_SUPPORT_ZSL_CAPTURE,
64 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
65 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
66 MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
67 MM_CAM_VIDEOSRC_ELEMENT_NAME,
68 MM_CAM_AUDIOSRC_ELEMENT_NAME
71 /*-----------------------------------------------------------------------
72 | LOCAL FUNCTION PROTOTYPES: |
73 -----------------------------------------------------------------------*/
74 /* STATIC INTERNAL FUNCTION */
75 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height);
76 static int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle);
77 static int __mmcamcorder_release_conf_valid_info(MMHandleType handle);
78 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
80 /*=======================================================================
81 | FUNCTION DEFINITIONS |
82 =======================================================================*/
83 /*-----------------------------------------------------------------------
84 | GLOBAL FUNCTION DEFINITIONS: |
85 -----------------------------------------------------------------------*/
87 _mmcamcorder_alloc_attribute(MMHandleType handle)
91 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
92 MMHandleType attrs = NULL;
93 MMAttrsConstructInfo *attrs_const_info;
94 unsigned int attr_count = 0;
96 int ret = MM_ERROR_NONE;
98 static int depth[] = {MM_CAMCORDER_AUDIO_FORMAT_PCM_U8, MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE};
99 static int flip_list[] = { MM_FLIP_NONE };
100 static int rotation_list[] = { MM_VIDEO_INPUT_ROTATION_NONE };
101 static int visible_values[] = { 0, 1 }; /*0: off, 1:on*/
102 static int tag_orientation_values[] = {
103 1, /*The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.*/
104 2, /*the 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.*/
105 3, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.*/
106 4, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.*/
107 5, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual top.*/
108 6, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual top.*/
109 7, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.*/
110 8, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.*/
113 if (hcamcorder == NULL) {
114 MMCAM_LOG_ERROR("handle is NULL");
118 /* Create attribute constructor */
119 MMCAM_LOG_INFO("start");
121 /* alloc 'MMAttrsConstructInfo' */
122 attr_count = MM_CAM_ATTRIBUTE_NUM;
123 attrs_const_info = malloc(attr_count * sizeof(MMAttrsConstructInfo));
124 if (!attrs_const_info) {
125 MMCAM_LOG_ERROR("Fail to alloc constructor.");
129 /* alloc default attribute info */
130 hcamcorder->cam_attrs_const_info = (mm_cam_attr_construct_info *)malloc(sizeof(mm_cam_attr_construct_info) * attr_count);
131 if (hcamcorder->cam_attrs_const_info == NULL) {
132 MMCAM_LOG_ERROR("failed to alloc default attribute info");
133 free(attrs_const_info);
134 attrs_const_info = NULL;
138 /* basic attributes' info */
139 mm_cam_attr_construct_info temp_info[] = {
142 MM_CAM_MODE, /* ID */
144 MM_ATTRS_TYPE_INT, /* Type */
145 MM_ATTRS_FLAG_RW, /* Flag */
146 {(void*)MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Default value */
147 MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */
148 {.int_min = MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Validity val1 (min, *array,...) */
149 {.int_max = MM_CAMCORDER_MODE_AUDIO}, /* Validity val2 (max, count, ...) */
150 NULL, /* Runtime setting function of the attribute */
157 {(void*)MM_AUDIO_DEVICE_MIC},
158 MM_ATTRS_VALID_TYPE_INT_ARRAY,
164 MM_CAM_CAMERA_DEVICE_COUNT,
165 "camera-device-count",
168 {(void*)MM_VIDEO_DEVICE_NUM},
169 MM_ATTRS_VALID_TYPE_INT_RANGE,
170 {.int_min = MM_VIDEO_DEVICE_NONE},
171 {.int_max = MM_VIDEO_DEVICE_NUM},
175 MM_CAM_AUDIO_ENCODER,
179 {(void*)MM_AUDIO_CODEC_AMR},
180 MM_ATTRS_VALID_TYPE_INT_ARRAY,
186 MM_CAM_VIDEO_ENCODER,
190 {(void*)MM_VIDEO_CODEC_MPEG4},
191 MM_ATTRS_VALID_TYPE_INT_ARRAY,
197 MM_CAM_IMAGE_ENCODER,
201 {(void*)MM_IMAGE_CODEC_JPEG},
202 MM_ATTRS_VALID_TYPE_INT_ARRAY,
212 {(void*)MM_FILE_FORMAT_MP4},
213 MM_ATTRS_VALID_TYPE_INT_ARRAY,
219 MM_CAM_CAMERA_DEVICE_NAME,
220 "camera-device-name",
221 MM_ATTRS_TYPE_STRING,
224 MM_ATTRS_VALID_TYPE_NONE,
230 MM_CAM_AUDIO_SAMPLERATE,
235 MM_ATTRS_VALID_TYPE_INT_RANGE,
237 {.int_max = _MMCAMCORDER_MAX_INT},
245 {(void*)MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE},
246 MM_ATTRS_VALID_TYPE_INT_ARRAY,
253 MM_CAM_AUDIO_CHANNEL,
258 MM_ATTRS_VALID_TYPE_INT_RANGE,
266 MM_ATTRS_TYPE_DOUBLE,
268 {.value_double = 1.0},
269 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
271 {.double_max = 10.0},
272 _mmcamcorder_commit_audio_volume,
275 MM_CAM_AUDIO_INPUT_ROUTE,
279 {(void*)MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
280 MM_ATTRS_VALID_TYPE_INT_RANGE,
281 {.int_min = MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
282 {.int_max = MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY},
283 _mmcamcorder_commit_audio_input_route,
286 MM_CAM_FILTER_SCENE_MODE,
291 MM_ATTRS_VALID_TYPE_INT_ARRAY,
294 _mmcamcorder_commit_filter_scene_mode,
297 MM_CAM_FILTER_BRIGHTNESS,
302 MM_ATTRS_VALID_TYPE_INT_RANGE,
305 _mmcamcorder_commit_filter,
308 MM_CAM_FILTER_CONTRAST,
313 MM_ATTRS_VALID_TYPE_INT_RANGE,
316 _mmcamcorder_commit_filter,
324 MM_ATTRS_VALID_TYPE_INT_ARRAY,
327 _mmcamcorder_commit_filter,
330 MM_CAM_FILTER_COLOR_TONE,
335 MM_ATTRS_VALID_TYPE_INT_ARRAY,
338 _mmcamcorder_commit_filter,
341 MM_CAM_FILTER_SATURATION,
346 MM_ATTRS_VALID_TYPE_INT_RANGE,
349 _mmcamcorder_commit_filter,
357 MM_ATTRS_VALID_TYPE_INT_RANGE,
360 _mmcamcorder_commit_filter,
364 MM_CAM_FILTER_SHARPNESS,
369 MM_ATTRS_VALID_TYPE_INT_RANGE,
372 _mmcamcorder_commit_filter,
375 MM_CAM_CAMERA_FORMAT,
379 {(void*)MM_PIXEL_FORMAT_YUYV},
380 MM_ATTRS_VALID_TYPE_INT_ARRAY,
383 _mmcamcorder_commit_camera_format,
386 MM_CAM_CAMERA_RECORDING_MOTION_RATE,
387 "camera-recording-motion-rate",
388 MM_ATTRS_TYPE_DOUBLE,
390 {.value_double = 1.0},
391 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
393 {.double_max = _MMCAMCORDER_MAX_DOUBLE},
394 _mmcamcorder_commit_camera_recording_motion_rate,
402 MM_ATTRS_VALID_TYPE_INT_RANGE,
405 _mmcamcorder_commit_camera_fps,
412 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
413 MM_ATTRS_VALID_TYPE_INT_ARRAY,
416 _mmcamcorder_commit_camera_width,
419 MM_CAM_CAMERA_HEIGHT,
423 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
424 MM_ATTRS_VALID_TYPE_INT_ARRAY,
427 _mmcamcorder_commit_camera_height,
430 MM_CAM_CAMERA_DIGITAL_ZOOM,
431 "camera-digital-zoom",
435 MM_ATTRS_VALID_TYPE_INT_RANGE,
438 _mmcamcorder_commit_camera_zoom,
441 MM_CAM_CAMERA_OPTICAL_ZOOM,
442 "camera-optical-zoom",
446 MM_ATTRS_VALID_TYPE_INT_RANGE,
449 _mmcamcorder_commit_camera_zoom,
452 MM_CAM_CAMERA_FOCUS_MODE,
456 {(void*)MM_CAMCORDER_FOCUS_MODE_NONE},
457 MM_ATTRS_VALID_TYPE_INT_ARRAY,
460 _mmcamcorder_commit_camera_focus_mode,
463 MM_CAM_CAMERA_AF_SCAN_RANGE,
464 "camera-af-scan-range",
468 MM_ATTRS_VALID_TYPE_INT_ARRAY,
471 _mmcamcorder_commit_camera_af_scan_range,
475 MM_CAM_CAMERA_EXPOSURE_MODE,
476 "camera-exposure-mode",
480 MM_ATTRS_VALID_TYPE_INT_ARRAY,
483 _mmcamcorder_commit_camera_capture_mode,
486 MM_CAM_CAMERA_EXPOSURE_VALUE,
487 "camera-exposure-value",
491 MM_ATTRS_VALID_TYPE_INT_RANGE,
494 _mmcamcorder_commit_camera_capture_mode,
497 MM_CAM_CAMERA_F_NUMBER,
502 MM_ATTRS_VALID_TYPE_INT_ARRAY,
505 _mmcamcorder_commit_camera_capture_mode,
508 MM_CAM_CAMERA_SHUTTER_SPEED,
509 "camera-shutter-speed",
513 MM_ATTRS_VALID_TYPE_INT_ARRAY,
516 _mmcamcorder_commit_camera_capture_mode,
524 MM_ATTRS_VALID_TYPE_INT_ARRAY,
527 _mmcamcorder_commit_camera_capture_mode,
535 MM_ATTRS_VALID_TYPE_INT_ARRAY,
538 _mmcamcorder_commit_camera_wdr,
541 MM_CAM_CAMERA_ANTI_HANDSHAKE,
542 "camera-anti-handshake",
546 MM_ATTRS_VALID_TYPE_INT_ARRAY,
549 _mmcamcorder_commit_camera_anti_handshake,
552 MM_CAM_CAMERA_FPS_AUTO,
557 MM_ATTRS_VALID_TYPE_INT_RANGE,
560 _mmcamcorder_commit_camera_fps,
563 MM_CAM_CAMERA_DELAY_ATTR_SETTING,
564 "camera-delay-attr-setting",
568 MM_ATTRS_VALID_TYPE_INT_RANGE,
574 MM_CAM_AUDIO_ENCODER_BITRATE,
575 "audio-encoder-bitrate",
579 MM_ATTRS_VALID_TYPE_INT_RANGE,
581 {.int_max = _MMCAMCORDER_MAX_INT},
582 _mmcamcorder_commit_encoder_bitrate,
586 MM_CAM_VIDEO_ENCODER_BITRATE,
587 "video-encoder-bitrate",
591 MM_ATTRS_VALID_TYPE_INT_RANGE,
593 {.int_max = _MMCAMCORDER_MAX_INT},
594 _mmcamcorder_commit_encoder_bitrate,
597 MM_CAM_IMAGE_ENCODER_QUALITY,
598 "image-encoder-quality",
602 MM_ATTRS_VALID_TYPE_INT_RANGE,
605 _mmcamcorder_commit_image_encoder_quality,
608 MM_CAM_CAPTURE_FORMAT,
612 {(void*)MM_PIXEL_FORMAT_ENCODED},
613 MM_ATTRS_VALID_TYPE_INT_ARRAY,
619 MM_CAM_CAPTURE_WIDTH,
624 MM_ATTRS_VALID_TYPE_INT_ARRAY,
627 _mmcamcorder_commit_capture_width ,
630 MM_CAM_CAPTURE_HEIGHT,
635 MM_ATTRS_VALID_TYPE_INT_ARRAY,
638 _mmcamcorder_commit_capture_height,
641 MM_CAM_CAPTURE_COUNT,
646 MM_ATTRS_VALID_TYPE_INT_RANGE,
649 _mmcamcorder_commit_capture_count,
652 MM_CAM_CAPTURE_INTERVAL,
657 MM_ATTRS_VALID_TYPE_INT_RANGE,
659 {.int_max = _MMCAMCORDER_MAX_INT},
663 MM_CAM_CAPTURE_BREAK_CONTINUOUS_SHOT,
664 "capture-break-cont-shot",
668 MM_ATTRS_VALID_TYPE_INT_RANGE,
671 _mmcamcorder_commit_capture_break_cont_shot,
674 MM_CAM_DISPLAY_HANDLE,
679 MM_ATTRS_VALID_TYPE_NONE,
682 _mmcamcorder_commit_display_handle,
685 MM_CAM_DISPLAY_DEVICE,
689 {(void*)MM_DISPLAY_DEVICE_MAINLCD},
690 MM_ATTRS_VALID_TYPE_INT_ARRAY,
697 MM_CAM_DISPLAY_SURFACE,
701 {(void*)MM_DISPLAY_SURFACE_OVERLAY},
702 MM_ATTRS_VALID_TYPE_INT_ARRAY,
708 MM_CAM_DISPLAY_RECT_X,
713 MM_ATTRS_VALID_TYPE_INT_RANGE,
715 {.int_max = _MMCAMCORDER_MAX_INT},
716 _mmcamcorder_commit_display_rect,
719 MM_CAM_DISPLAY_RECT_Y,
724 MM_ATTRS_VALID_TYPE_INT_RANGE,
726 {.int_max = _MMCAMCORDER_MAX_INT},
727 _mmcamcorder_commit_display_rect,
730 MM_CAM_DISPLAY_RECT_WIDTH,
731 "display-rect-width",
735 MM_ATTRS_VALID_TYPE_INT_RANGE,
737 {.int_max = _MMCAMCORDER_MAX_INT},
738 _mmcamcorder_commit_display_rect,
741 MM_CAM_DISPLAY_RECT_HEIGHT,
742 "display-rect-height",
746 MM_ATTRS_VALID_TYPE_INT_RANGE,
748 {.int_max = _MMCAMCORDER_MAX_INT},
749 _mmcamcorder_commit_display_rect,
752 MM_CAM_DISPLAY_SOURCE_X,
757 MM_ATTRS_VALID_TYPE_INT_RANGE,
759 {.int_max = _MMCAMCORDER_MAX_INT},
763 MM_CAM_DISPLAY_SOURCE_Y,
768 MM_ATTRS_VALID_TYPE_INT_RANGE,
770 {.int_max = _MMCAMCORDER_MAX_INT},
774 MM_CAM_DISPLAY_SOURCE_WIDTH,
779 MM_ATTRS_VALID_TYPE_INT_RANGE,
781 {.int_max = _MMCAMCORDER_MAX_INT},
785 MM_CAM_DISPLAY_SOURCE_HEIGHT,
786 "display-src-height",
790 MM_ATTRS_VALID_TYPE_INT_RANGE,
792 {.int_max = _MMCAMCORDER_MAX_INT},
796 MM_CAM_DISPLAY_ROTATION,
800 {(void*)MM_DISPLAY_ROTATION_NONE},
801 MM_ATTRS_VALID_TYPE_INT_RANGE,
802 {.int_min = MM_DISPLAY_ROTATION_NONE},
803 {.int_max = MM_DISPLAY_ROTATION_270},
804 _mmcamcorder_commit_display_rotation,
808 MM_CAM_DISPLAY_VISIBLE,
813 MM_ATTRS_VALID_TYPE_INT_ARRAY,
815 {ARRAY_SIZE(visible_values)},
816 _mmcamcorder_commit_display_visible,
819 MM_CAM_DISPLAY_SCALE,
824 MM_ATTRS_VALID_TYPE_INT_RANGE,
825 {.int_min = MM_DISPLAY_SCALE_DEFAULT},
826 {.int_max = MM_DISPLAY_SCALE_TRIPLE_LENGTH},
827 _mmcamcorder_commit_display_scale,
830 MM_CAM_DISPLAY_GEOMETRY_METHOD,
831 "display-geometry-method",
835 MM_ATTRS_VALID_TYPE_INT_RANGE,
836 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
837 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
838 _mmcamcorder_commit_display_geometry_method,
841 MM_CAM_TARGET_FILENAME,
843 MM_ATTRS_TYPE_STRING,
846 MM_ATTRS_VALID_TYPE_NONE,
849 _mmcamcorder_commit_target_filename,
852 MM_CAM_TARGET_MAX_SIZE,
857 MM_ATTRS_VALID_TYPE_INT_RANGE,
859 {.int_max = _MMCAMCORDER_MAX_INT},
860 _mmcamcorder_commit_recording_max_limit,
863 MM_CAM_TARGET_TIME_LIMIT,
868 MM_ATTRS_VALID_TYPE_INT_RANGE,
870 {.int_max = _MMCAMCORDER_MAX_INT},
871 _mmcamcorder_commit_recording_max_limit,
879 MM_ATTRS_VALID_TYPE_INT_RANGE,
882 _mmcamcorder_commit_tag,
885 MM_CAM_TAG_IMAGE_DESCRIPTION,
886 "tag-image-description",
887 MM_ATTRS_TYPE_STRING,
890 MM_ATTRS_VALID_TYPE_NONE,
893 _mmcamcorder_commit_tag,
896 MM_CAM_TAG_ORIENTATION,
901 MM_ATTRS_VALID_TYPE_INT_ARRAY,
902 {tag_orientation_values},
903 {ARRAY_SIZE(tag_orientation_values)},
904 _mmcamcorder_commit_tag,
909 MM_ATTRS_TYPE_STRING,
912 MM_ATTRS_VALID_TYPE_NONE,
915 _mmcamcorder_commit_tag,
921 MM_ATTRS_TYPE_DOUBLE,
923 {.value_double = 0.0},
924 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
925 {.double_min = -360.0},
926 {.double_max = 360.0},
927 _mmcamcorder_commit_tag,
930 MM_CAM_TAG_LONGITUDE,
932 MM_ATTRS_TYPE_DOUBLE,
934 {.value_double = 0.0},
935 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
936 {.double_min = -360.0},
937 {.double_max = 360.0},
938 _mmcamcorder_commit_tag,
943 MM_ATTRS_TYPE_DOUBLE,
945 {.value_double = 0.0},
946 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
947 {.double_min = -999999.0},
948 {.double_max = 999999.0},
949 _mmcamcorder_commit_tag,
952 MM_CAM_STROBE_CONTROL,
957 MM_ATTRS_VALID_TYPE_INT_RANGE,
960 _mmcamcorder_commit_strobe,
963 MM_CAM_STROBE_CAPABILITIES,
964 "strobe-capabilities",
968 MM_ATTRS_VALID_TYPE_INT_RANGE,
971 _mmcamcorder_commit_strobe,
979 MM_ATTRS_VALID_TYPE_INT_ARRAY,
982 _mmcamcorder_commit_strobe,
990 MM_ATTRS_VALID_TYPE_INT_ARRAY,
993 _mmcamcorder_commit_detect,
996 MM_CAM_DETECT_NUMBER,
1001 MM_ATTRS_VALID_TYPE_INT_RANGE,
1004 _mmcamcorder_commit_detect,
1007 MM_CAM_DETECT_FOCUS_SELECT,
1008 "detect-focus-select",
1012 MM_ATTRS_VALID_TYPE_INT_RANGE,
1015 _mmcamcorder_commit_detect,
1018 MM_CAM_DETECT_SELECT_NUMBER,
1019 "detect-select-number",
1023 MM_ATTRS_VALID_TYPE_INT_RANGE,
1026 _mmcamcorder_commit_detect,
1030 MM_CAM_DETECT_STATUS,
1035 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1038 _mmcamcorder_commit_detect,
1041 MM_CAM_CAPTURE_ZERO_SYSTEMLAG,
1042 "capture-zero-systemlag",
1046 MM_ATTRS_VALID_TYPE_INT_RANGE,
1052 MM_CAM_CAMERA_AF_TOUCH_X,
1053 "camera-af-touch-x",
1057 MM_ATTRS_VALID_TYPE_INT_RANGE,
1059 {.int_max = _MMCAMCORDER_MAX_INT},
1060 _mmcamcorder_commit_camera_af_touch_area,
1063 MM_CAM_CAMERA_AF_TOUCH_Y,
1064 "camera-af-touch-y",
1068 MM_ATTRS_VALID_TYPE_INT_RANGE,
1070 {.int_max = _MMCAMCORDER_MAX_INT},
1071 _mmcamcorder_commit_camera_af_touch_area,
1074 MM_CAM_CAMERA_AF_TOUCH_WIDTH,
1075 "camera-af-touch-width",
1079 MM_ATTRS_VALID_TYPE_INT_RANGE,
1081 {.int_max = _MMCAMCORDER_MAX_INT},
1082 _mmcamcorder_commit_camera_af_touch_area,
1085 MM_CAM_CAMERA_AF_TOUCH_HEIGHT,
1086 "camera-af-touch-height",
1090 MM_ATTRS_VALID_TYPE_INT_RANGE,
1092 {.int_max = _MMCAMCORDER_MAX_INT},
1093 _mmcamcorder_commit_camera_af_touch_area,
1096 MM_CAM_CAMERA_FOCAL_LENGTH,
1097 "camera-focal-length",
1098 MM_ATTRS_TYPE_DOUBLE,
1100 {.value_double = 0.0},
1101 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1102 {.double_min = 0.0},
1103 {.double_max = 1000.0},
1104 _mmcamcorder_commit_camera_capture_mode,
1107 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
1108 "recommend-preview-format-for-capture",
1111 {(void*)MM_PIXEL_FORMAT_YUYV},
1112 MM_ATTRS_VALID_TYPE_INT_RANGE,
1113 {.int_min = MM_PIXEL_FORMAT_NV12},
1114 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1118 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
1119 "recommend-preview-format-for-recording",
1122 {(void*)MM_PIXEL_FORMAT_NV12},
1123 MM_ATTRS_VALID_TYPE_INT_RANGE,
1124 {.int_min = MM_PIXEL_FORMAT_NV12},
1125 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1129 MM_CAM_TAG_GPS_ENABLE,
1134 MM_ATTRS_VALID_TYPE_INT_RANGE,
1137 _mmcamcorder_commit_tag,
1141 MM_CAM_TAG_GPS_TIME_STAMP,
1142 "tag-gps-time-stamp",
1143 MM_ATTRS_TYPE_DOUBLE,
1145 {.value_double = 0.0},
1146 MM_ATTRS_VALID_TYPE_NONE,
1149 _mmcamcorder_commit_tag,
1152 MM_CAM_TAG_GPS_DATE_STAMP,
1153 "tag-gps-date-stamp",
1154 MM_ATTRS_TYPE_STRING,
1157 MM_ATTRS_VALID_TYPE_NONE,
1160 _mmcamcorder_commit_tag,
1163 MM_CAM_TAG_GPS_PROCESSING_METHOD,
1164 "tag-gps-processing-method",
1165 MM_ATTRS_TYPE_STRING,
1168 MM_ATTRS_VALID_TYPE_NONE,
1171 _mmcamcorder_commit_tag,
1174 MM_CAM_CAMERA_ROTATION,
1178 {(void*)MM_VIDEO_INPUT_ROTATION_NONE},
1179 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1181 {ARRAY_SIZE(rotation_list)},
1182 _mmcamcorder_commit_camera_rotate,
1185 MM_CAM_CAPTURED_SCREENNAIL,
1186 "captured-screennail",
1190 MM_ATTRS_VALID_TYPE_NONE,
1196 MM_CAM_CAPTURE_SOUND_ENABLE,
1197 "capture-sound-enable",
1201 MM_ATTRS_VALID_TYPE_INT_RANGE,
1204 _mmcamcorder_commit_capture_sound_enable,
1207 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
1208 "recommend-display-rotation",
1211 {(void*)MM_DISPLAY_ROTATION_270},
1212 MM_ATTRS_VALID_TYPE_INT_RANGE,
1213 {.int_min = MM_DISPLAY_ROTATION_NONE},
1214 {.int_max = MM_DISPLAY_ROTATION_270},
1222 {(void*)MM_FLIP_NONE},
1223 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1225 {ARRAY_SIZE(flip_list)},
1226 _mmcamcorder_commit_camera_flip,
1229 MM_CAM_CAMERA_HDR_CAPTURE,
1230 "camera-hdr-capture",
1234 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1237 _mmcamcorder_commit_camera_hdr_capture,
1240 MM_CAM_DISPLAY_MODE,
1244 {(void*)MM_DISPLAY_MODE_DEFAULT},
1245 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1248 _mmcamcorder_commit_display_mode,
1252 MM_CAM_AUDIO_DISABLE,
1257 MM_ATTRS_VALID_TYPE_INT_RANGE,
1260 _mmcamcorder_commit_audio_disable,
1263 MM_CAM_RECOMMEND_CAMERA_WIDTH,
1264 "recommend-camera-width",
1267 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
1268 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1274 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
1275 "recommend-camera-height",
1278 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
1279 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1285 MM_CAM_CAPTURED_EXIF_RAW_DATA,
1286 "captured-exif-raw-data",
1290 MM_ATTRS_VALID_TYPE_NONE,
1296 MM_CAM_DISPLAY_EVAS_SURFACE_SINK,
1297 "display-evas-surface-sink",
1298 MM_ATTRS_TYPE_STRING,
1301 MM_ATTRS_VALID_TYPE_NONE,
1307 MM_CAM_DISPLAY_EVAS_DO_SCALING,
1308 "display-evas-do-scaling",
1312 MM_ATTRS_VALID_TYPE_INT_RANGE,
1315 _mmcamcorder_commit_display_evas_do_scaling,
1318 MM_CAM_CAMERA_FACING_DIRECTION,
1319 "camera-facing-direction",
1322 {(void*)MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1323 MM_ATTRS_VALID_TYPE_INT_RANGE,
1324 {.int_min = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1325 {.int_max = MM_CAMCORDER_CAMERA_FACING_DIRECTION_FRONT},
1329 MM_CAM_DISPLAY_FLIP,
1333 {(void*)MM_FLIP_NONE},
1334 MM_ATTRS_VALID_TYPE_INT_RANGE,
1335 {.int_min = MM_FLIP_NONE},
1336 {.int_max = MM_FLIP_BOTH},
1337 _mmcamcorder_commit_display_flip,
1340 MM_CAM_CAMERA_VIDEO_STABILIZATION,
1341 "camera-video-stabilization",
1344 {(void*)MM_CAMCORDER_VIDEO_STABILIZATION_OFF},
1345 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1348 _mmcamcorder_commit_camera_video_stabilization,
1351 MM_CAM_TAG_VIDEO_ORIENTATION,
1352 "tag-video-orientation",
1355 {(void*)MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1356 MM_ATTRS_VALID_TYPE_INT_RANGE,
1357 {.int_min = MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1358 {.int_max = MM_CAMCORDER_TAG_VIDEO_ORT_270},
1363 MM_CAM_CAMERA_PAN_MECHA,
1368 MM_ATTRS_VALID_TYPE_INT_RANGE,
1371 _mmcamcorder_commit_camera_pan,
1374 MM_CAM_CAMERA_PAN_ELEC,
1379 MM_ATTRS_VALID_TYPE_INT_RANGE,
1382 _mmcamcorder_commit_camera_pan,
1385 MM_CAM_CAMERA_TILT_MECHA,
1386 "camera-tilt-mecha",
1390 MM_ATTRS_VALID_TYPE_INT_RANGE,
1393 _mmcamcorder_commit_camera_tilt,
1396 MM_CAM_CAMERA_TILT_ELEC,
1401 MM_ATTRS_VALID_TYPE_INT_RANGE,
1404 _mmcamcorder_commit_camera_tilt,
1407 MM_CAM_CAMERA_PTZ_TYPE,
1412 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1415 _mmcamcorder_commit_camera_ptz_type,
1423 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1426 _mmcamcorder_commit_video_size,
1429 MM_CAM_VIDEO_HEIGHT,
1434 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1437 _mmcamcorder_commit_video_size,
1440 MM_CAM_SUPPORT_ZSL_CAPTURE,
1441 "support-zsl-capture",
1445 MM_ATTRS_VALID_TYPE_INT_RANGE,
1451 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
1452 "support-zero-copy-format",
1456 MM_ATTRS_VALID_TYPE_INT_RANGE,
1462 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
1463 "support-media-packet-preview-cb",
1467 MM_ATTRS_VALID_TYPE_INT_RANGE,
1474 MM_CAM_ENCODED_PREVIEW_BITRATE,
1475 "encoded-preview-bitrate",
1478 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_BITRATE},
1479 MM_ATTRS_VALID_TYPE_INT_RANGE,
1481 {.int_max = _MMCAMCORDER_MAX_INT},
1482 _mmcamcorder_commit_encoded_preview_bitrate,
1485 MM_CAM_ENCODED_PREVIEW_GOP_INTERVAL,
1486 "encoded-preview-gop-interval",
1489 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL},
1490 MM_ATTRS_VALID_TYPE_INT_RANGE,
1492 {.int_max = _MMCAMCORDER_MAX_INT},
1493 _mmcamcorder_commit_encoded_preview_gop_interval,
1496 MM_CAM_RECORDER_TAG_ENABLE,
1497 "recorder-tag-enable",
1501 MM_ATTRS_VALID_TYPE_INT_RANGE,
1507 MM_CAM_DISPLAY_SOCKET_PATH,
1508 "display-socket-path",
1509 MM_ATTRS_TYPE_STRING,
1512 MM_ATTRS_VALID_TYPE_NONE,
1523 MM_ATTRS_VALID_TYPE_INT_RANGE,
1525 {.int_max = _MMCAMCORDER_MAX_INT},
1529 MM_CAM_ROOT_DIRECTORY,
1531 MM_ATTRS_TYPE_STRING,
1534 MM_ATTRS_VALID_TYPE_NONE,
1540 MM_CAM_SOUND_STREAM_INDEX,
1541 "sound-stream-index",
1545 MM_ATTRS_VALID_TYPE_INT_RANGE,
1547 {.int_max = _MMCAMCORDER_MAX_INT},
1551 MM_CAM_SOUND_STREAM_TYPE,
1552 "sound-stream-type",
1553 MM_ATTRS_TYPE_STRING,
1556 MM_ATTRS_VALID_TYPE_NONE,
1559 _mmcamcorder_commit_sound_stream_info,
1562 MM_CAM_DISPLAY_REUSE_HINT,
1563 "display-reuse-hint",
1567 MM_ATTRS_VALID_TYPE_INT_RANGE,
1573 MM_CAM_DISPLAY_REUSE_ELEMENT,
1574 "display-reuse-element",
1578 MM_ATTRS_VALID_TYPE_NONE,
1584 MM_CAM_GDBUS_CONNECTION,
1589 MM_ATTRS_VALID_TYPE_NONE,
1595 MM_CAM_AUDIO_REPLAY_GAIN_ENABLE,
1596 "audio-replay-gain-enable",
1600 MM_ATTRS_VALID_TYPE_INT_RANGE,
1603 _mmcamcorder_commit_audio_replay_gain,
1606 MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL,
1607 "audio-replay-gain-reference-level",
1608 MM_ATTRS_TYPE_DOUBLE,
1610 {.value_double = MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL},
1611 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1612 {.double_min = 0.0},
1613 {.double_max = 150.0},
1614 _mmcamcorder_commit_audio_replay_gain,
1617 MM_CAM_SUPPORT_USER_BUFFER,
1618 "support-user-buffer",
1622 MM_ATTRS_VALID_TYPE_INT_RANGE,
1628 MM_CAM_USER_BUFFER_FD,
1633 MM_ATTRS_VALID_TYPE_NONE,
1639 MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
1640 "platform-privilege-camera",
1641 MM_ATTRS_TYPE_STRING,
1644 MM_ATTRS_VALID_TYPE_NONE,
1650 MM_CAM_STROBE_BRIGHTNESS,
1651 "strobe-brightness",
1655 MM_ATTRS_VALID_TYPE_INT_RANGE,
1658 _mmcamcorder_commit_strobe,
1661 MM_CAM_VIDEOSRC_ELEMENT_NAME,
1662 "videosrc-element-name",
1663 MM_ATTRS_TYPE_STRING,
1666 MM_ATTRS_VALID_TYPE_NONE,
1672 MM_CAM_AUDIOSRC_ELEMENT_NAME,
1673 "audiosrc-element-name",
1674 MM_ATTRS_TYPE_STRING,
1677 MM_ATTRS_VALID_TYPE_NONE,
1683 MM_CAM_EXTRA_PREVIEW_ENABLE,
1684 "extra-preview-enable",
1688 MM_ATTRS_VALID_TYPE_INT_RANGE,
1691 _mmcamcorder_commit_extra_preview,
1694 MM_CAM_CAMERA_FOCUS_LEVEL,
1695 "camera-focus-level",
1699 MM_ATTRS_VALID_TYPE_INT_RANGE,
1702 _mmcamcorder_commit_camera_focus_level,
1706 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1708 for (idx = 0 ; idx < attr_count ; idx++) {
1709 /* attribute order check. This should be same. */
1710 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1711 MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1712 free(attrs_const_info);
1713 attrs_const_info = NULL;
1714 free(hcamcorder->cam_attrs_const_info);
1715 hcamcorder->cam_attrs_const_info = NULL;
1719 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1720 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1721 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1722 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1725 /* Camcorder Attributes */
1726 MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1728 ret = mm_attrs_new(attrs_const_info,
1730 "Camcorder_Attributes",
1731 _mmcamcorder_commit_camcorder_attrs,
1735 free(attrs_const_info);
1736 attrs_const_info = NULL;
1738 if (ret != MM_ERROR_NONE) {
1739 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1740 free(hcamcorder->cam_attrs_const_info);
1741 hcamcorder->cam_attrs_const_info = NULL;
1745 __mmcamcorder_set_conf_to_valid_info(handle);
1747 for (idx = 0; idx < attr_count; idx++) {
1748 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1750 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1752 switch (attr_info->validity_type) {
1753 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1754 if (attr_info->validity_value_1.int_array &&
1755 attr_info->validity_value_2.count > 0) {
1756 mm_attrs_set_valid_array(attrs, idx,
1757 (const int *)(attr_info->validity_value_1.int_array),
1758 attr_info->validity_value_2.count,
1759 attr_info->default_value.value_int);
1762 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1763 mm_attrs_set_valid_range(attrs, idx,
1764 attr_info->validity_value_1.int_min,
1765 attr_info->validity_value_2.int_max,
1766 attr_info->default_value.value_int);
1768 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1769 if (attr_info->validity_value_1.double_array &&
1770 attr_info->validity_value_2.count > 0) {
1771 mm_attrs_set_valid_double_array(attrs, idx,
1772 (const double *)(attr_info->validity_value_1.double_array),
1773 attr_info->validity_value_2.count,
1774 attr_info->default_value.value_double);
1777 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1778 mm_attrs_set_valid_double_range(attrs, idx,
1779 attr_info->validity_value_1.double_min,
1780 attr_info->validity_value_2.double_max,
1781 attr_info->default_value.value_double);
1783 case MM_ATTRS_VALID_TYPE_NONE:
1785 case MM_ATTRS_VALID_TYPE_INVALID:
1787 MMCAM_LOG_ERROR("Valid type error.");
1792 __mmcamcorder_release_conf_valid_info(handle);
1799 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1801 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1803 if (hcamcorder == NULL) {
1804 MMCAM_LOG_ERROR("handle is NULL");
1811 mm_attrs_free(attrs);
1812 MMCAM_LOG_INFO("released attribute");
1815 if (hcamcorder->cam_attrs_const_info) {
1816 free(hcamcorder->cam_attrs_const_info);
1817 hcamcorder->cam_attrs_const_info = NULL;
1818 MMCAM_LOG_INFO("released attribute info");
1826 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1828 MMHandleType attrs = 0;
1829 int ret = MM_ERROR_NONE;
1831 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1832 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1834 attrs = MMF_CAMCORDER_ATTRS(handle);
1835 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1837 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1844 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1846 MMHandleType attrs = 0;
1847 int ret = MM_ERROR_NONE;
1849 char *tmp_err_attr_name = NULL;
1850 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1851 va_list var_args_copy;
1853 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1855 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1856 MMCAM_LOG_ERROR("Another command is running.");
1857 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1860 /* copy var_args to keep original var_args */
1861 va_copy(var_args_copy, var_args);
1863 attrs = MMF_CAMCORDER_ATTRS(handle);
1865 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1867 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1868 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1871 if (ret == MM_ERROR_NONE) {
1872 hcamcorder->error_code = MM_ERROR_NONE;
1873 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1874 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1877 va_end(var_args_copy);
1879 _MMCAMCORDER_UNLOCK_CMD(handle);
1881 if (ret != MM_ERROR_NONE) {
1882 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1883 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1884 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1885 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1886 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1887 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1891 if (hcamcorder->error_code != MM_ERROR_NONE) {
1892 MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1893 ret = hcamcorder->error_code;
1894 hcamcorder->error_code = MM_ERROR_NONE;
1897 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1900 if (tmp_err_attr_name) {
1901 if (!err_attr_name) {
1902 MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1903 free(tmp_err_attr_name);
1904 tmp_err_attr_name = NULL;
1906 *err_attr_name = tmp_err_attr_name;
1915 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1917 MMHandleType attrs = 0;
1918 MMAttrsInfo attrinfo;
1919 int ret = MM_ERROR_NONE;
1921 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1922 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1923 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1925 attrs = MMF_CAMCORDER_ATTRS(handle);
1926 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1928 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1930 if (ret == MM_ERROR_NONE) {
1931 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1932 info->type = attrinfo.type;
1933 info->flag = attrinfo.flag;
1934 info->validity_type = attrinfo.validity_type;
1936 switch (attrinfo.validity_type) {
1937 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1938 info->int_array.array = attrinfo.int_array.array;
1939 info->int_array.count = attrinfo.int_array.count;
1940 info->int_array.def = attrinfo.int_array.dval;
1942 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1943 info->int_range.min = attrinfo.int_range.min;
1944 info->int_range.max = attrinfo.int_range.max;
1945 info->int_range.def = attrinfo.int_range.dval;
1947 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1948 info->double_array.array = attrinfo.double_array.array;
1949 info->double_array.count = attrinfo.double_array.count;
1950 info->double_array.def = attrinfo.double_array.dval;
1952 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1953 info->double_range.min = attrinfo.double_range.min;
1954 info->double_range.max = attrinfo.double_range.max;
1955 info->double_range.def = attrinfo.double_range.dval;
1957 case MM_ATTRS_VALID_TYPE_NONE:
1959 case MM_ATTRS_VALID_TYPE_INVALID:
1970 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1973 mmf_camcorder_t *hcamcorder = NULL;
1975 mmf_return_val_if_fail(commit_param, FALSE);
1976 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1977 mmf_return_val_if_fail(attr_name, FALSE);
1978 mmf_return_val_if_fail(value, FALSE);
1980 hcamcorder = MMF_CAMCORDER(commit_param);
1982 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1983 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1991 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1994 int total_count = 0;
1996 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1998 if (hcamcorder == NULL) {
1999 MMCAM_LOG_ERROR("handle is NULL");
2000 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2004 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
2005 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
2006 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
2009 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
2010 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
2011 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
2014 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
2015 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
2016 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
2019 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
2020 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
2021 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
2023 return MM_ERROR_NONE;
2027 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
2029 int *allocated_memory = NULL;
2031 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2033 if (hcamcorder == NULL) {
2034 MMCAM_LOG_ERROR("handle is NULL");
2035 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2038 MMCAM_LOG_INFO("START");
2040 /* Audio encoder info */
2041 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2042 if (allocated_memory) {
2043 g_free(allocated_memory);
2044 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2045 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2048 /* Video encoder info */
2049 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2050 if (allocated_memory) {
2051 g_free(allocated_memory);
2052 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2053 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2056 /* Image encoder info */
2057 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2058 if (allocated_memory) {
2059 g_free(allocated_memory);
2060 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2061 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2064 /* File format info */
2065 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2066 if (allocated_memory) {
2067 g_free(allocated_memory);
2068 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2069 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2072 MMCAM_LOG_INFO("DONE");
2074 return MM_ERROR_NONE;
2078 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2080 MMHandleType attr = 0;
2081 int current_state = MM_CAMCORDER_STATE_NONE;
2083 mmf_return_val_if_fail(handle && value, FALSE);
2085 attr = MMF_CAMCORDER_ATTRS(handle);
2086 mmf_return_val_if_fail(attr, FALSE);
2088 /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2090 current_state = _mmcamcorder_get_state(handle);
2091 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2092 int flags = MM_ATTRS_FLAG_NONE;
2093 int capture_width, capture_height;
2094 MMCamAttrsInfo info;
2096 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2099 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2100 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2101 capture_width = value->value.i_val;
2103 /* Check whether they are valid pair */
2104 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2109 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2115 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2117 int current_state = MM_CAMCORDER_STATE_NONE;
2119 current_state = _mmcamcorder_get_state(handle);
2121 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2122 int capture_width, capture_height;
2124 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2125 capture_height = value->value.i_val;
2127 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2129 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2136 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2138 int current_state = 0;
2140 _MMCamcorderSubContext *sc = NULL;
2141 _MMCamcorderImageInfo *info = NULL;
2142 GstCameraControl *control = NULL;
2144 mmf_return_val_if_fail(handle && value, FALSE);
2146 current_state = _mmcamcorder_get_state(handle);
2147 ivalue = value->value.i_val;
2149 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2153 info = sc->info_image;
2155 MMCAM_LOG_ERROR("info image is NULL");
2159 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2160 if (info->capture_send_count > 0) {
2161 info->capturing = FALSE;
2162 MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2165 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2166 MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2170 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2172 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2173 MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2175 MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2178 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2185 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2187 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2188 int current_state = MM_CAMCORDER_STATE_NONE;
2189 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2191 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2193 current_state = _mmcamcorder_get_state(handle);
2194 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2196 MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2197 current_state, mode, value->value.i_val);
2199 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2200 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2203 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2209 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2211 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2213 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2215 MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2217 /* return error when disable shutter sound if policy is TRUE */
2218 if (!value->value.i_val &&
2219 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2220 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2223 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2229 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2231 int current_state = MM_CAMCORDER_STATE_NONE;
2232 _MMCamcorderSubContext *sc = NULL;
2235 mmf_return_val_if_fail(handle && value, FALSE);
2237 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2241 current_state = _mmcamcorder_get_state(handle);
2243 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2244 double mslNewVal = 0;
2245 mslNewVal = value->value.d_val;
2247 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2248 if (mslNewVal == 0.0) {
2249 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2250 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2252 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2253 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2257 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2260 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2268 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2270 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2271 int current_state = MM_CAMCORDER_STATE_NONE;
2273 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2275 current_state = _mmcamcorder_get_state(handle);
2276 if (current_state > MM_CAMCORDER_STATE_READY) {
2277 MMCAM_LOG_ERROR("invalid state %d", current_state);
2278 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2286 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2288 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2289 MMCamAttrsInfo fps_info;
2290 int resolution_width = 0;
2291 int resolution_height = 0;
2294 int current_state = MM_CAMCORDER_STATE_NONE;
2296 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2298 current_state = _mmcamcorder_get_state(handle);
2299 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2300 MMCAM_LOG_ERROR("invalid state %d", current_state);
2301 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2305 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2308 MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2310 ret = mm_camcorder_get_attributes(handle, NULL,
2311 MMCAM_CAMERA_WIDTH, &resolution_width,
2312 MMCAM_CAMERA_HEIGHT, &resolution_height,
2315 if (ret != MM_ERROR_NONE) {
2316 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2320 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2321 if (ret != MM_ERROR_NONE) {
2322 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2326 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2327 if (value->value.i_val == fps_info.int_array.array[i])
2331 MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2337 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2339 int current_state = MM_CAMCORDER_STATE_NONE;
2340 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2341 _MMCamcorderSubContext *sc = NULL;
2343 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2345 current_state = _mmcamcorder_get_state(handle);
2346 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2347 MMCAM_LOG_WARNING("invalid state %d", current_state);
2348 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2352 /* Verify recording motion rate */
2353 if (value->value.d_val > 0.0) {
2354 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2358 /* set is_slow flag */
2359 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2360 sc->is_modified_rate = TRUE;
2362 sc->is_modified_rate = FALSE;
2364 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2367 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2373 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2375 MMHandleType attr = 0;
2376 int current_state = MM_CAMCORDER_STATE_NONE;
2378 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2379 _MMCamcorderSubContext *sc = NULL;
2381 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2383 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2387 attr = MMF_CAMCORDER_ATTRS(handle);
2388 mmf_return_val_if_fail(attr, FALSE);
2390 MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2392 current_state = _mmcamcorder_get_state(handle);
2394 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2395 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2398 int flags = MM_ATTRS_FLAG_NONE;
2399 MMCamAttrsInfo info;
2400 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2403 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2404 int width = value->value.i_val;
2406 int preview_format = MM_PIXEL_FORMAT_NV12;
2407 int codec_type = MM_IMAGE_CODEC_JPEG;
2409 mm_camcorder_get_attributes(handle, NULL,
2410 MMCAM_CAMERA_HEIGHT, &height,
2411 MMCAM_CAMERA_FORMAT, &preview_format,
2412 MMCAM_IMAGE_ENCODER, &codec_type,
2415 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2416 if (hcamcorder->resolution_changed == FALSE) {
2417 MMCAM_LOG_INFO("no need to restart preview");
2421 hcamcorder->resolution_changed = FALSE;
2423 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2424 MMCAM_LOG_INFO("restart preview");
2426 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2427 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2429 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2430 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2432 /* check decoder recreation */
2433 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2434 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2435 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2439 /* get preview format */
2440 sc->info_image->preview_format = preview_format;
2441 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2442 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2444 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2445 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2447 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2448 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2451 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2453 MMCAM_LOG_ERROR("currently locked for preview restart");
2457 /* get preview format */
2458 sc->info_image->preview_format = preview_format;
2459 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2460 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2471 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2474 int current_state = MM_CAMCORDER_STATE_NONE;
2475 MMHandleType attr = 0;
2476 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2477 _MMCamcorderSubContext *sc = NULL;
2479 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2481 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2485 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2486 mmf_return_val_if_fail(attr, FALSE);
2488 MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2489 current_state = _mmcamcorder_get_state(handle);
2491 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2492 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2493 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2497 int height = value->value.i_val;
2498 int preview_format = MM_PIXEL_FORMAT_NV12;
2499 int codec_type = MM_IMAGE_CODEC_JPEG;
2500 int video_stabilization = 0;
2502 mm_camcorder_get_attributes(handle, NULL,
2503 MMCAM_CAMERA_WIDTH, &width,
2504 MMCAM_CAMERA_FORMAT, &preview_format,
2505 MMCAM_IMAGE_ENCODER, &codec_type,
2506 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2509 sc->info_video->preview_width = width;
2510 sc->info_video->preview_height = height;
2512 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2513 if (hcamcorder->resolution_changed == FALSE) {
2514 MMCAM_LOG_INFO("no need to restart preview");
2518 hcamcorder->resolution_changed = FALSE;
2520 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2521 MMCAM_LOG_INFO("restart preview");
2523 MMCAM_LOG_INFO("set empty buffers");
2525 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2526 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2528 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2529 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2531 /* check decoder recreation */
2532 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2533 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2534 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2538 /* get preview format */
2539 sc->info_image->preview_format = preview_format;
2540 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2542 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2544 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2545 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2547 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2548 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2551 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2553 MMCAM_LOG_ERROR("currently locked for preview restart");
2557 /* get preview format */
2558 sc->info_image->preview_format = preview_format;
2559 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2560 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2568 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2570 int current_state = MM_CAMCORDER_STATE_NONE;
2571 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2573 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2575 current_state = _mmcamcorder_get_state(handle);
2576 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2577 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2578 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2581 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2582 value->value.i_val, attr_idx);
2588 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2590 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2591 _MMCamcorderSubContext *sc = NULL;
2592 int current_state = MM_CAMCORDER_STATE_NONE;
2593 GstCameraControl *control = NULL;
2597 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2599 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2603 zoom_level = value->value.i_val;
2605 MMCAM_LOG_INFO("(%d)", attr_idx);
2607 current_state = _mmcamcorder_get_state(handle);
2608 if (current_state < MM_CAMCORDER_STATE_READY) {
2609 MMCAM_LOG_INFO("will be applied when preview starts");
2611 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2612 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2613 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2617 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2618 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2620 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2622 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2625 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2626 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2630 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2631 if (control == NULL) {
2632 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2636 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2638 MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2641 MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2644 MMCAM_LOG_INFO("pointer of video src is null");
2651 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2653 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2654 _MMCamcorderSubContext *sc = NULL;
2655 int current_state = MM_CAMCORDER_STATE_NONE;
2657 GstCameraControl *CameraControl = NULL;
2658 GstCameraControlChannel *CameraControlChannel = NULL;
2659 const GList *controls = NULL;
2660 const GList *item = NULL;
2662 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2664 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2665 mmf_return_val_if_fail(sc, TRUE);
2667 MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2669 current_state = _mmcamcorder_get_state(handle);
2670 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2671 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2672 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2673 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2677 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2678 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2679 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2683 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2684 if (CameraControl == NULL) {
2685 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2689 controls = gst_camera_control_list_channels(CameraControl);
2690 if (controls == NULL) {
2691 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2695 for (item = controls ; item && item->data ; item = item->next) {
2696 CameraControlChannel = item->data;
2697 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2698 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2699 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2700 MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2703 MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2709 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2716 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2718 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2719 _MMCamcorderSubContext *sc = NULL;
2720 int current_state = MM_CAMCORDER_STATE_NONE;
2722 GstCameraControl *CameraControl = NULL;
2723 GstCameraControlChannel *CameraControlChannel = NULL;
2724 const GList *controls = NULL;
2725 const GList *item = NULL;
2727 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2729 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2730 mmf_return_val_if_fail(sc, TRUE);
2732 MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2734 current_state = _mmcamcorder_get_state(handle);
2735 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2736 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2737 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2738 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2742 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2743 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2744 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2748 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2749 if (CameraControl == NULL) {
2750 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2754 controls = gst_camera_control_list_channels(CameraControl);
2755 if (controls == NULL) {
2756 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2760 for (item = controls ; item && item->data ; item = item->next) {
2761 CameraControlChannel = item->data;
2762 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2763 if (!strcmp(CameraControlChannel->label, "pan")) {
2764 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2765 MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2768 MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2774 MMCAM_LOG_WARNING("failed to find pan control channel");
2781 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2783 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2784 _MMCamcorderSubContext *sc = NULL;
2785 int current_state = MM_CAMCORDER_STATE_NONE;
2787 GstCameraControl *CameraControl = NULL;
2788 GstCameraControlChannel *CameraControlChannel = NULL;
2789 const GList *controls = NULL;
2790 const GList *item = NULL;
2792 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2794 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2795 mmf_return_val_if_fail(sc, TRUE);
2797 MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2799 current_state = _mmcamcorder_get_state(handle);
2800 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2801 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2802 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2803 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2807 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2808 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2809 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2813 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2814 if (CameraControl == NULL) {
2815 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2819 controls = gst_camera_control_list_channels(CameraControl);
2820 if (controls == NULL) {
2821 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2825 for (item = controls ; item && item->data ; item = item->next) {
2826 CameraControlChannel = item->data;
2827 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2828 if (!strcmp(CameraControlChannel->label, "tilt")) {
2829 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2830 MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2833 MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2839 MMCAM_LOG_WARNING("failed to find tilt control channel");
2846 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2848 MMHandleType attr = 0;
2849 int current_state = MM_CAMCORDER_STATE_NONE;
2850 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2851 _MMCamcorderSubContext *sc = NULL;
2852 GstCameraControl *control = NULL;
2854 int set_focus_mode = 0;
2855 int cur_focus_mode = 0;
2856 int cur_focus_range = 0;
2858 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2860 attr = MMF_CAMCORDER_ATTRS(handle);
2861 mmf_return_val_if_fail(attr, FALSE);
2863 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2867 MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2869 /* check whether set or not */
2870 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2871 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2875 current_state = _mmcamcorder_get_state(handle);
2876 if (current_state < MM_CAMCORDER_STATE_NULL) {
2877 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2879 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2880 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2881 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2885 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2886 int flags = MM_ATTRS_FLAG_NONE;
2887 MMCamAttrsInfo info;
2889 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2890 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2894 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2895 if (control == NULL) {
2896 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2900 mslVal = value->value.i_val;
2901 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2903 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2906 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2907 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2908 if (set_focus_mode != cur_focus_mode) {
2909 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2910 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2913 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2916 MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2920 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2924 MMCAM_LOG_INFO("pointer of video src is null");
2931 bool _mmcamcorder_commit_camera_focus_level(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2933 int current_state = MM_CAMCORDER_STATE_NONE;
2934 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2935 _MMCamcorderSubContext *sc = NULL;
2936 GstCameraControl *control = NULL;
2938 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2940 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2944 MMCAM_LOG_INFO("Focus level[%d]", value->value.i_val);
2946 current_state = _mmcamcorder_get_state(handle);
2947 if (current_state < MM_CAMCORDER_STATE_READY) {
2948 MMCAM_LOG_INFO("Focus level will be set later.(state=%d)", current_state);
2950 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2951 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2952 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2956 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2957 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
2961 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2962 if (control == NULL) {
2963 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2967 if (!gst_camera_control_set_focus_level(control, value->value.i_val)) {
2968 MMCAM_LOG_ERROR("set focus level[%d[ failed", value->value.i_val);
2976 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2978 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2979 _MMCamcorderSubContext *sc = NULL;
2980 GstCameraControl *control = NULL;
2981 int current_state = MM_CAMCORDER_STATE_NONE;
2984 int cur_focus_mode = 0;
2985 int cur_focus_range = 0;
2986 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2987 int converted_mode = 0;
2989 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2991 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2995 MMCAM_LOG_INFO("(%d)", attr_idx);
2997 /* check whether set or not */
2998 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2999 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3003 mslVal = value->value.i_val;
3004 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3006 current_state = _mmcamcorder_get_state(handle);
3007 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3008 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3010 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3011 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3012 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3016 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3017 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3018 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3022 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3023 if (control == NULL) {
3024 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3028 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
3029 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
3031 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
3032 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
3033 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
3034 /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
3037 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
3040 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
3044 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
3047 MMCAM_LOG_INFO("pointer of video src is null");
3054 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3056 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3057 _MMCamcorderSubContext *sc = NULL;
3058 GstCameraControl *control = NULL;
3059 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
3060 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
3062 int current_state = MM_CAMCORDER_STATE_NONE;
3064 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3066 gboolean do_set = FALSE;
3068 MMCamAttrsInfo info_y;
3069 MMCamAttrsInfo info_w;
3070 MMCamAttrsInfo info_h;
3072 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3074 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3078 MMCAM_LOG_INFO("(%d)", attr_idx);
3080 current_state = _mmcamcorder_get_state(handle);
3081 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3082 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3084 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3085 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3086 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3090 ret = mm_camcorder_get_attributes(handle, NULL,
3091 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3093 if (ret != MM_ERROR_NONE) {
3094 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3098 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3099 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3103 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3104 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3105 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3109 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3110 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3111 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3114 case MM_CAM_CAMERA_AF_TOUCH_X:
3115 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3116 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3117 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3118 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3119 set_area.x = value->value.i_val;
3120 mm_camcorder_get_attributes(handle, NULL,
3121 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3122 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3123 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3127 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3131 case MM_CAM_CAMERA_AF_TOUCH_Y:
3132 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3133 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3134 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3135 set_area.y = value->value.i_val;
3136 mm_camcorder_get_attributes(handle, NULL,
3137 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3138 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3139 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3143 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3147 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3148 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3149 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3150 set_area.width = value->value.i_val;
3151 mm_camcorder_get_attributes(handle, NULL,
3152 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3153 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3154 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3158 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3162 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3163 set_area.height = value->value.i_val;
3164 mm_camcorder_get_attributes(handle, NULL,
3165 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3166 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3167 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3176 _MMCamcorderVideoInfo *info = sc->info_video;
3179 MMCAM_LOG_ERROR("video info is NULL");
3183 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3184 if (control == NULL) {
3185 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3190 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3191 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3192 float ratio_width = 0.0;
3193 float ratio_height = 0.0;
3195 if (info->preview_width != 0 && info->preview_height != 0) {
3196 ratio_width = (float)info->video_width / (float)info->preview_width;
3197 ratio_height = (float)info->video_height / (float)info->preview_height;
3199 MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3200 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3202 set_area.x = (int)((float)set_area.x * ratio_width);
3203 set_area.y = (int)((float)set_area.y * ratio_height);
3204 set_area.width = (int)((float)set_area.width * ratio_width);
3205 set_area.height = (int)((float)set_area.height * ratio_height);
3207 if (set_area.width <= 0)
3210 if (set_area.height <= 0)
3211 set_area.height = 1;
3213 MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3214 set_area.x, set_area.y, set_area.width, set_area.height);
3216 MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3217 info->preview_width, info->preview_height);
3221 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3223 MMCAM_LOG_WARNING("Failed to get AF area");
3227 /* width and height are not supported now */
3228 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3229 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3230 get_area.x, get_area.y);
3234 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3236 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3237 set_area.x, set_area.y, set_area.width, set_area.height);
3240 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3241 set_area.x, set_area.y, set_area.width, set_area.height);
3245 MMCAM_LOG_INFO("pointer of video src is null");
3252 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3254 GstCameraControl *control = NULL;
3260 int exposure_type = 0;
3261 int current_state = MM_CAMCORDER_STATE_NONE;
3262 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3263 _MMCamcorderSubContext *sc = NULL;
3265 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3266 gboolean check_scene_mode = FALSE;
3268 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3270 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3274 /* check whether set or not */
3275 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3276 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3280 current_state = _mmcamcorder_get_state(handle);
3281 if (current_state < MM_CAMCORDER_STATE_READY) {
3282 MMCAM_LOG_INFO("will be applied when preview starts");
3284 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3285 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3286 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3290 ivalue = value->value.i_val;
3292 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3293 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3294 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3295 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3296 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3297 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3298 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3299 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3300 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3301 exposure_type = GST_CAMERA_CONTROL_ISO;
3303 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3304 check_scene_mode = TRUE;
3305 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3306 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3308 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3309 check_scene_mode = TRUE;
3310 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3311 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3312 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3313 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3316 if (check_scene_mode) {
3317 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3318 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3319 MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3324 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3327 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3328 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3332 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3333 if (control == NULL) {
3334 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3338 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3340 MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3343 MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3346 MMCAM_LOG_INFO("pointer of video src is null");
3353 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3355 GstCameraControl *control = NULL;
3359 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3360 _MMCamcorderSubContext *sc = NULL;
3361 int current_state = MM_CAMCORDER_STATE_NONE;
3363 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3365 /* check whether set or not */
3366 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3367 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3371 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3375 /* check current state */
3376 current_state = _mmcamcorder_get_state(handle);
3377 if (current_state < MM_CAMCORDER_STATE_READY) {
3378 MMCAM_LOG_INFO("will be applied when preview starts");
3380 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3381 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3382 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3386 mslVal = value->value.i_val;
3387 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3389 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3390 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3391 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3395 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3396 if (control == NULL) {
3397 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3401 if (gst_camera_control_get_wdr(control, &cur_value)) {
3402 if (newVal != cur_value) {
3403 if (gst_camera_control_set_wdr(control, newVal)) {
3404 MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3407 MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3410 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3414 MMCAM_LOG_WARNING("Failed to get WDR.");
3417 MMCAM_LOG_INFO("pointer of video src is null");
3424 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3426 int current_state = MM_CAMCORDER_STATE_NONE;
3427 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3429 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3431 /* check whether set or not */
3432 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3433 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3437 current_state = _mmcamcorder_get_state(handle);
3438 if (current_state < MM_CAMCORDER_STATE_READY) {
3439 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3441 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3442 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3443 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3447 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3451 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3455 int current_state = MM_CAMCORDER_STATE_NONE;
3456 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3457 _MMCamcorderSubContext *sc = NULL;
3459 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3461 bitrate = value->value.i_val;
3463 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3464 if (!sc || !sc->encode_element) {
3465 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3469 current_state = _mmcamcorder_get_state(handle);
3470 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3471 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3472 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3476 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3477 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3479 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3480 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3482 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3483 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3490 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3492 int current_state = MM_CAMCORDER_STATE_NONE;
3493 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3495 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3497 current_state = _mmcamcorder_get_state(handle);
3498 if (current_state < MM_CAMCORDER_STATE_READY) {
3499 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3501 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3502 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3503 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3507 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3511 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3513 int current_state = MM_CAMCORDER_STATE_NONE;
3514 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3516 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3518 MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3520 current_state = _mmcamcorder_get_state(handle);
3522 if (current_state > MM_CAMCORDER_STATE_READY) {
3523 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3524 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3527 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3532 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3534 int current_state = MM_CAMCORDER_STATE_NONE;
3536 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3537 _MMCamcorderSubContext *sc = NULL;
3539 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3542 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3543 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3547 /* check current state */
3548 current_state = _mmcamcorder_get_state(handle);
3549 if (current_state < MM_CAMCORDER_STATE_READY) {
3550 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3552 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3553 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3554 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3558 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3560 MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3562 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3563 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3566 MMCAM_LOG_ERROR("invalid state %d", current_state);
3572 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3574 mmf_return_val_if_fail(handle && value, FALSE);
3577 if (!value->value.s_val) {
3578 MMCAM_LOG_ERROR("NULL filename");
3582 MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3588 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3590 int current_state = MM_CAMCORDER_STATE_NONE;
3591 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3593 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3595 current_state = _mmcamcorder_get_state(handle);
3596 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3597 MMCAM_LOG_ERROR("Can not set while RECORDING");
3598 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3606 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3608 GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3609 MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3610 return strcmp(Colorchannel->label, user_data);
3613 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3615 GstColorBalance *balance = NULL;
3616 GstColorBalanceChannel *Colorchannel = NULL;
3617 GList *controls = NULL;
3621 int current_state = MM_CAMCORDER_STATE_NONE;
3622 const char *control_label = NULL;
3623 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3624 _MMCamcorderSubContext *sc = NULL;
3626 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3627 gboolean check_scene_mode = FALSE;
3629 int wb_temp_table[] = {
3630 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3631 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3632 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3633 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3634 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3635 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3638 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3640 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3644 /* check whether set or not */
3645 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3646 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3650 current_state = _mmcamcorder_get_state(handle);
3651 if (current_state < MM_CAMCORDER_STATE_READY) {
3652 MMCAM_LOG_INFO("will be applied when preview starts");
3654 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3655 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3656 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3660 if (value->type != MM_ATTRS_TYPE_INT) {
3661 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3665 mslVal = value->value.i_val;
3668 case MM_CAM_FILTER_BRIGHTNESS:
3669 control_label = "brightness";
3670 check_scene_mode = TRUE;
3672 case MM_CAM_FILTER_CONTRAST:
3673 control_label = "contrast";
3675 case MM_CAM_FILTER_WB:
3676 control_label = "white balance";
3677 check_scene_mode = TRUE;
3679 case MM_CAM_FILTER_COLOR_TONE:
3680 control_label = "color tone";
3682 case MM_CAM_FILTER_SATURATION:
3683 control_label = "saturation";
3684 check_scene_mode = TRUE;
3686 case MM_CAM_FILTER_HUE:
3687 control_label = "hue";
3689 case MM_CAM_FILTER_SHARPNESS:
3690 control_label = "sharpness";
3691 check_scene_mode = TRUE;
3694 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3698 if (check_scene_mode) {
3699 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3700 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3701 MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3706 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3707 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3710 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3711 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3715 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3716 if (balance == NULL) {
3717 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3721 controls = (GList *)gst_color_balance_list_channels(balance);
3722 if (controls == NULL) {
3723 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3728 MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3729 attr_idx, control_label, mslVal, newVal);
3731 item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3733 Colorchannel = item->data;
3734 gst_color_balance_set_value(balance, Colorchannel, newVal);
3735 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3739 if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3740 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3742 control_label = "white_balance_temperature_auto";
3745 newVal = wb_temp_table[mslVal];
3746 control_label = "white_balance_temperature";
3751 MMCAM_LOG_ERROR("failed to find color channel item");
3757 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3761 int current_state = MM_CAMCORDER_STATE_NONE;
3762 GstCameraControl *control = NULL;
3763 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3764 _MMCamcorderSubContext *sc = NULL;
3766 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3768 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3772 mslVal = value->value.i_val;
3773 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3775 /* check whether set or not */
3776 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3777 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3781 current_state = _mmcamcorder_get_state(handle);
3782 if (current_state < MM_CAMCORDER_STATE_READY) {
3783 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3785 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3786 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3787 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3791 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3794 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3795 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3799 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3800 if (control == NULL) {
3801 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3805 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3807 MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3809 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3813 MM_CAM_FILTER_BRIGHTNESS,
3815 MM_CAM_FILTER_SATURATION,
3816 MM_CAM_FILTER_SHARPNESS,
3817 MM_CAM_FILTER_COLOR_TONE,
3818 MM_CAM_CAMERA_EXPOSURE_MODE
3820 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3822 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3823 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3824 mm_attrs_set_modified(attrs, attr_idxs[i]);
3830 MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3833 MMCAM_LOG_WARNING("pointer of video src is null");
3840 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3842 mmf_return_val_if_fail(handle && value, FALSE);
3844 MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3850 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3852 mmf_return_val_if_fail(handle && value, FALSE);
3854 MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3860 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3862 int current_state = MM_CAMCORDER_STATE_NONE;
3863 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3865 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3867 current_state = _mmcamcorder_get_state(handle);
3868 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3869 MMCAM_LOG_WARNING("Can NOT Disable AUDIO. invalid state %d", current_state);
3870 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3873 MMCAM_LOG_INFO("Disable AUDIO when Recording");
3879 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3881 int current_state = MM_CAMCORDER_STATE_NONE;
3882 const char *videosink_name = NULL;
3883 void *dp_handle = NULL;
3884 MMCamWindowInfo *window_info = NULL;
3886 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3887 _MMCamcorderSubContext *sc = NULL;
3889 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3892 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3893 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3897 /* check current state */
3898 current_state = _mmcamcorder_get_state(handle);
3899 if (current_state < MM_CAMCORDER_STATE_READY) {
3900 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3904 dp_handle = value->value.p_val;
3906 MMCAM_LOG_WARNING("Display handle is NULL");
3910 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3912 /* get videosink name */
3913 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3914 if (!videosink_name) {
3915 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3919 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3921 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3922 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
3923 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
3924 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3925 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
3926 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
3927 } else if (!strcmp(videosink_name, "tizenwlsink")) {
3928 window_info = (MMCamWindowInfo *)dp_handle;
3929 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
3930 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3931 } else if (!strcmp(videosink_name, "directvideosink")) {
3932 window_info = (MMCamWindowInfo *)dp_handle;
3933 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
3934 window_info->surface_id,
3935 window_info->rect.x,
3936 window_info->rect.y,
3937 window_info->rect.width,
3938 window_info->rect.height);
3939 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3940 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3941 window_info->rect.x,
3942 window_info->rect.y,
3943 window_info->rect.width,
3944 window_info->rect.height);
3946 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
3954 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3956 int current_state = MM_CAMCORDER_STATE_NONE;
3957 const char *videosink_name = NULL;
3959 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3960 _MMCamcorderSubContext *sc = NULL;
3962 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3965 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3966 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3970 /* check current state */
3971 current_state = _mmcamcorder_get_state(handle);
3972 if (current_state < MM_CAMCORDER_STATE_READY) {
3973 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3977 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3979 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3980 if (videosink_name == NULL) {
3981 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3985 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3987 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3988 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
3989 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3991 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
3998 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4000 int current_state = MM_CAMCORDER_STATE_NONE;
4002 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4004 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4007 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4008 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4012 /* check current state */
4013 current_state = _mmcamcorder_get_state(handle);
4014 if (current_state < MM_CAMCORDER_STATE_READY) {
4015 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
4019 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4023 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4025 int current_state = MM_CAMCORDER_STATE_NONE;
4027 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4029 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4032 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4033 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4037 /* check current state */
4038 current_state = _mmcamcorder_get_state(handle);
4039 if (current_state < MM_CAMCORDER_STATE_READY) {
4040 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
4044 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4048 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4050 int current_state = MM_CAMCORDER_STATE_NONE;
4051 const char *videosink_name = NULL;
4053 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4054 _MMCamcorderSubContext *sc = NULL;
4056 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4059 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4060 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4064 /* check current state */
4065 current_state = _mmcamcorder_get_state(handle);
4066 if (current_state < MM_CAMCORDER_STATE_READY) {
4067 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4071 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4073 /* Get videosink name */
4074 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4075 if (videosink_name == NULL) {
4076 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4080 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4081 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4082 !strcmp(videosink_name, "directvideosink")) {
4083 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4084 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4086 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4093 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4096 int current_state = MM_CAMCORDER_STATE_NONE;
4097 const char *videosink_name = NULL;
4099 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4100 _MMCamcorderSubContext *sc = NULL;
4102 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4105 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4106 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4110 /* check current state */
4111 current_state = _mmcamcorder_get_state(handle);
4112 if (current_state < MM_CAMCORDER_STATE_READY) {
4113 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4117 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4119 /* Get videosink name */
4120 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4121 if (videosink_name == NULL) {
4122 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4126 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4127 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4128 !strcmp(videosink_name, "directvideosink")) {
4129 method = value->value.i_val;
4130 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4132 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4139 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4141 int current_state = MM_CAMCORDER_STATE_NONE;
4142 int ret = MM_ERROR_NONE;
4143 const char *videosink_name = NULL;
4145 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4146 _MMCamcorderSubContext *sc = NULL;
4148 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4151 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4152 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4156 /* check current state */
4157 current_state = _mmcamcorder_get_state(handle);
4158 if (current_state < MM_CAMCORDER_STATE_READY) {
4159 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4163 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4165 /* Get videosink name */
4166 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4167 if (videosink_name == NULL) {
4168 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4172 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4173 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4177 int rect_height = 0;
4178 int flags = MM_ATTRS_FLAG_NONE;
4179 MMCamAttrsInfo info;
4181 mm_camcorder_get_attributes(handle, NULL,
4182 MMCAM_DISPLAY_RECT_X, &rect_x,
4183 MMCAM_DISPLAY_RECT_Y, &rect_y,
4184 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4185 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4188 case MM_CAM_DISPLAY_RECT_X:
4189 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4191 memset(&info, 0x00, sizeof(info));
4192 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4194 memset(&info, 0x00, sizeof(info));
4195 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4198 rect_x = value->value.i_val;
4200 case MM_CAM_DISPLAY_RECT_Y:
4201 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4203 memset(&info, 0x00, sizeof(info));
4204 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4207 rect_y = value->value.i_val;
4209 case MM_CAM_DISPLAY_RECT_WIDTH:
4210 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4213 rect_width = value->value.i_val;
4215 case MM_CAM_DISPLAY_RECT_HEIGHT:
4216 rect_height = value->value.i_val;
4219 MMCAM_LOG_ERROR("Wrong attr_idx!");
4223 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4224 MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4226 if (!strcmp(videosink_name, "tizenwlsink")) {
4227 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4228 rect_x, rect_y, rect_width, rect_height);
4230 MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4234 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4235 "dst-roi-x", rect_x,
4236 "dst-roi-y", rect_y,
4237 "dst-roi-w", rect_width,
4238 "dst-roi-h", rect_height,
4243 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4250 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4253 int current_state = MM_CAMCORDER_STATE_NONE;
4254 const char *videosink_name = NULL;
4255 GstElement *vs_element = NULL;
4257 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4258 _MMCamcorderSubContext *sc = NULL;
4260 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4263 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4264 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4268 /* check current state */
4269 current_state = _mmcamcorder_get_state(handle);
4270 if (current_state < MM_CAMCORDER_STATE_READY) {
4271 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4275 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4277 /* Get videosink name */
4278 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4279 if (videosink_name == NULL) {
4280 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4284 zoom = value->value.i_val;
4285 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4286 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4288 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4289 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4293 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4299 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4301 int current_state = MM_CAMCORDER_STATE_NONE;
4303 const char *videosink_name = NULL;
4305 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4306 _MMCamcorderSubContext *sc = NULL;
4308 mmf_return_val_if_fail(handle && value, FALSE);
4311 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4312 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4316 /* check current state */
4317 current_state = _mmcamcorder_get_state(handle);
4318 if (current_state < MM_CAMCORDER_STATE_READY) {
4319 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4323 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4325 do_scaling = value->value.i_val;
4327 /* Get videosink name */
4328 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4329 if (videosink_name == NULL) {
4330 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4334 if (!strcmp(videosink_name, "evaspixmapsink")) {
4335 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4336 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4339 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4345 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4347 _MMCamcorderSubContext *sc = NULL;
4348 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4349 int strobe_type, mslVal, newVal, cur_value;
4350 int current_state = MM_CAMCORDER_STATE_NONE;
4352 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4354 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4358 /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4360 mslVal = value->value.i_val;
4362 /* check flash state */
4363 if (attr_idx == MM_CAM_STROBE_MODE) {
4364 int led_brightness = 0;
4366 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4367 MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4368 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4372 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4374 if (led_brightness > 0 &&
4375 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4376 /* other module already turned on LED */
4377 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4378 MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4382 MMCAM_LOG_INFO("keep going");
4386 current_state = _mmcamcorder_get_state(handle);
4387 if (current_state < MM_CAMCORDER_STATE_READY) {
4388 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4390 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4391 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4392 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4397 case MM_CAM_STROBE_CONTROL:
4398 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4399 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4401 case MM_CAM_STROBE_CAPABILITIES:
4402 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4405 case MM_CAM_STROBE_MODE:
4406 /* check whether set or not */
4407 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4408 MMCAM_LOG_INFO("skip set value %d", mslVal);
4412 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4413 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4415 case MM_CAM_STROBE_BRIGHTNESS:
4416 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4420 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4424 GstCameraControl *control = NULL;
4425 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4426 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4430 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4431 if (control == NULL) {
4432 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4436 if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4437 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4441 if (newVal == cur_value) {
4442 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4446 if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4447 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4451 MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4457 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4460 int current_state = MM_CAMCORDER_STATE_NONE;
4461 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4463 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4465 MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4468 current_state = _mmcamcorder_get_state(handle);
4469 if (current_state > MM_CAMCORDER_STATE_READY) {
4470 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4471 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4473 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4474 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4478 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4480 MMCAM_LOG_INFO("ret %d", ret);
4486 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4488 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4489 int current_state = MM_CAMCORDER_STATE_NONE;
4490 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4491 _MMCamcorderSubContext *sc = NULL;
4493 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4495 /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4497 /* check whether set or not */
4498 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4499 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4504 current_state = _mmcamcorder_get_state(handle);
4505 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4506 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4507 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4511 if (current_state >= MM_CAMCORDER_STATE_READY) {
4512 int current_value = 0;
4514 set_hdr_mode = value->value.i_val;
4515 mm_camcorder_get_attributes(handle, NULL,
4516 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4519 if (set_hdr_mode == current_value) {
4520 MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4524 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4526 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4527 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4528 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4530 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4532 /* check decoder recreation */
4533 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4534 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4538 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4539 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4542 set_hdr_mode = value->value.i_val;
4543 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4544 sc->info_image->hdr_capture_mode = set_hdr_mode;
4545 MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4547 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4548 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4550 MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4559 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4562 _MMCamcorderSubContext *sc = NULL;
4563 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4565 int current_value = 0;
4566 int current_state = MM_CAMCORDER_STATE_NONE;
4567 GstCameraControl *control = NULL;
4569 mmf_return_val_if_fail(handle && value, FALSE);
4571 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4575 /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4578 current_state = _mmcamcorder_get_state(handle);
4579 if (current_state < MM_CAMCORDER_STATE_READY) {
4580 MMCAM_LOG_INFO("will be applied when preview starts");
4584 set_value = value->value.i_val;
4587 case MM_CAM_DETECT_MODE:
4588 /* check whether set or not */
4589 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4590 MMCAM_LOG_INFO("skip set value %d", set_value);
4594 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4596 case MM_CAM_DETECT_NUMBER:
4597 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4599 case MM_CAM_DETECT_FOCUS_SELECT:
4600 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4602 case MM_CAM_DETECT_SELECT_NUMBER:
4603 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4605 case MM_CAM_DETECT_STATUS:
4606 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4609 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4613 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4614 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4617 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4618 if (control == NULL) {
4619 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4623 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4624 if (current_value == set_value) {
4625 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4628 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4629 MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4630 detect_type, set_value);
4633 MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4634 detect_type, set_value);
4639 MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4648 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4650 int current_state = MM_CAMCORDER_STATE_NONE;
4651 int preview_format = MM_PIXEL_FORMAT_NV12;
4653 mmf_return_val_if_fail(handle && value, FALSE);
4655 MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4657 /* check preview format */
4658 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4659 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
4660 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4665 current_state = _mmcamcorder_get_state(handle);
4666 if (current_state < MM_CAMCORDER_STATE_READY) {
4667 MMCAM_LOG_INFO("will be applied when preview starts");
4671 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4675 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4677 int current_state = MM_CAMCORDER_STATE_NONE;
4678 int preview_format = MM_PIXEL_FORMAT_NV12;
4680 mmf_return_val_if_fail(handle && value, FALSE);
4682 MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4684 /* check preview format */
4685 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4686 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
4687 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4692 current_state = _mmcamcorder_get_state(handle);
4693 if (current_state < MM_CAMCORDER_STATE_READY) {
4694 MMCAM_LOG_INFO("will be applied when preview starts");
4698 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4702 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4704 int stream_index = 0;
4705 char *stream_type = NULL;
4706 _MMCamcorderSubContext *sc = NULL;
4708 mmf_return_val_if_fail(handle && value, FALSE);
4710 stream_type = value->value.s_val;
4712 MMCAM_LOG_ERROR("NULL string");
4716 mm_camcorder_get_attributes(handle, NULL,
4717 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4719 if (stream_index < 0) {
4720 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4724 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4725 if (!sc || !sc->encode_element ||
4726 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4727 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4731 MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4733 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4737 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4739 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4740 int current_state = MM_CAMCORDER_STATE_NONE;
4742 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4744 current_state = _mmcamcorder_get_state(handle);
4745 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4746 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4747 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4754 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4756 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4758 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4760 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4761 /* Replay gain enable */
4762 int current_state = MM_CAMCORDER_STATE_NONE;
4763 int audio_disable = FALSE;
4765 current_state = _mmcamcorder_get_state(handle);
4766 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4767 MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4768 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4772 mm_camcorder_get_attributes(handle, NULL,
4773 MMCAM_AUDIO_DISABLE, &audio_disable,
4776 if (audio_disable) {
4777 MMCAM_LOG_ERROR("audio is disabled");
4778 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4782 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4783 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4784 /* Replay gain reference level */
4785 int replay_gain_enable = FALSE;
4787 mm_camcorder_get_attributes(handle, NULL,
4788 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4791 if (replay_gain_enable == FALSE) {
4792 MMCAM_LOG_ERROR("replay gain is disabled");
4793 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4797 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4799 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4807 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4809 int current_state = MM_CAMCORDER_STATE_NONE;
4810 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4811 _MMCamcorderSubContext *sc = NULL;
4813 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4815 if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4816 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4820 MMCAM_LOG_INFO("Enable extra preview(%d)", value->value.i_val);
4822 current_state = _mmcamcorder_get_state(handle);
4823 if (current_state < MM_CAMCORDER_STATE_READY) {
4824 MMCAM_LOG_INFO("will be set when preview is started");
4828 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4829 mmf_return_val_if_fail(sc, FALSE);
4831 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", value->value.i_val);
4833 MMCAM_LOG_INFO("done");
4839 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4841 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4844 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4848 int attr_idxs_default[] = {
4849 MM_CAM_CAMERA_DIGITAL_ZOOM,
4850 MM_CAM_CAMERA_OPTICAL_ZOOM,
4852 MM_CAM_FILTER_CONTRAST,
4855 MM_CAM_STROBE_BRIGHTNESS
4858 int attr_idxs_extra[] = {
4860 MM_CAM_FILTER_BRIGHTNESS,
4862 MM_CAM_FILTER_SATURATION,
4863 MM_CAM_FILTER_SHARPNESS,
4864 MM_CAM_FILTER_COLOR_TONE,
4865 MM_CAM_CAMERA_EXPOSURE_MODE
4868 mmf_return_val_if_fail(hcamcorder, FALSE);
4870 MMCAM_LOG_INFO("commit some attributes again");
4872 attrs = MMF_CAMCORDER_ATTRS(handle);
4873 if (attrs == NULL) {
4874 MMCAM_LOG_ERROR("Get attribute handle failed.");
4878 /* Get Scene mode */
4879 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4881 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4882 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4883 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4886 /* Set extra if scene mode is NORMAL */
4887 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4888 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4889 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4890 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4893 /* Set scene mode if scene mode is NOT NORMAL */
4894 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4895 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4898 if (mm_attrs_commit_all(attrs) == -1)
4903 MMCAM_LOG_INFO("Done.");
4909 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4911 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4917 MM_CAM_CAMERA_PTZ_TYPE,
4918 MM_CAM_CAMERA_PAN_MECHA,
4919 MM_CAM_CAMERA_PAN_ELEC,
4920 MM_CAM_CAMERA_TILT_MECHA,
4921 MM_CAM_CAMERA_TILT_ELEC
4924 mmf_return_val_if_fail(hcamcorder, FALSE);
4926 MMCAM_LOG_INFO("commit some attribute again[2]");
4928 attrs = MMF_CAMCORDER_ATTRS(handle);
4929 if (attrs == NULL) {
4930 MMCAM_LOG_ERROR("Get attribute handle failed.");
4934 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4935 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4936 mm_attrs_set_modified(attrs, attr_idxs[i]);
4939 if (mm_attrs_commit_all(attrs) == -1)
4944 MMCAM_LOG_INFO("Done.");
4950 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4952 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4956 int nerror = MM_ERROR_NONE;
4958 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4960 attrs = MMF_CAMCORDER_ATTRS(handle);
4961 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4965 table_size = ARRAY_SIZE(readonly_attributes);
4966 MMCAM_LOG_INFO("%d", table_size);
4967 for (i = 0; i < table_size; i++) {
4968 int sCategory = readonly_attributes[i];
4970 mm_attrs_set_readonly(attrs, sCategory);
4977 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4979 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4982 type_string_array * disabled_attr = NULL;
4984 int nerror = MM_ERROR_NONE ;
4986 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4988 attrs = MMF_CAMCORDER_ATTRS(handle);
4989 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4994 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4995 CONFIGURE_CATEGORY_MAIN_GENERAL,
4996 "DisabledAttributes",
4998 if (disabled_attr != NULL && disabled_attr->value) {
4999 cnt_str = disabled_attr->count;
5000 for (i = 0; i < cnt_str; i++) {
5002 MMCAM_LOG_INFO("[%d]%s", i, disabled_attr->value[i]);
5003 nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
5005 if (nerror == MM_ERROR_NONE)
5006 mm_attrs_set_disabled(attrs, idx);
5008 MMCAM_LOG_WARNING("No ATTR named %s[%d]", disabled_attr->value[i], i);
5016 /*---------------------------------------------------------------------------------------
5017 | INTERNAL FUNCTION DEFINITIONS: |
5018 ---------------------------------------------------------------------------------------*/
5019 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
5021 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5022 _MMCamcorderSubContext *sc = NULL;
5023 int current_state = MM_CAMCORDER_STATE_NULL;
5025 mmf_return_val_if_fail(hcamcorder, FALSE);
5027 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
5031 current_state = _mmcamcorder_get_state(handle);
5033 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
5034 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
5035 MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
5036 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
5037 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
5039 MMCAM_LOG_WARNING("invalid state[%d]", current_state);
5043 MMCAM_LOG_INFO("element is not created yet");
5050 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
5052 #define INIT_VALUE -1
5053 #define CHECK_COUNT 3
5055 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5056 MMHandleType attrs = 0;
5058 int ret = MM_ERROR_NONE;
5061 const char *name = NULL;
5062 const char *check_pair_name[CHECK_COUNT][3] = {
5063 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
5064 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
5065 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
5068 int check_pair_value[CHECK_COUNT][2] = {
5069 {INIT_VALUE, INIT_VALUE},
5070 {INIT_VALUE, INIT_VALUE},
5071 {INIT_VALUE, INIT_VALUE},
5074 if (hcamcorder == NULL || attribute_name == NULL) {
5075 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
5076 hcamcorder, attribute_name);
5077 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5081 *err_attr_name = NULL;
5083 /*MMCAM_LOG_INFO( "ENTER" );*/
5085 attrs = MMF_CAMCORDER_ATTRS(handle);
5087 name = attribute_name;
5091 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
5093 /*MMCAM_LOG_INFO("NAME : %s", name);*/
5095 /* attribute name check */
5096 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
5098 *err_attr_name = strdup(name);
5100 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
5101 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5107 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5110 switch (attr_type) {
5111 case MM_ATTRS_TYPE_INT:
5113 gboolean matched = FALSE;
5114 for (i = 0 ; i < CHECK_COUNT ; i++) {
5115 for (j = 0 ; j < 2 ; j++) {
5116 if (!strcmp(name, check_pair_name[i][j])) {
5117 check_pair_value[i][j] = va_arg((var_args), int);
5118 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5126 if (matched == FALSE)
5127 va_arg((var_args), int);
5130 case MM_ATTRS_TYPE_DOUBLE:
5131 va_arg((var_args), double);
5133 case MM_ATTRS_TYPE_STRING:
5134 va_arg((var_args), char*); /* string */
5135 va_arg((var_args), int); /* size */
5137 case MM_ATTRS_TYPE_DATA:
5138 va_arg((var_args), void*); /* data */
5139 va_arg((var_args), int); /* size */
5141 case MM_ATTRS_TYPE_INVALID:
5143 MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5145 *err_attr_name = strdup(name);
5147 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5151 name = va_arg(var_args, const char*);
5154 for (i = 0 ; i < CHECK_COUNT ; i++) {
5155 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5156 gboolean check_result = FALSE;
5157 char *err_name = NULL;
5158 MMCamAttrsInfo attr_info_0, attr_info_1;
5160 if (check_pair_value[i][0] == INIT_VALUE) {
5161 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5162 err_name = strdup(check_pair_name[i][1]);
5163 } else if (check_pair_value[i][1] == INIT_VALUE) {
5164 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5165 err_name = strdup(check_pair_name[i][0]);
5167 err_name = strdup(check_pair_name[i][2]);
5170 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5171 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5173 check_result = FALSE;
5175 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5176 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5177 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5179 MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5180 check_pair_name[i][0], check_pair_name[i][1],
5181 check_pair_value[i][0], check_pair_value[i][1], i);
5183 check_result = TRUE;
5188 if (check_result == FALSE) {
5189 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5190 check_pair_name[i][0], check_pair_name[i][1],
5191 check_pair_value[i][0], check_pair_value[i][1]);
5192 if (err_attr_name) {
5193 *err_attr_name = err_name;
5201 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5204 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5205 int current_width = 0;
5206 int current_height = 0;
5208 mm_camcorder_get_attributes(handle, NULL,
5209 MMCAM_CAMERA_WIDTH, ¤t_width,
5210 MMCAM_CAMERA_HEIGHT, ¤t_height,
5213 if (current_width != check_pair_value[i][0] ||
5214 current_height != check_pair_value[i][1]) {
5215 hcamcorder->resolution_changed = TRUE;
5217 hcamcorder->resolution_changed = FALSE;
5220 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5230 /*MMCAM_LOG_INFO("DONE");*/
5232 return MM_ERROR_NONE;
5236 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5240 if ((void *)handle == NULL) {
5241 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5245 memset(&info, 0x0, sizeof(MMAttrsInfo));
5247 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5249 switch (info.validity_type) {
5250 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5252 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5254 if (info.int_array.count < 1)
5257 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5259 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5261 if (info.int_range.min > info.int_range.max)
5264 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5266 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5268 if (info.double_array.count < 1)
5271 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5273 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5275 if (info.double_range.min >= info.double_range.max)
5279 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);