PeerConnection

1.PeerConnectionFactory的创建
  • proxy.h 通过宏定义了一些模板类
  • peer_connection_factory_proxy.h和peer_connection_proxy.h使用proxy.h中定义的宏,组装了对应的模板代理类,并通过typedef指定了代理的类型,以PeerConnectionFactory为例进行说明:
template <class INTERNAL_CLASS> class PeerConnectionFactoryProxyWithInternal;
typedef PeerConnectionFactoryProxyWithInternal<PeerConnectionFactoryInterFace> PeerConnectionFactoryProxy;
  • 使用PeerConnectionFactoryProxyWithInternal模板类中的静态方法Create来创建代理类对象PeerConnectionFactoryProxyWithInternal。
PeerConnectionFactoryProxy::Create(pc_factory->signaling_thread(),
                                            pc_factory);
static rtc::scoped_refptr<c##ProxyWithInternal> Create(rtc::Thread* signaling_thread, INTERNAL_CLASS* c) {
    return new rtc::RefCountedObject<PeerConnectionFactoryProxyWithInternal>(signaling_thread,  c); 
}

说明:
rtc::RefCountedObject是继承PeerConnectionFactoryProxyWithInternal的类,增加了引用计数功能;
通过宏定义来组装一个模板类的声明,模板类的类型为所要代理的类型,通过静态的Create方法来创建模板类,Create中的最后一个参数为要代理的类型的实例。

2.PeerConnection功能
  virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams() = 0;
  virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams() = 0;
  
  virtual bool AddStream(MediaStreamInterface* stream) = 0;
  virtual void RemoveStream(MediaStreamInterface* stream) = 0;
  
  virtual RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(rtc::scoped_refptr<MediaStreamTrackInterface> track,const std::vector<std::string>& stream_ids) = 0;
  virtual bool RemoveTrack(RtpSenderInterface* sender) = 0;
  virtual RTCError RemoveTrackNew(rtc::scoped_refptr<RtpSenderInterface> sender);
  
  virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>  AddTransceiver(rtc::scoped_refptr<MediaStreamTrackInterface> track) = 0;
  virtual rtc::scoped_refptr<RtpSenderInterface> CreateSender(const std::string& kind,const std::string& stream_id) = 0;
  virtual std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders() const = 0;
  virtual std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers() const = 0;
  virtual std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>  GetTransceivers() const = 0;
  
  virtual bool GetStats(StatsObserver* observer, MediaStreamTrackInterface* track, StatsOutputLevel level) = 0;
  virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(const std::string& label,const DataChannelInit* config) = 0;
  
  virtual const SessionDescriptionInterface* local_description() const = 0;
  virtual const SessionDescriptionInterface* remote_description() const = 0;
  virtual const SessionDescriptionInterface* current_local_description()const = 0;
  virtual const SessionDescriptionInterface* current_remote_description()      const = 0;
  virtual const SessionDescriptionInterface* pending_local_description()      const = 0;
  virtual const SessionDescriptionInterface* pending_remote_description()      const = 0;
  
  virtual void RestartIce() = 0;
  
  virtual void CreateOffer(CreateSessionDescriptionObserver* observer,  const RTCOfferAnswerOptions& options) = 0;
  virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,  const RTCOfferAnswerOptions& options) = 0;
  
  virtual void SetLocalDescription(SetSessionDescriptionObserver* observer,  SessionDescriptionInterface* desc) = 0;
  virtual void SetRemoteDescription(SetSessionDescriptionObserver* observer,  SessionDescriptionInterface* desc) {}
  
  virtual PeerConnectionInterface::RTCConfiguration GetConfiguration() = 0;  
  virtual RTCError SetConfiguration(const PeerConnectionInterface::RTCConfiguration& config); 
  
  virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0; 
  virtual bool RemoveIceCandidates( const std::vector<cricket::Candidate>& candidates) = 0;
  
  virtual RTCError SetBitrate(const BitrateSettings& bitrate);
  
  virtual void SetAudioPlayout(bool playout) {}  
  virtual void SetAudioRecording(bool recording) {}
  
  virtual rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(const std::string& mid) = 0;
  virtual rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport()const = 0;
  
  virtual SignalingState signaling_state() = 0;
  virtual IceConnectionState ice_connection_state() = 0;
  virtual IceConnectionState standardized_ice_connection_state() = 0;
  virtual PeerConnectionState peer_connection_state() = 0;
  virtual IceGatheringState ice_gathering_state() = 0;  
  
  virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output, int64_t output_period_ms) = 0;
  virtual void StopRtcEventLog() = 0;  
  virtual void Close() = 0;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值