Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1463528
  • 博文数量: 267
  • 博客积分: 3010
  • 博客等级: 少校
  • 技术积分: 3089
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-05 17:09
个人简介

尊天命,尽人事

文章分类

全部博文(267)

文章存档

2017年(6)

2015年(4)

2014年(27)

2013年(52)

2012年(59)

2011年(120)

分类: Android平台

2014-11-15 14:41:54

A2DP(Advanced Audio Distribution Profile)是蓝牙的音频传输协议,典型应用为蓝牙耳机。A2DP协议的音频数据在ACL Link上传输,这与SCO上传输的语音数据要区别。A2DP不包括远程控制的功能,远程控制的功能参考协议AVRCP。AVDTP则定义了蓝牙设备之间数据流句柄的参数协商,建立和传输过程以及相互交换的信令实体形式,该协议是A2DP框架的基础协议。A2DP与相关协议的附属关系如下图:
A2DP协议笔记
A2DP在协议栈中的位置如下图所示:
A2DP协议笔记
2.A2DP的一些定义
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。
一个Source和Sink的实例:
A2DP协议笔记
3.A2DP协议的限制
(1)不支持synchronized point-to-multipoint distribution。
(2)在Source和Sink端存在延迟。
(3)音频数据的速率必须足够小于蓝牙的传输速率。
(4)不提供任何数据保护的方法

4.编码
    传输音频数据必须在Source端编码,在Sink端解码。A2DP规定了下面几种编码类型:
A2DP协议笔记
SBC是强制支持的(Mandatory Codec),其余三种可选(Optional Codec),除了这些外,也可以有厂家自己的编码形式(Vendor Specific A2DP Codecs)。

5.SBC编码格式
   SBC是A2DP规定的强制支持的编码格式,这里我们具体只讨论这一种编码格式:
A2DP协议笔记
参数Sampling Frequency:
A2DP协议笔记
Sink端必须支持44100和48000这两种frequency,Source端支持一种就行。
参数Channel Mode:
A2DP协议笔记
参数Block Length:
A2DP协议笔记
参数Subbands:
A2DP协议笔记
参数Allocation Method:
A2DP协议笔记
参数Minimum / Maximum Bitpool Value:
A2DP协议笔记
6.Media Packet Header与Media payload:
    在第一部分数据的包装中可以看出,在每一个Media payload上都会加上Media packrt header。主要包括以下几个部分:
Timestamp (TS),Payload Type (PT),Marker (M) bit【置为全0】,Extension (X) bit【不使用,置为全0】。具体在AVDTP协议中定义,这里不详述。
Media payload的格式如下:
A2DP协议笔记
其中Media Payload的Header部分的格式如下:
A2DP协议笔记
F bit – Set to 1 if the SBC frame is fragmented, otherwise set to 0.
S bit – Set to 1 for the starting packet of a fragmented SBC frame, otherwise set to 0.
L bit – Set to 1 for the last packet of a fragmented SBC frame, otherwise set to 0
RFA – 置为0.
Number of frames (4 bits) – If the F bit is set to 0, this field indicates the number of
frames contained in this packet. If the F bit is set to 1, this field indicates the number
of remaining fragments, including the current fragment. Thus the last counter value
shall be one. For example, if there are three fragments then the counter has value 3,
2 and 1 for subsequent fragments. This field is expressed by 4 bit UiMsbf.
7.A2DP的通信过程
A2DP规定Sink个Source端有三种状态:IDLE、OPEN和STREAM,通过下图的流程进行状态转换:
A2DP协议笔记
Connection Establishment:
A2DP协议笔记
前提是L2CAP首先建立signaling Channel.
Start Streaming:
A2DP协议笔记

OPEN状态下经过Start Stream 过程就转换到STREAMING状态。
Connection Release:
A2DP协议笔记

在OPEN和STREAMING状态下都可以通过Stream Release过程变为IDLE状态。
Suspend:
A2DP协议笔记

只能从STREAMING状态通过Stream Suspend过程变为OPEN。
Change Parameters:
A2DP协议笔记


阅读(1218) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~