bluetooth: add discover of bluetooth sources
[platform/upstream/pulseaudio.git] / src / modules / bluetooth / bluetooth-util.h
1 #ifndef foobluetoothutilhfoo
2 #define foobluetoothutilhfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 2008-2009 Joao Paulo Rechi Vita
8
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.
13
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.
18
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
22   USA.
23 ***/
24
25 #include <dbus/dbus.h>
26
27 #include <pulsecore/llist.h>
28 #include <pulsecore/macro.h>
29 #include <pulsecore/core-util.h>
30
31 /* UUID copied from bluez/audio/device.h */
32 #define GENERIC_AUDIO_UUID      "00001203-0000-1000-8000-00805F9B34FB"
33
34 #define HSP_HS_UUID             "00001108-0000-1000-8000-00805F9B34FB"
35 #define HSP_AG_UUID             "00001112-0000-1000-8000-00805F9B34FB"
36
37 #define HFP_HS_UUID             "0000111E-0000-1000-8000-00805F9B34FB"
38 #define HFP_AG_UUID             "0000111F-0000-1000-8000-00805F9B34FB"
39
40 #define ADVANCED_AUDIO_UUID     "0000110D-0000-1000-8000-00805F9B34FB"
41
42 #define A2DP_SOURCE_UUID        "0000110A-0000-1000-8000-00805F9B34FB"
43 #define A2DP_SINK_UUID          "0000110B-0000-1000-8000-00805F9B34FB"
44
45 typedef struct pa_bluetooth_uuid pa_bluetooth_uuid;
46 typedef struct pa_bluetooth_device pa_bluetooth_device;
47 typedef struct pa_bluetooth_discovery pa_bluetooth_discovery;
48
49 struct userdata;
50
51 struct pa_bluetooth_uuid {
52     char *uuid;
53     PA_LLIST_FIELDS(pa_bluetooth_uuid);
54 };
55
56 /* This enum is shared among Audio, Headset, AudioSink, and AudioSource, although not all values are acceptable in all profiles */
57 typedef enum pa_bt_audio_state {
58     PA_BT_AUDIO_STATE_INVALID = -1,
59     PA_BT_AUDIO_STATE_DISCONNECTED,
60     PA_BT_AUDIO_STATE_CONNECTING,
61     PA_BT_AUDIO_STATE_CONNECTED,
62     PA_BT_AUDIO_STATE_PLAYING
63 } pa_bt_audio_state_t;
64
65 struct pa_bluetooth_device {
66     pa_bool_t dead;
67
68     int device_info_valid;      /* 0: no results yet; 1: good results; -1: bad results ... */
69
70     /* Device information */
71     char *name;
72     char *path;
73     int paired;
74     char *alias;
75     int device_connected;
76     PA_LLIST_HEAD(pa_bluetooth_uuid, uuids);
77     char *address;
78     int class;
79     int trusted;
80
81     /* Audio state */
82     pa_bt_audio_state_t audio_state;
83
84     /* AudioSink state */
85     pa_bt_audio_state_t audio_sink_state;
86
87     /* AudioSource state */
88     pa_bt_audio_state_t audio_source_state;
89
90     /* Headset state */
91     pa_bt_audio_state_t headset_state;
92 };
93
94 pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core);
95 pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
96 void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *d);
97
98 void pa_bluetooth_discovery_sync(pa_bluetooth_discovery *d);
99
100 const pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *d, const char* path);
101 const pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discovery *d, const char* address);
102
103 pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *d);
104
105 const char* pa_bluetooth_get_form_factor(uint32_t class);
106
107 char *pa_bluetooth_cleanup_name(const char *name);
108
109 pa_bool_t pa_bluetooth_uuid_has(pa_bluetooth_uuid *uuids, const char *uuid);
110
111 #endif