Release version 0.2.11 96/51296/2 accepted/tizen/mobile/20151109.233940 accepted/tizen/tv/20151109.233950 accepted/tizen/wearable/20151109.234001 submit/tizen/20151109.084637 submit/tizen/20151109.102233
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 6 Nov 2015 09:26:37 +0000 (18:26 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 9 Nov 2015 08:40:50 +0000 (17:40 +0900)
1. Remove unnecessary functions
2. Add new type and code for disply - CAMERA_DISPLAY_TYPE_REMOTE
3. Change event class name from MUSE_CAMERA_EVENT_CLASS_IDLE to MUSE_CAMERA_EVENT_CLASS_MAIN_THREAD

Change-Id: I109216d176475d2f84dbb71466361b7d9c78e435
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
legacy/include/legacy_camera.h
legacy/include/legacy_camera_internal.h
legacy/src/legacy_camera.c
legacy/src/legacy_camera_internal.c
muse/include/muse_camera.h
muse/include/muse_camera_msg.h
muse/src/muse_camera_dispatcher.c
packaging/mmsvc-camera.spec

index 0145f2d..d6331ff 100755 (executable)
@@ -115,6 +115,7 @@ typedef enum
 {
        CAMERA_DISPLAY_TYPE_OVERLAY = 0,        /**< Overlay surface display */
        CAMERA_DISPLAY_TYPE_EVAS,               /**< Evas object surface display */
+       CAMERA_DISPLAY_TYPE_REMOTE,             /**< Remote surface for display */
        CAMERA_DISPLAY_TYPE_NONE                /**< This disposes off buffers */
 } camera_display_type_e;
 
index dd33ce7..5eeb16c 100755 (executable)
@@ -32,26 +32,6 @@ extern "C" {
  * @ingroup CAPI_MEDIA_CAMERA_MUSED_MODULE
  * @remarks This function is valid only for #CAMERA_DISPLAY_TYPE_OVERLAY.
  * @param[in] camera The handle to the camera
- * @param[in] type The type of the display
- * @param[in] display_handle The handle of the created display
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #CAMERA_ERROR_NONE Successful
- * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
- * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
- * @pre        The camera state must be #CAMERA_STATE_CREATED by camera_create().
- * @post camera_set_mused_display() will be invoked.
- *
- * @see camera_set_mused_display()
- */
-int legacy_camera_set_mused_display(camera_h camera, camera_display_type_e type);
-
-/**
- * @brief Registers a callback function to be invoked when camera needs updated xid.
- * @ingroup CAPI_MEDIA_CAMERA_MUSED_MODULE
- * @remarks This function is valid only for #CAMERA_DISPLAY_TYPE_OVERLAY.
- * @param[in] camera The handle to the camera
  * @param[in] caps The caps information of the server's video element
  *
  * @return @c 0 on success, otherwise a negative error value
@@ -67,25 +47,6 @@ int legacy_camera_set_mused_display(camera_h camera, camera_display_type_e type)
 int legacy_camera_get_video_caps(camera_h camera, char **caps);
 
 /**
- * @brief Registers a callback function to be invoked when camera needs updated xid.
- * @ingroup CAPI_MEDIA_CAMERA_MUSED_MODULE
- * @remarks This function is valid only for #CAMERA_DISPLAY_TYPE_OVERLAY.
- * @param[in] camera The handle to the camera
- * @param[in] socket_path The socket file path for the display data ipc
- *
- * @return @c 0 on success, otherwise a negative error value
- * @retval #CAMERA_ERROR_NONE Successful
- * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CAMERA_ERROR_INVALID_OPERATION Invalid operation
- * @retval #CAMERA_ERROR_INVALID_STATE Invalid state
- * @pre        The camera state must be #CAMERA_STATE_CREATED by camera_create().
- * @post camera_set_shm_socket_path_for_mused() will be invoked.
- *
- * @see camera_set_shm_socket_path_for_mused()
- */
-int legacy_camera_set_shm_socket_path_for_mused(camera_h camera, char *socket_path);
-
-/**
  * @brief Set pid of client for sound focus API.
  * @ingroup CAPI_MEDIA_CAMERA_MUSED_MODULE
  * @param[in] camera The handle to the camera
index f2e020b..f8bb72a 100755 (executable)
@@ -1443,6 +1443,7 @@ int legacy_camera_set_display(camera_h camera, camera_display_type_e type, camer
 
        Evas_Object *obj = NULL;
        const char *object_type = NULL;
+       char *socket_path = NULL;
 
        if (camera == NULL) {
                LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
@@ -1457,13 +1458,11 @@ int legacy_camera_set_display(camera_h camera, camera_display_type_e type, camer
        handle = (camera_s *)camera;
        handle->display_type = type;
 
-       if (type == CAMERA_DISPLAY_TYPE_NONE) {
-               /* NULL surface */
-               set_surface = MM_DISPLAY_SURFACE_NULL;
-               handle->display_handle = 0;
+       LOGD("display type - %d, display handle - %p", type, display);
 
-               LOGD("display type NONE");
-       } else {
+       switch (type) {
+       case CAMERA_DISPLAY_TYPE_OVERLAY:
+       case CAMERA_DISPLAY_TYPE_EVAS:
                obj = (Evas_Object *)display;
                object_type = evas_object_type_get(obj);
                if (object_type) {
@@ -1528,17 +1527,36 @@ int legacy_camera_set_display(camera_h camera, camera_display_type_e type, camer
                        LOGE("failed to get evas object type from %p", obj);
                        return CAMERA_ERROR_INVALID_PARAMETER;
                }
+               break;
+       case CAMERA_DISPLAY_TYPE_REMOTE:
+               set_surface = MM_DISPLAY_SURFACE_REMOTE;
+               handle->display_handle = display;
+               break;
+       case CAMERA_DISPLAY_TYPE_NONE:
+               set_surface = MM_DISPLAY_SURFACE_NULL;
+               handle->display_handle = 0;
+               break;
+       default:
+               LOGE("unknown display type %d", type);
+               return CAMERA_ERROR_INVALID_PARAMETER;
        }
 
        ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
-                                         MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
-                                         MMCAM_DISPLAY_SURFACE, set_surface,
-                                         NULL);
+                                         MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
+                                         MMCAM_DISPLAY_SURFACE, set_surface,
+                                         NULL);
 
-       if (ret == MM_ERROR_NONE && type != CAMERA_DISPLAY_TYPE_NONE) {
-               ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
-                                                 MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *),
-                                                 NULL);
+       if (ret == MM_ERROR_NONE) {
+               if (type == CAMERA_DISPLAY_TYPE_REMOTE) {
+                       socket_path = (char *)handle->display_handle;
+                       ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
+                                                         MMCAM_DISPLAY_SHM_SOCKET_PATH, socket_path, strlen(socket_path),
+                                                         NULL);
+               } else if (type != CAMERA_DISPLAY_TYPE_NONE) {
+                       ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
+                                                         MMCAM_DISPLAY_HANDLE, set_handle, sizeof(void *),
+                                                         NULL);
+               }
        }
 
        return __convert_camera_error_code(__func__, ret);
