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 | |
AnubhavGupta | 1e52460 | 2015-10-03 11:32:25 +0530 | [diff] [blame] | 73 | /* |
| 74 | * Callback for audio focus request to be used only in |
| 75 | * case of A2DP Sink. This is required because we are using |
| 76 | * AudioTrack approach for audio data rendering. |
| 77 | */ |
| 78 | typedef void (* btav_audio_focus_request_callback)(bt_bdaddr_t *bd_addr); |
| 79 | |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 80 | /** BT-AV callback structure. */ |
| 81 | typedef struct { |
| 82 | /** set to sizeof(btav_callbacks_t) */ |
| 83 | size_t size; |
| 84 | btav_connection_state_callback connection_state_cb; |
| 85 | btav_audio_state_callback audio_state_cb; |
Mike Lockwood | 21e50b1 | 2014-06-07 14:05:22 -0700 | [diff] [blame] | 86 | btav_audio_config_callback audio_config_cb; |
Gaurav Asati | ab868ce | 2015-07-17 15:13:33 +0530 | [diff] [blame] | 87 | btav_connection_priority_callback connection_priority_cb; |
Gaurav Asati | aacbc38 | 2014-08-14 15:30:52 +0530 | [diff] [blame] | 88 | btav_is_multicast_enabled_callback multicast_state_cb; |
AnubhavGupta | 1e52460 | 2015-10-03 11:32:25 +0530 | [diff] [blame] | 89 | btav_audio_focus_request_callback audio_focus_request_cb; |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 90 | } btav_callbacks_t; |
| 91 | |
| 92 | /** |
| 93 | * NOTE: |
| 94 | * |
| 95 | * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands |
| 96 | * shall be handled internally via uinput |
| 97 | * |
| 98 | * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger |
| 99 | * android_audio_hw library and the Bluetooth stack. |
| 100 | * |
| 101 | */ |
Mike Lockwood | 21e50b1 | 2014-06-07 14:05:22 -0700 | [diff] [blame] | 102 | /** Represents the standard BT-AV interface. |
| 103 | * Used for both the A2DP source and sink interfaces. |
| 104 | */ |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 105 | typedef struct { |
| 106 | |
| 107 | /** set to sizeof(btav_interface_t) */ |
| 108 | size_t size; |
| 109 | /** |
| 110 | * Register the BtAv callbacks |
| 111 | */ |
Gaurav Asati | aacbc38 | 2014-08-14 15:30:52 +0530 | [diff] [blame] | 112 | bt_status_t (*init)( btav_callbacks_t* callbacks , int max_a2dp_connections, |
| 113 | int a2dp_multicast_state); |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 114 | |
| 115 | /** connect to headset */ |
| 116 | bt_status_t (*connect)( bt_bdaddr_t *bd_addr ); |
| 117 | |
| 118 | /** dis-connect from headset */ |
| 119 | bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); |
| 120 | |
| 121 | /** Closes the interface. */ |
| 122 | void (*cleanup)( void ); |
Gaurav Asati | ab868ce | 2015-07-17 15:13:33 +0530 | [diff] [blame] | 123 | |
| 124 | /** Send priority of device to stack*/ |
Gaurav Asati | aacbc38 | 2014-08-14 15:30:52 +0530 | [diff] [blame] | 125 | void (*allow_connection)( int is_valid , bt_bdaddr_t *bd_addr); |
AnubhavGupta | 1e52460 | 2015-10-03 11:32:25 +0530 | [diff] [blame] | 126 | |
| 127 | /** Sends Audio Focus State. */ |
| 128 | void (*audio_focus_state)( int focus_state ); |
Andre Eisenbach | 05f4954 | 2012-09-18 12:15:26 -0700 | [diff] [blame] | 129 | } btav_interface_t; |
| 130 | |
| 131 | __END_DECLS |
| 132 | |
| 133 | #endif /* ANDROID_INCLUDE_BT_AV_H */ |