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 <cstdint> 27 28 #include "include/hardware/bt_av.h" 29 #include "types/raw_address.h" 30 31 // #include "bta/include/bta_av_api.h" 32 // #include "btif/include/btif_common.h" 33 34 /** 35 * When the local device is A2DP source, get the address of the active peer. 36 */ 37 RawAddress btif_av_source_active_peer(void); 38 39 /** 40 * When the local device is A2DP sink, get the address of the active peer. 41 */ 42 RawAddress btif_av_sink_active_peer(void); 43 44 /** 45 * Check whether A2DP Sink is enabled. 46 */ 47 bool btif_av_is_sink_enabled(void); 48 49 /** 50 * Start streaming. 51 */ 52 void btif_av_stream_start(void); 53 54 /** 55 * Start streaming with latency setting. 56 */ 57 void btif_av_stream_start_with_latency(bool use_latency_mode); 58 59 /** 60 * Stop streaming. 61 * 62 * @param peer_address the peer address or RawAddress::kEmpty to stop all peers 63 */ 64 void btif_av_stream_stop(const RawAddress& peer_address); 65 66 /** 67 * Suspend streaming. 68 */ 69 void btif_av_stream_suspend(void); 70 71 /** 72 * Start offload streaming. 73 */ 74 void btif_av_stream_start_offload(void); 75 76 /** 77 * Check whether ready to start the A2DP stream. 78 */ 79 bool btif_av_stream_ready(void); 80 81 /** 82 * Check whether the A2DP stream is in started state and ready 83 * for media start. 84 */ 85 bool btif_av_stream_started_ready(void); 86 87 /** 88 * Check whether there is a connected peer (either Source or Sink) 89 */ 90 bool btif_av_is_connected(void); 91 92 /** 93 * Get the Stream Endpoint Type of the Active peer. 94 * 95 * @return the stream endpoint type: either AVDT_TSEP_SRC or AVDT_TSEP_SNK 96 */ 97 uint8_t btif_av_get_peer_sep(void); 98 99 /** 100 * Clear the remote suspended flag for the active peer. 101 */ 102 void btif_av_clear_remote_suspend_flag(void); 103 104 /** 105 * Check whether the connected A2DP peer supports EDR. 106 * 107 * The value can be provided only if the remote peer is connected. 108 * Otherwise, the answer will be always false. 109 * 110 * @param peer_address the peer address 111 * @return true if the remote peer is capable of EDR 112 */ 113 bool btif_av_is_peer_edr(const RawAddress& peer_address); 114 115 /** 116 * Check whether the connected A2DP peer supports 3 Mbps EDR. 117 * 118 * The value can be provided only if the remote peer is connected. 119 * Otherwise, the answer will be always false. 120 * 121 * @param peer_address the peer address 122 * @return true if the remote peer is capable of EDR and supports 3 Mbps 123 */ 124 bool btif_av_peer_supports_3mbps(const RawAddress& peer_address); 125 126 /** 127 * Check whether the mandatory codec is more preferred for this peer. 128 * 129 * @param peer_address the target peer address 130 * @return true if optional codecs are not preferred to be used 131 */ 132 bool btif_av_peer_prefers_mandatory_codec(const RawAddress& peer_address); 133 134 /** 135 * Report A2DP Source Codec State for a peer. 136 * 137 * @param peer_address the address of the peer to report 138 * @param codec_config the codec config to report 139 * @param codecs_local_capabilities the codecs local capabilities to report 140 * @param codecs_selectable_capabilities the codecs selectable capabilities 141 * to report 142 */ 143 void btif_av_report_source_codec_state( 144 const RawAddress& peer_address, 145 const btav_a2dp_codec_config_t& codec_config, 146 const std::vector<btav_a2dp_codec_config_t>& codecs_local_capabilities, 147 const std::vector<btav_a2dp_codec_config_t>& 148 codecs_selectable_capabilities); 149 150 /** 151 * Initialize / shut down the A2DP Source service. 152 * 153 * @param enable true to enable the A2DP Source service, false to disable it 154 * @return BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise 155 */ 156 bt_status_t btif_av_source_execute_service(bool enable); 157 158 /** 159 * Initialize / shut down the A2DP Sink service. 160 * 161 * @param enable true to enable the A2DP Sink service, false to disable it 162 * @return BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise 163 */ 164 bt_status_t btif_av_sink_execute_service(bool enable); 165 166 /** 167 * Peer ACL disconnected. 168 * 169 * @param peer_address the disconnected peer address 170 */ 171 void btif_av_acl_disconnected(const RawAddress& peer_address); 172 173 /** 174 * Dump debug-related information for the BTIF AV module. 175 * 176 * @param fd the file descriptor to use for writing the ASCII formatted 177 * information 178 */ 179 void btif_debug_av_dump(int fd); 180 181 /** 182 * Set the audio delay for the stream. 183 * 184 * @param peer_address the address of the peer to report 185 * @param delay the delay to set in units of 1/10ms 186 */ 187 void btif_av_set_audio_delay(const RawAddress& peer_address, uint16_t delay); 188 189 /** 190 * Get the audio delay for the stream. 191 * @param none 192 */ 193 uint16_t btif_av_get_audio_delay(void); 194 195 /** 196 * Reset the audio delay and count of audio bytes sent to zero. 197 */ 198 void btif_av_reset_audio_delay(void); 199 200 /** 201 * Called to disconnect peer device when 202 * remote initiatied offload start failed 203 * 204 * @param peer_address to disconnect 205 * 206 */ 207 void btif_av_src_disconnect_sink(const RawAddress& peer_address); 208 209 /** 210 * check A2DP offload support enabled 211 * @param none 212 */ 213 bool btif_av_is_a2dp_offload_enabled(void); 214 215 /** 216 * check A2DP offload enabled and running 217 * @param none 218 */ 219 bool btif_av_is_a2dp_offload_running(void); 220 221 /** 222 * Check whether peer device is silenced 223 * 224 * @param peer_address to check 225 * 226 */ 227 bool btif_av_is_peer_silenced(const RawAddress& peer_address); 228 229 /** 230 * Set the dynamic audio buffer size 231 * 232 * @param dynamic_audio_buffer_size to set 233 */ 234 void btif_av_set_dynamic_audio_buffer_size(uint8_t dynamic_audio_buffer_size); 235 236 /** 237 * Enable/disable the low latency 238 * 239 * @param is_low_latency to set 240 */ 241 void btif_av_set_low_latency(bool is_low_latency); 242 243 #endif /* BTIF_AV_H */ 244