From: Abhishek Chandra Date: Tue, 4 Apr 2017 05:31:04 +0000 (+0530) Subject: A2DP role change CAPI implementation X-Git-Tag: submit/tizen/20170410.040751~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8ffa9dfac75cc72711ad7d30431295dcc5bd30c;p=platform%2Fcore%2Fapi%2Fbluetooth.git A2DP role change CAPI implementation Change-Id: Ib0a5b5ab07cad2206d2b2b1c792f24e15689f902 Signed-off-by: Abhishek Chandra --- diff --git a/include/bluetooth_internal.h b/include/bluetooth_internal.h index d3567d6..20ee777 100644 --- a/include/bluetooth_internal.h +++ b/include/bluetooth_internal.h @@ -122,6 +122,23 @@ int bt_adapter_disable(void); */ int bt_adapter_recover(void); +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief A2DP source/sink role is switched using this API + * @since_tizen 4.0 + * @param[in] Role for A2DP + * @return @c 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 + * @retval #BT_ERROR_OPERATION_FAILED Internal Error + * @pre The Bluetooth service must be initialized with bt_initialize(). + * @pre The Bluetooth audio service must be initialized with bt_audio_initialize(). + * @see bt_initialize() + * @see bt_audio_initialize() + */ +int bt_audio_select_role(bt_audio_role_e role); /** * @internal * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE diff --git a/include/bluetooth_type_internal.h b/include/bluetooth_type_internal.h index da53b9e..906ba33 100644 --- a/include/bluetooth_type_internal.h +++ b/include/bluetooth_type_internal.h @@ -117,6 +117,16 @@ typedef enum { BT_TRANSFER_OUTBOUND, /**< Outbound Transfer Type */ } bt_opp_transfer_type_t; +/** + * @ingroup CAPI_NETWORK_BLUETOOTH_AUDIO_MODULE + * @brief Enumerations of the Bluetooth A2DP role. + * @since_tizen 4.0 + */ +typedef enum { + BT_A2DP_SOURCE, + BT_A2DP_SINK, +} bt_audio_role_e; + /** * @ingroup CAPI_NETWORK_BLUETOOTH_MAP_CLIENT_MODULE * @brief diff --git a/src/bluetooth-audio.c b/src/bluetooth-audio.c index 623cc77..466c695 100644 --- a/src/bluetooth-audio.c +++ b/src/bluetooth-audio.c @@ -317,6 +317,22 @@ int bt_audio_disconnect(const char *remote_address, bt_audio_profile_type_e type } /* LCOV_EXCL_STOP */ +int bt_audio_select_role(bt_audio_role_e role) +{ + BT_CHECK_AUDIO_SUPPORT(); + BT_CHECK_INIT_STATUS(); + BT_CHECK_AUDIO_INIT_STATUS(); + int ret; + + ret = bluetooth_audio_select_role(role); + ret = _bt_get_error_code(ret); + + if (ret != BT_ERROR_NONE) + BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret); + + return ret; +} + int bt_audio_set_connection_state_changed_cb(bt_audio_connection_state_changed_cb callback, void *user_data) { BT_CHECK_AUDIO_SUPPORT(); diff --git a/test/bt_unit_test.c b/test/bt_unit_test.c index 9358703..a639e90 100644 --- a/test/bt_unit_test.c +++ b/test/bt_unit_test.c @@ -519,7 +519,10 @@ tc_table_t tc_audio[] = { , BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED}, {"bt_ag_switch_headset" , BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET}, - + {"bt_audio_select_role(source)" + , BT_UNIT_TEST_FUNCTION_A2DP_SOURCE_ROLE}, + {"bt_audio_select_role(sink)" + , BT_UNIT_TEST_FUNCTION_A2DP_SINK_ROLE}, /* A2DP SCMS-T functions */ {"Select this menu to set parameters and then select the function again." , BT_UNIT_TEST_FUNCTION_ACTIVATE_FLAG_TO_SET_PARAMETERS}, @@ -6339,7 +6342,18 @@ int test_input_callback(void *data) need_to_set_params = true; TC_PRT("Select the function again"); break; - + case BT_UNIT_TEST_FUNCTION_A2DP_SOURCE_ROLE: { + bt_audio_role_e role = BT_A2DP_SOURCE; + ret = bt_audio_select_role(role); + TC_PRT("Asdp Source set change ret = %d", ret); + break; + } + case BT_UNIT_TEST_FUNCTION_A2DP_SINK_ROLE: { + bt_audio_role_e role = BT_A2DP_SINK; + ret = bt_audio_select_role(role); + TC_PRT("Asdp Sink set change ret = %d", ret); + break; + } default: break; } diff --git a/test/bt_unit_test.h b/test/bt_unit_test.h index 5737491..f5b210a 100644 --- a/test/bt_unit_test.h +++ b/test/bt_unit_test.h @@ -204,6 +204,8 @@ typedef enum { BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB, BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED, BT_UNIT_TEST_FUNCTION_AG_SWITCH_HEADSET, + BT_UNIT_TEST_FUNCTION_A2DP_SOURCE_ROLE, + BT_UNIT_TEST_FUNCTION_A2DP_SINK_ROLE, BT_UNIT_TEST_FUNCTION_AG_IS_WBS_MODE, BT_UNIT_TEST_FUNCTION_AG_SET_VENDOR_CMD_CB, BT_UNIT_TEST_FUNCTION_AG_UNSET_VENDOR_CMD_CB,