跨平台連接配接
WebRTC的通常連接配接流程:
http://blog.csdn.net/qq_21358401/article/details/
WebRTC SDP協定:
http://blog.csdn.net/qq_21358401/article/details/
連接配接不同平台的PeerConnection的流程和通常流程沒有什麼差別.
但很容易遇到這些一個問題:
不支援的音視訊編解碼器
WebRTC報錯: failed to set video send codecs
意為不支援收到的SDP裡聲明的某個視訊編碼
我在連接配接linux和android端時 就出現了android端不支援和(編碼協定的RTP序号)
是以需要在設定local或remote的SDP前 修改sdp 去掉不支援的codec
不支援的傳輸協定
這個錯誤常見于和浏覽器的peer連接配接
浏覽器通常不支援 UDP/TLS 這兩個傳輸選項(firefox上發現問題)
解決方法同樣是修改SDP 去除不支援的傳輸協定
如何修改SDP
以去除不支援的編碼器codec為例
截取部分video相關的sdp資訊 去除對VP9的支援
m=video UDP/TLS/RTP/SAVPF //删除此行中的101
c=IN IP4
a=rtcp: IN IP4
a=ice-ufrag:kQ3y
a=ice-pwd:QHoxQ17WUhFXGg8hld1gDq0
a=fingerprint:sha- F3:B:B4:E:F:F9:A:BF::F:::D3:::BB::A3::E3:EA:E3:F7::::::BB:B1::
a=setup:actpass
a=mid:video
a=extmap: urn:ietf:params:rtp-hdrext:toffset
a=extmap: http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap: urn:gpp:video-orientation
a=extmap: http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-
a=extmap: http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=sendrecv
a=rtcp-mux
a=rtcp-rsize
a=rtpmap: VP8/
a=rtcp-fb: ccm fir
a=rtcp-fb: nack
a=rtcp-fb: nack pli
a=rtcp-fb: goog-remb
a=rtcp-fb: transport-cc
a=rtpmap: VP9/ // 删除
a=rtcp-fb: ccm fir // 删除
a=rtcp-fb: nack // 删除
a=rtcp-fb: nack pli // 删除
a=rtcp-fb: goog-remb // 删除
a=rtcp-fb: transport-cc // 删除
a=rtpmap: red/
a=rtpmap: ulpfec/
a=rtpmap: rtx/
a=fmtp: apt=
a=rtpmap: rtx/
a=fmtp: apt=
a=rtpmap: rtx/
a=fmtp: apt=
修改後的SDP:
m=video UDP/TLS/RTP/SAVPF
c=IN IP4
a=rtcp: IN IP4
a=ice-ufrag:kQ3y
a=ice-pwd:QHoxQ17WUhFXGg8hld1gDq0
a=fingerprint:sha- F3:B:B4:E:F:F9:A:BF::F:::D3:::BB::A3::E3:EA:E3:F7::::::BB:B1::
a=setup:actpass
a=mid:video
a=extmap: urn:ietf:params:rtp-hdrext:toffset
a=extmap: http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap: urn:gpp:video-orientation
a=extmap: http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-
a=extmap: http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=sendrecv
a=rtcp-mux
a=rtcp-rsize
a=rtpmap: VP8/
a=rtcp-fb: ccm fir
a=rtcp-fb: nack
a=rtcp-fb: nack pli
a=rtcp-fb: goog-remb
a=rtcp-fb: transport-cc
a=rtpmap: red/
a=rtpmap: ulpfec/
a=rtpmap: rtx/
a=fmtp: apt=
a=rtpmap: rtx/
a=fmtp: apt=
a=rtpmap: rtx/
a=fmtp: apt=
WebRTC SDP 處理庫
github repo:
https://github.com/sliver-chen/WebRTC-SDP
還在逐漸的添加功能中.
示例代碼
github repo:
https://github.com/sliver-chen/WebRTCam
基于WebRTC的網絡攝像頭 包括linux裝置端 node服務端以及Android用戶端.