P2p ideas adapt to Android, iOS, web

1.SDP configuration sequence

1. Set parameters on the local PC

  • Generate offer SDP

[localPC offerForConstraints:constraints completionHandler:^(RTCSessionDescription * _Nullable sdp, NSError * _Nullable error) { }];Copy the code

  • The generated SDP is sent to the remote end through signaling and the local setLocalDescription is set

[localPC setLocalDescription:sdp];
// sender sdp to serverCopy the code
  • Receive the Answer SDP returned by the remote end
[localPC setRemoteDescription:answerSDP completionHandler:^(NSError * _Nullable error) {}]; Copy the code

2. Configure the remote PC

  • Receives the Offer from a remote PC and sets the SDP of the remote PC

[remotePC setRemoteDescription:sdp completionHandler:^(NSError * _Nullable error) {}];Copy the code
  • At the same time, the ANSWER SDP is generated and sent back to the remote PC, and the local SDP of the remote PC is set

[remotePC answerForConstraints:constraints completionHandler:^(RTCSessionDescription * _Nullable sdp, NSError * _Nullable error){   
  [remotePC setLocalDescription:sdp completionHandler:^(NSError * _Nullable error) {}]; // Send the Answer SDP to the remote end}];Copy the code


Ii. Time when candiate is sent to the peer end

1. The local PC should send Candiate after setRemoteDescription is set. During this period, candiate generated should be collected and sent after the preceding information is executed.

2. The remote PC should send candiate after setting and generating answer. During this period, candiate should be collected and sent to the peer end after the above information is sent