Home | History | Annotate | Download | only in hardware
      1 /*
      2  * Copyright (C) 2012 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ANDROID_INCLUDE_BT_AV_H
     18 #define ANDROID_INCLUDE_BT_AV_H
     19 
     20 __BEGIN_DECLS
     21 
     22 /* Bluetooth AV connection states */
     23 typedef enum {
     24     BTAV_CONNECTION_STATE_DISCONNECTED = 0,
     25     BTAV_CONNECTION_STATE_CONNECTING,
     26     BTAV_CONNECTION_STATE_CONNECTED,
     27     BTAV_CONNECTION_STATE_DISCONNECTING
     28 } btav_connection_state_t;
     29 
     30 /* Bluetooth AV datapath states */
     31 typedef enum {
     32     BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0,
     33     BTAV_AUDIO_STATE_STOPPED,
     34     BTAV_AUDIO_STATE_STARTED,
     35 } btav_audio_state_t;
     36 
     37 
     38 /** Callback for connection state change.
     39  *  state will have one of the values from btav_connection_state_t
     40  */
     41 typedef void (* btav_connection_state_callback)(btav_connection_state_t state,
     42                                                     bt_bdaddr_t *bd_addr);
     43 
     44 /** Callback for audiopath state change.
     45  *  state will have one of the values from btav_audio_state_t
     46  */
     47 typedef void (* btav_audio_state_callback)(btav_audio_state_t state,
     48                                                bt_bdaddr_t *bd_addr);
     49 
     50 /** Callback for audio configuration change.
     51  *  Used only for the A2DP sink interface.
     52  *  state will have one of the values from btav_audio_state_t
     53  *  sample_rate: sample rate in Hz
     54  *  channel_count: number of channels (1 for mono, 2 for stereo)
     55  */
     56 typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr,
     57                                                 uint32_t sample_rate,
     58                                                 uint8_t channel_count);
     59 
     60 /** BT-AV callback structure. */
     61 typedef struct {
     62     /** set to sizeof(btav_callbacks_t) */
     63     size_t      size;
     64     btav_connection_state_callback  connection_state_cb;
     65     btav_audio_state_callback audio_state_cb;
     66     btav_audio_config_callback audio_config_cb;
     67 } btav_callbacks_t;
     68 
     69 /**
     70  * NOTE:
     71  *
     72  * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands
     73  *    shall be handled internally via uinput
     74  *
     75  * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger
     76  *    android_audio_hw library and the Bluetooth stack.
     77  *
     78  */
     79 /** Represents the standard BT-AV interface.
     80  *  Used for both the A2DP source and sink interfaces.
     81  */
     82 typedef struct {
     83 
     84     /** set to sizeof(btav_interface_t) */
     85     size_t          size;
     86     /**
     87      * Register the BtAv callbacks
     88      */
     89     bt_status_t (*init)( btav_callbacks_t* callbacks );
     90 
     91     /** connect to headset */
     92     bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
     93 
     94     /** dis-connect from headset */
     95     bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
     96 
     97     /** Closes the interface. */
     98     void  (*cleanup)( void );
     99 
    100     /** Sends Audio Focus State. */
    101     void  (*set_audio_focus_state)( int focus_state );
    102 
    103     /** Sets the audio track gain. */
    104     void  (*set_audio_track_gain)( float gain );
    105 } btav_interface_t;
    106 
    107 __END_DECLS
    108 
    109 #endif /* ANDROID_INCLUDE_BT_AV_H */
    110