index dbdc965..e442b07 100755 (executable)
 #define LOG_TAG "TIZEN_N_CAMERA"
 
 
-int legacy_camera_set_mused_display(camera_h camera, camera_display_type_e type)
-{
-       int ret = MM_ERROR_NONE;
-       int set_surface = MM_DISPLAY_SURFACE_X;
-       camera_s *handle = NULL;
-
-       if (camera == NULL) {
-               LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
-               return CAMERA_ERROR_INVALID_PARAMETER;
-       }
-
-       handle = (camera_s *)camera;
-       handle->display_type = type;
-
-       switch(type) {
-               case CAMERA_DISPLAY_TYPE_OVERLAY:
-                       set_surface = MM_DISPLAY_SURFACE_X;
-                       LOGD("display type OVERLAY : set_surface : 0x%x", set_surface);
-                       break;
-               case CAMERA_DISPLAY_TYPE_EVAS:
-                       set_surface = MM_DISPLAY_SURFACE_EVAS;
-                       break;
-               case CAMERA_DISPLAY_TYPE_NONE:
-               default:
-                       set_surface = MM_DISPLAY_SURFACE_NULL;
-                       break;
-       }
-
-       ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
-                                         MMCAM_DISPLAY_DEVICE, MM_DISPLAY_DEVICE_MAINLCD,
-                                         MMCAM_DISPLAY_SURFACE, set_surface,
-                                         NULL);
-
-       return __convert_camera_error_code(__func__, ret);
-}
-
 int legacy_camera_get_video_caps(camera_h camera, char **caps)
 {
        int ret;
@@ -84,24 +48,6 @@ int legacy_camera_get_video_caps(camera_h camera, char **caps)
        return CAMERA_ERROR_NONE;
 }
 
