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 /** BT-AV callback structure. */
     51 typedef struct {
     52     /** set to sizeof(btav_callbacks_t) */
     53     size_t      size;
     54     btav_connection_state_callback  connection_state_cb;
     55     btav_audio_state_callback audio_state_cb;
     56 } btav_callbacks_t;
     57 
     58 /**
     59  * NOTE:
     60  *
     61  * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands
     62  *    shall be handled internally via uinput
     63  *
     64  * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger
     65  *    android_audio_hw library and the Bluetooth stack.
     66  *
     67  */
     68 /** Represents the standard BT-AV interface. */
     69 typedef struct {
     70 
     71     /** set to sizeof(btav_interface_t) */
     72     size_t          size;
     73     /**
     74      * Register the BtAv callbacks
     75      */
     76     bt_status_t (*init)( btav_callbacks_t* callbacks );
     77 
     78     /** connect to headset */
     79     bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
     80 
     81     /** dis-connect from headset */
     82     bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
     83 
     84     /** Closes the interface. */
     85     void  (*cleanup)( void );
     86 } btav_interface_t;
     87 
     88 __END_DECLS
     89 
     90 #endif /* ANDROID_INCLUDE_BT_AV_H */
     91