Browse 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 10 years ago
parent
commit
dbcfc92dc4

+ 1
- 1
index.html View File

19
     <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
19
     <script src="libs/popover.js?v=1"></script><!-- bootstrap tooltip lib -->
20
     <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
20
     <script src="libs/toastr.js?v=1"></script><!-- notifications lib -->
21
     <script src="interface_config.js?v=5"></script>
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
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
23
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
24
     <link rel="stylesheet" href="css/font.css?v=6"/>
24
     <link rel="stylesheet" href="css/font.css?v=6"/>
25
     <link rel="stylesheet" href="css/toastr.css?v=1">
25
     <link rel="stylesheet" href="css/toastr.css?v=1">

+ 55
- 18
libs/app.bundle.js View File

869
                 callback();
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
         // Stop the stream to trigger onended event for old stream
874
         // Stop the stream to trigger onended event for old stream
874
         oldStream.stop();
875
         oldStream.stop();
875
-        APP.xmpp.switchStreams(stream, oldStream,localCallback);
876
+        APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
876
     },
877
     },
877
     /**
878
     /**
878
      * Checks if video identified by given src is desktop stream.
879
      * Checks if video identified by given src is desktop stream.
1220
 }
1221
 }
1221
 
1222
 
1222
 RTCUtils.prototype.successCallback = function (stream) {
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
     this.handleLocalStream(stream);
1227
     this.handleLocalStream(stream);
1226
 };
1228
 };
1227
 
1229
 
1253
             function (error) {
1255
             function (error) {
1254
                 console.error('failed to obtain audio/video stream - stop',
1256
                 console.error('failed to obtain audio/video stream - stop',
1255
                     error);
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
     {
1270
     {
1268
         var audioStream = new webkitMediaStream();
1271
         var audioStream = new webkitMediaStream();
1269
         var videoStream = new webkitMediaStream();
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
         this.service.createLocalStream(videoStream, "video");
1289
         this.service.createLocalStream(videoStream, "video");
1284
     }
1290
     }
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
 module.exports = RTCUtils;
1320
 module.exports = RTCUtils;
1293
 
1321
 
1294
 },{"../../service/RTC/RTCBrowserType.js":88,"../../service/RTC/Resolutions":90}],8:[function(require,module,exports){
1322
 },{"../../service/RTC/RTCBrowserType.js":88,"../../service/RTC/Resolutions":90}],8:[function(require,module,exports){
9472
 function getSwitchStreamFailed(error) {
9500
 function getSwitchStreamFailed(error) {
9473
     console.error("Failed to obtain the stream to switch to", error);
9501
     console.error("Failed to obtain the stream to switch to", error);
9474
     switchInProgress = false;
9502
     switchInProgress = false;
9503
+    isUsingScreenStream = false;
9504
+    newStreamCreated(null);
9475
 }
9505
 }
9476
 
9506
 
9477
 function streamSwitchDone() {
9507
 function streamSwitchDone() {
13125
             oldSdp = new SDP(self.peerconnection.localDescription.sdp);
13155
             oldSdp = new SDP(self.peerconnection.localDescription.sdp);
13126
         }
13156
         }
13127
         self.peerconnection.removeStream(oldStream, true);
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
     APP.RTC.switchVideoStreams(new_stream, oldStream);
13162
     APP.RTC.switchVideoStreams(new_stream, oldStream);
19345
 var msg = require('./zlib/messages');
19376
 var msg = require('./zlib/messages');
19346
 var zstream = require('./zlib/zstream');
19377
 var zstream = require('./zlib/zstream');
19347
 
19378
 
19379
+var toString = Object.prototype.toString;
19348
 
19380
 
19349
 /* Public constants ==========================================================*/
19381
 /* Public constants ==========================================================*/
19350
 /* ===========================================================================*/
19382
 /* ===========================================================================*/
19500
 
19532
 
