Home | History | Annotate | Download | only in include
      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  * Process AVRCP Open event.
     96  *
     97  * @param peer_address the peer address
     98  */
     99 void btif_av_avrcp_event_open(const RawAddress& peer_address);
    100 
    101 /**
    102  * Process AVRCP Close event.
    103  *
    104  * @param peer_address the peer address
    105  */
    106 void btif_av_avrcp_event_close(const RawAddress& peer_address);
    107 
    108 /**
    109  * Process AVRCP Remote Play event.
    110  *
    111  * @param peer_address the peer address
    112  */
    113 void btif_av_avrcp_event_remote_play(const RawAddress& peer_address);
    114 
    115 /**
    116  * Check whether the connected A2DP peer supports 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
    123  */
    124 bool btif_av_is_peer_edr(const RawAddress& peer_address);
    125 
    126 /**
    127  * Check whether the connected A2DP peer supports 3 Mbps EDR.
    128  *
    129  * The value can be provided only if the remote peer is connected.
    130  * Otherwise, the answer will be always false.
    131  *
    132  * @param peer_address the peer address
    133  * @return true if the remote peer is capable of EDR and supports 3 Mbps
    134  */
    135 bool btif_av_peer_supports_3mbps(const RawAddress& peer_address);
    136 
    137 /**
    138  * Report A2DP Source Codec State for a peer.
    139  *
    140  * @param peer_address the address of the peer to report
    141  * @param codec_config the codec config to report
    142  * @param codecs_local_capabilities the codecs local capabilities to report
    143  * @param codecs_selectable_capabilities the codecs selectable capabilities
    144  * to report
    145  */
    146 void btif_av_report_source_codec_state(
    147     const RawAddress& peer_address,
    148     const btav_a2dp_codec_config_t& codec_config,
    149     const std::vector<btav_a2dp_codec_config_t>& codecs_local_capabilities,
    150     const std::vector<btav_a2dp_codec_config_t>&
    151         codecs_selectable_capabilities);
    152 
    153 /**
    154  * Initialize / shut down the A2DP Source service.
    155  *
    156  * @param enable true to enable the A2DP Source service, false to disable it
    157  * @return BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
    158  */
    159 bt_status_t btif_av_source_execute_service(bool enable);
    160 
    161 /**
    162  * Initialize / shut down the A2DP Sink service.
    163  *
    164  * @param enable true to enable the A2DP Sink service, false to disable it
    165  * @return BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
    166  */
    167 bt_status_t btif_av_sink_execute_service(bool enable);
    168 
    169 /**
    170  * Peer ACL disconnected.
    171  *
    172  * @param peer_address the disconnected peer address
    173  */
    174 void btif_av_acl_disconnected(const RawAddress& peer_address);
    175 
    176 /**
    177  * Dump debug-related information for the BTIF AV module.
    178  *
    179  * @param fd the file descriptor to use for writing the ASCII formatted
    180  * information
    181  */
    182 void btif_debug_av_dump(int fd);
    183 
    184 /**
    185  * Set the audio delay for the stream.
    186  *
    187  * @param delay the delay to set in units of 1/10ms
    188  */
    189 void btif_av_set_audio_delay(uint16_t delay);
    190 
    191 /**
    192  * Reset the audio delay and count of audio bytes sent to zero.
    193  */
    194 void btif_av_reset_audio_delay(void);
    195 
    196 /**
    197  * Called to disconnect peer device when
    198  *  remote initiatied offload start failed
    199  *
    200  * @param peer_address to disconnect
    201  *
    202  */
    203 void btif_av_src_disconnect_sink(const RawAddress& peer_address);
    204 
    205 /**
    206  *  check A2DP offload support enabled
    207  *  @param  none
    208  */
    209 bool btif_av_is_a2dp_offload_enabled(void);
    210 #endif /* BTIF_AV_H */
    211