浏览器直接调用 webrtc 相关 api 接口,比如调用PeerConnection
。
但是实际上不同浏览器上可能这个 API 不同:
W3C Standard | Chrome | Firefox |
---|---|---|
getUserMedia | webkitGetUserMedia | mozGetUserMedia |
RTCPeerConnection | webkitRTCPeerConnection | RTCPeerConnection |
RTCSessionDescription | RTCSessionDescription | RTCSessionDescription |
RTCIceCandidate | RTCIceCandidate | RTCIceCandidate |
Note: 参考 WebRTC APIs Interop 页面的描述。
所以对于 H5,推荐用一个adapter.js来支持各种浏览器。
adapter.js is a shim to insulate apps from spec changes and prefix differences in WebRTC. The prefix differences are mostly gone these days but differences in behaviour between browsers remain.
This repository used to be part of the WebRTC organisation on github but moved. We aim to keep the old repository updated with new releases.
这个库的 API 调用例子,参考Samples,比如 PC 应该用RTCPeerConnection。