Building iOS Native App using WebRTC

I came through the process of implementing it few month ago. What I've found was the library was not stable - sometimes it was working sometimes not.

Additionally my iPhone was always becoming hot when I was using it.

I would not suggest using this library and overall WebRTC technology for commercial projects.

This is my implementation, which was working few months ago:

https://github.com/aolszak/WebRTC-iOS

Good luck!


I am not an expert in webrtc but i will try to explain some of your questions.

1.ICE servers-- NATs and firewalls impose significant problem in setting up IP endpoints. so IETF standards STUN, TURN and ICE were developed to address the NAT traversal problem. STUN helps connect IP end-points:

  • discover whether they are behind a NAT/firewall, and if so,
  • to determine the public IP address and type of the firewall. STUN then uses this information to assist in establishing peer-to-peer IP connectivity.

TURN, which stands for Traversal Using Relay NAT, provides a fallback NAT traversal technique using a media relay server to facilitate media transport between end-points.

ICE is a framework that leverages both STUN and TURN to provide reliable IP set-up and media transport, through a SIP offer/answer model for end-points to exchange multiple candidate IP addresses and ports (such as private addresses and TURN server addresses).

2.Signaling is the process of coordinating communication. This signalling part needs to be implemented by you according to your needs(for ex. if you have sip structure in place then you will have to implement sip signalling). In order for a WebRTC application to set up a 'call', its clients need to exchange information:

  • Session control messages used to open or close communication.
  • Error messages.
  • Media metadata such as codecs and codec settings, bandwidth and media types.
  • Key data, used to establish secure connections.
  • Network data, such as a host's IP address and port as seen by the outside world.

    1. Steps

    for offerer:

  • first create the peer connection and pass the ice candidates into it as parameters.

  • set event handlers for three events:

    • onicecandidate-- onicecandidate returns locally generated ICE candidates so you can pass them over other peer(s) i.e. list of ice candidates that are returned by STUN/TURN servers; these ice candidates contains your public ipv4/ipv6 addresses as well as UDP random addresses
    • onaddstream--onaddstream returns remote stream (microphone and camera of your friend!).
      • addStream` attaches your local microphone and camera for other peer.

Now create SDP offer by calling setLocalDescription function and set remote SDP by calling setRemoteDescription.

For Answerer:

  • setRemoteDescription
  • createAnswer
  • setLocalDescription
  • oniceCandidate--On getting locally generated ICE
  • addiceCandidate--On getting ICE sent by other peer
  • onaddstream--for remote stream to add

I hope this will make some of your doubts clear.