[pulseaudio-discuss] [PATCH 0/2] Bluetooth A2DP Source module

Zheng, Huan huan.zheng at intel.com
Sun Aug 16 18:36:48 PDT 2009


Hi, Lennart
I think it will be good if PA could have sink/source direct connection.

>One question though: what about support for HSP/HFP? Would it even
>make sense to make PA behave like a headset to other devices?
On some platforms, such as a vehicle platform which has a Pulseaudio inside, it may want to behave like a headset. It wants to capture from BT HSP source (data coming from a real phone) and play it to its local speaker (ALSA sink), and capture from ALSA source and play it to BT HSP sink (data goes to a real phone).

To achieve the above goal, direct sink/source connection is needed, and PA's ability to auto detect a phone of capability "audio gateway" may also needed. 

I actually tried to use PA as a headset role with a NOKIA phone before, 
I wanted to make the below happen, but there's no direct sink/source connection, 
Far end voice --> Phone HSP --> PA HSP SRC --> PA ALSA SINK
PA ALSA SRC --> PA HSP SINK --> Phone HSP --> Far end
So, what I actually achieved is:
Far end voice --> Phone HSP --> PA HSP SRC --> Local file
Local playback --> PA HSP SINK --> Phone HSP --> Far end
And the above audio path works.
Conclusion is: Without direct sink/source connection, we may need a daemon which to do a fake sink/source connection. But if direct sink/source connection is implemented inside PA, it will be very useful. :)

Below is some code that I used for above, they are quick workarounds, but may give you a better idea about what people want in such scenario. :)

diff -r -u pulseaudio-0.9.15-origin/src/modules/bluetooth/bluetooth-util.c pulseaudio-0.9.15/src/modules/bluetooth/bluetooth-util.c
--- pulseaudio-0.9.15-origin/src/modules/bluetooth/bluetooth-util.c	2009-06-26 10:48:35.000000000 +0800
+++ pulseaudio-0.9.15/src/modules/bluetooth/bluetooth-util.c	2009-06-26 10:49:10.000000000 +0800
@@ -536,7 +536,31 @@
             dbus_message_get_path(m),
             dbus_message_get_member(m));
 
-    if (dbus_message_is_signal(m, "org.bluez.Adapter", "DeviceRemoved")) {
+    if (dbus_message_get_member(m) && !strcmp(dbus_message_get_member(m),"CallStarted")) {
+        pa_log_error("CallStarted");
+        pa_bluetooth_device *d;
+
+        if ((d = pa_hashmap_get(y->devices, dbus_message_get_path(m)))) {
+            if (dbus_message_has_interface(m, "org.bluez.HeadsetGateway")) {
+                pa_log_error("HeadsetGateway CallStarted detected\n");
+            }
+            d->audio_state = PA_BT_AUDIO_STATE_CONNECTED;
+            run_callback(y, d, FALSE);
+        }
+    }
+    else if (dbus_message_get_member(m) && !strcmp(dbus_message_get_member(m),"CallEnded")) {
+        pa_log_error("CallEnded");
+        pa_bluetooth_device *d;
+
+        if ((d = pa_hashmap_get(y->devices, dbus_message_get_path(m)))) {
+            if (dbus_message_has_interface(m, "org.bluez.HeadsetGateway")) {
+                pa_log_error("HeadsetGateway CallEnded detected\n");
+            }
+            d->audio_state = PA_BT_AUDIO_STATE_DISCONNECTED;
+            run_callback(y, d, TRUE);
+        }
+    }
+    else if (dbus_message_is_signal(m, "org.bluez.Adapter", "DeviceRemoved")) {
         const char *path;
         pa_bluetooth_device *d;
 
@@ -705,7 +729,9 @@
                 "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
                 "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
-                "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'", NULL) < 0) {
+                "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
+                "type='signal',sender='org.bluez',interface='org.bluez.HeadsetGateway',member='CallStarted'",
+                "type='signal',sender='org.bluez',interface='org.bluez.HeadsetGateway',member='CallEnded'",NULL) < 0) {
         pa_log("Failed to add D-Bus matches: %s", err.message);
         goto fail;
     }
