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 * Check whether the mandatory codec is more preferred for this peer. 118 * 119 * @param peer_address the target peer address 120 * @return true if optional codecs are not preferred to be used 121 */ 122 bool btif_av_peer_prefers_mandatory_codec(const RawAddress& peer_address); 123 124 /** 125 * Report A2DP Source Codec State for a peer. 126 * 127 * @param peer_address the address of the peer to report 128 * @param codec_config the codec config to report 129 * @param codecs_local_capabilities the codecs local capabilities to report 130 * @param codecs_selectable_capabilities the codecs selectable capabilities 131 * to report 132 */ 133 void btif_av_report_source_codec_state( 134 const RawAddress& peer_address, 135 const btav_a2dp_codec_config_t& codec_config, 136 const std::vector<btav_a2dp_codec_config_t>& codecs_local_capabilities, 137 const std::vector<btav_a2dp_codec_config_t>& 138 codecs_selectable_capabilities); 139 140 /** 141 * Initialize / shut down the A2DP Source service. 142 * 143 * @param enable true to enable the A2DP Source service, false to disable it 144 * @return BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise 145 */ 146 bt_status_t btif_av_source_execute_service(bool enable); 147 148 /** 149 * Initialize / shut down the A2DP Sink service. 150 * 151 * @param enable true to enable the A2DP Sink service, false to disable it 152 * @return BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise 153 */ 154 bt_status_t btif_av_sink_execute_service(bool enable); 155 156 /** 157 * Peer ACL disconnected. 158 * 159 * @param peer_address the disconnected peer address 160 */ 161 void btif_av_acl_disconnected(const RawAddress& peer_address); 162 163 /** 164 * Dump debug-related information for the BTIF AV module. 165 * 166 * @param fd the file descriptor to use for writing the ASCII formatted 167 * information 168 */ 169 void btif_debug_av_dump(int fd); 170 171 /** 172 * Set the audio delay for the stream. 173 * 174 * @param peer_address the address of the peer to report 175 * @param delay the delay to set in units of 1/10ms 176 */ 177 void btif_av_set_audio_delay(const RawAddress& peer_address, uint16_t delay); 178 179 /** 180 * Get the audio delay for the stream. 181 * @param none 182 */ 183 uint16_t btif_av_get_audio_delay(void); 184 185 /** 186 * Reset the audio delay and count of audio bytes sent to zero. 187 */ 188 void btif_av_reset_audio_delay(void); 189 190 /** 191 * Called to disconnect peer device when 192 * remote initiatied offload start failed 193 * 194 * @param peer_address to disconnect 195 * 196 */ 197 void btif_av_src_disconnect_sink(const RawAddress& peer_address); 198 199 /** 200 * check A2DP offload support enabled 201 * @param none 202 */ 203 bool btif_av_is_a2dp_offload_enabled(void); 204 205 /** 206 * check A2DP offload enabled and running 207 * @param none 208 */ 209 bool btif_av_is_a2dp_offload_running(void); 210 211 /** 212 * Check whether peer device is silenced 213 * 214 * @param peer_address to check 215 * 216 */ 217 bool btif_av_is_peer_silenced(const RawAddress& peer_address); 218 219 #endif /* BTIF_AV_H */ 220