The development of video conferencing based on the third party WEBRTC open source platform is not very difficult, mainly the business aspects. However, once involved in the core of the underlying issues need to read the source code, to find out the bug, the difficulty is not small.The project needs to analyze the creation process of peerconnection.assuming clienta,clientb is divided into offer and answer.
Offer end
PC =new rtcpeerconnection (null);Pc.onicecandidate=handleicecandid
= "Remotevideo"AutoPlay Style= "width:80px">Video>JS sectionDetermine the initiator var Iscaller = window.location.href.split (' # ') [1]; The socket connection of the signaling server is var socket = io.connect (' http://localhost:3000 '); Stun and turn server var iceserver = null; Iceserver can communicate var pc = new Webkitrtcpeerconnection (iceserver) under LAN; Other side notifications sent to Pc.onicecandidate = function (event) {if (eve
=newRTCPeerConnection(iceServer);
A, b each creates a PC instance configured with an ice server and adds a Onicecandidate event callback to it
When a network candidate is available, the Onicecandidate function is called
Inside the callback function, a or B encapsulates the network candidate's message in an ice candidate signaling, which is routed through the server to the other part
Clienta via the Onicecandidate interface. Clienta will receive the candidate information by signal server sent to CLIENTB,CLIENTB through Peerconnection Addicecandidate method saved up. The same operation ClientB to Clienta again.
So Clienta and CLIENTB have established the audio and video transmission of the peer channel, CLIENTB received the Clienta transmitted over the audio and video stream, A MediaStream object that identifies the Clienta-side
method and sends it to CLIENTB via the signal server.
CLIENTB receives the offer SDP object sent by Clienta, which is saved by Peerconnection's Setremotedescription method, and call Peerconnection's Createanswer method to create an answer to the SDP object, The answer SDP object is saved by Peerconnection's Setlocaldescription method and sent to Clienta through the signal server.
Clienta receives the reply SDP object sent by CLIENTB and saves it through the Peerconnection setremotedescripti
information. Peerconnection will send a notification via the Onicecandidate interface to Clienta, Clienta will receive the candidate message Signalserver sent to CLIENTB, ClientB is saved by Peerconnection's Addicecandidate method.The same operation ClientB to Clienta again.
In this way Clienta and CLIENTB have set up the audio and video transmission of the peer channel. CLIENTB receives the Clienta transmitted by the audio and video stream, will b
, Alice and Bob Exchange network information. ("Finding candidates" means looking for a network port using the ICE frame)
Alice uses the onicecandidate handle to create a rtcpeerconnection.
When a network handler is available, the handle runs.
Alice sends the serialized data to Bob, either way: WebSocket or otherwise.
When Bob gets the data from Alice, call Addicecandidate to add the remote node description.
WebRTC clients (k
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.