edeff567d05633d1868fbe6d2c2f517515c57eb7
[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 "bt-service-event-receiver.h"
27 #include  <bt-service-common.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 typedef enum {
33         BT_PENDING_NONE = 0x00,
34         BT_PENDING_CONNECT,
35         BT_PENDING_DISCONNECT
36 } bt_pending_request_t;
37
38 typedef enum {
39         BT_AUDIO_HSP = 0x01,    /* HSP Connection */
40         BT_AUDIO_A2DP = 0x02,           /* A2DP Source Connection, remote device is A2DP Sink */
41         BT_AUDIO_ALL = 0x03,            /* HSP and A2DP Source Connection */
42         BT_AVRCP_TARGET = 0x04, /* AVRCP Target Connection to remote AVRCP controller */
43         BT_AVRCP = 0x08,        /* AVRCP ctrl Connection to remote AVRCP target */
44         BT_AUDIO_A2DP_SOURCE = 0x10,    /* A2DP Sink Connection, remote device is A2DP Source */
45         BT_AUDIO_HFP_SOURCE = 0x20      /* HSP and A2DP Sink Connection */
46 } bt_audio_type_t;
47
48 typedef enum {
49         SERVICE_SEARCH_NOT_STARTED,
50         SERVICE_SEARCH_STARTED,
51         SERVICE_SEARCH_DONE,
52 } bt_audio_service_search_e;
53
54 typedef struct {
55         char *address;
56         bt_audio_type_t type;
57         bt_audio_type_t conn_req_type;
58         bt_audio_service_search_e search_status;
59         gboolean is_a2dp_src_supported;
60         gboolean is_a2dp_sink_supported;
61         gboolean is_hfp_supported;
62 } bt_pending_audio_conn_t;
63
64 typedef struct {
65         char *address;
66         bt_pending_request_t  pending;
67         int type;
68 } bt_audio_function_data_t;
69
70 typedef struct {
71         int type;
72         int disconnection_type;
73         char *address;
74         gboolean ag_flag;
75 } bt_headset_wait_t;
76
77 typedef enum {
78         BT_STATE_NONE = 0x00,
79         BT_STATE_CONNECTING,
80         BT_STATE_CONNECTED,
81         BT_STATE_DISCONNECTING,
82         BT_STATE_DISCONNECTED
83 } bt_headset_device_state_t;
84
85 int _bt_audio_initialize(bt_service_module_t module);
86
87 int _bt_audio_connect(int type, bluetooth_device_address_t *device_address);
88
89 int _bt_audio_disconnect(int type, bluetooth_device_address_t *device_address);
90
91 gboolean _bt_is_service_connected(char* address, int type);
92
93 void _bt_remove_service_search_request(char *address);
94
95 void _bt_remove_headset_from_list(int type, const char *address);
96
97 bt_headset_wait_t *_bt_get_audio_wait_data(void);
98
99 void _bt_rel_wait_data(void);
100
101 void _bt_set_audio_wait_data_flag(gboolean flag);
102
103 void _bt_audio_check_pending_connect(char *address);
104
105 gboolean _bt_is_headset_type_connected(int type, char *address);
106
107 void _bt_add_headset_to_list(int type, int status, const char *address);
108
109 void _bt_remove_service_search_request(char *address);
110
111 bt_pending_audio_conn_t* _bt_get_service_search_info(char *address);
112
113 void _bt_cleanup_search_info_and_reply_pending_req(bt_pending_audio_conn_t *info,
114                                                         int result);
115 void _bt_audio_check_pending_connection(char *address);
116
117 void _bt_audio_check_pending_disconnection(char *address, int type);
118
119 #ifdef __cplusplus
120 }
121 #endif /* __cplusplus */
122 #endif /* __BT_SERVICE_AUDIO_COMMON_H__ */