webrtc网络(network)的处理,cost, preference的计算

1、网络类的结构

2、调用逻辑

//初始化
PeerConnectionFactory::Initialize  //PeerConnectionFactory.cc 158L
default_network_manager_.reset(new rtc::BasicNetworkManager());

//赋值给BasicPortAllocator
PeerConnectionFactory::CreatePeerConnection //PeerConnectionFactory.cc 282L
allocator.reset(new cricket::BasicPortAllocator(default_network_manager_.get(), default_socket_factory_.get()));

//调用
BasicPortAllocatorSession::BasicPortAllocatorSession //BasicPortAllocator.cc 155L
allocator_->network_manager()->SignalNetworksChanged.connect( this, &BasicPortAllocatorSession::OnNetworksChanged);
//生成network的vector
allocator_->network_manager()->StartUpdating(); 

//每个network生成一个port
BasicPortAllocatorSession::DoAllocate  //BasicPortAllocator.cc 341L

AllocationSequence* sequence = new AllocationSequence(this, networks[i], config, sequence_flags);
if (!sequence->Init()) {
        delete sequence;
        continue;
}
done_signal_needed = true;
sequence->SignalPortAllocationComplete.connect(this, &BasicPortAllocatorSession::OnPortAllocationComplete);
if (running_)
        sequence->Start(); //开始创建各个port,继而将network传给port

可以看出每个network下面建了一套port

3、network的收集过程

你可能感兴趣的:(webrtc网络(network)的处理,cost, preference的计算)