基于RTSP协议实现摄像头语音对讲
该方案仅做过技术验证,未在项目中实际使用。不代表具有通用性。
发帖备忘,如有同道中人,望交流。
一。基于RTSP协议实现语音广播的交互流程:
二。技术方案:
1.流媒体服务采用zlmediakit组件:实现视频和音频的拉取转流。提供包含音视频的HTTP-FLV格式供前端页面播放。
2.RTSP客户端:自研实现RTSP客户端的协议交互过程。通过websocket方式接收前端页面发送的PCM音频流,转成PCMA之后推送到摄像头,实现摄像头播放语音。
3.在客户端发送的RTSP协议报文中需要增加获取语音标识,摄像头才会返回对应的音频通道(sendonly):Require: www.onvif.org / ver20 / backchannel #!!Require - tag
二。信令抓包:
1.OPTIONS: OPTIONS rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101 RTSP/1.0 CSeq: 1 User-Agent: -_- RTSP/1.0 200 OK CSeq: 1 Public: OPTIONS, DESCRIBE, PLAY, PAUSE, SETUP, TEARDOWN, SET_PARAMETER, GET_PARAMETER Date: Wed, Mar 29 2023 11:24:38 GMT 2.DESCRIBE: DESCRIBE rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101 RTSP/1.0 CSeq: 2 Accept: application/sdp Require: www.onvif.org / ver20 / backchannel #!!Require - tag User-Agent: -_- RTSP/1.0 401 Unauthorized CSeq: 2 WWW-Authenticate: Digest realm="IP Camera(11266)", nonce="d12dc42e26cb4aea7774358e27de4cdd", stale="FALSE" Date: Wed, Mar 29 2023 11:24:38 GMT DESCRIBE rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101 RTSP/1.0 CSeq: 3 Accept: application/sdp Require: www.onvif.org / ver20 / backchannel #!!Require - tag User-Agent: -_- Authorization: Digest username="admin", realm="IP Camera(11266)", nonce="d12dc42e26cb4aea7774358e27de4cdd", uri="rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101", response="fa2f8a7f7b47c9df1b735675e57c91a2" RTSP/1.0 200 OK CSeq: 3 Content-Type: application/sdp Content-Base: rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101/ Content-Length: 953 v=0 o=- 1680089078910230 1680089078910230 IN IP4 10.0.16.111 s=Media Presentation e=NONE b=AS:5150 t=0 0 a=control:rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101/ m=video 0 RTP/AVP 96 c=IN IP4 0.0.0.0 b=AS:5000 a=recvonly a=x-dimensions:1280,720 a=control:rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101/trackID=1 a=rtpmap:96 H264/90000 a=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=Z0IAH52oFAFum4CAgKAAAAMAIAAABlCA,aM48gA== m=audio 0 RTP/AVP 8 c=IN IP4 0.0.0.0 b=AS:50 a=recvonly a=control:rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101/trackID=2 a=rtpmap:8 PCMA/8000 m=audio 0 RTP/AVP 8 c=IN IP4 0.0.0.0 b=AS:50 a=sendonly a=control:rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101/trackID=4 a=rtpmap:8 PCMA/8000 a=Media_header:MEDIAINFO=494D4B48010200000400000111710110401F000000FA000000000000000000000000000000000000; a=appversion:1.0 3.SETUP: SETUP rtsp://admin:l1234567@10.0.16.111:554/Streaming/Channels/101/trackID=4 RTSP/1.0 Transport: RTP/AVP/TCP;unicast;mode=setup;interleaved=0-1 Require: www.onvif.org/ver20/backchannel #!! Require-tag CSeq: 4 User-Agent: -_- Session: RTSP/1.0 200 OK CSeq: 4 Session: 1655427714;timeout=60 Transport: RTP/AVP/TCP;unicast;mode=setup;interleaved=0-1;ssrc=251b22da;mode="play" Date: Wed, Mar 29 2023 11:24:38 GMT 3.PLAY: PLAY rtsp://10.0.16.111:554/Streaming/Channels/101/track4 RTSP/1.0 Require: www.onvif.org/ver20/backchannel #!! Require-tag CSeq: 5 User-Agent: -_- Session: 1655427714;timeout=60 RTSP/1.0 200 OK CSeq: 5 Session: 1655427714 RTP-Info: Date: Wed, Mar 29 2023 11:24:38 GMT