From: Jeongmo Yang Date: Fri, 9 Jun 2017 09:41:09 +0000 (+0900) Subject: [ACR-988] Add interrupt started callback related APIs X-Git-Tag: submit/tizen/20170614.052326^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F39%2F133239%2F5;p=platform%2Fcore%2Fapi%2Frecorder.git [ACR-988] Add interrupt started callback related APIs 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.3 [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: Ie9a68a5db4c5aa1498e68c01773627680da43f7e Signed-off-by: Jeongmo Yang --- diff --git a/include/recorder.h b/include/recorder.h index c0e2c4a..f64c79d 100644 --- a/include/recorder.h +++ b/include/recorder.h @@ -247,7 +247,8 @@ typedef void (*recorder_device_state_changed_cb)(recorder_type_e type, recorder_ /** * @brief Called when the recorder is interrupted by a policy. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - * @param[in] policy The policy that is interrupting the recorder + * @remarks This callback is called after interrupt handling is completed. + * @param[in] policy The policy that interrupted the recorder * @param[in] previous The previous state of the recorder * @param[in] current The current state of the recorder * @param[in] user_data The user data passed from the callback registration function @@ -255,6 +256,17 @@ typedef void (*recorder_device_state_changed_cb)(recorder_type_e type, recorder_ */ typedef void (*recorder_interrupted_cb)(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *user_data); +/** + * @brief Called when the recorder interrupt is started by a policy. + * @since_tizen 4.0 + * @remarks This callback is called before interrupt handling is started. + * @param[in] policy The policy that is interrupting the recorder + * @param[in] state The current state of the recorder + * @param[in] user_data The user data passed from the callback registration function + * @see recorder_set_interrupt_started_cb() + */ +typedef void (*recorder_interrupt_started_cb)(recorder_policy_e policy, recorder_state_e state, void *user_data); + /** * @brief Called when audio stream data was being delivered just before storing in the recorded file. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif @@ -1030,8 +1042,7 @@ int recorder_unset_state_changed_cb(recorder_h recorder); * @see recorder_unset_interrupted_cb() * @see recorder_interrupted_cb() */ -int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, - void *user_data); +int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb callback, void *user_data); /** * @brief Unregisters the callback function. @@ -1047,6 +1058,31 @@ int recorder_set_interrupted_cb(recorder_h recorder, recorder_interrupted_cb cal */ int recorder_unset_interrupted_cb(recorder_h recorder); +/** + * @brief Registers a callback function to be called when the media recorder interrupt is started according to a policy. + * @since_tizen 4.0 + * @param[in] recorder The handle to the media recorder + * @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 #RECORDER_ERROR_NONE Successful + * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter + * @see recorder_unset_interrupt_started_cb() + * @see recorder_interrupt_started_cb() + */ +int recorder_set_interrupt_started_cb(recorder_h recorder, recorder_interrupt_started_cb callback, void *user_data); + +/** + * @brief Unregisters the callback function. + * @since_tizen 4.0 + * @param[in] recorder The handle to the media recorder + * @return @c 0 on success, otherwise a negative error value + * @retval #RECORDER_ERROR_NONE Successful + * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter + * @see recorder_set_interrupt_started_cb() + */ +int recorder_unset_interrupt_started_cb(recorder_h recorder); + /** * @brief Registers a callback function to be called when audio stream data is being delivered. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif diff --git a/packaging/capi-media-recorder.spec b/packaging/capi-media-recorder.spec index 52d7a2a..4671832 100644 --- a/packaging/capi-media-recorder.spec +++ b/packaging/capi-media-recorder.spec @@ -1,6 +1,6 @@ Name: capi-media-recorder Summary: A Recorder API -Version: 0.3.2 +Version: 0.3.3 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/recorder.c b/src/recorder.c index de81bd5..38f833f 100644 --- a/src/recorder.c +++ b/src/recorder.c @@ -239,6 +239,27 @@ static void _recorder_client_user_callback(recorder_cb_info_s *cb_info, char *re cb_info->user_data[event]); break; } + case MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED: + { + int policy = 0; + int state = 0; + + muse_recorder_msg_get(policy, recv_msg); + muse_recorder_msg_get(state, recv_msg); + + LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state); + + if (policy == RECORDER_POLICY_SOUND) + LOGW("DEPRECATION WARNING: RECORDER_POLICY_SOUND is deprecated and will be removed from next release."); + else if (policy == RECORDER_POLICY_SOUND_BY_CALL) + LOGW("DEPRECATION WARNING: RECORDER_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release."); + else if (policy == RECORDER_POLICY_SOUND_BY_ALARM) + LOGW("DEPRECATION WARNING: RECORDER_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release."); + + ((recorder_interrupt_started_cb)cb_info->user_cb[event])((recorder_policy_e)policy, + (recorder_state_e)state, cb_info->user_data[event]); + } + break; case MUSE_RECORDER_EVENT_TYPE_AUDIO_STREAM: { int tbm_key = 0; @@ -2345,6 +2366,58 @@ int recorder_unset_interrupted_cb(recorder_h recorder) } +int recorder_set_interrupt_started_cb(recorder_h recorder, recorder_interrupt_started_cb callback, void *user_data) +{ + int ret = RECORDER_ERROR_NONE; + recorder_cli_s *pc = (recorder_cli_s *)recorder; + muse_recorder_api_e api = MUSE_RECORDER_API_SET_INTERRUPT_STARTED_CB; + + if (!pc || !pc->cb_info || callback == NULL) { + LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + LOGD("Enter, handle :%x", pc->remote_handle); + + _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); + + if (ret == RECORDER_ERROR_NONE) { + pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = callback; + pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = user_data; + } + + LOGD("ret : 0x%x", ret); + + return ret; +} + + +int recorder_unset_interrupt_started_cb(recorder_h recorder) +{ + int ret = RECORDER_ERROR_NONE; + muse_recorder_api_e api = MUSE_RECORDER_API_UNSET_INTERRUPT_STARTED_CB; + recorder_cli_s *pc = (recorder_cli_s *)recorder; + + if (!pc || !pc->cb_info) { + LOGE("NULL handle"); + return RECORDER_ERROR_INVALID_PARAMETER; + } + + LOGD("ENTER"); + + _recorder_msg_send(api, pc->cb_info, &ret, RECORDER_CB_TIMEOUT); + + if (ret == RECORDER_ERROR_NONE) { + pc->cb_info->user_cb[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL; + pc->cb_info->user_data[MUSE_RECORDER_EVENT_TYPE_INTERRUPT_STARTED] = NULL; + } + + LOGD("ret : 0x%x", ret); + + return ret; +} + + int recorder_set_audio_stream_cb(recorder_h recorder, recorder_audio_stream_cb callback, void *user_data) { int ret = RECORDER_ERROR_NONE;