Question

I'm playing around with WebRTC, and what I'd like to achive is:

User1 opens the browser at 192.168.x.x

User2 opens the browser at 192.168.x.x The same page

User 1 clicks call, user2 displays the stream on his screen.

I've created a signaling server with node and socket.io and I'm able to exchange messages betweeen users using socket.io rooms.

The steps I'm following are:

  • Get User Media
  • Create peerconnection1 - no ice servers
  • add the stream on peerconnection
  • create the offer
  • send offer via sockets
  • Receive the offer and create peerconnection2 - no ice servers
  • sending the answer

I've also put some logging in "onicecandidate" and "onaddstream" to see when they are called, and on "onaddstream" I create the videoelement.

When I press the call button I see on the other computer that the video element becomes black but I dont see any video neither audio. For sure I'm missing some vital steps,

Could someone tell me the steps I have to do to make a correct call and exchange all the necessary data to display the stream on the other side?

Thank you very much

Was it helpful?

Solution

A STUN server is used to get an external network address.
TURN servers are used to relay traffic if direct (peer to peer) connection fails. 

see this image describes how peerconnection works

webRTC Basics

enter image description here

OTHER TIPS

You should still have at least a stun server referenced for one of your ICE servers. I would use 'stun:stun.l.google.com:19302' || 'stun:23.21.150.121', even though you do not technically need one.

But if you do not have ICE servers, you do not need to worry about gathering candidates. A couple of things that could be happening.

  • Make sure you Add your streams to each connection BEFORE creating your offer and creating your answer, it says you get the user media but not that you add it to your peerconnection
  • You are not setting your local and remote descriptions
    • Offering computer should set their local description when creating it
    • Answering computer should set their remote description with the offering description and set their local description with the one they create
    • Make sure you send the answer sdp to the initial offering computer and that that offering computer sets it as their remote description.

Streams WILL NOT send to each other unless you add the needed streams, create your descriptions, and then set their local and remote descriptions accordingly.

If that does not work, you should probably post your code for the page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top