A2DP role change CAPI implementation 54/122954/2
authorAbhishek Chandra <abhishek.ch@samsung.com>
Tue, 4 Apr 2017 05:31:04 +0000 (11:01 +0530)
committerAbhishek Chandra <abhishek.ch@samsung.com>
Tue, 4 Apr 2017 11:00:29 +0000 (16:30 +0530)
Change-Id: Ib0a5b5ab07cad2206d2b2b1c792f24e15689f902
Signed-off-by: Abhishek Chandra <abhishek.ch@samsung.com>
include/bluetooth_internal.h
include/bluetooth_type_internal.h
src/bluetooth-audio.c
test/bt_unit_test.c
test/bt_unit_test.h

index d3567d699c23c6670bd4863d717f62686b35a328..20ee777222ff173d24ea780a9fc40495bc375afa 100644 (file)
@@ -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
index da53b9ea0a5f639629cc2128f40d3375c4c762cf..906ba33efa18305ffd8188d9a95b26edd2e08d2a 100644 (file)
@@ -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
index 623cc777ebf9970c38a4d20e464e6643f7c4c097..466c695364928ca5ff08a671fd049c8944e44358 100644 (file)
@@ -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();
index 93587033c5409d7770839a026457496aed6a4747..a639e906f6f7d11bb7fb6892d60ae9b67d31cd90 100644 (file)
@@ -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;
                }
index 573749146ddb2e49d428c6205fd24c77820bc1b9..f5b210a13b6cf933d89c3647d62a88d9b4ec298c 100644 (file)
@@ -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,