Multi-Session Establishment using RTCMultiConnection
Copyright © 2013 Muaz Khan<@muazkh>.
Join one of following sessions
Copy any of the following session-ids and paste in above input-box:
- : session-id for audio + video conferencing
- : session-id for audio + video broadcasting
- : session-id for audio-only conferencing
- : session-id for one-way only-audio broadcasting
- : session-id for one-way only-video broadcasting
Open Five Unique Sessions
Local Media Streams |
Remote Media Streams |
How to open multi-sessions using RTCMultiConnection?
<script src="https://www.webrtc-experiment.com/RTCMultiConnection-v1.1.js"></script> <script> var connection = new RTCMultiConnection(); // get access to local or remote streams connection.onstream = function (stream) { if (stream.type === 'local') { //------------------------ //-------------- see here! //------------------------ var stream = stream.stream; open_audio_conferencing_session(stream); open_audio_video_broadcasting_session(stream); open_only_audio_broadcasting_session(stream); open_only_video_broadcasting_session(stream); } } // to create/open a new session connection.open('session-id'); // if someone already created a session; to join it: use "connect" method connection.connect('session-id'); function open_audio_conferencing_session(stream) { var new_connection = new RTCMultiConnection(); // -------- getting only-audio stream! stream = new MediaStream(stream.getAudioTracks()); new_connection.attachStream = stream; new_connection.session = 'only-audio'; new_connection.open('audio conferencing session-id'); } function open_audio_video_broadcasting_session(stream) { var new_connection = new RTCMultiConnection(); // -------- attaching same stream! new_connection.attachStream = stream; // -------- setting 'one way' direction new_connection.direction = 'one-way'; new_connection.open('audio-video broadcasting session-id'); } function open_only_audio_broadcasting_session(stream) { var new_connection = new RTCMultiConnection(); // -------- getting only-audio stream! stream = new MediaStream(stream.getAudioTracks()); new_connection.attachStream = stream; new_connection.session = 'only-audio'; new_connection.direction = 'one-way'; new_connection.open('audio one-way broadcasting session-id'); } function open_only_video_broadcasting_session(stream) { var new_connection = new RTCMultiConnection(); // -------- getting only-video stream! stream = new MediaStream(stream.getVideoTracks()); new_connection.attachStream = stream; new_connection.session = 'only-video'; new_connection.direction = 'one-way'; new_connection.open('video one-way broadcasting session-id'); } </script>
Why multi-sessions?
- Sometimes you want to one-way broadcast your video for users who have no-camera or no-microphone
- You may want to allow audio-conferencing along with video-conferencing in the same session / same stream!
- You may want to open one-to-one ports between main-peer and the server to record speech or to further broadcast the stream
- You may want to allow end-users to anonymously join/view main-video session or chatting room
- You may want to open one-to-one private session between chairperson and CEO! — in the same session; same page!