Skip to content

Commit

Permalink
Added [email protected] Added admin/guest demo in v3
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Apr 16, 2016
1 parent b906e2f commit e227d48
Show file tree
Hide file tree
Showing 14 changed files with 633 additions and 140 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ More info about `forever-service` [here](http://stackoverflow.com/a/36027516/552
| Change Cameras/Microphonea | [Demo](https://rtcmulticonnection.herokuapp.com/demos/Switch-Cameras.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/Switch-Cameras.html) |
| MultiRTC: Skype-like app | [Demo](https://rtcmulticonnection.herokuapp.com/demos/MultiRTC/) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/MultiRTC/) |
| Change Video Resolutions in your Live Sessions | [Demo](https://rtcmulticonnection.herokuapp.com/demos/change-resolutions.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/change-resolutions.html) |
| Admin/Guest demo | [Demo](https://rtcmulticonnection.herokuapp.com/demos/admin-guest.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/admin-guest.html) |

## Link Script Files

Expand All @@ -136,7 +137,7 @@ All files from `/dist` directory are available on CDN: `https://cdn.webrtc-exper
<script src="https://cdn.webrtc-experiment.com:443/rmc3.min.js"></script>

<!-- or specific version -->
<script src="https://github.com/muaz-khan/RTCMultiConnection/releases/download/3.2.99/rmc3.min.js"></script>
<script src="https://github.com/muaz-khan/RTCMultiConnection/releases/download/3.3.00/rmc3.min.js"></script>
```

If you're sharing files, you also need to link:
Expand All @@ -148,7 +149,7 @@ If you're sharing files, you also need to link:
<script src="https://cdn.webrtc-experiment.com:443/rmc3.fbr.min.js"></script>

<!-- or specific version -->
<script src="https://github.com/muaz-khan/RTCMultiConnection/releases/download/3.2.99/rmc3.fbr.min.js"></script>
<script src="https://github.com/muaz-khan/RTCMultiConnection/releases/download/3.3.00/rmc3.fbr.min.js"></script>
```

> You can link multiple files from `dev` directory. Order doesn't matters.
Expand Down Expand Up @@ -1399,6 +1400,10 @@ connection.changeUserId('your-new-userid');

## iOS/Android

1. Audio/Video + TextChat/FileSharing (supported both on iOS/Android) [broadcast, conferencing, everything]
2. Screen Viewer (supported both on iOS/Android) -- You can merely view the screen shared by desktop.
3. Screen Capturing & Sharing (NOT Supported on Mobile platforms)

RTCMultiConnection-v3 supports `cordova` based iOS/android apps.

Copy/paste entire [`rmc3.min.js`](https://github.com/muaz-khan/RTCMultiConnection/tree/master/dist/rmc3.min.js) file inside `deviceready` callback:
Expand Down Expand Up @@ -1438,7 +1443,7 @@ document.addEventListener('deviceready', function() {

// you can put your custom-ui-codes here
// e.g.
// var connection = new RTCMultiConnection();
// var connection = new RTCMultiConnection({useDefaultDevices:true});
}, false);
```

Expand Down
47 changes: 11 additions & 36 deletions RTCMultiConnection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated: 2016-04-10 12:38:30 PM UTC
// Last time updated: 2016-04-16 6:42:16 AM UTC

// _____________________
// RTCMultiConnection-v3
Expand Down Expand Up @@ -551,7 +551,7 @@
video: {
mandatory: {},
optional: [{
bandwidth: connection.bandwidth.audio * 8 * 1024 || 128 * 8 * 1024
bandwidth: connection.bandwidth.video * 8 * 1024 || 128 * 8 * 1024
}, {
googLeakyBucket: true
}, {
Expand Down Expand Up @@ -1324,10 +1324,13 @@
connection.disconnectWith = mPeer.disconnectWith;

connection.checkPresence = function(remoteUserId, callback) {
mPeer.onNegotiationNeeded({
detectPresence: true,
userid: (remoteUserId || connection.sessionid) + ''
}, 'system', callback);
if (!connection.socket) {
connection.connectSocket(function() {
connection.checkPresence(remoteUserId, callback);
});
return;
}
connection.socket.emit('check-presence', (remoteUserId || connection.sessionid) + '', callback);
};

connection.onReadyForOffer = function(remoteUserId, userPreferences) {
Expand Down Expand Up @@ -1428,7 +1431,7 @@
screen: 30
};

if (connection.mediaConstraints.audio && connection.mediaConstraints.audio.optional.length) {
if (connection.mediaConstraints.audio && connection.mediaConstraints.audio.optional && connection.mediaConstraints.audio.optional.length) {
var newArray = [];
connection.mediaConstraints.audio.optional.forEach(function(opt) {
if (typeof opt.bandwidth === 'undefined') {
Expand All @@ -1438,7 +1441,7 @@
connection.mediaConstraints.audio.optional = newArray;
}

if (connection.mediaConstraints.video && connection.mediaConstraints.video.optional.length) {
if (connection.mediaConstraints.video && connection.mediaConstraints.video.optional && connection.mediaConstraints.video.optional.length) {
var newArray = [];
connection.mediaConstraints.video.optional.forEach(function(opt) {
if (typeof opt.bandwidth === 'undefined') {
Expand Down Expand Up @@ -4432,34 +4435,6 @@
});
}

// chrome 50+ supports promises over "play" method
HTMLMediaElement.prototype.nativePlay = HTMLMediaElement.prototype.play;
HTMLMediaElement.prototype.play = function() {
var myself = this;
var promise = myself.nativePlay();
if (promise) {
promise.then(function() {
// maybe it is Android
setTimeout(function() {
myself.nativePlay().then(function() {
// skip
}).catch(function() {
alert('Video requires manual action to start the player.');
});
}, 1000);
}).catch(function() {
// maybe it is iOS webview
setTimeout(function() {
myself.nativePlay().then(function() {
// skip
}).catch(function() {
alert('Video requires manual action to start the player.');
});
}, 1000);
});
}
};

// Proxy existing globals
getUserMedia = window.navigator && window.navigator.getUserMedia;
}
Expand Down
10 changes: 5 additions & 5 deletions RTCMultiConnection.min.js

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions Signaling-Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,20 @@ module.exports = exports = function(app, socketCallback) {
}
});

socket.on('check-presence', function(userid, callback) {
if (userid === socket.userid && !!listOfUsers[userid]) {
callback(false, socket.userid, listOfUsers[userid].extra);
return;
}

var extra = {};
if (listOfUsers[userid]) {
extra = listOfUsers[userid].extra;
}

callback(!!listOfUsers[userid], userid, extra);
});

function onMessageCallback(message) {
try {
if (!listOfUsers[message.sender]) {
Expand Down Expand Up @@ -244,18 +258,6 @@ module.exports = exports = function(app, socketCallback) {
return;
}

if (message.remoteUserId == 'system') {
if (message.message.detectPresence) {
if (message.message.userid === socket.userid) {
callback(false, socket.userid);
return;
}

callback(!!listOfUsers[message.message.userid], message.message.userid);
return;
}
}

if (!listOfUsers[message.sender]) {
listOfUsers[message.sender] = {
socket: socket,
Expand Down
44 changes: 44 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "rtcmulticonnection",
"description": "RTCMultiConnection is a WebRTC JavaScript wrapper library runs top over RTCPeerConnection API to provide multi-session establishment scenarios.",
"version": "3.3.00",
"authors": [
{
"name": "Muaz Khan",
"email": "[email protected]",
"homepage": "http://www.muazkhan.com/"
}
],
"main": "server.js",
"keywords": [
"webrtc",
"rtcmulticonnection",
"webrtc-library",
"library",
"javascript",
"chrome",
"firefox",
"opera",
"ie",
"internet-explorer",
"android",
"rtcweb",
"rtcmulticonnection.js",
"multirtc",
"webrtc-experiment",
"javascript-library",
"muaz",
"muaz-khan"
],
"repository": {
"type": "git",
"url": "https://github.com/muaz-khan/RTCMultiConnection.git"
},
"homepage": "http://www.rtcmulticonnection.org",
"ignore": [
"**/.*",
"node_modules",
"test",
"tests"
]
}
4 changes: 3 additions & 1 deletion demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You can test all demos LIVE here:

| DemoTitle | TestLive | ViewSource |
| ------------- |-------------|-------------|
| Audio+Video+File+Text | [Demo](https://rtcmulticonnection.herokuapp.com/demos/) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/Audio+Video+TextChat+FileSharing.html) |
| Audio+Video+File+TextChat | [Demo](https://rtcmulticonnection.herokuapp.com/demos/Audio+Video+TextChat+FileSharing.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/Audio+Video+TextChat+FileSharing.html) |
| FileSharing | [Demo](https://rtcmulticonnection.herokuapp.com/demos/file-sharing.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/file-sharing.html) |
| Scalable Audio/Video Broadcast | [Demo](https://rtcmulticonnection.herokuapp.com/demos/Scalable-Broadcast.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/Scalable-Broadcast.html) |
| Scalable Video Broadcast | [Demo](https://rtcmulticonnection.herokuapp.com/demos/Video-Scalable-Broadcast.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/Video-Scalable-Broadcast.html) |
Expand All @@ -28,6 +28,8 @@ You can test all demos LIVE here:
| getPublicModerators | [Demo](https://rtcmulticonnection.herokuapp.com/demos/getPublicModerators.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/getPublicModerators.html) |
| Change Cameras/Microphonea | [Demo](https://rtcmulticonnection.herokuapp.com/demos/Switch-Cameras.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/Switch-Cameras.html) |
| MultiRTC: Skype-like app | [Demo](https://rtcmulticonnection.herokuapp.com/demos/MultiRTC/) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/MultiRTC/) |
| Change Video Resolutions in your Live Sessions | [Demo](https://rtcmulticonnection.herokuapp.com/demos/change-resolutions.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/change-resolutions.html) |
| Admin/Guest demo | [Demo](https://rtcmulticonnection.herokuapp.com/demos/admin-guest.html) | [Source](https://github.com/muaz-khan/RTCMultiConnection/tree/master/demos/admin-guest.html) |

Source codes are available here:

Expand Down
Loading

0 comments on commit e227d48

Please sign in to comment.