4 * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Anupam Roy <anupam.r@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 #ifndef __BT_SERVICE_AUDIO_COMMON_H__
24 #define __BT_SERVICE_AUDIO_COMMON_H__
26 #include "bluetooth-audio-api.h"
27 #include "bt-service-event-receiver.h"
28 #include <bt-service-common.h>
34 BT_PENDING_NONE = 0x00,
37 } bt_pending_request_t;
40 BT_AUDIO_HSP = 0x01, /* HSP Connection */
41 BT_AUDIO_A2DP = 0x02, /* A2DP Source Connection, remote device is A2DP Sink */
42 BT_AUDIO_ALL = 0x03, /* HSP and A2DP Source Connection (BT_AUDIO_HSP and BT_AUDIO_A2DP) */
43 BT_AVRCP_TARGET = 0x04, /* AVRCP Target Connection to remote AVRCP controller */
44 BT_AVRCP = 0x08, /* AVRCP ctrl Connection to remote AVRCP target */
45 BT_AUDIO_A2DP_SOURCE = 0x10, /* A2DP Sink Connection, remote device is A2DP Source */
46 BT_AUDIO_HFP_SOURCE = 0x11, /* HSP and A2DP Sink Connection (BT_AUDIO_HSP and BT_AUDIO_A2DP_SOURCE)*/
47 BT_AUDIO_AG = 0x12 /* BT_HF_CONNECT local device HF Client and remote device AG */
51 BT_A2DP_SOURCE_ROLE = 0,
56 SERVICE_SEARCH_NOT_STARTED,
57 SERVICE_SEARCH_STARTED,
59 } bt_audio_service_search_e;
64 bt_audio_type_t conn_req_type;
65 bt_audio_service_search_e search_status;
66 gboolean is_a2dp_src_supported;
67 gboolean is_a2dp_sink_supported;
68 gboolean is_hfp_supported;
69 unsigned char bonded_info_retries;
70 } bt_pending_audio_conn_t;
74 bt_pending_request_t pending;
76 } bt_audio_function_data_t;
80 int disconnection_type;
89 BT_STATE_DISCONNECTING,
91 } bt_headset_device_state_t;
93 int _bt_audio_initialize(bt_service_module_t module);
95 int _bt_audio_connect(int type, bluetooth_device_address_t *device_address);
97 int _bt_audio_disconnect(int type, bluetooth_device_address_t *device_address);
99 gboolean _bt_is_service_connected(char* address, int type);
101 void _bt_remove_service_search_request(char *address);
103 void _bt_remove_headset_from_list(int type, const char *address);
105 bt_headset_wait_t *_bt_get_audio_wait_data(void);
107 void _bt_rel_wait_data(void);
109 void _bt_set_audio_wait_data_flag(gboolean flag);
111 void _bt_audio_check_pending_connect(char *address);
113 gboolean _bt_is_headset_type_connected(int type, char *address);
115 gboolean _bt_is_headset_address_type_connected(int type, const char *address);
117 void _bt_add_headset_to_list(int type, int status, const char *address);
119 void _bt_remove_service_search_request(char *address);
121 bt_pending_audio_conn_t* _bt_get_pending_audio_conn_info(char *address);
123 void _bt_cleanup_audio_pending_conn_info_and_reply_pending_req(bt_pending_audio_conn_t *info,
125 gboolean _bt_audio_check_pending_connection(char *address);
127 void _bt_audio_check_pending_disconnection(char *address, int type);
129 int _bt_audio_select_role(bluetooth_audio_role_t role);
131 void _bt_audio_set_current_role(bluetooth_audio_role_t role);
133 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
140 int _bt_audio_init_absolute_volume_control(void);
142 void _bt_audio_deinit_absolute_volume_control(void);
144 int _bt_audio_set_absolute_volume(unsigned int volume);
146 int _bt_audio_get_absolute_volume(unsigned int *volume);
148 int _bt_audio_is_avc_activated(bool *activated);
150 int _bt_audio_get_avc_mode(unsigned int *avc_mode);
152 void _bt_audio_handle_adapter_disabled(void);
154 void _bt_audio_handle_a2dp_state_changed(const char *address, bool connected);
156 void _bt_audio_handle_transport_volume_changed(unsigned int bt_vol);
159 int _bt_hf_connect(bluetooth_device_address_t *device_address);
161 int _bt_hf_disconnect(bluetooth_device_address_t *device_address);
165 #endif /* __cplusplus */
166 #endif /* __BT_SERVICE_AUDIO_COMMON_H__ */