瀏覽代碼

fix issues in RTCUtils

master
isymchych 10 年之前
父節點
當前提交
21d63506ee
共有 2 個檔案被更改,包括 42 行新增32 行删除
  1. 21
    16
      lib-jitsi-meet.js
  2. 21
    16
      modules/RTC/RTCUtils.js

+ 21
- 16
lib-jitsi-meet.js 查看文件

2089
 module.exports = RTCBrowserType;
2089
 module.exports = RTCBrowserType;
2090
 },{}],18:[function(require,module,exports){
2090
 },{}],18:[function(require,module,exports){
2091
 (function (__filename){
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
 var logger = require("jitsi-meet-logger").getLogger(__filename);
2099
 var logger = require("jitsi-meet-logger").getLogger(__filename);
2095
 var RTCBrowserType = require("./RTCBrowserType");
2100
 var RTCBrowserType = require("./RTCBrowserType");
2106
 var devices = {
2111
 var devices = {
2107
     audio: true,
2112
     audio: true,
2108
     video: true
2113
     video: true
2109
-}
2114
+};
2110
 
2115
 
2111
 var rtcReady = false;
2116
 var rtcReady = false;
2112
 
2117
 
2286
     rtcReady = true;
2291
     rtcReady = true;
2287
     eventEmitter.emit(RTCEvents.RTC_READY, true);
2292
     eventEmitter.emit(RTCEvents.RTC_READY, true);
2288
     screenObtainer.init(eventEmitter, options, GUM);
2293
     screenObtainer.init(eventEmitter, options, GUM);
2289
-};
2294
+}
2290
 
2295
 
2291
 /**
2296
 /**
2292
  * Apply function with arguments if function exists.
2297
  * Apply function with arguments if function exists.
2414
 }
2419
 }
2415
 
2420
 
2416
 function obtainDevices(options) {
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
     var device = options.devices.splice(0, 1);
2426
     var device = options.devices.splice(0, 1);
2455
             var videoTracks = audioVideo.getVideoTracks();
2460
             var videoTracks = audioVideo.getVideoTracks();
2456
             if(videoTracks.length) {
2461
             if(videoTracks.length) {
2457
                 videoStream = new webkitMediaStream();
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
 
2600
 
2596
                 //AdapterJS.WebRTCPlugin.setLogLevel(
2601
                 //AdapterJS.WebRTCPlugin.setLogLevel(
2597
                 //    AdapterJS.WebRTCPlugin.PLUGIN_LOG_LEVELS.VERBOSE);
2602
                 //    AdapterJS.WebRTCPlugin.PLUGIN_LOG_LEVELS.VERBOSE);
2598
-
2603
+                var self = this;
2599
                 AdapterJS.webRTCReady(function (isPlugin) {
2604
                 AdapterJS.webRTCReady(function (isPlugin) {
2600
 
2605
 
2601
                     self.peerconnection = RTCPeerConnection;
2606
                     self.peerconnection = RTCPeerConnection;
2653
 
2658
 
2654
             // Call onReady() if Temasys plugin is not used
2659
             // Call onReady() if Temasys plugin is not used
2655
             if (!RTCBrowserType.isTemasysPluginUsed()) {
2660
             if (!RTCBrowserType.isTemasysPluginUsed()) {
2656
-                onReady(options, self.getUserMediaWithConstraints);
2661
+                onReady(options, this.getUserMediaWithConstraints);
2657
                 resolve();
2662
                 resolve();
2658
             }
2663
             }
2659
         }.bind(this));
2664
         }.bind(this));
2672
     **/
2677
     **/
2673
     getUserMediaWithConstraints: function ( um, success_callback, failure_callback, options) {
2678
     getUserMediaWithConstraints: function ( um, success_callback, failure_callback, options) {
2674
         options = options || {};
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
         logger.info("Get media constraints", constraints);
2683
         logger.info("Get media constraints", constraints);
2680
 
2684
 
2731
                 RTCBrowserType.isTemasysPluginUsed()) {
2735
                 RTCBrowserType.isTemasysPluginUsed()) {
2732
                 var GUM = function (device, s, e) {
2736
                 var GUM = function (device, s, e) {
2733
                     this.getUserMediaWithConstraints(device, s, e, options);
2737
                     this.getUserMediaWithConstraints(device, s, e, options);
2734
-                }
2738
+                };
2735
                 var deviceGUM = {
2739
                 var deviceGUM = {
2736
                     "audio": GUM.bind(self, ["audio"]),
2740
                     "audio": GUM.bind(self, ["audio"]),
2737
                     "video": GUM.bind(self, ["video"]),
2741
                     "video": GUM.bind(self, ["video"]),
2738
                     "desktop": screenObtainer.obtainStream
2742
                     "desktop": screenObtainer.obtainStream
2739
-                }
2743
+                };
2740
                 // With FF/IE we can't split the stream into audio and video because FF
2744
                 // With FF/IE we can't split the stream into audio and video because FF
2741
                 // doesn't support media stream constructors. So, we need to get the
2745
                 // doesn't support media stream constructors. So, we need to get the
2742
                 // audio stream separately from the video stream using two distinct GUM
2746
                 // audio stream separately from the video stream using two distinct GUM
2747
                 // the successCallback method.
2751
                 // the successCallback method.
2748
                 obtainDevices({
2752
                 obtainDevices({
2749
                     devices: options.devices,
2753
                     devices: options.devices,
2754
+                    streams: [],
2750
                     successCallback: successCallback,
2755
                     successCallback: successCallback,
2751
                     errorCallback: reject,
2756
                     errorCallback: reject,
2752
                     deviceGUM: deviceGUM
2757
                     deviceGUM: deviceGUM
2753
                 });
2758
                 });
2754
             } else {
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
                     options.devices.splice(options.devices.indexOf("desktop"), 1);
2762
                     options.devices.splice(options.devices.indexOf("desktop"), 1);
2758
                 }
2763
                 }
2759
                 options.resolution = options.resolution || '360';
2764
                 options.resolution = options.resolution || '360';

+ 21
- 16
modules/RTC/RTCUtils.js 查看文件

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
 var logger = require("jitsi-meet-logger").getLogger(__filename);
8
 var logger = require("jitsi-meet-logger").getLogger(__filename);
4
 var RTCBrowserType = require("./RTCBrowserType");
9
 var RTCBrowserType = require("./RTCBrowserType");
15
 var devices = {
20
 var devices = {
16
     audio: true,
21
     audio: true,
17
     video: true
22
     video: true
18
-}
23
+};
19
 
24
 
20
 var rtcReady = false;
25
 var rtcReady = false;
21
 
26
 
197
     rtcReady = true;
202
     rtcReady = true;
198
     eventEmitter.emit(RTCEvents.RTC_READY, true);
203
     eventEmitter.emit(RTCEvents.RTC_READY, true);
199
     screenObtainer.init(eventEmitter, options, GUM);
204
     screenObtainer.init(eventEmitter, options, GUM);
200
-};
205
+}
201
 
