webrtc代码走读二十:extension扩展头协商及初始化流程

本文详细介绍了WebRTC中RTP扩展头的动态配置过程,从创建offer时封装扩展头到接收SDP解析并注册ExtensionMap,涉及Audio和Video通道的处理。涵盖了从Conductor到RtpHeaderExtensionMap的完整流程。

一、概述

如上图所示webrtc里面有很多扩展头,用于在RTP报文头里面传递一些信息给对端。 

这些扩展头的ID值没有标准定义,都是在SDP里面动态协商

webrtc作为发送端,他的RTP扩展头ID值是可以根据接受到的sdp answer动态配置。参见下面《二、解析sdp的extension,并注册ExtensionMap》。

webrtc作为接收端,他需要配置对端发送过来的extension扩展头ID,如下就是将本地配置封装成SDP的过程。 

二、封装CreateOffer

1、获取默认的extension扩展头配置

wWinMain
->MainWnd::PreTranslateMessage
->MainWnd::OnDefaultAction
->Conductor::ConnectToPeer
->Conductor::InitializePeerConnection
->Conductor::AddTracks
->PeerConnection::AddTrack
->RtpTransmissionManager::AddTrack
->RtpTransmissionManager::AddTrackUnifiedPlan
->RtpTransmissionManager::CreateAndAddTransceiver
----->ChannelManager::GetSupportedAudioRtpHeaderExtensions
----->RtpTransceiver::RtpTransceiver

2、将extension扩展头封装到sdp中

wWinMain
->MainWnd::PreTranslateMessage
->MainWnd::OnDefaultAction
->Conductor::ConnectToPeer
->SdpOfferAnswerHandler::CreateOffer
->SdpOfferAnswerHandler::GetOptionsForOffer
->SdpOfferAnswerHandler::GetOptionsForUnifiedPlanOffer
->MediaDescriptionOptions::GetMediaDescriptionOptionsForTransceiver
->RtpTransceiver::HeaderExtensionsToOffer

3、代码详解

1、Conductor::ConnectToPeer:获取及封装extension的sdp

 2、RtpTransmissionManager::CreateAndAddTransceiver获取音视频的extension信息

 3、WebRtcVoiceEngine::GetRtpHeaderExtensions:获取音频默认扩展头

  4、WebRtcVideoEngine::GetRtpHeaderExtensions:获取视频默认扩展头

 

 5、配置sdp的extension全局遍历

 

二、解析sdp的extension,并注册ExtensionMap

wWinMain
->Win32Window::WndProc    
->Win32SocketServer::MessageWindow::OnMessage
->Win32SocketServer::Pump
->Thread::Dispatch
->WebRtcSessionDescriptionFactory::OnMessage
->Conductor::OnSuccess
->PeerConnectionProxyWithInternal<webrtc::PeerConnectionInterface>::SetLocalDescription
->SdpOfferAnswerHandler::SetLocalDescription    
->SdpOfferAnswerHandler::DoSetLocalDescription
->SdpOfferAnswerHandler::ApplyLocalDescription   
->SdpOfferAnswerHandler::UpdateSessionState  
->SdpOfferAnswerHandler::PushdownMediaDescription
->BaseChannel::SetRemoteContent
VideoChannel::SetRemoteContent_w 或者 VoiceChannel::SetRemoteContent_w

1、音频分支

VoiceChannel::SetRemoteContent_w 分支
->WebRtcVoiceMediaChannel::SetSendParameters
->AudioSendStream::ConfigureStream
->ModuleRtpRtcpImpl2::RegisterRtpHeaderExtension
->RTPSender::RegisterRtpHeaderExtension
->RtpHeaderExtensionMap::Register

2、视频分支
VideoChannel::SetRemoteContent_w 分支
WebRtcVideoChannel::SetSendParameters
->WebRtcVideoChannel::ApplyChangedParams
->WebRtcVideoChannel::WebRtcVideoSendStream::SetCodec
->WebRtcVideoChannel::WebRtcVideoSendStream::RecreateWebRtcStream
->internal::Call::CreateVideoSendStream
->internal::Call::CreateVideoSendStream
->VideoSendStream::VideoSendStream
->RtpTransportControllerSend::CreateRtpVideoSender
->RtpVideoSender::RtpVideoSender
->ModuleRtpRtcpImpl2::RegisterRtpHeaderExtension
->RTPSender::RegisterRtpHeaderExtension
->RtpHeaderExtensionMap::Register

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值