~binli/ubuntu/vivid/pulseaudio/load-extcon-module

« back to all changes in this revision

Viewing changes to src/modules/bluetooth/bluez5-util.h

  • Committer: Bin Li
  • Date: 2016-01-23 15:04:48 UTC
  • Revision ID: bin.li@canonical.com-20160123150448-5ockvw4p5xxntda4
init the 1:6.0-0ubuntu9.15 from silo 12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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, see <http://www.gnu.org/licenses/>.
 
21
***/
 
22
 
 
23
#include <pulsecore/core.h>
 
24
 
 
25
#define PA_BLUETOOTH_UUID_A2DP_SOURCE "0000110a-0000-1000-8000-00805f9b34fb"
 
26
#define PA_BLUETOOTH_UUID_A2DP_SINK   "0000110b-0000-1000-8000-00805f9b34fb"
 
27
#define PA_BLUETOOTH_UUID_HSP_HS      "00001108-0000-1000-8000-00805f9b34fb"
 
28
#define PA_BLUETOOTH_UUID_HSP_AG      "00001112-0000-1000-8000-00805f9b34fb"
 
29
#define PA_BLUETOOTH_UUID_HFP_HF      "0000111e-0000-1000-8000-00805f9b34fb"
 
30
#define PA_BLUETOOTH_UUID_HFP_AG      "0000111f-0000-1000-8000-00805f9b34fb"
 
31
 
 
32
typedef struct pa_bluetooth_transport pa_bluetooth_transport;
 
33
typedef struct pa_bluetooth_device pa_bluetooth_device;
 
34
typedef struct pa_bluetooth_adapter pa_bluetooth_adapter;
 
35
typedef struct pa_bluetooth_discovery pa_bluetooth_discovery;
 
36
typedef struct pa_bluetooth_backend pa_bluetooth_backend;
 
37
 
 
38
typedef enum pa_bluetooth_hook {
 
39
    PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED,          /* Call data: pa_bluetooth_device */
 
40
    PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED,            /* Call data: pa_bluetooth_transport */
 
41
    PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED,  /* Call data: pa_bluetooth_transport */
 
42
    PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED,     /* Call data: pa_bluetooth_transport */
 
43
    PA_BLUETOOTH_HOOK_MAX
 
44
} pa_bluetooth_hook_t;
 
45
 
 
46
typedef enum profile {
 
47
    PA_BLUETOOTH_PROFILE_A2DP_SINK,
 
48
    PA_BLUETOOTH_PROFILE_A2DP_SOURCE,
 
49
    PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT,
 
50
    PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY,
 
51
    PA_BLUETOOTH_PROFILE_OFF
 
52
} pa_bluetooth_profile_t;
 
53
#define PA_BLUETOOTH_PROFILE_COUNT PA_BLUETOOTH_PROFILE_OFF
 
54
 
 
55
typedef enum pa_bluetooth_transport_state {
 
56
    PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED,
 
57
    PA_BLUETOOTH_TRANSPORT_STATE_IDLE,
 
58
    PA_BLUETOOTH_TRANSPORT_STATE_PLAYING
 
59
} pa_bluetooth_transport_state_t;
 
60
 
 
61
typedef int (*pa_bluetooth_transport_acquire_cb)(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu);
 
62
typedef void (*pa_bluetooth_transport_release_cb)(pa_bluetooth_transport *t);
 
63
typedef void (*pa_bluetooth_transport_destroy_cb)(pa_bluetooth_transport *t);
 
64
typedef void (*pa_bluetooth_transport_set_speaker_gain_cb)(pa_bluetooth_transport *t, uint16_t gain);
 
65
typedef void (*pa_bluetooth_transport_set_microphone_gain_cb)(pa_bluetooth_transport *t, uint16_t gain);
 
