Webrtcclient and turn and signaling server communication flowchart

Source: Internet
Author: User

WEBRTC is one of the important features supported by HTML5. With it, it is no longer necessary to use the audio-video-related client. The audio and video chat function can be realized directly through the Web page of the browser. And the WEBRTC project is open source. We are able to build our own audio and video chat capabilities at high speed with WEBRTC source code. Whether using the WEBRTC API interface of the front-end JS or building your own chat frame on the WEBRTC source code. are required to follow the following operating procedures:

In the above sequence, WEBRTC does not provide stunserver and signalserver. The server side needs to be implemented by itself. Stunserver can use Google to implement the stun Protocol test Server (stun:stun.l.google.com:19302), Signalserver is completely necessary to achieve their own, It needs to transmit each other's SDP information and candidate information between Clienta and CLIENTB, and Clienta and CLIENTB Use this information to establish a peer-to connection to deliver audio and video data.

Because of the complexity of the network environment, not all of the client can establish peer-to-peer connection, so that the situation requires a relayserver to do audio and video data transfer, this article is based on the source code analysis of the attitude, this situation is not considered.

Here to illustrate, Stun/turn, Relayserver's real today WEBRTC source code has a demo sample, is really a big treasure of the name of the deputy de facto.

The above sequence. The annotated scene is that Clienta initiates a chat request to CLIENTB, invoking descriptive narratives such as the following:

  • Clienta first creates the Peerconnection object and then turns on the local AV device, encapsulating the audio and video data as MediaStream into the peerconnection.
  • Clienta calls Peerconnection's Createoffer method to create an SDP object for the offer, which holds the relevant parameters for the current audio and video in the SDP object. Clienta saves the SDP object through the Peerconnection Setlocaldescription method and sends it to CLIENTB via Signalserver.
  • 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 Signalserver.
  • Clienta receives the reply SDP object sent by CLIENTB and saves it through the Peerconnection setremotedescription method.
  • In the offer/answer process of SDP information. Clienta and CLIENTB have created the corresponding audio channel and video channel based on SDP information and turned on the collection of candidate data, candidate data can be easily understood as the client IP address information (local IP address, IP address of the public network, the address assigned by the relay server).
  • When Clienta collects the candidate 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 be returned through the Peerconnection Onaddstream callback interface to identify the Clienta end of the audio and video stream of the MediaStream object, on the CLIENTB side render it.

    The same operation also adapts to the transmission of audio and video streams from CLIENTB to Clienta.

The process here but from the use of the description of the narrative, the details of what the interior has done, how to do, the future of the article will slowly fine, all the beginning difficult, self-encouragement.


From: http://www.cnblogs.com/fangkm/p/4364553.html

Webrtcclient and turn and signaling server communication flowchart

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.