SIP is an example of accepting inbounding SIP traffic (Invites) and bridging it with WebRTC. This is the most common way to connect phone calls with your WebRTC application. This is possible because of the excellent emiago/sipgo library.
This example demonstrates accepting SIP audio and playing it in the browser. If you wish to implement multiple participants in a call you will need to have audio mixing. See zaf/g711 for decoding + encoding. After you have decoded sum all the samples and then encode it.
jsfiddle.net you should see a audio player, two text-areas and a 'Start Session' button
In the jsfiddle the top textarea is your browser, copy that and:
Run echo $BROWSER_SDP | sip-to-webrtc
- Paste the SessionDescription into a file.
- Run
sip-to-webrtc < my_file
Copy the text that sip-to-webrtc
just emitted and copy into second text area
If a WebRTC session was successfully established you will get log messages
about ICEConnectionState going to connected
. In your browser and terminal.
Browser
checking
connected
Terminal
Connection State has changed checking
Connection State has changed connected
Starting SIP Listener
If everything worked now it is time to make a SIP Invite.
sip-to-webrtc
is now listening on :5060
and will accept all invites.
When an Invite has been accepted you will see a log message like this.
Accepting SIP Invite: From: "+15550100001" <sip:[email protected]>;tag=nc8uzmZUHUTbqH0v
You should hear the audio of the phone call in your browser.
Congrats, you have used Pion WebRTC! Now start building something cool