首页 > 其他 > 详细

A2DP协议笔记

时间:2018-10-24 11:37:46      阅读:184      评论:0      收藏:0      [点我收藏+]

1.概述

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

3.A2DP协议的限制
(1)不支持synchronized point-to-multipoint distribution。
(2)在Source和Sink端存在延迟。
(3)音频数据的速率必须足够小于蓝牙的传输速率。
(4)不提供任何数据保护的方法
 
4.编码
    传输音频数据必须在Source端编码,在Sink端解码。A2DP规定了下面几种编码类型:
技术分享图片

SBC是强制支持的(Mandatory Codec),其余三种可选(Optional Codec),除了这些外,也可以有厂家自己的编码形式(Vendor Specific A2DP Codecs)。
 
5.SBC编码格式
   SBC是A2DP规定的强制支持的编码格式,这里我们具体只讨论这一种编码格式:
技术分享图片
参数Sampling Frequency:
 
技术分享图片 技术分享图片
Sink端必须支持44100和48000这两种frequency,Source端支持一种就行。
 
参数Channel Mode:
技术分享图片

参数Block Length:
技术分享图片
  
参数Subbands:
技术分享图片

参数Allocation Method:
技术分享图片
 
参数Minimum / Maximum Bitpool Value:
技术分享图片

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的格式如下:
技术分享图片
其中Media Payload的Header部分的格式如下:
技术分享图片
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,通过下图的流程进行状态转换:
技术分享图片
Connection Establishment:
技术分享图片
前提是L2CAP首先建立signaling Channel.
Start Streaming:
技术分享图片

OPEN状态下经过Start Stream 过程就转换到STREAMING状态。
Connection Release:
技术分享图片

在OPEN和STREAMING状态下都可以通过Stream Release过程变为IDLE状态。
Suspend:
技术分享图片

只能从STREAMING状态通过Stream Suspend过程变为OPEN。
Change Parameters:
技术分享图片

A2DP协议笔记

原文:https://www.cnblogs.com/senior-engineer/p/9842309.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!