1 /* 2 * 3 * BlueZ - Bluetooth protocol stack for Linux 4 * 5 * Copyright (C) 2006-2010 Nokia Corporation 6 * Copyright (C) 2004-2010 Marcel Holtmann <marcel (at) holtmann.org> 7 * 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 * 23 */ 24 25 #define AUDIO_HEADSET_INTERFACE "org.bluez.Headset" 26 27 #define DEFAULT_HS_AG_CHANNEL 12 28 #define DEFAULT_HF_AG_CHANNEL 13 29 30 typedef enum { 31 HEADSET_STATE_DISCONNECTED, 32 HEADSET_STATE_CONNECTING, 33 HEADSET_STATE_CONNECTED, 34 HEADSET_STATE_PLAY_IN_PROGRESS, 35 HEADSET_STATE_PLAYING 36 } headset_state_t; 37 38 typedef enum { 39 HEADSET_LOCK_READ = 1, 40 HEADSET_LOCK_WRITE = 1 << 1, 41 } headset_lock_t; 42 43 typedef void (*headset_state_cb) (struct audio_device *dev, 44 headset_state_t old_state, 45 headset_state_t new_state, 46 void *user_data); 47 typedef void (*headset_nrec_cb) (struct audio_device *dev, 48 gboolean nrec, 49 void *user_data); 50 51 unsigned int headset_add_state_cb(headset_state_cb cb, void *user_data); 52 gboolean headset_remove_state_cb(unsigned int id); 53 54 typedef void (*headset_stream_cb_t) (struct audio_device *dev, void *user_data); 55 56 void headset_connect_cb(GIOChannel *chan, GError *err, gpointer user_data); 57 58 GIOChannel *headset_get_rfcomm(struct audio_device *dev); 59 60 struct headset *headset_init(struct audio_device *dev, uint16_t svc, 61 const char *uuidstr); 62 63 void headset_unregister(struct audio_device *dev); 64 65 uint32_t headset_config_init(GKeyFile *config); 66 67 void headset_update(struct audio_device *dev, uint16_t svc, 68 const char *uuidstr); 69 70 unsigned int headset_config_stream(struct audio_device *dev, 71 gboolean auto_dc, 72 headset_stream_cb_t cb, 73 void *user_data); 74 unsigned int headset_request_stream(struct audio_device *dev, 75 headset_stream_cb_t cb, 76 void *user_data); 77 unsigned int headset_suspend_stream(struct audio_device *dev, 78 headset_stream_cb_t cb, 79 void *user_data); 80 gboolean headset_cancel_stream(struct audio_device *dev, unsigned int id); 81 82 gboolean get_hfp_active(struct audio_device *dev); 83 void set_hfp_active(struct audio_device *dev, gboolean active); 84 85 void headset_set_authorized(struct audio_device *dev); 86 int headset_connect_rfcomm(struct audio_device *dev, GIOChannel *chan); 87 int headset_connect_sco(struct audio_device *dev, GIOChannel *io); 88 89 headset_state_t headset_get_state(struct audio_device *dev); 90 void headset_set_state(struct audio_device *dev, headset_state_t state); 91 92 int headset_get_channel(struct audio_device *dev); 93 94 int headset_get_sco_fd(struct audio_device *dev); 95 gboolean headset_get_nrec(struct audio_device *dev); 96 unsigned int headset_add_nrec_cb(struct audio_device *dev, 97 headset_nrec_cb cb, void *user_data); 98 gboolean headset_remove_nrec_cb(struct audio_device *dev, unsigned int id); 99 gboolean headset_get_inband(struct audio_device *dev); 100 gboolean headset_get_sco_hci(struct audio_device *dev); 101 102 gboolean headset_is_active(struct audio_device *dev); 103 104 headset_lock_t headset_get_lock(struct audio_device *dev); 105 gboolean headset_lock(struct audio_device *dev, headset_lock_t lock); 106 gboolean headset_unlock(struct audio_device *dev, headset_lock_t lock); 107 gboolean headset_suspend(struct audio_device *dev, void *data); 108 gboolean headset_play(struct audio_device *dev, void *data); 109 void headset_shutdown(struct audio_device *dev); 110