19501
 /**
19533
 /**
19502
  * Deflate#push(data[, mode]) -> Boolean
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
  * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
19537
  * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
19506
  *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
19538
  *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
19507
  *
19539
  *
19539
   if (typeof data === 'string') {
19571
   if (typeof data === 'string') {
19540
     // If we need to compress text, change encoding to utf8.
19572
     // If we need to compress text, change encoding to utf8.
19541
     strm.input = strings.string2buf(data);
19573
     strm.input = strings.string2buf(data);
19574
+  } else if (toString.call(data) === '[object ArrayBuffer]') {
19575
+    strm.input = new Uint8Array(data);
19542
   } else {
19576
   } else {
19543
     strm.input = data;
19577
     strm.input = data;
19544
   }
19578
   }
19709
 var zstream = require('./zlib/zstream');
19743
 var zstream = require('./zlib/zstream');
19710
 var gzheader = require('./zlib/gzheader');
19744
 var gzheader = require('./zlib/gzheader');
19711
 
19745
 
19746
+var toString = Object.prototype.toString;
19712
 
19747
 
19713
 /**
19748
 /**
19714
  * class Inflate
19749
  * class Inflate
19843
 
19878
 
19844
 /**
19879
 /**
19845
  * Inflate#push(data[, mode]) -> Boolean
19880
  * Inflate#push(data[, mode]) -> Boolean
19846
- * - data (Uint8Array|Array|String): input data
19881
+ * - data (Uint8Array|Array|ArrayBuffer|String): input data
19847
  * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
19882
  * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
19848
  *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
19883
  *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
19849
  *
19884
  *
19881
   if (typeof data === 'string') {
19916
   if (typeof data === 'string') {
19882
     // Only binary strings can be decompressed on practice
19917
     // Only binary strings can be decompressed on practice
19883
     strm.input = strings.binstring2buf(data);
19918
     strm.input = strings.binstring2buf(data);
19919
+  } else if (toString.call(data) === '[object ArrayBuffer]') {
19920
+    strm.input = new Uint8Array(data);
19884
   } else {
19921
   } else {
19885
     strm.input = data;
19922
     strm.input = data;
19886
   }
19923
   }

+ 3
- 2
modules/RTC/RTC.js View File

174
                 callback();
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
         // Stop the stream to trigger onended event for old stream
179
         // Stop the stream to trigger onended event for old stream
179
         oldStream.stop();
180
         oldStream.stop();
180
-        APP.xmpp.switchStreams(stream, oldStream,localCallback);
181
+        APP.xmpp.switchStreams(videoStream, oldStream,localCallback);
181
     },
182
     },
182
     /**
183
     /**
183
      * Checks if video identified by given src is desktop stream.
184
      * Checks if video identified by given src is desktop stream.

+ 39
- 12
modules/RTC/RTCUtils.js View File

294
 }
294
 }
295
 
295
 
296
 RTCUtils.prototype.successCallback = function (stream) {
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
     this.handleLocalStream(stream);
300
     this.handleLocalStream(stream);
300
 };
301
 };
301
 
302
 
327
             function (error) {
328
             function (error) {
328
                 console.error('failed to obtain audio/video stream - stop',
329
                 console.error('failed to obtain audio/video stream - stop',
329
                     error);
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
     {
343
     {
342
         var audioStream = new webkitMediaStream();
344
         var audioStream = new webkitMediaStream();
343
         var videoStream = new webkitMediaStream();
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
         this.service.createLocalStream(videoStream, "video");
362
         this.service.createLocalStream(videoStream, "video");
358
     }
363
     }
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
 module.exports = RTCUtils;
393
 module.exports = RTCUtils;

+ 2
- 0
modules/desktopsharing/desktopsharing.js View File

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

+ 2
- 1
modules/xmpp/JingleSession.js View File

971
             oldSdp = new SDP(self.peerconnection.localDescription.sdp);
971
             oldSdp = new SDP(self.peerconnection.localDescription.sdp);
972
         }
972
         }
973
         self.peerconnection.removeStream(oldStream, true);
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
     APP.RTC.switchVideoStreams(new_stream, oldStream);
978
     APP.RTC.switchVideoStreams(new_stream, oldStream);

Loading…
Cancel
Save