博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
licode学习之erizo篇--WebrtcConnection
阅读量:4521 次
发布时间:2019-06-08

本文共 3316 字,大约阅读时间需要 11 分钟。

WebrtcConnection是erizo进行Webrtc交互的基础类

其主要成员有如下:

std::string connection_id_; //唯一的ID  bool audio_enabled_; //如果主动发起请求,被createOffer函数赋值,否则被processRemote赋值,表示是否有音频交互  bool video_enabled_; //表示是否有视频交互  bool trickle_enabled_; //启用ice的trickle模式  bool slide_show_mode_; //没有用,应该是留作扩展或者是以前版本的残留  bool sending_;//发送数据开关  int bundle_;//ice 使用,是否使用合并端口收发数据  WebRtcConnectionEventListener* conn_event_listener_; //webrtc连接事件监听  IceConfig ice_config_;//ice配置  std::vector
rtp_mappings_; //支持的RtpMap,生成sdp使用 RtpExtensionProcessor extension_processor_; //支持的extension_processor,生成sdp使用 boost::condition_variable cond_; //没看到wait,只有notify,应该是被废弃的变量 std::shared_ptr
video_transport_, audio_transport_; //视频数据链路,音频数据链路 std::shared_ptr
stats_; //输出状态 WebRTCEvent global_state_; //webrtc事件状态枚举 boost::mutex update_state_mutex_; // boost::mutex event_listener_mutex_; std::shared_ptr
worker_; std::shared_ptr
io_worker_; std::vector
> media_streams_; //这个connection使用的流 std::shared_ptr
remote_sdp_; //对端的sdp std::shared_ptr
local_sdp_; //本地的sdp bool audio_muted_; //应该是残留或者扩展,没看到有用 bool video_muted_; //应该是残留或者扩展,没看到有用 bool first_remote_sdp_processed_; //是否第一次处理sdp标识 std::unique_ptr
distributor_; //remb码率估计处理

从成员可以看出,webrtcconnection,主要控制的有链路transport,交互local_sdp remote_sdp, ice控制,事件监听回调,数据流media_streams。

先看交互流程

交互之主动发起流程:

 

交互之被动呼叫流程

 

提供一个webrtc终端(手机,谷歌浏览器,iphone)主动发起offer的例子

#include 
#include
#include
using namespace erizo;class SendOfferEvtListener : public WebRtcConnectionEventListener{public: void notifyEvent(WebRTCEvent newEvent, const std::string& message, const std::string &stream_id) { switch (newEvent) { case CONN_GATHERED: std::string sdp = message; //send answer to the client break; } };};std::shared_ptr
webrtcConn = nullptr;std::string remote_sdp;//webrtc client send offer, and erizo send answervoid user_offer_sample_start() { std::shared_ptr
workerPool = std::make_shared
(2); std::shared_ptr
ioPool = std::make_shared
(2); std::string connid = "1"; IceConfig cfg;//you may need init the cfg value std::vector
rtp_mappings;//you may need to init the mappings std::vector
ext_mappings; //you may need to init the ext mappings WebRtcConnectionEventListener* listener = new SendOfferEvtListener; webrtcConn = std::make_shared
(workerPool->getLessUsedWorker(), ioPool->getLessUsedIOWorker(), connid, cfg, rtp_mappings, ext_mappings, listener);}void user_offer_sample_recv_answer(const std::string& answerSdp) { webrtcConn->setRemoteSdp(answerSdp); remote_sdp = answerSdp;}void user_offer_sample_recv_candidate(const std::string& candidate) { //parse candidate std::string mid; //parse from candidate int mLineIndex; //parse from candidate std::string cand; //parse from candidate const std::string sdp = remote_sdp; sdp += "\r\na="; sdp += cand; webrtcConn->addRemoteCandidate(mid, mLineIndex, sdp);}

 

总结:erizo的webrtcconnection,其封装的交互流程,主要依托于webrtc的标准交互:offer,candidate,answer来进行。整体流程需要根据ice的相关事件进行驱动,实际上是程序控制与ice状态的双重驱动控制。

 

转载于:https://www.cnblogs.com/limedia/p/licode_erizo_webrtcconnection.html

你可能感兴趣的文章
sql查询结果转XML和JSON
查看>>
正确代码 = =
查看>>
OpenCV入门学习资料汇总
查看>>
一款比较好用的JS时间控件-laydate
查看>>
vim分屏功能总结
查看>>
win7/8 访问 访问局域网 默认加载域 而无法成功访问的问题
查看>>
Centos 设置时区
查看>>
四款汤专治手脚冰凉
查看>>
UVA 1362 Exploring Pyramids 区间DP
查看>>
XJTUOJ wmq的A×B Problem FFT/NTT
查看>>
BZOJ 1042: [HAOI2008]硬币购物 容斥+背包
查看>>
常用yum命令小结
查看>>
div+CSS浏览器兼容问题整理
查看>>
Cesium demo
查看>>
FIFO先进先出,FILO先进后出
查看>>
温顾知新系列-JAVA网络编程系统(1)- 流
查看>>
常见对称加密算法
查看>>
2018-2019-1 20165320 20165325 20165337 实验一 开发环境的熟悉
查看>>
HTML5 学习
查看>>
2018服务端架构师技术图谱
查看>>