2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #include <mm_camcorder.h>
24 #include <mm_camcorder_mused.h>
25 #endif /* HAVE_WAYLAND */
28 #include <camera_internal.h>
29 #include <camera_private.h>
36 #define LOG_TAG "TIZEN_N_CAMERA"
39 int camera_set_x11_display_rotation(camera_h camera, camera_rotation_e rotation)
41 return camera_set_display_rotation(camera, rotation);
45 int camera_get_x11_display_rotation(camera_h camera, camera_rotation_e *rotation)
47 return camera_get_display_rotation(camera, rotation);
51 int camera_set_x11_display_flip(camera_h camera, camera_flip_e flip)
53 return camera_set_display_flip(camera, flip);
57 int camera_get_x11_display_flip(camera_h camera, camera_flip_e *flip)
59 return camera_get_display_flip(camera, flip);
63 int camera_set_x11_display_visible(camera_h camera, bool visible)
65 return camera_set_display_visible(camera, visible);
69 int camera_is_x11_display_visible(camera_h camera, bool *visible)
71 return camera_is_display_visible(camera, visible);
75 int camera_set_x11_display_mode(camera_h camera, camera_display_mode_e mode)
77 return camera_set_display_mode(camera, mode);
81 int camera_get_x11_display_mode(camera_h camera, camera_display_mode_e *mode)
83 return camera_get_display_mode(camera, mode);
87 int camera_set_x11_display_pixmap(camera_h camera, camera_x11_pixmap_updated_cb callback, void *user_data)
89 int ret = MM_ERROR_NONE;
90 camera_s *handle = (camera_s *)camera;
91 camera_state_e capi_state = CAMERA_STATE_NONE;
93 if (handle == NULL || callback == NULL) {
94 LOGE("INVALID_PARAMETER(handle:%p,callback:%p,user_data:%p)", handle, callback, user_data);
95 return CAMERA_ERROR_INVALID_PARAMETER;
98 camera_get_state(camera, &capi_state);
99 if (capi_state > CAMERA_STATE_CREATED) {
100 LOGE("INVALID STATE(state:%d)", capi_state);
101 return CAMERA_ERROR_INVALID_STATE;
104 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
105 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_X_EXT,
106 MMCAM_DISPLAY_HANDLE, callback, sizeof(void *),
109 return __convert_camera_error_code(__func__, ret);
112 int camera_set_mused_display(camera_h camera, camera_display_type_e type, void *display_handle)
114 int ret = MM_ERROR_NONE;
115 int set_surface = MM_DISPLAY_SURFACE_X;
116 camera_s *handle = NULL;
117 void *set_handle = NULL;
119 if (camera == NULL) {
120 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
121 return CAMERA_ERROR_INVALID_PARAMETER;
124 if (type != CAMERA_DISPLAY_TYPE_NONE && display_handle == NULL) {
125 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
126 return CAMERA_ERROR_INVALID_PARAMETER;
129 handle = (camera_s *)camera;
130 handle->display_type = type;
131 handle->display_handle = display_handle;
134 case CAMERA_DISPLAY_TYPE_OVERLAY:
135 set_surface = MM_DISPLAY_SURFACE_X;
136 set_handle = &(handle->display_handle);
137 LOGD("display type OVERLAY : handle %p", (int)handle->display_handle);
139 case CAMERA_DISPLAY_TYPE_EVAS:
140 set_surface = MM_DISPLAY_SURFACE_EVAS;
141 set_handle = display_handle;
143 case CAMERA_DISPLAY_TYPE_NONE:
145 set_surface = MM_DISPLAY_SURFACE_NULL;
146 handle->display_handle = NULL;
150 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
151 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
152 MMCAM_DISPLAY_SURFACE, set_surface,
155 if (ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE) {
156 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
157 MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *),
161 return __convert_camera_error_code(__func__, ret);
164 int camera_get_video_caps(camera_h camera, char **caps)
167 camera_s *handle = (camera_s *)camera;
170 ret = mm_camcorder_mused_get_video_caps(handle->mm_handle, caps);
171 if(ret != MM_ERROR_NONE) {
172 return __convert_camera_error_code(__func__, ret);
174 #endif /* HAVE_WAYLAND */
176 return CAMERA_ERROR_NONE;
179 int camera_set_shm_socket_path_for_mused(camera_h camera, char *socket_path)
181 int ret = MM_ERROR_NONE;
182 camera_s *handle = (camera_s *)camera;
184 if (camera == NULL) {
186 return CAMERA_ERROR_INVALID_PARAMETER;
189 if (socket_path == NULL) {
190 LOGE("NULL pointer for socket_path");
191 return CAMERA_ERROR_INVALID_PARAMETER;
194 LOGD("var : %s", socket_path);
196 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
197 MMCAM_DISPLAY_SHM_SOCKET_PATH, socket_path, strlen(socket_path),
199 if (ret != MM_ERROR_NONE) {
200 LOGE("error set shm socket path attribute 0x%x", ret);
201 return __convert_camera_error_code(__func__, ret);
204 return CAMERA_ERROR_NONE;