6

I need to develop a custom WebRTC peer (I need to establish audio or/and data connection between web-browser and non-browser). I however, struggle to find a proper, clear description of the handshake phase.

Answers to questions such as How to create data channel in WebRTC peer connection? are not entirely helpful, as they are not too detailed. Specifically, they say nothing about SDP contents.

Can anyone explain this or recommend any good documentation?

3
  • Are you referring to signaling? Commented Nov 28, 2015 at 18:14
  • Yes. I understand that it's my role to build a channel to initially deliver offer/answers to peers but I can't find detailed instructions how these messages should be built. Commented Nov 28, 2015 at 18:24
  • 2
    Start from ICE: tools.ietf.org/html/rfc5245 - it also covers basic moments on SDP. Basically, you need to start from ICE and STUN/TURN, then continue with SDP. At that stage your app would be able to exchange with SDP packets and pass signaling stage. After that you will need implement DTLS protocol support for your client. And then SRTP/SCTP. Commented Nov 28, 2015 at 22:50

1 Answer 1

12

Here is a page with some graphs showing how the signaling process works. Basically, you set some client side stuff first:

  • PeerConnectionFactory; to generate PeerConnections,
  • PeerConnection; one for every connection to another peer you want (usually 1),
  • MediaStream; to hook up the audio and video from your client device.

Then you generate an SDP offer

peerConnection.createOffer();  

on the caller side and send it to the callee. The callee sets this offer

peerConnection.setRemoteDescription(insert-the-offer-here);

and generates an SDP answer

peerConnection.createAnswer();

and sends it back to the caller. The caller receives this answer and sets it.

peerConnection.setRemoteDescription(insert-the-answer-here);

Both the caller and callee get a call to

onAddStream() {...} //needs to be implemented in your code

The callee when the caller's offer is set and the caller when the callee's answer is set. This callback signals the beginning of the connection.
You can also use ICE (STUN/TURN) to avoid firewall and NAT issues, but this is optional. Although in production code, you probably want to implement it anyway.

Note: Webrtc documentation is scarce and subject to change, take everything you read about webrtc (at least anything written as of now) with a grain of salt...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.