-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A2DP Source stream audio to two Sink device (IDFGH-253) #2060
Comments
Hi @rob-bits, I am also interested in this topic. Thanks for the white paper reference. Will be following this conversation. |
This is my current error log. It can be seen it get stuck at the av "scb not available for avdt connection" part. But before this error message there is an another "BT_OSI: alarm_set failed to start timer, err 0x103", I do not know how much is that relating to this topic. @yoelrc88, have you had any history activity in this topic? |
Hi @rob-bits im also interested in working on this. Currently studying the A2DP standard if i find anything i will contact you |
Hi @panafana Thank you very much for your comment. Well I spent +20 hours to work out a proof-of-concept example with esp-idf for this application. But I gained no success. I could not connect two device in the same time and so I cannot test the multiple streaming. The thing is the the bluedroid stack is more complicated as I can undenstand it and follow all of its layers. The current stack does not support any multi connection for the AVDTP or handling more SEPs as the application requires. So it requires too much work. And I did not get any support from the dev team so it is a dead end for me. BUT, I found the btstack from Bluekitchen which is compatible with the ESP32. It is more transparent for me and more low level what I like. It already supports the multi connection. And I have already reach more success. I can connect two BT speaker to the ESP32 and I can stream music, seperatly for both of them. With a software switch I can immediatly change the sink device. Now I have some issues when I am trying to stream to both of the devices, but I think I am not too far from the final goal. And the dev team of bluekitchen is very helpful. Anyway here is my open issue at the btstack repository: If you made any success in this topic feel free to share it. And I accept and acknowledge any help or suggestion in this topic. Cheers, Rob |
@rob-bits could you maybe share some code of your project so i can get up to speed faster? |
@panafana Which one would you like to have? The ESP-IDF or the btstack related code? |
@rob-bits the btstack but is it java for android or is it in C? |
@panafana It is in c. I am on it. If I uploaded the code I will update this comment. UPDATE: https://github.com/rob-bits/btstack-master/tree/test_branch/port/esp32/example/my_a2dp_source It is really a proof-of-concept code. It is not prepared to shared with anyone so there can be some debug related informations what are useful for me but maybe it is nosense for others.. So use it as it is. I am open to any discussion about this topic. It is tested on the ESP32. In the code you have to modify the following two lines:
In here you have to write the addresses of the BT audio speakers. Currently the automatic serach and identification by its name is not implemented. And for the proo-of-concept it is not needed. So you will need your devices bd addresses. There are two "switches" in the application. One is the idx_handler.config the other is the idx_handler.stream. The first one is used during the initialization of the connection of a BT speaker. When its value is 0 then it handling the first device connection, when its value is 1 then it is handling the 2nd device. Currently it can be changed manually from terminal with the '0' and '1' charachters. If you want to test the pllication please follow the following scenario: When the esp32 powered on and it is in idle then, and terminal is opened: Thats all. I hope you can test it as I. Rob |
@rob-bits Awesome man! |
@panafana Okay. If you reach any success keep me updated then :) |
Hello, how do you implement the connection to the Bluetooth headset? I use ESP32 to connect to the Bluetooth headset and always stuck in "esp_a2d_source_connect". I just modified the official example a2dp_source. But connecting a computer can be, that is, connecting a Bluetooth headset does not work. Sometimes it suddenly crashes and then restarts and suddenly connects. |
Any updates in this? |
This will not be implemented in any Espressif chips, we will develop BLE audio chips to replace this. Chips after ESP32C6 will support BLE audio(BLE5.2). |
Are there any esp32 devices out right now that support BLE audio? If so, will those devices allow me to stream audio to multiple speakers? |
Sorry, the BLE audio chip is not ready, still in R&D stage. |
Next generation chips will support:
Both of which will be taped out in 2024. |
Hello all, @blueMoodBHD @mywang-espressif @igrr @FayeY
I want to add new functionality to the A2DP source capability of the esp-idf. Especially I want to stream audio from ESP32 to two bluetooth speaker.
I want to reach this funtionality with the design guidelines of the bluetooth.org from the study called "WHITE PAPER ON USAGE OF MULTIPLE HEADPHONES":
(https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=110679)
In this study there are use cases how should a source device act if the user wants to connect two sink audio device.
One of the scenario follows the next steps:
---- new device connection----
Would somebody give some idea how to start for the 7-8, and 10th steps? The base application would be the A2DP_source example code.
The study states we need to have two (or more) Stream End Point, SEPs on the SRC device that support the SBC codec.
I have already figured out the SEPs are initialized with the bta_av_api_register() function in the bt/bluedroid/bta/av/bta_av_main.c file. The SEPs are handled in a tBTA_AV_SCB struct with the following code:
tBTA_AV_SEP seps[BTA_AV_MAX_SEPS];
Here it can be seen the BlueDroid stack is already prepared somehow to handle more connection.
As I go through the code in the current esp-idf there are two streams are handled. One seperated stream for the source device and one seperated stream for sink device. And that is why the BTA_AV_MAX_SEPS equals two. I guess...
In the bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c file, the btc_a2dp_source_send_aa_frame() function prepares the audio data/frame what we want to send to the sink device. And it would be good if the created frame would be sended to both of the connected devices in a queue. In that manner all SNK devices will be receiving identical A2DP media packets. But I have no idea where to start in this manner. Maybe the btc_a2dp_source_task_handler() function needs some rework too.
The study mentioned the following:
In the code hwo can I attach the same SBC configuration for both of the device?
Anyway, these are very small slices of the "game" and I know this is not a small rewrite. I just really need some help and advice which functions shall be rewrited.
Any advice are welcomed!
Rob
UPDATE 2018.06.22
I modified the btc_av.c , btc_avrc.c and the main API state handler to handle the multiple connections.
Basically I modified two main things:
In the btc_av.c the following:
And in the btc_avrc.c:
And I modified all of the functions whose are using these variables. But I run into an error when the second device tries to connec: av scb not available for avdt connection
This came from the bta_av_sig_chg() function in the bt/bluedroid/bta/av/bta_av_act.c file:
Any advice what can be the problem?
The text was updated successfully, but these errors were encountered: