return result;
}
+BT_EXPORT_API int bluetooth_audio_select_role(bluetooth_audio_role_t role)
+{
+ int result;
+
+ BT_CHECK_ENABLED(return);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, &role, sizeof(bluetooth_audio_role_t));
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_AUDIO_SELECT_ROLE,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+ return result;
+}
+
BT_EXPORT_API int bluetooth_ag_get_headset_volume(unsigned int *speaker_gain)
{
int result;
{BT_GET_SPEAKER_GAIN, "BT_GET_SPEAKER_GAIN"},
{BT_SET_SPEAKER_GAIN, "BT_SET_SPEAKER_GAIN"},
{BT_SET_CONTENT_PROTECT, "BT_SET_CONTENT_PROTECT"},
+ {BT_AUDIO_SELECT_ROLE, "BT_AUDIO_SELECT_ROLE"},
{BT_OOB_READ_LOCAL_DATA, "BT_OOB_READ_LOCAL_DATA"},
{BT_OOB_ADD_REMOTE_DATA, "BT_OOB_ADD_REMOTE_DATA"},
{BT_OOB_REMOVE_REMOTE_DATA, "BT_OOB_REMOVE_REMOTE_DATA"},
break;
}
+ case BT_AUDIO_SELECT_ROLE: {
+
+ bluetooth_audio_role_t role;
+
+ __bt_service_get_parameters(in_param1,
+ &role, sizeof(bluetooth_audio_role_t));
+
+ result = _bt_audio_select_role(role);
+
+ break;
+ }
case BT_OOB_READ_LOCAL_DATA: {
bt_oob_data_t local_oob_data;
case BT_PBAP_GET_LIST:
case BT_PBAP_PULL_VCARD:
case BT_PBAP_PHONEBOOK_SEARCH:
+ case BT_AUDIO_SELECT_ROLE:
ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
BT_PRIVILEGE_PUBLIC);
vconf_set_str(BT_LAST_CONNECTED_DEVICE, address);
}
#endif /*TIZEN_BT_A2DP_SINK_AUTO_CONNECT */
+
+int _bt_audio_select_role(bluetooth_audio_role_t role)
+{
+
+ GDBusProxy *proxy;
+ GVariant *ret;
+ GError *error = NULL;
+ GDBusConnection *g_conn = _bt_gdbus_get_system_gconn();
+ gchar *adapter_path = _bt_get_adapter_path();
+
+ BT_INFO("_bt_audio_select_role called [%d]", role);
+
+ retv_if(adapter_path == NULL, BLUETOOTH_ERROR_INTERNAL);
+ BT_INFO("Adapter Path = %s", adapter_path);
+
+ proxy = g_dbus_proxy_new_sync(g_conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ BT_BLUEZ_NAME, adapter_path, BT_MEDIA_INTERFACE, NULL, &error);
+
+ g_free(adapter_path);
+
+ if (proxy == NULL) {
+ BT_ERR("Unable to create proxy");
+
+ if (error) {
+ BT_ERR("Error: %s", error->message);
+ g_clear_error(&error);
+ }
+
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ if (role == BLUETOOTH_A2DP_SOURCE)
+ ret = g_dbus_proxy_call_sync(proxy, "SelectRole", g_variant_new("(s)", "source"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ else
+ ret = g_dbus_proxy_call_sync(proxy, "SelectRole", g_variant_new("(s)", "sink"),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+ g_object_unref(proxy);
+
+ if (ret == NULL) {
+ BT_ERR("Call SelectRole Failed");
+ if (error) {
+ BT_ERR("errCode[%x], message[%s]", error->code, error->message);
+ g_clear_error(&error);
+ }
+
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ g_variant_unref(ret);
+ return BLUETOOTH_ERROR_NONE;
+}
#include <glib.h>
#include <sys/types.h>
#include "bluetooth-api.h"
+#include "bluetooth-audio-api.h"
#ifdef __cplusplus
extern "C" {
#define BT_AUTO_CONNECT_TIMEOUT_RETRY_TIME 3600 /* 60 minute */
#endif
+int _bt_audio_select_role(bluetooth_audio_role_t role);
+
int _bt_audio_connect(int request_id, int type,
bluetooth_device_address_t *device_address,
GArray *out_param1);
BLUETOOTH_STATE_A2DP_HEADSET_CONNECTED = 0x0010,
} bluetooth_device_state_t;
+typedef enum {
+ BLUETOOTH_A2DP_SOURCE,
+ BLUETOOTH_A2DP_SINK,
+} bluetooth_audio_role_t;
+
/**
* @brief The function bluetooth_audio_init called to initializes the Audio
* service to bluetoothD and Global data related to audio.
*/
int bluetooth_ag_set_speaker_gain(unsigned int speaker_gain);
+/**
+ * @brief The function bluetooth_audio_select_role is called to set
+ * A2DP to Source or Sink.
+ *
+ * @param[in] role SINK/SOURCE.
+ * @return int Zero on Success or reason for error if any.
+ *
+ */
+int bluetooth_audio_select_role(bluetooth_audio_role_t role);
+
typedef struct {
int event;
int result;
BT_GET_SPEAKER_GAIN,
BT_SET_SPEAKER_GAIN,
BT_SET_CONTENT_PROTECT,
+ BT_AUDIO_SELECT_ROLE,
BT_OOB_READ_LOCAL_DATA = BT_FUNC_OOB_BASE,
BT_OOB_ADD_REMOTE_DATA,
BT_OOB_REMOVE_REMOTE_DATA,