PeerConnectionServer
的構(gòu)造函數(shù)

一個Endpoint有多個transport(例如每次sub一個),但是只有一個RTPBundleTransport(bundle:native層傳輸組織對象)
Endpoint :
this.bundle = new Native.RTPBundleTransport();
//Start it
this.bundle.Init();
Transport:
*傳輸表示通過單個DTLS會話在本地ICE候選者和遠程ICE候選者集合之間的連接。
*傳輸對象將在內(nèi)部分配本地端的ICE和DTLS信息,以便將其單獨發(fā)送到遠程端并建立連接。
*每個傳輸都有一組傳入和傳出流,這些流允許向遠程對等方發(fā)送或接收RTP流。
*您必須按照遠程SDP上的指示創(chuàng)建傳入流,因為任何具有未知ssrc的傳入RTP都將被忽略。
*創(chuàng)建輸出流時,傳輸將在內(nèi)部為不同的RTP流分配ssrc,以避免沖突。您將能夠從流對象中檢索該信息,以便能夠在發(fā)送到遠程端的SDP上宣布它們。
*為了確定如何路由流,必須將一種傳輸?shù)膫鞒隽鞲郊拥狡渌ɑ蛳嗤﹤鬏數(shù)膫魅肓魃稀?/p>
bundle:? 主要處理: iceTransport;? candidate
this.connection = bundle.AddICETransport(this.username,properties);
? ? ? ? 填上各屬性,創(chuàng)建DTLSICETransport
? ?????? std::shared_ptr<DTLSICETransport> transport = std::make_shared<DTLSICETransport>(sender, loop);
? ??????if (useDtls) {
????????????ret = transport->SetRemoteCryptoDTLS(dtls.GetProperty("setup"),dtls.GetProperty("hash"),dtls.GetProperty("fingerprint"));
????????} else if (useSdes) {
????????????std::string localKey(crypto.GetProperty("localKey"));
????????????std::string remoteKey(crypto.GetProperty("remoteKey"));
????????????ret = transport->SetCryptoSDES(localKey, remoteKey, crypto.GetProperty("suite"));
? ? ? ?}
????????auto connection = std::make_shared<Connection>(username,transport,properties.GetProperty("disableSTUNKeepAlive", false));
? ??????transport->Start();
this.transport = this.connection.transport;? 收發(fā)的具體情況
底層的?RTPBundleTransport
RTPBundleTransport::Init(int port)? 在指定的端口收發(fā)數(shù)據(jù), 后面的收發(fā)數(shù)據(jù)會用到
? ? ? ??int RTPBundleTransport::Send(const ICERemoteCandidate* candidate, Packet&& buffer)
????????????loop.Send(socket,candidate->GetIPAddress(),candidate->GetPort(),std::move(buffer));
具體的icetransport等都是通過這個Send函數(shù)來發(fā)送數(shù)據(jù)的
定時器里面,處理掉和候選人的連接 SendBindingRequest(connection.get(), candidate.get());
參考: https://cloud.tencent.com/developer/article/1608860