WebRTC Session-Reinitiation using RTCMultiConnection
© 2013 Muaz Khan<@muazkh> » @WebRTC Experiments » Google+ » What's New?
#123456789
- Join a conference; leave; and rejoin same or other conferences!
- Open a conference; close; reopen a conference; close again!
- Its all about session re-initiation!
// currently you need to set unique values for "sessionid" // ..before calling "open" method connection.sessionid = (Math.random() * 999).toString().replace('.', ''); connection.open();
Feedback
- Mesh networking model is implemented to open multiple interconnected peer connections
- Maximum peer connections limit is 256 (on chrome)
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:
- 10 RTP ports are opened to send video upward i.e. for outgoing video streams
- 10 RTP ports are opened to send audio upward i.e. for outgoing audio streams
- 10 RTP ports are opened to receive video i.e. for incoming video streams
- 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:
- Blurry video experience
- Unclear voice and audio lost
- Bandwidth issues / slow streaming / CPU overwhelming
Solution? Obviously a media server!
How to write video-conference?
- session.audio=true
- session.video=true
// https://www.webrtc-experiment.com/RTCMultiConnection-v1.4.js var connection = new RTCMultiConnection(); connection.session = { audio: true, video: true }; // on local/remote media stream connection.onstream = function(e) {} connection.onstreamended = function(e) {} // setup signaling to search for existing sessions connection.connect(); // setup new session document.getElementById('initiator').onclick = function() { connection.open(); };