Lyubomir Marinov 9 лет назад
Родитель
Сommit
a08ec825c8
3 измененных файлов: 52 добавлений и 55 удалений
  1. 5
    4
      JitsiConference.js
  2. 2
    5
      modules/statistics/RTPStatsCollector.js
  3. 45
    46
      modules/talkmuted/TalkMutedDetection.js

+ 5
- 4
JitsiConference.js Просмотреть файл

@@ -18,9 +18,9 @@ var GlobalOnErrorHandler = require("./modules/util/GlobalOnErrorHandler");
18 18
 var JitsiConferenceEventManager = require("./JitsiConferenceEventManager");
19 19
 var VideoType = require('./service/RTC/VideoType');
20 20
 var Transcriber = require("./modules/transcription/transcriber");
21
-var TalkMutedDetection = require("./modules/talkmuted/TalkMutedDetection");
22 21
 var ParticipantConnectionStatus
23 22
     = require("./modules/connectivity/ParticipantConnectionStatus");
23
+import TalkMutedDetection from "./modules/talkmuted/TalkMutedDetection";
24 24
 
25 25
 /**
26 26
  * Creates a JitsiConference object with the given name and properties.
@@ -119,9 +119,10 @@ JitsiConference.prototype._init = function (options) {
119 119
     this.eventManager.setupStatisticsListeners();
120 120
 
121 121
     if (this.options.config.enableTalkWhileMuted) {
122
-        this.talkMutedDetection = new TalkMutedDetection(function () {
123
-            this.eventEmitter.emit(JitsiConferenceEvents.TALK_WHILE_MUTED);
124
-        }.bind(this));
122
+        this.talkMutedDetection
123
+            = new TalkMutedDetection(() => {
124
+                this.eventEmitter.emit(JitsiConferenceEvents.TALK_WHILE_MUTED);
125
+            });
125 126
         this.statistics.addAudioLevelListener(
126 127
             this.talkMutedDetection.audioLevelListener
127 128
                 .bind(this.talkMutedDetection));

+ 2
- 5
modules/statistics/RTPStatsCollector.js Просмотреть файл

@@ -752,11 +752,6 @@ StatsCollector.prototype.processAudioLevelReport = function () {
752 752
         if (now.type != 'ssrc')
753 753
             continue;
754 754
 
755
-        var isLocal = false;
756
-        if (!getStatValue(now, 'packetsReceived')) {
757
-            isLocal = true;
758
-        }
759
-
760 755
         var before = this.baselineAudioLevelsReport[idx];
761 756
         var ssrc = getStatValue(now, 'ssrc');
762 757
         if (!before) {
@@ -787,6 +782,8 @@ StatsCollector.prototype.processAudioLevelReport = function () {
787 782
         }
788 783
 
789 784
         if (audioLevel) {
785
+            const isLocal = !getStatValue(now, 'packetsReceived');
786
+
790 787
             // TODO: can't find specs about what this value really is,
791 788
             // but it seems to vary between 0 and around 32k.
792 789
             audioLevel = audioLevel / 32767;

+ 45
- 46
modules/talkmuted/TalkMutedDetection.js Просмотреть файл

@@ -1,26 +1,26 @@
1
-var JitsiTrackEvents = require('../../JitsiTrackEvents');
2
-
3
-/**
4
- * Creates TalkMutedDetection
5
- * @param callback the callback to call when detected local user is talking
6
- * while its microphone is muted.
7
- * @constructor
8
- */
9
-function TalkMutedDetection(callback) {
10
-    this.callback = callback;
11
-
12
-    // we track firing the event, in order to avoid sending too many events
13
-    this.eventFired = false;
14
-}
15
-
16
-/**
17
- * Receives audio level events for all send/receive streams.
18
- * @param ssrc the ssrc of the stream
19
- * @param level the current audio level
20
- * @param isLocal whether this is local or remote stream (sent or received)
21
- */
22
-TalkMutedDetection.prototype.audioLevelListener =
23
-    function (ssrc, level, isLocal) {
1
+import * as JitsiTrackEvents from '../../JitsiTrackEvents';
2
+
3
+export default class TalkMutedDetection {
4
+    /**
5
+     * Creates TalkMutedDetection
6
+     * @param callback the callback to call when detected local user is talking
7
+     * while its microphone is muted.
8
+     * @constructor
9
+     */
10
+    constructor(callback) {
11
+        this.callback = callback;
12
+
13
+        // we track firing the event, in order to avoid sending too many events
14
+        this.eventFired = false;
15
+    }
16
+
17
+    /**
18
+     * Receives audio level events for all send/receive streams.
19
+     * @param ssrc the ssrc of the stream
20
+     * @param level the current audio level
21
+     * @param isLocal whether this is local or remote stream (sent or received)
22
+     */
23
+    audioLevelListener(ssrc, level, isLocal) {
24 24
         // we are interested only in local audio stream
25 25
         // and if event is not already sent
26 26
         if (!isLocal || !this.audioTrack || this.eventFired)
@@ -30,29 +30,28 @@ TalkMutedDetection.prototype.audioLevelListener =
30 30
             this.eventFired = true;
31 31
             this.callback();
32 32
         }
33
-    };
34
-
35
-/**
36
- * Mute changed for a track.
37
- * @param track the track which mute state has changed.
38
- */
39
-TalkMutedDetection.prototype.muteChanged = function (track) {
40
-    if (!track.isLocal() || !track.isAudioTrack())
41
-        return;
42
-
43
-    if (track.isMuted())
44
-        this.eventFired = false;
45
-};
33
+    }
34
+
35
+    /**
36
+     * Mute changed for a track.
37
+     * @param track the track which mute state has changed.
38
+     */
39
+    muteChanged(track) {
40
+        if (!track.isLocal() || !track.isAudioTrack())
41
+            return;
46 42
 
47
-/**
48
- * Adds local tracks. We are interested only in the audio one.
49
- * @param track
50
- */
51
-TalkMutedDetection.prototype.addTrack = function(track){
52
-    if (!track.isAudioTrack())
53
-        return;
43
+        if (track.isMuted())
44
+            this.eventFired = false;
45
+    }
54 46
 
55
-    this.audioTrack = track;
56
-};
47
+    /**
48
+     * Adds local tracks. We are interested only in the audio one.
49
+     * @param track
50
+     */
51
+    addTrack(track) {
52
+        if (!track.isAudioTrack())
53
+            return;
57 54
 
58
-module.exports = TalkMutedDetection;
55
+        this.audioTrack = track;
56
+    }
57
+}

Загрузка…
Отмена
Сохранить