Getting started with WebRTC
开始使用WebRTC
Creating a new application based on the WebRTC technologies can be overwhelming if you're unfamiliar with the APIs. In this section we will show how to get started with the various APIs in the WebRTC standard, by explaining a number of common use cases and code snippets for solving those.
如果不熟悉API,那么创建一个基于WebRTC技术的新应用程序可能会非常困难。在本节中,将通过解释一些常见用例和解决这些问题的代码片段,展示如何开始使用WebRTC标准中的各种API。
WebRTC APIs
The WebRTC standard covers, on a high level, two different technologies: media capture devices and peer-to-peer connectivity.
WebRTC标准在高水平上涵盖了两种不同的技术:媒体捕获设备和对等连接。
Media capture devices includes video cameras and microphones, but also screen capturing "devices". For cameras and microphones, we use navigator.mediaDevices.getUserMedia()
to capture MediaStreams
. For screen recording, we use navigator.mediaDevices.getDisplayMedia()
instead.
媒体捕捉设备包括摄像机和麦克风,也包括屏幕捕捉“设备”。对于相机和麦克风,使用navigator.mediaDevices.getUserMedia()来捕获MediaStreams。对于屏幕录制,使用navigator.mediaDevices.getDisplayMedia()。
The peer-to-peer connectivity is handled by the RTCPeerConnection
interface. This is the central point for establishing and controlling the connection between two peers in WebRTC.
对等连接由RTCPeerConnection接口处理。这是在WebRTC中建立和控制两个对等点之间连接的中心点。