zoukankan      html  css  js  c++  java
  • licode_WebrtcConnection

    WebrtcConnection

    1. 概要说明

    WebrtcConnection 是erizo进行Webrtc交互的基础类. 每一个PeerConnection 会创建一个WebrtcConnection.

    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<RtpMap> rtp_mappings_; //支持的RtpMap,生成sdp使用
      RtpExtensionProcessor extension_processor_; //支持的extension_processor,生成sdp使用
      boost::condition_variable cond_;  //没看到wait,只有notify,应该是被废弃的变量
      std::shared_ptr<Transport> video_transport_, audio_transport_; //视频数据链路,音频数据链路
      std::shared_ptr<Stats> stats_; //输出状态
      WebRTCEvent global_state_; //webrtc事件状态枚举
      boost::mutex update_state_mutex_; //
      boost::mutex event_listener_mutex_;
      std::shared_ptr<Worker> worker_; 
      std::shared_ptr<IOWorker> io_worker_;
      std::vector<std::shared_ptr<MediaStream>> media_streams_; //这个connection使用的流
      std::shared_ptr<SdpInfo> remote_sdp_; //对端的sdp
      std::shared_ptr<SdpInfo> local_sdp_; //本地的sdp
      bool audio_muted_; //应该是残留或者扩展,没看到有用
      bool video_muted_; //应该是残留或者扩展,没看到有用
      bool first_remote_sdp_processed_; //是否第一次处理sdp标识
      std::unique_ptr<BandwidthDistributionAlgorithm> distributor_; //remb码率估计处理  (REMB (Receiver Estimated Maximum Bitrate) )
    

    WebrtcConnection主要控制的有链路transport,交互local_sdp remote_sdp, ice控制,事件监听回调,数据流media_streams。

    交互之主动发起流程:

    交互之被动呼叫流程

    2. WebRTCEvent(WebrtcConnection的回调)

    enum WebRTCEvent {
      CONN_INITIAL = 101,  //WebrtcConnection对象创建后,需要外面手动调用init方法,该方法会回调notifyEvent,并传递事件为改枚举值,message和stream_id均为空值。
      CONN_STARTED = 102, //这个状态没有看到里面有明显调用的地方,有可能是保留的状态码
      CONN_GATHERED = 103, //WebrtcConnection的createOffer或者第一次setRemoteSdp时启动自身ICE过程,ICE完成收集时,发送该通知。message为自己的sdp数据
      CONN_READY = 104,  //当DTLS握手交互成功完成时,发送该通知
      CONN_FINISHED = 105, //WebrtcConnection对象关闭,调用close时,发送该通知
      CONN_CANDIDATE = 201, //自身ICE获取到Candidate时,发送该通知。message为candidate信息
      CONN_SDP = 202, //没有被使用
      CONN_SDP_PROCESSED = 203, //处理remote sdp时,发送该通知。message为remote sdp
      CONN_FAILED = 500 //:ICE失败,Dtls握手交互失败,均发送该通知。message为remote sdp
    };
    

    1. 主动发送offer

    1. webrtcconnection createOffer
    2. CONN_GATHERED时,发送sdp给client
    3. CONN_CANDIDATE时,发送candidate给client
    4. 接收到answer,调用webrtcconnection setRemoteSdp
    5. 接收到candidate,调用webrtcconnection addRemoteCandidate
    6. CONN_SDP_PROCESSED时,做私有处理
    7. CONN_FAILED时,进行重试,或者其他异常处理

    2. 被动接收offer

    1. 接收到answer,调用webrtcconnection setRemoteSdp
    2. 接收到candidate,调用webrtcconnection addRemoteCandidate
    3. CONN_GATHERED时,发送sdp给client
    4. CONN_CANDIDATE时,发送candidate给client
    5. CONN_FAILED时,进行重试,或者其他异常处理

    2. WebrtcConnection的Transport

    网络链路处理,其包含ice处理,数据包packet处理传递。

    erizo提供了两套ICE的方案,分别使用不同的ice库,可以再iceconfig参数里进行设置。

  • 相关阅读:
    linux grep (转)
    移除NDK方法
    Android Studio 中 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileDebugAidl'.的问题解答
    [Android] 环境配置之基础开发环境(SDK/Android Studio)(转)
    Rendering Problems: No Android SDK found. Please configure an Android SDK. 怎解决?
    Android Xutils 框架(转)
    Android Studio 简单设置
    Android笔记——Windows环境下Android Studio v1.0安装教程
    Android Studio使用教程(二)
    Android Studio使用教程(一)(转)
  • 原文地址:https://www.cnblogs.com/WillingCPP/p/13631991.html
Copyright © 2011-2022 走看看