4

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:

  1. Send real time voice data from PC's microphone to android device via bluetooth
  2. 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?

Community
  • 1
  • 1
IKM2007
  • 686
  • 8
  • 26

1 Answers1

2

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

Community
  • 1
  • 1
Halim Qarroum
  • 13,329
  • 4
  • 43
  • 66
  • Thanks a lot! As I understand, I can't implement case 1 by ANY built-in Bluetooth profile? And how can I implement my own protocol for audio streaming? Can you give any advice? – IKM2007 Apr 04 '13 at 21:46
  • Using Bluetooth for audio streaming on Android is possible but is kind of laggy due to some implementation bugs corrected in Android 4.2.2. Also it may be painful. Why wouldn't you go using Wifi and regular sockets ? – Halim Qarroum Apr 04 '13 at 21:55
  • I have a little more than a month to prepare the next project for university. The phone connects to the computer(I make connection over bluetooth). By app on PC's side user can send/receive sms messages, make phone calls and answer to them. For a week I implemented part for making / sending sms messages over RFCOMM protocol. I don't know is it doable to realize the project under wifi for a month. I also don't know is my phone(galaxy young, Android version 2.3.6) suitable for this purpose? And what equipment is needed for computer parts? – IKM2007 Apr 04 '13 at 22:29
  • If your phone has Wifi, it definitely is doable. Here is an example of to implement a TCP server in Android (see Server Side Application) : http://lakjeewa.blogspot.fr/2012/03/simple-client-server-application-for.html. The client will be developped on Windows I guess, using the Qt library on Windows might be a good choice. – Halim Qarroum Apr 04 '13 at 22:36
  • Yes my phone has wifi and Qt is much better for me than Java. Thank you very much!!! – IKM2007 Apr 05 '13 at 07:28
  • One more question please. What about Hands free profile(SCO)? Can I implement calls with it? – IKM2007 Apr 10 '13 at 07:12
  • Look at this SO response, you might be interested : http://stackoverflow.com/questions/6183894/does-android-support-hfp-bluetooth-profile. So yes, you can stream to another HFP device, but probably not from a HFP device to Android. – Halim Qarroum Apr 10 '13 at 08:32
  • I mean use PC as HFP device(if it is possible) and instantiate connection over HFP between PC and Android phone. – IKM2007 Apr 10 '13 at 11:18
  • 1
    I said above, yes you could use your PC as an HFP sink (receives sound) and your Android phone as a HFP source (streams sound to your PC). – Halim Qarroum Apr 10 '13 at 12:48
  • 1
    Not a feature I'm aware of, no. The purpose of Bluetooth capabilities in phone or a tablet is mainly to stream audio to a headset or to an external speaker, it has no sense to stream audio from a source to the speakers of a phone, thus the lack of this feature on Android. – Halim Qarroum Apr 10 '13 at 13:39