Add org.bluez.Telephony interface
Subsystems (2)
v2 cover Add org.bluez.Telephony interface
Hello,
This set of patches replaces telephony drivers for HeadSet/HandsFree Profiles by a new DBus interface (org.bluez.Telephony). External applications, which should implement AT parsing and telephony part of HeadSet or HandsFree Profiles, will have to register a telephony agent using this new interface.
First patch add the new org.bluez.Telephony interface and remove functions related to AT parsing from audio/headset.c.
Second patch remove the telephony drivers (dummy, maemo5, maemo6 and ofono), functions used by telephony drivers and no more needed methods of org.bluez.Headset interface.
Third patch move the HS/HF AG rfcomm servers from audio/manager.c to audio/telephony.c.
Rfcomm server for a specific profile is only started (and the related sdp records advertised) when an agent register for it.
Fourth patch passes MediaTransport path to the agent during NewConnection mehod call. So, telephony agent will be able to set NREC and ringtone, which can in turn notify Pulse Audio of property changed.
What I would like to do to continue is:
- add org.bluez.HeadsetGataway, which will replace org.bluez.HandsfreeGateway (audio/gateway.c)
Any comments appreciated
Regards
Fred
Frédéric Danis (4):
audio: Move tel drivers to DBus interface
audio: Remove tel drivers
audio: Move HFP/HSP AG servers to telephony.c
audio: Send transport path to telephony agent
Makefile.am | 17 +- audio/headset.c | 1561 ++------------------------------- audio/headset.h | 14 +- audio/manager.c | 390 +-------- audio/media.c | 9 +- audio/telephony-dummy.c | 433 --------- audio/telephony-maemo5.c | 2104 -------------------------------------------- audio/telephony-maemo6.c | 2201 ---------------------------------------------- audio/telephony-ofono.c | 1638 ---------------------------------- audio/telephony.c | 960 ++++++++++++++++++++ audio/telephony.h | 198 +---- audio/transport.c | 10 + audio/unix.c | 2 + doc/assigned-numbers.txt | 1 + doc/audio-api.txt | 91 ++ 15 files changed, 1148 insertions(+), 8481 deletions(-) delete mode 100644 audio/telephony-dummy.c delete mode 100644 audio/telephony-maemo5.c delete mode 100644 audio/telephony-maemo6.c delete mode 100644 audio/telephony-ofono.c create mode 100644 audio/telephony.c
RFC v2 1/4 audio: Move tel drivers to DBus interface
--- Makefile.am | 13 +- audio/headset.c | 614 ++-------------------------------------------- audio/headset.h | 2 + audio/manager.c | 4 +- audio/telephony.c | 529 +++++++++++++++++++++++++++++++++++++++ audio/telephony.h | 25 +-- doc/assigned-numbers.txt | 1 + doc/audio-api.txt | 91 +++++++ 8 files changed, 648 insertions(+), 631 deletions(-) create mode 100644 audio/telephony.c
Makefile.am +2 -11
@@ -154,14 +154,8 @@ builtin_sources += audio/main.c \ audio/unix.h audio/unix.c \ audio/media.h audio/media.c \ audio/transport.h audio/transport.c \ - audio/telephony.h audio/a2dp-codecs.h -builtin_nodist += audio/telephony.c - -noinst_LIBRARIES += audio/libtelephony.a - -audio_libtelephony_a_SOURCES = audio/telephony.h audio/telephony-dummy.c \ - audio/telephony-maemo5.c audio/telephony-ofono.c \ - audio/telephony-maemo6.c + audio/telephony.h audio/telephony.c \ + audio/a2dp-codecs.h endif if SAPPLUGIN
@@ -476,9 +470,6 @@ MAINTAINERCLEANFILES = Makefile.in \ src/builtin.h: src/genbuiltin $(builtin_sources) $(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@ -audio/telephony.c: audio/@TELEPHONY_DRIVER@ - $(AM_V_GEN)$(LN_S) $(abs_top_srcdir)/$< $@ - sap/sap.c: sap/@SAP_DRIVER@ $(AM_V_GEN)$(LN_S) $(abs_top_srcdir)/$< $@
audio/headset.c +15 -599
771 lines not on this page · raw message
audio/headset.h +2 -0
@@ -111,3 +111,5 @@ gboolean headset_unlock(struct audio_device *dev, headset_lock_t lock);gboolean headset_suspend (struct audio_device *dev,void *data);gboolean headset_play (struct audio_device *dev,void *data);void headset_shutdown (struct audio_device *dev); + +void headset_slc_complete (struct audio_device *dev);
audio/manager.c +2 -2
@@ -880,7 +880,7 @@ static void state_changed(struct btd_adapter *adapter, gboolean powered)/* telephony driver already initialized*/ if (telephony == TRUE)return ; -telephony_init (); +telephony_init (adapter); telephony = TRUE;return ; }
@@ -896,7 +896,7 @@ static void state_changed(struct btd_adapter *adapter, gboolean powered)return ; } -telephony_exit (); +telephony_exit (adapter); telephony = FALSE; }
audio/telephony.c new file +529 -0
529 lines not on this page · raw message
audio/telephony.h +6 -19
@@ -144,26 +144,13 @@ struct indicator {/* Notify telephony-*.c of connected/disconnected devices. Implemented by * telephony-*.c */ +void *telephony_device_connecting (GIOChannel *io,void *telephony_device);void telephony_device_connected (void *telephony_device); +void telephony_device_disconnect (void *slc);void telephony_device_disconnected (void *telephony_device); -/* HF requests (sent by the handsfree device). These are implemented by -* telephony-*.c -*/ -void telephony_event_reporting_req (void *telephony_device,int ind); -void telephony_response_and_hold_req (void *telephony_device,int rh); -void telephony_last_dialed_number_req (void *telephony_device); -void telephony_terminate_call_req (void *telephony_device); -void telephony_answer_call_req (void *telephony_device); -void telephony_dial_number_req (void *telephony_device,const char *number); -void telephony_transmit_dtmf_req (void *telephony_device,char tone); -void telephony_subscriber_number_req (void *telephony_device); -void telephony_list_current_calls_req (void *telephony_device); -void telephony_operator_selection_req (void *telephony_device); -void telephony_call_hold_req (void *telephony_device,const char *cmd); -void telephony_nr_and_ec_req (void *telephony_device,gboolean enable); -void telephony_voice_dial_req (void *telephony_device,gboolean enable); -void telephony_key_press_req (void *telephony_device,const char *keys); +gboolean telephony_get_ready_state (void ); +uint32_t telephony_get_ag_features (void );/* AG responses to HF requests. These are implemented by headset.c */ int telephony_event_reporting_rsp (void *telephony_device,cme_error_t err);
@@ -240,5 +227,5 @@ static inline int telephony_get_indicator(const struct indicator *indicators,return -ENOENT ; } -int telephony_init (void ); -void telephony_exit (void ); +int telephony_init (void *adapter); +void telephony_exit (void *adapter);
doc/assigned-numbers.txt +1 -0
@@ -8,6 +8,7 @@ avoid conflicts. Profile Channel ----------------------- DUN 1 +HSP HS 6 HFP HF 7 OPP 9 FTP 10
doc/audio-api.txt +91 -0
94 lines not on this page · raw message
Signature · 1 line
1.7.1
RFC v2 3/4 audio: Move HFP/HSP AG servers to telephony.c
In reply to Frédéric Danis--- audio/headset.c | 25 +++ audio/headset.h | 5 +- audio/manager.c | 386 -------------------------------------------- audio/telephony.c | 459 ++++++++++++++++++++++++++++++++++++++++++++++++++--- audio/telephony.h | 1 + 5 files changed, 467 insertions(+), 409 deletions(-)
audio/headset.c +25 -0
@@ -108,6 +108,7 @@ struct headset {GIOChannel *rfcomm;GIOChannel *tmp_rfcomm; +void *connecting_agent;GIOChannel *sco;guint sco_id;
@@ -413,6 +414,7 @@ void headset_connect_cb(GIOChannel *chan, GError *err, gpointer user_data) hs->auto_dc = FALSE; hs->slc =telephony_device_connecting (chan, dev); + hs->connecting_agent =NULL ;DBG ("%s: Connected to %s" , dev->path, hs_address);
@@ -563,6 +565,7 @@ failed_not_supported: } failed: p->svclass =0 ; + hs->connecting_agent =NULL ;pending_connect_finalize (dev);headset_set_state (dev,HEADSET_STATE_DISCONNECTED ); }
@@ -581,6 +584,14 @@ static int get_records(struct audio_device *device, headset_stream_cb_t cb, svclass = hs->search_hfp ?HANDSFREE_SVCLASS_ID :HEADSET_SVCLASS_ID ; +if (svclass ==HANDSFREE_SVCLASS_ID ) + hs->connecting_agent =telephony_agent_by_uuid (HFP_AG_UUID ); +else + hs->connecting_agent =telephony_agent_by_uuid (HSP_AG_UUID ); + +if (hs->connecting_agent ==NULL ) +return -1 ; +sdp_uuid16_create (&uuid, svclass); err = bt_search_service(&device->src, &device->dst, &uuid,
@@ -1251,6 +1262,20 @@ GIOChannel *headset_get_rfcomm(struct audio_device *dev)return hs->tmp_rfcomm; } +void headset_set_connecting_agent (struct audio_device *dev,void *agent) +{ +struct headset *hs = dev->headset; + + hs->connecting_agent = agent; +} + +void *headset_get_connecting_agent (struct audio_device *dev) +{ +struct headset *hs = dev->headset; + +return hs->connecting_agent; +} +int headset_connect_rfcomm (struct audio_device *dev,GIOChannel *io) {struct headset *hs = dev->headset;
audio/headset.h +2 -3
@@ -24,9 +24,6 @@#define AUDIO_HEADSET_INTERFACE "org.bluez.Headset" -#define DEFAULT_HS_AG_CHANNEL 12 -#define DEFAULT_HF_AG_CHANNEL 13 - typedef enum { HEADSET_STATE_DISCONNECTED, HEADSET_STATE_CONNECTING,
@@ -108,3 +105,5 @@ gboolean headset_play(struct audio_device *dev, void *data);void headset_shutdown (struct audio_device *dev);void headset_slc_complete (struct audio_device *dev); +void headset_set_connecting_agent (struct audio_device *dev,void *agent); +void *headset_get_connecting_agent (struct audio_device *dev);
audio/manager.c +0 -386
429 lines not on this page · raw message
audio/telephony.c +439 -20
557 lines not on this page · raw message
audio/telephony.h +1 -0
@@ -55,6 +55,7 @@ void telephony_device_disconnected(void *telephony_device);gboolean telephony_get_ready_state (void );uint32_t telephony_get_ag_features (void ); +void *telephony_agent_by_uuid (const char *uuid);int telephony_init (void *adapter);void telephony_exit (void *adapter);
Signature · 1 line
1.7.1
RFC v2 4/4 audio: Send transport path to telephony agent
In reply to Frédéric Danis--- audio/headset.c | 19 +++++++++++++++++++ audio/headset.h | 2 ++ audio/media.c | 9 ++++++++- audio/telephony.c | 12 ++++++++++++ audio/telephony.h | 1 + 5 files changed, 42 insertions(+), 1 deletions(-)
audio/headset.c +19 -0
@@ -109,6 +109,7 @@ struct headset {GIOChannel *rfcomm;GIOChannel *tmp_rfcomm;void *connecting_agent; +const char *connecting_path;GIOChannel *sco;guint sco_id;
@@ -415,6 +416,8 @@ void headset_connect_cb(GIOChannel *chan, GError *err, gpointer user_data) hs->slc =telephony_device_connecting (chan, dev); hs->connecting_agent =NULL ; +telephony_set_media_transport_path (hs->slc, hs->connecting_path); + hs->connecting_path =NULL ;DBG ("%s: Connected to %s" , dev->path, hs_address);
@@ -566,6 +569,7 @@ failed_not_supported: failed: p->svclass =0 ; hs->connecting_agent =NULL ; + hs->connecting_path =NULL ;pending_connect_finalize (dev);headset_set_state (dev,HEADSET_STATE_DISCONNECTED ); }
@@ -1276,6 +1280,21 @@ void *headset_get_connecting_agent(struct audio_device *dev)return hs->connecting_agent; } +void headset_set_media_transport_path (struct audio_device *dev, +const char *path) +{ +struct headset *hs = dev->headset; + +DBG ("MediaTransport path: %s" , path); + +if (hs->slc ==NULL ) { + hs->connecting_path = path; +return ; + } + +telephony_set_media_transport_path (hs->slc, path); +} +int headset_connect_rfcomm (struct audio_device *dev,GIOChannel *io) {struct headset *hs = dev->headset;
audio/headset.h +2 -0
@@ -107,3 +107,5 @@ void headset_shutdown(struct audio_device *dev);void headset_slc_complete (struct audio_device *dev);void headset_set_connecting_agent (struct audio_device *dev,void *agent);void *headset_get_connecting_agent (struct audio_device *dev); +void headset_set_media_transport_path (struct audio_device *dev, +const char *path);
audio/media.c +8 -1
@@ -440,6 +440,7 @@ static void headset_state_changed(struct audio_device *dev, void *user_data) {struct media_endpoint *endpoint = user_data; +const char *path;DBG ("" );
@@ -455,6 +456,8 @@ static void headset_state_changed(struct audio_device *dev,case HEADSET_STATE_CONNECTING :set_configuration (endpoint, dev,NULL ,0 , headset_setconf_cb, dev,NULL ); + path =media_transport_get_path (endpoint->transport); +headset_set_media_transport_path (dev, path);break ;case HEADSET_STATE_CONNECTED :break ;
@@ -669,14 +672,18 @@ static struct media_endpoint *media_endpoint_create(struct media_adapter *adapte }else if (strcasecmp (uuid,HFP_AG_UUID ) ==0 ||strcasecmp (uuid,HSP_AG_UUID ) ==0 ) {struct audio_device *dev; +const char *t_path; endpoint->hs_watch =headset_add_state_cb (headset_state_changed, endpoint); dev =manager_find_device (NULL , &adapter->src,BDADDR_ANY ,AUDIO_HEADSET_INTERFACE , TRUE); -if (dev) +if (dev) {set_configuration (endpoint, dev,NULL ,0 , headset_setconf_cb, dev,NULL ); + t_path =media_transport_get_path (endpoint->transport); +headset_set_media_transport_path (dev, t_path); + } }else if (strcasecmp (uuid,HFP_HS_UUID ) ==0 ||strcasecmp (uuid,HSP_HS_UUID ) ==0 ) {struct audio_device *dev;
audio/telephony.c +12 -0
@@ -65,6 +65,7 @@ struct tel_device {struct tel_agent *agent;struct audio_device *au_dev;GIOChannel *rfcomm; +const char *transport_path;uint16_t version;uint16_t features; };
@@ -220,6 +221,10 @@ static gboolean agent_sendfd(struct tel_device *dev, int fd,dict_append_entry (&dict,"Features" ,DBUS_TYPE_UINT16 , &dev->features); +if (dev->transport_path !=NULL ) +dict_append_entry (&dict,"MediaTransportPath" ,DBUS_TYPE_STRING , + &dev->transport_path); +dbus_message_iter_close_container (&iter, &dict);if (dbus_connection_send_with_reply (connection, msg, &call,-1 ) == FALSE)
@@ -362,6 +367,13 @@ void telephony_device_disconnected(void *telephony_device)DBG ("telephony-dbus: device %p disconnected" , telephony_device); } +void telephony_set_media_transport_path (void *slc,const char *path) +{ +struct tel_device *dev = slc; + + dev->transport_path = path; +} +gboolean telephony_get_ready_state (void ) {return find_agent (NULL ,NULL ,HFP_AG_UUID ) ? TRUE : FALSE;
audio/telephony.h +1 -0
@@ -52,6 +52,7 @@ void *telephony_device_connecting(GIOChannel *io, void *telephony_device);void telephony_device_connected (void *telephony_device);void telephony_device_disconnect (void *slc);void telephony_device_disconnected (void *telephony_device); +void telephony_set_media_transport_path (void *slc,const char *path);gboolean telephony_get_ready_state (void );uint32_t telephony_get_ag_features (void );
Signature · 1 line
1.7.1