需要对发送/ receiveing​​音频间以上的Andr​​oid /非Android设备支持A2DP的想法 [英] need idea on sending/receiveing audio over A2DP between android/non-android device

查看:548
本文介绍了需要对发送/ receiveing​​音频间以上的Andr​​oid /非Android设备支持A2DP的想法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够发送和接收音频通过蓝牙,它似乎A2DP是做这个事情。

I need to be able to send and receive audio over bluetooth and it seems A2DP is the thing that does this

使用code给出 href=\"http://stackoverflow.com/a/18397935/1693203\">,我设法让我的手机检测并与远程蓝牙配对设备,然后确定哪些通过蓝牙发送的Andr​​oid设备的所有音频输出到远程之一的A2DP连接

Using the code given here, I managed to get my phone to detect and pair with the remote bluetooth device, then establish an A2DP connection which sent all the audio output of the android device to the remote one via bluetooth

我是previously能够通过RFCOMM做这样的双向数据通信使用相同的远程蓝牙设备(是一个发起通信尽管所需的Andr​​oid手机,我不能这样做,通过虽然我的远程设备知道这是可能的)。一旦RFCOMM连接成立后,Android设备可以将数据发送到远程设备,以及从它接收数据

I was previously able to do such two way data communication with the same remote bluetooth device via RFCOMM (the android phone needed to be the one initiating the communication though, I could not do it through the remote device though I know it is possible). Once the RFCOMM link was established, the android device could send data to the remote device, as well as receive data from it

我现在需要的是类似的东西,但对于音频(preferrably使用A2DP,但我愿意用任何其他的,只要它能够完成任务)。虽然周围窥探所以我得到了暗示,对手机接收音频数据(至少一个无根正常的,生根不适合我的一个选项)通过A2DP是不可能的(参见例如,<一个HREF =htt​​p://stackoverflow.com/a/15559902/1693203>这里)。但我也看到,允许通过蓝牙打电话全部(当然,实际上无线,我假设它必须是蓝牙)耳机。例如,对于来电,只需preSS蓝牙耳机一个按钮,你可以谈,以及听对方。如果电话不能被用作音频接收器,怎么办这样的耳机呢?

What I need now is something similar, but for audio (preferrably using A2DP, but I am open to using whatever else, as long as it gets the job done). While snooping around SO I've got hints that receiving audio data on phone (at least an unrooted normal one, rooting is not an option for me) via A2DP is not possible (see for example, here). But I have also seen headsets that allow making phone calls entirely through bluetooth (well, wirelessly actually, I am assuming it must be bluetooth). For example, for an incoming call, you can just press a button on the bluetooth earpiece, then you can talk as well as listen to the other party. If a phone cannot be used as an audio sink, how do such headsets do it?

我需要我应该怎么去写一个Android应用程序发送以及通过蓝牙接收音频数据的一些想法(为简单起见,您认为它类似的 Bluechat示例程序,但涉及音频,而不是文本)。是否有可能在所有的(通过Java)?是否有可能只能通过NDK?如何在市场上的设备呢?它比A2DP不同的配置文件?

I need some ideas on how I should go about writing an android app to send as well as receive audio data via bluetooth (for simplicity lets consider it similar to the Bluechat sample program, but involving audio instead of text). Is it possible at all (through java)? Is it possible only through NDK? How do the devices on the market do it? Is it a different profile than A2DP?

PS:我的测试设备是三星Galaxy 2(电话)姜饼和华硕的Nexus 7(平板电脑)与奇巧。顺便远程蓝牙设备(它是一个开发板)自带是应该转板到A2DP的音频源的示例项目。如果我在黑板上运行此示例项目,使用电话的和平板电脑的内置蓝牙设置,我可以排序对用遥控板,但Android设备没有收到任何音讯。

PS: My test devices are Samsung Galaxy 2 (phone) with Gingerbread and Asus Nexus 7 (tablet) with KitKat. Incidentally the remote bluetooth device (it is a development board) comes with a sample project that is supposed to turn the board into an A2DP audio source. if I run this sample project on the board, using the phone's and tablet's built-in bluetooth settings, I can sort of pair with the remote board, but the android devices do not receive any audio.

推荐答案

有两种不同的A2DP模式, A2DP源 A2DP汇。在 A2DP源配置文件Android支持从而允许您从您的设备播放音乐像一个蓝牙音箱水槽。据我所知, A2DP汇配置文件未启用,这就是为什么您无法传送音乐到您的手机,并把它作为一个扬声器。我只在绕过前段时间Google搜索这样的事情可能会改变知道这一点。

There are two different A2DP profiles, A2DP source and A2DP sink. The A2DP source profile is supported by Android thus allowing you to stream music from your device to a sink like a bluetooth speaker. To my knowledge the A2DP sink profile is not enabled, which is why you're unable to stream music to your mobile phone and have it act as a speaker. I only know this from having googled around some time ago so things may have changed.

可以通过编辑启用 A2DP汇简介 /etc/bluetooth/audio.conf 并重新启动您的手机。不幸的是这具有禁用 A2DP源轮廓的副作用,因此不能在一个广泛分布的应用中使用。另一个缺点是,没有太多与该配置文件的工作是一个Java软件栈,所以你必须做相当多的工作中,把事情滚动。

It is possible to enable the A2DP sink profile by editing /etc/bluetooth/audio.conf and rebooting your phone. Unfortunately this has the side-effect of disabling the A2DP source profile and thus cannot be used in a widely distributed app. The other downside is that there is not much of a java software stack for working with that profile so you'd have to do quite a bit of work to get things rolling.

要回答你的问题,为什么一个耳机可以连接到Android,那是因为耳机使用名为耳机协议(HSP)不同的配置文件,常用通过耳机,或免提模式(HFP)常用的车。这两个配置文件有两个方面:一个客户端和网关端(手机)。这两个型材的音频质量被认为是语音质量。 8或16kHz的采样率和一个蹩脚的codeC。还有很多协议接听/拨打电话,等...我不知道,如果你甚至会得到的音频传输,不会对电话网络的有效连接。

To answer your question as to why a headset is able to connect to the Android, that is because headsets use a different profile called Headset profile (HSP), commonly used by headsets, or Handsfree profile (HFP) commonly used in cars. Both profiles have two sides: a client side and the gateway side (mobile phone). The audio quality of both of these profiles is considered voice quality. 8 or 16kHz sample rates and a crappy codec. There is also a lot of protocol for answering/making calls, etc... I'm not sure if you'd even get audio to transmit without an active connection to the phone network.

这篇关于需要对发送/ receiveing​​音频间以上的Andr​​oid /非Android设备支持A2DP的想法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