webrtc 关键模块创建的时机

文章目录

    • [一 webrtc 各个模块创建的时机](#一 webrtc 各个模块创建的时机)
      • [1 CreatePeerConnectionFactory](#1 CreatePeerConnectionFactory)
        • [1.1.1 创建的模块](#1.1.1 创建的模块)
        • [1.1.2 关键代码](#1.1.2 关键代码)
      • 2PeerConnectionFactory::Initialize
        • [1.2.1 创建的模块](#1.2.1 创建的模块)
        • [1.2.2 关键代码](#1.2.2 关键代码)
      • [3 CreatePeerConnection](#3 CreatePeerConnection)
        • [1.3.1 创建的模块](#1.3.1 创建的模块)
        • [1.3.2 关键代码](#1.3.2 关键代码)
      • [4 PeerConnection::Initialize](#4 PeerConnection::Initialize)
        • [1.4.1 创建的模块](#1.4.1 创建的模块)
        • [1.4.2 关键代码](#1.4.2 关键代码)
      • 5PeerConnection::AddTransceiver
        • [1.5.1 创建的模块](#1.5.1 创建的模块)
        • [1.5.2 关键代码](#1.5.2 关键代码)
      • 6PeerConnection::SetLocalDescription
        • 6.1PushdownTransportDescription
          • [1.6.1.1 创建的模块](#1.6.1.1 创建的模块)
          • [1.6.1.2 关键代码](#1.6.1.2 关键代码)
        • 6.2UpdateTransceiversAndDataChannels
          • [1.6.2.1 创建的模块](#1.6.2.1 创建的模块)
          • [1.6.2.2 关键代码](#1.6.2.2 关键代码)
        • [6.3 UpdateSessionState](#6.3 UpdateSessionState)
          • [1.6.3.1 创建的模块](#1.6.3.1 创建的模块)
          • [1.6.3.2 关键代码](#1.6.3.2 关键代码)

一 webrtc 各个模块创建的时机

1 CreatePeerConnectionFactory

1.1.1 创建的模块
c 复制代码
TaskQueueFactory
CallFactory
CompositeMediaEngine
WebRtcVoiceEngine
WebRtcVideoEngine
1.1.2 关键代码
c 复制代码
/*
api/create_peerconnection_factory.h
CreatePeerConnectionFactory 函数

PeerConnectionFactoryDependencies dependencies;
dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
dependencies.call_factory = CreateCallFactory();
创建:

dependencies.media_engine = cricket::CreateMediaEngine(std::move(media_dependencies));
创建了:
CompositeMediaEngine
WebRtcVoiceEngine
WebRtcVideoEngine
*/

2PeerConnectionFactory::Initialize

1.2.1 创建的模块
c 复制代码
BasicNetworkManager
BasicPacketSocketFactory
ChannelManager
1.2.2 关键代码
c 复制代码
/*
// 关键代码
default_network_manager_.reset(new rtc::BasicNetworkManager());	
default_socket_factory_.reset(
      new rtc::BasicPacketSocketFactory(network_thread_));
	  
channel_manager_ = std::make_unique<cricket::ChannelManager>(
	  std::move(media_engine_), std::make_unique<cricket::RtpDataEngine>(),
	  worker_thread_, network_thread_);

// 收集音频编码器
channelManager::Init -> media_engine_->Init  -> voice().Init();
*/

3 CreatePeerConnection

1.3.1 创建的模块
c 复制代码
Call
RtpTransportControllerSend
BasicPortAllocator
PeerConnection
1.3.2 关键代码
c 复制代码
/*
PeerConnectionFactory::CreatePeerConnection

创建call
    PeerConnectionFactory::CreateCall_w
    CallFactory::CreateCall
    Call::Create
创建:RtpTransportControllerSend
创建 BasicPortAllocator
*/

4 PeerConnection::Initialize

1.4.1 创建的模块
c 复制代码
JsepTransportController
WebRtcSessionDescriptionFactory
1.4.2 关键代码
c 复制代码
// 创建JsepTransportController
transport_controller_.reset(new JsepTransportController(
      signaling_thread(), network_thread(), port_allocator_.get(),
      async_resolver_factory_.get(), config));
// 创建WebRtcSessionDescriptionFactory
webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
  signaling_thread(), channel_manager(), this, session_id(),
  std::move(dependencies.cert_generator), certificate, &ssrc_generator_));

5PeerConnection::AddTransceiver

1.5.1 创建的模块
c 复制代码
RtpSenderInternal
RtpReceiverInternal
RtpTransceiver
1.5.2 关键代码
c 复制代码
/*
PeerConnection::CreateSender              RtpSenderInternal
PeerConnection::CreateReceiver            RtpReceiverInternal
PeerConnection::CreateAndAddTransceiver   RtpTransceiver
*/

6PeerConnection::SetLocalDescription

6.1PushdownTransportDescription
1.6.1.1 创建的模块
c 复制代码
DtlsTransportInternal 
RtpTransport 
SrtpTransport
DtlsSrtpTransport 
RtpTransportInternal
1.6.1.2 关键代码
c 复制代码
/*
创建:
PeerConnection::PushdownTransportDescription  
transport_controller_->SetLocalDescription
JsepTransportController::ApplyDescription_n 
JsepTransportController::MaybeCreateJsepTransport
*/
6.2UpdateTransceiversAndDataChannels
1.6.2.1 创建的模块
c 复制代码
VoiceMediaChannel
VoiceChannel
或
VideoMediaChannel
VideoChannel
1.6.2.2 关键代码
c 复制代码
/*
创建:
VoiceMediaChannel
VoiceChannel

PeerConnection::UpdateTransceiversAndDataChannels		
PeerConnection::UpdateTransceiverChannel
PeerConnection::CreateVoiceChannel
channel_manager()->CreateVoiceChannel
	
关键代码:			
创建:VoiceMediaChannel
VoiceMediaChannel* media_channel = media_engine_->voice().CreateMediaChannel(call, media_config, options, crypto_options);
创建:VoiceChannel    成员有:VoiceMediaChannel  rtp_transport(MaybeCreateJsepTransport 创建的rtp_transport)

或

创建:
VideoMediaChannel
VideoChannel

PeerConnection::UpdateTransceiversAndDataChannels		
PeerConnection::UpdateTransceiverChannel
PeerConnection::CreateVideoChannel	  
channel_manager()->CreateVideoChannel
	
关键代码:			
创建 VideoMediaChannel
VideoMediaChannel* media_channel = media_engine_->video().CreateMediaChannel
创建:VideoChannel 成员有:VideoMediaChannel  rtp_transport(MaybeCreateJsepTransport 创建的rtp_transport)
*/
6.3 UpdateSessionState
1.6.3.1 创建的模块
c 复制代码
WebRtcAudioSendStream
webrtc::AudioSendStream
ChannelSend
WebRtcVideoSendStream
VideoSendStream
1.6.3.2 关键代码
c 复制代码
/*
创建 WebRtcAudioSendStream
创建 webrtc::AudioSendStream
创建:ChannelSend

PeerConnection::UpdateSessionState
PeerConnection::PushdownMediaDescription
BaseChannel::SetLocalContent
VoiceChannel::SetLocalContent_w
BaseChannel::UpdateLocalStreams_w
WebRtcVoiceMediaChannel::AddSendStream
WebRtcVoiceMediaChannel::WebRtcAudioSendStream
AudioSendStream::AudioSendStream  创建 webrtc::AudioSendStream
voe::CreateChannelSend 创建:ChannelSend

或

创建:WebRtcVideoSendStream
创建: VideoSendStream

PeerConnection::UpdateSessionState
PeerConnection::PushdownMediaDescription
BaseChannel::SetLocalContent
VoiceChannel::SetLocalContent_w
BaseChannel::UpdateLocalStreams_w
WebRtcVideoChannel::AddSendStream
WebRtcVideoChannel::WebRtcVideoSendStream
备注:
1 创建 WebRtcVideoSendStream
2 创建 webrtc::VideoSendStream::Config,把自己传递给 config.send_transport

VideoChannel::SetRemoteContent_w
WebRtcVideoChannel::SetSendParameters
WebRtcVideoChannel::ApplyChangedParams
WebRtcVideoChannel::WebRtcVideoSendStream::SetSendParameter
WebRtcVideoChannel::WebRtcVideoSendStream::SetCodec
WebRtcVideoChannel::WebRtcVideoSendStream::RecreateWebRtcStream
Call::CreateVideoSendStream (参数有webrtc::VideoSendStream::Config)
创建 VideoSendStream
创建 VideoSendStreamImpl(参数有webrtc::VideoSendStream::Config)
创建 rtp_video_sender 其中 参数send_transport 就是 WebRtcVideoChannel
备注:将来分片rtp数据就是通过WebRtcVideoChannel 发送出去
*/
相关推荐
爱讲故事的4 分钟前
计算机网络第七章:无线与移动网络复习笔记
网络·笔记·计算机网络
王莎莎-MinerU19 分钟前
面向大模型工作流的文档解析:从OCR到MinerU的深度技术指南
网络·ocr
TechWayfarer40 分钟前
IP画像在企业安全中的应用:它能做什么?不能替代什么
网络·python·tcp/ip·安全·网络安全
VOOHU-沃虎1 小时前
PoE+音频一体化接口设计:从电源变压器到XLR卡侬座的完整链路
音视频
NOVAnet20231 小时前
SASE 透明模式:非侵入式部署,实现企业网络架构无感升级
网络·架构·零信任·sd-wan·sase
天启HTTP2 小时前
开启全局代理后网络变慢,问题出在哪
开发语言·前端·网络·tcp/ip·php
信息安全失业大专人员2 小时前
网络可靠性之战——物理检测与网络逻辑检测
网络
科技风向标go2 小时前
QYResearch联合发布:《2026室外网络摄像头行业白皮书》格行视精灵成用户室外硬核环境首选监控
大数据·网络·安全·监控·户外安防
Inhand陈工2 小时前
映翰通IG502实战:通过RS232采集交通信号灯数据,实现自动短信告警
网络·嵌入式硬件·物联网·网络安全·边缘计算·信息与通信·信号处理
weixin_604236672 小时前
华三 二层交换机 企业完整正式版配置
运维·网络·华为·华为交换机命令