Basically, what I am trying to do right now is use an android device as an A2DP receiver and when pairing established, android plays sound that is received from a transmitter. I am worrying that if I use STP profile, it may cause delay of streaming. So, I want to use A2DP but is this possible to use an android device as a receiver of A2DP? and how to do it?
In Android 8.0, devices that use the Advanced Audio Distribution Profile (A2DP) can support additional audio codecs. The Bluetooth stack supports audio codec negotiation for when devices connect to a remote audio sink.
Android only supports Bluetooth A2dp devices when connected by a single API method. Any API methods are protected with the appropriate permission from its developer.
Since Android L the BlueDriod stack does support A2DP sink, but it is disabled by default.
To enable it do the following:
/* Enable bluetooth av sink. */
#define BTA_AV_SINK_INCLUDED TRUE
in /external/bluetooth/bluedroid/include/bt_target.h. This enables sink support in the bluetooth stack.
Also you have to do this change:
<!-- Enable sink support. -->
<bool name="profile_supported_a2dp_sink">true</bool>
in /packages/apps/Bluetooth/res/values/config.xml. This enables the particular UI.
Now you can pair your devices and start streaming. Unfortunately you will hear no sound although you'll receive the packets. The reason is that there is no audio route for A2DP sink. In the commit message of this patch https://android-review.googlesource.com/#/c/98161/ you can find a sample implementation on how to fix this.
Here is a list of these changes:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With