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>
23 #include <mm_camcorder_mused.h>
26 #include <camera_internal.h>
27 #include <camera_private.h>
34 #define LOG_TAG "TIZEN_N_CAMERA"
37 int camera_set_x11_display_rotation(camera_h camera, camera_rotation_e rotation)
39 return camera_set_display_rotation(camera, rotation);
43 int camera_get_x11_display_rotation(camera_h camera, camera_rotation_e *rotation)
45 return camera_get_display_rotation(camera, rotation);
49 int camera_set_x11_display_flip(camera_h camera, camera_flip_e flip)
51 return camera_set_display_flip(camera, flip);
55 int camera_get_x11_display_flip(camera_h camera, camera_flip_e *flip)
57 return camera_get_display_flip(camera, flip);
61 int camera_set_x11_display_visible(camera_h camera, bool visible)
63 return camera_set_display_visible(camera, visible);
67 int camera_is_x11_display_visible(camera_h camera, bool *visible)
69 return camera_is_display_visible(camera, visible);
73 int camera_set_x11_display_mode(camera_h camera, camera_display_mode_e mode)
75 return camera_set_display_mode(camera, mode);
79 int camera_get_x11_display_mode(camera_h camera, camera_display_mode_e *mode)
81 return camera_get_display_mode(camera, mode);
85 int camera_set_x11_display_pixmap(camera_h camera, camera_x11_pixmap_updated_cb callback, void *user_data)
87 int ret = MM_ERROR_NONE;
88 camera_s *handle = (camera_s *)camera;
89 camera_state_e capi_state = CAMERA_STATE_NONE;
91 if (handle == NULL || callback == NULL) {
92 LOGE("INVALID_PARAMETER(handle:%p,callback:%p,user_data:%p)", handle, callback, user_data);
93 return CAMERA_ERROR_INVALID_PARAMETER;
96 camera_get_state(camera, &capi_state);
97 if (capi_state > CAMERA_STATE_CREATED) {
98 LOGE("INVALID STATE(state:%d)", capi_state);
99 return CAMERA_ERROR_INVALID_STATE;
102 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
103 MMCAM_DISPLAY_SURFACE, MM_DISPLAY_SURFACE_X_EXT,
104 MMCAM_DISPLAY_HANDLE, callback, sizeof(void *),
107 return __convert_camera_error_code(__func__, ret);
110 int camera_set_mused_display(camera_h camera, camera_display_type_e type, void *display_handle)
112 int ret = MM_ERROR_NONE;
113 int set_surface = MM_DISPLAY_SURFACE_X;
114 camera_s *handle = NULL;
115 void *set_handle = NULL;
117 if (camera == NULL) {
118 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
119 return CAMERA_ERROR_INVALID_PARAMETER;
122 if (type != CAMERA_DISPLAY_TYPE_NONE && display_handle == NULL) {
123 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
124 return CAMERA_ERROR_INVALID_PARAMETER;
127 handle = (camera_s *)camera;
128 handle->display_type = type;
129 handle->display_handle = display_handle;
132 case CAMERA_DISPLAY_TYPE_OVERLAY:
133 set_surface = MM_DISPLAY_SURFACE_X;
134 set_handle = &(handle->display_handle);
135 LOGD("display type OVERLAY : handle %p", (int)handle->display_handle);
137 case CAMERA_DISPLAY_TYPE_EVAS:
138 set_surface = MM_DISPLAY_SURFACE_EVAS;
139 set_handle = display_handle;
141 case CAMERA_DISPLAY_TYPE_NONE:
143 set_surface = MM_DISPLAY_SURFACE_NULL;
144 handle->display_handle = NULL;
148 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
149 MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
150 MMCAM_DISPLAY_SURFACE, set_surface,
153 if (ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE) {
154 ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
155 MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *),
159 return __convert_camera_error_code(__func__, ret);
162 int camera_get_video_caps(camera_h camera, char **caps)
165 camera_s *handle = (camera_s *)camera;
167 ret = mm_camcorder_mused_get_video_caps(handle->mm_handle, caps);
168 if(ret != MM_ERROR_NONE) {
169 return __convert_camera_error_code(__func__, ret);
172 return CAMERA_ERROR_NONE;
175 int camera_set_shm_socket_path_for_mused(camera_h camera, char *socket_path)
178 camera_s *handle = (camera_s *)camera;
180 LOGE("var : %s", socket_path);
181 mm_camcorder_set_attributes(handle->mm_handle, NULL,
182 MMCAM_DISPLAY_SHM_SOCKET_PATH, socket_path, strlen(socket_path),
185 if (ret != MM_ERROR_NONE) {
186 LOGE("error set shm socket path attribute 0x%x", ret);
187 return __convert_camera_error_code(__func__, ret);
190 return CAMERA_ERROR_NONE;