WebRTC 是一套基于 Web 的实时通信解决方案。
其官网上的解释如下:
借助WebRTC,您可以在基于开放标准的应用程序中添加实时通信功能。 它支持在端点之间发送视频,语音和一般的数据信息,从而使开发人员能够构建功能强大的语音和视频通信解决方案。
该技术可在所有现代浏览器以及所有主要平台的本机客户端上使用。 WebRTC背后的技术被实现为一个开放的Web标准,并在所有主要浏览器中均以常规JavaScript API的形式提供。 对于本机客户端(例如Android和iOS应用程序),可以使用提供相同功能的库。
WebRTC 开源项目的源码在此: https://webrtc.googlesource.com/src
,上百万行的代码汗牛充栋,直接看代码会迷失在汪洋大海中。
我们还要先理解标准和协议, 知道背后的设计思想
WebRTC 相关标准
- WebRTC standard: https://www.w3.org/TR/webrtc
WebRTC 相关协议
- SDP: http://www.rfcreader.com/#rfc4566
- RTP: https://www.rfcreader.com/#rfc3550
- SRTP: https://www.rfcreader.com/#rfc3711
- RTP Profile: https://www.rfcreader.com/#rfc3551
- Datagram Transport Layer Security Version 1.2: https://www.rfcreader.com/#rfc6347
- RTCWeb Offer/Answer Protocol (ROAP): https://tools.ietf.org/html/draft-jennings-rtcweb-signaling-01
- Javascript Session Establishment Protocol (JSEP): https://tools.ietf.org/html/rfc8829
- Session Traversal Utilities for NAT (STUN): https://tools.ietf.org/html/rfc5389
- Traversal Using Relays around NAT (TURN): https://tools.ietf.org/html/rfc5766
- Interactive Connectivity Establishment (ICE): https://tools.ietf.org/html/rfc8445
- TCP Candidates with Interactive Connectivity Establishment (ICE): https://tools.ietf.org/html/rfc6544
- Trickling ICE: https://tools.ietf.org/html/draft-ivov-mmusic-trickle-ice-sip-02
- Datagram Transport Layer Security for SRTP (DTLS-SRTP): https://www.rfcreader.com/#rfc5764
- Connection-Oriented Media Transport over TLS in SDP: https://www.rfcreader.com/#rfc4572
- TCP-Based Media Transport in SDP: https://www.rfcreader.com/#rfc4145
- Web Real-Time Communication (WebRTC): Media Transport and Use of RTP: https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26
- Codec Control Messages in the RTP Audio-Visual Profile with Feedback (AVPF): https://tools.ietf.org/html/rfc5104
- Extended RTP Profile for RTCP-Based Feedback (RTP/AVPF): https://tools.ietf.org/html/rfc4585
- REMB - RTCP message for Receiver Estimated Maximum Bitrate: https://tools.ietf.org/html/draft-alvestrand-rmcat-remb-03
- Codec Control Messages in the RTP Audio-Visual Profile with Feedback (AVPF): https://tools.ietf.org/html/rfc5104
- A Google Congestion Control Algorithm for Real-Time Communication: https://tools.ietf.org/html/draft-ietf-rmcat-gcc-02
- Framing RTP and RTCP Packets over Connection-Oriented Transport: https://tools.ietf.org/html/rfc4571
- SSRC Attributes in SDP: https://tools.ietf.org/html/rfc5576
- (RTP) Header Extension for Client-to-Mixer Audio Level Indication: https://tools.ietf.org/html/rfc6464
- RTP Retransmission Payload Format: https://tools.ietf.org/html/rfc4588
- Negotiating Media Multiplexing Using SDP: https://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-54
- RTP Stream Identifier Source Description (SDES): https://tools.ietf.org/html/draft-ietf-avtext-rid-09
- WebRTC MediaStream Identification in SDP: https://tools.ietf.org/id/draft-ietf-mmusic-msid-05.html
- RTP Extensions for Transport-wide Congestion Control: https://tools.ietf.org/html/draft-ietf-avtext-rid-09
- RTP Header Extension for the RTCP Source Description Items: https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01
- A Framework for SDP Attributes when Multiplexing: https://tools.ietf.org/html/draft-ietf-mmusic-sdp-mux-attributes-19
- ULPFEC - RTP Payload Format for Generic Forward Error Correction: https://tools.ietf.org/html/rfc5109
- RED - RTP Payload for Redundant Audio Data: https://tools.ietf.org/html/rfc2198
- RTP Payload Format for H.264 Video: https://tools.ietf.org/html/rfc6184
- RTP Payload Format for Scalable Video Coding: https://tools.ietf.org/html/rfc6190
- Definition of the Opus Audio Codec: https://tools.ietf.org/html/rfc6716
参考资料
WebRTC offical site: https://webrtc.org/
-
WebRTC tutorial and book
-
WebRTC native codes