Lyubomir Marinov hace 9 años
padre
commit
a08ec825c8

+ 5
- 4
JitsiConference.js Ver fichero

18
 var JitsiConferenceEventManager = require("./JitsiConferenceEventManager");
18
 var JitsiConferenceEventManager = require("./JitsiConferenceEventManager");
19
 var VideoType = require('./service/RTC/VideoType');
19
 var VideoType = require('./service/RTC/VideoType');
20
 var Transcriber = require("./modules/transcription/transcriber");
20
 var Transcriber = require("./modules/transcription/transcriber");
21
-var TalkMutedDetection = require("./modules/talkmuted/TalkMutedDetection");
22
 var ParticipantConnectionStatus
21
 var ParticipantConnectionStatus
23
     = require("./modules/connectivity/ParticipantConnectionStatus");
22
     = require("./modules/connectivity/ParticipantConnectionStatus");
23
+import TalkMutedDetection from "./modules/talkmuted/TalkMutedDetection";
24
 
24
 
25
 /**
25
 /**
26
  * Creates a JitsiConference object with the given name and properties.
26
  * Creates a JitsiConference object with the given name and properties.
119
     this.eventManager.setupStatisticsListeners();
119
     this.eventManager.setupStatisticsListeners();
120
 
120
 
121
     if (this.options.config.enableTalkWhileMuted) {
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
         this.statistics.addAudioLevelListener(
126
         this.statistics.addAudioLevelListener(
126
             this.talkMutedDetection.audioLevelListener
127
             this.talkMutedDetection.audioLevelListener
127
                 .bind(this.talkMutedDetection));
128
                 .bind(this.talkMutedDetection));

+ 2
- 5
modules/statistics/RTPStatsCollector.js Ver fichero

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

+ 45
- 46
modules/talkmuted/TalkMutedDetection.js Ver fichero

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
         // we are interested only in local audio stream
24
         // we are interested only in local audio stream
25
         // and if event is not already sent
25
         // and if event is not already sent
26
         if (!isLocal || !this.audioTrack || this.eventFired)
26
         if (!isLocal || !this.audioTrack || this.eventFired)
30
             this.eventFired = true;
30
             this.eventFired = true;
31
             this.callback();
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
+}

Loading…
Cancelar
Guardar