Merge "Provide callback support to battery monitor frwk when BT is disabled" into...
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / include / bt-service-audio-common.h
1 /*
2  * Bluetooth-frwk
3  *
4  * Copyright (c) 2015 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:  Anupam Roy <anupam.r@samsung.com>
7  *
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
11  *
12  *              http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22
23 #ifndef __BT_SERVICE_AUDIO_COMMON_H__
24 #define __BT_SERVICE_AUDIO_COMMON_H__
25
26 #include "bluetooth-audio-api.h"
27 #include "bt-service-event-receiver.h"
28 #include  <bt-service-common.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 typedef enum {
34         BT_PENDING_NONE = 0x00,
35         BT_PENDING_CONNECT,
36         BT_PENDING_DISCONNECT
37 } bt_pending_request_t;
38
39 typedef enum {
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 */
48 } bt_audio_type_t;
49
50 typedef enum {
51         SERVICE_SEARCH_NOT_STARTED,
52         SERVICE_SEARCH_STARTED,
53         SERVICE_SEARCH_DONE,
54 } bt_audio_service_search_e;
55
56 typedef struct {
57         char *address;
58         bt_audio_type_t type;
59         bt_audio_type_t conn_req_type;
60         bt_audio_service_search_e search_status;
61         gboolean is_a2dp_src_supported;
62         gboolean is_a2dp_sink_supported;
63         gboolean is_hfp_supported;
64         unsigned char bonded_info_retries;
65 } bt_pending_audio_conn_t;
66
67 typedef struct {
68         char *address;
69         bt_pending_request_t  pending;
70         int type;
71 } bt_audio_function_data_t;
72
73 typedef struct {
74         int type;
75         int disconnection_type;
76         char *address;
77         gboolean ag_flag;
78 } bt_headset_wait_t;
79
80 typedef enum {
81         BT_STATE_NONE = 0x00,
82         BT_STATE_CONNECTING,
83         BT_STATE_CONNECTED,
84         BT_STATE_DISCONNECTING,
85         BT_STATE_DISCONNECTED
86 } bt_headset_device_state_t;
87
88 int _bt_audio_initialize(bt_service_module_t module);
89
90 int _bt_audio_connect(int type, bluetooth_device_address_t *device_address);
91
92 int _bt_audio_disconnect(int type, bluetooth_device_address_t *device_address);
93
94 gboolean _bt_is_service_connected(char* address, int type);
95
96 void _bt_remove_service_search_request(char *address);
97
98 void _bt_remove_headset_from_list(int type, const char *address);
99
100 bt_headset_wait_t *_bt_get_audio_wait_data(void);
101
102 void _bt_rel_wait_data(void);
103
104 void _bt_set_audio_wait_data_flag(gboolean flag);
105
106 void _bt_audio_check_pending_connect(char *address);
107
108 gboolean _bt_is_headset_type_connected(int type, char *address);
109
110 gboolean _bt_is_headset_address_type_connected(int type, const char *address);
111
112 void _bt_add_headset_to_list(int type, int status, const char *address);
113
114 void _bt_remove_service_search_request(char *address);
115
116 bt_pending_audio_conn_t* _bt_get_pending_audio_conn_info(char *address);
117
118 void _bt_cleanup_audio_pending_conn_info_and_reply_pending_req(bt_pending_audio_conn_t *info,
119                                                         int result);
120 gboolean _bt_audio_check_pending_connection(char *address);
121
122 void _bt_audio_check_pending_disconnection(char *address, int type);
123
124 int _bt_audio_select_role(bluetooth_audio_role_t role);
125
126 void _bt_audio_set_current_role(bluetooth_audio_role_t role);
127
128 int _bt_hf_connect(bluetooth_device_address_t *device_address);
129
130 int _bt_hf_disconnect(bluetooth_device_address_t *device_address);
131
132 #ifdef __cplusplus
133 }
134 #endif /* __cplusplus */
135 #endif /* __BT_SERVICE_AUDIO_COMMON_H__ */