蓝牙(二)A2DP协议

1.概述

    A2DP(Advanced Audio Distribution Profile)是蓝牙的音频传输协议,典型应用为蓝牙耳机。A2DP协议的音频数据在ACL Link上传输,这与SCO上传输的语音数据要区别。A2DP不包括远程控制的功能,远程控制的功能参考协议AVRCP。AVDTP则定义了蓝牙设备之间数据流句柄的参数协商,建立和传输过程以及相互交换的信令实体形式,该协议是A2DP框架的基础协议。

A2DP在协议栈中的位置如下图所示:

AVDTP协议建立在connection-oriented L2CAP channel上,只能支持point-to-point signaling

1.1.基础知识

Stream:represents the logical end-to-end connection of streaming media data (audio or video) between two A/V devices(音视频流数据).

Media Packets, Recovery Packets, and Reporting Packets:根据三种不同的数据类型,有这三种数据包。其中,Basic Service会用到Basic service,Report service会用到Reporting Packets,Recovery service会用到Recovery Packets,此外Multiplexing service会用到Media Packets和其余一种或两种Packet。

Stream End Point (SEP):应用程序通过这个接口提供Transport Services and AV capabilities来建立Stream。

Stream Context (SC):两端设备都有的关于Stream的信息。

Stream Handle (SH):主要是暴露给用于程序使用的。

Stream End Point Identifier (SEID):标识Stream End Point的。

Transport Session:一条stream可以分解为多个transport sessions,每个transport session对应一个AVDTP的packet category ,which means Media, Recovery, or Reporting packets。 

Transport Session Identifier (TSID):标识Transport Session。

Transport Channel:通常和一个L2CAP Channel对应。不用AVDTP Multiplexing Mode时,一条Transport Channel只传输一个transport session;用transport session的情况下,一条Transport  Channel可以传输多个transport session(media,report或者recovery)。

Transport Channel Identifier (TCID):标识Transport Channel,唯一关联一条L2CAP channel。

GAVDP定义了两种角色:

Initiator (INT) – This is the device that initiates a signaling procedure.【发起signaling的】

Acceptor (ACP) – This is the device that shall respond to an incoming request from the INT.【响应signaling的】

A2DP在此基础上具体实现了连个角色:

Source (SRC) – A device is the SRC when it acts as a source of a digital audio stream that is delivered to the SNK of the piconet.【输出音频stream的】

Sink (SNK) – A device is the SNK when it acts as a sink of a digital audio stream delivered from the SRC on the same piconet.【接受音频stream的】

这里需要注意的是:一般在A2DP中Source和Sink的角色是固定的,而GAVDP的这两个角色是可以互换的,只要是发起signaling的一方就为initiator。

1.2.建立音频流流程

1.3.AVDTP Discover Command示例

1.3.1.发起

1.3.2.接受

1.5.AVDTP Open、Close抓包

1.5.1.open()

1.5.2.close()

1.6.编码

传输音频数据必须在Source端编码,在Sink端解码.

SBC是强制支持的(Mandatory Codec),其余三种可选(Optional Codec),除了这些外,也可以有厂家自己的编码形式(Vendor Specific A2DP Codecs)。

1.6.1.采样率

Sink端必须支持44100和48000这两种frequency,Source端支持一种就行。

例:

1.6.2.channel Mode

1.6.3.Block Length

1.6.4.Subbands

1.6.5.Allocation Method

1.6.6.Minimum / Maximum Bitpool Value

The decoder of the SNK shall support all possible bitpool values that do not result in
excess of the maximum bit rate. This profile limits the available maximum bit rate to
320kb/s for mono, and 512kb/s for two-channel modes.

猜你喜欢

转载自blog.csdn.net/xsophiax/article/details/89402254
今日推荐