WebRTC » video-conferencing & WebSync as Signaling GateWay!

Copyright © 2013 Muaz Khan<@muazkh> » @WebRTC Experiments » Google+ » What's New?

Private ?? #123456789

How to use WebSync for Signaling?

// ------------------------------------------------------------------
// start-using WebSync for signaling
var channels = {};
var username = Math.round(Math.random() * 60535) + 5000;

var client = new fm.websync.client('websync.ashx');

client.setAutoDisconnect({
    synchronous: true
});

client.connect({
    onSuccess: function () {
        client.join({
            channel: '/chat',
            userId: username,
            userNickname: username,
            onReceive: function (event) {
                var message = JSON.parse(event.getData().text);
                if (channels[message.channel] && channels[message.channel].onmessage) {
                    channels[message.channel].onmessage(message.message);
                }
            }
        });
    }
});

function openSocket(config) {
    var channel = config.channel || 'video-conferencing';
    channels[channel] = config;

    if (config.onopen) setTimeout(config.onopen, 1000);
    return {
        send: function (message) {
            client.publish({
                channel: '/chat',
                data: {
                    username: username,
                    text: JSON.stringify({
                        message: message,
                        channel: channel
                    })
                }
            });
        }
    };
}
// end-using WebSync for signaling
// ------------------------------------------------------------------

var config = {
     openSocket: openSocket,
     onRemoteStream: function() {},
     onRoomFound: function() {}
};
  1. Mesh networking model is implemented to open multiple interconnected peer connections
  2. Maximum peer connections limit is 256 (on chrome)

Latest Updates

Feedback

Enter your email too; if you want "direct" reply!

How it works?

Huge bandwidth and CPU-usage out of multiple peers interconnection:

To understand it better; assume that 10 users are sharing video in a group. 40 RTP-ports (i.e. streams) will be created for each user. All streams are expected to be flowing concurrently; which causes blur video experience and audio lose/noise (echo) issues.

For each user:

  1. 10 RTP ports are opened to send video upward i.e. for outgoing video streams
  2. 10 RTP ports are opened to send audio upward i.e. for outgoing audio streams
  3. 10 RTP ports are opened to receive video i.e. for incoming video streams
  4. 10 RTP ports are opened to receive audio i.e. for incoming audio streams

Maximum bandwidth used by each video RTP port (media-track) is about 1MB; which can be controlled using "b=AS" session description parameter values. In two-way video-only session; 2MB bandwidth is used by each peer; otherwise; a low-quality blurred video will be delivered.

// removing existing bandwidth lines
sdp = sdp.replace( /b=AS([^\r\n]+\r\n)/g , '');

// setting "outgoing" audio RTP port's bandwidth to "50kbit/s"
sdp = sdp.replace( /a=mid:audio\r\n/g , 'a=mid:audio\r\nb=AS:50\r\n');

// setting "outgoing" video RTP port's bandwidth to "256kbit/s"
sdp = sdp.replace( /a=mid:video\r\n/g , 'a=mid:video\r\nb=AS:256\r\n');

Possible issues:

  1. Blurry video experience
  2. Unclear voice and audio lost
  3. Bandwidth issues / slow streaming / CPU overwhelming

Solution? Obviously a media server!

Web hosting by Somee.com