Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 1 | /* |
Gaurav Asati | aacbc38 | 2014-08-14 15:30:52 +0530 | [diff] [blame^] | 2 | * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved. |
| 3 | * Not a Contribution. |
| 4 | * |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 5 | * Copyright (C) 2012 The Android Open Source Project |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | #ifndef ANDROID_INCLUDE_BT_AV_H |
| 21 | #define ANDROID_INCLUDE_BT_AV_H |
| 22 | |
| 23 | __BEGIN_DECLS |
| 24 | |
| 25 | /* Bluetooth AV connection states */ |
| 26 | typedef enum { |
| 27 | BTAV_CONNECTION_STATE_DISCONNECTED = 0, |
| 28 | BTAV_CONNECTION_STATE_CONNECTING, |
| 29 | BTAV_CONNECTION_STATE_CONNECTED, |
| 30 | BTAV_CONNECTION_STATE_DISCONNECTING |
| 31 | } btav_connection_state_t; |
| 32 | |
| 33 | /* Bluetooth AV datapath states */ |
| 34 | typedef enum { |
| 35 | BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0, |
| 36 | BTAV_AUDIO_STATE_STOPPED, |
| 37 | BTAV_AUDIO_STATE_STARTED, |
| 38 | } btav_audio_state_t; |
| 39 | |
| 40 | |
| 41 | /** Callback for connection state change. |
| 42 | * state will have one of the values from btav_connection_state_t |
| 43 | */ |
| 44 | typedef void (* btav_connection_state_callback)(btav_connection_state_t state, |
| 45 | bt_bdaddr_t *bd_addr); |
| 46 | |
| 47 | /** Callback for audiopath state change. |
| 48 | * state will have one of the values from btav_audio_state_t |
| 49 | */ |
| 50 | typedef void (* btav_audio_state_callback)(btav_audio_state_t state, |
| 51 | bt_bdaddr_t *bd_addr); |
| 52 | |
Gaurav Asati | ab868ce | 2015-07-17 15:13:33 +0530 | [diff] [blame] | 53 | /** Callback for connection priority of device for incoming connection |
| 54 | * btav_connection_priority_t |
| 55 | */ |
| 56 | typedef void (* btav_connection_priority_callback)(bt_bdaddr_t *bd_addr); |
| 57 | |
Mike Lockwood | 21e50b1 | 2014-06-07 14:05:22 -0700 | [diff] [blame] | 58 | /** Callback for audio configuration change. |
| 59 | * Used only for the A2DP sink interface. |
| 60 | * state will have one of the values from btav_audio_state_t |
| 61 | * sample_rate: sample rate in Hz |
| 62 | * channel_count: number of channels (1 for mono, 2 for stereo) |
| 63 | */ |
| 64 | typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr, |
| 65 | uint32_t sample_rate, |
| 66 | uint8_t channel_count); |
| 67 | |
Gaurav Asati | aacbc38 | 2014-08-14 15:30:52 +0530 | [diff] [blame^] | 68 | /** Callback for updating apps for A2dp multicast state. |
| 69 | */ |
| 70 | |
| 71 | typedef void (* btav_is_multicast_enabled_callback)(int state); |
| 72 | |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 73 | /** BT-AV callback structure. */ |
| 74 | typedef struct { |
| 75 | /** set to sizeof(btav_callbacks_t) */ |
| 76 | size_t size; |
| 77 | btav_connection_state_callback connection_state_cb; |
| 78 | btav_audio_state_callback audio_state_cb; |
Mike Lockwood | 21e50b1 | 2014-06-07 14:05:22 -0700 | [diff] [blame] | 79 | btav_audio_config_callback audio_config_cb; |
Gaurav Asati | ab868ce | 2015-07-17 15:13:33 +0530 | [diff] [blame] | 80 | btav_connection_priority_callback connection_priority_cb; |
Gaurav Asati | aacbc38 | 2014-08-14 15:30:52 +0530 | [diff] [blame^] | 81 | btav_is_multicast_enabled_callback multicast_state_cb; |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 82 | } btav_callbacks_t; |
| 83 | |
| 84 | /** |
| 85 | * NOTE: |
| 86 | * |
| 87 | * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands |
| 88 | * shall be handled internally via uinput |
| 89 | * |
| 90 | * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger |
| 91 | * android_audio_hw library and the Bluetooth stack. |
| 92 | * |
| 93 | */ |
Mike Lockwood | 21e50b1 | 2014-06-07 14:05:22 -0700 | [diff] [blame] | 94 | /** Represents the standard BT-AV interface. |
| 95 | * Used for both the A2DP source and sink interfaces. |
| 96 | */ |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 97 | typedef struct { |
| 98 | |
| 99 | /** set to sizeof(btav_interface_t) */ |
| 100 | size_t size; |
| 101 | /** |
| 102 | * Register the BtAv callbacks |
| 103 | */ |
Gaurav Asati | aacbc38 | 2014-08-14 15:30:52 +0530 | [diff] [blame^] | 104 | bt_status_t (*init)( btav_callbacks_t* callbacks , int max_a2dp_connections, |
| 105 | int a2dp_multicast_state); |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 106 | |
| 107 | /** connect to headset */ |
| 108 | bt_status_t (*connect)( bt_bdaddr_t *bd_addr ); |
| 109 | |
| 110 | /** dis-connect from headset */ |
| 111 | bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); |
| 112 | |
| 113 | /** Closes the interface. */ |
| 114 | void (*cleanup)( void ); |
Gaurav Asati | ab868ce | 2015-07-17 15:13:33 +0530 | [diff] [blame] | 115 | |
| 116 | /** Send priority of device to stack*/ |
Gaurav Asati | aacbc38 | 2014-08-14 15:30:52 +0530 | [diff] [blame^] | 117 | void (*allow_connection)( int is_valid , bt_bdaddr_t *bd_addr); |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 118 | } btav_interface_t; |
| 119 | |
| 120 | __END_DECLS |
| 121 | |
| 122 | #endif /* ANDROID_INCLUDE_BT_AV_H */ |