blob: 88af757b48d53af3bad39fd1140bb754945400a6 [file] [log] [blame]
Andre Eisenbach05f49542012-09-18 12:15:26 -07001/*
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 */
23typedef 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 */
31typedef 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 */
AnubhavGupta0080e702014-08-05 01:36:53 +053041typedef void (* btav_connection_state_callback)(btav_connection_state_t state,
Andre Eisenbach05f49542012-09-18 12:15:26 -070042 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 */
AnubhavGupta0080e702014-08-05 01:36:53 +053047typedef void (* btav_audio_state_callback)(btav_audio_state_t state,
Andre Eisenbach05f49542012-09-18 12:15:26 -070048 bt_bdaddr_t *bd_addr);
49
Mike Lockwood21e50b12014-06-07 14:05:22 -070050/** 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 */
56typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr,
57 uint32_t sample_rate,
58 uint8_t channel_count);
Nitin Srivastavaee5df9f2013-06-13 11:47:21 +053059/** Callback for connection priority of device for incoming connection
60 * btav_connection_priority_t
61 */
62typedef void (* btav_connection_priority_callback)(bt_bdaddr_t *bd_addr);
Mike Lockwood21e50b12014-06-07 14:05:22 -070063
AnubhavGupta0080e702014-08-05 01:36:53 +053064/** Callback for requesting audio focus.
65 * enable will be either TRUE or FALSE
66 */
67typedef void (* btav_audio_focus_request_callback)(int enable,
68 bt_bdaddr_t *bd_addr);
Andre Eisenbach05f49542012-09-18 12:15:26 -070069/** BT-AV callback structure. */
70typedef struct {
71 /** set to sizeof(btav_callbacks_t) */
72 size_t size;
73 btav_connection_state_callback connection_state_cb;
74 btav_audio_state_callback audio_state_cb;
Mike Lockwood21e50b12014-06-07 14:05:22 -070075 btav_audio_config_callback audio_config_cb;
Nitin Srivastavaee5df9f2013-06-13 11:47:21 +053076 btav_connection_priority_callback connection_priority_cb;
AnubhavGupta0080e702014-08-05 01:36:53 +053077 btav_audio_focus_request_callback audio_focus_request_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -070078} btav_callbacks_t;
79
AnubhavGupta0080e702014-08-05 01:36:53 +053080/**
Andre Eisenbach05f49542012-09-18 12:15:26 -070081 * NOTE:
82 *
83 * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands
AnubhavGupta0080e702014-08-05 01:36:53 +053084 * shall be handled internally via uinput
Andre Eisenbach05f49542012-09-18 12:15:26 -070085 *
86 * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger
87 * android_audio_hw library and the Bluetooth stack.
AnubhavGupta0080e702014-08-05 01:36:53 +053088 *
Andre Eisenbach05f49542012-09-18 12:15:26 -070089 */
Mike Lockwood21e50b12014-06-07 14:05:22 -070090/** Represents the standard BT-AV interface.
91 * Used for both the A2DP source and sink interfaces.
92 */
Andre Eisenbach05f49542012-09-18 12:15:26 -070093typedef struct {
94
95 /** set to sizeof(btav_interface_t) */
96 size_t size;
97 /**
98 * Register the BtAv callbacks
99 */
100 bt_status_t (*init)( btav_callbacks_t* callbacks );
101
102 /** connect to headset */
103 bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
104
105 /** dis-connect from headset */
106 bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
107
108 /** Closes the interface. */
109 void (*cleanup)( void );
Nitin Srivastavaee5df9f2013-06-13 11:47:21 +0530110
111 /** Send priority of device to stack*/
112 void (*allow_connection)( int is_valid );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700113} btav_interface_t;
114
AnubhavGupta0080e702014-08-05 01:36:53 +0530115typedef struct {
116
117 /** set to sizeof(btav_interface_t) */
118 size_t size;
119 /**
120 * Register the BtAv callbacks
121 */
122 bt_status_t (*init)( btav_callbacks_t* callbacks );
123
124 /** connect to headset */
125 bt_status_t (*connect)( bt_bdaddr_t *bd_addr );
126
127 /** dis-connect from headset */
128 bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr );
129
130 /** Closes the interface. */
131 void (*cleanup)( void );
132
133 /* suspend stream for A2DP Sink */
134 void (*suspend_sink)( void );
135
136 /* resume stream for A2DP Sink */
137 void (*resume_sink)( void );
138
139 /* inform audio focus state */
140 void (*audio_focus_status)( int is_enable );
141} btav_sink_interface_t;
142
Andre Eisenbach05f49542012-09-18 12:15:26 -0700143__END_DECLS
144
145#endif /* ANDROID_INCLUDE_BT_AV_H */