This article mainly analyzes the WEBRTC audio and video point-to-point part of the code structure, the article from the blog Garden Rtc.blacker, reproduced please explain the source.
Some time ago in the problem of an occasional disconnection (this problem is the most painful, not reproducible, only by experience to do), so the next WEBRTC of the peer code structure, summarized as follows:
The first image shows the two communication paths in the actual session: Peer-to-peer or forward, 92% in the case.
Note: During the actual communication process, each client will continuously send and receive the stun packet, which is done in order to maintain the response of the connection and port.
The core component of the actual communication process is P2ptransportchannel, which represents the connection channel for local and remote computers,
A number of connection objects, such as TCP,UDP, that manage many different connection types on local and remote computers,
The Connection object contains the local port and remote address information, and when a connection fails, he seamlessly switches to the other connection, which is the internal structure of the peer data channel.
The following is the stack call procedure in the code structure:
1. The Asyncudpsocket creation process for receiving and sending data is as follows:
2, calling Party Create a connection based on Remotecandidate and perform the ping process as follows:
3. The receiver creates a connection based on Remotecandidate and performs the ping process as follows:
4. Received stun response Change the connection status call process as follows:
5, the connection successfully set up to start the process of sending and receiving data is as follows:
Android IOS WebRTC Audio Video Development Summary (24)