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.