66
 
 
67
struct pa_bluetooth_transport {
 
68
    pa_bluetooth_device *device;
 
69
 
 
70
    char *owner;
 
71
    char *path;
 
72
    pa_bluetooth_profile_t profile;
 
73
 
 
74
    uint8_t codec;
 
75
    uint8_t *config;
 
76
    size_t config_size;
 
77
 
 
78
    uint16_t microphone_gain;
 
79
    uint16_t speaker_gain;
 
80
 
 
81
    pa_bluetooth_transport_state_t state;
 
82
 
 
83
    pa_bluetooth_transport_acquire_cb acquire;
 
84
    pa_bluetooth_transport_release_cb release;
 
85
    pa_bluetooth_transport_destroy_cb destroy;
 
86
    pa_bluetooth_transport_set_speaker_gain_cb set_speaker_gain;
 
87
    pa_bluetooth_transport_set_microphone_gain_cb set_microphone_gain;
 
88
    void *userdata;
 
89
};
 
90
 
 
91
struct pa_bluetooth_device {
 
92
    pa_bluetooth_discovery *discovery;
 
93
    pa_bluetooth_adapter *adapter;
 
94
 
 
95
    bool properties_received;
 
96
    bool tried_to_link_with_adapter;
 
97
    bool valid;
 
98
 
 
99
    /* Device information */
 
100
    char *path;
 
101
    char *adapter_path;
 
102
    char *alias;
 
103
    char *address;
 
104
    uint32_t class_of_device;
 
105
    pa_hashmap *uuids;
 
106
 
 
107
    pa_bluetooth_transport *transports[PA_BLUETOOTH_PROFILE_COUNT];
 
108
};
 
109
 
 
110
struct pa_bluetooth_adapter {
 
111
    pa_bluetooth_discovery *discovery;
 
112
    char *path;
 
113
    char *address;
 
114
 
 
115
    bool valid;
 
116
};
 
117
 
 
118
#ifdef HAVE_BLUEZ_5_OFONO_HEADSET
 
119
pa_bluetooth_backend *pa_bluetooth_ofono_backend_new(pa_core *c, pa_bluetooth_discovery *y);
 
120
void pa_bluetooth_ofono_backend_free(pa_bluetooth_backend *b);
 
121
#else
 
122
static inline pa_bluetooth_backend *pa_bluetooth_ofono_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
 
123
    return NULL;
 
124
}
 
125
static inline void pa_bluetooth_ofono_backend_free(pa_bluetooth_backend *b) {}
 
126
#endif
 
127
 
 
128
#ifdef HAVE_BLUEZ_5_NATIVE_HEADSET
 
129
pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y);
 
130
void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b);
 
131
#else
 
132
static inline pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
 
133
    return NULL;
 
134
}
 
135
static inline void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b) {}
 
136
#endif
 
137
 
 
138
pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
 
139
                                                   pa_bluetooth_profile_t p, const uint8_t *config, size_t size);
 
140
 
 
141
void pa_bluetooth_transport_set_state(pa_bluetooth_transport *t, pa_bluetooth_transport_state_t state);
 
142
void pa_bluetooth_transport_put(pa_bluetooth_transport *t);
 
143
void pa_bluetooth_transport_unlink(pa_bluetooth_transport *t);
 
144
void pa_bluetooth_transport_free(pa_bluetooth_transport *t);
 
145
 
 
146
bool pa_bluetooth_device_any_transport_connected(const pa_bluetooth_device *d);
 
147
bool pa_bluetooth_device_is_transport_connected(const pa_bluetooth_device *d, pa_bluetooth_profile_t profile);
 
148
 
 
149
 
 
150
pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_path(pa_bluetooth_discovery *y, const char *path);
 
151
pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_address(pa_bluetooth_discovery *y, const char *remote, const char *local);
 
152
 
 
153
pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
 
154
 
 
155
const char *pa_bluetooth_profile_to_string(pa_bluetooth_profile_t profile);
 
156
const char *pa_bluetooth_transport_state_to_string(pa_bluetooth_transport_state_t state);
 
157
 
 
158
#define HEADSET_BACKEND_OFONO 0
 
159
#define HEADSET_BACKEND_NATIVE 1
 
160
#define HEADSET_BACKEND_AUTO 2
 
161
#define HEADSET_BACKEND_BOTH 3
 
162
 
 
163
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core, int headset_backend);
 
164
pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
 
165
void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y);
 
166
void pa_bluetooth_discovery_set_ofono_running(pa_bluetooth_discovery *y, bool is_running);
 
167
#endif