Home | History | Annotate | Download | only in audio
      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 
     48 unsigned int headset_add_state_cb(headset_state_cb cb, void *user_data);
     49 gboolean headset_remove_state_cb(unsigned int id);
     50 
     51 typedef void (*headset_stream_cb_t) (struct audio_device *dev, void *user_data);
     52 
     53 void headset_connect_cb(GIOChannel *chan, GError *err, gpointer user_data);
     54 
     55 GIOChannel *headset_get_rfcomm(struct audio_device *dev);
     56 
     57 struct headset *headset_init(struct audio_device *dev, uint16_t svc,
     58 				const char *uuidstr);
     59 
     60 void headset_unregister(struct audio_device *dev);
     61 
     62 uint32_t headset_config_init(GKeyFile *config);
     63 
     64 void headset_update(struct audio_device *dev, uint16_t svc,
     65 			const char *uuidstr);
     66 
     67 unsigned int headset_config_stream(struct audio_device *dev,
     68 					gboolean auto_dc,
     69 					headset_stream_cb_t cb,
     70 					void *user_data);
     71 unsigned int headset_request_stream(struct audio_device *dev,
     72 					headset_stream_cb_t cb,
     73 					void *user_data);
     74 unsigned int headset_suspend_stream(struct audio_device *dev,
     75 					headset_stream_cb_t cb,
     76 					void *user_data);
     77 gboolean headset_cancel_stream(struct audio_device *dev, unsigned int id);
     78 
     79 gboolean get_hfp_active(struct audio_device *dev);
     80 void set_hfp_active(struct audio_device *dev, gboolean active);
     81 
     82 void headset_set_authorized(struct audio_device *dev);
     83 int headset_connect_rfcomm(struct audio_device *dev, GIOChannel *chan);
     84 int headset_connect_sco(struct audio_device *dev, GIOChannel *io);
     85 
     86 headset_state_t headset_get_state(struct audio_device *dev);
     87 void headset_set_state(struct audio_device *dev, headset_state_t state);
     88 
     89 int headset_get_channel(struct audio_device *dev);
     90 
     91 int headset_get_sco_fd(struct audio_device *dev);
     92 gboolean headset_get_nrec(struct audio_device *dev);
     93 gboolean headset_get_sco_hci(struct audio_device *dev);
     94 
     95 gboolean headset_is_active(struct audio_device *dev);
     96 
     97 headset_lock_t headset_get_lock(struct audio_device *dev);
     98 gboolean headset_lock(struct audio_device *dev, headset_lock_t lock);
     99 gboolean headset_unlock(struct audio_device *dev, headset_lock_t lock);
    100 gboolean headset_suspend(struct audio_device *dev, void *data);
    101 gboolean headset_play(struct audio_device *dev, void *data);
    102 void headset_shutdown(struct audio_device *dev);
    103