PeerConnectionInterface接口简介

1.接口概述

        该接口是一个抽象基类, 是WebRTC API中的一个核心组件。它定义了创建offer、answer,添加和移除流,管理ICE候选等标准方法。具体的实现是由PeerConnection类实现。

  • 2.重点方法介绍

1.AddTrack

函数原型:RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
      rtc::scoped_refptr<MediaStreamTrackInterface> track,
      const std::vector<std::string>& stream_ids)

       本方法用于添加一条音频/视频轨道,该音视频轨道track由PeerConnectionFactory::CreateAudioSource或PeerConnectionFactory::CreateVideoTrack创建。stream_ids数组表明该轨道属于哪个流id,一个track可以同时属于多个流id。本方法调用时会自动创建sender和transceiver

2.RemoveTrack

函数原型:bool RemoveTrack(RtpSenderInterface* sender)

移除一条音视频轨道,该音视频轨道由sender指定(一条track对应一个sender)。

3.CreateSender

函数原型:rtc::scoped_refptr<RtpSenderInterface> CreateSender(
      const std::string& kind,
      const std::string& stream_id)

创建一个不带track的sender

4.RestartIce

函数原型:void RestartIce()

重启ICE

5.CreateOffer

函数原型:void CreateOffer(CreateSessionDescriptionObserver* observer, const RTCOfferAnswerOptions& options);

创建offer sdp信息

6.CreateAnswer

函数原型:void CreateAnswer(CreateSessionDescriptionObserver* observer, const RTCOfferAnswerOptions& options);

创建answer sdp信息

7.SetLocalDescription

函数原型:void SetLocalDescription(SetSessionDescriptionObserver* observer, SessionDescriptionInterface* desc)

设置本地sdp信息,在创建offer成功后设置

8.SetRemoteDescription

函数原型:void SetRemoteDescription(
      std::unique_ptr<SessionDescriptionInterface> desc,
      rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)

设置远端sdp信息。

9.AddIceCandidate

函数原型:bool AddIceCandidate(const IceCandidateInterface* candidate)

添加(对端的)候选地址

10.RemoveIceCandidates

函数原型:bool RemoveIceCandidates(
      const std::vector<cricket::Candidate>& candidates)

移除候选地址

11Close

函数原型:void Close()

关闭PeerConnection

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值