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