Android BlueZ 与 Bluedroid 蓝牙堆栈

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20407326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 02:49:10  来源:igfitidea点击:

BlueZ vs Bluedroid bluetooth stack

androidbluetoothandroid-bluetoothblueza2dp

提问by Nidhin Joseph

BlueZ have a lot of documentations and all. And from the same, i understood BlueZ supports A2DP sink support. And at the same time an android device can be made act as an A2DP sink by modifying the audio.conf file inside the same.

BlueZ 有很多文档等等。同样,我理解 BlueZ 支持 A2DP 接收器支持。同时,通过修改其中的 audio.conf 文件,可以使 android 设备充当 A2DP 接收器。

I also came to know that from android 4.2 onwards, the BlueZ stack was replaced by Broadcom's Bluedroid stack. I searched a lot about Bluedroid stack. But i was not able to find much details about the same.

我还了解到,从 android 4.2 开始,BlueZ 堆栈被 Broadcom 的 Bluedroid 堆栈取代。我搜索了很多关于 Bluedroid 堆栈的信息。但我无法找到更多关于相同的细节。

Hope someone can help me with the following doubts.

希望有人可以帮助我解决以下疑问。

1). Whether Bluedroid have A2DP sink support?

1)。Bluedroid 是否有 A2DP sink 支持?

2). Whether the audio.conf file will be available for devices having bluedroid stack?

2)。audio.conf 文件是否可用于具有 bluedroid 堆栈的设备?

3). I am going to write an A2DP sink support for an android device by directly calling API's of BlueZ stack. But my final question is whether the same can be used with Bluedroid stack also? Hope Bluedroid is just an expansion of BlueZ.

3)。我将通过直接调用 BlueZ 堆栈的 API 来为 Android 设备编写 A2DP 接收器支持。但我的最后一个问题是 Bluedroid 堆栈是否也可以使用相同的功能?希望 Bluedroid 只是 BlueZ 的扩展。

Please help.

请帮忙。

采纳答案by ashish

Bluedroid is a stack provided by Broadcom and is now opensource in android . Bluedroid is not related with bluez in any respect, it has few advantages over bluez(i differ to that).

Bluedroid 是 Broadcom 提供的堆栈,现在在 android 中开源。Bluedroid 在任何方面都与 bluez 无关,它比 bluez 几乎没有优势(我与此不同)。

[1]. Bluedroid does not have a2dp sink support as of now, as per code available source codeonly a2dp source support is available

[1]。Bluedroid 目前不支持 a2dp 接收器,根据可用的代码源代码,只有 a2dp 源支持可用

[2]. Audio.conf file is for bluez stack, it is not a part of bluedroid

[2]。Audio.conf 文件用于 bluez 堆栈,它不是 bluedroid 的一部分

[3]. Directly calling Bluez API-- i think you will use dbus calls but bluedroid does not support dbus method calls, it has a callback mechanism implemented, so it will not work, bluedroid is not an expansion of bluez.

[3]。直接调用Bluez API——我想你会使用dbus调用但是bluedroid不支持dbus方法调用,它实现了回调机制,所以它不起作用,bluedroid不是bluez的扩展。

回答by theangrylama

A2DP Sink role is now supported in Android Lollipop (5.0). They have modified the Bluedroid source code to support the same. To completely support it , you need to modify the audio HAL (audio.h), AudioPolicyManagerBase.cpp and audio_policy.conf and Also Audio Manager, A2DPStateMachine etc.

Android Lollipop (5.0) 现在支持 A2DP Sink 角色。他们修改了 Bluedroid 源代码以支持相同的功能。要完全支持它,您需要修改音频 HAL (audio.h)、AudioPolicyManagerBase.cpp 和 audio_policy.conf 以及 Audio Manager、A2DPStateMachine 等。

回答by Boatman_Yang

As user987500 said, A2DP sink is supported in android L,only make minor modification, you device can changed from A2DP src to sink. But be sure only one role can be supported for one device, which can be configured from xml file.

正如user987500所说,android L支持A2DP sink,只需稍作修改,您的设备就可以从A2DP src更改为sink。但请确保一台设备只能支持一个角色,可以从 xml 文件配置。

回答by aksonlyaks

Adding to the above answers, since Android L, sink support is introduced but still Audio streaming portion of code is not completed. However, I have found thischange list where a2dp sink implementation is completed and media can be played through sink device as mentioned in the commit message of the change list:

添加到上述答案中,自 Android L 以来,引入了接收器支持,但代码的音频流部分仍未完成。但是,我发现了这个更改列表,其中 a2dp 接收器实现完成并且媒体可以通过接收器设备播放,如更改列表的提交消息中所述:

Bluetooth A2DP Sink

The change implements the A2DP sink feature. If the android device is a sink role, it can receive music from phone via BT. This feature can be apply in multimedia car kit, set-top box and family HiFi. Set BLUETOOTH_A2DP_SINK := true in BoardConfig.mk to enable A2DP Sink featue in bluedroid.

You also need the changes below in framework to route music to speaker. https://android-review.googlesource.com/#/c/97832/https://android-review.googlesource.com/#/c/97853/https://android-review.googlesource.com/#/c/97833/https://android-review.googlesource.com/#/c/98130/https://android-review.googlesource.com/#/c/98131/

This change does not include SBC decoder. You can get a SBC decoder from github.com/tieto/sbc-decoder.

蓝牙 A2DP 接收器

此更改实现了 A2DP 接收器功能。如果安卓设备是接收器角色,它可以通过BT从手机接收音乐。此功能可应用于多媒体车载套件、机顶盒和家庭 HiFi。在 BoardConfig.mk 中设置 BLUETOOTH_A2DP_SINK := true 以启用 bluedroid 中的 A2DP Sink 功能。

您还需要在框架中进行以下更改以将音乐路由到扬声器。https://android-review.googlesource.com/#/c/97832/ https://android-review.googlesource.com/#/c/97853/ https://android-review.googlesource.com/#/ c/97833/ https://android-review.googlesource.com/#/c/98130/ https://android-review.googlesource.com/#/c/98131/

此更改不包括 SBC 解码器。您可以从 github.com/tieto/sbc-decoder 获得 SBC 解码器。

All the best!!!

祝一切顺利!!!