Added CAPI for BT Audio Role selection 95/150695/1
authorAtul Rai <a.rai@samsung.com>
Mon, 18 Sep 2017 09:04:17 +0000 (14:34 +0530)
committerAtul Rai <a.rai@samsung.com>
Mon, 18 Sep 2017 09:04:17 +0000 (14:34 +0530)
Change-Id: I870b9f4290af3cddeaff0449a1f277f8b2b6a46f
Signed-off-by: Atul Rai <a.rai@samsung.com>
include/mobile/bluetooth_internal.h
include/mobile/bluetooth_type_internal.h
include/tv/bluetooth_internal.h
include/tv/bluetooth_type_internal.h
include/wearable/bluetooth_internal.h
include/wearable/bluetooth_type_internal.h
src/bluetooth-audio.c
test/bt_unit_test.c
test/bt_unit_test.h

index 66b7069cbb39426c413f5e47a37091a6bbc58af8..bcea6f9b050f9a1bb85d625be19cc1ee3e34abbd 100644 (file)
@@ -122,6 +122,24 @@ 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 9eae080b64797e3dda47f1e20786bd0766633f28..1c312ba06da983e81be76176f49b8610330601dd 100644 (file)
@@ -93,6 +93,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_ADAPTER_MODULE
  * @brief  Called when the connectable state changes.
index 66b7069cbb39426c413f5e47a37091a6bbc58af8..bcea6f9b050f9a1bb85d625be19cc1ee3e34abbd 100644 (file)
@@ -122,6 +122,24 @@ 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 92f17dfc812e117e1512be00d75e001b9cb01cfc..dcb21452d1a57a4b56d9af8b66c0d6e47c1f1c1b 100644 (file)
@@ -93,6 +93,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_ADAPTER_MODULE
  * @brief  Called when the connectable state changes.
index 6a99d860f8447fdc875fe890c483406f8394374c..5958a5e8011967db4e39fc82c2ecc56ad90b2e56 100644 (file)
@@ -122,6 +122,24 @@ 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 a6b75653ea289745150287c22928ab401da7f6fa..d1657bc56d60aa3e02d0cad230522e4eee2d9b9d 100644 (file)
@@ -95,6 +95,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_ADAPTER_MODULE
  * @brief  Called when the connectable state changes.
index 5929f96bc8939fb038b01b6b21f30fd96146288b..b609a801b8d3980d861e46045c56891739736f19 100644 (file)
@@ -319,6 +319,22 @@ int bt_audio_disconnect(const char *remote_address, bt_audio_profile_type_e type
 
        return error;
 }
+
+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;
+}
 /* LCOV_EXCL_STOP */
 
 int bt_audio_set_connection_state_changed_cb(bt_audio_connection_state_changed_cb callback, void *user_data)
index 22422289108518ef07548f32f6b5bef26b6c7908..c6aa47158aa4b95a840b65dbefe6a77b2a5fe9ac 100644 (file)
@@ -521,7 +521,10 @@ tc_table_t tc_audio[] = {
                , BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB},
        {"bt_ag_is_nrec_enabled"
                , BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED},
-
+       {"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},
@@ -6191,7 +6194,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 6e83527f963b91cc7bcf51af5bcfa5b7e746523e..3f906198f1e0eb5462bcbebfbe6712dba3202792 100644 (file)
@@ -211,6 +211,8 @@ typedef enum {
        BT_UNIT_TEST_FUNCTION_AG_NOTIFY_CALL_LIST,
        BT_UNIT_TEST_FUNCTION_AG_SET_CALL_HANDLING_EVENT_CB,
        BT_UNIT_TEST_FUNCTION_AG_IS_NREC_ENABLED,
+       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,