-int legacy_camera_set_shm_socket_path_for_mused(camera_h camera, char *socket_path)
-{
-       int ret;
-       camera_s *handle = (camera_s *)camera;
-
-       LOGE("var : %s", socket_path);
-       ret = mm_camcorder_set_attributes(handle->mm_handle, NULL,
-                                   MMCAM_DISPLAY_SHM_SOCKET_PATH, socket_path, strlen(socket_path),
-                                   NULL);
-
-       if (ret != MM_ERROR_NONE) {
-               LOGE("error set shm socket path attribute 0x%x", ret);
-               return __convert_camera_error_code(__func__, ret);
-       }
-
-       return CAMERA_ERROR_NONE;
-}
-
 int legacy_camera_set_client_pid(camera_h camera, int pid)
 {
        int ret;
index c40ff94..3d0fe24 100644 (file)
@@ -209,7 +209,7 @@ typedef enum {
 typedef enum {
        MUSE_CAMERA_EVENT_CLASS_NORMAL,
        MUSE_CAMERA_EVENT_CLASS_IMMEDIATE,
-       MUSE_CAMERA_EVENT_CLASS_IDLE,
+       MUSE_CAMERA_EVENT_CLASS_MAIN_THREAD,
        MUSE_CAMERA_EVENT_CLASS_NUM
 } muse_camera_event_class_e;
 
index 06d9b72..628bd2c 100755 (executable)
@@ -154,7 +154,7 @@ typedef const char* STRING;
        do{     \
                char *__sndMsg__; \
                int __len__; \
-               __sndMsg__ = muse_core_msg_json_factory_new(api,        0); \
+               __sndMsg__ = muse_core_msg_json_factory_new(api, 0); \
                __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
                if (__len__ <= 0) { \
                        LOGE("sending message failed"); \
index 720523e..e2650ec 100755 (executable)
@@ -444,7 +444,7 @@ void _camera_dispatcher_state_changed_cb(camera_state_e previous, camera_state_e
 
        muse_camera_msg_event3(MUSE_CAMERA_CB_EVENT,
                               MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE,
-                              MUSE_CAMERA_EVENT_CLASS_IDLE,
+                              MUSE_CAMERA_EVENT_CLASS_MAIN_THREAD,
                               module,
                               INT, previous,
                               INT, current,
@@ -461,7 +461,7 @@ void _camera_dispatcher_interrupted_cb(camera_policy_e policy, camera_state_e pr
 
        muse_camera_msg_event3(MUSE_CAMERA_CB_EVENT,
                               MUSE_CAMERA_EVENT_TYPE_INTERRUPTED,
-                              MUSE_CAMERA_EVENT_CLASS_IDLE,
+                              MUSE_CAMERA_EVENT_CLASS_MAIN_THREAD,
                               module,
                               INT, policy,
                               INT, previous,
@@ -612,7 +612,7 @@ void _camera_dispatcher_capture_completed_cb(void *user_data)
 
        muse_camera_msg_event(MUSE_CAMERA_CB_EVENT,
                              MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE,
-                             MUSE_CAMERA_EVENT_CLASS_IDLE,
+                             MUSE_CAMERA_EVENT_CLASS_MAIN_THREAD,
                              module);
        return;
 }
@@ -696,7 +696,7 @@ void _camera_dispatcher_face_detected_cb(camera_detected_face_s *faces, int coun
                /* send message */
                muse_camera_msg_event2(MUSE_CAMERA_CB_EVENT,
                                       MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION,
-                                      MUSE_CAMERA_EVENT_CLASS_IDLE,
+                                      MUSE_CAMERA_EVENT_CLASS_MAIN_THREAD,
                                       module,
                                       INT, count,
                                       INT, tbm_key);
@@ -715,7 +715,7 @@ void _camera_dispatcher_focus_changed_cb(camera_focus_state_e state, void *user_
 
        muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
                               MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE,
-                              MUSE_CAMERA_EVENT_CLASS_IDLE,
+                              MUSE_CAMERA_EVENT_CLASS_MAIN_THREAD,
                               module,
                               INT, state);
 
@@ -730,7 +730,7 @@ void _camera_dispatcher_error_cb(camera_error_e error, camera_state_e current_st
 
        muse_camera_msg_event2(MUSE_CAMERA_CB_EVENT,
                               MUSE_CAMERA_EVENT_TYPE_ERROR,
-                              MUSE_CAMERA_EVENT_CLASS_IDLE,
+                              MUSE_CAMERA_EVENT_CLASS_MAIN_THREAD,
                               module,
                               INT, error,
                               INT, current_state);
@@ -746,7 +746,7 @@ void _camera_dispatcher_hdr_progress_cb(int percent, void *user_data)
 
        muse_camera_msg_event1(MUSE_CAMERA_CB_EVENT,
                               MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS,
-                              MUSE_CAMERA_EVENT_CLASS_IDLE,
+                              MUSE_CAMERA_EVENT_CLASS_MAIN_THREAD,
                               module,
                               INT, percent);
        return;
@@ -861,17 +861,26 @@ int camera_dispatcher_start_preview(muse_module_h module)
        muse_camera_handle_s *muse_camera = NULL;
        muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
        char *caps = NULL;
+       camera_state_e prev_state = CAMERA_STATE_NONE;
 
        muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
 
        LOGD("handle : %p", muse_camera);
 
+       legacy_camera_get_state(muse_camera->camera_handle, &prev_state);
+
        ret = legacy_camera_start_preview(muse_camera->camera_handle);
-       if(ret == CAMERA_ERROR_NONE) {
+       if (ret != CAMERA_ERROR_NONE) {
+               LOGD("start preview failed 0x%x", ret);
+               muse_camera_msg_return(api, ret, module);
+               return MUSE_CAMERA_ERROR_NONE;
+       }
+
+       if (prev_state == CAMERA_STATE_CREATED) {
                ret = legacy_camera_get_video_caps(muse_camera->camera_handle, &caps);
-               if((ret == CAMERA_ERROR_NONE) && caps) {
+               if (ret == CAMERA_ERROR_NONE && caps) {
                        LOGD("caps : %s", caps);
-                       muse_camera_msg_return1(api, ret, module, STRING, caps);
+                       muse_camera_msg_return2(api, ret, module, STRING, caps, INT, prev_state);
                        g_free(caps);
                } else {
                        LOGD("Failed to get server's video caps. ret 0x%x, caps %p", ret, caps);
@@ -881,9 +890,8 @@ int camera_dispatcher_start_preview(muse_module_h module)
                        }
                }
        } else {
-               LOGD("start preview failed 0x%x", ret);
-               muse_camera_msg_return(api, ret, module);
-               return ret;
+               LOGD("preview started after capture");
+               muse_camera_msg_return1(api, ret, module, INT, prev_state);
        }
 
        return MUSE_CAMERA_ERROR_NONE;
@@ -1180,8 +1188,6 @@ int camera_dispatcher_set_display(muse_module_h module)
 {
        int ret = CAMERA_ERROR_NONE;
        muse_camera_handle_s *muse_camera = NULL;
-       int display_type;
-       int display_surface;
        muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
        static guint stream_id = 0;
        char socket_path[SOCKET_PATH_LENGTH] = {0,};
@@ -1189,10 +1195,7 @@ int camera_dispatcher_set_display(muse_module_h module)
 
        muse_camera = (muse_camera_handle_s *)muse_core_ipc_get_handle(module);
 
-       muse_camera_msg_get(display_type, muse_core_client_get_msg(module));
-       muse_camera_msg_get(display_surface, muse_core_client_get_msg(module));
-
-       LOGD("handle : 0x%x, display_type : %d", muse_camera, display_type);
+       LOGD("handle : 0x%x", muse_camera);
 
        camera = muse_camera->camera_handle;
        stream_id = muse_core_get_atomic_uint();
@@ -1201,10 +1204,7 @@ int camera_dispatcher_set_display(muse_module_h module)
 
        LOGD("socket_path : %s", socket_path);
 
-       ret = legacy_camera_set_shm_socket_path_for_mused(camera, socket_path);
-
-       ret |= legacy_camera_set_mused_display(muse_camera->camera_handle, (camera_display_type_e)display_type);
-
+       ret = legacy_camera_set_display(muse_camera->camera_handle, CAMERA_DISPLAY_TYPE_REMOTE, (void *)socket_path);
        if (ret != CAMERA_ERROR_NONE) {
                muse_camera_msg_return(api, ret, module);
        } else {
index c53039e..20065b7 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:       mmsvc-camera
 Summary:    A Camera module for muse server
-Version:    0.2.10
+Version:    0.2.11
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0