getUserMedia()
到RTCPeerConnection()
,自认为难度陡增。我想一方面是以前在Linux平台上学习ROS调用摄像头时,对底层的外设接口调用、摄像头参数都有学习理解;另外一方面是,咱们在大三下学期才开始计算机网络的课程学习,对网络通讯的理解尚处于未能达到闭环的自闭状态(自闭——"全程自学完成知识闭环")RTCPeerConnection()
是最难的但也是最关键的,一样在RTCPeerConnection()
中,signaling部分是最难的,但也是最重要的,我想弄清楚这个部分,对WebRTC的各类跨平台搭建会很是有帮助(跨PC、Android、Raspberry Pi)创建了解基本的计算机网络知识,好比协议架构模型、设备之间的通讯所需的基本步骤网络
OK,先忽略各类具体的API,从一个基于现实物理器械的现实角度看看WebRTC的P2P到底怎么实现,参考Lifetime of a WebRTC sessionsession
getUserMedia()
把要寄的东西找出来,在WebRTC里面对应的就是获取audio | video,以及对对获取设备的选择、分辨率的设置之类RTCPeerConnection()
的signaling
,相似于选什么快递公司(communication protocols),要寄的东西要不要处理一下形式、要装箱子寄仍是塑料袋就好、收到快递打开使用有没有注意事项(media codecs and formats),填好寄到的地址(IP adress and port information),而后快递就能够寄出了架构
Signaling is the process of sending control information between two devices to determine the communication protocols, channels, media codecs and formats, and method of data transfer, as well as any required routing information.ide
There are three basic types of information that need to be exchanged during signaling:
- Control messages used to set up, open, and close the communication channel, and to handle errors.
- Information needed in order to set up the connection: the IP addressing and port information needed for the peers to be able to talk to one another.
- Media capability negotiation: what codecs and media data formats can the peers understand? These need to be agreed upon before the WebRTC session can begin.
RTCPeerConnection()
里的一系列API实现上述signaling
过程,这个过程在下一节里面详细分解固然寄快递有时候也会出现错误或者碰到异常状况(虽然现实中这种状况我没遇到过),假如是天天都要发一次货物的那种,ICE restart
,就是指去找新的发货方式,在找到新的发货渠道以前保持原来的方式,直到找到新的发货方式svg
<video>
element.