How the headsed send/receive data to/from audio gateway - android

I have read the HSP bluetooth specification but I don't understand If I can use the headset bluetooth profile to send data (e.g. audio stream) from headset to phone and from phone to headset. If the HSP specification I see that the headset send AT commands to audio gateway, but I don't understand how the data are transferred from audio gateway to phone and from phone to audio gateway.
I want to change data between 2 android devices that have only HSP, HPF and A2DP profiles. It is possible to send/receive data to/from 2 devices with only this bluetooth profiles?

Technically you can transfer data via the audio channel. E.g. a wav file is also some binary data, containing audio Ra data, so why not transfer any other binary?
You just have to bypass the encoder (sbc or similar) what maybe is not so easy. Otherwise your binary data is destroyed.
Moreover, note that you talk from audiogate and smartphone. Usually the smartphone IS the audiogate. E.g. when using smartphone and headset, the smartphone also called audiogate in the Bluetooth spec.
If you try to connect 2 android devices with audio streams, of of these needs to take the headset role.
You could also transfer data using hfp by using AT commands. Might get a bit ugly. By the way, if you can send AT commands, these commands are most likely transferred over rfcomm. So I am wondering why you cannot access it.

Related

BLE audio as microphone input on Android

I am developing a custom hardware (peripheral) device that will communicate with Android smartphones through BLE. This device will have several capabilities, including the transmission of audio through GATT and keypresses through HID.
Is it somehow possible to re-route the BLE audio input to the Android OS if it was the internal device microphone? For instance, so that we could make voice searches using the default Google app, using the microphone on this external device. Can it be done without rooting the device, writing custom drivers or customize the kernel?
I found several similar threads on SO, but none with a specific solution for this issue (e.g., An extensive project: Streaming audio from microphone to Android device)
Thanks in advance!
It can be done. This is how I did it:
Have a service that talks to BLE Remote device and receives audio
Create a Audio HAL that implements an audio input.
Modify Audio Policy manager to use your HAL for Voice-recognition inputs
Send audio data from Service to HAL over any available IPC (I use socket)
Done.
There are other ways too. e.g. you could allow regular pairing but then intercept all audio messages from your device in fluoride and forward them to your, or A2DP HAL etc.

Android bluetooth a2dp and spp in same time is possible? Aka Audio and data in same time

Hello i use bk8000l chip which according with specifications support spp and a2dp in same time. I need to find/build an app that is sendind some spp commands and also voice from phone mic. Is a ptt (push-to-talk). The data is necessary to be received by a pic cpu on serial port to start /stop transmission on transceiver side bi pressing/releasing a button on phone. Audio is obviously for what is needed i think. Please give me some ideas thank you.

Bluetooth : Transferring call from Source to sink?

I have one android phone (Samsung S Duos) that will act as SOURCE and one Audio Development Kit i.e. CSR 8670 which will Act as SINK. I am trying to activate the a2dp profile and than transferring the incoming call of my phone (Samsung S Duos) to the Kit(CSR 8670) but not able to achieve it. Please assist me to overcome this problem.
A2DP uses ACL packets, voice calls (handsfree) uses SCO packets over the air.
The "Call" audio runs over SCO channel, so it is "technically" not possible to route calls to A2DP sink (unless you do some great hacks, which does not conform to the BT spec). Ideally you should use HFP for audio calls.
HCI can transport both ACL and SCO. BT chips often have PCM interface to which SCO data can be routed but usually its not accessible unless you can access the PINs of the chip.
Also, please try to ask some precise questions (with log/code) so that we can really assist you. If you ask some generic questions, it is difficult to answer.

Bluetooth audio streaming between android devices

I made a research on the same topic and found that android devices are a2dp sources and the audio can be streamed only from an a2dp source to an a2dp sink. A2dp sink can be a bluetooth headset or a bluetooth speaker.
But my question is then how the android app named "Bluetooth Music Player" works?
It allows streaming from one mobile to another. So in this case the listening mobile device must act as a sink. How this is possible?
Are they using some other profile instead of a2dp?
Ok, that may be a different profile what they are using. Because the application needs to be installed in the client side also.
But how it becomes possible to stream voice from a bluetooth microphone to an android device?
Please help.
Without knowing details about the mentioned Bluetooth Music Player, it seems to use simple Bluetooth data connection, otherwise you would not need to install a client on playing/sending device.
To stream audio from microphone to another device, you can record it on your sending device and send it to the receiving device. You will need to implement a protocol for that purpose.
OR
You can implement an alternative A2DP sink service. This is, what the sink is: a device with a Bluetooth Protocol Stack with an implementation of A2DP Sink.
Edit:
For the case you detailed by your comments, the sending device should be left as-is, without installing any app. That implicitly means that your solution must make use of out-of-the-box Bluetooth functionality of that Android device.
What you can use here is therefor limited to those profiles that Android typically support, which is HSP, HFP and A2DP. Since you obviously want to stream music, A2DP would be your choice.
On the device supposed to receive the audio stream and do the playback, you have to implement a service providing the A2DP sink as an self implemented BluetoothService opening a BluetoothServerSocket on RFCOMM as described in Android documentation.
You will have to spend much effort implementing this, and I am not sure if you will need a license for this.

Is it possible to send/receive voice from PC to Android device over Bluetooth

I have a PC (where java program is running), Bluetooth dongle (which supports A2DP) and Android device (2.3.6, which also supports A2DP).
I want to:
Send real time voice data from PC's microphone to android device via bluetooth
Send real time voice data from Android device's microphone to PC via bluetooth
I found this question, where Dennis says that "Phones are typically only Source devices (Source of the stream that can stream to sink devices), Sinks are Headsets or Bluetooth speakers.". So it seems it is possible to implement case 2? Or not? And what about case 1, is it impossible to implement?
It is true that Android phone are uniquely A2DP source devices.
Sadly, your first case is impossible to realize if you decide to rely on the A2DP profile for streaming audio, because Android does not implement the required callbacks supposed to be handling BlueZ's advertisings when a remote device wants to stream audio to your phone.
The second use case is possible, given that you have a bluetooth enabled PC and some awesome apps that will decode and route the sound from the Bluetooth stack to the speakers. I managed once to reproduce this use case using PulseAudio and pulseaudio-module-bluetooth on Ubuntu 12.10.
Here is a working example showing how to manage the routing of the sound once a connected BT device begins to stream. Here is another one. They both take place on Linux and I never did this on Windows though.
For the sake of completeness, here is another SO answer written by me, giving details about how to implement A2DP sink capabilities on Android.
EDIT :
Nothing forbids you to implement your own protocol for audio streaming via Bluetooth on an Android device, this will work, but as it will not be a standard, it will never comply with the system built-in Bluetooth profiles (A2DP, HFP ...).

Categories

Resources