Update code for sound policy error accepted/tizen/ivi/stable accepted/tizen_generic tizen_2.2 accepted/tizen/20130926.033203 accepted/tizen/20130926.072441 accepted/tizen/20130926.203834 accepted/tizen/generic/20140306.080942 accepted/tizen/ivi/20140307.055929 accepted/tizen/mobile/20140306.024325 accepted/tizen_ivi_stable/20131116.102009 submit/tizen/20130925.193438 submit/tizen/20140305.205313 submit/tizen_ivi_stable/20131116.100052
authorSangchul Lee <sc11.lee@samsung.com>
Sat, 27 Jul 2013 09:41:04 +0000 (18:41 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Sat, 27 Jul 2013 09:41:04 +0000 (18:41 +0900)
CMakeLists.txt
include/camera.h
packaging/capi-media-camera.spec
src/camera.c

index 673daab..f9ba3e3 100755 (executable)
@@ -23,7 +23,7 @@ SET(service "media")
 SET(submodule "camera")
 
 # for package file
-SET(dependents "dlog mm-camcorder capi-base-common")
+SET(dependents "dlog audio-session-mgr mm-camcorder capi-base-common")
 SET(pc_dependents "capi-base-common")
 
 SET(fw_name "${project_prefix}-${service}-${submodule}")
index 5894d67..0261436 100755 (executable)
@@ -46,16 +46,18 @@ extern "C" {
  */
 typedef enum
 {
-    CAMERA_ERROR_NONE =              TIZEN_ERROR_NONE,         /**< Successful */
-    CAMERA_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,  /**< Invalid parameter */
-    CAMERA_ERROR_INVALID_STATE =     CAMERA_ERROR_CLASS | 0x02,    /**< Invalid state */
-    CAMERA_ERROR_OUT_OF_MEMORY =     TIZEN_ERROR_OUT_OF_MEMORY,      /**< Out of memory */
-    CAMERA_ERROR_DEVICE =            CAMERA_ERROR_CLASS | 0x04,    /**< Device error */
-    CAMERA_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION,  /**< Internal error */
-    CAMERA_ERROR_SOUND_POLICY =      CAMERA_ERROR_CLASS | 0x06,    /**< Blocked by Audio Session Manager */
-    CAMERA_ERROR_SECURITY_RESTRICTED = CAMERA_ERROR_CLASS | 0x07,    /**< Restricted by security system policy */
-    CAMERA_ERROR_DEVICE_BUSY = CAMERA_ERROR_CLASS | 0x08,    /**< The device is using in other applications or working some operation */
-    CAMERA_ERROR_DEVICE_NOT_FOUND = CAMERA_ERROR_CLASS | 0x09, /**< No camera device */
+    CAMERA_ERROR_NONE                   = TIZEN_ERROR_NONE,                     /**< Successful */
+    CAMERA_ERROR_INVALID_PARAMETER      = TIZEN_ERROR_INVALID_PARAMETER,        /**< Invalid parameter */
+    CAMERA_ERROR_INVALID_STATE          = CAMERA_ERROR_CLASS | 0x02,            /**< Invalid state */
+    CAMERA_ERROR_OUT_OF_MEMORY          = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of memory */
+    CAMERA_ERROR_DEVICE                 = CAMERA_ERROR_CLASS | 0x04,            /**< Device error */
+    CAMERA_ERROR_INVALID_OPERATION      = TIZEN_ERROR_INVALID_OPERATION,        /**< Internal error */
+    CAMERA_ERROR_SOUND_POLICY           = CAMERA_ERROR_CLASS | 0x06,            /**< Blocked by Audio Session Manager */
+    CAMERA_ERROR_SECURITY_RESTRICTED    = CAMERA_ERROR_CLASS | 0x07,            /**< Restricted by security system policy */
+    CAMERA_ERROR_DEVICE_BUSY            = CAMERA_ERROR_CLASS | 0x08,            /**< The device is using in other applications or working some operation */
+    CAMERA_ERROR_DEVICE_NOT_FOUND       = CAMERA_ERROR_CLASS | 0x09,            /**< No camera device */
+    CAMERA_ERROR_SOUND_POLICY_BY_CALL   = CAMERA_ERROR_CLASS | 0x0a,            /**< Blocked by Audio Session Manager - CALL */
+    CAMERA_ERROR_SOUND_POLICY_BY_ALARM  = CAMERA_ERROR_CLASS | 0x0b,            /**< Blocked by Audio Session Manager - ALARM */
 } camera_error_e;
 
 
@@ -188,9 +190,11 @@ typedef enum
  */
 typedef enum
 {
-       CAMERA_POLICY_NONE = 0, /**< None */
-       CAMERA_POLICY_SOUND, /**< Sound policy */
-       CAMERA_POLICY_SECURITY /**< Security policy */
+       CAMERA_POLICY_NONE = 0,         /**< None */
+       CAMERA_POLICY_SOUND,            /**< Sound policy */
+       CAMERA_POLICY_SOUND_BY_CALL,    /**< Sound policy by CALL */
+       CAMERA_POLICY_SOUND_BY_ALARM,   /**< Sound policy by ALARM */
+       CAMERA_POLICY_SECURITY          /**< Security policy */
 } camera_policy_e;
 
 
index 23b1380..5aa412b 100755 (executable)
@@ -1,13 +1,14 @@
 Name:       capi-media-camera
 Summary:    A Camera library in Tizen C API
-Version:    0.1.3
-Release:    1
+Version:    0.1.4
+Release:    0
 Group:      libdevel
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(mm-camcorder)
+BuildRequires:  pkgconfig(audio-session-mgr)
 BuildRequires:  pkgconfig(capi-base-common)
 
 %description
index b128fdf..e99d2d3 100755 (executable)
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <mm.h>
+#include <audio-session-manager-types.h>
 #include <mm_camcorder.h>
 #include <mm_types.h>
 #include <math.h>
@@ -114,6 +115,14 @@ static int __convert_camera_error_code(const char* func, int code){
                        ret = CAMERA_ERROR_SOUND_POLICY;
                        errorstr = "ERROR_SOUND_POLICY";
                        break;
+               case MM_ERROR_POLICY_BLOCKED_BY_CALL:
+                       ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
+                       errorstr = "ERROR_SOUND_POLICY_BY_CALL";
+                       break;
+               case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
+                       ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
+                       errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
+                       break;
                case MM_ERROR_POLICY_RESTRICTED:
                        ret = CAMERA_ERROR_SECURITY_RESTRICTED;
                        errorstr = "ERROR_RESTRICTED";
@@ -293,10 +302,26 @@ static int __mm_camera_message_callback(int message, void *param, void *user_dat
                        previous_state = handle->state;
                        handle->state = __camera_state_convert(m->state.current );
                        camera_policy_e policy = CAMERA_POLICY_NONE;
-                       if(message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM )
-                               policy = CAMERA_POLICY_SOUND;
-                       else if( message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY )
+                       if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_ASM) {
+                               switch (m->state.code) {
+                               case ASM_EVENT_SOURCE_CALL_START:
+                                       policy = CAMERA_POLICY_SOUND_BY_CALL;
+                                       LOGE("CAMERA_POLICY_SOUND_BY_CALL");
+                                       break;
+                               case ASM_EVENT_SOURCE_ALARM_START:
+                               case ASM_EVENT_SOURCE_ALARM_END:
+                                       policy = CAMERA_POLICY_SOUND_BY_ALARM;
+                                       LOGE("CAMERA_POLICY_SOUND_BY_ALARM");
+                                       break;
+                               default:
+                                       policy = CAMERA_POLICY_SOUND;
+                                       LOGE("CAMERA_POLICY_SOUND");
+                                       break;
+                               }
+                       } else if (message == MM_MESSAGE_CAMCORDER_STATE_CHANGED_BY_SECURITY) {
                                policy = CAMERA_POLICY_SECURITY;
+                               LOGE("CAMERA_POLICY_SECURITY");
+                       }
 
                        if( previous_state != handle->state && handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE] ){
                                ((camera_state_changed_cb)handle->user_cb[_CAMERA_EVENT_TYPE_STATE_CHANGE])(previous_state, handle->state, policy, handle->user_data[_CAMERA_EVENT_TYPE_STATE_CHANGE]);