Parcourir la source

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.

j8
hristoterezov il y a 10 ans
Parent
révision
dbcfc92dc4

+ 1
- 1
index.html Voir le fichier

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

+ 55
- 18
libs/app.bundle.js Voir le fichier

@@ -869,10 +869,11 @@ var RTC = {
869 869
                 callback();
870 870
             };
871 871
         }
872
-        this.localVideo = this.createLocalStream(stream, "video", true, type);
872
+        var videoStream = this.rtcUtils.createVideoStream(stream);
873
+        this.localVideo = this.createLocalStream(videoStream, "video", true, type);
873 874
         // Stop the stream to trigger onended event for old stream
874 875
         oldStream.stop();
875
-        APP.xmpp.switchStreams(stream, oldStream,localCallback);
876
+        APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
876 877
     },
877 878
     /**
878 879
      * Checks if video identified by given src is desktop stream.
@@ -1220,8 +1221,9 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions = function(devices, callback)
1220 1221
 }
1221 1222
 
1222 1223
 RTCUtils.prototype.successCallback = function (stream) {
1223
-    console.log('got', stream, stream.getAudioTracks().length,
1224
-        stream.getVideoTracks().length);
1224
+    if(stream)
1225
+        console.log('got', stream, stream.getAudioTracks().length,
1226
+            stream.getVideoTracks().length);
1225 1227
     this.handleLocalStream(stream);
1226 1228
 };
1227 1229
 
@@ -1253,8 +1255,9 @@ RTCUtils.prototype.errorCallback = function (error) {
1253 1255
             function (error) {
1254 1256
                 console.error('failed to obtain audio/video stream - stop',
1255 1257
                     error);
1256
-                APP.UI.messageHandler.showError("dialog.error",
1257
-                    "dialog.failedpermissions");
1258
+//                APP.UI.messageHandler.showError("dialog.error",
1259
+//                    "dialog.failedpermissions");
1260
+                return self.successCallback(null);
1258 1261
             }
1259 1262
         );
1260 1263
     }
@@ -1267,18 +1270,21 @@ RTCUtils.prototype.handleLocalStream = function(stream)
1267 1270
     {
1268 1271
         var audioStream = new webkitMediaStream();
1269 1272
         var videoStream = new webkitMediaStream();
1270
-        var audioTracks = stream.getAudioTracks();
1271
-        var videoTracks = stream.getVideoTracks();
1272
-        for (var i = 0; i < audioTracks.length; i++) {
1273
-            audioStream.addTrack(audioTracks[i]);
1274
-        }
1273
+        if(stream) {
1274
+            var audioTracks = stream.getAudioTracks();
1275 1275
 
1276
-        this.service.createLocalStream(audioStream, "audio");
1276
+            for (var i = 0; i < audioTracks.length; i++) {
1277
+                audioStream.addTrack(audioTracks[i]);
1278
+            }
1279
+
1280
+            var videoTracks = stream.getVideoTracks();
1277 1281
 
1278
-        for (i = 0; i < videoTracks.length; i++) {
1279
-            videoStream.addTrack(videoTracks[i]);
1282
+            for (i = 0; i < videoTracks.length; i++) {
1283
+                videoStream.addTrack(videoTracks[i]);
1284
+            }
1280 1285
         }
1281 1286
 
1287
+        this.service.createLocalStream(audioStream, "audio");
1282 1288
 
1283 1289
         this.service.createLocalStream(videoStream, "video");
1284 1290
     }
@@ -1289,6 +1295,28 @@ RTCUtils.prototype.handleLocalStream = function(stream)
1289 1295
 
1290 1296
 };
1291 1297
 
1298
+RTCUtils.prototype.createVideoStream = function(stream)
1299
+{
1300
+    var videoStream = null;
1301
+    if(window.webkitMediaStream)
1302
+    {
1303
+        videoStream = new webkitMediaStream();
1304
+        if(stream)
1305
+        {
1306
+            var videoTracks = stream.getVideoTracks();
1307
+
1308
+            for (i = 0; i < videoTracks.length; i++) {
1309
+                videoStream.addTrack(videoTracks[i]);
1310
+            }
1311
+        }
1312
+
1313
+    }
1314
+    else
1315
+        videoStream = stream;
1316
+
1317
+    return videoStream;
1318
+};
1319
+
1292 1320
 module.exports = RTCUtils;
1293 1321
 
1294 1322
 },{"../../service/RTC/RTCBrowserType.js":88,"../../service/RTC/Resolutions":90}],8:[function(require,module,exports){
@@ -9472,6 +9500,8 @@ function initInlineInstalls()
9472 9500
 function getSwitchStreamFailed(error) {
9473 9501
     console.error("Failed to obtain the stream to switch to", error);
9474 9502
     switchInProgress = false;
9503
+    isUsingScreenStream = false;
9504
+    newStreamCreated(null);
9475 9505
 }
9476 9506
 
9477 9507
 function streamSwitchDone() {
@@ -13125,7 +13155,8 @@ JingleSession.prototype.switchStreams = function (new_stream, oldStream, success
13125 13155
             oldSdp = new SDP(self.peerconnection.localDescription.sdp);
13126 13156
         }
13127 13157
         self.peerconnection.removeStream(oldStream, true);
13128
-        self.peerconnection.addStream(new_stream);
13158
+        if(new_stream)
13159
+            self.peerconnection.addStream(new_stream);
13129 13160
     }
13130 13161
 
13131 13162
     APP.RTC.switchVideoStreams(new_stream, oldStream);
@@ -19345,6 +19376,7 @@ var strings = require('./utils/strings');
19345 19376
 var msg = require('./zlib/messages');
19346 19377
 var zstream = require('./zlib/zstream');
19347 19378
 
19379
+var toString = Object.prototype.toString;
19348 19380
 
19349 19381
 /* Public constants ==========================================================*/
