• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2009-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /**
20  * BTIF AV API functions accessed internally.
21  */
22 
23 #ifndef BTIF_AV_H
24 #define BTIF_AV_H
25 
26 #include "bta_av_api.h"
27 #include "btif_common.h"
28 
29 /**
30  * When the local device is A2DP source, get the address of the active peer.
31  */
32 RawAddress btif_av_source_active_peer(void);
33 
34 /**
35  * When the local device is A2DP sink, get the address of the active peer.
36  */
37 RawAddress btif_av_sink_active_peer(void);
38 
39 /**
40  * Check whether A2DP Sink is enabled.
41  */
42 bool btif_av_is_sink_enabled(void);
43 
44 /**
45  * Start streaming.
46  */
47 void btif_av_stream_start(void);
48 
49 /**
50  * Stop streaming.
51  *
52  * @param peer_address the peer address or RawAddress::kEmpty to stop all peers
53  */
54 void btif_av_stream_stop(const RawAddress& peer_address);
55 
56 /**
57  * Suspend streaming.
58  */
59 void btif_av_stream_suspend(void);
60 
61 /**
62  * Start offload streaming.
63  */
64 void btif_av_stream_start_offload(void);
65 
66 /**
67  * Check whether ready to start the A2DP stream.
68  */
69 bool btif_av_stream_ready(void);
70 
71 /**
72  * Check whether the A2DP stream is in started state and ready
73  * for media start.
74  */
75 bool btif_av_stream_started_ready(void);
76 
77 /**
78  * Check whether there is a connected peer (either Source or Sink)
79  */
80 bool btif_av_is_connected(void);
81 
82 /**
83  * Get the Stream Endpoint Type of the Active peer.
84  *
85  * @return the stream endpoint type: either AVDT_TSEP_SRC or AVDT_TSEP_SNK
86  */
87 uint8_t btif_av_get_peer_sep(void);
88 
89 /**
90  * Clear the remote suspended flag for the active peer.
91  */
92 void btif_av_clear_remote_suspend_flag(void);
93 
94 /**
95  * Check whether the connected A2DP peer supports EDR.
96  *
97  * The value can be provided only if the remote peer is connected.
98  * Otherwise, the answer will be always false.
99  *
100  * @param peer_address the peer address
101  * @return true if the remote peer is capable of EDR
102  */
103 bool btif_av_is_peer_edr(const RawAddress& peer_address);
104 
105 /**
106  * Check whether the connected A2DP peer supports 3 Mbps EDR.
107  *
108  * The value can be provided only if the remote peer is connected.
109  * Otherwise, the answer will be always false.
110  *
111  * @param peer_address the peer address
112  * @return true if the remote peer is capable of EDR and supports 3 Mbps
113  */
114 bool btif_av_peer_supports_3mbps(const RawAddress& peer_address);
115 
116 /**
117  * Report A2DP Source Codec State for a peer.
118  *
119  * @param peer_address the address of the peer to report
120  * @param codec_config the codec config to report
121  * @param codecs_local_capabilities the codecs local capabilities to report
122  * @param codecs_selectable_capabilities the codecs selectable capabilities
123  * to report
124  */
125 void btif_av_report_source_codec_state(
126     const RawAddress& peer_address,
127     const btav_a2dp_codec_config_t& codec_config,
128     const std::vector<btav_a2dp_codec_config_t>& codecs_local_capabilities,
129     const std::vector<btav_a2dp_codec_config_t>&
130         codecs_selectable_capabilities);
131 
132 /**
133  * Initialize / shut down the A2DP Source service.
134  *
135  * @param enable true to enable the A2DP Source service, false to disable it
136  * @return BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
137  */
138 bt_status_t btif_av_source_execute_service(bool enable);
139 
140 /**
141  * Initialize / shut down the A2DP Sink service.
142  *
143  * @param enable true to enable the A2DP Sink service, false to disable it
144  * @return BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
145  */
146 bt_status_t btif_av_sink_execute_service(bool enable);
147 
148 /**
149  * Peer ACL disconnected.
150  *
151  * @param peer_address the disconnected peer address
152  */
153 void btif_av_acl_disconnected(const RawAddress& peer_address);
154 
155 /**
156  * Dump debug-related information for the BTIF AV module.
157  *
158  * @param fd the file descriptor to use for writing the ASCII formatted
159  * information
160  */
161 void btif_debug_av_dump(int fd);
162 
163 /**
164  * Set the audio delay for the stream.
165  *
166  * @param delay the delay to set in units of 1/10ms
167  */
168 void btif_av_set_audio_delay(uint16_t delay);
169 
170 /**
171  * Reset the audio delay and count of audio bytes sent to zero.
172  */
173 void btif_av_reset_audio_delay(void);
174 
175 /**
176  * Called to disconnect peer device when
177  *  remote initiatied offload start failed
178  *
179  * @param peer_address to disconnect
180  *
181  */
182 void btif_av_src_disconnect_sink(const RawAddress& peer_address);
183 
184 /**
185  *  check A2DP offload support enabled
186  *  @param  none
187  */
188 bool btif_av_is_a2dp_offload_enabled(void);
189 
190 /**
191  * Check whether peer device is silenced
192  *
193  * @param peer_address to check
194  *
195  */
196 bool btif_av_is_peer_silenced(const RawAddress& peer_address);
197 
198 #endif /* BTIF_AV_H */
199