1 #ifndef foobluetoothutilhfoo
2 #define foobluetoothutilhfoo
5 This file is part of PulseAudio.
7 Copyright 2008-2009 Joao 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, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 #include <dbus/dbus.h>
27 #include <pulsecore/llist.h>
28 #include <pulsecore/macro.h>
30 #define PA_BLUETOOTH_ERROR_NOT_SUPPORTED "org.bluez.Error.NotSupported"
32 /* UUID copied from bluez/audio/device.h */
33 #define GENERIC_AUDIO_UUID "00001203-0000-1000-8000-00805f9b34fb"
35 #define HSP_HS_UUID "00001108-0000-1000-8000-00805f9b34fb"
36 #define HSP_AG_UUID "00001112-0000-1000-8000-00805f9b34fb"
38 #define HFP_HS_UUID "0000111e-0000-1000-8000-00805f9b34fb"
39 #define HFP_AG_UUID "0000111f-0000-1000-8000-00805f9b34fb"
41 #define ADVANCED_AUDIO_UUID "0000110d-0000-1000-8000-00805f9b34fb"
43 #define A2DP_SOURCE_UUID "0000110a-0000-1000-8000-00805f9b34fb"
44 #define A2DP_SINK_UUID "0000110b-0000-1000-8000-00805f9b34fb"
46 typedef struct pa_bluetooth_uuid pa_bluetooth_uuid
;
47 typedef struct pa_bluetooth_device pa_bluetooth_device
;
48 typedef struct pa_bluetooth_discovery pa_bluetooth_discovery
;
49 typedef struct pa_bluetooth_transport pa_bluetooth_transport
;
53 struct pa_bluetooth_uuid
{
55 PA_LLIST_FIELDS(pa_bluetooth_uuid
);
66 #define PA_BLUETOOTH_PROFILE_COUNT PROFILE_OFF
68 /* Hook data: pa_bluetooth_transport pointer. */
69 typedef enum pa_bluetooth_transport_hook
{
70 PA_BLUETOOTH_TRANSPORT_HOOK_NREC_CHANGED
, /* Call data: NULL. */
71 PA_BLUETOOTH_TRANSPORT_HOOK_REMOVED
, /* Call data: NULL. */
72 PA_BLUETOOTH_TRANSPORT_HOOK_MAX
73 } pa_bluetooth_transport_hook_t
;
75 struct pa_bluetooth_transport
{
76 pa_bluetooth_device
*device
;
85 pa_hook hooks
[PA_BLUETOOTH_TRANSPORT_HOOK_MAX
];
88 /* This enum is shared among Audio, Headset, AudioSink, and AudioSource, although not all values are acceptable in all profiles */
89 typedef enum pa_bt_audio_state
{
90 PA_BT_AUDIO_STATE_INVALID
= -1,
91 PA_BT_AUDIO_STATE_DISCONNECTED
,
92 PA_BT_AUDIO_STATE_CONNECTING
,
93 PA_BT_AUDIO_STATE_CONNECTED
,
94 PA_BT_AUDIO_STATE_PLAYING
95 } pa_bt_audio_state_t
;
97 /* Hook data: pa_bluetooth_device pointer. */
98 typedef enum pa_bluetooth_device_hook
{
99 PA_BLUETOOTH_DEVICE_HOOK_REMOVED
, /* Call data: NULL. */
100 PA_BLUETOOTH_DEVICE_HOOK_UUID_ADDED
, /* Call data: const char *uuid. */
101 PA_BLUETOOTH_DEVICE_HOOK_MAX
102 } pa_bluetooth_device_hook_t
;
104 struct pa_bluetooth_device
{
105 pa_bluetooth_discovery
*discovery
;
108 int device_info_valid
; /* 0: no results yet; 1: good results; -1: bad results ... */
110 /* Device information */
113 pa_bluetooth_transport
*transports
[PA_BLUETOOTH_PROFILE_COUNT
];
116 PA_LLIST_HEAD(pa_bluetooth_uuid
, uuids
);
122 pa_bt_audio_state_t audio_state
;
124 /* AudioSink state */
125 pa_bt_audio_state_t audio_sink_state
;
127 /* AudioSource state */
128 pa_bt_audio_state_t audio_source_state
;
131 pa_bt_audio_state_t headset_state
;
133 /* HandsfreeGateway state */
134 pa_bt_audio_state_t hfgw_state
;
136 pa_hook hooks
[PA_BLUETOOTH_DEVICE_HOOK_MAX
];
139 pa_bluetooth_discovery
* pa_bluetooth_discovery_get(pa_core
*core
);
140 pa_bluetooth_discovery
* pa_bluetooth_discovery_ref(pa_bluetooth_discovery
*y
);
141 void pa_bluetooth_discovery_unref(pa_bluetooth_discovery
*d
);
143 void pa_bluetooth_discovery_sync(pa_bluetooth_discovery
*d
);
145 pa_bluetooth_device
* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery
*d
, const char* path
);
146 pa_bluetooth_device
* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discovery
*d
, const char* address
);
148 bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device
*d
);
150 int pa_bluetooth_transport_acquire(pa_bluetooth_transport
*t
, const char *accesstype
, size_t *imtu
, size_t *omtu
);
151 void pa_bluetooth_transport_release(pa_bluetooth_transport
*t
, const char *accesstype
);
153 pa_hook
* pa_bluetooth_discovery_hook(pa_bluetooth_discovery
*d
);
155 const char* pa_bluetooth_get_form_factor(uint32_t class);
157 char *pa_bluetooth_cleanup_name(const char *name
);
159 pa_bool_t
pa_bluetooth_uuid_has(pa_bluetooth_uuid
*uuids
, const char *uuid
);
160 pa_bt_audio_state_t
pa_bt_audio_state_from_string(const char* value
);