]> code.delx.au - pulseaudio/blob - src/modules/bluetooth/bluez5-util.h
bluetooth: Implement org.bluez.MediaEndpoint1.SetConfiguration()
[pulseaudio] / src / modules / bluetooth / bluez5-util.h
1 #ifndef foobluez5utilhfoo
2 #define foobluez5utilhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2008-2013 João 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 <pulsecore/core.h>
26
27 #define PA_BLUETOOTH_UUID_A2DP_SOURCE "0000110a-0000-1000-8000-00805f9b34fb"
28 #define PA_BLUETOOTH_UUID_A2DP_SINK "0000110b-0000-1000-8000-00805f9b34fb"
29
30 typedef struct pa_bluetooth_transport pa_bluetooth_transport;
31 typedef struct pa_bluetooth_device pa_bluetooth_device;
32 typedef struct pa_bluetooth_adapter pa_bluetooth_adapter;
33 typedef struct pa_bluetooth_discovery pa_bluetooth_discovery;
34
35 typedef enum pa_bluetooth_hook {
36 PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED, /* Call data: pa_bluetooth_device */
37 PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED, /* Call data: pa_bluetooth_transport */
38 PA_BLUETOOTH_HOOK_MAX
39 } pa_bluetooth_hook_t;
40
41 typedef enum profile {
42 PA_BLUETOOTH_PROFILE_A2DP_SINK,
43 PA_BLUETOOTH_PROFILE_A2DP_SOURCE,
44 PA_BLUETOOTH_PROFILE_OFF
45 } pa_bluetooth_profile_t;
46 #define PA_BLUETOOTH_PROFILE_COUNT PA_BLUETOOTH_PROFILE_OFF
47
48 typedef enum pa_bluetooth_transport_state {
49 PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED,
50 PA_BLUETOOTH_TRANSPORT_STATE_IDLE,
51 PA_BLUETOOTH_TRANSPORT_STATE_PLAYING
52 } pa_bluetooth_transport_state_t;
53
54 typedef int (*pa_bluetooth_transport_acquire_cb)(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu);
55 typedef void (*pa_bluetooth_transport_release_cb)(pa_bluetooth_transport *t);
56
57 struct pa_bluetooth_transport {
58 pa_bluetooth_device *device;
59
60 char *owner;
61 char *path;
62 pa_bluetooth_profile_t profile;
63
64 uint8_t codec;
65 uint8_t *config;
66 size_t config_size;
67
68 pa_bluetooth_transport_state_t state;
69
70 pa_bluetooth_transport_acquire_cb acquire;
71 pa_bluetooth_transport_release_cb release;
72 void *userdata;
73 };
74
75 struct pa_bluetooth_device {
76 pa_bluetooth_discovery *discovery;
77 pa_bluetooth_adapter *adapter;
78
79 int device_info_valid; /* 0: no results yet; 1: good results; -1: bad results ... */
80
81 /* Device information */
82 char *path;
83 char *alias;
84 char *address;
85 uint32_t class_of_device;
86
87 pa_bluetooth_transport *transports[PA_BLUETOOTH_PROFILE_COUNT];
88 };
89
90 struct pa_bluetooth_adapter {
91 pa_bluetooth_discovery *discovery;
92 char *path;
93 char *address;
94 };
95
96 pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
97 pa_bluetooth_profile_t p, const uint8_t *config, size_t size);
98
99 void pa_bluetooth_transport_put(pa_bluetooth_transport *t);
100 void pa_bluetooth_transport_free(pa_bluetooth_transport *t);
101
102 bool pa_bluetooth_device_any_transport_connected(const pa_bluetooth_device *d);
103
104 pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_path(pa_bluetooth_discovery *y, const char *path);
105 pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_address(pa_bluetooth_discovery *y, const char *remote, const char *local);
106
107 pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
108
109 const char *pa_bluetooth_profile_to_string(pa_bluetooth_profile_t profile);
110
111 pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core);
112 pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
113 void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y);
114 #endif