webrtc c++(三) peerConnection分析

peerconnection是webrtc面向外面的音视频交互的统一接口,可以理解为一个功能特别强大的socket接口,里面保存了实时交互的所有信息,同时音视频的转发与接收也是通过peerconnection来完成

1 peerconnection 概述

peerconnection继承自PeerConnectionInterface 接口,所以作为对外暴露的统一接口为PeerConnectionInterface,通过工厂方法来通过统一创建PeerConnectionInterface 来创建peerconnection,在peerConnection.h中,// It uses WebRtcSession to implement the PeerConnection functionality. 说明了,webRtcSession类的重要

webrtc c++(三) peerConnection分析_第1张图片

2 peerconnection类简要分析

  rtc::scoped_refptr factory_; //创建工厂
  PeerConnectionObserver* observer_;    //回调观察者,一般在外部类创建成功时,传入this指针,在示例中是Conductor,方便时间回调
  UMAObserver* uma_observer_; //暂时不清楚
  SignalingState signaling_state_; // signal slot相关
  // TODO(bemasc): Remove ice_state_.
  IceState ice_state_;    //ice状态
  IceConnectionState ice_connection_state_;//ice链接状态(相当于ice_state_的子状态的一个状态)
  IceGatheringState ice_gathering_state_;//ice 收集状态(相当于ice_state_的子状态的一个状态)

  std::unique_ptr port_allocator_;//sdp相关?
  std::unique_ptr media_controller_;//媒体控制相关

  // One PeerConnection has only one RTCP CNAME.
  // https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9
  std::string rtcp_cname_;

  // Streams added via AddStream.
  rtc::scoped_refptr local_streams_;//本地stream管理
  // Streams created as a result of SetRemoteDescription.
  rtc::scoped_refptr remote_streams_;//远端stream管理

  std::vector> stream_observers_;

  // These lists store track info seen in local/remote descriptions.
  TrackInfos remote_audio_tracks_;
  TrackInfos remote_video_tracks_;
  TrackInfos local_audio_tracks_;
  TrackInfos local_video_tracks_;

  SctpSidAllocator sid_allocator_;//暂不清楚
  // label -> DataChannel
  std::map> rtp_data_channels_;//数据通道
  std::vector> sctp_data_channels_;
  std::vector> sctp_data_channels_to_free_;

  bool remote_peer_supports_msid_ = false;

  std::vector>>
      senders_;
  std::vector<
      rtc::scoped_refptr>>
      receivers_;

  std::unique_ptr session_; //session管理类
  std::unique_ptr stats_;

 

你可能感兴趣的:(webrtc,c++)