Update code for device state APIs 85/91585/1
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 10 Oct 2016 09:13:18 +0000 (18:13 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 10 Oct 2016 09:15:08 +0000 (18:15 +0900)
1. Add code to emit signal for device state change
2. Remove unused code

[Version] 0.2.51
[Profile] Common
[Issue Type] Update
[Dependency module] libmm-camcorder
[Dependency commit] 6012f7ec5032f940e8446a7aec9a9ee001ba05c6
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-mobile_20161007.1]

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

index bdd6dbb..ccfb764 100644 (file)
@@ -24,15 +24,14 @@ extern "C" {
 
 /**
   * @file camera_internal.h
-  * @brief This file contains the Camera Product-internal API for framework, related structures and enumerations.
+  * @brief This file contains the Camera internal API for framework, related structures and enumerations.
   */
 
 /**
- * @brief Registers a callback function to be invoked when camera needs updated xid.
+ * @brief Set pid of client for sound focus API.
  * @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
+ * @param[in] pid The pid of client
  *
  * @return @c 0 on success, otherwise a negative error value
  * @retval #CAMERA_ERROR_NONE Successful
@@ -40,26 +39,20 @@ extern "C" {
  * @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_get_video_caps() will be invoked.
- *
- * @see camera_get_video_caps()
  */
-int legacy_camera_get_video_caps(camera_h camera, char **caps);
+int legacy_camera_set_client_pid(camera_h camera, int pid);
 
 /**
- * @brief Set pid of client for sound focus API.
+ * @brief Emit signal to notify some information.
  * @ingroup CAPI_MEDIA_CAMERA_MUSED_MODULE
  * @param[in] camera The handle to the camera
- * @param[in] pid The pid of client
- *
- * @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().
+ * @param[in] object_name The name of signal object
+ * @param[in] interface_name The name of signal interface
+ * @param[in] signal_name The name of signal
+ * @param[in] value The value of signal to emit
  */
-int legacy_camera_set_client_pid(camera_h camera, int pid);
+void legacy_camera_emit_signal(camera_h camera, const char *object_name,
+       const char *interface_name, const char *signal_name, int value);
 
 
 #ifdef __cplusplus
index cd05235..eb696dd 100644 (file)
@@ -22,7 +22,7 @@
 #include <mm_camcorder.h>
 #include <mm_types.h>
 #include <math.h>
-#include <legacy_camera.h>
+#include <legacy_camera_internal.h>
 #include <legacy_camera_private.h>
 #include <glib.h>
 #include <dlog.h>
 #endif
 #define LOG_TAG "LEGACY_CAMERA"
 
+/**
+ * @brief Definition for device state change signal
+ */
+#define MM_CAMCORDER_DBUS_OBJECT                "/org/tizen/MMCamcorder"
+#define MM_CAMCORDER_DBUS_INTERFACE_CAMERA      "org.tizen.MMCamcorder.Camera"
+#define MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED  "DeviceStateChanged"
+
 static gboolean __mm_videostream_callback(MMCamcorderVideoStreamDataType *stream, void *user_data);
 static gboolean __mm_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data);
 
@@ -301,6 +308,10 @@ static int __mm_camera_message_callback(int message, void *param, void *user_dat
        case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM:
        case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY:
        case MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_RM:
+       {
+               int emit_value = 0;
+               int device_state = -1;
+
                if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED &&
                    (m->state.previous < MM_CAMCORDER_STATE_NONE ||
                     m->state.previous > MM_CAMCORDER_STATE_PAUSED ||
@@ -309,6 +320,7 @@ static int __mm_camera_message_callback(int message, void *param, void *user_dat
                        break;
                }
 
+               /* check policy */
                if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
                        switch (m->state.code) {
                        case MM_MSG_CODE_INTERRUPTED_BY_CALL_START:
@@ -353,6 +365,28 @@ static int __mm_camera_message_callback(int message, void *param, void *user_dat
                                handle->state, policy, handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);
                }
 
+               /* emit signal for camera device state */
+               if (m->state.previous == MM_CAMCORDER_STATE_READY && m->state.current == MM_CAMCORDER_STATE_NULL)
+                       device_state = CAMERA_DEVICE_STATE_NULL;
+               else if ((m->state.previous == MM_CAMCORDER_STATE_NULL && m->state.current == MM_CAMCORDER_STATE_READY) ||
+                       (m->state.previous == MM_CAMCORDER_STATE_PREPARE && m->state.current == MM_CAMCORDER_STATE_READY))
+                       device_state = CAMERA_DEVICE_STATE_OPENED;
+               else if (m->state.previous == MM_CAMCORDER_STATE_READY &&
+                       m->state.current == MM_CAMCORDER_STATE_PREPARE)
+                       device_state = CAMERA_DEVICE_STATE_WORKING;
+
+               if (device_state != -1) {
+                       emit_value = handle->device_type << 16 | device_state;
+
+                       LOGD("camera devce state change signal [0x8x]", emit_value);
+
+                       legacy_camera_emit_signal((camera_h)handle,
+                               MM_CAMCORDER_DBUS_OBJECT,
+                               MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
+                               MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED,
+                               emit_value);
+               }
+
                /* should change intermediate state MM_CAMCORDER_STATE_READY is not valid in capi , change to NULL state */
                if (policy != CAMERA_POLICY_NONE && m->state.current == MM_CAMCORDER_STATE_NULL) {
                        if (handle->user_cb[_CAMERA_EVENT_TYPE_INTERRUPTED]) {
@@ -363,6 +397,7 @@ static int __mm_camera_message_callback(int message, void *param, void *user_dat
                        }
                }
                break;
+       }
        case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED:
                if (handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE]) {
                        ((camera_focus_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_FOCUS_CHANGE])(m->code,
index 1fa52d8..986336b 100644 (file)
 #define LOG_TAG "LEGACY_CAMERA"
 
 
-int legacy_camera_get_video_caps(camera_h camera, char **caps)
-{
-       int ret;
-       camera_s *handle = (camera_s *)camera;
-
-       ret = mm_camcorder_get_video_caps(handle->mm_handle, caps);
-       if (ret != MM_ERROR_NONE)
-               return __convert_camera_error_code(__func__, ret);
-
-       return CAMERA_ERROR_NONE;
-}
-
 int legacy_camera_set_client_pid(camera_h camera, int pid)
 {
        int ret;
@@ -63,3 +51,20 @@ int legacy_camera_set_client_pid(camera_h camera, int pid)
 
        return __convert_camera_error_code(__func__, ret);
 }
+
+
+void legacy_camera_emit_signal(camera_h camera, const char *object_name,
+       const char *interface_name, const char *signal_name, int value)
+{
+       camera_s *handle = (camera_s *)camera;
+
+       if (!handle) {
+               LOGE("NULL handle");
+               return;
+       }
+
+       mm_camcorder_emit_signal(handle->mm_handle,
+               object_name, interface_name, signal_name, value);
+
+       return;
+}
index 92e8f72..fc96504 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-camera
 Summary:    A Camera module for muse server
-Version:    0.2.50
+Version:    0.2.51
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0