Skip to content

RTCMultiConnection is a WebRTC JavaScript wrapper library runs top over RTCPeerConnection API to provide multi-session establishment scenarios. It also provides dozens of features as hybrid-less mesh networking model, a reliable presence detection and syncing system; complex renegotiation scenarios; and much more. It provides everything you've i…

License

Notifications You must be signed in to change notification settings

Zeniagromoff/RTCMultiConnection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RTCMultiConnection.js / WebRTC Library npm downloads

Changes log for current version: http://www.rtcmulticonnection.org/changes-log/#v2.0

RTCMultiConnection is a WebRTC JavaScript wrapper library runs top over RTCPeerConnection API to provide multi-session establishment scenarios. It also provides dozens of features as hybrid-less mesh networking model, a reliable presence detection and syncing system; complex renegotiation scenarios; and much more. It provides everything you've in your mind! Just understand the API and you'll enjoy using it! It is simple and its syntax is similar as WebSockets JavaScript API and RTCPeerConnection API.

It is MIT Licenced, which means that you can use it in any commercial/non-commercial product, free of cost.

NPM package: https://www.npmjs.org/package/rtcmulticonnection

npm install rtcmulticonnection

To use it:

<script src="./node_modules/rtcmulticonnection/RTCMultiConnection.js"></script>

There are some other NPM packages regarding RTCMultiConnection:

1. Link The Library

// stable version is v1.9
https://cdn.webrtc-experiment.com/RTCMultiConnection-v1.9.js

2. Common Code

var MODERATOR_CHANNEL_ID = 'ABCDEF'; // channel-id
var MODERATOR_SESSION_ID = 'XYZ';    // room-id
var MODERATOR_ID         = 'JKL';    // user-id
var MODERATOR_SESSION    = {         // media-type
    audio: true,
    video: true
};
var MODERATOR_EXTRA      = {};       // empty extra-data

3. Code for Room Moderator (i.e. Initiator)

var moderator     = new RTCMultiConnection(MODERATOR_CHANNEL_ID);
moderator.session = MODERATOR_SESSION;
moderator.userid  = MODERATOR_ID;
moderator.extra   = MODERATOR_EXTRA;
moderator.open({
    dontTransmit: true,
    sessionid:    MODERATOR_SESSION_ID
});

4. Code for Room Participants

var participants = new RTCMultiConnection(MODERATOR_CHANNEL_ID);
participants.join({
    sessionid: MODERATOR_SESSION_ID,
    userid:    MODERATOR_ID,
    extra:     MODERATOR_EXTRA,
    session:   MODERATOR_SESSION
});

5. (optional) Handle how to get streams

// same code can be used for participants
// (it is optional) 
moderator.onstreamid = function(event) {
    // got a clue of incoming remote stream
    // didn't get remote stream yet
    
    var incoming_stream_id = event.streamid;
    
    YOUR_PREVIEW_IMAGE.show();
    
    // or
    YOUR_PREVIEW_VIDEO.show();
};

// same code can be used for participants
// it is useful
moderator.onstream = function(event) {
    // got local or remote stream
    // if(event.type == 'local')  {}
    // if(event.type == 'remote') {}
    
    document.body.appendChild(event.mediaElement);
    
    // or YOUR_VIDEO.src = event.blobURL;
    // or YOUR_VIDEO.src = URL.createObjectURL(event.stream);
};

