I'm hoping to have an Android broadcast to multiple Bluetooth headsets at once - the idea is to have a radio-like stream that users of an app can tap into. It is important that all users hear the music in sync (that is, the song ends at the same time for everyone).
I have not been able to determine if A2DP will allow streaming to multiple receivers, but I'd be open to other streaming solutions if you have them. Extra points if Android and iOS devices can play with each other!
I dont think streaming to multiple devices over A2DP is currently supported.
According to http://developer.android.com/reference/android/bluetooth/BluetoothA2dp.html in BluetoothA2dp class overview: "Android only supports one connected Bluetooth A2dp device at a time".
I have two Creative WP-380 that have ShareMe function that permit to listen the same stream audio in the same time. I and my wife watch movie with our linux notebook using that couple of headsets.
One is the master, bluetooth connected with the notebook, and the second is the slave, paired with the first.
Works excellent with our android tablets!
It was possible with Windows Mobile 6.5 on a HTC Touch Pro 2 (a bad smartphone because of it´s slow CPU). I used two A2PD Headphones simultaneously.
Related
I am trying to figure out if there is an abilily to program on android a music streaming through Bluetooth connection. However, I want to manage it from one phone device to several phone devices in parallel.
So far, I have managed to create a connection but not streaming.
Streaming is possible from phone to pc speaker. Not sure whether you can run in parallel or not.
This app could do the trick:
Bluetooth Music Player Free
You need to install it on both Android devices and pair them.
Since they are doing it so programatically it is possible.
I need to be able to send and receive audio over bluetooth and it seems A2DP is the thing that does this
Using the code given here, I managed to get my phone to detect and pair with the remote bluetooth device, then establish an A2DP connection which sent all the audio output of the android device to the remote one via bluetooth
I was previously able to do such two way data communication with the same remote bluetooth device via RFCOMM (the android phone needed to be the one initiating the communication though, I could not do it through the remote device though I know it is possible). Once the RFCOMM link was established, the android device could send data to the remote device, as well as receive data from it
What I need now is something similar, but for audio (preferrably using A2DP, but I am open to using whatever else, as long as it gets the job done). While snooping around SO I've got hints that receiving audio data on phone (at least an unrooted normal one, rooting is not an option for me) via A2DP is not possible (see for example, here). But I have also seen headsets that allow making phone calls entirely through bluetooth (well, wirelessly actually, I am assuming it must be bluetooth). For example, for an incoming call, you can just press a button on the bluetooth earpiece, then you can talk as well as listen to the other party. If a phone cannot be used as an audio sink, how do such headsets do it?
I need some ideas on how I should go about writing an android app to send as well as receive audio data via bluetooth (for simplicity lets consider it similar to the Bluechat sample program, but involving audio instead of text). Is it possible at all (through java)? Is it possible only through NDK? How do the devices on the market do it? Is it a different profile than A2DP?
PS: My test devices are Samsung Galaxy 2 (phone) with Gingerbread and Asus Nexus 7 (tablet) with KitKat. Incidentally the remote bluetooth device (it is a development board) comes with a sample project that is supposed to turn the board into an A2DP audio source. if I run this sample project on the board, using the phone's and tablet's built-in bluetooth settings, I can sort of pair with the remote board, but the android devices do not receive any audio.
There are two different A2DP profiles, A2DP source and A2DP sink. The A2DP source profile is supported by Android thus allowing you to stream music from your device to a sink like a bluetooth speaker. To my knowledge the A2DP sink profile is not enabled, which is why you're unable to stream music to your mobile phone and have it act as a speaker. I only know this from having googled around some time ago so things may have changed.
It is possible to enable the A2DP sink profile by editing /etc/bluetooth/audio.conf and rebooting your phone. Unfortunately this has the side-effect of disabling the A2DP source profile and thus cannot be used in a widely distributed app. The other downside is that there is not much of a java software stack for working with that profile so you'd have to do quite a bit of work to get things rolling.
To answer your question as to why a headset is able to connect to the Android, that is because headsets use a different profile called Headset profile (HSP), commonly used by headsets, or Handsfree profile (HFP) commonly used in cars. Both profiles have two sides: a client side and the gateway side (mobile phone). The audio quality of both of these profiles is considered voice quality. 8 or 16kHz sample rates and a crappy codec. There is also a lot of protocol for answering/making calls, etc... I'm not sure if you'd even get audio to transmit without an active connection to the phone network.
For A2DP Sink support -
Yes. It is possible. I have done it in Android JB.
Android device as a receiver for A2DP profile - Please read my reply.
Basically I want to make the tizen smartwatch into a bluetooth headset for a period of time. We have a tizen and an android developer handy and we're willing to build anything necessary to make this work.
This kind of process seems to work with built-in android applications like the standard phone app. But there doesn't seem to be any documentation online as to how an app developer would leverage streaming the mic.
It should be noted that we do need to get the audio into the microphone input on the phone for our third party software to work. It's not as simple as just getting the audio to the phone.
Any help, even someone telling us what isn't possible, will be greatly appreciated.
It is possible to play sound with the HTML audio tag: http://developer.samsung.com/forum/board/thread/view.do?boardName=SDK&messageId=269002&startId=zzzzz~&searchSubId=0000000032&searchType=ALL&searchText=sound
It is possible to capture the sound in a Host Android application
It is possible to exchange data bytes by bluetooth with the accessory SDK: http://developer.samsung.com/samsung-mobile#accessory
The data transfer is quick and efficient, so low quality sound may works with little delay
So it certainly is possible. But you'll have to code (or use compatible javascript and android libraries) all the streaming code which is quite a lot of work
Actually, this begins with following question:
Can I create a virtual Bluetooth headset to manipulate call stream?
I'm sure this can be done by replacing kernel module for Bluetooth with something made-up. So Virtual bluetooth device on Android? sounds like definitely possible.
And, of course, one may simply use Raspberry Pi, which is capable of emulating a headset (at least, A2DP playback only) bluetooth profile, or even one of these Bluegiga modules, to hook a custom virtual headset with Android and let it play sounds into call. (Oh, well, it's enough to just solder headset's mic input into PC's soundcard..)
It seems, that Android (at least, rooted) allows some flexibility with hacking into other applications by some sort of hooks - https://play.google.com/store/apps/details?id=com.trigonesoft.iti; there's an app which from my desktop experience with JVMTI and jaspects, it also seems that Java-based apps can be tricked well. -
So in theory, there is a way to just make the system think that bluetooth connection manager is actually connected to headset, thus force it to use Bluetooth route to play sound into.
But there's no way to actually "play" into phone conversation, of which I know - so questions like Is it possible to create a simple answering machine in android? are in fact 100% unanswered. I guess it's due to the hardware limitations (and with all that energy-saving audio-routing bells&whistles, it seems to be true)
So, the question is: can the Bluetooth device be emulated without having to replace vendor's bluetooth kernel module (for example, on MTK phones its mtk_stp_bt) with custom stub?
(Honestly it sounds like I'm giving out a bluetooth-sdk-in-userspace idea, well, lets state that I do it for CC-BY-NC license
)
When I use Bluetooth on my computer, I have a choice of a few different types of devices to look for. One choice is "headset".
I want to make an application that will connect to another device as though it is nothing but a headset. So the audio and microphone will route from the Android phone to the other device.
Is this possible within the Bluetooth API? If so, is the Bluetooth Chat example the best thing to start with for something like this? Most of the information I can find deals with the opposite situation (using an actual headset with an Android device.)
Most phones are only bluetooth masters, cannot act as devices... I am afraid you are out of luck... Unless what you are doing is on a completely different device and in that case, no, the API will not handle that case.