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