Kaynağa Gözat

feat: add methods to check muti-mic support and stats collecting

For audio previewing, some browsers cannot have multiple local
audio streams at once. For audio output previewing, local
stats need to be collected to detect changes in volume level.

Pull Request #435
dev1
Leonard Kim 8 yıl önce
ebeveyn
işleme
731b2a7ad5

+ 11
- 0
JitsiMediaDevices.js Dosyayı Görüntüle

@@ -2,6 +2,7 @@ import EventEmitter from 'events';
2 2
 import * as JitsiMediaDevicesEvents from './JitsiMediaDevicesEvents';
3 3
 import * as MediaType from './service/RTC/MediaType';
4 4
 import RTC from './modules/RTC/RTC';
5
+import RTCBrowserType from './modules/RTC/RTCBrowserType';
5 6
 import RTCEvents from './service/RTC/RTCEvents';
6 7
 import Statistics from './modules/statistics/statistics';
7 8
 
@@ -72,6 +73,16 @@ const JitsiMediaDevices = {
72 73
         }
73 74
     },
74 75
 
76
+    /**
77
+     * Returns true if it is possible to be simultaneously capturing audio
78
+     * from more than one device.
79
+     *
80
+     * @returns {boolean}
81
+     */
82
+    isMultipleAudioInputSupported() {
83
+        return !RTCBrowserType.isFirefox();
84
+    },
85
+
75 86
     /**
76 87
      * Returns currently used audio output device id, 'default' stands
77 88
      * for default device

+ 22
- 0
JitsiMeetJS.js Dosyayı Görüntüle

@@ -15,6 +15,7 @@ import JitsiRecorderErrors from './JitsiRecorderErrors';
15 15
 import JitsiTrackError from './JitsiTrackError';
16 16
 import * as JitsiTrackErrors from './JitsiTrackErrors';
17 17
 import * as JitsiTrackEvents from './JitsiTrackEvents';
18
+import LocalStatsCollector from './modules/statistics/LocalStatsCollector';
18 19
 import Logger from 'jitsi-meet-logger';
19 20
 import * as MediaType from './service/RTC/MediaType';
20 21
 import Resolutions from './service/RTC/Resolutions';
@@ -390,6 +391,27 @@ const LibJitsiMeet = {
390 391
         return this.mediaDevices.isDeviceChangeAvailable(deviceType);
391 392
     },
392 393
 
394
+
395
+    /**
396
+     * Checks if the current environment supports having multiple audio
397
+     * input devices in use simultaneously.
398
+     *
399
+     * @returns {boolean} True if multiple audio input devices can be used.
400
+     */
401
+    isMultipleAudioInputSupported() {
402
+        return this.mediaDevices.isMultipleAudioInputSupported();
403
+    },
404
+
405
+    /**
406
+     * Checks if local tracks can collect stats and collection is enabled.
407
+     *
408
+     * @param {boolean} True if stats are being collected for local tracks.
409
+     */
410
+    isCollectingLocalStats() {
411
+        return Statistics.audioLevelsEnabled
412
+            && LocalStatsCollector.isLocalStatsSupported();
413
+    },
414
+
393 415
     /**
394 416
      * Executes callback with list of media devices connected.
395 417
      * @param {function} callback

+ 2
- 0
modules/RTC/JitsiLocalTrack.js Dosyayı Görüntüle

@@ -235,6 +235,8 @@ JitsiLocalTrack.prototype._fireNoDataFromSourceEvent = function() {
235 235
  */
236 236
 JitsiLocalTrack.prototype._setRealDeviceIdFromDeviceList = function(devices) {
237 237
     const track = this.getTrack();
238
+
239
+    // FIXME for temasys video track, label refers to id not the actual device
238 240
     const device
239 241
         = devices.find(
240 242
             d => d.kind === `${track.kind}input` && d.label === track.label);

+ 11
- 2
modules/statistics/LocalStatsCollector.js Dosyayı Görüntüle

@@ -96,8 +96,7 @@ function LocalStatsCollector(stream, interval, callback) {
96 96
  * Starts the collecting the statistics.
97 97
  */
98 98
 LocalStatsCollector.prototype.start = function() {
99
-    if (!context
100
-        || RTCBrowserType.isTemasysPluginUsed()) {
99
+    if (!LocalStatsCollector.isLocalStatsSupported()) {
101 100
         return;
102 101
     }
103 102
     context.resume();
@@ -139,4 +138,14 @@ LocalStatsCollector.prototype.stop = function() {
139 138
     }
140 139
 };
141 140
 
141
+/**
142
+ * Checks if the environment has the necessary conditions to support
143
+ * collecting stats from local streams.
144
+ *
145
+ * @returns {boolean}
146
+ */
147
+LocalStatsCollector.isLocalStatsSupported = function() {
148
+    return Boolean(context && !RTCBrowserType.isTemasysPluginUsed());
149
+};
150
+
142 151
 module.exports = LocalStatsCollector;

Loading…
İptal
Kaydet