From b0c46f206796456fd5193a89babf8d380ee49430 Mon Sep 17 00:00:00 2001 From: Hyuk Lee Date: Thu, 5 Apr 2018 13:44:38 +0900 Subject: [PATCH] Add the AVRCP delay changed callback function Change-Id: I5308f0eacfd3ee388d487f17fc2637143c5e8fa2 Signed-off-by: Hyuk Lee --- include/bluetooth_internal.h | 34 +++++++++++++++++++++++++++++++ include/bluetooth_private.h | 1 + include/bluetooth_type_internal.h | 11 ++++++++++ src/bluetooth-avrcp.c | 17 ++++++++++++++++ src/bluetooth-common.c | 8 ++++++++ 5 files changed, 71 insertions(+) diff --git a/include/bluetooth_internal.h b/include/bluetooth_internal.h index 359195f..50d7277 100644 --- a/include/bluetooth_internal.h +++ b/include/bluetooth_internal.h @@ -3519,6 +3519,40 @@ int bt_avrcp_control_set_absolute_volume(unsigned int value); */ int bt_avrcp_control_send_delay_report(unsigned int value); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Registers a callback function that will be invoked when the delay is changed. + * @since_tizen 5.0 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The AVRCP service must be initialized with bt_avrcp_target_initialize() or bt_avrcp_control_initialize(). + * @see bt_avrcp_target_initialize() + * @see bt_avrcp_control_initialize() + */ +int bt_avrcp_set_delay_changed_cb(bt_avrcp_delay_changed_cb callback, void *user_data); + +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Unregisters a callback function that will be invoked when the delay is changed. + * @since_tizen 5.0 + * @return 0 on success, otherwise a negative error value. + * @retval #BT_ERROR_NONE Successful + * @retval #BT_ERROR_NOT_INITIALIZED Not initialized + * @retval #BT_ERROR_NOT_SUPPORTED Not supported + * + * @pre The AVRCP service must be initialized with bt_avrcp_target_initialize() or bt_avrcp_control_initialize(). + * @see bt_avrcp_target_initialize() + * @see bt_avrcp_control_initialize() + * @see bt_avrcp_set_delay_changed_cb() + */ +int bt_avrcp_unset_delay_changed_cb(void); + /** * @ingroup CAPI_NETWORK_BLUETOOTH_PROXIMITY_MODULE * @brief Creates the Proximity Profile Reporter Role. diff --git a/include/bluetooth_private.h b/include/bluetooth_private.h index 094ad49..39e25b9 100644 --- a/include/bluetooth_private.h +++ b/include/bluetooth_private.h @@ -107,6 +107,7 @@ typedef enum { BT_EVENT_AVRCP_PLAY_STATUS_CHANGED, /**< AVRCP scan mode change callback */ BT_EVENT_AVRCP_SONG_POSITION_CHANGED, /**< AVRCP scan mode change callback */ BT_EVENT_AVRCP_TRACK_INFO_CHANGED, /**< AVRCP scan mode change callback */ + BT_EVENT_AVRCP_DELAY_CHANGED, /**< AVRCP scan mode change callback */ BT_EVENT_HID_CONNECTION_STATUS, /**< HID connection status callback */ BT_EVENT_HID_DEVICE_CONNECTION_STATUS, /**< HID Device connection status callback */ BT_EVENT_HID_DEVICE_DATA_RECEIVED, /**< HID Device Data received callback */ diff --git a/include/bluetooth_type_internal.h b/include/bluetooth_type_internal.h index 650ab1d..babfb95 100644 --- a/include/bluetooth_type_internal.h +++ b/include/bluetooth_type_internal.h @@ -123,6 +123,17 @@ typedef enum { */ typedef void (*bt_adapter_le_state_changed_cb)(int result, bt_adapter_le_state_e adapter_le_state, void *user_data); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AVRCP_MODULE + * @brief Called when the delay is changed by the remote device. + * @since_tizen 5.0 + * @param[in] delay Streaming delay in milliseconds. + * @param[in] user_data The user data passed from the callback registration function + * @see bt_avrcp_set_delay_changed_cb() + * @see bt_avrcp_unset_delay_changed_cb() + */ +typedef void (*bt_avrcp_delay_changed_cb) (unsigned int delay, void *user_data); + /** * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_AG_MODULE * @brief Enumerations for the call state diff --git a/src/bluetooth-avrcp.c b/src/bluetooth-avrcp.c index 150ab5a..48c3945 100644 --- a/src/bluetooth-avrcp.c +++ b/src/bluetooth-avrcp.c @@ -718,6 +718,23 @@ int bt_avrcp_unset_position_changed_cb(void) return BT_ERROR_NONE; } +int bt_avrcp_set_delay_changed_cb(bt_avrcp_delay_changed_cb callback, void *user_data) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_INPUT_PARAMETER(callback); + _bt_set_cb(BT_EVENT_AVRCP_DELAY_CHANGED, callback, user_data); + return BT_ERROR_NONE; +} + +int bt_avrcp_unset_delay_changed_cb(void) +{ + BT_CHECK_AVRCP_SUPPORT(); + BT_CHECK_INIT_STATUS(); + _bt_unset_cb(BT_EVENT_AVRCP_DELAY_CHANGED); + return BT_ERROR_NONE; +} + int bt_avrcp_set_play_status_changed_cb(bt_avrcp_play_status_changed_cb callback, void *user_data) { BT_CHECK_AVRCP_SUPPORT(); diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c index f94a18a..c7adf14 100644 --- a/src/bluetooth-common.c +++ b/src/bluetooth-common.c @@ -1965,6 +1965,12 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us ((bt_avrcp_position_changed_cb)bt_event_slot_container[event_index].callback) (*postion, bt_event_slot_container[event_index].user_data); break; + case BLUETOOTH_EVENT_AVRCP_DELAY_CHANGED: + BT_INFO("BLUETOOTH_EVENT_AVRCP_DELAY_CHANGED "); + unsigned int *delay = (unsigned int *)(param->param_data); + ((bt_avrcp_delay_changed_cb)bt_event_slot_container[event_index].callback) + (*delay, bt_event_slot_container[event_index].user_data); + break; case BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED: BT_INFO("BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED "); bt_avrcp_metadata_attributes_info_s meta_info = {0, }; @@ -3447,6 +3453,8 @@ static int __bt_get_cb_index(int event) return BT_EVENT_AVRCP_PLAY_STATUS_CHANGED; case BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED: return BT_EVENT_AVRCP_TRACK_INFO_CHANGED; + case BLUETOOTH_EVENT_AVRCP_DELAY_CHANGED: + return BT_EVENT_AVRCP_DELAY_CHANGED; case BLUETOOTH_HID_CONNECTED: return BT_EVENT_HID_CONNECTION_STATUS; case BLUETOOTH_HID_DISCONNECTED: -- 2.34.1