【问题标题】:How to change Bluetooth codec, programmatically?如何以编程方式更改蓝牙编解码器?
【发布时间】:2022-11-17 13:34:08
【问题描述】:

我们可以选择更改配对设备的当前蓝牙编解码器开发者设置, 如下所示。

是否有任何解决方法可以通过更改系统设置来以编程方式更改此设置?

【问题讨论】:

    标签: android bluetooth settings codec


    【解决方案1】:

    不是作为应用程序开发人员,因为编解码器协商是蓝牙堆栈的一部分。但是,如果您可以更改蓝牙堆栈源,则有可能。在 appuals 上有一篇很好的文章介绍如何做到这一点: How to Modify Bluetooth Stacks on Android for Greatly Enhanced Bluetooth Audio Quality

    【讨论】:

    • 我的问题不是关于更改 Android 上的蓝牙堆栈,而是更改配对耳机使用的编解码器。我可以使用开发人员设置中的 UI 更改它。那么,有什么办法可以改变它吗?AAC -> 单板机,以编程方式?
    【解决方案2】:

    不幸的是,API 的标准实现不允许这样做。

    但是没有人阻止我们扩展标准 API。 扩展API可以获取HERE

    接下来,我们得到蓝牙A2dp上课并选择新方法:getCodecStatus、getCodecConfig、getCodecType

    我们收集BluetoothCodecConfig并申请setCodecConfigPreference(设备,新配置)

    例子: 对象:服务监听器

                a2dp = proxy as BluetoothA2dp
                val device: BluetoothDevice = a2dp.activeDevice
                val status: BluetoothCodecStatus = a2dp.getCodecStatus(device)
                val config = status.codecConfig
                val codec = config.codecType
                val newConfig = BluetoothCodecConfig(0, 1000 * 1000, SAMPLE_RATE_44100, BITS_PER_SAMPLE_16, CHANNEL_MODE_STEREO, 32771, 49152, 0, 0)
                a2dp.setCodecConfigPreference(device, newConfig)
                val updatedStatus: BluetoothCodecStatus = a2dp.getCodecStatus(device)
                val updatedConfig = updatedStatus.codecConfig
    

    【讨论】:

      猜你喜欢
      • 2023-03-14
      • 1970-01-01
      • 2019-09-12
      • 1970-01-01
      • 2017-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多