2009-11-12 07:50:04

by Zhenhua Zhang

[permalink] [raw]
Subject: [PATCH] oFonoHFP profile to enable audio routing in BlueZ

Hi,

These three patches are created to enable audio routing for Handsfree Profile.
It was created during the voicecall driver implementation in oFono so it does
not use the new hfp-api yet. You can take it as reference only since it will
not be commited into trunk.

Basically, a new profile oFonoHFP was added to create RFCOMM connection
and turn IO into TTY device for oFono. It sends TTY device string to oFono
through D-Bus. Meanwhile, it listens oFono property changes to emit CallStarted
and CallEnded signals. PulseAudio could listen these signals and redirect audio
source/sink to use bluetooth one.

If you are interested at it, you may apply 0001..0003 into BlueZ, oFono and PA
respectively. Last commit SHA-1 is in patch note.

And you need to enable oFonoHFP by modify audio.conf:
Disable=Gateway
Enable=oFonoHFP, Headset

In ofono modem.conf, specify device address like:
[hfp]
Driver=hfp
Address=00:22:A9:8C:AF:34

And power on modem by:
dbus-send --system --print-reply --dest=org.ofono /hfp0
org.ofono.Modem.SetProperty string:Powered variant:boolean:true

The PulseAudio will load module-bluetooth-discover automatically. If not,
please load it manually. This module listens BlueZ signal and load
module-bluetooth-device automatically. Unfortunately, you need to load
module-loopback manually to redirect bluez source/sink to alsa, e.g.:
load-module module-loopback source="bluez_source.XX..XX"
sink="alsa_output.0.analog-stereo"
load-module module-loopback source="alsa_input.0.analog-stereo"
sink="bluez_sink.XX..XX"

Feel free to let me know if any problems. Thanks.

Regards,
Zhenhua


Attachments:
0001-oFonoHFP-Add-oFonoHFP-profile-in-BlueZ.patch (18.97 kB)
0001-oFonoHFP-Add-oFonoHFP-profile-in-BlueZ.patch
0002-oFonoHFP-Add-oFonoHFP-support-in-oFono.patch (10.01 kB)
0002-oFonoHFP-Add-oFonoHFP-support-in-oFono.patch
0003-oFonoHFP-Add-oFonoHFP-patch-in-PulseAudio.patch (7.16 kB)
0003-oFonoHFP-Add-oFonoHFP-patch-in-PulseAudio.patch
Download all attachments

2009-11-13 13:54:03

by Gustavo F. Padovan

[permalink] [raw]
Subject: Re: [PATCH] oFonoHFP profile to enable audio routing in BlueZ

Hi Luiz,

On Fri, Nov 13, 2009 at 11:36 AM, Luiz Augusto von Dentz
<[email protected]> wrote:
> Hi,
>
> 2009/11/12 Zhang, Zhenhua <[email protected]>:
>> Hi,
>>
>> Ops, forgot to add ofono-hfp.c into BlueZ patch. So I add them and
>> resend 0001 patch.
>>
>> [email protected] wrote:
>>> Hi,
>>>
>>> These three patches are created to enable audio routing for Handsfree
>>> Profile. It was created during the voicecall driver implementation in
>>> oFono so it does not use the new hfp-api yet. You can take it
>>> as reference only since it will not be commited into trunk.
>>>
>>> Basically, a new profile oFonoHFP was added to create RFCOMM
>>> connection and turn IO into TTY device for oFono. It sends TTY
>>> device string to oFono through D-Bus. Meanwhile, it listens
>>> oFono property changes to emit CallStarted and CallEnded
>>> signals. PulseAudio could listen these signals and redirect
>>> audio source/sink to use bluetooth one.
>>>
>>> If you are interested at it, you may apply 0001..0003 into
>>> BlueZ, oFono and PA respectively. Last commit SHA-1 is in patch note.
>>>
>>> And you need to enable oFonoHFP by modify audio.conf: ? ? ? ? Disable=Gateway
>>> ? ? ? Enable=oFonoHFP, Headset
>>>
>>> In ofono modem.conf, specify device address like:
>>> ? ? ? [hfp]
>>> ? ? ? Driver=hfp
>>> ? ? ? Address=00:22:A9:8C:AF:34
>>>
>>> And power on modem by:
>>> ? ? ? dbus-send --system --print-reply --dest=org.ofono /hfp0
>>> org.ofono.Modem.SetProperty string:Powered variant:boolean:true
>>>
>>> The PulseAudio will load module-bluetooth-discover
>>> automatically. If not, please load it manually. This module
>>> listens BlueZ signal and load module-bluetooth-device
>>> automatically. Unfortunately, you need to load module-loopback
>>> manually to redirect bluez source/sink to alsa, e.g.:
>>> ? ? ? load-module module-loopback source="bluez_source.XX..XX"
>>> sink="alsa_output.0.analog-stereo"
>>> ? ? ? load-module module-loopback source="alsa_input.0.analog-stereo"
>>> sink="bluez_sink.XX..XX"
>>>
>>> Feel free to let me know if any problems. Thanks.
>
> What happened with the original idea from Denis, I don't think
> oFonoHFP is a good name to start with and it should be a generic
> interface where any telephony agent could register.

