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/videooverlay.h>
32 /*-----------------------------------------------------------------------
33 | MACRO DEFINITIONS: |
34 -----------------------------------------------------------------------*/
35 #define MMCAMCORDER_DEFAULT_CAMERA_WIDTH 640
36 #define MMCAMCORDER_DEFAULT_CAMERA_HEIGHT 480
37 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL 1000
38 #define MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL 89.0
40 /*---------------------------------------------------------------------------------------
41 | GLOBAL VARIABLE DEFINITIONS for internal |
42 ---------------------------------------------------------------------------------------*/
44 /*-----------------------------------------------------------------------
45 | LOCAL VARIABLE DEFINITIONS for internal |
46 -----------------------------------------------------------------------*/
47 /* Readonly attributes list.
48 * If you want to make some attributes read only, write down here.
49 * It will make them read only after composing whole attributes.
52 static int readonly_attributes[] = {
53 MM_CAM_CAMERA_DEVICE_COUNT,
54 MM_CAM_CAMERA_DEVICE_NAME,
55 MM_CAM_CAMERA_FACING_DIRECTION,
56 MM_CAM_CAMERA_SHUTTER_SPEED,
57 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
58 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
59 MM_CAM_CAPTURED_SCREENNAIL,
60 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
61 MM_CAM_SUPPORT_ZSL_CAPTURE,
62 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
63 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
64 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_INTERNAL_CB,
65 MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
66 MM_CAM_VIDEOSRC_ELEMENT_NAME,
67 MM_CAM_AUDIOSRC_ELEMENT_NAME
70 /*-----------------------------------------------------------------------
71 | LOCAL FUNCTION PROTOTYPES: |
72 -----------------------------------------------------------------------*/
73 /* STATIC INTERNAL FUNCTION */
74 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height);
75 static int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle);
76 static int __mmcamcorder_release_conf_valid_info(MMHandleType handle);
77 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args);
79 /*=======================================================================
80 | FUNCTION DEFINITIONS |
81 =======================================================================*/
82 /*-----------------------------------------------------------------------
83 | GLOBAL FUNCTION DEFINITIONS: |
84 -----------------------------------------------------------------------*/
86 _mmcamcorder_alloc_attribute(MMHandleType handle)
90 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
91 MMHandleType attrs = NULL;
92 MMAttrsConstructInfo *attrs_const_info;
93 unsigned int attr_count = 0;
95 int ret = MM_ERROR_NONE;
97 static int depth[] = {MM_CAMCORDER_AUDIO_FORMAT_PCM_U8, MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE};
98 static int flip_list[] = { MM_FLIP_NONE };
99 static int rotation_list[] = { MM_VIDEO_INPUT_ROTATION_NONE };
100 static int visible_values[] = { 0, 1 }; /*0: off, 1:on*/
101 static int tag_orientation_values[] = {
102 1, /*The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.*/
103 2, /*the 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.*/
104 3, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.*/
105 4, /*the 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.*/
106 5, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual top.*/
107 6, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual top.*/
108 7, /*the 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.*/
109 8, /*the 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.*/
112 if (hcamcorder == NULL) {
113 MMCAM_LOG_ERROR("handle is NULL");
117 /* Create attribute constructor */
118 MMCAM_LOG_INFO("start");
120 /* alloc 'MMAttrsConstructInfo' */
121 attr_count = MM_CAM_ATTRIBUTE_NUM;
122 attrs_const_info = malloc(attr_count * sizeof(MMAttrsConstructInfo));
123 if (!attrs_const_info) {
124 MMCAM_LOG_ERROR("Fail to alloc constructor.");
128 /* alloc default attribute info */
129 hcamcorder->cam_attrs_const_info = (mm_cam_attr_construct_info *)malloc(sizeof(mm_cam_attr_construct_info) * attr_count);
130 if (hcamcorder->cam_attrs_const_info == NULL) {
131 MMCAM_LOG_ERROR("failed to alloc default attribute info");
132 free(attrs_const_info);
133 attrs_const_info = NULL;
137 /* basic attributes' info */
138 mm_cam_attr_construct_info temp_info[] = {
141 MM_CAM_MODE, /* ID */
143 MM_ATTRS_TYPE_INT, /* Type */
144 MM_ATTRS_FLAG_RW, /* Flag */
145 {(void*)MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Default value */
146 MM_ATTRS_VALID_TYPE_INT_RANGE, /* Validity type */
147 {.int_min = MM_CAMCORDER_MODE_VIDEO_CAPTURE}, /* Validity val1 (min, *array,...) */
148 {.int_max = MM_CAMCORDER_MODE_AUDIO}, /* Validity val2 (max, count, ...) */
149 NULL, /* Runtime setting function of the attribute */
156 {(void*)MM_AUDIO_DEVICE_MIC},
157 MM_ATTRS_VALID_TYPE_INT_ARRAY,
163 MM_CAM_CAMERA_DEVICE_COUNT,
164 "camera-device-count",
167 {(void*)MM_VIDEO_DEVICE_NUM},
168 MM_ATTRS_VALID_TYPE_INT_RANGE,
169 {.int_min = MM_VIDEO_DEVICE_NONE},
170 {.int_max = MM_VIDEO_DEVICE_NUM},
174 MM_CAM_AUDIO_ENCODER,
178 {(void*)MM_AUDIO_CODEC_AMR},
179 MM_ATTRS_VALID_TYPE_INT_ARRAY,
185 MM_CAM_VIDEO_ENCODER,
189 {(void*)MM_VIDEO_CODEC_MPEG4},
190 MM_ATTRS_VALID_TYPE_INT_ARRAY,
196 MM_CAM_IMAGE_ENCODER,
200 {(void*)MM_IMAGE_CODEC_JPEG},
201 MM_ATTRS_VALID_TYPE_INT_ARRAY,
211 {(void*)MM_FILE_FORMAT_MP4},
212 MM_ATTRS_VALID_TYPE_INT_ARRAY,
218 MM_CAM_CAMERA_DEVICE_NAME,
219 "camera-device-name",
220 MM_ATTRS_TYPE_STRING,
223 MM_ATTRS_VALID_TYPE_NONE,
229 MM_CAM_AUDIO_SAMPLERATE,
234 MM_ATTRS_VALID_TYPE_INT_RANGE,
236 {.int_max = _MMCAMCORDER_MAX_INT},
244 {(void*)MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE},
245 MM_ATTRS_VALID_TYPE_INT_ARRAY,
252 MM_CAM_AUDIO_CHANNEL,
257 MM_ATTRS_VALID_TYPE_INT_RANGE,
265 MM_ATTRS_TYPE_DOUBLE,
267 {.value_double = 1.0},
268 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
270 {.double_max = 10.0},
271 _mmcamcorder_commit_audio_volume,
274 MM_CAM_AUDIO_INPUT_ROUTE,
278 {(void*)MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
279 MM_ATTRS_VALID_TYPE_INT_RANGE,
280 {.int_min = MM_AUDIOROUTE_USE_EXTERNAL_SETTING},
281 {.int_max = MM_AUDIOROUTE_CAPTURE_STEREOMIC_ONLY},
282 _mmcamcorder_commit_audio_input_route,
285 MM_CAM_FILTER_SCENE_MODE,
290 MM_ATTRS_VALID_TYPE_INT_ARRAY,
293 _mmcamcorder_commit_filter_scene_mode,
296 MM_CAM_FILTER_BRIGHTNESS,
301 MM_ATTRS_VALID_TYPE_INT_RANGE,
304 _mmcamcorder_commit_filter,
307 MM_CAM_FILTER_CONTRAST,
312 MM_ATTRS_VALID_TYPE_INT_RANGE,
315 _mmcamcorder_commit_filter,
323 MM_ATTRS_VALID_TYPE_INT_ARRAY,
326 _mmcamcorder_commit_filter,
329 MM_CAM_FILTER_COLOR_TONE,
334 MM_ATTRS_VALID_TYPE_INT_ARRAY,
337 _mmcamcorder_commit_filter,
340 MM_CAM_FILTER_SATURATION,
345 MM_ATTRS_VALID_TYPE_INT_RANGE,
348 _mmcamcorder_commit_filter,
356 MM_ATTRS_VALID_TYPE_INT_RANGE,
359 _mmcamcorder_commit_filter,
363 MM_CAM_FILTER_SHARPNESS,
368 MM_ATTRS_VALID_TYPE_INT_RANGE,
371 _mmcamcorder_commit_filter,
374 MM_CAM_CAMERA_FORMAT,
378 {(void*)MM_PIXEL_FORMAT_YUYV},
379 MM_ATTRS_VALID_TYPE_INT_ARRAY,
382 _mmcamcorder_commit_camera_format,
385 MM_CAM_CAMERA_RECORDING_MOTION_RATE,
386 "camera-recording-motion-rate",
387 MM_ATTRS_TYPE_DOUBLE,
389 {.value_double = 1.0},
390 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
392 {.double_max = _MMCAMCORDER_MAX_DOUBLE},
393 _mmcamcorder_commit_camera_recording_motion_rate,
401 MM_ATTRS_VALID_TYPE_INT_RANGE,
404 _mmcamcorder_commit_camera_fps,
411 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
412 MM_ATTRS_VALID_TYPE_INT_ARRAY,
415 _mmcamcorder_commit_camera_width,
418 MM_CAM_CAMERA_HEIGHT,
422 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
423 MM_ATTRS_VALID_TYPE_INT_ARRAY,
426 _mmcamcorder_commit_camera_height,
429 MM_CAM_CAMERA_DIGITAL_ZOOM,
430 "camera-digital-zoom",
434 MM_ATTRS_VALID_TYPE_INT_RANGE,
437 _mmcamcorder_commit_camera_zoom,
440 MM_CAM_CAMERA_OPTICAL_ZOOM,
441 "camera-optical-zoom",
445 MM_ATTRS_VALID_TYPE_INT_RANGE,
448 _mmcamcorder_commit_camera_zoom,
451 MM_CAM_CAMERA_FOCUS_MODE,
455 {(void*)MM_CAMCORDER_FOCUS_MODE_NONE},
456 MM_ATTRS_VALID_TYPE_INT_ARRAY,
459 _mmcamcorder_commit_camera_focus_mode,
462 MM_CAM_CAMERA_AF_SCAN_RANGE,
463 "camera-af-scan-range",
467 MM_ATTRS_VALID_TYPE_INT_ARRAY,
470 _mmcamcorder_commit_camera_af_scan_range,
474 MM_CAM_CAMERA_EXPOSURE_MODE,
475 "camera-exposure-mode",
479 MM_ATTRS_VALID_TYPE_INT_ARRAY,
482 _mmcamcorder_commit_camera_capture_mode,
485 MM_CAM_CAMERA_EXPOSURE_VALUE,
486 "camera-exposure-value",
490 MM_ATTRS_VALID_TYPE_INT_RANGE,
493 _mmcamcorder_commit_camera_capture_mode,
496 MM_CAM_CAMERA_F_NUMBER,
501 MM_ATTRS_VALID_TYPE_INT_ARRAY,
504 _mmcamcorder_commit_camera_capture_mode,
507 MM_CAM_CAMERA_SHUTTER_SPEED,
508 "camera-shutter-speed",
512 MM_ATTRS_VALID_TYPE_INT_ARRAY,
515 _mmcamcorder_commit_camera_capture_mode,
523 MM_ATTRS_VALID_TYPE_INT_ARRAY,
526 _mmcamcorder_commit_camera_capture_mode,
534 MM_ATTRS_VALID_TYPE_INT_ARRAY,
537 _mmcamcorder_commit_camera_wdr,
540 MM_CAM_CAMERA_ANTI_HANDSHAKE,
541 "camera-anti-handshake",
545 MM_ATTRS_VALID_TYPE_INT_ARRAY,
548 _mmcamcorder_commit_camera_anti_handshake,
551 MM_CAM_CAMERA_FPS_AUTO,
556 MM_ATTRS_VALID_TYPE_INT_RANGE,
559 _mmcamcorder_commit_camera_fps,
562 MM_CAM_CAMERA_DELAY_ATTR_SETTING,
563 "camera-delay-attr-setting",
567 MM_ATTRS_VALID_TYPE_INT_RANGE,
573 MM_CAM_AUDIO_ENCODER_BITRATE,
574 "audio-encoder-bitrate",
578 MM_ATTRS_VALID_TYPE_INT_RANGE,
580 {.int_max = _MMCAMCORDER_MAX_INT},
581 _mmcamcorder_commit_encoder_bitrate,
585 MM_CAM_VIDEO_ENCODER_BITRATE,
586 "video-encoder-bitrate",
590 MM_ATTRS_VALID_TYPE_INT_RANGE,
592 {.int_max = _MMCAMCORDER_MAX_INT},
593 _mmcamcorder_commit_encoder_bitrate,
596 MM_CAM_IMAGE_ENCODER_QUALITY,
597 "image-encoder-quality",
601 MM_ATTRS_VALID_TYPE_INT_RANGE,
604 _mmcamcorder_commit_image_encoder_quality,
607 MM_CAM_CAPTURE_FORMAT,
611 {(void*)MM_PIXEL_FORMAT_ENCODED},
612 MM_ATTRS_VALID_TYPE_INT_ARRAY,
618 MM_CAM_CAPTURE_WIDTH,
623 MM_ATTRS_VALID_TYPE_INT_ARRAY,
626 _mmcamcorder_commit_capture_width ,
629 MM_CAM_CAPTURE_HEIGHT,
634 MM_ATTRS_VALID_TYPE_INT_ARRAY,
637 _mmcamcorder_commit_capture_height,
640 MM_CAM_CAPTURE_COUNT,
645 MM_ATTRS_VALID_TYPE_INT_RANGE,
648 _mmcamcorder_commit_capture_count,
651 MM_CAM_CAPTURE_INTERVAL,
656 MM_ATTRS_VALID_TYPE_INT_RANGE,
658 {.int_max = _MMCAMCORDER_MAX_INT},
662 MM_CAM_CAPTURE_BREAK_CONTINUOUS_SHOT,
663 "capture-break-cont-shot",
667 MM_ATTRS_VALID_TYPE_INT_RANGE,
670 _mmcamcorder_commit_capture_break_cont_shot,
673 MM_CAM_DISPLAY_HANDLE,
678 MM_ATTRS_VALID_TYPE_NONE,
681 _mmcamcorder_commit_display_handle,
684 MM_CAM_DISPLAY_DEVICE,
688 {(void*)MM_DISPLAY_DEVICE_MAINLCD},
689 MM_ATTRS_VALID_TYPE_INT_ARRAY,
696 MM_CAM_DISPLAY_SURFACE,
700 {(void*)MM_DISPLAY_SURFACE_OVERLAY},
701 MM_ATTRS_VALID_TYPE_INT_ARRAY,
707 MM_CAM_DISPLAY_RECT_X,
712 MM_ATTRS_VALID_TYPE_INT_RANGE,
714 {.int_max = _MMCAMCORDER_MAX_INT},
715 _mmcamcorder_commit_display_rect,
718 MM_CAM_DISPLAY_RECT_Y,
723 MM_ATTRS_VALID_TYPE_INT_RANGE,
725 {.int_max = _MMCAMCORDER_MAX_INT},
726 _mmcamcorder_commit_display_rect,
729 MM_CAM_DISPLAY_RECT_WIDTH,
730 "display-rect-width",
734 MM_ATTRS_VALID_TYPE_INT_RANGE,
736 {.int_max = _MMCAMCORDER_MAX_INT},
737 _mmcamcorder_commit_display_rect,
740 MM_CAM_DISPLAY_RECT_HEIGHT,
741 "display-rect-height",
745 MM_ATTRS_VALID_TYPE_INT_RANGE,
747 {.int_max = _MMCAMCORDER_MAX_INT},
748 _mmcamcorder_commit_display_rect,
751 MM_CAM_DISPLAY_SOURCE_X,
756 MM_ATTRS_VALID_TYPE_INT_RANGE,
758 {.int_max = _MMCAMCORDER_MAX_INT},
762 MM_CAM_DISPLAY_SOURCE_Y,
767 MM_ATTRS_VALID_TYPE_INT_RANGE,
769 {.int_max = _MMCAMCORDER_MAX_INT},
773 MM_CAM_DISPLAY_SOURCE_WIDTH,
778 MM_ATTRS_VALID_TYPE_INT_RANGE,
780 {.int_max = _MMCAMCORDER_MAX_INT},
784 MM_CAM_DISPLAY_SOURCE_HEIGHT,
785 "display-src-height",
789 MM_ATTRS_VALID_TYPE_INT_RANGE,
791 {.int_max = _MMCAMCORDER_MAX_INT},
795 MM_CAM_DISPLAY_ROTATION,
799 {(void*)MM_DISPLAY_ROTATION_NONE},
800 MM_ATTRS_VALID_TYPE_INT_RANGE,
801 {.int_min = MM_DISPLAY_ROTATION_NONE},
802 {.int_max = MM_DISPLAY_ROTATION_270},
803 _mmcamcorder_commit_display_rotation,
807 MM_CAM_DISPLAY_VISIBLE,
812 MM_ATTRS_VALID_TYPE_INT_ARRAY,
814 {ARRAY_SIZE(visible_values)},
815 _mmcamcorder_commit_display_visible,
818 MM_CAM_DISPLAY_SCALE,
823 MM_ATTRS_VALID_TYPE_INT_RANGE,
824 {.int_min = MM_DISPLAY_SCALE_DEFAULT},
825 {.int_max = MM_DISPLAY_SCALE_TRIPLE_LENGTH},
826 _mmcamcorder_commit_display_scale,
829 MM_CAM_DISPLAY_GEOMETRY_METHOD,
830 "display-geometry-method",
834 MM_ATTRS_VALID_TYPE_INT_RANGE,
835 {.int_min = MM_DISPLAY_METHOD_LETTER_BOX},
836 {.int_max = MM_DISPLAY_METHOD_CUSTOM_ROI},
837 _mmcamcorder_commit_display_geometry_method,
840 MM_CAM_TARGET_FILENAME,
842 MM_ATTRS_TYPE_STRING,
845 MM_ATTRS_VALID_TYPE_NONE,
848 _mmcamcorder_commit_target_filename,
851 MM_CAM_TARGET_MAX_SIZE,
856 MM_ATTRS_VALID_TYPE_INT_RANGE,
858 {.int_max = _MMCAMCORDER_MAX_INT},
859 _mmcamcorder_commit_recording_max_limit,
862 MM_CAM_TARGET_TIME_LIMIT,
867 MM_ATTRS_VALID_TYPE_INT_RANGE,
869 {.int_max = _MMCAMCORDER_MAX_INT},
870 _mmcamcorder_commit_recording_max_limit,
878 MM_ATTRS_VALID_TYPE_INT_RANGE,
881 _mmcamcorder_commit_tag,
884 MM_CAM_TAG_IMAGE_DESCRIPTION,
885 "tag-image-description",
886 MM_ATTRS_TYPE_STRING,
889 MM_ATTRS_VALID_TYPE_NONE,
892 _mmcamcorder_commit_tag,
895 MM_CAM_TAG_ORIENTATION,
900 MM_ATTRS_VALID_TYPE_INT_ARRAY,
901 {tag_orientation_values},
902 {ARRAY_SIZE(tag_orientation_values)},
903 _mmcamcorder_commit_tag,
908 MM_ATTRS_TYPE_STRING,
911 MM_ATTRS_VALID_TYPE_NONE,
914 _mmcamcorder_commit_tag,
920 MM_ATTRS_TYPE_DOUBLE,
922 {.value_double = 0.0},
923 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
924 {.double_min = -360.0},
925 {.double_max = 360.0},
926 _mmcamcorder_commit_tag,
929 MM_CAM_TAG_LONGITUDE,
931 MM_ATTRS_TYPE_DOUBLE,
933 {.value_double = 0.0},
934 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
935 {.double_min = -360.0},
936 {.double_max = 360.0},
937 _mmcamcorder_commit_tag,
942 MM_ATTRS_TYPE_DOUBLE,
944 {.value_double = 0.0},
945 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
946 {.double_min = -999999.0},
947 {.double_max = 999999.0},
948 _mmcamcorder_commit_tag,
951 MM_CAM_STROBE_CONTROL,
956 MM_ATTRS_VALID_TYPE_INT_RANGE,
959 _mmcamcorder_commit_strobe,
962 MM_CAM_STROBE_CAPABILITIES,
963 "strobe-capabilities",
967 MM_ATTRS_VALID_TYPE_INT_RANGE,
970 _mmcamcorder_commit_strobe,
978 MM_ATTRS_VALID_TYPE_INT_ARRAY,
981 _mmcamcorder_commit_strobe,
989 MM_ATTRS_VALID_TYPE_INT_ARRAY,
992 _mmcamcorder_commit_detect,
995 MM_CAM_DETECT_NUMBER,
1000 MM_ATTRS_VALID_TYPE_INT_RANGE,
1003 _mmcamcorder_commit_detect,
1006 MM_CAM_DETECT_FOCUS_SELECT,
1007 "detect-focus-select",
1011 MM_ATTRS_VALID_TYPE_INT_RANGE,
1014 _mmcamcorder_commit_detect,
1017 MM_CAM_DETECT_SELECT_NUMBER,
1018 "detect-select-number",
1022 MM_ATTRS_VALID_TYPE_INT_RANGE,
1025 _mmcamcorder_commit_detect,
1029 MM_CAM_DETECT_STATUS,
1034 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1037 _mmcamcorder_commit_detect,
1040 MM_CAM_CAPTURE_ZERO_SYSTEMLAG,
1041 "capture-zero-systemlag",
1045 MM_ATTRS_VALID_TYPE_INT_RANGE,
1051 MM_CAM_CAMERA_AF_TOUCH_X,
1052 "camera-af-touch-x",
1056 MM_ATTRS_VALID_TYPE_INT_RANGE,
1058 {.int_max = _MMCAMCORDER_MAX_INT},
1059 _mmcamcorder_commit_camera_af_touch_area,
1062 MM_CAM_CAMERA_AF_TOUCH_Y,
1063 "camera-af-touch-y",
1067 MM_ATTRS_VALID_TYPE_INT_RANGE,
1069 {.int_max = _MMCAMCORDER_MAX_INT},
1070 _mmcamcorder_commit_camera_af_touch_area,
1073 MM_CAM_CAMERA_AF_TOUCH_WIDTH,
1074 "camera-af-touch-width",
1078 MM_ATTRS_VALID_TYPE_INT_RANGE,
1080 {.int_max = _MMCAMCORDER_MAX_INT},
1081 _mmcamcorder_commit_camera_af_touch_area,
1084 MM_CAM_CAMERA_AF_TOUCH_HEIGHT,
1085 "camera-af-touch-height",
1089 MM_ATTRS_VALID_TYPE_INT_RANGE,
1091 {.int_max = _MMCAMCORDER_MAX_INT},
1092 _mmcamcorder_commit_camera_af_touch_area,
1095 MM_CAM_CAMERA_FOCAL_LENGTH,
1096 "camera-focal-length",
1097 MM_ATTRS_TYPE_DOUBLE,
1099 {.value_double = 0.0},
1100 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1101 {.double_min = 0.0},
1102 {.double_max = 1000.0},
1103 _mmcamcorder_commit_camera_capture_mode,
1106 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
1107 "recommend-preview-format-for-capture",
1110 {(void*)MM_PIXEL_FORMAT_YUYV},
1111 MM_ATTRS_VALID_TYPE_INT_RANGE,
1112 {.int_min = MM_PIXEL_FORMAT_NV12},
1113 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1117 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
1118 "recommend-preview-format-for-recording",
1121 {(void*)MM_PIXEL_FORMAT_NV12},
1122 MM_ATTRS_VALID_TYPE_INT_RANGE,
1123 {.int_min = MM_PIXEL_FORMAT_NV12},
1124 {.int_max = (MM_PIXEL_FORMAT_NUM-1)},
1128 MM_CAM_TAG_GPS_ENABLE,
1133 MM_ATTRS_VALID_TYPE_INT_RANGE,
1136 _mmcamcorder_commit_tag,
1140 MM_CAM_TAG_GPS_TIME_STAMP,
1141 "tag-gps-time-stamp",
1142 MM_ATTRS_TYPE_DOUBLE,
1144 {.value_double = 0.0},
1145 MM_ATTRS_VALID_TYPE_NONE,
1148 _mmcamcorder_commit_tag,
1151 MM_CAM_TAG_GPS_DATE_STAMP,
1152 "tag-gps-date-stamp",
1153 MM_ATTRS_TYPE_STRING,
1156 MM_ATTRS_VALID_TYPE_NONE,
1159 _mmcamcorder_commit_tag,
1162 MM_CAM_TAG_GPS_PROCESSING_METHOD,
1163 "tag-gps-processing-method",
1164 MM_ATTRS_TYPE_STRING,
1167 MM_ATTRS_VALID_TYPE_NONE,
1170 _mmcamcorder_commit_tag,
1173 MM_CAM_CAMERA_ROTATION,
1177 {(void*)MM_VIDEO_INPUT_ROTATION_NONE},
1178 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1180 {ARRAY_SIZE(rotation_list)},
1181 _mmcamcorder_commit_camera_rotate,
1184 MM_CAM_CAPTURED_SCREENNAIL,
1185 "captured-screennail",
1189 MM_ATTRS_VALID_TYPE_NONE,
1195 MM_CAM_CAPTURE_SOUND_ENABLE,
1196 "capture-sound-enable",
1200 MM_ATTRS_VALID_TYPE_INT_RANGE,
1203 _mmcamcorder_commit_capture_sound_enable,
1206 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
1207 "recommend-display-rotation",
1210 {(void*)MM_DISPLAY_ROTATION_270},
1211 MM_ATTRS_VALID_TYPE_INT_RANGE,
1212 {.int_min = MM_DISPLAY_ROTATION_NONE},
1213 {.int_max = MM_DISPLAY_ROTATION_270},
1221 {(void*)MM_FLIP_NONE},
1222 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1224 {ARRAY_SIZE(flip_list)},
1225 _mmcamcorder_commit_camera_flip,
1228 MM_CAM_CAMERA_HDR_CAPTURE,
1229 "camera-hdr-capture",
1233 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1236 _mmcamcorder_commit_camera_hdr_capture,
1239 MM_CAM_DISPLAY_MODE,
1243 {(void*)MM_DISPLAY_MODE_DEFAULT},
1244 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1247 _mmcamcorder_commit_display_mode,
1251 MM_CAM_AUDIO_DISABLE,
1256 MM_ATTRS_VALID_TYPE_INT_RANGE,
1259 _mmcamcorder_commit_audio_disable,
1262 MM_CAM_RECOMMEND_CAMERA_WIDTH,
1263 "recommend-camera-width",
1266 {(void*)MMCAMCORDER_DEFAULT_CAMERA_WIDTH},
1267 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1273 MM_CAM_RECOMMEND_CAMERA_HEIGHT,
1274 "recommend-camera-height",
1277 {(void*)MMCAMCORDER_DEFAULT_CAMERA_HEIGHT},
1278 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1284 MM_CAM_CAPTURED_EXIF_RAW_DATA,
1285 "captured-exif-raw-data",
1289 MM_ATTRS_VALID_TYPE_NONE,
1295 MM_CAM_DISPLAY_EVAS_SURFACE_SINK,
1296 "display-evas-surface-sink",
1297 MM_ATTRS_TYPE_STRING,
1300 MM_ATTRS_VALID_TYPE_NONE,
1306 MM_CAM_DISPLAY_EVAS_DO_SCALING,
1307 "display-evas-do-scaling",
1311 MM_ATTRS_VALID_TYPE_INT_RANGE,
1314 _mmcamcorder_commit_display_evas_do_scaling,
1317 MM_CAM_CAMERA_FACING_DIRECTION,
1318 "camera-facing-direction",
1321 {(void*)MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1322 MM_ATTRS_VALID_TYPE_INT_RANGE,
1323 {.int_min = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR},
1324 {.int_max = MM_CAMCORDER_CAMERA_FACING_DIRECTION_FRONT},
1328 MM_CAM_DISPLAY_FLIP,
1332 {(void*)MM_FLIP_NONE},
1333 MM_ATTRS_VALID_TYPE_INT_RANGE,
1334 {.int_min = MM_FLIP_NONE},
1335 {.int_max = MM_FLIP_BOTH},
1336 _mmcamcorder_commit_display_flip,
1339 MM_CAM_CAMERA_VIDEO_STABILIZATION,
1340 "camera-video-stabilization",
1343 {(void*)MM_CAMCORDER_VIDEO_STABILIZATION_OFF},
1344 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1347 _mmcamcorder_commit_camera_video_stabilization,
1350 MM_CAM_TAG_VIDEO_ORIENTATION,
1351 "tag-video-orientation",
1354 {(void*)MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1355 MM_ATTRS_VALID_TYPE_INT_RANGE,
1356 {.int_min = MM_CAMCORDER_TAG_VIDEO_ORT_NONE},
1357 {.int_max = MM_CAMCORDER_TAG_VIDEO_ORT_270},
1362 MM_CAM_CAMERA_PAN_MECHA,
1367 MM_ATTRS_VALID_TYPE_INT_RANGE,
1370 _mmcamcorder_commit_camera_pan,
1373 MM_CAM_CAMERA_PAN_ELEC,
1378 MM_ATTRS_VALID_TYPE_INT_RANGE,
1381 _mmcamcorder_commit_camera_pan,
1384 MM_CAM_CAMERA_TILT_MECHA,
1385 "camera-tilt-mecha",
1389 MM_ATTRS_VALID_TYPE_INT_RANGE,
1392 _mmcamcorder_commit_camera_tilt,
1395 MM_CAM_CAMERA_TILT_ELEC,
1400 MM_ATTRS_VALID_TYPE_INT_RANGE,
1403 _mmcamcorder_commit_camera_tilt,
1406 MM_CAM_CAMERA_PTZ_TYPE,
1411 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1414 _mmcamcorder_commit_camera_ptz_type,
1422 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1425 _mmcamcorder_commit_video_size,
1428 MM_CAM_VIDEO_HEIGHT,
1433 MM_ATTRS_VALID_TYPE_INT_ARRAY,
1436 _mmcamcorder_commit_video_size,
1439 MM_CAM_SUPPORT_ZSL_CAPTURE,
1440 "support-zsl-capture",
1444 MM_ATTRS_VALID_TYPE_INT_RANGE,
1450 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
1451 "support-zero-copy-format",
1455 MM_ATTRS_VALID_TYPE_INT_RANGE,
1461 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB,
1462 "support-media-packet-preview-cb",
1466 MM_ATTRS_VALID_TYPE_INT_RANGE,
1473 MM_CAM_ENCODED_PREVIEW_BITRATE,
1474 "encoded-preview-bitrate",
1478 MM_ATTRS_VALID_TYPE_INT_RANGE,
1480 {.int_max = _MMCAMCORDER_MAX_INT},
1481 _mmcamcorder_commit_encoded_preview_bitrate,
1484 MM_CAM_ENCODED_PREVIEW_GOP_INTERVAL,
1485 "encoded-preview-gop-interval",
1488 {(void*)MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL},
1489 MM_ATTRS_VALID_TYPE_INT_RANGE,
1491 {.int_max = _MMCAMCORDER_MAX_INT},
1492 _mmcamcorder_commit_encoded_preview_gop_interval,
1495 MM_CAM_RECORDER_TAG_ENABLE,
1496 "recorder-tag-enable",
1500 MM_ATTRS_VALID_TYPE_INT_RANGE,
1506 MM_CAM_DISPLAY_SOCKET_PATH,
1507 "display-socket-path",
1508 MM_ATTRS_TYPE_STRING,
1511 MM_ATTRS_VALID_TYPE_NONE,
1522 MM_ATTRS_VALID_TYPE_INT_RANGE,
1524 {.int_max = _MMCAMCORDER_MAX_INT},
1528 MM_CAM_ROOT_DIRECTORY,
1530 MM_ATTRS_TYPE_STRING,
1533 MM_ATTRS_VALID_TYPE_NONE,
1539 MM_CAM_SOUND_STREAM_INDEX,
1540 "sound-stream-index",
1544 MM_ATTRS_VALID_TYPE_INT_RANGE,
1546 {.int_max = _MMCAMCORDER_MAX_INT},
1550 MM_CAM_SOUND_STREAM_TYPE,
1551 "sound-stream-type",
1552 MM_ATTRS_TYPE_STRING,
1555 MM_ATTRS_VALID_TYPE_NONE,
1558 _mmcamcorder_commit_sound_stream_info,
1561 MM_CAM_DISPLAY_REUSE_HINT,
1562 "display-reuse-hint",
1566 MM_ATTRS_VALID_TYPE_INT_RANGE,
1572 MM_CAM_DISPLAY_REUSE_ELEMENT,
1573 "display-reuse-element",
1577 MM_ATTRS_VALID_TYPE_NONE,
1583 MM_CAM_GDBUS_CONNECTION,
1588 MM_ATTRS_VALID_TYPE_NONE,
1594 MM_CAM_AUDIO_REPLAY_GAIN_ENABLE,
1595 "audio-replay-gain-enable",
1599 MM_ATTRS_VALID_TYPE_INT_RANGE,
1602 _mmcamcorder_commit_audio_replay_gain,
1605 MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL,
1606 "audio-replay-gain-reference-level",
1607 MM_ATTRS_TYPE_DOUBLE,
1609 {.value_double = MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL},
1610 MM_ATTRS_VALID_TYPE_DOUBLE_RANGE,
1611 {.double_min = 0.0},
1612 {.double_max = 150.0},
1613 _mmcamcorder_commit_audio_replay_gain,
1616 MM_CAM_SUPPORT_USER_BUFFER,
1617 "support-user-buffer",
1621 MM_ATTRS_VALID_TYPE_INT_RANGE,
1627 MM_CAM_USER_BUFFER_FD,
1632 MM_ATTRS_VALID_TYPE_NONE,
1638 MM_CAM_PLATFORM_PRIVILEGE_CAMERA,
1639 "platform-privilege-camera",
1640 MM_ATTRS_TYPE_STRING,
1643 MM_ATTRS_VALID_TYPE_NONE,
1649 MM_CAM_STROBE_BRIGHTNESS,
1650 "strobe-brightness",
1654 MM_ATTRS_VALID_TYPE_INT_RANGE,
1657 _mmcamcorder_commit_strobe,
1660 MM_CAM_VIDEOSRC_ELEMENT_NAME,
1661 "videosrc-element-name",
1662 MM_ATTRS_TYPE_STRING,
1665 MM_ATTRS_VALID_TYPE_NONE,
1671 MM_CAM_AUDIOSRC_ELEMENT_NAME,
1672 "audiosrc-element-name",
1673 MM_ATTRS_TYPE_STRING,
1676 MM_ATTRS_VALID_TYPE_NONE,
1682 MM_CAM_EXTRA_PREVIEW_ENABLE,
1683 "extra-preview-enable",
1687 MM_ATTRS_VALID_TYPE_INT_RANGE,
1690 _mmcamcorder_commit_extra_preview,
1693 MM_CAM_CAMERA_FOCUS_LEVEL,
1694 "camera-focus-level",
1698 MM_ATTRS_VALID_TYPE_INT_RANGE,
1701 _mmcamcorder_commit_camera_focus_level,
1704 MM_CAM_SUPPORT_EXTRA_PREVIEW,
1705 "support-extra-preview",
1709 MM_ATTRS_VALID_TYPE_INT_RANGE,
1715 MM_CAM_REQUEST_CODEC_CONFIG,
1716 "request-codec-config",
1720 MM_ATTRS_VALID_TYPE_INT_RANGE,
1723 _mmcamcorder_commit_request_codec_config,
1726 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_INTERNAL_CB,
1727 "support-media-packet-preview-internal-cb",
1731 MM_ATTRS_VALID_TYPE_INT_RANGE,
1737 MM_CAM_VIDEO_STREAM_CALLBACK_FLAG,
1738 "video-stream-callback-flag",
1741 {(void*)MM_CAMCORDER_VIDEO_STREAM_CALLBACK_FLAG_NONE},
1742 MM_ATTRS_VALID_TYPE_INT_RANGE,
1744 {.int_max = _MMCAMCORDER_MAX_INT},
1748 MM_CAM_FILTER_WB_TEMPERATURE,
1749 "filter-wb-temperature",
1753 MM_ATTRS_VALID_TYPE_INT_RANGE,
1756 _mmcamcorder_commit_filter,
1759 MM_CAM_FILTER_WB_TEMPERATURE_STEP,
1760 "filter-wb-temperature-step",
1764 MM_ATTRS_VALID_TYPE_INT_RANGE,
1766 {.int_max = _MMCAMCORDER_MAX_INT},
1775 MM_ATTRS_VALID_TYPE_INT_RANGE,
1778 _mmcamcorder_commit_camera_capture_mode,
1781 MM_CAM_CAMERA_GAIN_STEP,
1786 MM_ATTRS_VALID_TYPE_INT_RANGE,
1788 {.int_max = _MMCAMCORDER_MAX_INT},
1793 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1795 for (idx = 0 ; idx < attr_count ; idx++) {
1796 /* attribute order check. This should be same. */
1797 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1798 MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1799 free(attrs_const_info);
1800 attrs_const_info = NULL;
1801 free(hcamcorder->cam_attrs_const_info);
1802 hcamcorder->cam_attrs_const_info = NULL;
1806 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1807 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1808 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1809 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1812 /* Camcorder Attributes */
1813 MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1815 ret = mm_attrs_new(attrs_const_info,
1817 "Camcorder_Attributes",
1818 _mmcamcorder_commit_camcorder_attrs,
1822 free(attrs_const_info);
1823 attrs_const_info = NULL;
1825 if (ret != MM_ERROR_NONE) {
1826 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1827 free(hcamcorder->cam_attrs_const_info);
1828 hcamcorder->cam_attrs_const_info = NULL;
1832 __mmcamcorder_set_conf_to_valid_info(handle);
1834 for (idx = 0; idx < attr_count; idx++) {
1835 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1837 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1839 switch (attr_info->validity_type) {
1840 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1841 if (attr_info->validity_value_1.int_array &&
1842 attr_info->validity_value_2.count > 0) {
1843 mm_attrs_set_valid_array(attrs, idx,
1844 (const int *)(attr_info->validity_value_1.int_array),
1845 attr_info->validity_value_2.count,
1846 attr_info->default_value.value_int);
1849 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1850 mm_attrs_set_valid_range(attrs, idx,
1851 attr_info->validity_value_1.int_min,
1852 attr_info->validity_value_2.int_max,
1853 attr_info->default_value.value_int);
1855 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1856 if (attr_info->validity_value_1.double_array &&
1857 attr_info->validity_value_2.count > 0) {
1858 mm_attrs_set_valid_double_array(attrs, idx,
1859 (const double *)(attr_info->validity_value_1.double_array),
1860 attr_info->validity_value_2.count,
1861 attr_info->default_value.value_double);
1864 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1865 mm_attrs_set_valid_double_range(attrs, idx,
1866 attr_info->validity_value_1.double_min,
1867 attr_info->validity_value_2.double_max,
1868 attr_info->default_value.value_double);
1870 case MM_ATTRS_VALID_TYPE_NONE:
1872 case MM_ATTRS_VALID_TYPE_INVALID:
1874 MMCAM_LOG_ERROR("Valid type error.");
1879 __mmcamcorder_release_conf_valid_info(handle);
1886 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1888 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1890 if (hcamcorder == NULL) {
1891 MMCAM_LOG_ERROR("handle is NULL");
1898 mm_attrs_free(attrs);
1899 MMCAM_LOG_INFO("released attribute");
1902 if (hcamcorder->cam_attrs_const_info) {
1903 free(hcamcorder->cam_attrs_const_info);
1904 hcamcorder->cam_attrs_const_info = NULL;
1905 MMCAM_LOG_INFO("released attribute info");
1913 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1915 MMHandleType attrs = 0;
1916 int ret = MM_ERROR_NONE;
1918 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1919 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1921 attrs = MMF_CAMCORDER_ATTRS(handle);
1922 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1924 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1931 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1933 MMHandleType attrs = 0;
1934 int ret = MM_ERROR_NONE;
1936 char *tmp_err_attr_name = NULL;
1937 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1938 va_list var_args_copy;
1940 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1942 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1943 MMCAM_LOG_ERROR("Another command is running.");
1944 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1947 hcamcorder->error_code = MM_ERROR_NONE;
1949 /* copy var_args to keep original var_args */
1950 va_copy(var_args_copy, var_args);
1952 attrs = MMF_CAMCORDER_ATTRS(handle);
1954 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1956 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1957 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1960 if (ret == MM_ERROR_NONE) {
1961 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1962 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1965 va_end(var_args_copy);
1967 _MMCAMCORDER_UNLOCK_CMD(handle);
1969 if (ret != MM_ERROR_NONE) {
1970 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1971 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1972 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1973 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1974 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1975 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1979 if (hcamcorder->error_code != MM_ERROR_NONE) {
1980 MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1981 ret = hcamcorder->error_code;
1982 hcamcorder->error_code = MM_ERROR_NONE;
1985 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1988 if (tmp_err_attr_name) {
1989 if (!err_attr_name) {
1990 MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1991 free(tmp_err_attr_name);
1992 tmp_err_attr_name = NULL;
1994 *err_attr_name = tmp_err_attr_name;
2003 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
2005 MMHandleType attrs = 0;
2006 MMAttrsInfo attrinfo;
2007 int ret = MM_ERROR_NONE;
2009 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
2010 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
2011 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
2013 attrs = MMF_CAMCORDER_ATTRS(handle);
2014 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
2016 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
2018 if (ret == MM_ERROR_NONE) {
2019 memset(info, 0x00, sizeof(MMCamAttrsInfo));
2020 info->type = attrinfo.type;
2021 info->flag = attrinfo.flag;
2022 info->validity_type = attrinfo.validity_type;
2024 switch (attrinfo.validity_type) {
2025 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
2026 info->int_array.array = attrinfo.int_array.array;
2027 info->int_array.count = attrinfo.int_array.count;
2028 info->int_array.def = attrinfo.int_array.dval;
2030 case MM_ATTRS_VALID_TYPE_INT_RANGE:
2031 info->int_range.min = attrinfo.int_range.min;
2032 info->int_range.max = attrinfo.int_range.max;
2033 info->int_range.def = attrinfo.int_range.dval;
2035 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
2036 info->double_array.array = attrinfo.double_array.array;
2037 info->double_array.count = attrinfo.double_array.count;
2038 info->double_array.def = attrinfo.double_array.dval;
2040 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
2041 info->double_range.min = attrinfo.double_range.min;
2042 info->double_range.max = attrinfo.double_range.max;
2043 info->double_range.def = attrinfo.double_range.dval;
2045 case MM_ATTRS_VALID_TYPE_NONE:
2047 case MM_ATTRS_VALID_TYPE_INVALID:
2058 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
2061 mmf_camcorder_t *hcamcorder = NULL;
2063 mmf_return_val_if_fail(commit_param, FALSE);
2064 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
2065 mmf_return_val_if_fail(attr_name, FALSE);
2066 mmf_return_val_if_fail(value, FALSE);
2068 hcamcorder = MMF_CAMCORDER(commit_param);
2070 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
2071 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
2079 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
2082 int total_count = 0;
2084 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2086 if (hcamcorder == NULL) {
2087 MMCAM_LOG_ERROR("handle is NULL");
2088 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2092 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
2093 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
2094 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
2097 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
2098 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
2099 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
2102 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
2103 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
2104 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
2107 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
2108 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
2109 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
2111 return MM_ERROR_NONE;
2115 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
2117 int *allocated_memory = NULL;
2119 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2121 if (hcamcorder == NULL) {
2122 MMCAM_LOG_ERROR("handle is NULL");
2123 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2126 MMCAM_LOG_INFO("START");
2128 /* Audio encoder info */
2129 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2130 if (allocated_memory) {
2131 g_free(allocated_memory);
2132 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2133 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2136 /* Video encoder info */
2137 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2138 if (allocated_memory) {
2139 g_free(allocated_memory);
2140 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2141 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2144 /* Image encoder info */
2145 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2146 if (allocated_memory) {
2147 g_free(allocated_memory);
2148 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2149 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2152 /* File format info */
2153 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2154 if (allocated_memory) {
2155 g_free(allocated_memory);
2156 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2157 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2160 MMCAM_LOG_INFO("DONE");
2162 return MM_ERROR_NONE;
2166 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2168 MMHandleType attr = 0;
2169 int current_state = MM_CAMCORDER_STATE_NONE;
2171 mmf_return_val_if_fail(handle && value, FALSE);
2173 attr = MMF_CAMCORDER_ATTRS(handle);
2174 mmf_return_val_if_fail(attr, FALSE);
2176 /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2178 current_state = _mmcamcorder_get_state(handle);
2179 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2180 int flags = MM_ATTRS_FLAG_NONE;
2181 int capture_width, capture_height;
2182 MMCamAttrsInfo info;
2184 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2187 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2188 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2189 capture_width = value->value.i_val;
2191 /* Check whether they are valid pair */
2192 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2197 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2203 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2205 int current_state = MM_CAMCORDER_STATE_NONE;
2207 current_state = _mmcamcorder_get_state(handle);
2209 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2210 int capture_width, capture_height;
2212 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2213 capture_height = value->value.i_val;
2215 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2217 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2224 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2226 int current_state = 0;
2228 _MMCamcorderSubContext *sc = NULL;
2229 _MMCamcorderImageInfo *info = NULL;
2230 GstCameraControl *control = NULL;
2232 mmf_return_val_if_fail(handle && value, FALSE);
2234 current_state = _mmcamcorder_get_state(handle);
2235 ivalue = value->value.i_val;
2237 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2241 info = sc->info_image;
2243 MMCAM_LOG_ERROR("info image is NULL");
2247 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2248 if (info->capture_send_count > 0) {
2249 info->capturing = FALSE;
2250 MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2253 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2254 MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2258 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2260 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2261 MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2263 MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2266 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2273 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2275 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2276 int current_state = MM_CAMCORDER_STATE_NONE;
2277 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2279 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2281 current_state = _mmcamcorder_get_state(handle);
2282 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2284 MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2285 current_state, mode, value->value.i_val);
2287 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2288 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2291 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2297 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2299 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2301 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2303 MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2305 /* return error when disable shutter sound if policy is TRUE */
2306 if (!value->value.i_val &&
2307 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2308 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2311 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2317 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2319 int current_state = MM_CAMCORDER_STATE_NONE;
2320 _MMCamcorderSubContext *sc = NULL;
2323 mmf_return_val_if_fail(handle && value, FALSE);
2325 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2329 current_state = _mmcamcorder_get_state(handle);
2331 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2332 double mslNewVal = 0;
2333 mslNewVal = value->value.d_val;
2335 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2336 if (mslNewVal == 0.0) {
2337 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2338 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2340 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2341 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2345 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2348 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2356 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2358 int ret = MM_ERROR_NONE;
2359 int current_state = MM_CAMCORDER_STATE_NONE;
2360 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2362 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2364 current_state = _mmcamcorder_get_state(handle);
2365 if (current_state > MM_CAMCORDER_STATE_READY) {
2366 MMCAM_LOG_ERROR("invalid state %d", current_state);
2367 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2371 if (hcamcorder->is_configured && hcamcorder->mmcam_capability) {
2372 ret = _mmcamcorder_capability_update_capability_format(handle, value->value.i_val);
2373 if (ret != MM_ERROR_NONE) {
2374 MMCAM_LOG_ERROR("update capability format failed[0x%x]", ret);
2378 ret = _mmcamcorder_capability_update_preview_resolution_list(handle);
2379 if (ret != MM_ERROR_NONE) {
2380 MMCAM_LOG_ERROR("update resolution list failed[0x%x]", ret);
2385 MMCAM_LOG_INFO("done");
2391 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2393 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2394 MMCamAttrsInfo fps_info;
2395 int resolution_width = 0;
2396 int resolution_height = 0;
2399 int current_state = MM_CAMCORDER_STATE_NONE;
2401 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2403 current_state = _mmcamcorder_get_state(handle);
2404 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2405 MMCAM_LOG_ERROR("invalid state %d", current_state);
2406 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2410 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2413 MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2415 if (hcamcorder->on_preview_resolution_update) {
2416 MMCAM_LOG_INFO("no need to check FPS list");
2420 ret = mm_camcorder_get_attributes(handle, NULL,
2421 MMCAM_CAMERA_WIDTH, &resolution_width,
2422 MMCAM_CAMERA_HEIGHT, &resolution_height,
2425 if (ret != MM_ERROR_NONE) {
2426 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2430 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2431 if (ret != MM_ERROR_NONE) {
2432 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2436 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2437 if (value->value.i_val == fps_info.int_array.array[i])
2441 MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2447 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2449 int current_state = MM_CAMCORDER_STATE_NONE;
2450 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2451 _MMCamcorderSubContext *sc = NULL;
2453 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2455 current_state = _mmcamcorder_get_state(handle);
2456 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2457 MMCAM_LOG_WARNING("invalid state %d", current_state);
2458 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2462 /* Verify recording motion rate */
2463 if (value->value.d_val > 0.0) {
2464 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2468 /* set is_slow flag */
2469 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2470 sc->is_modified_rate = TRUE;
2472 sc->is_modified_rate = FALSE;
2474 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2477 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2483 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2485 MMHandleType attr = 0;
2486 int current_state = MM_CAMCORDER_STATE_NONE;
2488 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2489 _MMCamcorderSubContext *sc = NULL;
2491 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2493 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2497 attr = MMF_CAMCORDER_ATTRS(handle);
2498 mmf_return_val_if_fail(attr, FALSE);
2500 MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2502 current_state = _mmcamcorder_get_state(handle);
2504 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2505 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2508 int flags = MM_ATTRS_FLAG_NONE;
2509 MMCamAttrsInfo info;
2510 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2513 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2514 int width = value->value.i_val;
2516 int preview_format = MM_PIXEL_FORMAT_NV12;
2517 int codec_type = MM_IMAGE_CODEC_JPEG;
2519 mm_camcorder_get_attributes(handle, NULL,
2520 MMCAM_CAMERA_HEIGHT, &height,
2521 MMCAM_CAMERA_FORMAT, &preview_format,
2522 MMCAM_IMAGE_ENCODER, &codec_type,
2525 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2526 if (hcamcorder->resolution_changed == FALSE) {
2527 MMCAM_LOG_INFO("no need to restart preview");
2531 hcamcorder->resolution_changed = FALSE;
2533 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2534 MMCAM_LOG_INFO("restart preview");
2536 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2537 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2539 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2540 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2542 /* check decoder recreation */
2543 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2544 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2545 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2549 /* get preview format */
2550 sc->info_image->preview_format = preview_format;
2551 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2552 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2554 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2555 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2557 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2558 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2561 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2563 MMCAM_LOG_ERROR("currently locked for preview restart");
2567 /* get preview format */
2568 sc->info_image->preview_format = preview_format;
2569 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2570 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2581 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2584 int mm_ret = MM_ERROR_NONE;
2585 int current_state = MM_CAMCORDER_STATE_NONE;
2588 int preview_format = MM_PIXEL_FORMAT_NV12;
2589 int codec_type = MM_IMAGE_CODEC_JPEG;
2590 MMHandleType attr = 0;
2591 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2592 _MMCamcorderSubContext *sc = NULL;
2594 mmf_return_val_if_fail(hcamcorder && value, false);
2596 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2600 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2601 mmf_return_val_if_fail(attr, false);
2603 MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2604 current_state = _mmcamcorder_get_state(handle);
2606 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2607 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2608 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2612 height = value->value.i_val;
2614 mm_ret = mm_camcorder_get_attributes(handle, NULL,
2615 MMCAM_CAMERA_WIDTH, &width,
2616 MMCAM_CAMERA_FORMAT, &preview_format,
2617 MMCAM_IMAGE_ENCODER, &codec_type,
2619 if (mm_ret != MM_ERROR_NONE) {
2620 MMCAM_LOG_ERROR("attributes get failed[0x%x]", ret);
2624 sc->info_video->preview_width = width;
2625 sc->info_video->preview_height = height;
2627 /* update FPS from capability */
2628 if (hcamcorder->is_configured && hcamcorder->mmcam_capability) {
2629 mm_ret = _mmcamcorder_capability_update_capability_resolution(handle, width, height);
2630 if (mm_ret != MM_ERROR_NONE) {
2631 MMCAM_LOG_ERROR("update capability resolution failed[0x%x]", mm_ret);
2635 hcamcorder->on_preview_resolution_update = TRUE;
2636 mm_ret = _mmcamcorder_capability_update_preview_fps(hcamcorder);
2637 hcamcorder->on_preview_resolution_update = FALSE;
2639 if (mm_ret != MM_ERROR_NONE) {
2640 MMCAM_LOG_ERROR("update resolution list failed[0x%x]", mm_ret);
2645 if (current_state != MM_CAMCORDER_STATE_PREPARE) {
2646 sc->info_image->preview_format = preview_format;
2647 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2648 return _mmcamcorder_set_camera_resolution(handle, width, height);
2651 if (hcamcorder->resolution_changed == FALSE) {
2652 MMCAM_LOG_INFO("no need to restart preview");
2656 hcamcorder->resolution_changed = FALSE;
2658 if (!g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2659 MMCAM_LOG_ERROR("currently locked for preview restart");
2663 MMCAM_LOG_INFO("restart preview");
2665 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2666 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2668 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2669 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2671 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2672 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2673 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2677 sc->info_image->preview_format = preview_format;
2678 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2680 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2682 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2683 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2685 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2686 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2688 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2694 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2696 int current_state = MM_CAMCORDER_STATE_NONE;
2697 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2699 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2701 current_state = _mmcamcorder_get_state(handle);
2702 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2703 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2704 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2707 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2708 value->value.i_val, attr_idx);
2714 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2716 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2717 _MMCamcorderSubContext *sc = NULL;
2718 int current_state = MM_CAMCORDER_STATE_NONE;
2719 GstCameraControl *control = NULL;
2723 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2725 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2729 zoom_level = value->value.i_val;
2731 MMCAM_LOG_INFO("(%d)", attr_idx);
2733 current_state = _mmcamcorder_get_state(handle);
2734 if (current_state < MM_CAMCORDER_STATE_READY) {
2735 MMCAM_LOG_INFO("will be applied when preview starts");
2737 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2738 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2739 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2743 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2744 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2746 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2748 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2751 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2752 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2756 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2757 if (control == NULL) {
2758 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2762 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2764 MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2767 MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2770 MMCAM_LOG_INFO("pointer of video src is null");
2777 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2779 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2780 _MMCamcorderSubContext *sc = NULL;
2781 int current_state = MM_CAMCORDER_STATE_NONE;
2783 GstCameraControl *CameraControl = NULL;
2784 GstCameraControlChannel *CameraControlChannel = NULL;
2785 const GList *controls = NULL;
2786 const GList *item = NULL;
2788 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2790 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2791 mmf_return_val_if_fail(sc, TRUE);
2793 MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2795 current_state = _mmcamcorder_get_state(handle);
2796 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2797 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2798 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2799 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2803 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2804 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2805 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2809 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2810 if (CameraControl == NULL) {
2811 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2815 controls = gst_camera_control_list_channels(CameraControl);
2816 if (controls == NULL) {
2817 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2821 for (item = controls ; item && item->data ; item = item->next) {
2822 CameraControlChannel = item->data;
2823 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2824 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2825 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2826 MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2829 MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2835 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2842 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2844 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2845 _MMCamcorderSubContext *sc = NULL;
2846 int current_state = MM_CAMCORDER_STATE_NONE;
2848 GstCameraControl *CameraControl = NULL;
2849 GstCameraControlChannel *CameraControlChannel = NULL;
2850 const GList *controls = NULL;
2851 const GList *item = NULL;
2853 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2855 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2856 mmf_return_val_if_fail(sc, TRUE);
2858 MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2860 current_state = _mmcamcorder_get_state(handle);
2861 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2862 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2863 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2864 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2868 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2869 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2870 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2874 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2875 if (CameraControl == NULL) {
2876 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2880 controls = gst_camera_control_list_channels(CameraControl);
2881 if (controls == NULL) {
2882 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2886 for (item = controls ; item && item->data ; item = item->next) {
2887 CameraControlChannel = item->data;
2888 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2889 if (!strcmp(CameraControlChannel->label, "pan")) {
2890 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2891 MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2894 MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2900 MMCAM_LOG_WARNING("failed to find pan control channel");
2907 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2909 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2910 _MMCamcorderSubContext *sc = NULL;
2911 int current_state = MM_CAMCORDER_STATE_NONE;
2913 GstCameraControl *CameraControl = NULL;
2914 GstCameraControlChannel *CameraControlChannel = NULL;
2915 const GList *controls = NULL;
2916 const GList *item = NULL;
2918 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2920 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2921 mmf_return_val_if_fail(sc, TRUE);
2923 MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2925 current_state = _mmcamcorder_get_state(handle);
2926 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2927 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2928 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2929 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2933 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2934 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2935 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2939 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2940 if (CameraControl == NULL) {
2941 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2945 controls = gst_camera_control_list_channels(CameraControl);
2946 if (controls == NULL) {
2947 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2951 for (item = controls ; item && item->data ; item = item->next) {
2952 CameraControlChannel = item->data;
2953 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2954 if (!strcmp(CameraControlChannel->label, "tilt")) {
2955 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2956 MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2959 MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2965 MMCAM_LOG_WARNING("failed to find tilt control channel");
2972 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2974 MMHandleType attr = 0;
2975 int current_state = MM_CAMCORDER_STATE_NONE;
2976 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2977 _MMCamcorderSubContext *sc = NULL;
2978 GstCameraControl *control = NULL;
2980 int set_focus_mode = 0;
2981 int cur_focus_mode = 0;
2982 int cur_focus_range = 0;
2984 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2986 attr = MMF_CAMCORDER_ATTRS(handle);
2987 mmf_return_val_if_fail(attr, FALSE);
2989 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2993 MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2995 /* check whether set or not */
2996 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2997 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3001 current_state = _mmcamcorder_get_state(handle);
3002 if (current_state < MM_CAMCORDER_STATE_NULL) {
3003 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
3005 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3006 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3007 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3011 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3012 int flags = MM_ATTRS_FLAG_NONE;
3013 MMCamAttrsInfo info;
3015 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3016 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3020 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3021 if (control == NULL) {
3022 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3026 mslVal = value->value.i_val;
3027 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3029 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
3032 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
3033 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
3034 if (set_focus_mode != cur_focus_mode) {
3035 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
3036 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
3039 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
3042 MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
3046 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
3050 MMCAM_LOG_INFO("pointer of video src is null");
3057 bool _mmcamcorder_commit_camera_focus_level(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3059 int current_state = MM_CAMCORDER_STATE_NONE;
3060 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3061 _MMCamcorderSubContext *sc = NULL;
3062 GstCameraControl *control = NULL;
3064 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3066 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3070 MMCAM_LOG_INFO("Focus level[%d]", value->value.i_val);
3072 current_state = _mmcamcorder_get_state(handle);
3073 if (current_state < MM_CAMCORDER_STATE_READY) {
3074 MMCAM_LOG_INFO("Focus level will be set later.(state=%d)", current_state);
3076 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3077 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3078 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3082 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3083 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
3087 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3088 if (control == NULL) {
3089 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3093 if (!gst_camera_control_set_focus_level(control, value->value.i_val)) {
3094 MMCAM_LOG_ERROR("set focus level[%d[ failed", value->value.i_val);
3102 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3104 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3105 _MMCamcorderSubContext *sc = NULL;
3106 GstCameraControl *control = NULL;
3107 int current_state = MM_CAMCORDER_STATE_NONE;
3110 int cur_focus_mode = 0;
3111 int cur_focus_range = 0;
3112 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3113 int converted_mode = 0;
3115 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3117 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3121 MMCAM_LOG_INFO("(%d)", attr_idx);
3123 /* check whether set or not */
3124 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3125 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3129 mslVal = value->value.i_val;
3130 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3132 current_state = _mmcamcorder_get_state(handle);
3133 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3134 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3136 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3137 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3138 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3142 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3143 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3144 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3148 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3149 if (control == NULL) {
3150 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3154 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
3155 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
3157 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
3158 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
3159 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
3160 /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
3163 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
3166 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
3170 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
3173 MMCAM_LOG_INFO("pointer of video src is null");
3180 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3182 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3183 _MMCamcorderSubContext *sc = NULL;
3184 GstCameraControl *control = NULL;
3185 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
3186 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
3188 int current_state = MM_CAMCORDER_STATE_NONE;
3190 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3192 gboolean do_set = FALSE;
3194 MMCamAttrsInfo info_y;
3195 MMCamAttrsInfo info_w;
3196 MMCamAttrsInfo info_h;
3198 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3200 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3204 MMCAM_LOG_INFO("(%d)", attr_idx);
3206 current_state = _mmcamcorder_get_state(handle);
3207 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3208 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3210 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3211 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3212 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3216 ret = mm_camcorder_get_attributes(handle, NULL,
3217 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3219 if (ret != MM_ERROR_NONE) {
3220 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3224 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3225 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3229 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3230 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3231 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3235 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3236 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3237 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3240 case MM_CAM_CAMERA_AF_TOUCH_X:
3241 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3242 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3243 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3244 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3245 set_area.x = value->value.i_val;
3246 mm_camcorder_get_attributes(handle, NULL,
3247 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3248 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3249 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3253 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3257 case MM_CAM_CAMERA_AF_TOUCH_Y:
3258 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3259 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3260 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3261 set_area.y = value->value.i_val;
3262 mm_camcorder_get_attributes(handle, NULL,
3263 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3264 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3265 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3269 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3273 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3274 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3275 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3276 set_area.width = value->value.i_val;
3277 mm_camcorder_get_attributes(handle, NULL,
3278 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3279 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3280 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3284 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3288 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3289 set_area.height = value->value.i_val;
3290 mm_camcorder_get_attributes(handle, NULL,
3291 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3292 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3293 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3302 _MMCamcorderVideoInfo *info = sc->info_video;
3305 MMCAM_LOG_ERROR("video info is NULL");
3309 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3310 if (control == NULL) {
3311 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3316 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3317 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3318 float ratio_width = 0.0;
3319 float ratio_height = 0.0;
3321 if (info->preview_width != 0 && info->preview_height != 0) {
3322 ratio_width = (float)info->video_width / (float)info->preview_width;
3323 ratio_height = (float)info->video_height / (float)info->preview_height;
3325 MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3326 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3328 set_area.x = (int)((float)set_area.x * ratio_width);
3329 set_area.y = (int)((float)set_area.y * ratio_height);
3330 set_area.width = (int)((float)set_area.width * ratio_width);
3331 set_area.height = (int)((float)set_area.height * ratio_height);
3333 if (set_area.width <= 0)
3336 if (set_area.height <= 0)
3337 set_area.height = 1;
3339 MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3340 set_area.x, set_area.y, set_area.width, set_area.height);
3342 MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3343 info->preview_width, info->preview_height);
3347 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3349 MMCAM_LOG_WARNING("Failed to get AF area");
3353 /* width and height are not supported now */
3354 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3355 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3356 get_area.x, get_area.y);
3360 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3362 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3363 set_area.x, set_area.y, set_area.width, set_area.height);
3366 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3367 set_area.x, set_area.y, set_area.width, set_area.height);
3371 MMCAM_LOG_INFO("pointer of video src is null");
3378 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3380 GstCameraControl *control = NULL;
3386 int exposure_type = 0;
3387 int current_state = MM_CAMCORDER_STATE_NONE;
3388 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3389 _MMCamcorderSubContext *sc = NULL;
3391 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3392 gboolean check_scene_mode = FALSE;
3394 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3396 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3400 /* check whether set or not */
3401 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3402 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3406 current_state = _mmcamcorder_get_state(handle);
3407 if (current_state < MM_CAMCORDER_STATE_READY) {
3408 MMCAM_LOG_INFO("will be applied when preview starts");
3410 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3411 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3412 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3416 ivalue = value->value.i_val;
3419 case MM_CAM_CAMERA_F_NUMBER:
3420 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3421 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3422 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3424 case MM_CAM_CAMERA_SHUTTER_SPEED:
3425 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3426 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3427 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3429 case MM_CAM_CAMERA_ISO:
3430 exposure_type = GST_CAMERA_CONTROL_ISO;
3432 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3433 check_scene_mode = TRUE;
3435 case MM_CAM_CAMERA_EXPOSURE_MODE:
3436 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3438 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3439 check_scene_mode = TRUE;
3441 case MM_CAM_CAMERA_EXPOSURE_VALUE:
3442 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3443 mslVal1 = newVal1 = ivalue;
3445 case MM_CAM_CAMERA_GAIN:
3446 exposure_type = GST_CAMERA_CONTROL_GAIN;
3447 mslVal1 = newVal1 = ivalue;
3450 MMCAM_LOG_ERROR("unknown attr idx[%d]", attr_idx);
3454 if (check_scene_mode) {
3455 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3456 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3457 MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3462 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3465 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3466 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3470 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3471 if (control == NULL) {
3472 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3476 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3478 MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3481 MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3484 MMCAM_LOG_INFO("pointer of video src is null");
3491 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3493 GstCameraControl *control = NULL;
3497 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3498 _MMCamcorderSubContext *sc = NULL;
3499 int current_state = MM_CAMCORDER_STATE_NONE;
3501 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3503 /* check whether set or not */
3504 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3505 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3509 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3513 /* check current state */
3514 current_state = _mmcamcorder_get_state(handle);
3515 if (current_state < MM_CAMCORDER_STATE_READY) {
3516 MMCAM_LOG_INFO("will be applied when preview starts");
3518 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3519 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3520 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3524 mslVal = value->value.i_val;
3525 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3527 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3528 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3529 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3533 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3534 if (control == NULL) {
3535 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3539 if (gst_camera_control_get_wdr(control, &cur_value)) {
3540 if (newVal != cur_value) {
3541 if (gst_camera_control_set_wdr(control, newVal)) {
3542 MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3545 MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3548 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3552 MMCAM_LOG_WARNING("Failed to get WDR.");
3555 MMCAM_LOG_INFO("pointer of video src is null");
3562 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3564 int current_state = MM_CAMCORDER_STATE_NONE;
3565 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3567 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3569 /* check whether set or not */
3570 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3571 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3575 current_state = _mmcamcorder_get_state(handle);
3576 if (current_state < MM_CAMCORDER_STATE_READY) {
3577 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3579 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3580 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3581 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3585 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3589 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3593 int current_state = MM_CAMCORDER_STATE_NONE;
3594 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3595 _MMCamcorderSubContext *sc = NULL;
3597 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3599 bitrate = value->value.i_val;
3601 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3602 if (!sc || !sc->encode_element) {
3603 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3607 current_state = _mmcamcorder_get_state(handle);
3608 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3609 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3610 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3614 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3615 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3617 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3618 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3620 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3621 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3628 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3630 int current_state = MM_CAMCORDER_STATE_NONE;
3631 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3633 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3635 current_state = _mmcamcorder_get_state(handle);
3636 if (current_state < MM_CAMCORDER_STATE_READY) {
3637 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3639 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3640 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3641 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3645 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3649 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3651 int current_state = MM_CAMCORDER_STATE_NONE;
3652 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3654 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3656 MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3658 current_state = _mmcamcorder_get_state(handle);
3660 if (current_state > MM_CAMCORDER_STATE_READY) {
3661 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3662 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3665 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3670 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3672 int current_state = MM_CAMCORDER_STATE_NONE;
3674 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3675 _MMCamcorderSubContext *sc = NULL;
3677 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3680 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3681 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3685 /* check current state */
3686 current_state = _mmcamcorder_get_state(handle);
3687 if (current_state < MM_CAMCORDER_STATE_READY) {
3688 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3690 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3691 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3692 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3696 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3698 MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3700 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3701 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3704 MMCAM_LOG_ERROR("invalid state %d", current_state);
3710 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3712 mmf_return_val_if_fail(handle && value, FALSE);
3715 if (!value->value.s_val) {
3716 MMCAM_LOG_ERROR("NULL filename");
3720 MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3726 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3728 int current_state = MM_CAMCORDER_STATE_NONE;
3729 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3731 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3733 current_state = _mmcamcorder_get_state(handle);
3734 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3735 MMCAM_LOG_ERROR("Can not set while RECORDING");
3736 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3744 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3746 GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3747 MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3748 return strcmp(Colorchannel->label, user_data);
3751 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3753 GstColorBalance *balance = NULL;
3754 GstColorBalanceChannel *Colorchannel = NULL;
3755 GList *controls = NULL;
3759 int current_state = MM_CAMCORDER_STATE_NONE;
3760 const char *control_label = NULL;
3761 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3762 _MMCamcorderSubContext *sc = NULL;
3764 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3765 gboolean check_scene_mode = FALSE;
3767 int wb_temp_table[] = {
3768 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3769 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3770 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3771 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3772 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3773 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3776 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3778 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3782 /* check whether set or not */
3783 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3784 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3788 current_state = _mmcamcorder_get_state(handle);
3789 if (current_state < MM_CAMCORDER_STATE_READY) {
3790 MMCAM_LOG_INFO("will be applied when preview starts");
3792 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3793 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3794 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3798 if (value->type != MM_ATTRS_TYPE_INT) {
3799 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3803 mslVal = value->value.i_val;
3806 case MM_CAM_FILTER_BRIGHTNESS:
3807 control_label = "brightness";
3808 check_scene_mode = TRUE;
3810 case MM_CAM_FILTER_CONTRAST:
3811 control_label = "contrast";
3813 case MM_CAM_FILTER_WB:
3814 control_label = "white balance";
3815 check_scene_mode = TRUE;
3817 case MM_CAM_FILTER_WB_TEMPERATURE:
3818 control_label = "white balance temperature";
3819 check_scene_mode = TRUE;
3821 case MM_CAM_FILTER_COLOR_TONE:
3822 control_label = "color tone";
3824 case MM_CAM_FILTER_SATURATION:
3825 control_label = "saturation";
3826 check_scene_mode = TRUE;
3828 case MM_CAM_FILTER_HUE:
3829 control_label = "hue";
3831 case MM_CAM_FILTER_SHARPNESS:
3832 control_label = "sharpness";
3833 check_scene_mode = TRUE;
3836 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3840 if (check_scene_mode) {
3841 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3842 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3843 MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3848 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3849 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3852 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3853 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3857 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3858 if (balance == NULL) {
3859 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3863 controls = (GList *)gst_color_balance_list_channels(balance);
3864 if (controls == NULL) {
3865 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3870 MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3871 attr_idx, control_label, mslVal, newVal);
3873 item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3875 Colorchannel = item->data;
3876 gst_color_balance_set_value(balance, Colorchannel, newVal);
3877 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3881 if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3882 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3884 control_label = "white_balance_temperature_auto";
3887 newVal = wb_temp_table[mslVal];
3888 control_label = "white_balance_temperature";
3893 MMCAM_LOG_ERROR("failed to find color channel item");
3899 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3903 int current_state = MM_CAMCORDER_STATE_NONE;
3904 GstCameraControl *control = NULL;
3905 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3906 _MMCamcorderSubContext *sc = NULL;
3908 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3910 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3914 mslVal = value->value.i_val;
3915 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3917 /* check whether set or not */
3918 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3919 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3923 current_state = _mmcamcorder_get_state(handle);
3924 if (current_state < MM_CAMCORDER_STATE_READY) {
3925 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3927 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3928 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3929 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3933 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3936 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3937 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3941 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3942 if (control == NULL) {
3943 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3947 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3949 MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3951 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3955 MM_CAM_FILTER_BRIGHTNESS,
3957 MM_CAM_FILTER_SATURATION,
3958 MM_CAM_FILTER_SHARPNESS,
3959 MM_CAM_FILTER_COLOR_TONE,
3960 MM_CAM_CAMERA_EXPOSURE_MODE
3962 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3964 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3965 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3966 mm_attrs_set_modified(attrs, attr_idxs[i]);
3972 MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3975 MMCAM_LOG_WARNING("pointer of video src is null");
3982 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3984 mmf_return_val_if_fail(handle && value, FALSE);
3986 MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3992 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3994 mmf_return_val_if_fail(handle && value, FALSE);
3996 MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
4002 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4004 int current_state = MM_CAMCORDER_STATE_NONE;
4005 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4007 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4009 current_state = _mmcamcorder_get_state(handle);
4010 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4011 MMCAM_LOG_WARNING("Can NOT set disable[%d] AUDIO. invalid state %d",
4012 value->value.i_val, current_state);
4013 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4016 MMCAM_LOG_INFO("Set disable[%d] AUDIO when Recording", value->value.i_val);
4022 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4024 int current_state = MM_CAMCORDER_STATE_NONE;
4025 const char *videosink_name = NULL;
4026 void *dp_handle = NULL;
4027 MMCamWindowInfo *window_info = NULL;
4029 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4030 _MMCamcorderSubContext *sc = NULL;
4032 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4035 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4036 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4040 /* check current state */
4041 current_state = _mmcamcorder_get_state(handle);
4042 if (current_state < MM_CAMCORDER_STATE_READY) {
4043 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4047 dp_handle = value->value.p_val;
4049 MMCAM_LOG_WARNING("Display handle is NULL");
4053 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4055 /* get videosink name */
4056 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4057 if (!videosink_name) {
4058 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4062 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
4064 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
4065 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
4066 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
4067 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
4068 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
4069 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
4070 } else if (!strcmp(videosink_name, "tizenwlsink")) {
4071 window_info = (MMCamWindowInfo *)dp_handle;
4072 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
4073 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
4074 } else if (!strcmp(videosink_name, "directvideosink")) {
4075 window_info = (MMCamWindowInfo *)dp_handle;
4076 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
4077 window_info->surface_id,
4078 window_info->rect.x,
4079 window_info->rect.y,
4080 window_info->rect.width,
4081 window_info->rect.height);
4082 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
4083 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4084 window_info->rect.x,
4085 window_info->rect.y,
4086 window_info->rect.width,
4087 window_info->rect.height);
4089 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
4097 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4099 int current_state = MM_CAMCORDER_STATE_NONE;
4100 const char *videosink_name = NULL;
4102 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4103 _MMCamcorderSubContext *sc = NULL;
4105 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4108 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4109 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4113 /* check current state */
4114 current_state = _mmcamcorder_get_state(handle);
4115 if (current_state < MM_CAMCORDER_STATE_READY) {
4116 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4120 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4122 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4123 if (videosink_name == NULL) {
4124 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4128 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
4130 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4131 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
4132 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
4134 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
4141 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4143 int current_state = MM_CAMCORDER_STATE_NONE;
4145 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4147 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4150 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4151 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4155 /* check current state */
4156 current_state = _mmcamcorder_get_state(handle);
4157 if (current_state < MM_CAMCORDER_STATE_READY) {
4158 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
4162 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4166 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4168 int current_state = MM_CAMCORDER_STATE_NONE;
4170 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4172 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4175 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4176 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4180 /* check current state */
4181 current_state = _mmcamcorder_get_state(handle);
4182 if (current_state < MM_CAMCORDER_STATE_READY) {
4183 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
4187 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4191 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4193 int current_state = MM_CAMCORDER_STATE_NONE;
4194 const char *videosink_name = NULL;
4196 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4197 _MMCamcorderSubContext *sc = NULL;
4199 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4202 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4203 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4207 /* check current state */
4208 current_state = _mmcamcorder_get_state(handle);
4209 if (current_state < MM_CAMCORDER_STATE_READY) {
4210 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4214 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4216 /* Get videosink name */
4217 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4218 if (videosink_name == NULL) {
4219 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4223 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4224 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4225 !strcmp(videosink_name, "directvideosink")) {
4226 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4227 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4229 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4236 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4239 int current_state = MM_CAMCORDER_STATE_NONE;
4240 const char *videosink_name = NULL;
4242 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4243 _MMCamcorderSubContext *sc = NULL;
4245 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4248 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4249 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4253 /* check current state */
4254 current_state = _mmcamcorder_get_state(handle);
4255 if (current_state < MM_CAMCORDER_STATE_READY) {
4256 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4260 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4262 /* Get videosink name */
4263 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4264 if (videosink_name == NULL) {
4265 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4269 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4270 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4271 !strcmp(videosink_name, "directvideosink")) {
4272 method = value->value.i_val;
4273 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4275 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4282 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4284 int current_state = MM_CAMCORDER_STATE_NONE;
4285 int ret = MM_ERROR_NONE;
4286 const char *videosink_name = NULL;
4288 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4289 _MMCamcorderSubContext *sc = NULL;
4291 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4294 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4295 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4299 /* check current state */
4300 current_state = _mmcamcorder_get_state(handle);
4301 if (current_state < MM_CAMCORDER_STATE_READY) {
4302 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4306 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4308 /* Get videosink name */
4309 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4310 if (videosink_name == NULL) {
4311 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4315 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4316 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4320 int rect_height = 0;
4321 int flags = MM_ATTRS_FLAG_NONE;
4322 MMCamAttrsInfo info;
4324 mm_camcorder_get_attributes(handle, NULL,
4325 MMCAM_DISPLAY_RECT_X, &rect_x,
4326 MMCAM_DISPLAY_RECT_Y, &rect_y,
4327 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4328 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4331 case MM_CAM_DISPLAY_RECT_X:
4332 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4334 memset(&info, 0x00, sizeof(info));
4335 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4337 memset(&info, 0x00, sizeof(info));
4338 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4341 rect_x = value->value.i_val;
4343 case MM_CAM_DISPLAY_RECT_Y:
4344 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4346 memset(&info, 0x00, sizeof(info));
4347 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4350 rect_y = value->value.i_val;
4352 case MM_CAM_DISPLAY_RECT_WIDTH:
4353 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4356 rect_width = value->value.i_val;
4358 case MM_CAM_DISPLAY_RECT_HEIGHT:
4359 rect_height = value->value.i_val;
4362 MMCAM_LOG_ERROR("Wrong attr_idx!");
4366 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4367 MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4369 if (!strcmp(videosink_name, "tizenwlsink")) {
4370 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4371 rect_x, rect_y, rect_width, rect_height);
4373 MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4377 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4378 "dst-roi-x", rect_x,
4379 "dst-roi-y", rect_y,
4380 "dst-roi-w", rect_width,
4381 "dst-roi-h", rect_height,
4386 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4393 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4396 int current_state = MM_CAMCORDER_STATE_NONE;
4397 const char *videosink_name = NULL;
4398 GstElement *vs_element = NULL;
4400 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4401 _MMCamcorderSubContext *sc = NULL;
4403 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4406 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4407 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4411 /* check current state */
4412 current_state = _mmcamcorder_get_state(handle);
4413 if (current_state < MM_CAMCORDER_STATE_READY) {
4414 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4418 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4420 /* Get videosink name */
4421 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4422 if (videosink_name == NULL) {
4423 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4427 zoom = value->value.i_val;
4428 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4429 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4431 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4432 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4436 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4442 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4444 int current_state = MM_CAMCORDER_STATE_NONE;
4446 const char *videosink_name = NULL;
4448 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4449 _MMCamcorderSubContext *sc = NULL;
4451 mmf_return_val_if_fail(handle && value, FALSE);
4454 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4455 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4459 /* check current state */
4460 current_state = _mmcamcorder_get_state(handle);
4461 if (current_state < MM_CAMCORDER_STATE_READY) {
4462 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4466 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4468 do_scaling = value->value.i_val;
4470 /* Get videosink name */
4471 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4472 if (videosink_name == NULL) {
4473 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4477 if (!strcmp(videosink_name, "evaspixmapsink")) {
4478 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4479 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4482 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4488 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4490 _MMCamcorderSubContext *sc = NULL;
4491 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4492 int strobe_type, mslVal, newVal, cur_value;
4493 int current_state = MM_CAMCORDER_STATE_NONE;
4495 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4497 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4501 /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4503 mslVal = value->value.i_val;
4505 /* check flash state */
4506 if (attr_idx == MM_CAM_STROBE_MODE) {
4507 int led_brightness = 0;
4509 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4510 MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4511 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4515 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4517 if (led_brightness > 0 &&
4518 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4519 /* other module already turned on LED */
4520 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4521 MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4525 MMCAM_LOG_INFO("keep going");
4529 current_state = _mmcamcorder_get_state(handle);
4530 if (current_state < MM_CAMCORDER_STATE_READY) {
4531 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4533 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4534 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4535 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4540 case MM_CAM_STROBE_CONTROL:
4541 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4542 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4544 case MM_CAM_STROBE_CAPABILITIES:
4545 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4548 case MM_CAM_STROBE_MODE:
4549 /* check whether set or not */
4550 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4551 MMCAM_LOG_INFO("skip set value %d", mslVal);
4555 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4556 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4558 case MM_CAM_STROBE_BRIGHTNESS:
4559 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4563 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4567 GstCameraControl *control = NULL;
4568 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4569 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4573 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4574 if (control == NULL) {
4575 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4579 if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4580 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4584 if (newVal == cur_value) {
4585 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4589 if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4590 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4594 MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4600 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4603 int current_state = MM_CAMCORDER_STATE_NONE;
4604 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4606 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4608 MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4611 current_state = _mmcamcorder_get_state(handle);
4612 if (current_state > MM_CAMCORDER_STATE_READY) {
4613 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4614 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4616 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4617 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4621 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4623 MMCAM_LOG_INFO("ret %d", ret);
4629 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4631 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4632 int current_state = MM_CAMCORDER_STATE_NONE;
4633 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4634 _MMCamcorderSubContext *sc = NULL;
4636 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4638 /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4640 /* check whether set or not */
4641 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4642 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4647 current_state = _mmcamcorder_get_state(handle);
4648 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4649 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4650 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4654 if (current_state >= MM_CAMCORDER_STATE_READY) {
4655 int current_value = 0;
4657 set_hdr_mode = value->value.i_val;
4658 mm_camcorder_get_attributes(handle, NULL,
4659 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4662 if (set_hdr_mode == current_value) {
4663 MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4667 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4669 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4670 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4671 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4673 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4675 /* check decoder recreation */
4676 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4677 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4681 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4682 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4685 set_hdr_mode = value->value.i_val;
4686 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4687 sc->info_image->hdr_capture_mode = set_hdr_mode;
4688 MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4690 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4691 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4693 MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4702 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4705 _MMCamcorderSubContext *sc = NULL;
4706 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4708 int current_value = 0;
4709 int current_state = MM_CAMCORDER_STATE_NONE;
4710 GstCameraControl *control = NULL;
4712 mmf_return_val_if_fail(handle && value, FALSE);
4714 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4718 /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4721 current_state = _mmcamcorder_get_state(handle);
4722 if (current_state < MM_CAMCORDER_STATE_READY) {
4723 MMCAM_LOG_INFO("will be applied when preview starts");
4727 set_value = value->value.i_val;
4730 case MM_CAM_DETECT_MODE:
4731 /* check whether set or not */
4732 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4733 MMCAM_LOG_INFO("skip set value %d", set_value);
4737 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4739 case MM_CAM_DETECT_NUMBER:
4740 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4742 case MM_CAM_DETECT_FOCUS_SELECT:
4743 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4745 case MM_CAM_DETECT_SELECT_NUMBER:
4746 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4748 case MM_CAM_DETECT_STATUS:
4749 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4752 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4756 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4757 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4760 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4761 if (control == NULL) {
4762 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4766 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4767 if (current_value == set_value) {
4768 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4771 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4772 MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4773 detect_type, set_value);
4776 MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4777 detect_type, set_value);
4782 MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4791 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4793 int current_state = MM_CAMCORDER_STATE_NONE;
4795 mmf_return_val_if_fail(handle && value, FALSE);
4797 MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4800 current_state = _mmcamcorder_get_state(handle);
4801 if (current_state < MM_CAMCORDER_STATE_READY) {
4802 MMCAM_LOG_INFO("will be applied when preview starts");
4806 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4810 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4812 int current_state = MM_CAMCORDER_STATE_NONE;
4813 int preview_format = MM_PIXEL_FORMAT_NV12;
4815 mmf_return_val_if_fail(handle && value, FALSE);
4817 MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4819 /* check preview format */
4820 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4821 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
4822 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4827 current_state = _mmcamcorder_get_state(handle);
4828 if (current_state < MM_CAMCORDER_STATE_READY) {
4829 MMCAM_LOG_INFO("will be applied when preview starts");
4833 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4837 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4839 int stream_index = 0;
4840 char *stream_type = NULL;
4841 _MMCamcorderSubContext *sc = NULL;
4843 mmf_return_val_if_fail(handle && value, FALSE);
4845 stream_type = value->value.s_val;
4847 MMCAM_LOG_ERROR("NULL string");
4851 mm_camcorder_get_attributes(handle, NULL,
4852 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4854 if (stream_index < 0) {
4855 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4859 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4860 if (!sc || !sc->encode_element ||
4861 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4862 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4866 MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4868 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4872 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4874 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4875 int current_state = MM_CAMCORDER_STATE_NONE;
4877 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4879 current_state = _mmcamcorder_get_state(handle);
4880 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4881 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4882 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4889 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4891 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4893 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4895 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4896 /* Replay gain enable */
4897 int current_state = MM_CAMCORDER_STATE_NONE;
4898 int audio_disable = FALSE;
4900 current_state = _mmcamcorder_get_state(handle);
4901 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4902 MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4903 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4907 mm_camcorder_get_attributes(handle, NULL,
4908 MMCAM_AUDIO_DISABLE, &audio_disable,
4911 if (audio_disable) {
4912 MMCAM_LOG_ERROR("audio is disabled");
4913 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4917 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4918 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4919 /* Replay gain reference level */
4920 int replay_gain_enable = FALSE;
4922 mm_camcorder_get_attributes(handle, NULL,
4923 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4926 if (replay_gain_enable == FALSE) {
4927 MMCAM_LOG_ERROR("replay gain is disabled");
4928 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4932 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4934 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4942 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4944 int ret = MM_ERROR_NONE;
4945 int current_state = MM_CAMCORDER_STATE_NONE;
4946 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4947 _MMCamcorderSubContext *sc = NULL;
4949 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4951 if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4952 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4956 MMCAM_LOG_INFO("Enable extra preview(%d)", value->value.i_val);
4958 current_state = _mmcamcorder_get_state(handle);
4959 if (current_state < MM_CAMCORDER_STATE_READY) {
4960 MMCAM_LOG_INFO("will be set when preview is started");
4964 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4965 mmf_return_val_if_fail(sc, FALSE);
4967 if (value->value.i_val)
4968 ret = _mmcamcorder_initialize_extra_preview_mode(handle);
4970 ret = _mmcamcorder_deinitialize_extra_preview_mode(handle);
4972 if (ret != MM_ERROR_NONE) {
4973 MMCAM_LOG_ERROR("set[%d] failed[0x%x]", value->value.i_val, ret);
4977 MMCAM_LOG_INFO("done");
4983 bool _mmcamcorder_commit_request_codec_config(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4985 int ret = MM_ERROR_NONE;
4986 int current_state = MM_CAMCORDER_STATE_NONE;
4987 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4988 _MMCamcorderSubContext *sc = NULL;
4990 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4992 if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4993 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4997 MMCAM_LOG_INFO("Request codec config");
4999 current_state = _mmcamcorder_get_state(handle);
5000 if (current_state < MM_CAMCORDER_STATE_READY) {
5001 MMCAM_LOG_INFO("invalid state[%d]", current_state);
5005 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
5006 mmf_return_val_if_fail(sc, FALSE);
5008 ret = _mmcamcorder_request_codec_config(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
5009 if (ret != MM_ERROR_NONE) {
5010 hcamcorder->error_code = ret;
5018 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
5020 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5023 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
5027 int attr_idxs_default[] = {
5028 MM_CAM_CAMERA_DIGITAL_ZOOM,
5029 MM_CAM_CAMERA_OPTICAL_ZOOM,
5031 MM_CAM_FILTER_CONTRAST,
5034 MM_CAM_STROBE_BRIGHTNESS
5037 int attr_idxs_extra[] = {
5039 MM_CAM_FILTER_BRIGHTNESS,
5041 MM_CAM_FILTER_SATURATION,
5042 MM_CAM_FILTER_SHARPNESS,
5043 MM_CAM_FILTER_COLOR_TONE,
5044 MM_CAM_CAMERA_EXPOSURE_MODE,
5045 MM_CAM_CAMERA_EXPOSURE_VALUE
5048 mmf_return_val_if_fail(hcamcorder, FALSE);
5050 MMCAM_LOG_INFO("commit some attributes again");
5052 attrs = MMF_CAMCORDER_ATTRS(handle);
5053 if (attrs == NULL) {
5054 MMCAM_LOG_ERROR("Get attribute handle failed.");
5058 /* Get Scene mode */
5059 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
5061 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
5062 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
5063 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
5066 /* Set extra if scene mode is NORMAL */
5067 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
5068 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
5069 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
5070 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
5073 /* Set scene mode if scene mode is NOT NORMAL */
5074 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
5075 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
5078 if (mm_attrs_commit_all(attrs) == -1)
5081 MMCAM_LOG_INFO("Done.");
5087 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
5089 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5095 MM_CAM_CAMERA_PTZ_TYPE,
5096 MM_CAM_CAMERA_PAN_MECHA,
5097 MM_CAM_CAMERA_PAN_ELEC,
5098 MM_CAM_CAMERA_TILT_MECHA,
5099 MM_CAM_CAMERA_TILT_ELEC
5102 mmf_return_val_if_fail(hcamcorder, FALSE);
5104 MMCAM_LOG_INFO("commit some attribute again[2]");
5106 attrs = MMF_CAMCORDER_ATTRS(handle);
5107 if (attrs == NULL) {
5108 MMCAM_LOG_ERROR("Get attribute handle failed.");
5112 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
5113 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
5114 mm_attrs_set_modified(attrs, attr_idxs[i]);
5117 if (mm_attrs_commit_all(attrs) == -1)
5120 MMCAM_LOG_INFO("Done.");
5126 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
5128 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5132 int nerror = MM_ERROR_NONE;
5134 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
5136 attrs = MMF_CAMCORDER_ATTRS(handle);
5137 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
5141 table_size = ARRAY_SIZE(readonly_attributes);
5142 MMCAM_LOG_INFO("%d", table_size);
5143 for (i = 0; i < table_size; i++) {
5144 int sCategory = readonly_attributes[i];
5146 mm_attrs_set_readonly(attrs, sCategory);
5153 /*---------------------------------------------------------------------------------------
5154 | INTERNAL FUNCTION DEFINITIONS: |
5155 ---------------------------------------------------------------------------------------*/
5156 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
5158 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5159 _MMCamcorderSubContext *sc = NULL;
5160 int current_state = MM_CAMCORDER_STATE_NULL;
5162 mmf_return_val_if_fail(hcamcorder, FALSE);
5164 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
5168 current_state = _mmcamcorder_get_state(handle);
5170 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
5171 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
5172 MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
5173 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
5174 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
5176 MMCAM_LOG_WARNING("invalid state[%d]", current_state);
5180 MMCAM_LOG_INFO("element is not created yet");
5187 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
5189 #define INIT_VALUE -1
5190 #define CHECK_COUNT 3
5192 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5193 MMHandleType attrs = 0;
5195 int ret = MM_ERROR_NONE;
5198 const char *name = NULL;
5199 const char *check_pair_name[CHECK_COUNT][3] = {
5200 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
5201 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
5202 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
5205 int check_pair_value[CHECK_COUNT][2] = {
5206 {INIT_VALUE, INIT_VALUE},
5207 {INIT_VALUE, INIT_VALUE},
5208 {INIT_VALUE, INIT_VALUE},
5211 if (hcamcorder == NULL || attribute_name == NULL) {
5212 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
5213 hcamcorder, attribute_name);
5214 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5218 *err_attr_name = NULL;
5220 /*MMCAM_LOG_INFO( "ENTER" );*/
5222 attrs = MMF_CAMCORDER_ATTRS(handle);
5224 name = attribute_name;
5228 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
5230 /*MMCAM_LOG_INFO("NAME : %s", name);*/
5232 /* attribute name check */
5233 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
5235 *err_attr_name = strdup(name);
5237 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
5238 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5244 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5247 switch (attr_type) {
5248 case MM_ATTRS_TYPE_INT:
5250 gboolean matched = FALSE;
5251 for (i = 0 ; i < CHECK_COUNT ; i++) {
5252 for (j = 0 ; j < 2 ; j++) {
5253 if (!strcmp(name, check_pair_name[i][j])) {
5254 check_pair_value[i][j] = va_arg((var_args), int);
5255 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5263 if (matched == FALSE)
5264 va_arg((var_args), int);
5267 case MM_ATTRS_TYPE_DOUBLE:
5268 va_arg((var_args), double);
5270 case MM_ATTRS_TYPE_STRING:
5271 va_arg((var_args), char*); /* string */
5272 va_arg((var_args), int); /* size */
5274 case MM_ATTRS_TYPE_DATA:
5275 va_arg((var_args), void*); /* data */
5276 va_arg((var_args), int); /* size */
5278 case MM_ATTRS_TYPE_INVALID:
5280 MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5282 *err_attr_name = strdup(name);
5284 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5288 name = va_arg(var_args, const char*);
5291 for (i = 0 ; i < CHECK_COUNT ; i++) {
5292 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5293 gboolean check_result = FALSE;
5294 char *err_name = NULL;
5295 MMCamAttrsInfo attr_info_0, attr_info_1;
5297 if (check_pair_value[i][0] == INIT_VALUE) {
5298 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5299 err_name = strdup(check_pair_name[i][1]);
5300 } else if (check_pair_value[i][1] == INIT_VALUE) {
5301 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5302 err_name = strdup(check_pair_name[i][0]);
5304 err_name = strdup(check_pair_name[i][2]);
5307 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5308 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5310 check_result = FALSE;
5312 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5313 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5314 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5316 MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5317 check_pair_name[i][0], check_pair_name[i][1],
5318 check_pair_value[i][0], check_pair_value[i][1], i);
5320 check_result = TRUE;
5325 if (check_result == FALSE) {
5326 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5327 check_pair_name[i][0], check_pair_name[i][1],
5328 check_pair_value[i][0], check_pair_value[i][1]);
5329 if (err_attr_name) {
5330 *err_attr_name = err_name;
5338 if (check_pair_value[i][0] <= 0 || check_pair_value[i][1] <= 0)
5339 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5341 return MM_ERROR_CAMCORDER_NOT_SUPPORTED;
5344 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5345 int current_width = 0;
5346 int current_height = 0;
5348 mm_camcorder_get_attributes(handle, NULL,
5349 MMCAM_CAMERA_WIDTH, ¤t_width,
5350 MMCAM_CAMERA_HEIGHT, ¤t_height,
5353 if (current_width != check_pair_value[i][0] ||
5354 current_height != check_pair_value[i][1]) {
5355 hcamcorder->resolution_changed = TRUE;
5357 hcamcorder->resolution_changed = FALSE;
5360 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5370 /*MMCAM_LOG_INFO("DONE");*/
5372 return MM_ERROR_NONE;
5376 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5380 if ((void *)handle == NULL) {
5381 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5385 memset(&info, 0x0, sizeof(MMAttrsInfo));
5387 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5389 switch (info.validity_type) {
5390 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5392 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5394 if (info.int_array.count < 1)
5397 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5399 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5401 if (info.int_range.min > info.int_range.max)
5404 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5406 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5408 if (info.double_array.count < 1)
5411 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5413 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5415 if (info.double_range.min >= info.double_range.max)
5419 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);