2009-01-29 20:30:42 +01:00
|
|
|
#ifndef foobluetoothutilhfoo
|
|
|
|
|
#define foobluetoothutilhfoo
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
This file is part of PulseAudio.
|
|
|
|
|
|
2009-07-24 21:44:36 -03:00
|
|
|
Copyright 2008-2009 Joao Paulo Rechi Vita
|
2009-01-29 20:30:42 +01:00
|
|
|
|
|
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Lesser General Public License as
|
2009-03-03 20:23:02 +00:00
|
|
|
published by the Free Software Foundation; either version 2.1 of the
|
2009-01-29 20:30:42 +01:00
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
License along with PulseAudio; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
|
|
|
|
|
|
#include <pulsecore/llist.h>
|
|
|
|
|
#include <pulsecore/macro.h>
|
|
|
|
|
|
2011-03-21 15:08:34 +02:00
|
|
|
#define PA_BLUETOOTH_ERROR_NOT_SUPPORTED "org.bluez.Error.NotSupported"
|
|
|
|
|
|
2009-03-27 13:56:26 +02:00
|
|
|
/* UUID copied from bluez/audio/device.h */
|
2010-11-03 14:44:28 +02:00
|
|
|
#define GENERIC_AUDIO_UUID "00001203-0000-1000-8000-00805f9b34fb"
|
2009-03-27 13:56:26 +02:00
|
|
|
|
2010-11-03 14:44:28 +02:00
|
|
|
#define HSP_HS_UUID "00001108-0000-1000-8000-00805f9b34fb"
|
|
|
|
|
#define HSP_AG_UUID "00001112-0000-1000-8000-00805f9b34fb"
|
2009-03-27 13:56:26 +02:00
|
|
|
|
2010-11-03 14:44:28 +02:00
|
|
|
#define HFP_HS_UUID "0000111e-0000-1000-8000-00805f9b34fb"
|
|
|
|
|
#define HFP_AG_UUID "0000111f-0000-1000-8000-00805f9b34fb"
|
2009-03-27 13:56:26 +02:00
|
|
|
|
2010-11-03 14:44:28 +02:00
|
|
|
#define ADVANCED_AUDIO_UUID "0000110d-0000-1000-8000-00805f9b34fb"
|
2009-03-27 13:56:26 +02:00
|
|
|
|
2010-11-03 14:44:28 +02:00
|
|
|
#define A2DP_SOURCE_UUID "0000110a-0000-1000-8000-00805f9b34fb"
|
|
|
|
|
#define A2DP_SINK_UUID "0000110b-0000-1000-8000-00805f9b34fb"
|
2009-03-27 13:56:26 +02:00
|
|
|
|
2012-12-14 15:14:28 +01:00
|
|
|
#define HSP_MAX_GAIN 15
|
|
|
|
|
|
2009-01-29 20:30:42 +01:00
|
|
|
typedef struct pa_bluetooth_uuid pa_bluetooth_uuid;
|
|
|
|
|
typedef struct pa_bluetooth_device pa_bluetooth_device;
|
|
|
|
|
typedef struct pa_bluetooth_discovery pa_bluetooth_discovery;
|
2010-10-07 17:22:41 +03:00
|
|
|
typedef struct pa_bluetooth_transport pa_bluetooth_transport;
|
2009-01-29 20:30:42 +01:00
|
|
|
|
|
|
|
|
struct userdata;
|
|
|
|
|
|
|
|
|
|
struct pa_bluetooth_uuid {
|
|
|
|
|
char *uuid;
|
|
|
|
|
PA_LLIST_FIELDS(pa_bluetooth_uuid);
|
|
|
|
|
};
|
|
|
|
|
|
2010-10-07 17:22:41 +03:00
|
|
|
enum profile {
|
|
|
|
|
PROFILE_A2DP,
|
|
|
|
|
PROFILE_A2DP_SOURCE,
|
|
|
|
|
PROFILE_HSP,
|
|
|
|
|
PROFILE_HFGW,
|
|
|
|
|
PROFILE_OFF
|
|
|
|
|
};
|
|
|
|
|
|
2012-12-06 10:35:19 +01:00
|
|
|
#define PA_BLUETOOTH_PROFILE_COUNT PROFILE_OFF
|
|
|
|
|
|
2012-12-06 15:55:28 +01:00
|
|
|
struct pa_bluetooth_hook_uuid_data {
|
|
|
|
|
pa_bluetooth_device *device;
|
|
|
|
|
const char *uuid;
|
|
|
|
|
};
|
|
|
|
|
|
2012-12-06 15:55:27 +01:00
|
|
|
/* Hook data: pa_bluetooth_discovery pointer. */
|
|
|
|
|
typedef enum pa_bluetooth_hook {
|
|
|
|
|
PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED, /* Call data: pa_bluetooth_device */
|
2012-12-06 15:55:28 +01:00
|
|
|
PA_BLUETOOTH_HOOK_DEVICE_UUID_ADDED, /* Call data: pa_bluetooth_hook_uuid_data */
|
2012-12-10 08:30:39 +01:00
|
|
|
PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED, /* Call data: pa_bluetooth_transport */
|
|
|
|
|
PA_BLUETOOTH_HOOK_TRANSPORT_NREC_CHANGED, /* Call data: pa_bluetooth_transport */
|
2012-12-14 15:14:28 +01:00
|
|
|
PA_BLUETOOTH_HOOK_TRANSPORT_MICROPHONE_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
|
2012-12-14 15:14:29 +01:00
|
|
|
PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED, /* Call data: pa_bluetooth_transport */
|
2012-12-06 15:55:27 +01:00
|
|
|
PA_BLUETOOTH_HOOK_MAX
|
|
|
|
|
} pa_bluetooth_hook_t;
|
|
|
|
|
|
2012-12-10 08:30:38 +01:00
|
|
|
typedef enum pa_bluetooth_transport_state {
|
|
|
|
|
PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED,
|
|
|
|
|
PA_BLUETOOTH_TRANSPORT_STATE_IDLE, /* Connected but not playing */
|
|
|
|
|
PA_BLUETOOTH_TRANSPORT_STATE_PLAYING
|
|
|
|
|
} pa_bluetooth_transport_state_t;
|
|
|
|
|
|
2010-10-07 17:22:41 +03:00
|
|
|
struct pa_bluetooth_transport {
|
2012-12-05 17:23:15 +01:00
|
|
|
pa_bluetooth_device *device;
|
2012-11-12 12:26:02 +02:00
|
|
|
char *owner;
|
2010-10-07 17:22:41 +03:00
|
|
|
char *path;
|
|
|
|
|
enum profile profile;
|
|
|
|
|
uint8_t codec;
|
|
|
|
|
uint8_t *config;
|
|
|
|
|
int config_size;
|
2012-12-10 08:30:38 +01:00
|
|
|
|
|
|
|
|
pa_bluetooth_transport_state_t state;
|
2011-01-14 14:18:08 +02:00
|
|
|
pa_bool_t nrec;
|
2012-12-14 15:14:28 +01:00
|
|
|
uint16_t microphone_gain; /* Used for HSP/HFP */
|
2012-12-14 15:14:29 +01:00
|
|
|
uint16_t speaker_gain; /* Used for HSP/HFP */
|
2010-10-07 17:22:41 +03:00
|
|
|
};
|
|
|
|
|
|
2009-07-24 21:44:36 -03:00
|
|
|
/* This enum is shared among Audio, Headset, AudioSink, and AudioSource, although not all values are acceptable in all profiles */
|
2009-03-30 20:55:10 +02:00
|
|
|
typedef enum pa_bt_audio_state {
|
2009-03-27 21:48:04 +02:00
|
|
|
PA_BT_AUDIO_STATE_INVALID = -1,
|
|
|
|
|
PA_BT_AUDIO_STATE_DISCONNECTED,
|
|
|
|
|
PA_BT_AUDIO_STATE_CONNECTING,
|
|
|
|
|
PA_BT_AUDIO_STATE_CONNECTED,
|
2009-08-15 22:24:13 +02:00
|
|
|
PA_BT_AUDIO_STATE_PLAYING
|
2009-03-30 20:55:10 +02:00
|
|
|
} pa_bt_audio_state_t;
|
2009-03-27 21:48:04 +02:00
|
|
|
|
2009-01-29 20:30:42 +01:00
|
|
|
struct pa_bluetooth_device {
|
2012-11-20 14:51:27 +02:00
|
|
|
pa_bluetooth_discovery *discovery;
|
2009-03-21 01:19:49 +01:00
|
|
|
pa_bool_t dead;
|
2009-01-29 20:30:42 +01:00
|
|
|
|
|
|
|
|
int device_info_valid; /* 0: no results yet; 1: good results; -1: bad results ... */
|
|
|
|
|
|
|
|
|
|
/* Device information */
|
|
|
|
|
char *name;
|
|
|
|
|
char *path;
|
2012-12-06 10:35:19 +01:00
|
|
|
pa_bluetooth_transport *transports[PA_BLUETOOTH_PROFILE_COUNT];
|
2009-01-29 20:30:42 +01:00
|
|
|
int paired;
|
|
|
|
|
char *alias;
|
|
|
|
|
PA_LLIST_HEAD(pa_bluetooth_uuid, uuids);
|
|
|
|
|
char *address;
|
|
|
|
|
int class;
|
|
|
|
|
int trusted;
|
|
|
|
|
|
2009-03-27 21:48:04 +02:00
|
|
|
/* Audio state */
|
2009-03-30 20:55:10 +02:00
|
|
|
pa_bt_audio_state_t audio_state;
|
2009-01-29 20:30:42 +01:00
|
|
|
|
2012-12-06 15:55:29 +01:00
|
|
|
/* AudioSink, AudioSource, Headset and HandsfreeGateway states */
|
|
|
|
|
pa_bt_audio_state_t profile_state[PA_BLUETOOTH_PROFILE_COUNT];
|
2009-01-29 20:30:42 +01:00
|
|
|
};
|
|
|
|
|
|
2009-03-21 01:19:49 +01:00
|
|
|
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core);
|
|
|
|
|
pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y);
|
|
|
|
|
void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *d);
|
2009-01-29 20:30:42 +01:00
|
|
|
|
|
|
|
|
void pa_bluetooth_discovery_sync(pa_bluetooth_discovery *d);
|
|
|
|
|
|
2012-10-22 10:46:36 +02:00
|
|
|
pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *d, const char* path);
|
|
|
|
|
pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discovery *d, const char* address);
|
2009-03-21 01:19:49 +01:00
|
|
|
|
2012-11-22 15:20:26 +01:00
|
|
|
bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d);
|
2010-10-07 17:22:41 +03:00
|
|
|
|
2012-10-19 10:11:24 +02:00
|
|
|
int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, const char *accesstype, size_t *imtu, size_t *omtu);
|
|
|
|
|
void pa_bluetooth_transport_release(pa_bluetooth_transport *t, const char *accesstype);
|
2010-10-07 17:22:41 +03:00
|
|
|
|
2012-12-14 15:14:28 +01:00
|
|
|
void pa_bluetooth_transport_set_microphone_gain(pa_bluetooth_transport *t, uint16_t value);
|
2012-12-14 15:14:29 +01:00
|
|
|
void pa_bluetooth_transport_set_speaker_gain(pa_bluetooth_transport *t, uint16_t value);
|
2012-12-14 15:14:28 +01:00
|
|
|
|
2012-12-06 15:55:27 +01:00
|
|
|
pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook);
|
2009-03-21 01:19:49 +01:00
|
|
|
|
|
|
|
|
const char* pa_bluetooth_get_form_factor(uint32_t class);
|
2009-02-02 00:30:10 +01:00
|
|
|
|
|
|
|
|
char *pa_bluetooth_cleanup_name(const char *name);
|
|
|
|
|
|
2009-03-27 21:48:04 +02:00
|
|
|
pa_bool_t pa_bluetooth_uuid_has(pa_bluetooth_uuid *uuids, const char *uuid);
|
2011-10-04 09:37:25 +02:00
|
|
|
pa_bt_audio_state_t pa_bt_audio_state_from_string(const char* value);
|
2012-12-14 15:14:31 +01:00
|
|
|
const char *pa_bt_profile_to_string(enum profile profile);
|
2009-03-27 21:48:04 +02:00
|
|
|
|
2009-01-29 20:30:42 +01:00
|
|
|
#endif
|