Merge "Fix for unlimited attepmts to write to socket" into tizen
[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_type_t;
48
49 typedef enum {
50         SERVICE_SEARCH_NOT_STARTED,
51         SERVICE_SEARCH_STARTED,
52         SERVICE_SEARCH_DONE,
53 } bt_audio_service_search_e;
54
55 typedef struct {
56         char *address;
57         bt_audio_type_t type;
58         bt_audio_type_t conn_req_type;
59         bt_audio_service_search_e search_status;
60         gboolean is_a2dp_src_supported;
61         gboolean is_a2dp_sink_supported;
62         gboolean is_hfp_supported;
63         unsigned char bonded_info_retries;
64 } bt_pending_audio_conn_t;
65
66 typedef struct {
67         char *address;
68         bt_pending_request_t  pending;
69         int type;
70 } bt_audio_function_data_t;
71
72 typedef struct {
73         int type;
74         int disconnection_type;
75         char *address;
76         gboolean ag_flag;
77 } bt_headset_wait_t;
78
79 typedef enum {
80         BT_STATE_NONE = 0x00,
81         BT_STATE_CONNECTING,
82         BT_STATE_CONNECTED,
83         BT_STATE_DISCONNECTING,
84         BT_STATE_DISCONNECTED
85 } bt_headset_device_state_t;
86
87 int _bt_audio_initialize(bt_service_module_t module);
88
89 int _bt_audio_connect(int type, bluetooth_device_address_t *device_address);
90
91 int _bt_audio_disconnect(int type, bluetooth_device_address_t *device_address);
92
93 gboolean _bt_is_service_connected(char* address, int type);
94
95 void _bt_remove_service_search_request(char *address);
96
97 void _bt_remove_headset_from_list(int type, const char *address);
98
99 bt_headset_wait_t *_bt_get_audio_wait_data(void);
100
101 void _bt_rel_wait_data(void);
102
103 void _bt_set_audio_wait_data_flag(gboolean flag);
104
105 void _bt_audio_check_pending_connect(char *address);
106
107 gboolean _bt_is_headset_type_connected(int type, char *address);
108
109 gboolean _bt_is_headset_address_type_connected(int type, const char *address);
110
111 void _bt_add_headset_to_list(int type, int status, const char *address);
112
113 void _bt_remove_service_search_request(char *address);
114
115 bt_pending_audio_conn_t* _bt_get_pending_audio_conn_info(char *address);
116
117 void _bt_cleanup_audio_pending_conn_info_and_reply_pending_req(bt_pending_audio_conn_t *info,
118                                                         int result);
119 gboolean _bt_audio_check_pending_connection(char *address);
120
121 void _bt_audio_check_pending_disconnection(char *address, int type);
122
123 int _bt_audio_select_role(bluetooth_audio_role_t role);
124
125 void _bt_audio_set_current_role(bluetooth_audio_role_t role);
126
127 #ifdef __cplusplus
128 }
129 #endif /* __cplusplus */
130 #endif /* __BT_SERVICE_AUDIO_COMMON_H__ */