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_BITRATE (1024*1024*10)
38 #define MMCAMCORDER_DEFAULT_ENCODED_PREVIEW_GOP_INTERVAL 1000
39 #define MMCAMCORDER_DEFAULT_REPLAY_GAIN_REFERENCE_LEVEL 89.0
41 /*---------------------------------------------------------------------------------------
42 | GLOBAL VARIABLE DEFINITIONS for internal |
43 ---------------------------------------------------------------------------------------*/
45 /*-----------------------------------------------------------------------
46 | LOCAL VARIABLE DEFINITIONS for internal |
47 -----------------------------------------------------------------------*/
48 /* Readonly attributes list.
49 * If you want to make some attributes read only, write down here.
50 * It will make them read only after composing whole attributes.
53 static int readonly_attributes[] = {
54 MM_CAM_CAMERA_DEVICE_COUNT,
55 MM_CAM_CAMERA_DEVICE_NAME,
56 MM_CAM_CAMERA_FACING_DIRECTION,
57 MM_CAM_CAMERA_SHUTTER_SPEED,
58 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_CAPTURE,
59 MM_CAM_RECOMMEND_PREVIEW_FORMAT_FOR_RECORDING,
60 MM_CAM_CAPTURED_SCREENNAIL,
61 MM_CAM_RECOMMEND_DISPLAY_ROTATION,
62 MM_CAM_SUPPORT_ZSL_CAPTURE,
63 MM_CAM_SUPPORT_ZERO_COPY_FORMAT,
64 MM_CAM_SUPPORT_MEDIA_PACKET_PREVIEW_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",
1477 {(void*)MMCAMCORDER_DEFAULT_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,
1705 memcpy(hcamcorder->cam_attrs_const_info, temp_info, sizeof(mm_cam_attr_construct_info) * attr_count);
1707 for (idx = 0 ; idx < attr_count ; idx++) {
1708 /* attribute order check. This should be same. */
1709 if (idx != hcamcorder->cam_attrs_const_info[idx].attrid) {
1710 MMCAM_LOG_ERROR("Please check attributes order. Is the idx same with enum val?");
1711 free(attrs_const_info);
1712 attrs_const_info = NULL;
1713 free(hcamcorder->cam_attrs_const_info);
1714 hcamcorder->cam_attrs_const_info = NULL;
1718 attrs_const_info[idx].name = hcamcorder->cam_attrs_const_info[idx].name;
1719 attrs_const_info[idx].value_type = hcamcorder->cam_attrs_const_info[idx].value_type;
1720 attrs_const_info[idx].flags = hcamcorder->cam_attrs_const_info[idx].flags;
1721 attrs_const_info[idx].default_value = hcamcorder->cam_attrs_const_info[idx].default_value.value_void;
1724 /* Camcorder Attributes */
1725 MMCAM_LOG_INFO("Create Camcorder Attributes[%p, %d]", attrs_const_info, attr_count);
1727 ret = mm_attrs_new(attrs_const_info,
1729 "Camcorder_Attributes",
1730 _mmcamcorder_commit_camcorder_attrs,
1734 free(attrs_const_info);
1735 attrs_const_info = NULL;
1737 if (ret != MM_ERROR_NONE) {
1738 MMCAM_LOG_ERROR("Fail to alloc attribute handle");
1739 free(hcamcorder->cam_attrs_const_info);
1740 hcamcorder->cam_attrs_const_info = NULL;
1744 __mmcamcorder_set_conf_to_valid_info(handle);
1746 for (idx = 0; idx < attr_count; idx++) {
1747 mm_cam_attr_construct_info *attr_info = &hcamcorder->cam_attrs_const_info[idx];
1749 mm_attrs_set_valid_type(attrs, idx, attr_info->validity_type);
1751 switch (attr_info->validity_type) {
1752 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1753 if (attr_info->validity_value_1.int_array &&
1754 attr_info->validity_value_2.count > 0) {
1755 mm_attrs_set_valid_array(attrs, idx,
1756 (const int *)(attr_info->validity_value_1.int_array),
1757 attr_info->validity_value_2.count,
1758 attr_info->default_value.value_int);
1761 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1762 mm_attrs_set_valid_range(attrs, idx,
1763 attr_info->validity_value_1.int_min,
1764 attr_info->validity_value_2.int_max,
1765 attr_info->default_value.value_int);
1767 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1768 if (attr_info->validity_value_1.double_array &&
1769 attr_info->validity_value_2.count > 0) {
1770 mm_attrs_set_valid_double_array(attrs, idx,
1771 (const double *)(attr_info->validity_value_1.double_array),
1772 attr_info->validity_value_2.count,
1773 attr_info->default_value.value_double);
1776 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1777 mm_attrs_set_valid_double_range(attrs, idx,
1778 attr_info->validity_value_1.double_min,
1779 attr_info->validity_value_2.double_max,
1780 attr_info->default_value.value_double);
1782 case MM_ATTRS_VALID_TYPE_NONE:
1784 case MM_ATTRS_VALID_TYPE_INVALID:
1786 MMCAM_LOG_ERROR("Valid type error.");
1791 __mmcamcorder_release_conf_valid_info(handle);
1798 _mmcamcorder_dealloc_attribute(MMHandleType handle, MMHandleType attrs)
1800 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1802 if (hcamcorder == NULL) {
1803 MMCAM_LOG_ERROR("handle is NULL");
1810 mm_attrs_free(attrs);
1811 MMCAM_LOG_INFO("released attribute");
1814 if (hcamcorder->cam_attrs_const_info) {
1815 free(hcamcorder->cam_attrs_const_info);
1816 hcamcorder->cam_attrs_const_info = NULL;
1817 MMCAM_LOG_INFO("released attribute info");
1825 _mmcamcorder_get_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1827 MMHandleType attrs = 0;
1828 int ret = MM_ERROR_NONE;
1830 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1831 /*mmf_return_val_if_fail(err_attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);*/
1833 attrs = MMF_CAMCORDER_ATTRS(handle);
1834 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
1836 ret = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, var_args);
1843 _mmcamcorder_set_attributes(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
1845 MMHandleType attrs = 0;
1846 int ret = MM_ERROR_NONE;
1848 char *tmp_err_attr_name = NULL;
1849 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1850 va_list var_args_copy;
1852 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1854 if (!_MMCAMCORDER_TRYLOCK_CMD(handle)) {
1855 MMCAM_LOG_ERROR("Another command is running.");
1856 return MM_ERROR_CAMCORDER_CMD_IS_RUNNING;
1859 /* copy var_args to keep original var_args */
1860 va_copy(var_args_copy, var_args);
1862 attrs = MMF_CAMCORDER_ATTRS(handle);
1864 ret = __mmcamcorder_check_valid_pair(handle, &tmp_err_attr_name, attribute_name, var_args);
1866 MMCAM_LOG_ERROR("handle %p, attrs is NULL, attr name [%s]", handle, attribute_name);
1867 ret = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
1870 if (ret == MM_ERROR_NONE) {
1871 hcamcorder->error_code = MM_ERROR_NONE;
1872 /* In 64bit environment, unexpected result is returned if var_args is used again. */
1873 ret = mm_attrs_set_valist(attrs, &tmp_err_attr_name, attribute_name, var_args_copy);
1876 va_end(var_args_copy);
1878 _MMCAMCORDER_UNLOCK_CMD(handle);
1880 if (ret != MM_ERROR_NONE) {
1881 if (ret == MM_ERROR_COMMON_OUT_OF_RANGE) {
1882 if (mm_attrs_get_index(attrs, tmp_err_attr_name, &err_index) == MM_ERROR_NONE &&
1883 _mmcamcorder_check_supported_attribute(handle, err_index)) {
1884 MMCAM_LOG_ERROR("[%s] is supported, but value is invalid",
1885 tmp_err_attr_name ? tmp_err_attr_name : "NULL");
1886 ret = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
1890 if (hcamcorder->error_code != MM_ERROR_NONE) {
1891 MMCAM_LOG_ERROR("error_code is set. ret 0x%x -> modified 0x%x", ret, hcamcorder->error_code);
1892 ret = hcamcorder->error_code;
1893 hcamcorder->error_code = MM_ERROR_NONE;
1896 MMCAM_LOG_ERROR("failed error code 0x%x - handle %p", ret, (mmf_camcorder_t *)handle);
1899 if (tmp_err_attr_name) {
1900 if (!err_attr_name) {
1901 MMCAM_LOG_ERROR("set attribute[%s] error, but err name is NULL", tmp_err_attr_name);
1902 free(tmp_err_attr_name);
1903 tmp_err_attr_name = NULL;
1905 *err_attr_name = tmp_err_attr_name;
1914 _mmcamcorder_get_attribute_info(MMHandleType handle, const char *attr_name, MMCamAttrsInfo *info)
1916 MMHandleType attrs = 0;
1917 MMAttrsInfo attrinfo;
1918 int ret = MM_ERROR_NONE;
1920 mmf_return_val_if_fail(handle, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1921 mmf_return_val_if_fail(attr_name, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1922 mmf_return_val_if_fail(info, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1924 attrs = MMF_CAMCORDER_ATTRS(handle);
1925 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
1927 ret = mm_attrs_get_info_by_name(attrs, attr_name, (MMAttrsInfo*)&attrinfo);
1929 if (ret == MM_ERROR_NONE) {
1930 memset(info, 0x00, sizeof(MMCamAttrsInfo));
1931 info->type = attrinfo.type;
1932 info->flag = attrinfo.flag;
1933 info->validity_type = attrinfo.validity_type;
1935 switch (attrinfo.validity_type) {
1936 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
1937 info->int_array.array = attrinfo.int_array.array;
1938 info->int_array.count = attrinfo.int_array.count;
1939 info->int_array.def = attrinfo.int_array.dval;
1941 case MM_ATTRS_VALID_TYPE_INT_RANGE:
1942 info->int_range.min = attrinfo.int_range.min;
1943 info->int_range.max = attrinfo.int_range.max;
1944 info->int_range.def = attrinfo.int_range.dval;
1946 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
1947 info->double_array.array = attrinfo.double_array.array;
1948 info->double_array.count = attrinfo.double_array.count;
1949 info->double_array.def = attrinfo.double_array.dval;
1951 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
1952 info->double_range.min = attrinfo.double_range.min;
1953 info->double_range.max = attrinfo.double_range.max;
1954 info->double_range.def = attrinfo.double_range.dval;
1956 case MM_ATTRS_VALID_TYPE_NONE:
1958 case MM_ATTRS_VALID_TYPE_INVALID:
1969 _mmcamcorder_commit_camcorder_attrs(int attr_idx, const char *attr_name, const MMAttrsValue *value, void *commit_param)
1972 mmf_camcorder_t *hcamcorder = NULL;
1974 mmf_return_val_if_fail(commit_param, FALSE);
1975 mmf_return_val_if_fail(attr_idx >= 0, FALSE);
1976 mmf_return_val_if_fail(attr_name, FALSE);
1977 mmf_return_val_if_fail(value, FALSE);
1979 hcamcorder = MMF_CAMCORDER(commit_param);
1981 if (hcamcorder->cam_attrs_const_info[attr_idx].attr_commit)
1982 bret = hcamcorder->cam_attrs_const_info[attr_idx].attr_commit((MMHandleType)commit_param, attr_idx, value);
1990 int __mmcamcorder_set_conf_to_valid_info(MMHandleType handle)
1993 int total_count = 0;
1995 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
1997 if (hcamcorder == NULL) {
1998 MMCAM_LOG_ERROR("handle is NULL");
1999 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2003 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_AUDIO_ENCODER, &format);
2004 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = format;
2005 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = total_count;
2008 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_VIDEO_ENCODER, &format);
2009 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = format;
2010 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = total_count;
2013 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_IMAGE_ENCODER, &format);
2014 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = format;
2015 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = total_count;
2018 total_count = _mmcamcorder_get_available_format(handle, CONFIGURE_CATEGORY_MAIN_MUX, &format);
2019 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = format;
2020 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = total_count;
2022 return MM_ERROR_NONE;
2026 int __mmcamcorder_release_conf_valid_info(MMHandleType handle)
2028 int *allocated_memory = NULL;
2030 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2032 if (hcamcorder == NULL) {
2033 MMCAM_LOG_ERROR("handle is NULL");
2034 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
2037 MMCAM_LOG_INFO("START");
2039 /* Audio encoder info */
2040 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array);
2041 if (allocated_memory) {
2042 g_free(allocated_memory);
2043 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_1.int_array = NULL;
2044 hcamcorder->cam_attrs_const_info[MM_CAM_AUDIO_ENCODER].validity_value_2.count = 0;
2047 /* Video encoder info */
2048 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array);
2049 if (allocated_memory) {
2050 g_free(allocated_memory);
2051 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_1.int_array = NULL;
2052 hcamcorder->cam_attrs_const_info[MM_CAM_VIDEO_ENCODER].validity_value_2.count = 0;
2055 /* Image encoder info */
2056 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array);
2057 if (allocated_memory) {
2058 g_free(allocated_memory);
2059 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_1.int_array = NULL;
2060 hcamcorder->cam_attrs_const_info[MM_CAM_IMAGE_ENCODER].validity_value_2.count = 0;
2063 /* File format info */
2064 allocated_memory = (int *)(hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array);
2065 if (allocated_memory) {
2066 g_free(allocated_memory);
2067 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_1.int_array = NULL;
2068 hcamcorder->cam_attrs_const_info[MM_CAM_FILE_FORMAT].validity_value_2.count = 0;
2071 MMCAM_LOG_INFO("DONE");
2073 return MM_ERROR_NONE;
2077 bool _mmcamcorder_commit_capture_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2079 MMHandleType attr = 0;
2080 int current_state = MM_CAMCORDER_STATE_NONE;
2082 mmf_return_val_if_fail(handle && value, FALSE);
2084 attr = MMF_CAMCORDER_ATTRS(handle);
2085 mmf_return_val_if_fail(attr, FALSE);
2087 /*MMCAM_LOG_INFO("(%d)", attr_idx);*/
2089 current_state = _mmcamcorder_get_state(handle);
2090 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2091 int flags = MM_ATTRS_FLAG_NONE;
2092 int capture_width, capture_height;
2093 MMCamAttrsInfo info;
2095 mm_camcorder_get_attribute_info(handle, MMCAM_CAPTURE_HEIGHT, &info);
2098 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2099 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_HEIGHT, &capture_height, NULL);
2100 capture_width = value->value.i_val;
2102 /* Check whether they are valid pair */
2103 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2108 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2114 bool _mmcamcorder_commit_capture_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2116 int current_state = MM_CAMCORDER_STATE_NONE;
2118 current_state = _mmcamcorder_get_state(handle);
2120 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
2121 int capture_width, capture_height;
2123 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAPTURE_WIDTH, &capture_width, NULL);
2124 capture_height = value->value.i_val;
2126 return __mmcamcorder_set_capture_resolution(handle, capture_width, capture_height);
2128 MMCAM_LOG_INFO("Capture resolution can't be set.(state=%d)", current_state);
2135 bool _mmcamcorder_commit_capture_break_cont_shot(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2137 int current_state = 0;
2139 _MMCamcorderSubContext *sc = NULL;
2140 _MMCamcorderImageInfo *info = NULL;
2141 GstCameraControl *control = NULL;
2143 mmf_return_val_if_fail(handle && value, FALSE);
2145 current_state = _mmcamcorder_get_state(handle);
2146 ivalue = value->value.i_val;
2148 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2152 info = sc->info_image;
2154 MMCAM_LOG_ERROR("info image is NULL");
2158 if (ivalue && current_state == MM_CAMCORDER_STATE_CAPTURING) {
2159 if (info->capture_send_count > 0) {
2160 info->capturing = FALSE;
2161 MMCAM_LOG_WARNING("capturing -> FALSE and skip capture callback since now");
2164 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2165 MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
2169 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2171 gst_camera_control_set_capture_command(control, GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP_MULTISHOT);
2172 MMCAM_LOG_WARNING("Commit Break continuous shot : Set command OK. current state[%d]", current_state);
2174 MMCAM_LOG_WARNING("cast CAMERA_CONTROL failed");
2177 MMCAM_LOG_WARNING("Commit Break continuous shot : No effect. value[%d],current state[%d]", ivalue, current_state);
2184 bool _mmcamcorder_commit_capture_count(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2186 int mode = MM_CAMCORDER_MODE_VIDEO_CAPTURE;
2187 int current_state = MM_CAMCORDER_STATE_NONE;
2188 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2190 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2192 current_state = _mmcamcorder_get_state(handle);
2193 mm_camcorder_get_attributes(handle, NULL, MMCAM_MODE, &mode, NULL);
2195 MMCAM_LOG_INFO("current state %d, mode %d, set count %d",
2196 current_state, mode, value->value.i_val);
2198 if (mode != MM_CAMCORDER_MODE_AUDIO &&
2199 current_state != MM_CAMCORDER_STATE_CAPTURING) {
2202 MMCAM_LOG_ERROR("Invalid mode[%d] or state[%d]", mode, current_state);
2208 bool _mmcamcorder_commit_capture_sound_enable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2210 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2212 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2214 MMCAM_LOG_INFO("shutter sound policy: %d", hcamcorder->shutter_sound_policy);
2216 /* return error when disable shutter sound if policy is TRUE */
2217 if (!value->value.i_val &&
2218 hcamcorder->shutter_sound_policy == VCONFKEY_CAMERA_SHUTTER_SOUND_POLICY_ON) {
2219 MMCAM_LOG_ERROR("not permitted DISABLE SHUTTER SOUND");
2222 MMCAM_LOG_INFO("set value [%d] success", value->value.i_val);
2228 bool _mmcamcorder_commit_audio_volume(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2230 int current_state = MM_CAMCORDER_STATE_NONE;
2231 _MMCamcorderSubContext *sc = NULL;
2234 mmf_return_val_if_fail(handle && value, FALSE);
2236 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2240 current_state = _mmcamcorder_get_state(handle);
2242 if ((current_state == MM_CAMCORDER_STATE_RECORDING) || (current_state == MM_CAMCORDER_STATE_PAUSED)) {
2243 double mslNewVal = 0;
2244 mslNewVal = value->value.d_val;
2246 if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst) {
2247 if (mslNewVal == 0.0) {
2248 /* Because data probe of audio src do the same job, it doesn't need to set mute here. Already null raw data. */
2249 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
2251 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
2252 MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", mslNewVal);
2256 MMCAM_LOG_INFO("Commit : volume(%f)", mslNewVal);
2259 MMCAM_LOG_INFO("Commit : nothing to commit. status(%d)", current_state);
2267 bool _mmcamcorder_commit_camera_format(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2269 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2270 int current_state = MM_CAMCORDER_STATE_NONE;
2272 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2274 current_state = _mmcamcorder_get_state(handle);
2275 if (current_state > MM_CAMCORDER_STATE_READY) {
2276 MMCAM_LOG_ERROR("invalid state %d", current_state);
2277 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2285 bool _mmcamcorder_commit_camera_fps(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2287 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2288 MMCamAttrsInfo fps_info;
2289 int resolution_width = 0;
2290 int resolution_height = 0;
2293 int current_state = MM_CAMCORDER_STATE_NONE;
2295 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2297 current_state = _mmcamcorder_get_state(handle);
2298 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2299 MMCAM_LOG_ERROR("invalid state %d", current_state);
2300 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2304 if (attr_idx == MM_CAM_CAMERA_FPS_AUTO)
2307 MMCAM_LOG_INFO("FPS(%d)", value->value.i_val);
2309 ret = mm_camcorder_get_attributes(handle, NULL,
2310 MMCAM_CAMERA_WIDTH, &resolution_width,
2311 MMCAM_CAMERA_HEIGHT, &resolution_height,
2314 if (ret != MM_ERROR_NONE) {
2315 MMCAM_LOG_ERROR("FAILED : coult not get resolution values.");
2319 ret = mm_camcorder_get_fps_list_by_resolution(handle, resolution_width, resolution_height, &fps_info);
2320 if (ret != MM_ERROR_NONE) {
2321 MMCAM_LOG_ERROR("FAILED : coult not get FPS values by resolution.");
2325 for (i = 0 ; i < fps_info.int_array.count ; i++) {
2326 if (value->value.i_val == fps_info.int_array.array[i])
2330 MMCAM_LOG_ERROR("FAILED : %d is not supported FPS", value->value.i_val);
2336 bool _mmcamcorder_commit_camera_recording_motion_rate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2338 int current_state = MM_CAMCORDER_STATE_NONE;
2339 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2340 _MMCamcorderSubContext *sc = NULL;
2342 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2344 current_state = _mmcamcorder_get_state(handle);
2345 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2346 MMCAM_LOG_WARNING("invalid state %d", current_state);
2347 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2351 /* Verify recording motion rate */
2352 if (value->value.d_val > 0.0) {
2353 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2357 /* set is_slow flag */
2358 if (value->value.d_val != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
2359 sc->is_modified_rate = TRUE;
2361 sc->is_modified_rate = FALSE;
2363 MMCAM_LOG_INFO("Set slow motion rate %lf", value->value.d_val);
2366 MMCAM_LOG_WARNING("Failed to set recording motion rate %lf", value->value.d_val);
2372 bool _mmcamcorder_commit_camera_width(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2374 MMHandleType attr = 0;
2375 int current_state = MM_CAMCORDER_STATE_NONE;
2377 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2378 _MMCamcorderSubContext *sc = NULL;
2380 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2382 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2386 attr = MMF_CAMCORDER_ATTRS(handle);
2387 mmf_return_val_if_fail(attr, FALSE);
2389 MMCAM_LOG_INFO("Width(%d)", value->value.i_val);
2391 current_state = _mmcamcorder_get_state(handle);
2393 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2394 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2397 int flags = MM_ATTRS_FLAG_NONE;
2398 MMCamAttrsInfo info;
2399 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_HEIGHT, &info);
2402 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2403 int width = value->value.i_val;
2405 int preview_format = MM_PIXEL_FORMAT_NV12;
2406 int codec_type = MM_IMAGE_CODEC_JPEG;
2408 mm_camcorder_get_attributes(handle, NULL,
2409 MMCAM_CAMERA_HEIGHT, &height,
2410 MMCAM_CAMERA_FORMAT, &preview_format,
2411 MMCAM_IMAGE_ENCODER, &codec_type,
2414 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2415 if (hcamcorder->resolution_changed == FALSE) {
2416 MMCAM_LOG_INFO("no need to restart preview");
2420 hcamcorder->resolution_changed = FALSE;
2422 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2423 MMCAM_LOG_INFO("restart preview");
2425 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2426 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2428 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2429 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2431 /* check decoder recreation */
2432 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2433 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2434 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2438 /* get preview format */
2439 sc->info_image->preview_format = preview_format;
2440 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2441 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2443 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2444 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2446 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2447 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2450 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2452 MMCAM_LOG_ERROR("currently locked for preview restart");
2456 /* get preview format */
2457 sc->info_image->preview_format = preview_format;
2458 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2459 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2470 bool _mmcamcorder_commit_camera_height(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2473 int current_state = MM_CAMCORDER_STATE_NONE;
2474 MMHandleType attr = 0;
2475 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2476 _MMCamcorderSubContext *sc = NULL;
2478 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2480 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2484 attr = MMF_CAMCORDER_ATTRS(hcamcorder);
2485 mmf_return_val_if_fail(attr, FALSE);
2487 MMCAM_LOG_INFO("Height(%d)", value->value.i_val);
2488 current_state = _mmcamcorder_get_state(handle);
2490 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2491 MMCAM_LOG_INFO("Resolution can't be changed.(state=%d)", current_state);
2492 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2496 int height = value->value.i_val;
2497 int preview_format = MM_PIXEL_FORMAT_NV12;
2498 int codec_type = MM_IMAGE_CODEC_JPEG;
2499 int video_stabilization = 0;
2501 mm_camcorder_get_attributes(handle, NULL,
2502 MMCAM_CAMERA_WIDTH, &width,
2503 MMCAM_CAMERA_FORMAT, &preview_format,
2504 MMCAM_IMAGE_ENCODER, &codec_type,
2505 MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
2508 sc->info_video->preview_width = width;
2509 sc->info_video->preview_height = height;
2511 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
2512 if (hcamcorder->resolution_changed == FALSE) {
2513 MMCAM_LOG_INFO("no need to restart preview");
2517 hcamcorder->resolution_changed = FALSE;
2519 if (g_mutex_trylock(&hcamcorder->restart_preview_lock)) {
2520 MMCAM_LOG_INFO("restart preview");
2522 MMCAM_LOG_INFO("set empty buffers");
2524 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
2525 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
2527 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2528 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
2530 /* check decoder recreation */
2531 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
2532 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
2533 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2537 /* get preview format */
2538 sc->info_image->preview_format = preview_format;
2539 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2541 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2543 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
2544 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
2546 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format))
2547 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
2550 g_mutex_unlock(&hcamcorder->restart_preview_lock);
2552 MMCAM_LOG_ERROR("currently locked for preview restart");
2556 /* get preview format */
2557 sc->info_image->preview_format = preview_format;
2558 sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codec_type, hcamcorder->use_zero_copy_format);
2559 ret = _mmcamcorder_set_camera_resolution(handle, width, height);
2567 bool _mmcamcorder_commit_video_size(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2569 int current_state = MM_CAMCORDER_STATE_NONE;
2570 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2572 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2574 current_state = _mmcamcorder_get_state(handle);
2575 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
2576 MMCAM_LOG_ERROR("Video Resolution can't be changed.(state=%d)", current_state);
2577 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2580 MMCAM_LOG_WARNING("Video Resolution %d [attr_idx %d] ",
2581 value->value.i_val, attr_idx);
2587 bool _mmcamcorder_commit_camera_zoom(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2589 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2590 _MMCamcorderSubContext *sc = NULL;
2591 int current_state = MM_CAMCORDER_STATE_NONE;
2592 GstCameraControl *control = NULL;
2596 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2598 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2602 zoom_level = value->value.i_val;
2604 MMCAM_LOG_INFO("(%d)", attr_idx);
2606 current_state = _mmcamcorder_get_state(handle);
2607 if (current_state < MM_CAMCORDER_STATE_READY) {
2608 MMCAM_LOG_INFO("will be applied when preview starts");
2610 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2611 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2612 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2616 if (attr_idx == MM_CAM_CAMERA_OPTICAL_ZOOM)
2617 zoom_type = GST_CAMERA_CONTROL_OPTICAL_ZOOM;
2619 zoom_type = GST_CAMERA_CONTROL_DIGITAL_ZOOM;
2621 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2624 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2625 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2629 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2630 if (control == NULL) {
2631 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2635 ret = gst_camera_control_set_zoom(control, zoom_type, zoom_level);
2637 MMCAM_LOG_INFO("Succeed in operating Zoom[%d].", zoom_level);
2640 MMCAM_LOG_WARNING("Failed to operate Zoom. Type[%d],Level[%d]", zoom_type, zoom_level);
2643 MMCAM_LOG_INFO("pointer of video src is null");
2650 bool _mmcamcorder_commit_camera_ptz_type(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2652 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2653 _MMCamcorderSubContext *sc = NULL;
2654 int current_state = MM_CAMCORDER_STATE_NONE;
2656 GstCameraControl *CameraControl = NULL;
2657 GstCameraControlChannel *CameraControlChannel = NULL;
2658 const GList *controls = NULL;
2659 const GList *item = NULL;
2661 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2663 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2664 mmf_return_val_if_fail(sc, TRUE);
2666 MMCAM_LOG_INFO("ptz type : %d", value->value.i_val);
2668 current_state = _mmcamcorder_get_state(handle);
2669 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2670 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2671 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2672 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2676 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2677 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2678 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2682 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2683 if (CameraControl == NULL) {
2684 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2688 controls = gst_camera_control_list_channels(CameraControl);
2689 if (controls == NULL) {
2690 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2694 for (item = controls ; item && item->data ; item = item->next) {
2695 CameraControlChannel = item->data;
2696 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2697 if (!strcmp(CameraControlChannel->label, "ptz_type")) {
2698 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2699 MMCAM_LOG_WARNING("set ptz type %d done", value->value.i_val);
2702 MMCAM_LOG_ERROR("failed to set ptz type %d", value->value.i_val);
2708 MMCAM_LOG_WARNING("failed to find ptz type control channel");
2715 bool _mmcamcorder_commit_camera_pan(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2717 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2718 _MMCamcorderSubContext *sc = NULL;
2719 int current_state = MM_CAMCORDER_STATE_NONE;
2721 GstCameraControl *CameraControl = NULL;
2722 GstCameraControlChannel *CameraControlChannel = NULL;
2723 const GList *controls = NULL;
2724 const GList *item = NULL;
2726 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2728 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2729 mmf_return_val_if_fail(sc, TRUE);
2731 MMCAM_LOG_INFO("pan : %d", value->value.i_val);
2733 current_state = _mmcamcorder_get_state(handle);
2734 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2735 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2736 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2737 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2741 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2742 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2743 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2747 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2748 if (CameraControl == NULL) {
2749 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2753 controls = gst_camera_control_list_channels(CameraControl);
2754 if (controls == NULL) {
2755 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2759 for (item = controls ; item && item->data ; item = item->next) {
2760 CameraControlChannel = item->data;
2761 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2762 if (!strcmp(CameraControlChannel->label, "pan")) {
2763 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2764 MMCAM_LOG_WARNING("set pan %d done", value->value.i_val);
2767 MMCAM_LOG_ERROR("failed to set pan %d", value->value.i_val);
2773 MMCAM_LOG_WARNING("failed to find pan control channel");
2780 bool _mmcamcorder_commit_camera_tilt(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2782 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2783 _MMCamcorderSubContext *sc = NULL;
2784 int current_state = MM_CAMCORDER_STATE_NONE;
2786 GstCameraControl *CameraControl = NULL;
2787 GstCameraControlChannel *CameraControlChannel = NULL;
2788 const GList *controls = NULL;
2789 const GList *item = NULL;
2791 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2793 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2794 mmf_return_val_if_fail(sc, TRUE);
2796 MMCAM_LOG_INFO("tilt : %d", value->value.i_val);
2798 current_state = _mmcamcorder_get_state(handle);
2799 if (current_state < MM_CAMCORDER_STATE_PREPARE ||
2800 current_state == MM_CAMCORDER_STATE_CAPTURING) {
2801 MMCAM_LOG_ERROR("invalid state[%d]", current_state);
2802 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2806 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2807 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2808 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2812 CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2813 if (CameraControl == NULL) {
2814 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2818 controls = gst_camera_control_list_channels(CameraControl);
2819 if (controls == NULL) {
2820 MMCAM_LOG_ERROR("gst_camera_control_list_channels failed");
2824 for (item = controls ; item && item->data ; item = item->next) {
2825 CameraControlChannel = item->data;
2826 MMCAM_LOG_INFO("CameraControlChannel->label %s", CameraControlChannel->label);
2827 if (!strcmp(CameraControlChannel->label, "tilt")) {
2828 if (gst_camera_control_set_value(CameraControl, CameraControlChannel, value->value.i_val)) {
2829 MMCAM_LOG_WARNING("set tilt %d done", value->value.i_val);
2832 MMCAM_LOG_ERROR("failed to set tilt %d", value->value.i_val);
2838 MMCAM_LOG_WARNING("failed to find tilt control channel");
2845 bool _mmcamcorder_commit_camera_focus_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2847 MMHandleType attr = 0;
2848 int current_state = MM_CAMCORDER_STATE_NONE;
2849 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2850 _MMCamcorderSubContext *sc = NULL;
2851 GstCameraControl *control = NULL;
2853 int set_focus_mode = 0;
2854 int cur_focus_mode = 0;
2855 int cur_focus_range = 0;
2857 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2859 attr = MMF_CAMCORDER_ATTRS(handle);
2860 mmf_return_val_if_fail(attr, FALSE);
2862 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2866 MMCAM_LOG_INFO("Focus mode(%d)", value->value.i_val);
2868 /* check whether set or not */
2869 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2870 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
2874 current_state = _mmcamcorder_get_state(handle);
2875 if (current_state < MM_CAMCORDER_STATE_NULL) {
2876 MMCAM_LOG_INFO("Focus mode will be changed later.(state=%d)", current_state);
2878 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2879 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2880 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2884 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
2885 int flags = MM_ATTRS_FLAG_NONE;
2886 MMCamAttrsInfo info;
2888 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2889 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
2893 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2894 if (control == NULL) {
2895 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2899 mslVal = value->value.i_val;
2900 set_focus_mode = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
2902 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_SCAN_RANGE, &info);
2905 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
2906 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
2907 if (set_focus_mode != cur_focus_mode) {
2908 if (gst_camera_control_set_focus(control, set_focus_mode, cur_focus_range)) {
2909 MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);
2912 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
2915 MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);
2919 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
2923 MMCAM_LOG_INFO("pointer of video src is null");
2930 bool _mmcamcorder_commit_camera_focus_level(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2932 int current_state = MM_CAMCORDER_STATE_NONE;
2933 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2934 _MMCamcorderSubContext *sc = NULL;
2935 GstCameraControl *control = NULL;
2937 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2939 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2943 MMCAM_LOG_INFO("Focus level[%d]", value->value.i_val);
2945 current_state = _mmcamcorder_get_state(handle);
2946 if (current_state < MM_CAMCORDER_STATE_READY) {
2947 MMCAM_LOG_INFO("Focus level will be set later.(state=%d)", current_state);
2949 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
2950 MMCAM_LOG_ERROR("Can not set while CAPTURING");
2951 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
2955 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
2956 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
2960 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
2961 if (control == NULL) {
2962 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
2966 if (!gst_camera_control_set_focus_level(control, value->value.i_val)) {
2967 MMCAM_LOG_ERROR("set focus level[%d[ failed", value->value.i_val);
2975 bool _mmcamcorder_commit_camera_af_scan_range(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
2977 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
2978 _MMCamcorderSubContext *sc = NULL;
2979 GstCameraControl *control = NULL;
2980 int current_state = MM_CAMCORDER_STATE_NONE;
2983 int cur_focus_mode = 0;
2984 int cur_focus_range = 0;
2985 int msl_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
2986 int converted_mode = 0;
2988 mmf_return_val_if_fail(hcamcorder && value, FALSE);
2990 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
2994 MMCAM_LOG_INFO("(%d)", attr_idx);
2996 /* check whether set or not */
2997 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
2998 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3002 mslVal = value->value.i_val;
3003 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3005 current_state = _mmcamcorder_get_state(handle);
3006 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3007 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3009 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3010 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3011 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3015 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3016 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3017 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3021 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3022 if (control == NULL) {
3023 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3027 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FOCUS_MODE, &msl_mode, NULL);
3028 converted_mode = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_FOCUS_MODE, msl_mode);
3030 if (gst_camera_control_get_focus(control, &cur_focus_mode, &cur_focus_range)) {
3031 if ((newVal != cur_focus_range) || (converted_mode != cur_focus_mode)) {
3032 if (gst_camera_control_set_focus(control, converted_mode, newVal)) {
3033 /*MMCAM_LOG_INFO("Succeed in setting AF mode[%d]", mslVal);*/
3036 MMCAM_LOG_WARNING("Failed to set AF mode[%d]", mslVal);
3039 /*MMCAM_LOG_INFO("No need to set AF mode. Current[%d]", mslVal);*/
3043 MMCAM_LOG_WARNING("Failed to get AF mode, so do not set new AF mode[%d]", mslVal);
3046 MMCAM_LOG_INFO("pointer of video src is null");
3053 bool _mmcamcorder_commit_camera_af_touch_area(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3055 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3056 _MMCamcorderSubContext *sc = NULL;
3057 GstCameraControl *control = NULL;
3058 GstCameraControlRectType set_area = { 0, 0, 0, 0 };
3059 GstCameraControlRectType get_area = { 0, 0, 0, 0 };
3061 int current_state = MM_CAMCORDER_STATE_NONE;
3063 int focus_mode = MM_CAMCORDER_FOCUS_MODE_NONE;
3065 gboolean do_set = FALSE;
3067 MMCamAttrsInfo info_y;
3068 MMCamAttrsInfo info_w;
3069 MMCamAttrsInfo info_h;
3071 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3073 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3077 MMCAM_LOG_INFO("(%d)", attr_idx);
3079 current_state = _mmcamcorder_get_state(handle);
3080 if (current_state < MM_CAMCORDER_STATE_PREPARE) {
3081 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3083 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3084 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3085 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3089 ret = mm_camcorder_get_attributes(handle, NULL,
3090 MMCAM_CAMERA_FOCUS_MODE, &focus_mode,
3092 if (ret != MM_ERROR_NONE) {
3093 MMCAM_LOG_WARNING("Failed to get FOCUS MODE.[%x]", ret);
3097 if ((focus_mode != MM_CAMCORDER_FOCUS_MODE_TOUCH_AUTO) && (focus_mode != MM_CAMCORDER_FOCUS_MODE_CONTINUOUS)) {
3098 MMCAM_LOG_WARNING("Focus mode is NOT TOUCH AUTO or CONTINUOUS(current[%d]). return FALSE", focus_mode);
3102 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3103 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3104 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3108 memset(&info_y, 0x0, sizeof(MMCamAttrsInfo));
3109 memset(&info_w, 0x0, sizeof(MMCamAttrsInfo));
3110 memset(&info_h, 0x0, sizeof(MMCamAttrsInfo));
3113 case MM_CAM_CAMERA_AF_TOUCH_X:
3114 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_Y, &info_y);
3115 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3116 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3117 if (!((info_y.flag|info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3118 set_area.x = value->value.i_val;
3119 mm_camcorder_get_attributes(handle, NULL,
3120 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3121 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3122 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3126 MMCAM_LOG_INFO("Just store AF area[x:%d]", value->value.i_val);
3130 case MM_CAM_CAMERA_AF_TOUCH_Y:
3131 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_WIDTH, &info_w);
3132 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3133 if (!((info_w.flag|info_h.flag) & MM_ATTRS_FLAG_MODIFIED)) {
3134 set_area.y = value->value.i_val;
3135 mm_camcorder_get_attributes(handle, NULL,
3136 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3137 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3138 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3142 MMCAM_LOG_INFO("Just store AF area[y:%d]", value->value.i_val);
3146 case MM_CAM_CAMERA_AF_TOUCH_WIDTH:
3147 mm_camcorder_get_attribute_info(handle, MMCAM_CAMERA_AF_TOUCH_HEIGHT, &info_h);
3148 if (!(info_h.flag & MM_ATTRS_FLAG_MODIFIED)) {
3149 set_area.width = value->value.i_val;
3150 mm_camcorder_get_attributes(handle, NULL,
3151 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3152 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3153 MMCAM_CAMERA_AF_TOUCH_HEIGHT, &set_area.height,
3157 MMCAM_LOG_INFO("Just store AF area[width:%d]", value->value.i_val);
3161 case MM_CAM_CAMERA_AF_TOUCH_HEIGHT:
3162 set_area.height = value->value.i_val;
3163 mm_camcorder_get_attributes(handle, NULL,
3164 MMCAM_CAMERA_AF_TOUCH_X, &set_area.x,
3165 MMCAM_CAMERA_AF_TOUCH_Y, &set_area.y,
3166 MMCAM_CAMERA_AF_TOUCH_WIDTH, &set_area.width,
3175 _MMCamcorderVideoInfo *info = sc->info_video;
3178 MMCAM_LOG_ERROR("video info is NULL");
3182 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3183 if (control == NULL) {
3184 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3189 if (current_state >= MM_CAMCORDER_STATE_RECORDING && info->support_dual_stream == FALSE &&
3190 (info->preview_width != info->video_width || info->preview_height != info->video_height)) {
3191 float ratio_width = 0.0;
3192 float ratio_height = 0.0;
3194 if (info->preview_width != 0 && info->preview_height != 0) {
3195 ratio_width = (float)info->video_width / (float)info->preview_width;
3196 ratio_height = (float)info->video_height / (float)info->preview_height;
3198 MMCAM_LOG_INFO("original area %d,%d,%dx%d, resolution ratio : width %f, height %f",
3199 set_area.x, set_area.y, set_area.width, set_area.height, ratio_width, ratio_height);
3201 set_area.x = (int)((float)set_area.x * ratio_width);
3202 set_area.y = (int)((float)set_area.y * ratio_height);
3203 set_area.width = (int)((float)set_area.width * ratio_width);
3204 set_area.height = (int)((float)set_area.height * ratio_height);
3206 if (set_area.width <= 0)
3209 if (set_area.height <= 0)
3210 set_area.height = 1;
3212 MMCAM_LOG_INFO("converted area %d,%d,%dx%d",
3213 set_area.x, set_area.y, set_area.width, set_area.height);
3215 MMCAM_LOG_WARNING("invalid preview size %dx%d, skip AF area converting",
3216 info->preview_width, info->preview_height);
3220 ret = gst_camera_control_get_auto_focus_area(control, &get_area);
3222 MMCAM_LOG_WARNING("Failed to get AF area");
3226 /* width and height are not supported now */
3227 if (get_area.x == set_area.x && get_area.y == set_area.y) {
3228 MMCAM_LOG_INFO("No need to set AF area[x,y:%d,%d]",
3229 get_area.x, get_area.y);
3233 ret = gst_camera_control_set_auto_focus_area(control, set_area);
3235 MMCAM_LOG_INFO("Succeed to set AF area[%d,%d,%dx%d]",
3236 set_area.x, set_area.y, set_area.width, set_area.height);
3239 MMCAM_LOG_WARNING("Failed to set AF area[%d,%d,%dx%d]",
3240 set_area.x, set_area.y, set_area.width, set_area.height);
3244 MMCAM_LOG_INFO("pointer of video src is null");
3251 bool _mmcamcorder_commit_camera_capture_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3253 GstCameraControl *control = NULL;
3259 int exposure_type = 0;
3260 int current_state = MM_CAMCORDER_STATE_NONE;
3261 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3262 _MMCamcorderSubContext *sc = NULL;
3264 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3265 gboolean check_scene_mode = FALSE;
3267 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3269 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3273 /* check whether set or not */
3274 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3275 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3279 current_state = _mmcamcorder_get_state(handle);
3280 if (current_state < MM_CAMCORDER_STATE_READY) {
3281 MMCAM_LOG_INFO("will be applied when preview starts");
3283 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3284 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3285 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3289 ivalue = value->value.i_val;
3291 if (attr_idx == MM_CAM_CAMERA_F_NUMBER) {
3292 exposure_type = GST_CAMERA_CONTROL_F_NUMBER;
3293 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3294 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3295 } else if (attr_idx == MM_CAM_CAMERA_SHUTTER_SPEED) {
3296 exposure_type = GST_CAMERA_CONTROL_SHUTTER_SPEED;
3297 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3298 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3299 } else if (attr_idx == MM_CAM_CAMERA_ISO) {
3300 exposure_type = GST_CAMERA_CONTROL_ISO;
3302 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3303 check_scene_mode = TRUE;
3304 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_MODE) {
3305 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_MODE;
3307 newVal1 = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal1);
3308 check_scene_mode = TRUE;
3309 } else if (attr_idx == MM_CAM_CAMERA_EXPOSURE_VALUE) {
3310 exposure_type = GST_CAMERA_CONTROL_EXPOSURE_VALUE;
3311 mslVal1 = newVal1 = MM_CAMCORDER_GET_NUMERATOR(ivalue);
3312 mslVal2 = newVal2 = MM_CAMCORDER_GET_DENOMINATOR(ivalue);
3315 if (check_scene_mode) {
3316 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3317 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3318 MMCAM_LOG_WARNING("can not set [%d] when scene mode is NOT normal.", attr_idx);
3323 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3326 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3327 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3331 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3332 if (control == NULL) {
3333 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3337 ret = gst_camera_control_set_exposure(control, exposure_type, newVal1, newVal2);
3339 MMCAM_LOG_INFO("Succeed in setting exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3342 MMCAM_LOG_WARNING("Failed to set exposure. Type[%d],value1[%d],value2[%d]", exposure_type, mslVal1, mslVal2);
3345 MMCAM_LOG_INFO("pointer of video src is null");
3352 bool _mmcamcorder_commit_camera_wdr(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3354 GstCameraControl *control = NULL;
3358 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3359 _MMCamcorderSubContext *sc = NULL;
3360 int current_state = MM_CAMCORDER_STATE_NONE;
3362 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3364 /* check whether set or not */
3365 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3366 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3370 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3374 /* check current state */
3375 current_state = _mmcamcorder_get_state(handle);
3376 if (current_state < MM_CAMCORDER_STATE_READY) {
3377 MMCAM_LOG_INFO("will be applied when preview starts");
3379 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3380 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3381 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3385 mslVal = value->value.i_val;
3386 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_CAMERA_WDR, mslVal);
3388 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3389 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3390 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3394 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3395 if (control == NULL) {
3396 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3400 if (gst_camera_control_get_wdr(control, &cur_value)) {
3401 if (newVal != cur_value) {
3402 if (gst_camera_control_set_wdr(control, newVal)) {
3403 MMCAM_LOG_INFO("Success - set wdr[%d]", mslVal);
3406 MMCAM_LOG_WARNING("Failed to set WDR. NewVal[%d],CurVal[%d]", newVal, cur_value);
3409 MMCAM_LOG_INFO("No need to set new WDR. Current[%d]", mslVal);
3413 MMCAM_LOG_WARNING("Failed to get WDR.");
3416 MMCAM_LOG_INFO("pointer of video src is null");
3423 bool _mmcamcorder_commit_camera_anti_handshake(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3425 int current_state = MM_CAMCORDER_STATE_NONE;
3426 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3428 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3430 /* check whether set or not */
3431 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3432 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3436 current_state = _mmcamcorder_get_state(handle);
3437 if (current_state < MM_CAMCORDER_STATE_READY) {
3438 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3440 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3441 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3442 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3446 return _mmcamcorder_set_videosrc_anti_shake(handle, value->value.i_val);
3450 bool _mmcamcorder_commit_encoder_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3454 int current_state = MM_CAMCORDER_STATE_NONE;
3455 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3456 _MMCamcorderSubContext *sc = NULL;
3458 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3460 bitrate = value->value.i_val;
3462 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3463 if (!sc || !sc->encode_element) {
3464 MMCAM_LOG_INFO("will be applied later - idx %d, bitrate %d", attr_idx, bitrate);
3468 current_state = _mmcamcorder_get_state(handle);
3469 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3470 MMCAM_LOG_ERROR("Can not set while RECORDING - attr idx %d", attr_idx);
3471 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3475 if (attr_idx == MM_CAM_AUDIO_ENCODER_BITRATE) {
3476 mm_camcorder_get_attributes(handle, NULL, MMCAM_AUDIO_ENCODER, &audio_enc, NULL);
3478 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
3479 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
3481 _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
3482 bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
3489 bool _mmcamcorder_commit_camera_video_stabilization(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3491 int current_state = MM_CAMCORDER_STATE_NONE;
3492 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3494 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3496 current_state = _mmcamcorder_get_state(handle);
3497 if (current_state < MM_CAMCORDER_STATE_READY) {
3498 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3500 } else if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3501 MMCAM_LOG_ERROR("Invalid state (state %d)", current_state);
3502 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3506 return _mmcamcorder_set_videosrc_stabilization(handle, value->value.i_val);
3510 bool _mmcamcorder_commit_camera_rotate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3512 int current_state = MM_CAMCORDER_STATE_NONE;
3513 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3515 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3517 MMCAM_LOG_INFO("rotate(%d)", value->value.i_val);
3519 current_state = _mmcamcorder_get_state(handle);
3521 if (current_state > MM_CAMCORDER_STATE_READY) {
3522 MMCAM_LOG_ERROR("camera rotation setting failed.(state=%d)", current_state);
3523 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3526 return _mmcamcorder_set_videosrc_rotation(handle, value->value.i_val);
3531 bool _mmcamcorder_commit_image_encoder_quality(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3533 int current_state = MM_CAMCORDER_STATE_NONE;
3535 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3536 _MMCamcorderSubContext *sc = NULL;
3538 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3541 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3542 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3546 /* check current state */
3547 current_state = _mmcamcorder_get_state(handle);
3548 if (current_state < MM_CAMCORDER_STATE_READY) {
3549 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3551 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3552 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3553 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3557 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3559 MMCAM_LOG_INFO("Image encoder quality(%d)", value->value.i_val);
3561 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
3562 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", value->value.i_val);
3565 MMCAM_LOG_ERROR("invalid state %d", current_state);
3571 bool _mmcamcorder_commit_target_filename(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3573 mmf_return_val_if_fail(handle && value, FALSE);
3576 if (!value->value.s_val) {
3577 MMCAM_LOG_ERROR("NULL filename");
3581 MMCAM_LOG_INFO("set filename [%s]", value->value.s_val);
3587 bool _mmcamcorder_commit_recording_max_limit(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3589 int current_state = MM_CAMCORDER_STATE_NONE;
3590 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3592 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3594 current_state = _mmcamcorder_get_state(handle);
3595 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
3596 MMCAM_LOG_ERROR("Can not set while RECORDING");
3597 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3605 static int __color_channel_item_compare_func(gconstpointer data, gconstpointer user_data)
3607 GstColorBalanceChannel *Colorchannel = (GstColorBalanceChannel *)data;
3608 MMCAM_LOG_VERBOSE("check[%s], input[%s]", Colorchannel->label, (char *)user_data);
3609 return strcmp(Colorchannel->label, user_data);
3612 bool _mmcamcorder_commit_filter(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3614 GstColorBalance *balance = NULL;
3615 GstColorBalanceChannel *Colorchannel = NULL;
3616 GList *controls = NULL;
3620 int current_state = MM_CAMCORDER_STATE_NONE;
3621 const char *control_label = NULL;
3622 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3623 _MMCamcorderSubContext *sc = NULL;
3625 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
3626 gboolean check_scene_mode = FALSE;
3628 int wb_temp_table[] = {
3629 [MM_CAMCORDER_WHITE_BALANCE_DAYLIGHT] = 5200,
3630 [MM_CAMCORDER_WHITE_BALANCE_CLOUDY] = 6000,
3631 [MM_CAMCORDER_WHITE_BALANCE_FLUORESCENT] = 4000,
3632 [MM_CAMCORDER_WHITE_BALANCE_INCANDESCENT] = 3200,
3633 [MM_CAMCORDER_WHITE_BALANCE_SHADE] = 7000,
3634 [MM_CAMCORDER_WHITE_BALANCE_FLASH] = 6000
3637 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3639 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3643 /* check whether set or not */
3644 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3645 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3649 current_state = _mmcamcorder_get_state(handle);
3650 if (current_state < MM_CAMCORDER_STATE_READY) {
3651 MMCAM_LOG_INFO("will be applied when preview starts");
3653 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3654 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3655 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3659 if (value->type != MM_ATTRS_TYPE_INT) {
3660 MMCAM_LOG_WARNING("Mismatched value type (%d)", value->type);
3664 mslVal = value->value.i_val;
3667 case MM_CAM_FILTER_BRIGHTNESS:
3668 control_label = "brightness";
3669 check_scene_mode = TRUE;
3671 case MM_CAM_FILTER_CONTRAST:
3672 control_label = "contrast";
3674 case MM_CAM_FILTER_WB:
3675 control_label = "white balance";
3676 check_scene_mode = TRUE;
3678 case MM_CAM_FILTER_COLOR_TONE:
3679 control_label = "color tone";
3681 case MM_CAM_FILTER_SATURATION:
3682 control_label = "saturation";
3683 check_scene_mode = TRUE;
3685 case MM_CAM_FILTER_HUE:
3686 control_label = "hue";
3688 case MM_CAM_FILTER_SHARPNESS:
3689 control_label = "sharpness";
3690 check_scene_mode = TRUE;
3693 MMCAM_LOG_ERROR("unknown attribute index %d", attr_idx);
3697 if (check_scene_mode) {
3698 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
3699 if (scene_mode != MM_CAMCORDER_SCENE_MODE_NORMAL) {
3700 MMCAM_LOG_WARNING("can not set %s when scene mode is NOT normal.", control_label);
3705 newVal = _mmcamcorder_convert_msl_to_sensor(handle, attr_idx, mslVal);
3706 if (newVal == _MMCAMCORDER_SENSOR_ENUM_NONE)
3709 if (!GST_IS_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3710 MMCAM_LOG_INFO("Can't cast Video source into color balance.");
3714 balance = GST_COLOR_BALANCE(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3715 if (balance == NULL) {
3716 MMCAM_LOG_ERROR("cast COLOR_BALANCE failed");
3720 controls = (GList *)gst_color_balance_list_channels(balance);
3721 if (controls == NULL) {
3722 MMCAM_LOG_INFO("There is no list of colorbalance controls");
3727 MMCAM_LOG_DEBUG("attr[%d] label[%s]: MSL[%d] -> Sensor[%d]",
3728 attr_idx, control_label, mslVal, newVal);
3730 item = g_list_find_custom(controls, control_label, __color_channel_item_compare_func);
3732 Colorchannel = item->data;
3733 gst_color_balance_set_value(balance, Colorchannel, newVal);
3734 MMCAM_LOG_INFO("Set complete - %s[msl:%d,real:%d]", Colorchannel->label, mslVal, newVal);
3738 if (attr_idx == MM_CAM_FILTER_WB && !strcmp(control_label, "white balance")) {
3739 if (mslVal == MM_CAMCORDER_WHITE_BALANCE_AUTOMATIC) {
3741 control_label = "white_balance_temperature_auto";
3744 newVal = wb_temp_table[mslVal];
3745 control_label = "white_balance_temperature";
3750 MMCAM_LOG_ERROR("failed to find color channel item");
3756 bool _mmcamcorder_commit_filter_scene_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3760 int current_state = MM_CAMCORDER_STATE_NONE;
3761 GstCameraControl *control = NULL;
3762 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3763 _MMCamcorderSubContext *sc = NULL;
3765 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3767 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3771 mslVal = value->value.i_val;
3772 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_FILTER_SCENE_MODE, mslVal);
3774 /* check whether set or not */
3775 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
3776 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
3780 current_state = _mmcamcorder_get_state(handle);
3781 if (current_state < MM_CAMCORDER_STATE_READY) {
3782 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
3784 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
3785 MMCAM_LOG_ERROR("Can not set while CAPTURING");
3786 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3790 if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
3793 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
3794 MMCAM_LOG_INFO("Can't cast Video source into camera control.");
3798 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
3799 if (control == NULL) {
3800 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
3804 ret = gst_camera_control_set_exposure(control, GST_CAMERA_CONTROL_PROGRAM_MODE, newVal, 0);
3806 MMCAM_LOG_INFO("Succeed in setting program mode[%d].", mslVal);
3808 if (mslVal == MM_CAMCORDER_SCENE_MODE_NORMAL) {
3812 MM_CAM_FILTER_BRIGHTNESS,
3814 MM_CAM_FILTER_SATURATION,
3815 MM_CAM_FILTER_SHARPNESS,
3816 MM_CAM_FILTER_COLOR_TONE,
3817 MM_CAM_CAMERA_EXPOSURE_MODE
3819 MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
3821 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
3822 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
3823 mm_attrs_set_modified(attrs, attr_idxs[i]);
3829 MMCAM_LOG_INFO("Failed to set program mode[%d].", mslVal);
3832 MMCAM_LOG_WARNING("pointer of video src is null");
3839 bool _mmcamcorder_commit_filter_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3841 mmf_return_val_if_fail(handle && value, FALSE);
3843 MMCAM_LOG_WARNING("Filter Flip(%d)", value->value.i_val);
3849 bool _mmcamcorder_commit_audio_input_route(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3851 mmf_return_val_if_fail(handle && value, FALSE);
3853 MMCAM_LOG_INFO("Commit : Do nothing. this attr will be removed soon.");
3859 bool _mmcamcorder_commit_audio_disable(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3861 int current_state = MM_CAMCORDER_STATE_NONE;
3862 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3864 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3866 current_state = _mmcamcorder_get_state(handle);
3867 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
3868 MMCAM_LOG_WARNING("Can NOT Disable AUDIO. invalid state %d", current_state);
3869 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
3872 MMCAM_LOG_INFO("Disable AUDIO when Recording");
3878 bool _mmcamcorder_commit_display_handle(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3880 int current_state = MM_CAMCORDER_STATE_NONE;
3881 const char *videosink_name = NULL;
3882 void *dp_handle = NULL;
3883 MMCamWindowInfo *window_info = NULL;
3885 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3886 _MMCamcorderSubContext *sc = NULL;
3888 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3891 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3892 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3896 /* check current state */
3897 current_state = _mmcamcorder_get_state(handle);
3898 if (current_state < MM_CAMCORDER_STATE_READY) {
3899 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3903 dp_handle = value->value.p_val;
3905 MMCAM_LOG_WARNING("Display handle is NULL");
3909 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3911 /* get videosink name */
3912 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3913 if (!videosink_name) {
3914 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3918 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3920 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
3921 MMCAM_LOG_INFO("Commit : Set XID[%x]", *(int *)(dp_handle));
3922 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), *(int *)(dp_handle));
3923 } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
3924 MMCAM_LOG_INFO("Commit : Set evas object [%p]", dp_handle);
3925 MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "evas-object", dp_handle);
3926 } else if (!strcmp(videosink_name, "tizenwlsink")) {
3927 window_info = (MMCamWindowInfo *)dp_handle;
3928 MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
3929 gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3930 } else if (!strcmp(videosink_name, "directvideosink")) {
3931 window_info = (MMCamWindowInfo *)dp_handle;
3932 MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
3933 window_info->surface_id,
3934 window_info->rect.x,
3935 window_info->rect.y,
3936 window_info->rect.width,
3937 window_info->rect.height);
3938 gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), (guintptr)window_info->surface_id);
3939 gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
3940 window_info->rect.x,
3941 window_info->rect.y,
3942 window_info->rect.width,
3943 window_info->rect.height);
3945 MMCAM_LOG_WARNING("Commit : Nothing to commit with this element[%s]", videosink_name);
3953 bool _mmcamcorder_commit_display_mode(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3955 int current_state = MM_CAMCORDER_STATE_NONE;
3956 const char *videosink_name = NULL;
3958 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
3959 _MMCamcorderSubContext *sc = NULL;
3961 mmf_return_val_if_fail(hcamcorder && value, FALSE);
3964 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
3965 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
3969 /* check current state */
3970 current_state = _mmcamcorder_get_state(handle);
3971 if (current_state < MM_CAMCORDER_STATE_READY) {
3972 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
3976 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
3978 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
3979 if (videosink_name == NULL) {
3980 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
3984 MMCAM_LOG_INFO("Commit : videosinkname[%s]", videosink_name);
3986 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
3987 MMCAM_LOG_INFO("Commit : display mode [%d]", value->value.i_val);
3988 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-mode", value->value.i_val);
3990 MMCAM_LOG_WARNING("[%s] does not support display mode, but no error", videosink_name);
3997 bool _mmcamcorder_commit_display_rotation(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
3999 int current_state = MM_CAMCORDER_STATE_NONE;
4001 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4003 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4006 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4007 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4011 /* check current state */
4012 current_state = _mmcamcorder_get_state(handle);
4013 if (current_state < MM_CAMCORDER_STATE_READY) {
4014 MMCAM_LOG_INFO("NOT initialized. this will be applied later [rotate:%d]", value->value.i_val);
4018 return _mmcamcorder_set_display_rotation(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4022 bool _mmcamcorder_commit_display_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4024 int current_state = MM_CAMCORDER_STATE_NONE;
4026 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4028 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4031 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4032 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4036 /* check current state */
4037 current_state = _mmcamcorder_get_state(handle);
4038 if (current_state < MM_CAMCORDER_STATE_READY) {
4039 MMCAM_LOG_INFO("NOT initialized. this will be applied later [flip:%d]", value->value.i_val);
4043 return _mmcamcorder_set_display_flip(handle, value->value.i_val, _MMCAMCORDER_VIDEOSINK_SINK);
4047 bool _mmcamcorder_commit_display_visible(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4049 int current_state = MM_CAMCORDER_STATE_NONE;
4050 const char *videosink_name = NULL;
4052 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4053 _MMCamcorderSubContext *sc = NULL;
4055 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4058 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4059 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4063 /* check current state */
4064 current_state = _mmcamcorder_get_state(handle);
4065 if (current_state < MM_CAMCORDER_STATE_READY) {
4066 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4070 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4072 /* Get videosink name */
4073 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4074 if (videosink_name == NULL) {
4075 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4079 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4080 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4081 !strcmp(videosink_name, "directvideosink")) {
4082 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "visible", value->value.i_val);
4083 MMCAM_LOG_INFO("Set visible [%d] done.", value->value.i_val);
4085 MMCAM_LOG_WARNING("[%s] does not support VISIBLE, but no error", videosink_name);
4092 bool _mmcamcorder_commit_display_geometry_method(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4095 int current_state = MM_CAMCORDER_STATE_NONE;
4096 const char *videosink_name = NULL;
4098 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4099 _MMCamcorderSubContext *sc = NULL;
4101 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4104 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4105 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4109 /* check current state */
4110 current_state = _mmcamcorder_get_state(handle);
4111 if (current_state < MM_CAMCORDER_STATE_READY) {
4112 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4116 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4118 /* Get videosink name */
4119 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4120 if (videosink_name == NULL) {
4121 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4125 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4126 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "evasimagesink") ||
4127 !strcmp(videosink_name, "directvideosink")) {
4128 method = value->value.i_val;
4129 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "display-geometry-method", method);
4131 MMCAM_LOG_WARNING("[%s] does not support geometry method, but no error", videosink_name);
4138 bool _mmcamcorder_commit_display_rect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4140 int current_state = MM_CAMCORDER_STATE_NONE;
4141 int ret = MM_ERROR_NONE;
4142 const char *videosink_name = NULL;
4144 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4145 _MMCamcorderSubContext *sc = NULL;
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");
4162 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4164 /* Get videosink name */
4165 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4166 if (videosink_name == NULL) {
4167 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4171 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
4172 !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
4176 int rect_height = 0;
4177 int flags = MM_ATTRS_FLAG_NONE;
4178 MMCamAttrsInfo info;
4180 mm_camcorder_get_attributes(handle, NULL,
4181 MMCAM_DISPLAY_RECT_X, &rect_x,
4182 MMCAM_DISPLAY_RECT_Y, &rect_y,
4183 MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
4184 MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
4187 case MM_CAM_DISPLAY_RECT_X:
4188 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_Y, &info);
4190 memset(&info, 0x00, sizeof(info));
4191 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4193 memset(&info, 0x00, sizeof(info));
4194 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4197 rect_x = value->value.i_val;
4199 case MM_CAM_DISPLAY_RECT_Y:
4200 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_WIDTH, &info);
4202 memset(&info, 0x00, sizeof(info));
4203 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4206 rect_y = value->value.i_val;
4208 case MM_CAM_DISPLAY_RECT_WIDTH:
4209 mm_camcorder_get_attribute_info(handle, MMCAM_DISPLAY_RECT_HEIGHT, &info);
4212 rect_width = value->value.i_val;
4214 case MM_CAM_DISPLAY_RECT_HEIGHT:
4215 rect_height = value->value.i_val;
4218 MMCAM_LOG_ERROR("Wrong attr_idx!");
4222 if (!(flags & MM_ATTRS_FLAG_MODIFIED)) {
4223 MMCAM_LOG_INFO("RECT(x,y,w,h) = (%d,%d,%d,%d)", rect_x, rect_y, rect_width, rect_height);
4225 if (!strcmp(videosink_name, "tizenwlsink")) {
4226 ret = gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst),
4227 rect_x, rect_y, rect_width, rect_height);
4229 MMCAM_LOG_ERROR("FAILED : could not set display roi area.");
4233 g_object_set(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
4234 "dst-roi-x", rect_x,
4235 "dst-roi-y", rect_y,
4236 "dst-roi-w", rect_width,
4237 "dst-roi-h", rect_height,
4242 MMCAM_LOG_WARNING("[%s] does not support display rect, but no error", videosink_name);
4249 bool _mmcamcorder_commit_display_scale(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4252 int current_state = MM_CAMCORDER_STATE_NONE;
4253 const char *videosink_name = NULL;
4254 GstElement *vs_element = NULL;
4256 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4257 _MMCamcorderSubContext *sc = NULL;
4259 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4262 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4263 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4267 /* check current state */
4268 current_state = _mmcamcorder_get_state(handle);
4269 if (current_state < MM_CAMCORDER_STATE_READY) {
4270 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4274 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4276 /* Get videosink name */
4277 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4278 if (videosink_name == NULL) {
4279 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4283 zoom = value->value.i_val;
4284 if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink")) {
4285 vs_element = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
4287 MMCAMCORDER_G_OBJECT_SET(vs_element, "zoom", (float)(zoom + 1));
4288 MMCAM_LOG_INFO("Set display zoom to %d", zoom + 1);
4292 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4298 bool _mmcamcorder_commit_display_evas_do_scaling(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4300 int current_state = MM_CAMCORDER_STATE_NONE;
4302 const char *videosink_name = NULL;
4304 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4305 _MMCamcorderSubContext *sc = NULL;
4307 mmf_return_val_if_fail(handle && value, FALSE);
4310 if (hcamcorder->type == MM_CAMCORDER_MODE_AUDIO) {
4311 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4315 /* check current state */
4316 current_state = _mmcamcorder_get_state(handle);
4317 if (current_state < MM_CAMCORDER_STATE_READY) {
4318 MMCAM_LOG_INFO("NOT initialized. this will be applied later");
4322 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4324 do_scaling = value->value.i_val;
4326 /* Get videosink name */
4327 _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
4328 if (videosink_name == NULL) {
4329 MMCAM_LOG_ERROR("Please check videosink element in configuration file");
4333 if (!strcmp(videosink_name, "evaspixmapsink")) {
4334 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "origin-size", !do_scaling);
4335 MMCAM_LOG_INFO("Set origin-size to %d", !(value->value.i_val));
4338 MMCAM_LOG_WARNING("videosink[%s] does not support scale", videosink_name);
4344 bool _mmcamcorder_commit_strobe(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4346 _MMCamcorderSubContext *sc = NULL;
4347 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4348 int strobe_type, mslVal, newVal, cur_value;
4349 int current_state = MM_CAMCORDER_STATE_NONE;
4351 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4353 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4357 /*MMCAM_LOG_INFO( "Commit : strobe attribute(%d)", attr_idx );*/
4359 mslVal = value->value.i_val;
4361 /* check flash state */
4362 if (attr_idx == MM_CAM_STROBE_MODE) {
4363 int led_brightness = 0;
4365 if (_mmcamcorder_get_device_led_brightness(hcamcorder->gdbus_conn, &led_brightness) != MM_ERROR_NONE) {
4366 MMCAM_LOG_ERROR("_mmcamcorder_get_device_led_brightness failed");
4367 hcamcorder->error_code = MM_ERROR_COMMON_INVALID_PERMISSION;
4371 MMCAM_LOG_INFO("LED brightness[%d] from deviced", led_brightness);
4373 if (led_brightness > 0 &&
4374 mslVal != MM_CAMCORDER_STROBE_MODE_OFF) {
4375 /* other module already turned on LED */
4376 hcamcorder->error_code = MM_ERROR_CAMCORDER_DEVICE_BUSY;
4377 MMCAM_LOG_ERROR("other module already turned on LED. avoid to set strobe mode here.");
4381 MMCAM_LOG_INFO("keep going");
4385 current_state = _mmcamcorder_get_state(handle);
4386 if (current_state < MM_CAMCORDER_STATE_READY) {
4387 MMCAM_LOG_INFO("It doesn't need to change dynamically.(state=%d)", current_state);
4389 } else if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4390 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4391 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4396 case MM_CAM_STROBE_CONTROL:
4397 strobe_type = GST_CAMERA_CONTROL_STROBE_CONTROL;
4398 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_CONTROL, mslVal);
4400 case MM_CAM_STROBE_CAPABILITIES:
4401 strobe_type = GST_CAMERA_CONTROL_STROBE_CAPABILITIES;
4404 case MM_CAM_STROBE_MODE:
4405 /* check whether set or not */
4406 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4407 MMCAM_LOG_INFO("skip set value %d", mslVal);
4411 strobe_type = GST_CAMERA_CONTROL_STROBE_MODE;
4412 newVal = _mmcamcorder_convert_msl_to_sensor(handle, MM_CAM_STROBE_MODE, mslVal);
4414 case MM_CAM_STROBE_BRIGHTNESS:
4415 strobe_type = GST_CAMERA_CONTROL_STROBE_BRIGHTNESS;
4419 MMCAM_LOG_ERROR("invalid attribute[%d]", attr_idx);
4423 GstCameraControl *control = NULL;
4424 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4425 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4429 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4430 if (control == NULL) {
4431 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4435 if (!gst_camera_control_get_strobe(control, strobe_type, &cur_value)) {
4436 MMCAM_LOG_WARNING("Failed to get strobe. Type[%d]", strobe_type);
4440 if (newVal == cur_value) {
4441 MMCAM_LOG_INFO("No need to set strobe. Type[%d],value[%d]", strobe_type, mslVal);
4445 if (!gst_camera_control_set_strobe(control, strobe_type, newVal)) {
4446 MMCAM_LOG_WARNING("Set strobe failed. Type[%d],value[%d]", strobe_type, mslVal);
4450 MMCAM_LOG_INFO("Succeed in setting strobe. Type[%d],value[%d]", strobe_type, mslVal);
4456 bool _mmcamcorder_commit_camera_flip(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4459 int current_state = MM_CAMCORDER_STATE_NONE;
4460 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4462 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4464 MMCAM_LOG_INFO("Commit : flip %d", value->value.i_val);
4467 current_state = _mmcamcorder_get_state(handle);
4468 if (current_state > MM_CAMCORDER_STATE_READY) {
4469 MMCAM_LOG_ERROR("Can not set camera FLIP horizontal at state %d", current_state);
4470 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4472 } else if (current_state < MM_CAMCORDER_STATE_READY) {
4473 MMCAM_LOG_INFO("Pipeline is not created yet. This will be set when create pipeline.");
4477 ret = _mmcamcorder_set_videosrc_flip(handle, value->value.i_val);
4479 MMCAM_LOG_INFO("ret %d", ret);
4485 bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4487 int set_hdr_mode = MM_CAMCORDER_HDR_OFF;
4488 int current_state = MM_CAMCORDER_STATE_NONE;
4489 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4490 _MMCamcorderSubContext *sc = NULL;
4492 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4494 /*MMCAM_LOG_INFO("Commit : HDR Capture %d", value->value.i_val);*/
4496 /* check whether set or not */
4497 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4498 MMCAM_LOG_INFO("skip set value %d", value->value.i_val);
4503 current_state = _mmcamcorder_get_state(handle);
4504 if (current_state > MM_CAMCORDER_STATE_PREPARE) {
4505 MMCAM_LOG_ERROR("can NOT set HDR capture at state %d", current_state);
4506 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4510 if (current_state >= MM_CAMCORDER_STATE_READY) {
4511 int current_value = 0;
4513 set_hdr_mode = value->value.i_val;
4514 mm_camcorder_get_attributes(handle, NULL,
4515 MMCAM_CAMERA_HDR_CAPTURE, ¤t_value,
4518 if (set_hdr_mode == current_value) {
4519 MMCAM_LOG_INFO("same HDR value : %d, do nothing", set_hdr_mode);
4523 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4525 if (current_state == MM_CAMCORDER_STATE_PREPARE) {
4526 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", TRUE);
4527 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", TRUE);
4529 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_READY);
4531 /* check decoder recreation */
4532 if (!_mmcamcorder_recreate_decoder_for_encoded_preview(handle)) {
4533 MMCAM_LOG_ERROR("_mmcamcorder_recreate_decoder_for_encoded_preview failed");
4537 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "empty-buffers", FALSE);
4538 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "empty-buffers", FALSE);
4541 set_hdr_mode = value->value.i_val;
4542 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", set_hdr_mode);
4543 sc->info_image->hdr_capture_mode = set_hdr_mode;
4544 MMCAM_LOG_INFO("set HDR mode : %d", set_hdr_mode);
4546 if (current_state == MM_CAMCORDER_STATE_PREPARE)
4547 _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_MAIN_PIPE].gst, GST_STATE_PLAYING);
4549 MMCAM_LOG_ERROR("sc is NULL. can not set HDR capture");
4558 bool _mmcamcorder_commit_detect(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4561 _MMCamcorderSubContext *sc = NULL;
4562 int detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4564 int current_value = 0;
4565 int current_state = MM_CAMCORDER_STATE_NONE;
4566 GstCameraControl *control = NULL;
4568 mmf_return_val_if_fail(handle && value, FALSE);
4570 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4574 /*MMCAM_LOG_INFO("Commit : detect attribute(%d)", attr_idx);*/
4577 current_state = _mmcamcorder_get_state(handle);
4578 if (current_state < MM_CAMCORDER_STATE_READY) {
4579 MMCAM_LOG_INFO("will be applied when preview starts");
4583 set_value = value->value.i_val;
4586 case MM_CAM_DETECT_MODE:
4587 /* check whether set or not */
4588 if (!_mmcamcorder_check_supported_attribute(handle, attr_idx)) {
4589 MMCAM_LOG_INFO("skip set value %d", set_value);
4593 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_MODE;
4595 case MM_CAM_DETECT_NUMBER:
4596 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_NUMBER;
4598 case MM_CAM_DETECT_FOCUS_SELECT:
4599 detect_type = GST_CAMERA_CONTROL_FACE_FOCUS_SELECT;
4601 case MM_CAM_DETECT_SELECT_NUMBER:
4602 detect_type = GST_CAMERA_CONTROL_FACE_SELECT_NUMBER;
4604 case MM_CAM_DETECT_STATUS:
4605 detect_type = GST_CAMERA_CONTROL_FACE_DETECT_STATUS;
4608 MMCAM_LOG_ERROR("Commit : strobe attribute(attr_idx(%d) is out of range)", attr_idx);
4612 if (!GST_IS_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst)) {
4613 MMCAM_LOG_ERROR("Can't cast Video source into camera control.");
4616 control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
4617 if (control == NULL) {
4618 MMCAM_LOG_ERROR("cast CAMERA_CONTROL failed");
4622 if (gst_camera_control_get_detect(control, detect_type, ¤t_value)) {
4623 if (current_value == set_value) {
4624 MMCAM_LOG_INFO("No need to set detect(same). Type[%d],value[%d]", detect_type, set_value);
4627 if (!gst_camera_control_set_detect(control, detect_type, set_value)) {
4628 MMCAM_LOG_WARNING("Set detect failed. Type[%d],value[%d]",
4629 detect_type, set_value);
4632 MMCAM_LOG_INFO("Set detect success. Type[%d],value[%d]",
4633 detect_type, set_value);
4638 MMCAM_LOG_WARNING("Get detect failed. Type[%d]", detect_type);
4647 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4649 int current_state = MM_CAMCORDER_STATE_NONE;
4650 int preview_format = MM_PIXEL_FORMAT_NV12;
4652 mmf_return_val_if_fail(handle && value, FALSE);
4654 MMCAM_LOG_INFO("Commit : encoded preview bitrate - %d", value->value.i_val);
4656 /* check preview format */
4657 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4658 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
4659 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4664 current_state = _mmcamcorder_get_state(handle);
4665 if (current_state < MM_CAMCORDER_STATE_READY) {
4666 MMCAM_LOG_INFO("will be applied when preview starts");
4670 return _mmcamcorder_set_encoded_preview_bitrate(handle, value->value.i_val);
4674 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4676 int current_state = MM_CAMCORDER_STATE_NONE;
4677 int preview_format = MM_PIXEL_FORMAT_NV12;
4679 mmf_return_val_if_fail(handle && value, FALSE);
4681 MMCAM_LOG_INFO("Commit : encoded preview I-frame interval - %d", value->value.i_val);
4683 /* check preview format */
4684 mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
4685 if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
4686 MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
4691 current_state = _mmcamcorder_get_state(handle);
4692 if (current_state < MM_CAMCORDER_STATE_READY) {
4693 MMCAM_LOG_INFO("will be applied when preview starts");
4697 return _mmcamcorder_set_encoded_preview_gop_interval(handle, value->value.i_val);
4701 bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4703 int stream_index = 0;
4704 char *stream_type = NULL;
4705 _MMCamcorderSubContext *sc = NULL;
4707 mmf_return_val_if_fail(handle && value, FALSE);
4709 stream_type = value->value.s_val;
4711 MMCAM_LOG_ERROR("NULL string");
4715 mm_camcorder_get_attributes(handle, NULL,
4716 MMCAM_SOUND_STREAM_INDEX, &stream_index,
4718 if (stream_index < 0) {
4719 MMCAM_LOG_ERROR("invalid stream index %d", stream_index);
4723 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4724 if (!sc || !sc->encode_element ||
4725 !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
4726 MMCAM_LOG_WARNING("audiosrc element is not initialized, it will be set later");
4730 MMCAM_LOG_WARNING("Commit : sound stream info - type %s, index %d", stream_type, stream_index);
4732 return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
4736 bool _mmcamcorder_commit_tag(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4738 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4739 int current_state = MM_CAMCORDER_STATE_NONE;
4741 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4743 current_state = _mmcamcorder_get_state(handle);
4744 if (current_state == MM_CAMCORDER_STATE_CAPTURING) {
4745 MMCAM_LOG_ERROR("Can not set while CAPTURING");
4746 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4753 bool _mmcamcorder_commit_audio_replay_gain(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4755 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4757 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4759 if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_ENABLE) {
4760 /* Replay gain enable */
4761 int current_state = MM_CAMCORDER_STATE_NONE;
4762 int audio_disable = FALSE;
4764 current_state = _mmcamcorder_get_state(handle);
4765 if (current_state >= MM_CAMCORDER_STATE_RECORDING) {
4766 MMCAM_LOG_ERROR("Can not set replay gain enable [state : %d]", current_state);
4767 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_STATE;
4771 mm_camcorder_get_attributes(handle, NULL,
4772 MMCAM_AUDIO_DISABLE, &audio_disable,
4775 if (audio_disable) {
4776 MMCAM_LOG_ERROR("audio is disabled");
4777 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4781 MMCAM_LOG_INFO("set replay gain enable : %d", value->value.i_val);
4782 } else if (attr_idx == MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL) {
4783 /* Replay gain reference level */
4784 int replay_gain_enable = FALSE;
4786 mm_camcorder_get_attributes(handle, NULL,
4787 MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
4790 if (replay_gain_enable == FALSE) {
4791 MMCAM_LOG_ERROR("replay gain is disabled");
4792 hcamcorder->error_code = MM_ERROR_CAMCORDER_INVALID_CONDITION;
4796 MMCAM_LOG_INFO("set reference level for replay gain : %lf dB", value->value.d_val);
4798 MMCAM_LOG_ERROR("unknown attribute id %d", attr_idx);
4806 bool _mmcamcorder_commit_extra_preview(MMHandleType handle, int attr_idx, const MMAttrsValue *value)
4808 int current_state = MM_CAMCORDER_STATE_NONE;
4809 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4810 _MMCamcorderSubContext *sc = NULL;
4812 mmf_return_val_if_fail(hcamcorder && value, FALSE);
4814 if (hcamcorder->type != MM_CAMCORDER_MODE_VIDEO_CAPTURE) {
4815 MMCAM_LOG_ERROR("invalid mode %d", hcamcorder->type);
4819 MMCAM_LOG_INFO("Enable extra preview(%d)", value->value.i_val);
4821 current_state = _mmcamcorder_get_state(handle);
4822 if (current_state < MM_CAMCORDER_STATE_READY) {
4823 MMCAM_LOG_INFO("will be set when preview is started");
4827 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
4828 mmf_return_val_if_fail(sc, FALSE);
4830 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", value->value.i_val);
4832 MMCAM_LOG_INFO("done");
4838 bool _mmcamcorder_set_attribute_to_camsensor(MMHandleType handle)
4840 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4843 int scene_mode = MM_CAMCORDER_SCENE_MODE_NORMAL;
4847 int attr_idxs_default[] = {
4848 MM_CAM_CAMERA_DIGITAL_ZOOM,
4849 MM_CAM_CAMERA_OPTICAL_ZOOM,
4851 MM_CAM_FILTER_CONTRAST,
4854 MM_CAM_STROBE_BRIGHTNESS
4857 int attr_idxs_extra[] = {
4859 MM_CAM_FILTER_BRIGHTNESS,
4861 MM_CAM_FILTER_SATURATION,
4862 MM_CAM_FILTER_SHARPNESS,
4863 MM_CAM_FILTER_COLOR_TONE,
4864 MM_CAM_CAMERA_EXPOSURE_MODE
4867 mmf_return_val_if_fail(hcamcorder, FALSE);
4869 MMCAM_LOG_INFO("commit some attributes again");
4871 attrs = MMF_CAMCORDER_ATTRS(handle);
4872 if (attrs == NULL) {
4873 MMCAM_LOG_ERROR("Get attribute handle failed.");
4877 /* Get Scene mode */
4878 mm_camcorder_get_attributes(handle, NULL, MMCAM_FILTER_SCENE_MODE, &scene_mode, NULL);
4880 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_default) ; i++) {
4881 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_default[i]))
4882 mm_attrs_set_modified(attrs, attr_idxs_default[i]);
4885 /* Set extra if scene mode is NORMAL */
4886 if (scene_mode == MM_CAMCORDER_SCENE_MODE_NORMAL) {
4887 for (i = 0 ; i < ARRAY_SIZE(attr_idxs_extra) ; i++) {
4888 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs_extra[i]))
4889 mm_attrs_set_modified(attrs, attr_idxs_extra[i]);
4892 /* Set scene mode if scene mode is NOT NORMAL */
4893 if (_mmcamcorder_check_supported_attribute(handle, MM_CAM_FILTER_SCENE_MODE))
4894 mm_attrs_set_modified(attrs, MM_CAM_FILTER_SCENE_MODE);
4897 if (mm_attrs_commit_all(attrs) == -1)
4902 MMCAM_LOG_INFO("Done.");
4908 bool _mmcamcorder_set_attribute_to_camsensor2(MMHandleType handle)
4910 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4916 MM_CAM_CAMERA_PTZ_TYPE,
4917 MM_CAM_CAMERA_PAN_MECHA,
4918 MM_CAM_CAMERA_PAN_ELEC,
4919 MM_CAM_CAMERA_TILT_MECHA,
4920 MM_CAM_CAMERA_TILT_ELEC
4923 mmf_return_val_if_fail(hcamcorder, FALSE);
4925 MMCAM_LOG_INFO("commit some attribute again[2]");
4927 attrs = MMF_CAMCORDER_ATTRS(handle);
4928 if (attrs == NULL) {
4929 MMCAM_LOG_ERROR("Get attribute handle failed.");
4933 for (i = 0 ; i < ARRAY_SIZE(attr_idxs) ; i++) {
4934 if (_mmcamcorder_check_supported_attribute(handle, attr_idxs[i]))
4935 mm_attrs_set_modified(attrs, attr_idxs[i]);
4938 if (mm_attrs_commit_all(attrs) == -1)
4943 MMCAM_LOG_INFO("Done.");
4949 int _mmcamcorder_lock_readonly_attributes(MMHandleType handle)
4951 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4955 int nerror = MM_ERROR_NONE;
4957 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4959 attrs = MMF_CAMCORDER_ATTRS(handle);
4960 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4964 table_size = ARRAY_SIZE(readonly_attributes);
4965 MMCAM_LOG_INFO("%d", table_size);
4966 for (i = 0; i < table_size; i++) {
4967 int sCategory = readonly_attributes[i];
4969 mm_attrs_set_readonly(attrs, sCategory);
4976 int _mmcamcorder_set_disabled_attributes(MMHandleType handle)
4978 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
4981 type_string_array * disabled_attr = NULL;
4983 int nerror = MM_ERROR_NONE ;
4985 mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
4987 attrs = MMF_CAMCORDER_ATTRS(handle);
4988 mmf_return_val_if_fail(attrs, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
4993 _mmcamcorder_conf_get_value_string_array(hcamcorder->conf_main,
4994 CONFIGURE_CATEGORY_MAIN_GENERAL,
4995 "DisabledAttributes",
4997 if (disabled_attr != NULL && disabled_attr->value) {
4998 cnt_str = disabled_attr->count;
4999 for (i = 0; i < cnt_str; i++) {
5001 MMCAM_LOG_INFO("[%d]%s", i, disabled_attr->value[i]);
5002 nerror = mm_attrs_get_index(attrs, disabled_attr->value[i], &idx);
5004 if (nerror == MM_ERROR_NONE)
5005 mm_attrs_set_disabled(attrs, idx);
5007 MMCAM_LOG_WARNING("No ATTR named %s[%d]", disabled_attr->value[i], i);
5015 /*---------------------------------------------------------------------------------------
5016 | INTERNAL FUNCTION DEFINITIONS: |
5017 ---------------------------------------------------------------------------------------*/
5018 static bool __mmcamcorder_set_capture_resolution(MMHandleType handle, int width, int height)
5020 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5021 _MMCamcorderSubContext *sc = NULL;
5022 int current_state = MM_CAMCORDER_STATE_NULL;
5024 mmf_return_val_if_fail(hcamcorder, FALSE);
5026 sc = MMF_CAMCORDER_SUBCONTEXT(handle);
5030 current_state = _mmcamcorder_get_state(handle);
5032 if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
5033 if (current_state <= MM_CAMCORDER_STATE_PREPARE) {
5034 MMCAM_LOG_INFO("set capture width and height [%dx%d] to camera plugin", width, height);
5035 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", width);
5036 MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", height);
5038 MMCAM_LOG_WARNING("invalid state[%d]", current_state);
5042 MMCAM_LOG_INFO("element is not created yet");
5049 static int __mmcamcorder_check_valid_pair(MMHandleType handle, char **err_attr_name, const char *attribute_name, va_list var_args)
5051 #define INIT_VALUE -1
5052 #define CHECK_COUNT 3
5054 mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
5055 MMHandleType attrs = 0;
5057 int ret = MM_ERROR_NONE;
5060 const char *name = NULL;
5061 const char *check_pair_name[CHECK_COUNT][3] = {
5062 {MMCAM_CAMERA_WIDTH, MMCAM_CAMERA_HEIGHT, "MMCAM_CAMERA_WIDTH and HEIGHT"},
5063 {MMCAM_CAPTURE_WIDTH, MMCAM_CAPTURE_HEIGHT, "MMCAM_CAPTURE_WIDTH and HEIGHT"},
5064 {MMCAM_VIDEO_WIDTH, MMCAM_VIDEO_HEIGHT, "MMCAM_VIDEO_WIDTH and HEIGHT"},
5067 int check_pair_value[CHECK_COUNT][2] = {
5068 {INIT_VALUE, INIT_VALUE},
5069 {INIT_VALUE, INIT_VALUE},
5070 {INIT_VALUE, INIT_VALUE},
5073 if (hcamcorder == NULL || attribute_name == NULL) {
5074 MMCAM_LOG_WARNING("handle[%p] or attribute_name[%p] is NULL.",
5075 hcamcorder, attribute_name);
5076 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5080 *err_attr_name = NULL;
5082 /*MMCAM_LOG_INFO( "ENTER" );*/
5084 attrs = MMF_CAMCORDER_ATTRS(handle);
5086 name = attribute_name;
5090 MMAttrsType attr_type = MM_ATTRS_TYPE_INVALID;
5092 /*MMCAM_LOG_INFO("NAME : %s", name);*/
5094 /* attribute name check */
5095 if ((ret = mm_attrs_get_index(attrs, name, &idx)) != MM_ERROR_NONE) {
5097 *err_attr_name = strdup(name);
5099 if (ret == (int)MM_ERROR_COMMON_OUT_OF_ARRAY)
5100 return MM_ERROR_COMMON_ATTR_NOT_EXIST;
5106 if ((ret = mm_attrs_get_type(attrs, idx, &attr_type)) != MM_ERROR_NONE)
5109 switch (attr_type) {
5110 case MM_ATTRS_TYPE_INT:
5112 gboolean matched = FALSE;
5113 for (i = 0 ; i < CHECK_COUNT ; i++) {
5114 for (j = 0 ; j < 2 ; j++) {
5115 if (!strcmp(name, check_pair_name[i][j])) {
5116 check_pair_value[i][j] = va_arg((var_args), int);
5117 MMCAM_LOG_INFO("%s : %d", check_pair_name[i][j], check_pair_value[i][j]);
5125 if (matched == FALSE)
5126 va_arg((var_args), int);
5129 case MM_ATTRS_TYPE_DOUBLE:
5130 va_arg((var_args), double);
5132 case MM_ATTRS_TYPE_STRING:
5133 va_arg((var_args), char*); /* string */
5134 va_arg((var_args), int); /* size */
5136 case MM_ATTRS_TYPE_DATA:
5137 va_arg((var_args), void*); /* data */
5138 va_arg((var_args), int); /* size */
5140 case MM_ATTRS_TYPE_INVALID:
5142 MMCAM_LOG_ERROR("Not supported attribute type(%d, name:%s)", attr_type, name);
5144 *err_attr_name = strdup(name);
5146 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5150 name = va_arg(var_args, const char*);
5153 for (i = 0 ; i < CHECK_COUNT ; i++) {
5154 if (check_pair_value[i][0] != INIT_VALUE || check_pair_value[i][1] != INIT_VALUE) {
5155 gboolean check_result = FALSE;
5156 char *err_name = NULL;
5157 MMCamAttrsInfo attr_info_0, attr_info_1;
5159 if (check_pair_value[i][0] == INIT_VALUE) {
5160 mm_attrs_get_int_by_name(attrs, check_pair_name[i][0], &check_pair_value[i][0]);
5161 err_name = strdup(check_pair_name[i][1]);
5162 } else if (check_pair_value[i][1] == INIT_VALUE) {
5163 mm_attrs_get_int_by_name(attrs, check_pair_name[i][1], &check_pair_value[i][1]);
5164 err_name = strdup(check_pair_name[i][0]);
5166 err_name = strdup(check_pair_name[i][2]);
5169 mm_camcorder_get_attribute_info(handle, check_pair_name[i][0], &attr_info_0);
5170 mm_camcorder_get_attribute_info(handle, check_pair_name[i][1], &attr_info_1);
5172 check_result = FALSE;
5174 for (j = 0 ; j < attr_info_0.int_array.count ; j++) {
5175 if (attr_info_0.int_array.array[j] == check_pair_value[i][0] &&
5176 attr_info_1.int_array.array[j] == check_pair_value[i][1]) {
5178 MMCAM_LOG_INFO("Valid Pair[%s,%s] existed %dx%d[index:%d]",
5179 check_pair_name[i][0], check_pair_name[i][1],
5180 check_pair_value[i][0], check_pair_value[i][1], i);
5182 check_result = TRUE;
5187 if (check_result == FALSE) {
5188 MMCAM_LOG_ERROR("INVALID pair[%s,%s] %dx%d",
5189 check_pair_name[i][0], check_pair_name[i][1],
5190 check_pair_value[i][0], check_pair_value[i][1]);
5191 if (err_attr_name) {
5192 *err_attr_name = err_name;
5200 return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
5203 if (!strcmp(check_pair_name[i][0], MMCAM_CAMERA_WIDTH)) {
5204 int current_width = 0;
5205 int current_height = 0;
5207 mm_camcorder_get_attributes(handle, NULL,
5208 MMCAM_CAMERA_WIDTH, ¤t_width,
5209 MMCAM_CAMERA_HEIGHT, ¤t_height,
5212 if (current_width != check_pair_value[i][0] ||
5213 current_height != check_pair_value[i][1]) {
5214 hcamcorder->resolution_changed = TRUE;
5216 hcamcorder->resolution_changed = FALSE;
5219 MMCAM_LOG_INFO("resolution changed : %d", hcamcorder->resolution_changed);
5229 /*MMCAM_LOG_INFO("DONE");*/
5231 return MM_ERROR_NONE;
5235 bool _mmcamcorder_check_supported_attribute(MMHandleType handle, int attr_index)
5239 if ((void *)handle == NULL) {
5240 MMCAM_LOG_WARNING("handle %p is NULL", handle);
5244 memset(&info, 0x0, sizeof(MMAttrsInfo));
5246 mm_attrs_get_info(MMF_CAMCORDER_ATTRS(handle), attr_index, &info);
5248 switch (info.validity_type) {
5249 case MM_ATTRS_VALID_TYPE_INT_ARRAY:
5251 MMCAM_LOG_INFO("int array count %d", info.int_array.count);
5253 if (info.int_array.count < 1)
5256 case MM_ATTRS_VALID_TYPE_INT_RANGE:
5258 MMCAM_LOG_INFO("int range min %d, max %d",info.int_range.min, info.int_range.max);
5260 if (info.int_range.min > info.int_range.max)
5263 case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
5265 MMCAM_LOG_INFO("double array count %d", info.double_array.count);
5267 if (info.double_array.count < 1)
5270 case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
5272 MMCAM_LOG_INFO("double range min %lf, max %lf",info.int_range.min, info.int_range.max);
5274 if (info.double_range.min >= info.double_range.max)
5278 MMCAM_LOG_WARNING("invalid type %d", info.validity_type);