Zhenhua did these patches before the new API spec. I'll help Zhenhua
to move this code to the new API.
It's here just for test.

>
>
> --
> Luiz Augusto von Dentz
> Engenheiro de Computa??o
>



--
Gustavo F. Padovan
http://padovan.org

2009-11-13 13:36:15

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] oFonoHFP profile to enable audio routing in BlueZ

Hi,

2009/11/12 Zhang, Zhenhua <[email protected]>:
> Hi,
>
> Ops, forgot to add ofono-hfp.c into BlueZ patch. So I add them and
> resend 0001 patch.
>
> [email protected] wrote:
>> Hi,
>>
>> These three patches are created to enable audio routing for Handsfree
>> Profile. It was created during the voicecall driver implementation in
>> oFono so it does not use the new hfp-api yet. You can take it
>> as reference only since it will not be commited into trunk.
>>
>> Basically, a new profile oFonoHFP was added to create RFCOMM
>> connection and turn IO into TTY device for oFono. It sends TTY
>> device string to oFono through D-Bus. Meanwhile, it listens
>> oFono property changes to emit CallStarted and CallEnded
>> signals. PulseAudio could listen these signals and redirect
>> audio source/sink to use bluetooth one.
>>
>> If you are interested at it, you may apply 0001..0003 into
>> BlueZ, oFono and PA respectively. Last commit SHA-1 is in patch note.
>>
>> And you need to enable oFonoHFP by modify audio.conf: ? ? ? ? Disable=Gateway
>> ? ? ? Enable=oFonoHFP, Headset
>>
>> In ofono modem.conf, specify device address like:
>> ? ? ? [hfp]
>> ? ? ? Driver=hfp
>> ? ? ? Address=00:22:A9:8C:AF:34
>>
>> And power on modem by:
>> ? ? ? dbus-send --system --print-reply --dest=org.ofono /hfp0
>> org.ofono.Modem.SetProperty string:Powered variant:boolean:true
>>
>> The PulseAudio will load module-bluetooth-discover
>> automatically. If not, please load it manually. This module
>> listens BlueZ signal and load module-bluetooth-device
>> automatically. Unfortunately, you need to load module-loopback
>> manually to redirect bluez source/sink to alsa, e.g.:
>> ? ? ? load-module module-loopback source="bluez_source.XX..XX"
>> sink="alsa_output.0.analog-stereo"
>> ? ? ? load-module module-loopback source="alsa_input.0.analog-stereo"
>> sink="bluez_sink.XX..XX"
>>
>> Feel free to let me know if any problems. Thanks.

What happened with the original idea from Denis, I don't think
oFonoHFP is a good name to start with and it should be a generic
interface where any telephony agent could register.


--
Luiz Augusto von Dentz
Engenheiro de Computa??o

2009-11-13 01:01:10

by Zhenhua Zhang

[permalink] [raw]
Subject: RE: [PATCH] oFonoHFP profile to enable audio routing in BlueZ

Hi,

Ops, forgot to add ofono-hfp.c into BlueZ patch. So I add them and
resend 0001 patch.

