1. 程式人生 > >AVDTP協議分析(一)--轉--

AVDTP協議分析(一)--轉--

AVDTP協議分析(一)

1.概述

   AVDTP(AUDIO/VIDEODISTRIBUTION TRANSPORT PROTOCOL)是用來描述音訊/視訊在藍芽裝置間的傳輸的協議,是A2DP協議的基礎協議,其在協議棧中的位置如下:


AVDTP協議建立在connection-oriented L2CAP channel上,只能支援point-to-pointsignaling。

2.一些術語

Stream:represents the logical end-to-endconnection of streaming media data (audio or video) between two A/V devices.
MediaPackets, Recovery Packets, and Reporting Packets:根據三種不同的資料型別,有這三種資料包。其中,Basic Service會用到Basicservice,Report service會用到ReportingPackets,Recovery service會用到RecoveryPackets,此外Multiplexing service會用到Media Packets和其餘一種或兩種Packet。
Stream EndPoint (SEP):應用程式通過這個介面提供TransportServices and AV capabilities來建立Stream。
StreamContext (SC):兩端裝置都有的關於Stream的資訊。
Stream Handle(SH):主要是暴露給用於程式使用的。
Stream EndPoint Identifier (SEID):標識Stream End Point的。
TransportSession:一條stream可以分解為多個transportsessions,每個transport session對應一個AVDTP的packet category ,which means Media, Recovery, or Reporting packets。 
TransportSession Identifier (TSID):標識Transport Session。
TransportChannel:通常和一個L2CAP Channel對應。不用AVDTP Multiplexing Mode時,一條Transport Channel只傳輸一個transport session;用transport session的情況下,一條Transport  Channel可以傳輸多個transportsession(media,report或者recovery)。
TransportChannel Identifier (TCID):標識Transport Channel,唯一關聯一條L2CAP channel。

3.Signaling Procedures

一個典型的Stream End-pointDiscovery to Stream Release過程:State Machine如下共有5個狀態:


一些主要的procedure如下:
Stream End Point Discovery:遠端裝置提供支援的SEP列表和mediaType。
Get All Capabilities:Using the SEID as a reference, the local device can querythe service capabilities of the remote SEP。
Stream Configuration:By referencing both the local and the remote SEID, thelocal device (the INT) configures the SEP of the remote device (the ACP)。
Stream Get Configuration:etrieve the last capabilities settingsperformed by the remote device on the SEP。
Stream Establishment:The opening of a transport session, while referencingthe remote SEID, includes, if necessary, the establishment of a new TransportChannel。
Stream Start:After the Stream Establishment is complete, the Start Streamingprocedure causes the streaming to start; i.e., Media (Reporting, Recovery)packets can be exchanged。
Stream Release:initiated by the upper layer within a device; a signal is sentindicating
thata stream end-point be closed.
Stream Suspend:掛起。
Stream Reconfigure:對Stream進行配置。
StreamReconfigure:再次配置。
Security Control:對AV data transmitted over a Bluetooth 提供protection。
Abort:用於兩個裝置的同步。
General Reject:對包含invalid Signal Identifier的Command進行的response。
Delay Reporting:provide an initial delay report required for synchronizedaudio/video playback。
 

4.Transport Procedures

分為三種Service:Basic Service,Reporting Service,Recovery Service和Multiplexing Service。
Basic Service只提供signaling 和mediastreaming。Media Packet Format如下圖:


引數定義如下:


Reporting packet格式如下:


注意:如果不使用multiplexing mode ,一個PDU包含一個meida或者reporting或者recovery packet
每個transport session 使用不同的L2CAPChannel。如果使用MultiplexingService,則一個transport channel上可能有好幾種transport transport,需要AL header 來進行區分。
4.signaling message

一個SignalFragmentation的例項:


Signal command and response headers:


引數Packet Type:


引數Message Type:


原文;https://mp.weixin.qq.com/s/-7i-Feo7tpjbgCdiqPzo7Q