WebRTC学习笔记七 pion/webrtc

一、Usage用法

1.使用Go Modules

Go Modules are mandatory for using Pion WebRTC. So make sure you set export GO111MODULE=on, and explicitly specify /v2 or /v3 when importing.

2.常见示例

example applications contains code samples of common things people build with Pion WebRTC.

3.更多示例

example-webrtc-applications contains more full featured examples that use 3rd party libraries.

4.真实案例

awesome-pion contains projects that have used Pion, and serve as real world examples of usage.

5.GoDoc

GoDoc is an auto generated API reference. All our Public APIs are commented.

6.FAQ

FAQ has answers to common questions. If you have a question not covered please ask in Slack we are always looking to expand it.

7.我还没搞清这些特性有没有实现……

Now go build something awesome! Here are some ideas to get your creative juices flowing:

Send a video file to multiple browser in real time for perfectly synchronized movie watching. Send a webcam on an embedded device to your browser with no additional server required! Securely send data between two servers, without using pub/sub. Record your webcam and do special effects server side. Build a conferencing application that processes audio/video and make decisions off of it. Remotely control a robots and stream its cameras in realtime.

二、Features特性

1.PeerConnection API

  • Go implementation of webrtc-pc and webrtc-stats

  • DataChannels

  • Send/Receive audio and video

  • Renegotiation 重连??

  • Plan-B and Unified Plan

  • SettingEngine for Pion specific extensions

2.Connectivity

  • Full ICE Agent

  • ICE Restart

  • Trickle ICE ??

  • STUN

  • TURN (UDP, TCP, DTLS and TLS)

  • mDNS candidates

3.DataChannels

  • Ordered/Unordered 有序/无序

  • Lossy/Lossless 有损/无损

4.Media

  • API with direct RTP/RTCP access

  • Opus, PCM, H264, VP8 and VP9 packetizer

  • API also allows developer to pass their own packetizer

  • IVF, Ogg, H264 and Matroska provided for easy sending and saving

  • getUserMedia implementation (Requires Cgo)

  • Easy integration with x264, libvpx, GStreamer and ffmpeg.

  • Simulcast SFU的概念

  • SVC SFU的概念

  • NACK 断线重连??

  • Full loss recovery and congestion control is not complete, see pion/interceptor for progress

  • See ion for how an implementor can do it today

5.Security

  • TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 and TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA for DTLS v1.2

  • SRTP_AEAD_AES_256_GCM and SRTP_AES128_CM_HMAC_SHA1_80 for SRTP

  • Hardware acceleration available for GCM suites

【学习地址】:

FFmpeg/WebRTC/RTMP/NDK/Android音视频流媒体高级开发
【文章福利】:

免费领取更多音视频学习资料包、大厂面试题、技术视频和学习路线图,资料包括(C/C++,Linux,FFmpeg webRTC rtmp hls rtsp ffplay srs 等等)有需要的可以点击1079654574加群领取哦~

WebRTC学习笔记七 pion/webrtc_第1张图片

WebRTC学习笔记七 pion/webrtc_第2张图片  

三、Samples

1.使用go run examples.go启动webserver,然后打开127.0.0.1:8080

WebRTC学习笔记七 pion/webrtc_第3张图片

2.部分示例需要复制浏览器的SDP,手动生成Go服务器的SDP再复制回来

WebRTC学习笔记七 pion/webrtc_第4张图片

3.Linux/macOS参照readme

Run echo $BROWSER_SDP | insertable-streams

WebRTC学习笔记七 pion/webrtc_第5张图片

个人推测,有可能是Go的环境变量没配置好,有点麻烦……

4.Windows参照readme

  • Paste the SessionDescription into a file.

  • Run

    insertable-streams < my_file

    WebRTC学习笔记七 pion/webrtc_第6张图片

    使用power shell不行

WebRTC学习笔记七 pion/webrtc_第7张图片

使用Cmd是可以的

将生成的SDP复制到Golang base64 Session Description即可连接

四、ION

ION的来由和发展https://zhuanlan.zhihu.com/p/206492402 ION-SFU整体流程https://zhuanlan.zhihu.com/p/258559751

五、源码阅读

https://github.com/63isOK/pion-log

WebRTC学习笔记七 pion/webrtc_第8张图片

说明:

  • 粉底是第三方库,天蓝底是pion的库

  • 红色框中的randutil/testify/logging,是基础库,很多库都依赖这3个库

分析:

  • 核心都是以x/net库为中心,一步步扩展

  • 直接依赖x/net的有4个库,transport/mdns/ice/dtls

    • 其中mdns/ice/dtls都依赖transport

    • ice依赖dtls/mdns

    • 总的来说.ice依赖mdns/dtls,她们都依赖transport

    • 依赖x/net的库,要么使用了网络连接,要么使用了网络工具库的功能

  • transport作为传输对象的封装,有以下库使用

    • quic, quic协议的实现

    • dtls, udp 安全传输协议的实现

    • srtp, 安全rtp传输协议的实现

    • ice, p2p连接解决方案的实现

    • turn, p2p中继协议的实现

    • mdns, 多播dns协议的实现

    • datachannel/sctp, webrtc数据传输通道的实现

    • transport作为传输对象的封装,屏蔽了底层网络传输细节

      • 让webrtc上层诸多传输协议复用,大大提高了效率

  • 按webrtc功能分

    • datachannel/sctp 对应webrtc datachannel

    • srtp/rtp/rtcp 对应webrtc媒体数据的传输

    • ice 对应p2p连通性解决方案

    • dlts 对应udp安全传输

源码阅读顺序:

  • 基础公共库

    • randutil

    • testify

    • logging

  • 基础库

    • x/net

    • transport

    • dtls

  • p2p

    • stun/turn

    • ice

  • rtp

    • rtp/rtcp/srtp

    • interceptor

  • sdp

  • 其他功能

    • mdns

    • datachannel/sctp

    • agoutil

    • quic

你可能感兴趣的:(音视频开发,编程,程序员,webrtc,学习,ffmpeg)