All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC v4 6/6] audio: Send transport path to telephony agent
Date: Mon, 12 Dec 2011 11:49:14 +0100	[thread overview]
Message-ID: <1323686954-11899-7-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1323686954-11899-1-git-send-email-frederic.danis@linux.intel.com>

---
 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(-)

diff --git a/audio/headset.c b/audio/headset.c
index d248643..fef80a6 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -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);
 }
@@ -1250,6 +1254,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;
diff --git a/audio/headset.h b/audio/headset.h
index d74a69c..7eac876 100644
--- a/audio/headset.h
+++ b/audio/headset.h
@@ -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);
diff --git a/audio/media.c b/audio/media.c
index a2ef437..43ffcc2 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -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;
diff --git a/audio/telephony.c b/audio/telephony.c
index 593d56a..fd384b3 100644
--- a/audio/telephony.c
+++ b/audio/telephony.c
@@ -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;
 };
@@ -217,6 +218,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)
@@ -359,6 +364,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;
diff --git a/audio/telephony.h b/audio/telephony.h
index d5d9f65..24afd28 100644
--- a/audio/telephony.h
+++ b/audio/telephony.h
@@ -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);
-- 
1.7.1


  parent reply	other threads:[~2011-12-12 10:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-12 10:49 [RFC v4 0/6] Add org.bluez.Telephony interface Frédéric Danis
2011-12-12 10:49 ` [RFC v4 1/6] audio: Move tel drivers to DBus interface Frédéric Danis
2011-12-12 10:49 ` [RFC v4 2/6] audio: Remove tel drivers Frédéric Danis
2011-12-12 10:49 ` [RFC v4 3/6] audio: Remove maemo5 tel driver Frédéric Danis
2011-12-12 10:49 ` [RFC v4 4/6] audio: Remove maemo6 " Frédéric Danis
2011-12-12 10:49 ` [RFC v4 5/6] audio: Move HFP/HSP AG servers to telephony.c Frédéric Danis
2011-12-12 10:49 ` Frédéric Danis [this message]
2011-12-12 11:03 ` [RFC v4 0/6] Add org.bluez.Telephony interface Johan Hedberg
2011-12-12 21:24   ` Dmitriy Paliy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1323686954-11899-7-git-send-email-frederic.danis@linux.intel.com \
    --to=frederic.danis@linux.intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.