1
#ifndef foobluez5utilhfoo
2
#define foobluez5utilhfoo
5
This file is part of PulseAudio.
7
Copyright 2008-2013 João Paulo Rechi Vita
9
PulseAudio is free software; you can redistribute it and/or modify
10
it under the terms of the GNU Lesser General Public License as
11
published by the Free Software Foundation; either version 2.1 of the
12
License, or (at your option) any later version.
14
PulseAudio is distributed in the hope that it will be useful, but
15
WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
General Public License for more details.
19
You should have received a copy of the GNU Lesser General Public
20
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
23
#include <pulsecore/core.h>
25
#define PA_BLUETOOTH_UUID_A2DP_SOURCE "0000110a-0000-1000-8000-00805f9b34fb"
26
#define PA_BLUETOOTH_UUID_A2DP_SINK "0000110b-0000-1000-8000-00805f9b34fb"
27
#define PA_BLUETOOTH_UUID_HSP_HS "00001108-0000-1000-8000-00805f9b34fb"
28
#define PA_BLUETOOTH_UUID_HSP_AG "00001112-0000-1000-8000-00805f9b34fb"
29
#define PA_BLUETOOTH_UUID_HFP_HF "0000111e-0000-1000-8000-00805f9b34fb"
30
#define PA_BLUETOOTH_UUID_HFP_AG "0000111f-0000-1000-8000-00805f9b34fb"
32
typedef struct pa_bluetooth_transport pa_bluetooth_transport;
33
typedef struct pa_bluetooth_device pa_bluetooth_device;
34
typedef struct pa_bluetooth_adapter pa_bluetooth_adapter;
35
typedef struct pa_bluetooth_discovery pa_bluetooth_discovery;
36
typedef struct pa_bluetooth_backend pa_bluetooth_backend;
38
typedef enum pa_bluetooth_hook {
39
PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED, /* Call data: pa_bluetooth_device */
40
PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED, /* Call data: pa_bluetooth_transport */
41
PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
42
PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
44
} pa_bluetooth_hook_t;
46
typedef enum profile {
47
PA_BLUETOOTH_PROFILE_A2DP_SINK,
48
PA_BLUETOOTH_PROFILE_A2DP_SOURCE,
49
PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT,
50
PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY,
51
PA_BLUETOOTH_PROFILE_OFF
52
} pa_bluetooth_profile_t;
53
#define PA_BLUETOOTH_PROFILE_COUNT PA_BLUETOOTH_PROFILE_OFF
55
typedef enum pa_bluetooth_transport_state {
56
PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED,
57
PA_BLUETOOTH_TRANSPORT_STATE_IDLE,
58
PA_BLUETOOTH_TRANSPORT_STATE_PLAYING
59
} pa_bluetooth_transport_state_t;
61
typedef int (*pa_bluetooth_transport_acquire_cb)(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu);
62
typedef void (*pa_bluetooth_transport_release_cb)(pa_bluetooth_transport *t);
63
typedef void (*pa_bluetooth_transport_destroy_cb)(pa_bluetooth_transport *t);
64
typedef void (*pa_bluetooth_transport_set_speaker_gain_cb)(pa_bluetooth_transport *t, uint16_t gain);
65
typedef void (*pa_bluetooth_transport_set_microphone_gain_cb)(pa_bluetooth_transport *t, uint16_t gain);
67
struct pa_bluetooth_transport {
68
pa_bluetooth_device *device;
72
pa_bluetooth_profile_t profile;
78
uint16_t microphone_gain;
79
uint16_t speaker_gain;
81
pa_bluetooth_transport_state_t state;
83
pa_bluetooth_transport_acquire_cb acquire;
84
pa_bluetooth_transport_release_cb release;
85
pa_bluetooth_transport_destroy_cb destroy;
86
pa_bluetooth_transport_set_speaker_gain_cb set_speaker_gain;
87
pa_bluetooth_transport_set_microphone_gain_cb set_microphone_gain;
91
struct pa_bluetooth_device {
92
pa_bluetooth_discovery *discovery;
93
pa_bluetooth_adapter *adapter;
95
bool properties_received;
96
bool tried_to_link_with_adapter;
99
/* Device information */
104
uint32_t class_of_device;
107
pa_bluetooth_transport *transports[PA_BLUETOOTH_PROFILE_COUNT];
110
struct pa_bluetooth_adapter {
111
pa_bluetooth_discovery *discovery;
118
#ifdef HAVE_BLUEZ_5_OFONO_HEADSET
119
pa_bluetooth_backend *pa_bluetooth_ofono_backend_new(pa_core *c, pa_bluetooth_discovery *y);
120
void pa_bluetooth_ofono_backend_free(pa_bluetooth_backend *b);
122
static inline pa_bluetooth_backend *pa_bluetooth_ofono_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
125
static inline void pa_bluetooth_ofono_backend_free(pa_bluetooth_backend *b) {}
128
#ifdef HAVE_BLUEZ_5_NATIVE_HEADSET
129
pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y);
130
void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b);
132
static inline pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
135
static inline void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b) {}
138
pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
139
pa_bluetooth_profile_t p, const uint8_t *config, size_t size);
141
void pa_bluetooth_transport_set_state(pa_bluetooth_transport *t, pa_bluetooth_transport_state_t state);
142
void pa_bluetooth_transport_put(pa_bluetooth_transport *t);
143
void pa_bluetooth_transport_unlink(pa_bluetooth_transport *t);
144
void pa_bluetooth_transport_free(pa_bluetooth_transport *t);
146
bool pa_bluetooth_device_any_transport_connected(const pa_bluetooth_device *d);
147
bool pa_bluetooth_device_is_transport_connected(const pa_bluetooth_device *d, pa_bluetooth_profile_t profile);
150
pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_path(pa_bluetooth_discovery *y, const char *path);
151
pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_address(pa_bluetooth_discovery *y, const char *remote, const char *local);
153
pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
155
const char *pa_bluetooth_profile_to_string(pa_bluetooth_profile_t profile);
156
const char *pa_bluetooth_transport_state_to_string(pa_bluetooth_transport_state_t state);
158
#define HEADSET_BACKEND_OFONO 0
159
#define HEADSET_BACKEND_NATIVE 1
160
#define HEADSET_BACKEND_AUTO 2
161
#define HEADSET_BACKEND_BOTH 3
163
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core, int headset_backend);
164
pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
165
void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y);
166
void pa_bluetooth_discovery_set_ofono_running(pa_bluetooth_discovery *y, bool is_running);