You can even use WebRTC with the "pure" API, I recommend this tutorial in English: link
But I found it easier to use the libraries available at link
There are several examples to make video calling with sound, screen sharing, text chat and etc, like the one here that is one of the most complete: link
It's usually pretty simple, just include some javascript files, copy some calls, and it 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 conferencing, a "signaling server" is used, you can read more about it at: link
Below is an example code that initiates the connection to a signaling server using WebSockets (but you can use FireBase, or even TUN / STUN or other protocols with little variation, as described in the link above) p>
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 a few other events that you should implement as per the examples and as you can see at: link
At the end you should remember to make the connection itself, by executing:
connection.connect();