瀏覽代碼

fix: Scale remote audio levels reported on receiver to getStats levels

The audio levels reported on the audio receivers are lower when compared to the value reported by getStats.
Values reported by getStats on chrome do not follow the the spec and since we have combination of clients using both getStats and getSynchronizationSources,
lets stick to one scale to make them look uniform.
Also, the receivers seem to be reporting audio level for a little bit after the remote user has muted. Make sure the track is unmuted
before setting the audio level on the track.
dev1
Jaya Allamsetty 5 年之前
父節點
當前提交
43835df2a0
共有 2 個文件被更改,包括 14 次插入1 次删除
  1. 9
    0
      modules/RTC/JitsiTrack.js
  2. 5
    1
      modules/statistics/RTPStatsCollector.js

+ 9
- 0
modules/RTC/JitsiTrack.js 查看文件

@@ -424,6 +424,15 @@ export default class JitsiTrack extends EventEmitter {
424 424
      * peerconnection (see /modules/statistics/LocalStatsCollector.js).
425 425
      */
426 426
     setAudioLevel(audioLevel, tpc) {
427
+        // The receiver seems to be reporting audio level immediately after the
428
+        // remote user has muted, so do not set the audio level on the track
429
+        // if it is muted.
430
+        if (browser.supportsReceiverStats()
431
+            && !this.isLocalAudioTrack()
432
+            && this.isWebRTCTrackMuted()) {
433
+            return;
434
+        }
435
+
427 436
         if (this.audioLevel !== audioLevel) {
428 437
             this.audioLevel = audioLevel;
429 438
             this.emit(

+ 5
- 1
modules/statistics/RTPStatsCollector.js 查看文件

@@ -303,11 +303,15 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
303 303
 
304 304
                     for (const ssrc in audioLevels) {
305 305
                         if (audioLevels.hasOwnProperty(ssrc)) {
306
+                            // Use a scaling factor of 2.5 to report the same
307
+                            // audio levels that getStats reports.
308
+                            const audioLevel = audioLevels[ssrc] * 2.5;
309
+
306 310
                             this.eventEmitter.emit(
307 311
                                 StatisticsEvents.AUDIO_LEVEL,
308 312
                                 this.peerconnection,
309 313
                                 Number.parseInt(ssrc, 10),
310
-                                audioLevels[ssrc],
314
+                                audioLevel,
311 315
                                 false /* isLocal */);
312 316
                         }
313 317
                     }

Loading…
取消
儲存