@@ -762,7 +788,9 @@
                                "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
                                "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
-                               "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'", NULL);
+                               "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'", 
+                               "type='signal',sender='org.bluez',interface='org.bluez.HeadsetGateway',member='CallStarted'", 
+                               "type='signal',sender='org.bluez',interface='org.bluez.HeadsetGateway',member='CallEnded'", NULL);
 
         dbus_connection_remove_filter(pa_dbus_connection_get(y->connection), filter_cb, y);
 
diff -r -u pulseaudio-0.9.15-origin/src/modules/bluetooth/module-bluetooth-device.c pulseaudio-0.9.15/src/modules/bluetooth/module-bluetooth-device.c
--- pulseaudio-0.9.15-origin/src/modules/bluetooth/module-bluetooth-device.c	2009-06-26 10:48:35.000000000 +0800
+++ pulseaudio-0.9.15/src/modules/bluetooth/module-bluetooth-device.c	2009-06-26 10:50:11.000000000 +0800
@@ -641,6 +641,9 @@
     msg.open_req.h.type = BT_REQUEST;
     msg.open_req.h.name = BT_OPEN;
     msg.open_req.h.length = sizeof(msg.open_req);
+    
+    pa_assert(u->address);
+    pa_strlcpy(msg.open_req.destination, u->address, sizeof(msg.open_req.destination));
 
     pa_strlcpy(msg.open_req.object, u->path, sizeof(msg.open_req.object));
     msg.open_req.seid = u->profile == PROFILE_A2DP ? u->a2dp.sbc_capabilities.capability.seid : BT_A2DP_SEID_RANGE + 1;
@@ -1982,7 +1985,12 @@
     }
 
     if (pa_bluetooth_uuid_has(device->uuids, HSP_HS_UUID) ||
-        pa_bluetooth_uuid_has(device->uuids, HFP_HS_UUID)) {
+        pa_bluetooth_uuid_has(device->uuids, HFP_HS_UUID) || 
+        /////////////////////////////////////////////////
+        pa_bluetooth_uuid_has(device->uuids, HSP_AG_UUID) ||
+        pa_bluetooth_uuid_has(device->uuids, HFP_AG_UUID)) {
+        ////////////////////////////////////////////////////
+        pa_log_error("Got HSP_HS_UUID, HFP_HS_UUID\n");
         p = pa_card_profile_new("hsp", _("Telephony Duplex (HSP/HFP)"), sizeof(enum profile));
         p->priority = 20;
         p->n_sinks = 1; 

Best Regards, Zheng, Huan(ZBT)

OTC/SSD/SSG

Intel Asia-Pacific Research & Developement Ltd

Tel: 021-6116 6435

Inet: 8821 6435

Cub: 3W035

-----Original Message-----
From: pulseaudio-discuss-bounces at mail.0pointer.de [mailto:pulseaudio-discuss-bounces at mail.0pointer.de] On Behalf Of Lennart Poettering
Sent: 2009年8月16日 21:36
To: pulseaudio-discuss at mail.0pointer.de
Subject: Re: [pulseaudio-discuss] [PATCH 0/2] Bluetooth A2DP Source module

On Sun, 16.08.09 02:16, João Paulo Rechi Vita (jprvita at gmail.com) wrote:

> This serie of patches adds A2DP Source support on PulseAudio. Please Lennart
> and Luiz have a look and tell me what you think. I'm currently discarding any
> information coming on the RTP header. I'll probably work on this soon, but first
> I want to solve an issue on BlueZ side with Android playing the Source role,
> since now I have an Android phone. :)

Looks pretty good.

You exposed this as a source. Which makes a lot of sense I
guess. However, there is one little problem: we don't allow direct
connections between sinks and sources right now, which limtis the
usefulness of the a2dp source, because you cannot really use PA as a
set of a2dp speakers like this... But I guess this should really
convince me to get of my ass and actually implement the necessary code
for allowing direct sink/source connections.

One question though: what about support for HSP/HFP? Would it even
make sense to make PA behave like a headset to other devices?

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4
_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss at mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


More information about the pulseaudio-discuss mailing list