bluetooth: Add SuspendMedia method
[platform/upstream/pulseaudio.git] / 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 #define PA_BLUETOOTH_UUID_HSP_HS      "00001108-0000-1000-8000-00805f9b34fb"
30 #define PA_BLUETOOTH_UUID_HSP_AG      "00001112-0000-1000-8000-00805f9b34fb"
31 #define PA_BLUETOOTH_UUID_HFP_HF      "0000111e-0000-1000-8000-00805f9b34fb"
32 #define PA_BLUETOOTH_UUID_HFP_AG      "0000111f-0000-1000-8000-00805f9b34fb"
33
34 typedef struct pa_bluetooth_transport pa_bluetooth_transport;
35 typedef struct pa_bluetooth_device pa_bluetooth_device;
36 typedef struct pa_bluetooth_adapter pa_bluetooth_adapter;
37 typedef struct pa_bluetooth_discovery pa_bluetooth_discovery;
38
39 typedef enum pa_bluetooth_hook {
40     PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED,          /* Call data: pa_bluetooth_device */
41     PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED,            /* Call data: pa_bluetooth_transport */
42 #ifdef __TIZEN_BT__
43     PA_BLUETOOTH_HOOK_SCO_STATE_CHANGED,            /* Call data: pa_bluetooth_transport */
44 #endif
45     PA_BLUETOOTH_HOOK_MAX
46 } pa_bluetooth_hook_t;
47
48 typedef enum profile {
49     PA_BLUETOOTH_PROFILE_A2DP_SINK,
50     PA_BLUETOOTH_PROFILE_A2DP_SOURCE,
51     PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT,
52     PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY,
53     PA_BLUETOOTH_PROFILE_OFF
54 } pa_bluetooth_profile_t;
55 #define PA_BLUETOOTH_PROFILE_COUNT PA_BLUETOOTH_PROFILE_OFF
56
57 typedef enum pa_bluetooth_transport_state {
58     PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED,
59     PA_BLUETOOTH_TRANSPORT_STATE_IDLE,
60     PA_BLUETOOTH_TRANSPORT_STATE_PLAYING
61 } pa_bluetooth_transport_state_t;
62
63 typedef int (*pa_bluetooth_transport_acquire_cb)(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu);
64 typedef void (*pa_bluetooth_transport_release_cb)(pa_bluetooth_transport *t);
65
66 struct pa_bluetooth_transport {
67     pa_bluetooth_device *device;
68
69     char *owner;
70     char *path;
71     pa_bluetooth_profile_t profile;
72
73     uint8_t codec;
74     uint8_t *config;
75     size_t config_size;
76
77     pa_bluetooth_transport_state_t state;
78
79     pa_bluetooth_transport_acquire_cb acquire;
80     pa_bluetooth_transport_release_cb release;
81     void *userdata;
82 };
83
84 struct pa_bluetooth_device {
85     pa_bluetooth_discovery *discovery;
86     pa_bluetooth_adapter *adapter;
87
88     int device_info_valid;      /* 0: no results yet; 1: good results; -1: bad results ... */
89
90     /* Device information */
91     char *path;
92     char *adapter_path;
93     char *alias;
94     char *address;
95     uint32_t class_of_device;
96     pa_hashmap *uuids;
97
98     pa_bluetooth_transport *transports[PA_BLUETOOTH_PROFILE_COUNT];
99 };
100
101 struct pa_bluetooth_adapter {
102     pa_bluetooth_discovery *discovery;
103     char *path;
104     char *address;
105 };
106
107 pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
108                                                    pa_bluetooth_profile_t p, const uint8_t *config, size_t size);
109
110 void pa_bluetooth_transport_put(pa_bluetooth_transport *t);
111 void pa_bluetooth_transport_free(pa_bluetooth_transport *t);
112
113 bool pa_bluetooth_device_any_transport_connected(const pa_bluetooth_device *d);
114 #ifdef __TIZEN_BT__
115 bool pa_bluetooth_device_sink_transport_connected(const pa_bluetooth_device *d);
116 bool pa_bluetooth_device_source_transport_connected(const pa_bluetooth_device *d);
117 #endif
118
119 pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_path(pa_bluetooth_discovery *y, const char *path);
120 pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_address(pa_bluetooth_discovery *y, const char *remote, const char *local);
121
122 pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
123
124 const char *pa_bluetooth_profile_to_string(pa_bluetooth_profile_t profile);
125
126 pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core);
127 pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
128 void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y);
129
130 #ifdef BLUETOOTH_APTX_SUPPORT
131 int pa_load_aptx(const char *aptx_lib_name);
132 int pa_unload_aptx(void);
133 void* pa_aptx_get_handle(void);
134 #endif
135
136 #endif