19350 19382
 /* ===========================================================================*/
@@ -19500,8 +19532,8 @@ var Deflate = function(options) {
19500 19532
 
19501 19533
 /**
19502 19534
  * Deflate#push(data[, mode]) -> Boolean
19503
- * - data (Uint8Array|Array|String): input data. Strings will be converted to
19504
- *   utf8 byte sequence.
19535
+ * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be
19536
+ *   converted to utf8 byte sequence.
19505 19537
  * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
19506 19538
  *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
19507 19539
  *
@@ -19539,6 +19571,8 @@ Deflate.prototype.push = function(data, mode) {
19539 19571
   if (typeof data === 'string') {
19540 19572
     // If we need to compress text, change encoding to utf8.
19541 19573
     strm.input = strings.string2buf(data);
19574
+  } else if (toString.call(data) === '[object ArrayBuffer]') {
19575
+    strm.input = new Uint8Array(data);
19542 19576
   } else {
19543 19577
     strm.input = data;
19544 19578
   }
@@ -19709,6 +19743,7 @@ var msg = require('./zlib/messages');
19709 19743
 var zstream = require('./zlib/zstream');
19710 19744
 var gzheader = require('./zlib/gzheader');
19711 19745
 
19746
+var toString = Object.prototype.toString;
19712 19747
 
19713 19748
 /**
19714 19749
  * class Inflate
@@ -19843,7 +19878,7 @@ var Inflate = function(options) {
19843 19878
 
19844 19879
 /**
19845 19880
  * Inflate#push(data[, mode]) -> Boolean
19846
- * - data (Uint8Array|Array|String): input data
19881
+ * - data (Uint8Array|Array|ArrayBuffer|String): input data
19847 19882
  * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
19848 19883
  *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
19849 19884
  *
@@ -19881,6 +19916,8 @@ Inflate.prototype.push = function(data, mode) {
19881 19916
   if (typeof data === 'string') {
19882 19917
     // Only binary strings can be decompressed on practice
19883 19918
     strm.input = strings.binstring2buf(data);
19919
+  } else if (toString.call(data) === '[object ArrayBuffer]') {
19920
+    strm.input = new Uint8Array(data);
19884 19921
   } else {
19885 19922
     strm.input = data;
19886 19923
   }

+ 3
- 2
modules/RTC/RTC.js Voir le fichier

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

+ 39
- 12
modules/RTC/RTCUtils.js Voir le fichier

@@ -294,8 +294,9 @@ RTCUtils.prototype.obtainAudioAndVideoPermissions = function(devices, callback)
294 294
 }
295 295
 
296 296
 RTCUtils.prototype.successCallback = function (stream) {
297
-    console.log('got', stream, stream.getAudioTracks().length,
298
-        stream.getVideoTracks().length);
297
+    if(stream)
298
+        console.log('got', stream, stream.getAudioTracks().length,
299
+            stream.getVideoTracks().length);
299 300
     this.handleLocalStream(stream);
300 301
 };
301 302
 
@@ -327,8 +328,9 @@ RTCUtils.prototype.errorCallback = function (error) {
327 328
             function (error) {
328 329
                 console.error('failed to obtain audio/video stream - stop',
329 330
                     error);
330
-                APP.UI.messageHandler.showError("dialog.error",
331
-                    "dialog.failedpermissions");
331
+//                APP.UI.messageHandler.showError("dialog.error",
332
+//                    "dialog.failedpermissions");
333
+                return self.successCallback(null);
332 334
             }
333 335
         );
334 336
     }
@@ -341,18 +343,21 @@ RTCUtils.prototype.handleLocalStream = function(stream)
341 343
     {
342 344
         var audioStream = new webkitMediaStream();
343 345
         var videoStream = new webkitMediaStream();
344
-        var audioTracks = stream.getAudioTracks();
345
-        var videoTracks = stream.getVideoTracks();
346
-        for (var i = 0; i < audioTracks.length; i++) {
347
-            audioStream.addTrack(audioTracks[i]);
348
-        }
346
+        if(stream) {
347
+            var audioTracks = stream.getAudioTracks();
349 348
 
350
-        this.service.createLocalStream(audioStream, "audio");
349
+            for (var i = 0; i < audioTracks.length; i++) {
350
+                audioStream.addTrack(audioTracks[i]);
351
+            }
351 352
 
352
-        for (i = 0; i < videoTracks.length; i++) {
353
-            videoStream.addTrack(videoTracks[i]);
353
+            var videoTracks = stream.getVideoTracks();
354
+
355
+            for (i = 0; i < videoTracks.length; i++) {
356
+                videoStream.addTrack(videoTracks[i]);
357
+            }
354 358
         }
355 359
 
360
+        this.service.createLocalStream(audioStream, "audio");
356 361
 
357 362
         this.service.createLocalStream(videoStream, "video");
358 363
     }
@@ -363,4 +368,26 @@ RTCUtils.prototype.handleLocalStream = function(stream)
363 368
 
364 369
 };
365 370
 
371
+RTCUtils.prototype.createVideoStream = function(stream)
372
+{
373
+    var videoStream = null;
374
+    if(window.webkitMediaStream)
375
+    {
376
+        videoStream = new webkitMediaStream();
377
+        if(stream)
378
+        {
379
+            var videoTracks = stream.getVideoTracks();
380
+
381
+            for (i = 0; i < videoTracks.length; i++) {
382
+                videoStream.addTrack(videoTracks[i]);
383
+            }
384
+        }
385
+
386
+    }
387
+    else
388
+        videoStream = stream;
389
+
390
+    return videoStream;
391
+};
392
+
366 393
 module.exports = RTCUtils;

+ 2
- 0
modules/desktopsharing/desktopsharing.js Voir le fichier

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

+ 2
- 1
modules/xmpp/JingleSession.js Voir le fichier

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

Chargement…
Annuler
Enregistrer