A2DP和AVRCP藍牙音頻傳輸協議
1.A2DP全名是Advenced Audio Distribution Profile藍牙音頻傳輸模型拹定。
A2DP 規定了使用藍牙非同步傳輸信道方式,傳輸高質量音樂文件數據的拹議堆棧軟件和使用方法,基於該拹議就能通過以藍牙方式傳事輸高品質的音樂了,
例如可以利用立體聲藍牙耳機或藍牙音響設備來收聽音樂了。A2DP和AVRCP是一對兄弟,A2DP裏WM設備是控制端,藍牙耳機是接收端,AVRCP反之,這裏說的就是WM如何接收藍牙耳機發送的AVRCP並處理的過程。
2.AVRCP全名是Audio Video Remote Cortrol Profile音頻/視頻遠程控制配置文件。
AVRCP 設計用於提供控制 TV、Hi-fi 設備等的標準接口。此配置文件用於許可單個遠程控制設備(或其它設備)控制所有用戶可以接入的 A/V 設備。
AVRCP 定義瞭如何控制流媒體的特徵。包括暫停、停止、啓動重放、音量控制及其它類型的遠程控制操作。
AVRCP(Audio/Video Remote Control Profile)是一種在藍牙協議棧A2DP/AVCTP上實現的控制技術,通俗點說,就是你用藍牙耳機聽歌時按一下撥號鍵它會暫停,按下選曲它會切換,這就是AVRCP的功勞。
栗子:手機通過藍牙連接音箱,播放手機上的音樂。
Audio Source:發送音頻流 //手機端
Audio Sink:接收音頻流 //音箱端
A2DP
AVCTP Audio/Video Control Transport Protocol 音頻/視頻控制傳輸協議(通過L2CAP傳輸AV/C指令) 通過L2CAP通道由遠程控制規範去發送AV/C指令
AVRCP
AVDTP Audio/Video Distribution Transport Protocol 音頻/視頻分發傳輸協議(通過L2CAP向立體聲耳機傳輸音樂文件) 通過L2CAP通道由高級音頻分發規範將音樂傳輸到立體聲耳機
Audio 音頻
TCP/UDP
PPP/BNEP 網絡
SDP 服務發現協議 爲實現藍牙設備之間相互查詢及訪問對方提供的服務
TCS 電話控制
AT 指令集
OBEX 對象交換協議
RFCOMM 串口仿真
L2CAP 邏輯鏈路控制與適配協議
persist.bluetooth.btsnoopenable
一次完整的連接:connect Event
設備發現過程:
Advertise: 從機處於廣播狀態
Scan Request: 主機接收到廣播後發送掃描請求到外設
Scan Response: 從機接收請求後返回掃描響應到主機
Establish Link Request:主機向從機發送一個鏈接請求
Pairing:配對過程,產生加密肯認證密鑰
Bonding:綁定過程,主從機綁定後下次連接可以快速配對
藍牙技術應用框架協議堆棧
通用訪問框架(GAP)
服務發現框架(SDAP)
擴展服務發現框架(ESDP)
硬拷貝電纜替代框架(HCRP)
個人局域網框架(PANP)
電話控制協議規範框架(TCSP)
無繩電話框架(CTP)
對講機框架(IntP)
音頻/視頻遙控框架(AVRCP)
藍牙音頻視頻控制傳輸協議(AVCTP)
通用音頻/視頻分發框架(GAVDP)
高級音頻分發框架(A2DP)
視頻分發框架(VDP)
串口框架(SPP)
撥號上網框架(DUNP)
傳真框架(FaxP)
頭戴式設備框架(HSP)
局域網訪問框架(LAP)
免提框架(HFP)
通用對象交換框架(GOEP)
文件傳輸框架(FTP)
對象推送框架(OPP)
同步框架(SP)
基本打印框架(BPP)
基本成像框架(BIP)
A2DP 高級音頻分發框架
異步無連接鏈路(ACL)
音頻數據 -> 耳機或音箱
點對點的音頻分發
AVCTP
09-03 21:01:02.187 503 787 W bt_btif : bta_av_str_closed: peer_addr=18:bb:26:e1:61:14 open_status=0 chnl=64 hndl=65 co_started=1
09-03 21:01:02.187 503 787 E bt_btif : bta_av_str_stopped: audio_open_cnt=1, p_data 0x0
09-03 21:01:02.187 503 787 W bt_btif : bta_dm_rm_cback:2, status:6
09-03 21:01:02.188 503 639 W bt_btif : btif_av_state_started_handler: event=BTA_AV_STOP_EVT flags=0x0
09-03 21:01:02.188 503 787 W bt_btif : bta_dm_rm_cback:2, status:1
09-03 21:01:02.188 503 639 W bt_btif : ## ON A2DP STOPPED ##
09-03 21:01:02.188 503 639 I BluetoothA2dpServiceJni: bta2dp_audio_state_callback
09-03 21:01:02.188 503 787 E bt_btif : bta_av_rc_create ACP handle exist for shdl:0
09-03 21:01:02.189 503 807 W bt_btif : btif_a2dp_command_ack: ## a2dp ack : A2DP_CTRL_CMD_NONE, status 0 ##
09-03 21:01:02.189 503 808 W bt_btif : btif_a2dp_data_cb: BTIF MEDIA (A2DP-DATA) EVENT UIPC_CLOSE_EVT
09-03 21:01:02.189 503 807 E bt_btif : btif_a2dp_command_ack: warning : no command pending, ignore ack
09-03 21:01:02.189 503 808 W bt_btif : btif_a2dp_command_ack: ## a2dp ack : A2DP_CTRL_CMD_NONE, status 0 ##
09-03 21:01:02.189 503 807 D a2dp_sbc_encoder: a2dp_sbc_feeding_reset: PCM bytes per tick 3528
09-03 21:01:02.189 503 808 E bt_btif : btif_a2dp_command_ack: warning : no command pending, ignore ack
09-03 21:01:02.190 503 639 W bt_btif : ## ON A2DP STOPPED ##
09-03 21:01:02.190 503 806 D A2dpStateMachine: Connected process message: 101
09-03 21:01:02.191 503 639 I BluetoothA2dpServiceJni: bta2dp_connection_state_callback
09-03 21:01:02.191 503 807 D a2dp_sbc_encoder: a2dp_sbc_feeding_reset: PCM bytes per tick 3528
09-03 21:01:02.191 503 639 D a2dp_codec: init
09-03 21:01:02.191 503 639 D a2dp_codec: createCodec: codec SBC
09-03 21:01:02.191 503 639 I a2dp_codec: init: updated SBC codec priority to 1001
09-03 21:01:02.192 503 639 D a2dp_codec: createCodec: codec AAC
09-03 21:01:02.192 503 639 I a2dp_codec: init: updated AAC codec priority to 2001
09-03 21:01:02.192 503 639 D a2dp_codec: createCodec: codec aptX
09-03 21:01:02.193 503 806 D A2dpStateMachine: A2DP Playing state : device: 18:BB:26:E1:61:14 State:10->11
09-03 21:01:02.193 503 806 D A2dpStateMachine: Connected process message: 101
09-03 21:01:02.195 503 639 D a2dp_codec: createCodec: codec aptX-HD
09-03 21:01:02.202 503 806 D A2dpStateMachine: Enter Disconnected: 101
09-03 21:01:02.204 503 503 D A2dpStateMachine: Connection state 18:BB:26:E1:61:14: 2->0
09-03 21:01:02.225 503 808 W bt_btif : btif_a2dp_ctrl_cb: A2DP-CTRL-CHANNEL EVENT UIPC_RX_DATA_READY_EVT
09-03 21:01:02.225 503 808 W bt_btif : btif_a2dp_recv_ctrl_data: a2dp-ctrl-cmd : A2DP_CTRL_CMD_START
09-03 21:01:02.225 503 808 W bt_btif : btif_av_stream_started_ready: sm_handle=-448876552 state=0 flags=0x0 ready=0
09-03 21:01:02.226 503 808 W bt_btif : btif_a2dp_recv_ctrl_data: A2DP command A2DP_CTRL_CMD_START while AV stream is not ready
09-03 21:01:02.226 503 808 W bt_btif : btif_a2dp_command_ack: ## a2dp ack : A2DP_CTRL_CMD_START, status 1 ##
09-03 21:01:02.226 503 808 W bt_btif : btif_a2dp_recv_ctrl_data: a2dp-ctrl-cmd : A2DP_CTRL_CMD_START DONE
09-03 21:01:02.248 503 808 W bt_btif : btif_a2dp_ctrl_cb: A2DP-CTRL-CHANNEL EVENT UIPC_RX_DATA_READY_EVT
09-03 21:01:02.248 503 808 W bt_btif : btif_a2dp_recv_ctrl_data: a2dp-ctrl-cmd : A2DP_CTRL_CMD_START
09-03 21:01:02.248 503 808 W bt_btif : btif_av_stream_started_ready: sm_handle=-448876552 state=0 flags=0x0 ready=0
09-03 21:01:02.248 503 808 W bt_btif : btif_a2dp_recv_ctrl_data: A2DP command A2DP_CTRL_CMD_START while AV stream is not ready
09-03 21:01:02.248 503 808 W bt_btif : btif_a2dp_command_ack: ## a2dp ack : A2DP_CTRL_CMD_START, status 1 ##
09-03 21:01:02.248 503 808 W bt_btif : btif_a2dp_recv_ctrl_data: a2dp-ctrl-cmd : A2DP_CTRL_CMD_START DONE
09-03 21:01:02.248 503 639 D a2dp_codec: createCodec: codec LDAC
09-03 21:01:02.249 503 639 I a2dp_codec: init: updated LDAC codec priority to 5001
09-03 21:01:02.249 503 639 D a2dp_codec: createCodec: codec SBC SINK
09-03 21:01:02.250 503 639 I a2dp_codec: init: initialized Source codec LDAC
09-03 21:01:02.250 503 639 I a2dp_codec: init: initialized Source codec AAC
09-03 21:01:02.250 503 639 I a2dp_codec: init: initialized Source codec SBC
09-03 21:01:02.251 503 639 I a2dp_codec: init: initialized Sink codec SBC(Sink)
09-03 21:01:02.253 503 639 W bt_btif : ## ON A2DP IDLE ## peer_sep = 1
09-03 21:01:02.254 503 807 D a2dp_sbc_encoder: a2dp_sbc_feeding_reset: PCM bytes per tick 3528
09-03 21:01:02.254 503 639 I BluetoothA2dpServiceJni: bta2dp_audio_config_callback