Browse Source

fix issues in RTCUtils

master
isymchych 10 years ago
parent
commit
21d63506ee
2 changed files with 42 additions and 32 deletions
  1. 21
    16
      lib-jitsi-meet.js
  2. 21
    16
      modules/RTC/RTCUtils.js

+ 21
- 16
lib-jitsi-meet.js View File

@@ -2089,7 +2089,12 @@ isAndroid = navigator.userAgent.indexOf('Android') != -1;
2089 2089
 module.exports = RTCBrowserType;
2090 2090
 },{}],18:[function(require,module,exports){
2091 2091
 (function (__filename){
2092
-/* global config, require, attachMediaStream, getUserMedia */
2092
+/* global config, require, attachMediaStream, getUserMedia,
2093
+   RTCPeerConnection, RTCSessionDescription, RTCIceCandidate, MediaStreamTrack,
2094
+   mozRTCPeerConnection, mozRTCSessionDescription, mozRTCIceCandidate,
2095
+   webkitRTCPeerConnection, webkitMediaStream, webkitURL
2096
+*/
2097
+/* jshint -W101 */
2093 2098
 
2094 2099
 var logger = require("jitsi-meet-logger").getLogger(__filename);
2095 2100
 var RTCBrowserType = require("./RTCBrowserType");
@@ -2106,7 +2111,7 @@ var eventEmitter = new EventEmitter();
2106 2111
 var devices = {
2107 2112
     audio: true,
2108 2113
     video: true
2109
-}
2114
+};
2110 2115
 
2111 2116
 var rtcReady = false;
2112 2117
 
@@ -2286,7 +2291,7 @@ function onReady (options, GUM) {
2286 2291
     rtcReady = true;
2287 2292
     eventEmitter.emit(RTCEvents.RTC_READY, true);
2288 2293
     screenObtainer.init(eventEmitter, options, GUM);
2289
-};
2294
+}
2290 2295
 
2291 2296
 /**
2292 2297
  * Apply function with arguments if function exists.
@@ -2414,8 +2419,8 @@ function enumerateDevicesThroughMediaStreamTrack (callback) {
2414 2419
 }
2415 2420
 
2416 2421
 function obtainDevices(options) {
2417
-    if(!options.devices || options.devices.length === 0) {
2418
-        return options.successCallback(streams);
2422
+    if (!options.devices || options.devices.length === 0) {
2423
+        return options.successCallback(options.streams);
2419 2424
     }
2420 2425
 
2421 2426
     var device = options.devices.splice(0, 1);
@@ -2455,8 +2460,8 @@ function handleLocalStream(streams, resolution) {
2455 2460
             var videoTracks = audioVideo.getVideoTracks();
2456 2461
             if(videoTracks.length) {
2457 2462
                 videoStream = new webkitMediaStream();
2458
-                for (i = 0; i < videoTracks.length; i++) {
2459
-                    videoStream.addTrack(videoTracks[i]);
2463
+                for (var j = 0; j < videoTracks.length; j++) {
2464
+                    videoStream.addTrack(videoTracks[j]);
2460 2465
                 }
2461 2466
             }
2462 2467
         }
@@ -2595,7 +2600,7 @@ var RTCUtils = {
2595 2600
 
2596 2601
                 //AdapterJS.WebRTCPlugin.setLogLevel(
2597 2602
                 //    AdapterJS.WebRTCPlugin.PLUGIN_LOG_LEVELS.VERBOSE);
2598
-
2603
+                var self = this;
2599 2604
                 AdapterJS.webRTCReady(function (isPlugin) {
2600 2605
 
2601 2606
                     self.peerconnection = RTCPeerConnection;
@@ -2653,7 +2658,7 @@ var RTCUtils = {
2653 2658
 
2654 2659
             // Call onReady() if Temasys plugin is not used
2655 2660
             if (!RTCBrowserType.isTemasysPluginUsed()) {
2656
-                onReady(options, self.getUserMediaWithConstraints);
2661
+                onReady(options, this.getUserMediaWithConstraints);
2657 2662
                 resolve();
2658 2663
             }
2659 2664
         }.bind(this));
@@ -2672,9 +2677,8 @@ var RTCUtils = {
2672 2677
     **/
2673 2678
     getUserMediaWithConstraints: function ( um, success_callback, failure_callback, options) {
2674 2679
         options = options || {};
2675
-        resolution = options.resolution;
2676
-        var constraints = getConstraints(
2677
-            um, options);
2680
+        var resolution = options.resolution;
2681
+        var constraints = getConstraints(um, options);
2678 2682
 
2679 2683
         logger.info("Get media constraints", constraints);
2680 2684
 
@@ -2731,12 +2735,12 @@ var RTCUtils = {
2731 2735
                 RTCBrowserType.isTemasysPluginUsed()) {
2732 2736
                 var GUM = function (device, s, e) {
2733 2737
                     this.getUserMediaWithConstraints(device, s, e, options);
2734
-                }
2738
+                };
2735 2739
                 var deviceGUM = {
2736 2740
                     "audio": GUM.bind(self, ["audio"]),
2737 2741
                     "video": GUM.bind(self, ["video"]),
2738 2742
                     "desktop": screenObtainer.obtainStream
2739
-                }
2743
+                };
2740 2744
                 // With FF/IE we can't split the stream into audio and video because FF
2741 2745
                 // doesn't support media stream constructors. So, we need to get the
2742 2746
                 // audio stream separately from the video stream using two distinct GUM
@@ -2747,13 +2751,14 @@ var RTCUtils = {
2747 2751
                 // the successCallback method.
2748 2752
                 obtainDevices({
2749 2753
                     devices: options.devices,
2754
+                    streams: [],
2750 2755
                     successCallback: successCallback,
2751 2756
                     errorCallback: reject,
2752 2757
                     deviceGUM: deviceGUM
2753 2758
                 });
2754 2759
             } else {
2755
-                var hasDesktop = false;
2756
-                if(hasDesktop = options.devices.indexOf("desktop") !== -1) {
2760
+                var hasDesktop = options.devices.indexOf('desktop') > -1;
2761
+                if (hasDesktop) {
2757 2762
                     options.devices.splice(options.devices.indexOf("desktop"), 1);
2758 2763
                 }
2759 2764
                 options.resolution = options.resolution || '360';

+ 21
- 16
modules/RTC/RTCUtils.js View File

@@ -1,4 +1,9 @@
1
-/* global config, require, attachMediaStream, getUserMedia */
1
+/* global config, require, attachMediaStream, getUserMedia,
2
+   RTCPeerConnection, RTCSessionDescription, RTCIceCandidate, MediaStreamTrack,
3
+   mozRTCPeerConnection, mozRTCSessionDescription, mozRTCIceCandidate,
4
+   webkitRTCPeerConnection, webkitMediaStream, webkitURL
5
+*/
6
+/* jshint -W101 */
2 7
 
3 8
 var logger = require("jitsi-meet-logger").getLogger(__filename);
4 9
 var RTCBrowserType = require("./RTCBrowserType");
@@ -15,7 +20,7 @@ var eventEmitter = new EventEmitter();
15 20
 var devices = {
16 21
     audio: true,
17 22
     video: true
18
-}
23
+};
19 24
 
20 25
 var rtcReady = false;
21 26
 
@@ -197,7 +202,7 @@ function onReady (options, GUM) {
197 202
     rtcReady = true;
198 203
     eventEmitter.emit(RTCEvents.RTC_READY, true);
199 204
     screenObtainer.init(eventEmitter, options, GUM);
200
-};
205
+}
201 206
 
202 207
 /**
203 208
  * Apply function with arguments if function exists.
@@ -325,8 +330,8 @@ function enumerateDevicesThroughMediaStreamTrack (callback) {
325 330
 }
326 331
 
327 332
 function obtainDevices(options) {
328
-    if(!options.devices || options.devices.length === 0) {
329
-        return options.successCallback(streams);
333
+    if (!options.devices || options.devices.length === 0) {
334
+        return options.successCallback(options.streams);
330 335
     }
331 336
 
332 337
     var device = options.devices.splice(0, 1);
@@ -366,8 +371,8 @@ function handleLocalStream(streams, resolution) {
366 371
             var videoTracks = audioVideo.getVideoTracks();
367 372
             if(videoTracks.length) {
368 373
                 videoStream = new webkitMediaStream();
369
-                for (i = 0; i < videoTracks.length; i++) {
370
-                    videoStream.addTrack(videoTracks[i]);
374
+                for (var j = 0; j < videoTracks.length; j++) {
375
+                    videoStream.addTrack(videoTracks[j]);
371 376
                 }
372 377
             }
373 378
         }
@@ -506,7 +511,7 @@ var RTCUtils = {
506 511
 
507 512
                 //AdapterJS.WebRTCPlugin.setLogLevel(
508 513
                 //    AdapterJS.WebRTCPlugin.PLUGIN_LOG_LEVELS.VERBOSE);
509
-
514
+                var self = this;
510 515
                 AdapterJS.webRTCReady(function (isPlugin) {
511 516
 
512 517
                     self.peerconnection = RTCPeerConnection;
@@ -564,7 +569,7 @@ var RTCUtils = {
564 569
 
565 570
             // Call onReady() if Temasys plugin is not used
566 571
             if (!RTCBrowserType.isTemasysPluginUsed()) {
567
-                onReady(options, self.getUserMediaWithConstraints);
572
+                onReady(options, this.getUserMediaWithConstraints);
568 573
                 resolve();
569 574
             }
570 575
         }.bind(this));
@@ -583,9 +588,8 @@ var RTCUtils = {
583 588
     **/
584 589
     getUserMediaWithConstraints: function ( um, success_callback, failure_callback, options) {
585 590
         options = options || {};
586
-        resolution = options.resolution;
587
-        var constraints = getConstraints(
588
-            um, options);
591
+        var resolution = options.resolution;
592
+        var constraints = getConstraints(um, options);
589 593
 
590 594
         logger.info("Get media constraints", constraints);
591 595
 
@@ -642,12 +646,12 @@ var RTCUtils = {
642 646
                 RTCBrowserType.isTemasysPluginUsed()) {
643 647
                 var GUM = function (device, s, e) {
644 648
                     this.getUserMediaWithConstraints(device, s, e, options);
645
-                }
649
+                };
646 650
                 var deviceGUM = {
647 651
                     "audio": GUM.bind(self, ["audio"]),
648 652
                     "video": GUM.bind(self, ["video"]),
649 653
                     "desktop": screenObtainer.obtainStream
650
-                }
654
+                };
651 655
                 // With FF/IE we can't split the stream into audio and video because FF
652 656
                 // doesn't support media stream constructors. So, we need to get the
653 657
                 // audio stream separately from the video stream using two distinct GUM
@@ -658,13 +662,14 @@ var RTCUtils = {
658 662
                 // the successCallback method.
659 663
                 obtainDevices({
660 664
                     devices: options.devices,
665
+                    streams: [],
661 666
                     successCallback: successCallback,
662 667
                     errorCallback: reject,
663 668
                     deviceGUM: deviceGUM
664 669
                 });
665 670
             } else {
666
-                var hasDesktop = false;
667
-                if(hasDesktop = options.devices.indexOf("desktop") !== -1) {
671
+                var hasDesktop = options.devices.indexOf('desktop') > -1;
672
+                if (hasDesktop) {
668 673
                     options.devices.splice(options.devices.indexOf("desktop"), 1);
669 674
                 }
670 675
                 options.resolution = options.resolution || '360';

Loading…
Cancel
Save