WebRTC 1-to-1 audio and video call signaling protocol design

main logic diagram

The blue part is the main signaling logic (note the arrow)
insert image description here

signaling logic

Adopt json encapsulation format

1. join 加入房间 
2. resp­_join 当join房间后发现房间已经存在另一个人时则返回另一个人的uid;如果只有自己则不返回 
3. leave 离开房间,服务器收到leave信令则检查同一房间是否有其他人,如果有其他人则通知他有人离开 
4. new­peer 服务器通知客户端有新人加入,收到new­peer则发起连接请求 
5. peer­leave 服务器通知客户端有人离开 
6. offer 转发offer sdp 
7. answer 转发answer sdp
8. candidate 转发candidate sdp

Comparing logic
1 resp_join A first enters room B and then returns A’s basic information to B after entering the room
2 new_peer A first enters room B enters the room and then returns B’s basic information to A

join

var jsonMsg = {
    
    
 'cmd': 'join', 
 'roomId': roomId,
  'uid': localUserId
  };

resp­join

jsonMsg = {
    
     
	'cmd': 'resp‐join',
    'remoteUid': remoteUid 
    };

leave

var jsonMsg = {
    
     
	'cmd': 'leave', 
	'roomId': roomId, 
	'uid': localUserId 
	};

new­peer

var jsonMsg = {
    
     
	 'cmd': 'new‐peer',
	 'remoteUid': uid 
	  };

peer­leave

var jsonMsg = {
    
     
	 'cmd': 'peer‐leave',
	 'remoteUid': uid 
	 };

offer

var jsonMsg = {
    
    
	'cmd': 'offer', 
	'roomId': roomId, 
	'uid': localUserId, 
	'remoteUid':remoteUserId, 
	'msg': JSON.stringify(sessionDescription)
	 };

answer

 var jsonMsg = {
    
     
 	 'cmd': 'answer', 
 	 'roomId': roomId, 
 	 'uid': localUserId, 
 	 'remoteUid':remoteUserId, 
 	 'msg': JSON.stringify(sessionDescription) 
 	  };

candidate

var jsonMsg = {
    
     
	 'cmd': 'candidate', 
	 'roomId': roomId, 
	 'uid': localUserId, 
	 'remoteUid':remoteUserId, 
	 'msg': JSON.stringify(candidateJson) 
	 };

Guess you like

Origin blog.csdn.net/qq_33329316/article/details/124740960