Skip to content

Commit

Permalink
Minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
muaz-khan committed Nov 16, 2016
1 parent 2b8dc6d commit 9191d3c
Showing 5 changed files with 72 additions and 14 deletions.
21 changes: 20 additions & 1 deletion dev/RTCMultiConnection.js
Original file line number Diff line number Diff line change
@@ -1093,7 +1093,14 @@ function RTCMultiConnection(roomid, forceOptions) {
}

if (!isRemote) {
delete connection.attachStreams[connection.attachStreams.indexOf(stream)];
// reset attachStreams
var streams = [];
connection.attachStreams.forEach(function(s) {
if (s.id != stream.id) {
streams.push(s);
}
});
connection.attachStreams = streams;
}

// connection.renegotiate();
@@ -1110,6 +1117,18 @@ function RTCMultiConnection(roomid, forceOptions) {
};
}

if (isRemote && connection.peers[streamEvent.userid]) {
// reset remote "streams"
var peer = connection.peers[streamEvent.userid].peer;
var streams = [];
peer.getRemoteStreams().forEach(function(s) {
if (s.id != stream.id) {
streams.push(s);
}
});
connection.peers[streamEvent.userid].streams = streams;
}

if (streamEvent.userid === connection.userid && streamEvent.type === 'remote') {
return;
}
13 changes: 11 additions & 2 deletions dev/Screen-Capturing.js
Original file line number Diff line number Diff line change
@@ -50,7 +50,8 @@ function onMessageCallback(data) {

// extension shared temp sourceId
if (data.sourceId && screenCallback) {
screenCallback(sourceId = data.sourceId);
sourceId = data.sourceId;
screenCallback(sourceId);
}
}

@@ -71,7 +72,10 @@ function isChromeExtensionAvailable(callback) {
return;
}

if (chromeMediaSource == 'desktop') return callback(true);
if (chromeMediaSource == 'desktop') {
callback(true);
return;
}

// ask extension if it is available
window.postMessage('are-you-there', '*');
@@ -155,6 +159,7 @@ function getChromeExtensionStatus(extensionid, callback) {
var image = document.createElement('img');
image.src = 'chrome-extension://' + extensionid + '/icon.png';
image.onload = function() {
sourceId = null;
chromeMediaSource = 'screen';
window.postMessage('are-you-there', '*');
setTimeout(function() {
@@ -220,6 +225,10 @@ function getScreenConstraints(callback, audioPlusTab) {
screen_constraints.mandatory.chromeMediaSourceId = sourceId;
}

sourceId = null;
chromeMediaSource = 'screen'; // maybe this line is redundant?
screenCallback = null;

// now invoking native getUserMedia API
callback(null, screen_constraints);
});
3 changes: 2 additions & 1 deletion dev/getUserMedia.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@ function setStreamType(constraints, stream) {
}
}

var currentUserMediaRequest = {
// allow users to manage this object (to support re-capturing of screen/etc.)
window.currentUserMediaRequest = {
streams: [],
mutex: false,
queueRequests: [],
39 changes: 34 additions & 5 deletions dist/RTCMultiConnection.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Last time updated: 2016-11-12 6:04:49 AM UTC
// Last time updated: 2016-11-16 2:15:21 PM UTC

// _________________________
// RTCMultiConnection v3.4.2
@@ -1109,7 +1109,14 @@
}

if (!isRemote) {
delete connection.attachStreams[connection.attachStreams.indexOf(stream)];
// reset attachStreams
var streams = [];
connection.attachStreams.forEach(function(s) {
if (s.id != stream.id) {
streams.push(s);
}
});
connection.attachStreams = streams;
}

// connection.renegotiate();
@@ -1126,6 +1133,18 @@
};
}

if (isRemote && connection.peers[streamEvent.userid]) {
// reset remote "streams"
var peer = connection.peers[streamEvent.userid].peer;
var streams = [];
peer.getRemoteStreams().forEach(function(s) {
if (s.id != stream.id) {
streams.push(s);
}
});
connection.peers[streamEvent.userid].streams = streams;
}

if (streamEvent.userid === connection.userid && streamEvent.type === 'remote') {
return;
}
@@ -4735,7 +4754,8 @@
}
}

var currentUserMediaRequest = {
// allow users to manage this object (to support re-capturing of screen/etc.)
window.currentUserMediaRequest = {
streams: [],
mutex: false,
queueRequests: [],
@@ -5046,7 +5066,8 @@

// extension shared temp sourceId
if (data.sourceId && screenCallback) {
screenCallback(sourceId = data.sourceId);
sourceId = data.sourceId;
screenCallback(sourceId);
}
}

@@ -5067,7 +5088,10 @@
return;
}

if (chromeMediaSource == 'desktop') return callback(true);
if (chromeMediaSource == 'desktop') {
callback(true);
return;
}

// ask extension if it is available
window.postMessage('are-you-there', '*');
@@ -5151,6 +5175,7 @@
var image = document.createElement('img');
image.src = 'chrome-extension://' + extensionid + '/icon.png';
image.onload = function() {
sourceId = null;
chromeMediaSource = 'screen';
window.postMessage('are-you-there', '*');
setTimeout(function() {
@@ -5216,6 +5241,10 @@
screen_constraints.mandatory.chromeMediaSourceId = sourceId;
}

sourceId = null;
chromeMediaSource = 'screen'; // maybe this line is redundant?
screenCallback = null;

// now invoking native getUserMedia API
callback(null, screen_constraints);
});
10 changes: 5 additions & 5 deletions dist/RTCMultiConnection.min.js

Large diffs are not rendered by default.

0 comments on commit 9191d3c

Please sign in to comment.