一、概述

如上图所示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
本文详细介绍了WebRTC中RTP扩展头的动态配置过程,从创建offer时封装扩展头到接收SDP解析并注册ExtensionMap,涉及Audio和Video通道的处理。涵盖了从Conductor到RtpHeaderExtensionMap的完整流程。
540

被折叠的 条评论
为什么被折叠?