206
 
202
 /**
207
 /**
203
  * Apply function with arguments if function exists.
208
  * Apply function with arguments if function exists.
325
 }
330
 }
326
 
331
 
327
 function obtainDevices(options) {
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
     var device = options.devices.splice(0, 1);
337
     var device = options.devices.splice(0, 1);
366
             var videoTracks = audioVideo.getVideoTracks();
371
             var videoTracks = audioVideo.getVideoTracks();
367
             if(videoTracks.length) {
372
             if(videoTracks.length) {
368
                 videoStream = new webkitMediaStream();
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
 
511
 
507
                 //AdapterJS.WebRTCPlugin.setLogLevel(
512
                 //AdapterJS.WebRTCPlugin.setLogLevel(
508
                 //    AdapterJS.WebRTCPlugin.PLUGIN_LOG_LEVELS.VERBOSE);
513
                 //    AdapterJS.WebRTCPlugin.PLUGIN_LOG_LEVELS.VERBOSE);
509
-
514
+                var self = this;
510
                 AdapterJS.webRTCReady(function (isPlugin) {
515
                 AdapterJS.webRTCReady(function (isPlugin) {
511
 
516
 
512
                     self.peerconnection = RTCPeerConnection;
517
                     self.peerconnection = RTCPeerConnection;
564
 
569
 
565
             // Call onReady() if Temasys plugin is not used
570
             // Call onReady() if Temasys plugin is not used
566
             if (!RTCBrowserType.isTemasysPluginUsed()) {
571
             if (!RTCBrowserType.isTemasysPluginUsed()) {
567
-                onReady(options, self.getUserMediaWithConstraints);
572
+                onReady(options, this.getUserMediaWithConstraints);
568
                 resolve();
573
                 resolve();
569
             }
574
             }
570
         }.bind(this));
575
         }.bind(this));
583
     **/
588
     **/
584
     getUserMediaWithConstraints: function ( um, success_callback, failure_callback, options) {
589
     getUserMediaWithConstraints: function ( um, success_callback, failure_callback, options) {
585
         options = options || {};
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
         logger.info("Get media constraints", constraints);
594
         logger.info("Get media constraints", constraints);
591
 
595
 
642
                 RTCBrowserType.isTemasysPluginUsed()) {
646
                 RTCBrowserType.isTemasysPluginUsed()) {
643
                 var GUM = function (device, s, e) {
647
                 var GUM = function (device, s, e) {
644
                     this.getUserMediaWithConstraints(device, s, e, options);
648
                     this.getUserMediaWithConstraints(device, s, e, options);
645
-                }
649
+                };
646
                 var deviceGUM = {
650
                 var deviceGUM = {
647
                     "audio": GUM.bind(self, ["audio"]),
651
                     "audio": GUM.bind(self, ["audio"]),
648
                     "video": GUM.bind(self, ["video"]),
652
                     "video": GUM.bind(self, ["video"]),
649
                     "desktop": screenObtainer.obtainStream
653
                     "desktop": screenObtainer.obtainStream
650
-                }
654
+                };
651
                 // With FF/IE we can't split the stream into audio and video because FF
655
                 // With FF/IE we can't split the stream into audio and video because FF
652
                 // doesn't support media stream constructors. So, we need to get the
656
                 // doesn't support media stream constructors. So, we need to get the
653
                 // audio stream separately from the video stream using two distinct GUM
657
                 // audio stream separately from the video stream using two distinct GUM
658
                 // the successCallback method.
662
                 // the successCallback method.
659
                 obtainDevices({
663
                 obtainDevices({
660
                     devices: options.devices,
664
                     devices: options.devices,
665
+                    streams: [],
661
                     successCallback: successCallback,
666
                     successCallback: successCallback,
662
                     errorCallback: reject,
667
                     errorCallback: reject,
663
                     deviceGUM: deviceGUM
668
                     deviceGUM: deviceGUM
664
                 });
669
                 });
665
             } else {
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
                     options.devices.splice(options.devices.indexOf("desktop"), 1);
673
                     options.devices.splice(options.devices.indexOf("desktop"), 1);
669
                 }
674
                 }
670
                 options.resolution = options.resolution || '360';
675
                 options.resolution = options.resolution || '360';

Loading…
取消
儲存