-
WebRTC原理及分析
-
媒体协议
-
RTP, 实时传输协议
- rfc1889, rfc3550: RTP: A Transport Protocol for Real-Time Applications
- rfc1890, rfc3551: RTP Profile for Audio and Video Conferences with Minimal Control
- rfc4571: Framing Real-time Transport Protocol (RTP) and RTP Control Protocol (RTCP) Packets over Connection-Oriented Transport
- rfc5761: Multiplexing RTP Data and Control Packets on a Single Port
- rfc6051: Rapid Synchronisation of RTP Flows
- rfc7160: Support for Multiple Clock Rates in an RTP Session
- rfc7164: RTP and Leap Seconds
- rfc8083: Multimedia Congestion Control: Circuit Breakers for Unicast RTP Sessions
- rfc8108, rfc8860: Sending Multiple RTP Streams in a Single RTP Session
- rfc5285, rfc8285: A General Mechanism for RTP Header Extensions
-
图例
- RTP Format,
请参考http://www.networksorcery.com/enp/protocol/rtp.htm
- V:RTP版本号,为“10”
- P:填充指示位,P为“1”时表示分组有填充(结尾填充数据)
- X:扩展指示位,X为“1”时,则表示固定头部后还有一个扩展头部
- CC:CSRC计数,指示固定头部后的CSRC的个数
- M:由应用文档解释(如视频帧中,可用于标识一帧的结束(一帧的最后一个包))
- PT:RTP分组的净荷类型,如:
“0”: G.711μ
“8”: G.711A
“4”: G.723.1
“18”: G.729
“96~127”:用于动态协商的算法,如iLBC、AMR、SPEEX等
- 时间戳:表示RTP分组第一个字节的取样时刻。其初值为随机数,每个采样周期加1。
如每次传送20ms的采样频率为8000Hz的数据,则每个传输分组时间戳增加160;
- SSRC:同步源标识(Synchronous Source),表示信号的同步信源(如产生媒体流的麦克风、摄像机、RTP混合器等)。其值应随机选择,以保证同一个RTP会话中任意两个同步源的SSRC标识不同
- CSRC:分信源(贡献源)标识(Contributing Source),识别该数据包中的有效载荷的贡献源
RTP分组的头部最多可以包含15个CSRC标识,其数目由CC字段指明;
通过混合器时;来源的RTP包的SSRC作为CSRC,混合器的SSRC做为新的SSRC;
-
参考资料
- RTP: Overview,
http://www.cs.columbia.edu/~hgs/rtp/
-
SRTP, 安全实时传输协议
- rfc3711: The Secure Real-time Transport Protocol (SRTP)
- rfc6904: Encryption of Header Extensions in the Secure Real-time Transport Protocol (SRTP)
-
图例
- SRTP over UDP
- SRTP Format,
请参考http://www.networksorcery.com/enp/protocol/srtp.htm
- RTP extension
- Payload
- Pad
- Pad count
- MKI
- Authentication tag
-
参考资料
- <<基于SRTP协议的视频传输安全技术的研究>>论文, 卢陈越
-
RTCP, 实时传输控制协议
- rfc5506: Support for Reduced-Size Real-Time Transport Control Protocol (RTCP): Opportunities and Consequences
- rfc4585: Extended RTP Profile for Real-time Transport Control Protocol (RTCP)-Based Feedback (RTP/AVPF)
- rfc6222, rfc7022: Guidelines for Choosing RTP Control Protocol (RTCP) Canonical Names (CNAMEs)
-
图例
- RTCP Format,
http://www.networksorcery.com/enp/protocol/rtcp.htm
- Version
- P
- Count
- Type
-
SRTCP, 安全实时传输控制协议
-
图例
- SRTCP Format,
http://www.networksorcery.com/enp/protocol/srtcp.htm
- E
- SRTCP index
- SRTCP MKI
- Authentication tag
-
SCTP, 流控制传输协议
- rfc2960, rfc4960: Stream Control Transmission Protocol
- rfc3309: Stream Control Transmission Protocol (SCTP) Checksum Change
- SCTP in Go,
https://2013.asiabsdcon.org/papers/abc2013-P7A-paper.pdf
-
图例
- SCTP Format,
http://www.networksorcery.com/enp/protocol/sctp.htm
- Source port
- Destination port
- Verification tag
- Checksum
- Chunk
-
信令与SDP协商
-
JSEP, JavaScript会话建立协议
-
rfc8829: JavaScript Session Establishment Protocol (JSEP)
- https://www.w3.org/TR/webrtc/#call-flow-browser-to-browser
https://cloudconvert.com/svg-to-png
- 术语
- 媒体流(MediaStream),
包含0或多个Track
- 媒体流轨(MediaStreamTrack)
- 媒体流约束(MediaStreamConstraints)
- 媒体描述(media description)
- 媒体传输(media transport)
- Semantics and Syntax
- Session Descriptions and State Machine
- JSEP State Machine
- Signaling Model
- JSEP Signaling Model
- Session Description Format
- Session Description Control
- RtpTransceivers,
允许应用程序访问有关发送和接收数据包的ICE传输的信息
- RtpSenders,
允许应用控制一个 MediaStreamTrack 如何被编码并被发送至远程对端
- RtpReceivers,
允许应用程序监视流媒体轨 MediaStreamTrack 的接收情况
- ICE
- ICE Gathering Overview
- ICE Candidate Trickling
- ICE Candidate Format
- ICE Candidate Policy
- ICE Candidate Pool
- ICE Versions
- Video Size Negotiation
- Creating an imageattr Attribute
- Interpreting imageattr Attributes
- Simulcast
- Interactions with Forking
- Sequential Forking
- Parallel Forking
- Interface
- PeerConnection
- RTCpeerConnection API
- Constructor
- addTrack,
将一个被指定媒体流 MediaStream 对象包含的新媒体轨加入 RTCPeerConnection
- removeTrack
- addTransceiver
- onaddtrack Event
- createDataChannel
- ondatachannel Event
- createOffer
- createAnswer
- SessionDescriptionType
- Use of Provisional Answers
- Rollback
- setLocalDescription
- setRemoteDescription
- currentLocalDescription
- pendingLocalDescription
- currentRemoteDescription
- pendingRemoteDescription
- canTrickleIceCandidates
- setConfiguration
- addIceCandidate
- onicecandidate Event
- RtpTransceiver
- stop
- stopped
- setDirection
- direction
- currentDirection
- setCodecPreferences
- SDP Interaction Procedures
- Profile Names and Interoperability
- Constructing an Offer
- Initial Offers
- Subsequent Offers
- Options Handling
- IceRestart
- VoiceActivityDetection
- Generating an Answer
- Initial Answers
- Subsequent Answers
- Options Handling
- VoiceActivityDetection
- Modifying an Offer or Answer
- Processing a Local Description
- Processing a Remote Description
- Processing a Rollback
- Parsing a Session Description
- Session-Level Parsing
- Media Section Parsing
- Semantics Verification
- SDP ABNF Syntax
- Applying a Local Description
- Applying a Remote Description
- Applying an Answer
- Processing RTP/RTCP
-
SDP, 描述会话的协议
- rfc2327, rfc4566, rfc8866: SDP: Session Description Protocol
- rfc3266: Support for IPv6 in Session Description Protocol (SDP)
-
rfc3264, rfc5888, rfc7941, rfc8843: Negotiating Media Multiplexing Using the Session Description Protocol(SDP)
- sdp offer/answer model
- session level
- media level
- rfc3605: Real Time Control Protocol (RTCP) attribute in Session Description Protocol (SDP)
- rfc3890: A Transport Independent Bandwidth Modifier for the Session Description Protocol (SDP)
- rfc4145: TCP-Based Media Transport in the Session Description Protocol (SDP)
- rfc6236: Negotiation of Generic Image Attributes in the Session Description Protocol (SDP)
- Anatomy of a WebRTC SDP,
https://webrtchacks.com/sdp-anatomy/
- rfc4145: TCP-Based Media Transport in the Session Description Protocol (SDP)
- 在WebRTC中,SDP主要用来描述:
1. 设备支持的媒体能力,包括编解码器等
2. ICE候选地址
3. 流媒体传输协议
-
SIP, 会话发起协议
- rfc3261: SIP: Session Initiation Protocol
- rfc3261, rfc3264: SIP: Session Initiation Protocol
-
XMPP, 开放式实时通信协议
- rfc3921, rfc6121: Extensible Messaging and Presence Protocol (XMPP):
Instant Messaging and Presence
-
HTTP/1.1, 超文本传输协议
-
参考资料
- HTTP API 认证授权术,
https://coolshell.cn/articles/19395.html
- HTTP权威指南
- <<透视HTTP协议>>-罗剑锋
- HTTP History
- HTTP 协议始于三十年前蒂姆·伯纳斯 - 李的一篇论文;
- HTTP/0.9 是个简单的文本协议,只能获取文本资源;
- HTTP/1.0 确立了大部分现在使用的技术,但它不是正式标准;
- HTTP/1.1 是目前互联网上使用最广泛的协议,功能也非常完善;
- HTTP/2 基于 Google 的 SPDY 协议,注重性能改善,但还未普及;
- HTTP/3 基于 Google 的 QUIC 协议,是将来的发展方向。
-
RFC
- rfc2616
- rfc7230-7235
- 2014年重修修订, rfc2616拆分
-
特性
- HTTP/1.0 vs HTTP/1.1
- 增加了 PUT、DELETE 等新的方法;
- 增加了缓存管理和控制;
- 明确了连接管理,允许持久连接;
- 允许响应数据分块(chunked),利于传输大文件;
- 强制要求 Host 头,让互联网主机托管成为可能;
- 基本认证授权
- HTTP Basic
- Digest Access
- App Secret Key + HMAC
- JWT – JSON Web Tokens
- OAuth 1.0 – 3 legged & 2 legged
- OAuth 2.0 – Authentication Code & Client Credential
- 摘要认证
- Ajax, client主动发起请求数据
- 短连接(实指Tcp连接, 一次请求后关闭)
- XHR, XMLHttpRequest对象
- XMLHttpRequest Living Standard: https://xhr.spec.whatwg.org/
- 服务器Push技术
- Comet, 彗星技术
- 基于Ajax的长轮询(需要client和server配合)
- 服务器推”与传统的 AJAX?
- 服务器端会阻塞请求直到有数据传递或超时才返回
- 客户端 JavaScript 响应处理函数会在处理完服务器返回的信息后,再次发出请求,重新建立连接
- 当客户端处理接收的数据、重新建立连接时,服务器端可能有新的数据到达;
这些信息会被服务器端保存直到客户端重新建立连接,客户端会一次把当前服务器端所有的信息取回
- 基于iframe
- 基于http流
- SSE, 服务器推送事件(单向, 不支持跨域)
- 支持短轮询
- 支持长轮询
- 支持http流
- html5标准
- WebSocket, 全双工
- rfc6455: The WebSocket Protocol
- Socket.io, client端WebSocket库
- html5标准
- 一般都是长连接(Tcp keeplive)
-
HTTPS, 安全Http
HTTPS = HTTP + 加密 + 认证 + 完整性保护
-
RFC
- rfc2818: HTTP Over TLS
-
实验
- ssl测试,
https://www.ssllabs.com/ssltest/index.html
- Openssl使用
- Let's Encrypt使用,
docs, https://letsencrypt.org/zh-cn/docs/
- 免费申请证书
- nginx配置证书
- wireshark分析https
- #配置浏览器导出SSL Key
export SSLKEYLOGFILE="$HOME/keylog.log"
#wireshark中配置SSL Key
首选项->协议->TLS(Master-Secret log filename), 指定SSL Key文件路径
- chrome行为分析
- wireshark: 过滤http
chrome打开: https://http1.akamai.com/demo/h1_demo_frame.html
#证实chrome会使用大于6个tcp流访问同域网站
wireshark: 追踪流->tcp流 => http and tcp.stream eq 3 #3测试换成其他数字
- tshark分析https
- tcpdump分析https
-
参考资料
- HTTPS流程(使用证书的公钥方式)
- 图解SSL/TLS协议,
http://www.ruanyifeng.com/blog/2014/09/illustration-ssl.html
- SSL/TLS协议运行机制的概述,
http://www.ruanyifeng.com/blog/2014/02/ssl_tls.html
- SSL/TLS协议运行机制的概述,
http://www.ruanyifeng.com/blog/2014/02/ssl_tls.html
- SSL/TLS发展历史和SSLv3.0协议详解,
http://www.bewindoweb.com/271.html
-
HTTP2
-
RFC
- rfc7540: Hypertext Transfer Protocol version 2
- rfc7541: HPACK - Header Compression for HTTP/2
- rfc6797: HPACK - HTTP Strict Transport Security
-
特性
- 二进制协议,不再是纯文本
- 可发起多个请求,废弃了 1.1 里的管道
- 使用专用算法压缩头部,减少数据传输量
- 允许服务器主动向客户端推送数据
- 增强了安全性,“事实上”要求加密通信
-
实验
- wireshark分析http2
- wireshark: 过滤http2
chrome打开: https://http2.akamai.com/demo/h2_demo_frame.html
- tshark分析http2
-
参考资料
- http1.1 vs http2,
https://http2.akamai.com/demo
- HTTP2详解,
https://daniel.haxx.se/http2/
- HTTP 2.0 协议详解,
https://github.com/zqjflash/http2-protocol
- Better HTTP/2 Prioritization for a Faster Web,
https://blog.cloudflare.com/better-http-2-prioritization-for-a-faster-web/
- http2支持清单,
https://github.com/httpwg/http2-spec/wiki/Implementations
- NGINX_HTTP2_White_Paper_v4,
https://www.nginx.com/wp-content/uploads/2015/09/NGINX_HTTP2_White_Paper_v4.pdf
- 使用HTTP/2提升性能的7个建议,
https://www.w3ctech.com/topic/1563
- HTTP性能极限优化,
https://taohui.blog.csdn.net/article/details/103952639
- HTTP/2资料汇总,
https://imququ.com/post/http2-resource.html
-
HTTP3
-
RFC
- QUIC RFC: https://tools.ietf.org/html/draft-ietf-quic-transport-24
QUIC with TLS RFC: https://quicwg.org/base-drafts/draft-ietf-quic-tls.html#name-introduction
中文QUIC RFC: http://docs.wxclimb.top/draft-ietf-quic-transport-zh.html#fc-credit
- 特性
-
参考资料
- http1 vs http2 vs http3
- HTTP3详解,
https://http3-explained.haxx.se/zh/
- QUIC & HTTP/3 Support:主流浏览器和服务端对 HTTP/3 的支持情况,
https://sysin.org/article/QUIC-HTTP3-Support/
- QUIC & HTTP/3 Support:主流浏览器和服务端对 HTTP/3 的支持情况,
https://sysin.org/article/QUIC-HTTP3-Support/
- HTTP/HTTPS/HTTP2/HTTP3/QUIC/WebSocket协议详解,
https://segmentfault.com/a/1190000021390130?utm_source=tag-newest
- HTTP/3:起源,
https://github.com/xitu/gold-miner/blob/master/TODO1/http-3-from-root-to-tip.md
-
P2P内网穿透
- nat, 网络地址转换
-
stun, NAT会话穿越应用程序
-
rfc3489: STUN - Simple Traversal of User Datagram Protocol (UDP) hrough Network Address Translators (NATs)
- Binding Lifetime Discovery
- Test II checks the presence of a NAT or symmetric UDP firewall, and discovers a full cone NAT
Test I' discovers a symmetric NAT
Test III discovers a restricted con NAT or port restricted cone NAT
- Open Internet,
主机具有公网IP,允许主动发起和被动响应两种方式的UDP通信
- UDP Blocked,
位于防火墙之后,并且防火墙阻止了UDP通信
- Symmetric Firewall,
主机具有公网IP,但位于防火墙之后,且防火墙阻止了外部主机的主动UDP通信
- Full Cone NAT,
当内网主机创建一个UDP socket并通过它第一次向外发送UDP数据包时,NAT会为之分配一个固定的公网{IP:端口}。此后,通过这个socket发送的任何UDP数据包都是通过这个公网{IP:端口}发送出去的;同时,任何外部主机都可以使用这个公网{IP:端口}向该socket发送UDP数据包。即是说,NAT维护了一个映射表,内网主机的内网{IP:端口}与公网{IP:端口}是一一对应的关系。一旦这个映射关系建立起来(内部主机向某一外部主机发送一次数据即可),任何外部主机就可以直接向NAT内的这台主机发起UDP通信了,此时NAT透明化了
- Full Cone NAT
- Restricted Cone NAT,
当内网主机创建一个UDP socket并通过它第一次向外发送UDP数据包时,NAT会为之分配一个公网{IP:端口}。此后,通过这个socket向外发送的任何UDP数据包都是通过这个公网{IP:端口}发送出去的;而任何收到过从这个socket发送来的数据的外部主机(由IP标识),都可以通过这个公网{IP:端口}向该socket发送UDP数据包。即是说,NAT维护了一个内网{IP:端口}到公网{IP:端口}的映射,还维护了一个{外部主机{IP}, 公网{IP:端口}}到内网{IP:端口}的映射。因此,要想外部主机能够主动向该内部主机发起通信,必须先由该内部主机向这个外部发起一次通信
- Address Restricted Cone NAT
- Port Restricted Cone NAT,
当内网主机创建一个UDP socket并通过它第一次向外发送UDP数据包时,NAT会为之分配一个公网{IP:端口}。此后,通过这个socket向外部发送的任何UDP数据包都是通过这个公网{IP:端口}发送出去的;一旦外部主机在{IP:端口}上收到过从这个socket发送来的数据后,都可以通过这个外部主机{IP:端口}向该socket发送UDP数据包。即是说,NAT维护了一个从内网{IP:端口}到公网{IP:端口}的映射,还维护了一个从{外部主机{IP:端口}, 公网{IP:端口}}到内网{IP:端口}的映射
- Port Restricted Cone NAT
- Symmetrict NAT,
当内网主机创建一个UDP socket并通过它第一次向外部主机1发送UDP数据包时,NAT为其分配一个公网{IP1:端口1},以后内网主机发送给外部主机1的所有UDP数据包都是通过公网{IP1:端口1}发送的;当内网主机通过这个socket向外部主机2发送UDP数据包时,NAT为其分配一个公网{IP2:端口2},以后内网主机发送给外部主机2的所有UDP数据包都是通过公网{IP2:端口2}发送的。公网{IP1:端口1}和公网{IP2:端口2}一定不会完全相同(即要么IP不同,要么端口不同,或者都不同)。这种情况下,外部主机只能在接收到内网主机发来的数据时,才能向内网主机回送数据
- Symmetric NAT
-
rfc5780: NAT Behavior Discovery Using Session Traversal Utilities for NAT (STUN)
- NAT隐射方式探测
- no NAT
- 端点无关的隐射NAT
- NAT隐射方式探测
- 地址和端口相关的隐射NAT
- NAT过滤方式探测
- 端点无关的过滤NAT
- 地址相关的过滤NAT
- 地址和端口相关的过滤NAT
- rfc5389, rfc8489: Session Traversal Utilities for NAT (STUN)
- rfc5764: URI Scheme for the Session Traversal Utilities for NAT (STUN) Protocol
- rfc5769: Test Vectors for Session Traversal Utilities for NAT (STUN)
- rfc7350: Datagram Transport Layer Security (DTLS) as Transport
for Session Traversal Utilities for NAT (STUN)
- rfc7443: Application-Layer Protocol Negotiation (ALPN) Labels
for Session Traversal Utilities for NAT (STUN) Usages
- rfc7635: Session Traversal Utilities for NAT (STUN) Extension
for Third-Party Authorization
-
图例
- STUN Format,
http://www.networksorcery.com/enp/protocol/stun.htm
-
turn, 使用中继穿透NAT:
- rfc5766: Traversal Using Relays around NAT (TURN): Relay Extensions to Session Traversal Utilities for NAT (STUN)
- rfc6062: Traversal Using Relays around NAT (TURN) Extensions for TCP Allocations
- rfc6156: Traversal Using Relays around NAT (TURN) Extension for IPv6
-
ice, 交互式连接建立
-
rfc5245 rfc8445: Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols
- http://www.hiastar.com/doc/最新ICE协议-RFC5245-RFC8445-Interactive-Connectivity-Establishment-中文详解.pdf
- rfc8863: Interactive Connectivity Establishment Patiently Awaiting Connectivity(ICE PAC)
- rfc6336: IANA Registry for Interactive Connectivity Establishment (ICE) Options
-
trickle ice, 缓慢型ice
- rfc8838: Trickle ICE: Incremental Provisioning of Candidates for the Interactive Connectivity Establishment (ICE) Protocol
-
mDNS, 多播DNS
- rfc6762: Multicast DNS
-
Tools
- Trickle ICE⬇
https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
- 测试NAT外网端口是否开放⬇
http://canyouseeme.org/
- //stun客户端go-stun⬇
go get github.com/ccding/go-stun
go-stun -vvv -s stun.stunprotocol.org:3478
------------------------------------------------
curl -L ip.tool.lu
-
参考资料
- NAT Behavioral Requirements, as Defined by the IETF (RFC 4787) - Part 1. Mapping Behavior⬇
https://netmanias.com/en/?m=view&id=techdocs&tag=248&no=6058
- NAT Behavioral Requirements, as Defined by the IETF (RFC 4787) - Part 2. Filtering Behavior⬇
https://netmanias.com/en/?m=view&id=techdocs&tag=248&no=6062
- nat-behavior-discovery-using-stun-rfc-5780⬇
https://www.netmanias.com/en/post/techdocs/6067/nat-network-protocol/nat-behavior-discovery-using-stun-rfc-5780
- STUN (RFC 3489) vs. STUN (RFC 5389/5780)⬇
https://netmanias.com/en/?m=view&id=techdocs&no=6065&xtag=nat-network-protocol&xref=stun-rfc-3489-vs-stun-rfc-5389-5780
- stun协议解析⬇
https://blog.csdn.net/momo0853/article/details/105387675
-
传输层安全性协议
-
SSL/TLS, 安全套接层/传输层安全性协议
- rfc2246: The TLS Protocol Version 1.0
- rfc4346: The Transport Layer Security (TLS) Protocol Version 1.1
- rfc5246: The Transport Layer Security (TLS) Protocol Version 1.2
- rfc5746: Transport Layer Security (TLS) Renegotiation Indication Extension
- rfc8446: The Transport Layer Security (TLS) Protocol Version 1.3
- rfc7507: TLS Fallback Signaling Cipher Suite Value (SCSV)
for Preventing Protocol Downgrade Attacks
-
图例
-
参考资料
- TLS协议分析 与 现代加密通信协议设计,
https://blog.helong.info/blog/2015/09/06/tls-protocol-analysis-and-crypto-protocol-design/
- TLS 握手优化详解,
https://imququ.com/post/optimize-tls-handshake.html
-
DTLS, 数据包安全性协议
- rfc4347: Datagram Transport Layer Security
- rfc5763: Framework for Establishing a Secure Real-time Transport Protocol (SRTP) Security Context Using Datagram Transport Layer Security (DTLS)
- rfc5764: Datagram Transport Layer Security (DTLS) Extension to Establish Keys
for the Secure Real-time Transport Protocol (SRTP)
- rfc6347: Datagram Transport Layer Security Version 1.2
- handshake over DTLS
-
编解码
- rfc67874: WebRTC Audio Codec and Processing Requirements
- rfc6716: Definition of the Opus Audio Codec
- rfc6386: VP8 Data Format and Decoding Guide
-
WebRTC安全
- rfc7675: Session Traversal Utilities for NAT (STUN) Usage for Consent Freshness
- rfc8826: Security Considerations for WebRTC
- rfc8827: WebRTC Security Architecture
-
参考资料
- about-crypto,
https://gitee.com/yejinlei/about-crypto
-
其他
- rfc8825: Overview: Real-Time Protocols for Browser-Based Applications
- rfc8835: Transports for WebRTC
-
工具
- netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
- tshark -i lo -d tcp.port==8085,http
- strace -k -fp 6 -e trace=network,close,shutdown,rename
- by yejinlei
-
WebRTC相关资料
- WebRTC 1.0: Real-Time Communication Between Browsers,
https://www.w3.org/TR/webrtc/#intro
- WebRTC权威指南
- Get Started with WebRTC,
https://www.html5rocks.com/en/tutorials/webrtc/basics/#toc-disruptive
-
WebRTC Trace
- https://nashaofu.github.io/webrtc-demo/
-
WebRTC Next
- WebRTC 的现状和将来:专访 W3C WebRTC Chair Bernard Aboba, https://webrtchacks.com/webrtc-today-tomorrow-bernard-aboba-qa/
-
Scheme
-
AppRTC
-
知识储备
- Ndoejs/npm/express/websocket
- JS/Grunt
- Python
- Golang
- Nginx
- SimpleWebRTC
-
Licode
- nuve.js
- cloudHandler.js
- mdb数据库操作
-
resoucre
- room管理
- user管理
- service管理
- token管理
- rpc远程调用, mq通讯
-
erizo_controller信令服务
-
erizoController
- erizoController.js, 简称EC
- ./models/Room.js房间管理
- ./models/Client.js客户端管理
- ./models/Stream.js流管理
- ecCloudHandler.js
- nuveProxy.js
- rpc远程调用,mq通讯
-
ROV
- rovMetricsServer.js,指标
-
erizoAgent.js, 简称EA
initErizo_agent.sh or /initDockerLicode.sh通过node启动,按Agent调度
-
erizoJS.js
通过lunch.sh来启动进程1:N(N配置指定)
- 加载addon
-
erizo媒体服务, MCU/SFU实现
- class MediaStream
- class DtlsTransport
- class IceConnection
- class NicerConnection
//使用lynckia/nICEr
- class OneToManyProcessor
- class SdpInfo
- class SrtpChannel
- class Stats
- class WebRtcConnection
- media
- pipeline
- rtp
- stats
- thread
- RabbitMQ消息中间件
- MongoDB数据库
-
FAQ
- //Nodejs C++插件, 文档http://nodejs.cn/api/addons.html
grep -nr 'NODE_MODULE'
grep -nr 'addon ='|grep require
-
spine, WebRTC API封装
- Spine.js, JavaScript的MVC框架
- Client <= erizoClient
-
知识储备
- Ndoejs/npm/c++ plug编写/Socker.io/Express/Spine/JS
- C++/Conan
- MQ消息中间件
- MongoDB数据库
-
Jitsi
- 演示,
https://meet.jit.si/
-
Janus
- 演示,
https://janus.conf.meetecho.com/videoroomtest.html
-
MediaSoup
- 演示,
https://v3demo.mediasoup.org/
-
OpenVidu/Kurento
- 演示,
https://www.egv.me/#/hx2021
-
FAQ
-
如果信令服务器为scheme外的独立服务器
- 可以通过Nginx实现主备容灾和负载均衡
- 如果信令服务器作为scheme的一部分,例如licode,由其自己负载实现
- //带宽测试
iperf3 -s
iperf3 -c server_ip
-
开源项目
- libnice⬇
https://gitlab.freedesktop.org/libnice/libnice/
- lynckia/nICEr⬇
https://github.com/lynckia/nicer
- go-stun⬇
https://github.com/ccding/go-stun
- pjproject⬇
https://github.com/pjsip/pjproject
- jitsi/turnserver⬇
https://github.com/jitsi/turnserver
- coturn/coturn⬇
https://github.com/coturn/coturn
- gortc/gortcd⬇
https://github.com/gortc/gortcd
- pion⬇
https://pion.ly/
- webrtc.rs⬇
https://webrtc.rs/
-
WebRTC API
-
web api
- 参考规范: rfc8829
---
WebRTC 1.0: Real-Time Communication Between Browsers,
API doc, https://www.w3.org/TR/webrtc/
---
Web API 接口参考, https://developer.mozilla.org/zh-CN/docs/Web/API
---
Demos, https://webrtc.github.io/samples/
---
Source, https://github.com/webrtc/samples
- 有关Javsscript, Browser, Nodejs
- adapter.js,
https://github.com/Temasys/AdapterJS
-
devices
- Choose camera, microphone and speaker
- Choose media source and audio output
-
getusermedia
- getUserMedia
-
Basic getUserMedia demo
- const constraints = window.constraints = {
audio: false,
video: true
};
//使用getUserMedia函数,传入constraints约束
navigator.mediaDevices.getUserMedia(constraints);
document.querySelector('#showVideo').addEventListener('click', e => init(e));
-
Use getUserMedia with canvas
- const video = document.querySelector('video');
const canvas = window.canvas = document.querySelector('canvas');
canvas.width = 480;
canvas.height = 360;
const button = document.querySelector('button');
button.onclick = function() {
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
//使用drawImage函数,传入video对象来截图
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
};
const constraints = {
audio: false,
video: true
};
function handleSuccess(stream) {
window.stream = stream; // make stream available to browser console
video.srcObject = stream;
}
function handleError(error) {
console.log('navigator.MediaDevices.getUserMedia error: ', error.message, error.name);
}
navigator.mediaDevices.getUserMedia(constraints).then(handleSuccess).catch(handleError);;
-
Use getUserMedia with canvas and CSS filters
- video.className = filterSelect.value;
-
Choose camera resolution
- //选择分辨率
const qvgaConstraints = {
video: {width: {exact: 320}, height: {exact: 240}}
};
navigator.mediaDevices.getUserMedia(qvgaConstraints)
- Audio-only getUserMedia() output to local audio element
- Audio-only getUserMedia() displaying volume
- Record stream
- Screensharing with getDisplayMedia
- Control camera pan, tilt, and zoom
-
datachannel
- Transmit text
- Transfer a file
- Transfer data
- Messaging
-
capture
- Stream from a video element to a video element
- Stream from a video element to a peer connection
- Stream from a canvas element to a video element
- Stream from a canvas element to a peer connection
- Record a stream from a canvas element
- Guiding video encoding with content hints
-
peerconnection
-
state-definitions, 状态定义
- signaling状态
- RTCSignalingState
- RTCPeerConnection连接状态
- ice收集状态
- ice连接状态
- RTCIceConnectionState
- Basic peer connection demo
- Peer connection using Perfect Negotiation
- Audio-only peer connection demo
- Change bandwidth on the fly
- Change codecs before the call
- Upgrade a call and turn video on
- Multiple peer connections at once
- Forward the output of one PC into another
- Munge SDP parameters
- Use pranswer when setting up a peer connection
- Constraints and stats
- More constraints and stats
- Display createOffer output for various scenarios
- Use RTCDTMFSender
- Display peer connection states
- ICE candidate gathering from STUN/TURN servers
- Do an ICE restart
- Web Audio output as input to peer connection
- Peer connection as input to Web Audio
- Measure how long renegotation takes
- extensions
-
insertable-streams
- End to end encryption using WebRTC Insertable Streams
- Video analyzer using WebRTC Insertable Streams
- Video processing using MediaStream Insertable Streams
- Audio processing using MediaStream Insertable Streams
-
其他
- signaling getway
-
native api
- 架构
-
VIdeo Capture
- VideoCaptureModuleV4L2
- v4l2 framework
- Video for Linux Two API Specification,
http://v4l.videotechnology.com/dwg/v4l2.html
- Audio Capture/Render
- Network I/O
- 网址
https://tools.ietf.org/html/[rfc]
http://www.networksorcery.com/enp/protocol/[rtp].htm