blob: be82fbeffdbb2c84673950dd03a21b62bffad46c [file] [log] [blame]
Andre Eisenbach05f49542012-09-18 12:15:26 -07001/*
Gaurav Asatiaacbc382014-08-14 15:30:52 +05302 * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved.
3 * Not a Contribution.
4 *
Andre Eisenbach05f49542012-09-18 12:15:26 -07005 * 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 */
26typedef 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 */
34typedef 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 */
44typedef 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 */
50typedef void (* btav_audio_state_callback)(btav_audio_state_t state,
51 bt_bdaddr_t *bd_addr);
52
Gaurav Asatiab868ce2015-07-17 15:13:33 +053053/** Callback for connection priority of device for incoming connection
54 * btav_connection_priority_t
55 */
56typedef void (* btav_connection_priority_callback)(bt_bdaddr_t *bd_addr);
57
Mike Lockwood21e50b12014-06-07 14:05:22 -070058/** 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 */
64typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr,
65 uint32_t sample_rate,
66 uint8_t channel_count);
67
Gaurav Asatiaacbc382014-08-14 15:30:52 +053068/** Callback for updating apps for A2dp multicast state.
69 */
70
71typedef void (* btav_is_multicast_enabled_callback)(int state);
72
AnubhavGupta1e524602015-10-03 11:32:25 +053073/*
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 */
78typedef void (* btav_audio_focus_request_callback)(bt_bdaddr_t *bd_addr);
79
Andre Eisenbach05f49542012-09-18 12:15:26 -070080/** BT-AV callback structure. */
81typedef 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 Lockwood21e50b12014-06-07 14:05:22 -070086 btav_audio_config_callback audio_config_cb;
Gaurav Asatiab868ce2015-07-17 15:13:33 +053087 btav_connection_priority_callback connection_priority_cb;
Gaurav Asatiaacbc382014-08-14 15:30:52 +053088 btav_is_multicast_enabled_callback multicast_state_cb;
AnubhavGupta1e524602015-10-03 11:32:25 +053089 btav_audio_focus_request_callback audio_focus_request_cb;
Andre Eisenbach05f49542012-09-18 12:15:26 -070090} 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 Lockwood21e50b12014-06-07 14:05:22 -0700102/** Represents the standard BT-AV interface.
103 * Used for both the A2DP source and sink interfaces.
104 */
Andre Eisenbach05f49542012-09-18 12:15:26 -0700105typedef struct {
106
107 /** set to sizeof(btav_interface_t) */
108 size_t size;
109 /**
110 * Register the BtAv callbacks
111 */
Gaurav Asatiaacbc382014-08-14 15:30:52 +0530112 bt_status_t (*init)( btav_callbacks_t* callbacks , int max_a2dp_connections,
113 int a2dp_multicast_state);
Andre Eisenbach05f49542012-09-18 12:15:26 -0700114
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 Asatiab868ce2015-07-17 15:13:33 +0530123
124 /** Send priority of device to stack*/
Gaurav Asatiaacbc382014-08-14 15:30:52 +0530125 void (*allow_connection)( int is_valid , bt_bdaddr_t *bd_addr);
AnubhavGupta1e524602015-10-03 11:32:25 +0530126
127 /** Sends Audio Focus State. */
128 void (*audio_focus_state)( int focus_state );
Andre Eisenbach05f49542012-09-18 12:15:26 -0700129} btav_interface_t;
130
131__END_DECLS
132
133#endif /* ANDROID_INCLUDE_BT_AV_H */