Ask a question: about WEBRTC communication

Source: Internet
Author: User

In the next is WEBRTC development novice, at present encountered a problem, turned over to have not understood. Maybe English is not good, look at the document to see blindfolded, so has not found a solution.

Development environment:

node. JS Server built

I'm using Socket.io to do communications now.

Development Purpose:

A classmate to B students to initiate a request, B received after the two sides live video.

If there is a clear classmate trouble tell me ha, really trouble everyone O (∩_∩) o~~

Problem Description:

Currently in the two-person video demo, but on both sides of the signal exchange information problems. The console prints it out like this:

The code is as follows:

1   varServers =NULL;2 3   functionTrace (text) {4Console.log ((Performance.now ()/+). ToFixed (3) + ":" +text);5   }6 7 //Creating an Peerconnection instance8Localpeerconnection =Newrtcpeerconnection (servers);9Trace ("Created local Peer Connection object Localpeerconnection");Ten  ALocalpeerconnection.onicecandidate =function(evt) { -      -Socket.send (json.stringify ({"Candidate": Evt.candidate}); the  -Trace ("Local ICE candidate: \ n" +evt.candidate.candidate); -  -   } + -Localpeerconnection.onaddstream =function(evt) { +REMOTEVIDEO.SRC =Url.createobjecturl (evt.stream); ATrace ("Add remote stream to other peer") at   }; -  - Localpeerconnection.addstream (localstream); -Trace ("Added Localstream to Localpeerconnection"); -  -   if(iscaller) { in Localpeerconnection.createoffer (gotdescription, handleError); -  to   } +   Else{ - Localpeerconnection.createanswer (localpeerconnection.remotedescription, gotdescription); the   } *  $ }Panax Notoginseng  - functiongotdescription (evt) { the  + localpeerconnection.setlocaldescription (evt); ASocket.send (json.stringify ({"SDP": evt}); the } +  -Socket.on (' Pushmessagedone ',function(evt) { $  $     if(!localpeerconnection) { -Console.log (1); -Callfalse); the     } - Wuyi     varSignal =Json.parse (evt); the  -     if(SIGNAL.SDP) { Wu  -Localpeerconnection.setremotedescription (Newrtcsessiondescription (SIGNAL.SDP)); About}Else { $  -Localpeerconnection.addicecandidate (Newrtcicecandidate (signal.candidate)); -       } - }); A  +  the functionHandleError () {}

Ask a question: about WEBRTC communication

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.