【发布时间】:2019-04-10 08:46:23
【问题描述】:
我正在尝试使用 A2DP 将音频从 Raspbian 播放到蓝牙扬声器。
通过查看 bluez 源代码中的 test/simple-endpoint,似乎在不带参数的情况下运行它应该使用 0000110A-0000-1000-8000-00805F9B34FB 的 A2DP_SOURCE_UUID 注册一个端点。但是,当使用bluetoothctl 连接到蓝牙扬声器时,我没有看到任何端点的回调方法被调用(SelectConfiguration/SetConfiguration)。我尝试了两种不同类型的蓝牙扬声器。
如果我改为在“sbcsink”模式下运行simple-endpoint,然后将我的手机连接到它,我确实会看到名为(SelectConfiguration/SetConfiguration)的端点方法。因此,端点似乎适用于 A2DP 接收器 uuid,但不适用于源。
通过遍历 dbus 管理对象,我能够找到与蓝牙扬声器对应的 org.bluez.MediaTransport1:
import dbus
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object('org.bluez', '/'), 'org.freedesktop.DBus.ObjectManager')
for path, ifaces in manager.GetManagedObjects().items():
transport = ifaces.get('org.bluez.MediaTransport1')
if transport is None:
continue
transport_obj = dbus.Interface(bus.get_object('org.bluez', path), 'org.bluez.MediaTransport1')
(fd, read_mtu, write_mtu) = transport_obj.Acquire('w')
taken_fd = fd.take()
print(path, fd, taken_fd, read_mtu, write_mtu)
我可以写入传输的文件描述符taken_fd,但我无法像我想的那样控制音频配置,如果传输是通过org.bluez.MediaEndpoint1 获取的。这似乎有点hacky,我不确定这种传输是否适合我以这种方式访问。我希望通过MediaEndpoint1's SetConfiguration 访问传输。
我在 Rasbian Stretch 上使用 bluez 5.43 观察到了这种行为。我还尝试更新到最新的 bluez 5.50 并看到相同的行为。
使用 bluez 作为音频源的预期方式是什么?
【问题讨论】:
标签: bluetooth raspbian bluez speaker