// same code can be used for participants
// it is useful but optional
moderator.onstreamended = function(event) {
    event.mediaElement.parentNode.removeChild(event.mediaElement);
};
    <td>
        <a href="http://www.rtcmulticonnection.org/docs/getting-started/" target="_blank">
            <img src="https://www.rtcmulticonnection.org/img/getting-started.png" style="display:block; width:99px; height99px;" alt="Getting-Started">
            Getting Started
        </a>
    </td>
    
    <td>
        <a href="http://www.rtcmulticonnection.org/docs/" target="_blank">
            <img src="https://www.rtcmulticonnection.org/img/documentation.png" style="display:block; width:99px; height99px;" alt="Documentation">
            Documentation
        </a>
    </td>
    
    <td>
        <a href="http://www.rtcmulticonnection.org/changes-log/" target="_blank">
            <img src="https://www.rtcmulticonnection.org/img/whats-new.png" style="display:block; width:99px; height99px;" alt="Changes Log">
            Changes Log
        </a>
    </td>
    
    <td>
        <a href="http://www.rtcmulticonnection.org/FAQ/" target="_blank">
            <img src="https://www.rtcmulticonnection.org/img/FAQ.png" style="display:block; width:99px; height99px;" alt="FAQ">
            FAQ
        </a>
    </td>
</tr>
Demos Demos

Demos using RTCMultiConnection

Experiment Name Demo Source Code
All-in-One test Demo Source
Renegotiation & Mute/UnMute/Stop Demo Source
Multi-streams attachment Demo Source
Admin/Guest audio/video calling Demo Source
Session-Reinitiation Demo Source
Audio/Video Recording Demo Source
Mute/UnMute Demo Source
Password Protected Rooms Demo Source
WebRTC remote media stream forwarding Demo Source
Video Conferencing Demo Source
Multi-Session Establishment Demo Source
RTCMultiConnection-v1.3 testing demo Demo Source
Video Broadcasting Demo Source
File Sharing + Text Chat Demo Source
Audio Conferencing Demo Source
Join with/without camera Demo Source
Screen Sharing Demo Source
One-to-One file sharing Demo Source
Manual session establishment + extra data transmission + video conferencing Demo Source
Customizing Bandwidth Demo Source
Users ejection and presence detection Demo Source
RTCMultiConnection-v1.3 and socket.io ---- Source
Multi-Broadcasters and Many Viewers Demo Source
Stream Mp3 Live Demo Source

Auto open/join room? Demo

// Copy and use below code in any RTCMultiConnection based demo
// You can even use it with DataChannel.js
// You can even use it with other experiments; simply replace
// "openSignalingChannel" with:
// var config = { openSocket: openSignalingChannel };

// via: https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs#how-to-use
var SIGNALING_SERVER = 'https://webrtc-signaling.nodejitsu.com:443/';
var mainSocket = io.connect(SIGNALING_SERVER);

connection.openSignalingChannel = function(config) {   
   config.channel = config.channel || this.channel;
   
   mainSocket.emit('new-channel', {
      channel: config.channel,
      sender : connection.userid
   });

   var socket = io.connect(SIGNALING_SERVER + config.channel);
   socket.channel = config.channel;

   socket.on('connect', function () {
      if (config.callback) config.callback(socket);
   });

   socket.send = function (message) {
        socket.emit('message', {
            sender: connection.userid,
            data  : message
        });
    };

   socket.on('message', config.onmessage);
};

// via https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs#presence-detection
mainSocket.on('presence', function (isChannelPresent) {
    console.log('is channel present', isChannelPresent);
    
    if (!isChannelPresent) 
        connection.open(connection.channel); // open new room
    else 
        connection.join(connection.channel); // join existing room
});
mainSocket.emit('presence', connection.channel);

Credits

Muaz Khan:

  1. Personal Webpage: http://www.muazkhan.com
  2. Email: [email protected]
  3. Twitter: https://twitter.com/muazkh and https://twitter.com/WebRTCWeb
  4. Google+: https://plus.google.com/+WebRTC-Experiment
  5. Facebook: https://www.facebook.com/WebRTC

License

RTCMultiConnection is released under MIT licence . Copyright (c) Muaz Khan.

About

RTCMultiConnection is a WebRTC JavaScript wrapper library runs top over RTCPeerConnection API to provide multi-session establishment scenarios. It also provides dozens of features as hybrid-less mesh networking model, a reliable presence detection and syncing system; complex renegotiation scenarios; and much more. It provides everything you've i…

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 75.5%
  • HTML 23.4%
  • CSS 1.1%