Add interfaces for BT AVC feature (AVRCP Target)
[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         BT_A2DP_SOURCE_ROLE = 0,
52         BT_A2DP_SINK_ROLE,
53 } bt_a2dp_role_t;
54
55 typedef enum {
56         SERVICE_SEARCH_NOT_STARTED,
57         SERVICE_SEARCH_STARTED,
58         SERVICE_SEARCH_DONE,
59 } bt_audio_service_search_e;
60
61 typedef struct {
62         char *address;
63         bt_audio_type_t type;
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;
71
72 typedef struct {
73         char *address;
74         bt_pending_request_t  pending;
75         int type;
76 } bt_audio_function_data_t;
77
78 typedef struct {
79         int type;
80         int disconnection_type;
81         char *address;
82         gboolean ag_flag;
83 } bt_headset_wait_t;
84
85 typedef enum {
86         BT_STATE_NONE = 0x00,
87         BT_STATE_CONNECTING,
88         BT_STATE_CONNECTED,
89         BT_STATE_DISCONNECTING,
90         BT_STATE_DISCONNECTED
91 } bt_headset_device_state_t;
92
93 int _bt_audio_initialize(bt_service_module_t module);
94
95 int _bt_audio_connect(int type, bluetooth_device_address_t *device_address);
96
97 int _bt_audio_disconnect(int type, bluetooth_device_address_t *device_address);
98
99 gboolean _bt_is_service_connected(char* address, int type);
100
101 void _bt_remove_service_search_request(char *address);
102
103 void _bt_remove_headset_from_list(int type, const char *address);
104
105 bt_headset_wait_t *_bt_get_audio_wait_data(void);
106
107 void _bt_rel_wait_data(void);
108
109 void _bt_set_audio_wait_data_flag(gboolean flag);
110
111 void _bt_audio_check_pending_connect(char *address);
112
113 gboolean _bt_is_headset_type_connected(int type, char *address);
114
115 gboolean _bt_is_headset_address_type_connected(int type, const char *address);
116
117 void _bt_add_headset_to_list(int type, int status, const char *address);
118
119 void _bt_remove_service_search_request(char *address);
120
121 bt_pending_audio_conn_t* _bt_get_pending_audio_conn_info(char *address);
122
123 void _bt_cleanup_audio_pending_conn_info_and_reply_pending_req(bt_pending_audio_conn_t *info,
124                                                         int result);
125 gboolean _bt_audio_check_pending_connection(char *address);
126
127 void _bt_audio_check_pending_disconnection(char *address, int type);
128
129 int _bt_audio_select_role(bluetooth_audio_role_t role);
130
131 void _bt_audio_set_current_role(bluetooth_audio_role_t role);
132
133 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
134 typedef enum {
135         BT_AVC_OFF = 0x00,
136         BT_AVC_NULL,
137         BT_AVC_MAX
138 } bt_avc_mode_t;
139
140 int _bt_audio_set_absolute_volume(unsigned int volume);
141
142 int _bt_audio_get_absolute_volume(unsigned int *volume);
143
144 int _bt_audio_is_avc_activated(bool *activated);
145 #endif
146
147 int _bt_hf_connect(bluetooth_device_address_t *device_address);
148
149 int _bt_hf_disconnect(bluetooth_device_address_t *device_address);
150
151 #ifdef __cplusplus
152 }
153 #endif /* __cplusplus */
154 #endif /* __BT_SERVICE_AUDIO_COMMON_H__ */