summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2017-06-09 18:39:30 +0900
committerJeongmo Yang <jm80.yang@samsung.com>2017-06-14 18:10:06 +0900
commitc64db312088425fd6ac87c1e32f83fe027a36b16 (patch)
tree10874941714020fdad1a871bcba51183920bccd7
parent2543d8cbaa4dcfd802b410b9f5345fc8e3b957e2 (diff)
downloadcamera-c64db312088425fd6ac87c1e32f83fe027a36b16.tar.gz
camera-c64db312088425fd6ac87c1e32f83fe027a36b16.tar.bz2
camera-c64db312088425fd6ac87c1e32f83fe027a36b16.zip
The application can only get callback after interrupt is completed, it means that there is no way to know the internal interrupt handling status for application. This patch provides the APIs to get callback when interrupt is started. [Version] 0.3.2 [Profile] Common [Issue Type] Update [Dependency module] N/A [Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-unified_20170608.1] Change-Id: I3af3dedec3f1c195c0206e32b7509a368d84ee5e Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r--include/camera.h40
-rw-r--r--packaging/capi-media-camera.spec2
-rw-r--r--src/camera.c77
-rw-r--r--test/camera_test.c8
4 files changed, 122 insertions, 5 deletions
diff --git a/include/camera.h b/include/camera.h
index 5a8933c..c102af0 100644
--- a/include/camera.h
+++ b/include/camera.h
@@ -549,6 +549,7 @@ typedef void (*camera_device_state_changed_cb)(camera_device_e device, camera_de
/**
* @brief Called when the camera is interrupted by policy.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks This callback is called after interrupt handling is completed.
* @param[in] policy The policy that interrupted the camera
* @param[in] previous The previous state of the camera
* @param[in] current The current state of the camera
@@ -558,6 +559,17 @@ typedef void (*camera_device_state_changed_cb)(camera_device_e device, camera_de
typedef void (*camera_interrupted_cb)(camera_policy_e policy, camera_state_e previous, camera_state_e current, void *user_data);
/**
+ * @brief Called when the camera interrupt is started by policy.
+ * @since_tizen 4.0
+ * @remarks This callback is called before interrupt handling is started.
+ * @param[in] policy The policy that is interrupting the camera
+ * @param[in] state The current state of the camera
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see camera_set_interrupt_started_cb()
+ */
+typedef void (*camera_interrupt_started_cb)(camera_policy_e policy, camera_state_e state, void *user_data);
+
+/**
* @brief Called when the camera focus state is changed.
* @details When the camera auto focus completes or a change to the focus state occurs,
* this callback is invoked. \n \n
@@ -1844,8 +1856,7 @@ int camera_unset_state_changed_cb(camera_h camera);
* @see camera_unset_interrupted_cb()
* @see camera_interrupted_cb()
*/
-int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback,
- void *user_data);
+int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data);
/**
* @brief Unregisters the callback function.
@@ -1862,6 +1873,31 @@ int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback,
int camera_unset_interrupted_cb(camera_h camera);
/**
+ * @brief Registers a callback function to be called when the camera interrupt is started by policy.
+ * @since_tizen 4.0
+ * @param[in] camera The handle to the camera
+ * @param[in] callback The callback function to register
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see camera_unset_interrupt_started_cb()
+ * @see camera_interrupt_started_cb()
+ */
+int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen 4.0
+ * @param[in] camera The handle to the camera
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CAMERA_ERROR_NONE Successful
+ * @retval #CAMERA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see camera_set_interrupt_started_cb()
+ */
+int camera_unset_interrupt_started_cb(camera_h camera);
+
+/**
* @brief Registers a callback function to be called when the auto-focus state changes.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] camera The handle to the camera
diff --git a/packaging/capi-media-camera.spec b/packaging/capi-media-camera.spec
index 51b0ac8..b5b3e54 100644
--- a/packaging/capi-media-camera.spec
+++ b/packaging/capi-media-camera.spec
@@ -1,6 +1,6 @@
Name: capi-media-camera
Summary: A Camera API
-Version: 0.3.1
+Version: 0.3.2
Release: 0
Group: Multimedia/API
License: Apache-2.0
diff --git a/src/camera.c b/src/camera.c
index 6b999f6..39d7d6c 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -1343,6 +1343,27 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
(camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
}
break;
+ case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
+ {
+ int policy = 0;
+ int state = 0;
+
+ muse_camera_msg_get(policy, recv_msg);
+ muse_camera_msg_get(state, recv_msg);
+
+ LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
+
+ if (policy == CAMERA_POLICY_SOUND)
+ LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
+ else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
+ LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
+ else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
+ LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
+
+ ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
+ (camera_state_e)state, cb_info->user_data[event]);
+ }
+ break;
case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
{
int count = 0;
@@ -1555,8 +1576,8 @@ static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_m
LOGD("return buffer done");
}
break;
- default: /* MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
- LOGE("render error");
+ default:
+ LOGW("unhandled event %d", event);
break;
}
@@ -3971,6 +3992,58 @@ int camera_unset_interrupted_cb(camera_h camera)
}
+int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
+
+ if (!pc || !pc->cb_info || !callback) {
+ LOGE("NULL pointer %p %p", pc, callback);
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
+ }
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
+int camera_unset_interrupt_started_cb(camera_h camera)
+{
+ int ret = CAMERA_ERROR_NONE;
+ camera_cli_s *pc = (camera_cli_s *)camera;
+ muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
+
+ if (!pc || !pc->cb_info) {
+ LOGE("NULL handle");
+ return CAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ LOGD("Enter");
+
+ _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+ pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
+ }
+
+ LOGD("ret : 0x%x", ret);
+
+ return ret;
+}
+
+
int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
{
int ret = CAMERA_ERROR_NONE;
diff --git a/test/camera_test.c b/test/camera_test.c
index 022074c..d5dc5e3 100644
--- a/test/camera_test.c
+++ b/test/camera_test.c
@@ -451,6 +451,12 @@ static void _camera_interrupted_cb(camera_policy_e policy, camera_state_e previo
return;
}
+static void _camera_interrupt_started_cb(camera_policy_e policy, camera_state_e state, void *user_data)
+{
+ g_print("\ncamera interrupt started callback called[state %d, policy %d]\n", state, policy);
+ return;
+}
+
static bool preview_resolution_cb(int width, int height, void *user_data)
{
resolution_stack *data = (resolution_stack *)user_data;
@@ -763,6 +769,7 @@ static void main_menu(gchar buf)
camera_set_error_cb(hcamcorder->camera, _camera_error_cb, NULL);
camera_set_state_changed_cb(hcamcorder->camera, _camera_state_changed_cb, NULL);
camera_set_interrupted_cb(hcamcorder->camera, _camera_interrupted_cb, NULL);
+ camera_set_interrupt_started_cb(hcamcorder->camera, _camera_interrupt_started_cb, NULL);
camera_set_display_mode(hcamcorder->camera, CAMERA_DISPLAY_MODE_LETTER_BOX);
@@ -1446,6 +1453,7 @@ static gboolean mode_change(gchar buf)
camera_set_error_cb(hcamcorder->camera, _camera_error_cb, NULL);
camera_set_state_changed_cb(hcamcorder->camera, _camera_state_changed_cb, NULL);
camera_set_interrupted_cb(hcamcorder->camera, _camera_interrupted_cb, NULL);
+ camera_set_interrupt_started_cb(hcamcorder->camera, _camera_interrupt_started_cb, NULL);
camera_set_display_mode(hcamcorder->camera, CAMERA_DISPLAY_MODE_LETTER_BOX);
/*camera_set_display_rotation(hcamcorder->camera, CAMERA_ROTATION_90);*/
/*camera_set_display_flip(hcamcorder->camera, CAMERA_FLIP_VERTICAL);*/