Browse Source

fix(audio-levels): Reset audio level to 0 when remote user is muted.

When using getSynchornizationSources on the audio receiver to gather audio levels for remote tracks, browser reports last known audio levels even when the remote user is audio muted, we need to reset the value to zero here so that the audio levels are cleared.
dev1
Jaya Allamsetty 5 years ago
parent
commit
ff9cce994b
1 changed files with 13 additions and 12 deletions
  1. 13
    12
      modules/RTC/JitsiTrack.js

+ 13
- 12
modules/RTC/JitsiTrack.js View File

@@ -424,31 +424,32 @@ 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;
427
+        let newAudioLevel = audioLevel;
428
+
429
+        // When using getSynchornizationSources on the audio receiver to gather audio levels for
430
+        // remote tracks, browser reports last known audio levels even when the remote user is
431
+        // audio muted, we need to reset the value to zero here so that the audio levels are cleared.
432
+        // Remote tracks have the tpc info present while local tracks do not.
433
+        if (browser.supportsReceiverStats() && typeof tpc !== 'undefined' && this.isMuted()) {
434
+            newAudioLevel = 0;
434 435
         }
435 436
 
436
-        if (this.audioLevel !== audioLevel) {
437
-            this.audioLevel = audioLevel;
437
+        if (this.audioLevel !== newAudioLevel) {
438
+            this.audioLevel = newAudioLevel;
438 439
             this.emit(
439 440
                 JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
440
-                audioLevel,
441
+                newAudioLevel,
441 442
                 tpc);
442 443
 
443 444
         // LocalStatsCollector reports a value of 0.008 for muted mics
444 445
         // and a value of 0 when there is no audio input.
445 446
         } else if (this.audioLevel === 0
446
-            && audioLevel === 0
447
+            && newAudioLevel === 0
447 448
             && this.isLocal()
448 449
             && !this.isWebRTCTrackMuted()) {
449 450
             this.emit(
450 451
                 JitsiTrackEvents.NO_AUDIO_INPUT,
451
-                audioLevel);
452
+                newAudioLevel);
452 453
         }
453 454
     }
454 455
 

Loading…
Cancel
Save