webrtc-SDP中answer-之发送方向确定方式

answer-之发送方向确定方式:由对端的offer的方向和本地想要的方向做对比最终获取answer的方向。

为了简化篇幅,故只附上相关的源码文件路径及相关的函数。

1. 首先sdp的生成是和peerconnection有密切关系的。

      peerconnection对象的track的添加将会影响最终sdp的生成。

     详见peerconnection的AddTrack。

2. answer中direction的判定流程。

src/pc/peer_connection.cc

CreateAnswer

src/pc/webrtc_session_description_factory.cc

CreateAnswer 
InternalCreateAnswer

src/pc/media_session.cc

CreateAnswer 
AddVideoContentForAnswer 
CreateMediaContentAnswer 
static RtpTransceiverDirection 
NegotiateRtpTransceiverDirection( RtpTransceiverDirection offer, 
                                  RtpTransceiverDirection wants) { 
    bool offer_send = webrtc::RtpTransceiverDirectionHasSend(offer); 
    bool offer_recv = webrtc::RtpTransceiverDirectionHasRecv(offer);
    bool wants_send = webrtc::RtpTransceiverDirectionHasSend(wants); 
    bool wants_recv = webrtc::RtpTransceiverDirectionHasRecv(wants); 
    return webrtc::RtpTransceiverDirectionFromSendRecv(offer_recv && wants_send, 
                                                        offer_send && wants_recv); 
}

上述为追踪answer中direction的判定;

3. 首先对方传过来的direction已确定,关键是看本地answer生成时wants的是什么?

其中wants的传入是由如下传入:

src/pc/peer_connection.cc

CreateAnswer 
cricket::MediaSessionOptions session_options; 

GetOptionsForAnswer(options, &session_options); 

GetOptionsForUnifiedPlanAnswer 

GetMediaDescriptionOptionsForTransceiver 

cricket::MediaDescriptionOptions media_description_options( transceiver->media_type(), mid,         
                                                            transceiver->direction(), 
                                                            transceiver->stopped());

transceiver的生成位置:

UpdateTransceiversAndDataChannels 
AssociateTransceiver

后续请等待......

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值