[email protected] wrote:
> Hi,
>
> These three patches are created to enable audio routing for Handsfree
> Profile. It was created during the voicecall driver implementation in
> oFono so it does not use the new hfp-api yet. You can take it
> as reference only since it will not be commited into trunk.
>
> Basically, a new profile oFonoHFP was added to create RFCOMM
> connection and turn IO into TTY device for oFono. It sends TTY
> device string to oFono through D-Bus. Meanwhile, it listens
> oFono property changes to emit CallStarted and CallEnded
> signals. PulseAudio could listen these signals and redirect
> audio source/sink to use bluetooth one.
>
> If you are interested at it, you may apply 0001..0003 into
> BlueZ, oFono and PA respectively. Last commit SHA-1 is in patch note.
>
> And you need to enable oFonoHFP by modify audio.conf: Disable=Gateway
> Enable=oFonoHFP, Headset
>
> In ofono modem.conf, specify device address like:
> [hfp]
> Driver=hfp
> Address=00:22:A9:8C:AF:34
>
> And power on modem by:
> dbus-send --system --print-reply --dest=org.ofono /hfp0
> org.ofono.Modem.SetProperty string:Powered variant:boolean:true
>
> The PulseAudio will load module-bluetooth-discover
> automatically. If not, please load it manually. This module
> listens BlueZ signal and load module-bluetooth-device
> automatically. Unfortunately, you need to load module-loopback
> manually to redirect bluez source/sink to alsa, e.g.:
> load-module module-loopback source="bluez_source.XX..XX"
> sink="alsa_output.0.analog-stereo"
> load-module module-loopback source="alsa_input.0.analog-stereo"
> sink="bluez_sink.XX..XX"
>
> Feel free to let me know if any problems. Thanks.
>
> Regards,
> Zhenhua

Regards,
Zhenhua


Attachments:
0001-oFonoHFP-Add-oFonoHFP-profile-in-BlueZ.patch (40.96 kB)
0001-oFonoHFP-Add-oFonoHFP-profile-in-BlueZ.patch

2009-11-12 16:48:31

by Gustavo F. Padovan

[permalink] [raw]
Subject: Re: [PATCH] oFonoHFP profile to enable audio routing in BlueZ

Hi Zhenhua,

2009/11/12 Zhang, Zhenhua <[email protected]>:
> Hi,
>
> These three patches are created to enable audio routing for Handsfree Profile.
> It was created during the voicecall driver implementation in oFono so it does
> not use the new hfp-api yet. You can take it as reference only since it will
> not be commited into trunk.

You forgot to include ofono-hfp.h into the BlueZ patch.

>
> Basically, a new profile oFonoHFP was added to create RFCOMM connection
> and turn IO into TTY device for oFono. It sends TTY device string to oFono
> through D-Bus. Meanwhile, it listens oFono property changes to emit CallStarted
> and CallEnded signals. PulseAudio could listen these signals and redirect audio
> source/sink to use bluetooth one.
>
> If you are interested at it, you may apply 0001..0003 into BlueZ, oFono and PA
> respectively. Last commit SHA-1 is in patch note.
>
> And you need to enable oFonoHFP by modify audio.conf:
> ? ? ? ?Disable=Gateway
> ? ? ? ?Enable=oFonoHFP, Headset
>
> In ofono modem.conf, specify device address like:
> ? ? ? ?[hfp]
> ? ? ? ?Driver=hfp
> ? ? ? ?Address=00:22:A9:8C:AF:34
>
> And power on modem by:
> ? ? ? ?dbus-send --system --print-reply --dest=org.ofono /hfp0
> org.ofono.Modem.SetProperty string:Powered variant:boolean:true
>
> The PulseAudio will load module-bluetooth-discover automatically. If not,
> please load it manually. This module listens BlueZ signal and load
> module-bluetooth-device automatically. Unfortunately, you need to load
> module-loopback manually to redirect bluez source/sink to alsa, e.g.:
> ? ? ? ?load-module module-loopback source="bluez_source.XX..XX"
> sink="alsa_output.0.analog-stereo"
> ? ? ? ?load-module module-loopback source="alsa_input.0.analog-stereo"
> sink="bluez_sink.XX..XX"
>
> Feel free to let me know if any problems. Thanks.
>
> Regards,
> Zhenhua
>
>



--
Gustavo F. Padovan
http://padovan.org