Changes the implementation to allow users without audio and video to join the conferences. Fixes issue with switching off desktop sharing for audio only users.

This commit is contained in:
hristoterezov 2015-03-24 17:43:33 +02:00
parent b9bd1d599b
commit dbcfc92dc4
6 changed files with 104 additions and 36 deletions

View File

@ -19,7 +19,7 @@
<script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib --> <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
<script src="libs/toastr.js?v=1"></script><!-- notifications lib --> <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
<script src="interface_config.js?v=5"></script> <script src="interface_config.js?v=5"></script>
<script src="libs/app.bundle.js?v=44"></script> <script src="libs/app.bundle.js?v=45"></script>
<script src="analytics.js?v=1"></script><!-- google analytics plugin --> <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
<link rel="stylesheet" href="css/font.css?v=6"/> <link rel="stylesheet" href="css/font.css?v=6"/>
<link rel="stylesheet" href="css/toastr.css?v=1"> <link rel="stylesheet" href="css/toastr.css?v=1">

View File

@ -869,10 +869,11 @@ var RTC = {
callback(); callback();
}; };
} }
this.localVideo = this.createLocalStream(stream, "video", true, type); var videoStream = this.rtcUtils.createVideoStream(stream);
this.localVideo = this.createLocalStream(videoStream, "video", true, type);
// Stop the stream to trigger onended event for old stream // Stop the stream to trigger onended event for old stream
oldStream.stop(); oldStream.stop();
APP.xmpp.switchStreams(stream, oldStream,localCallback); APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
}, },
/** /**
* Checks if video identified by given src is desktop stream. * Checks if video identified by given src is desktop stream.
@ -1220,8 +1221,9 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions = function(devices, callback)
} }
RTCUtils.prototype.successCallback = function (stream) { RTCUtils.prototype.successCallback = function (stream) {
console.log('got', stream, stream.getAudioTracks().length, if(stream)
stream.getVideoTracks().length); console.log('got', stream, stream.getAudioTracks().length,
stream.getVideoTracks().length);
this.handleLocalStream(stream); this.handleLocalStream(stream);
}; };
@ -1253,8 +1255,9 @@ RTCUtils.prototype.errorCallback = function (error) {
function (error) { function (error) {
console.error('failed to obtain audio/video stream - stop', console.error('failed to obtain audio/video stream - stop',
error); error);
APP.UI.messageHandler.showError("dialog.error", // APP.UI.messageHandler.showError("dialog.error",
"dialog.failedpermissions"); // "dialog.failedpermissions");
return self.successCallback(null);
} }
); );
} }
@ -1267,19 +1270,22 @@ RTCUtils.prototype.handleLocalStream = function(stream)
{ {
var audioStream = new webkitMediaStream(); var audioStream = new webkitMediaStream();
var videoStream = new webkitMediaStream(); var videoStream = new webkitMediaStream();
var audioTracks = stream.getAudioTracks(); if(stream) {
var videoTracks = stream.getVideoTracks(); var audioTracks = stream.getAudioTracks();
for (var i = 0; i < audioTracks.length; i++) {
audioStream.addTrack(audioTracks[i]); for (var i = 0; i < audioTracks.length; i++) {
audioStream.addTrack(audioTracks[i]);
}
var videoTracks = stream.getVideoTracks();
for (i = 0; i < videoTracks.length; i++) {
videoStream.addTrack(videoTracks[i]);
}
} }
this.service.createLocalStream(audioStream, "audio"); this.service.createLocalStream(audioStream, "audio");
for (i = 0; i < videoTracks.length; i++) {
videoStream.addTrack(videoTracks[i]);
}
this.service.createLocalStream(videoStream, "video"); this.service.createLocalStream(videoStream, "video");
} }
else else
@ -1289,6 +1295,28 @@ RTCUtils.prototype.handleLocalStream = function(stream)
}; };
RTCUtils.prototype.createVideoStream = function(stream)
{
var videoStream = null;
if(window.webkitMediaStream)
{
videoStream = new webkitMediaStream();
if(stream)
{
var videoTracks = stream.getVideoTracks();
for (i = 0; i < videoTracks.length; i++) {
videoStream.addTrack(videoTracks[i]);
}
}
}
else
videoStream = stream;
return videoStream;
};
module.exports = RTCUtils; module.exports = RTCUtils;
},{"../../service/RTC/RTCBrowserType.js":88,"../../service/RTC/Resolutions":90}],8:[function(require,module,exports){ },{"../../service/RTC/RTCBrowserType.js":88,"../../service/RTC/Resolutions":90}],8:[function(require,module,exports){
@ -9472,6 +9500,8 @@ function initInlineInstalls()
function getSwitchStreamFailed(error) { function getSwitchStreamFailed(error) {
console.error("Failed to obtain the stream to switch to", error); console.error("Failed to obtain the stream to switch to", error);
switchInProgress = false; switchInProgress = false;
isUsingScreenStream = false;
newStreamCreated(null);
} }
function streamSwitchDone() { function streamSwitchDone() {
@ -13125,7 +13155,8 @@ JingleSession.prototype.switchStreams = function (new_stream, oldStream, success
oldSdp = new SDP(self.peerconnection.localDescription.sdp); oldSdp = new SDP(self.peerconnection.localDescription.sdp);
} }
self.peerconnection.removeStream(oldStream, true); self.peerconnection.removeStream(oldStream, true);
self.peerconnection.addStream(new_stream); if(new_stream)
self.peerconnection.addStream(new_stream);
} }
APP.RTC.switchVideoStreams(new_stream, oldStream); APP.RTC.switchVideoStreams(new_stream, oldStream);
@ -19345,6 +19376,7 @@ var strings = require('./utils/strings');
var msg = require('./zlib/messages'); var msg = require('./zlib/messages');
var zstream = require('./zlib/zstream'); var zstream = require('./zlib/zstream');
var toString = Object.prototype.toString;
/* Public constants ==========================================================*/ /* Public constants ==========================================================*/
/* ===========================================================================*/ /* ===========================================================================*/
@ -19500,8 +19532,8 @@ var Deflate = function(options) {
/** /**
* Deflate#push(data[, mode]) -> Boolean * Deflate#push(data[, mode]) -> Boolean
* - data (Uint8Array|Array|String): input data. Strings will be converted to * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be
* utf8 byte sequence. * converted to utf8 byte sequence.
* - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes. * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
* See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH. * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
* *
@ -19539,6 +19571,8 @@ Deflate.prototype.push = function(data, mode) {
if (typeof data === 'string') { if (typeof data === 'string') {
// If we need to compress text, change encoding to utf8. // If we need to compress text, change encoding to utf8.
strm.input = strings.string2buf(data); strm.input = strings.string2buf(data);
} else if (toString.call(data) === '[object ArrayBuffer]') {
strm.input = new Uint8Array(data);
} else { } else {
strm.input = data; strm.input = data;
} }
@ -19709,6 +19743,7 @@ var msg = require('./zlib/messages');
var zstream = require('./zlib/zstream'); var zstream = require('./zlib/zstream');
var gzheader = require('./zlib/gzheader'); var gzheader = require('./zlib/gzheader');
var toString = Object.prototype.toString;
/** /**
* class Inflate * class Inflate
@ -19843,7 +19878,7 @@ var Inflate = function(options) {
/** /**
* Inflate#push(data[, mode]) -> Boolean * Inflate#push(data[, mode]) -> Boolean
* - data (Uint8Array|Array|String): input data * - data (Uint8Array|Array|ArrayBuffer|String): input data
* - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes. * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
* See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH. * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
* *
@ -19881,6 +19916,8 @@ Inflate.prototype.push = function(data, mode) {
if (typeof data === 'string') { if (typeof data === 'string') {
// Only binary strings can be decompressed on practice // Only binary strings can be decompressed on practice
strm.input = strings.binstring2buf(data); strm.input = strings.binstring2buf(data);
} else if (toString.call(data) === '[object ArrayBuffer]') {
strm.input = new Uint8Array(data);
} else { } else {
strm.input = data; strm.input = data;
} }

View File

@ -174,10 +174,11 @@ var RTC = {
callback(); callback();
}; };
} }
this.localVideo = this.createLocalStream(stream, "video", true, type); var videoStream = this.rtcUtils.createVideoStream(stream);
this.localVideo = this.createLocalStream(videoStream, "video", true, type);
// Stop the stream to trigger onended event for old stream // Stop the stream to trigger onended event for old stream
oldStream.stop(); oldStream.stop();
APP.xmpp.switchStreams(stream, oldStream,localCallback); APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
}, },
/** /**
* Checks if video identified by given src is desktop stream. * Checks if video identified by given src is desktop stream.

View File

@ -294,8 +294,9 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions = function(devices, callback)
} }
RTCUtils.prototype.successCallback = function (stream) { RTCUtils.prototype.successCallback = function (stream) {
console.log('got', stream, stream.getAudioTracks().length, if(stream)
stream.getVideoTracks().length); console.log('got', stream, stream.getAudioTracks().length,
stream.getVideoTracks().length);
this.handleLocalStream(stream); this.handleLocalStream(stream);
}; };
@ -327,8 +328,9 @@ RTCUtils.prototype.errorCallback = function (error) {
function (error) { function (error) {
console.error('failed to obtain audio/video stream - stop', console.error('failed to obtain audio/video stream - stop',
error); error);
APP.UI.messageHandler.showError("dialog.error", // APP.UI.messageHandler.showError("dialog.error",
"dialog.failedpermissions"); // "dialog.failedpermissions");
return self.successCallback(null);
} }
); );
} }
@ -341,19 +343,22 @@ RTCUtils.prototype.handleLocalStream = function(stream)
{ {
var audioStream = new webkitMediaStream(); var audioStream = new webkitMediaStream();
var videoStream = new webkitMediaStream(); var videoStream = new webkitMediaStream();
var audioTracks = stream.getAudioTracks(); if(stream) {
var videoTracks = stream.getVideoTracks(); var audioTracks = stream.getAudioTracks();
for (var i = 0; i < audioTracks.length; i++) {
audioStream.addTrack(audioTracks[i]); for (var i = 0; i < audioTracks.length; i++) {
audioStream.addTrack(audioTracks[i]);
}
var videoTracks = stream.getVideoTracks();
for (i = 0; i < videoTracks.length; i++) {
videoStream.addTrack(videoTracks[i]);
}
} }
this.service.createLocalStream(audioStream, "audio"); this.service.createLocalStream(audioStream, "audio");
for (i = 0; i < videoTracks.length; i++) {
videoStream.addTrack(videoTracks[i]);
}
this.service.createLocalStream(videoStream, "video"); this.service.createLocalStream(videoStream, "video");
} }
else else
@ -363,4 +368,26 @@ RTCUtils.prototype.handleLocalStream = function(stream)
}; };
RTCUtils.prototype.createVideoStream = function(stream)
{
var videoStream = null;
if(window.webkitMediaStream)
{
videoStream = new webkitMediaStream();
if(stream)
{
var videoTracks = stream.getVideoTracks();
for (i = 0; i < videoTracks.length; i++) {
videoStream.addTrack(videoTracks[i]);
}
}
}
else
videoStream = stream;
return videoStream;
};
module.exports = RTCUtils; module.exports = RTCUtils;

View File

@ -240,6 +240,8 @@ function initInlineInstalls()
function getSwitchStreamFailed(error) { function getSwitchStreamFailed(error) {
console.error("Failed to obtain the stream to switch to", error); console.error("Failed to obtain the stream to switch to", error);
switchInProgress = false; switchInProgress = false;
isUsingScreenStream = false;
newStreamCreated(null);
} }
function streamSwitchDone() { function streamSwitchDone() {

View File

@ -971,7 +971,8 @@ JingleSession.prototype.switchStreams = function (new_stream, oldStream, success
oldSdp = new SDP(self.peerconnection.localDescription.sdp); oldSdp = new SDP(self.peerconnection.localDescription.sdp);
} }
self.peerconnection.removeStream(oldStream, true); self.peerconnection.removeStream(oldStream, true);
self.peerconnection.addStream(new_stream); if(new_stream)
self.peerconnection.addStream(new_stream);
} }
APP.RTC.switchVideoStreams(new_stream, oldStream); APP.RTC.switchVideoStreams(new_stream, oldStream);