You can even use Webrtc with the "pure" API, I recommend this tutorial in English: http://www.html5rocks.com/en/tutorials/webrtc/basics/
But I found it easier to use the libraries available on https://www.webrtc-experiment.com/
There are several examples, to make video call with sound, share screen, text chat and etc, like this one which is one of the most complete: https://www.webrtc-experiment.com/RTCMultiConnection/MultiRTC/
It is usually quite simple, just include some javascript files, copy some calls and works.
To create a communication channel using the Rtcmulticonnection library, you should do something like:
var connection = new RTCMultiConnection();
connection.firebase = false;
connection.session = {
audio: true,
video: true
};
var current_user = 'test user';
To create "rooms" for video conference, a "signage server" is used, you can read more about it at: https://github.com/muaz-khan/WebRTC-Experiment/blob/master/Signaling.md
Below is an example of code that starts connecting to a signage server using Websockets (but you can use Firebase, or even TUN/STUN or other protocols with little variation, as described in the link above):
connection.openSignalingChannel = function(config) {
var channel = location.href.replace(/\/|:|#|%|\.|\[|\]/g, '');
var websocket = new WebSocket("ws://localhost");
websocket.channel = channel;
websocket.onopen = function () {
websocket.push(JSON.stringify({
open: true,
channel: channel
}));
if (config.callback) {
config.callback(websocket);
}
};
websocket.onmessage = function(event) {
config.onmessage(JSON.parse(event.data));
};
websocket.push = websocket.send;
websocket.send = function (data) {
if (websocket.readyState != 1) {
return setTimeout(function() {
websocket.send(data);
}, 300);
}
websocket.push(JSON.stringify({
data: data,
channel: channel
}));
};
return websocket;
};
There are some other events that you should implement as examples and as you can see in: https://github.com/danielneis/moodle-mod_webrtcexperiments/blob/master/module.js#L11
At the end you should remember to make the connection itself by running:
connection.connect();
I know the http://webrtc2sip.org/ I’ve used it to make audio and video conversations between browser/phone and browser/browser using SIP protocol.
– Ibrahim