|
|
@@ -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
|
+}
|