一、Usage用法1。使用GoModulesGoModulesaremandatoryforusingPionWebRTC。SomakesureyousetexportGO111MODULEon,andexplicitlyspecifyv2orv3whenimporting。2。常见示例exampleapplicationscontainscodesamplesofcommonthingspeoplebuildwithPionWebRTC。3。更多示例examplewebrtcapplicationscontainsmorefullfeaturedexamplesthatuse3rdpartylibraries。4。真实案例awesomepioncontainsprojectsthathaveusedPion,andserveasrealworldexamplesofusage。5。GoDocGoDocisanautogeneratedAPIreference。AllourPublicAPIsarecommented。6。FAQFAQhasanswerstocommonquestions。IfyouhaveaquestionnotcoveredpleaseaskinSlackwearealwayslookingtoexpandit。7。我还没搞清这些特性有没有实现Nowgobuildsomethingawesome!Herearesomeideastogetyourcreativejuicesflowing:Sendavideofiletomultiplebrowserinrealtimeforperfectlysynchronizedmoviewatching。Sendawebcamonanembeddeddevicetoyourbrowserwithnoadditionalserverrequired!Securelysenddatabetweentwoservers,withoutusingpubsub。Recordyourwebcamanddospecialeffectsserverside。Buildaconferencingapplicationthatprocessesaudiovideoandmakedecisionsoffofit。Remotelycontrolarobotsandstreamitscamerasinrealtime。 【腾讯文档】FFmpegWebRTCRTMPRTSPHLSRTP播放器音视频流媒体高级开发资料领取 FFmpegWebRTCRTMPRTSPHLSRTP鎾斁鍣闊宠棰戞祦濯掍綋楂樼骇寮鍙璧勬枡棰嗗彇二、Features特性1。PeerConnectionAPIGoimplementationofwebrtcpcandwebrtcstatsDataChannelsSendReceiveaudioandvideoRenegotiation重连??PlanBandUnifiedPlanSettingEngineforPionspecificextensions2。ConnectivityFullICEAgentICERestartTrickleICE??STUNTURN(UDP,TCP,DTLSandTLS)mDNScandidates3。DataChannelsOrderedUnordered有序无序LossyLossless有损无损4。MediaAPIwithdirectRTPRTCPaccessOpus,PCM,H264,VP8andVP9packetizerAPIalsoallowsdevelopertopasstheirownpacketizerIVF,Ogg,H264andMatroskaprovidedforeasysendingandsavinggetUserMediaimplementation(RequiresCgo)Easyintegrationwithx264,libvpx,GStreamerandffmpeg。SimulcastSFU的概念SVCSFU的概念NACK断线重连??Fulllossrecoveryandcongestioncontrolisnotcomplete,seepioninterceptorforprogressSeeionforhowanimplementorcandoittoday5。SecurityTLSECDHEECDSAWITHAES128GCMSHA256andTLSECDHEECDSAWITHAES256CBCSHAforDTLSv1。2SRTPAEADAES256GCMandSRTPAES128CMHMACSHA180forSRTPHardwareaccelerationavailableforGCMsuites三、Samples1。使用gorunexamples。go启动webserver,然后打开127。0。0。1:8080 2。部分示例需要复制浏览器的SDP,手动生成Go服务器的SDP再复制回来 3。LinuxmacOS参照readmeRunechoBROWSERSDPinsertablestreams 个人推测,有可能是Go的环境变量没配置好,有点麻烦4。Windows参照readmePastetheSessionDescriptionintoafile。Runinsertablestreamsmyfile使用powershell不行 使用Cmd是可以的 将生成的SDP复制到Golangbase64SessionDescription即可连接四、ION ION的来由和发展https:zhuanlan。zhihu。comp206492402IONSFU整体流程https:zhuanlan。zhihu。comp258559751五、源码阅读 https:github。com63isOKpionlog 说明:粉底是第三方库,天蓝底是pion的库红色框中的randutiltestifylogging,是基础库,很多库都依赖这3个库 分析:核心都是以xnet库为中心,一步步扩展直接依赖xnet的有4个库,transportmdnsicedtls其中mdnsicedtls都依赖transportice依赖dtlsmdns总的来说。ice依赖mdnsdtls,她们都依赖transport依赖xnet的库,要么使用了网络连接,要么使用了网络工具库的功能transport作为传输对象的封装,有以下库使用quic,quic协议的实现dtls,udp安全传输协议的实现srtp,安全rtp传输协议的实现ice,p2p连接解决方案的实现turn,p2p中继协议的实现mdns,多播dns协议的实现datachannelsctp,webrtc数据传输通道的实现transport作为传输对象的封装,屏蔽了底层网络传输细节让webrtc上层诸多传输协议复用,大大提高了效率按webrtc功能分datachannelsctp对应webrtcdatachannelsrtprtprtcp对应webrtc媒体数据的传输ice对应p2p连通性解决方案dlts对应udp安全传输 源码阅读顺序:基础公共库randutiltestifylogging基础库xnettransportdtlsp2pstunturnicertprtprtcpsrtpinterceptorsdp其他功能mdnsdatachannelsctpagoutilquic