|
@@ -4,37 +4,32 @@ export default class TalkMutedDetection {
|
4
|
4
|
/**
|
5
|
5
|
* Creates TalkMutedDetection
|
6
|
6
|
* @param conference the JitsiConference instance that created us.
|
7
|
|
- * @param callback the callback to call when detected local user is talking
|
8
|
|
- * while its microphone is muted.
|
|
7
|
+ * @param callback the callback to call when detected that the local user is
|
|
8
|
+ * talking while her microphone is muted.
|
9
|
9
|
* @constructor
|
10
|
10
|
*/
|
11
|
11
|
constructor(conference, callback) {
|
12
|
|
- this.callback = callback;
|
|
12
|
+ /**
|
|
13
|
+ * The callback to call when detected that the local user is talking
|
|
14
|
+ * while her microphone is muted.
|
|
15
|
+ *
|
|
16
|
+ * @private
|
|
17
|
+ */
|
|
18
|
+ this._callback = callback;
|
13
|
19
|
|
14
|
20
|
conference.statistics.addAudioLevelListener(
|
15
|
21
|
this.audioLevelListener.bind(this));
|
16
|
|
- conference.eventEmitter.on(
|
|
22
|
+ conference.on(
|
17
|
23
|
JitsiConferenceEvents.TRACK_MUTE_CHANGED,
|
18
|
|
- this.muteChanged.bind(this));
|
19
|
|
- conference.eventEmitter.on(
|
|
24
|
+ this._trackMuteChanged.bind(this));
|
|
25
|
+ conference.on(
|
20
|
26
|
JitsiConferenceEvents.TRACK_ADDED,
|
21
|
|
- this.onTrackAdded.bind(this));
|
|
27
|
+ this._trackAdded.bind(this));
|
22
|
28
|
|
23
|
29
|
// we track firing the event, in order to avoid sending too many events
|
24
|
30
|
this.eventFired = false;
|
25
|
31
|
}
|
26
|
32
|
|
27
|
|
- /**
|
28
|
|
- * Adds local tracks. We are interested only in the audio one.
|
29
|
|
- * @param track
|
30
|
|
- */
|
31
|
|
- onTrackAdded(track) {
|
32
|
|
- if (!track.isAudioTrack())
|
33
|
|
- return;
|
34
|
|
-
|
35
|
|
- this.audioTrack = track;
|
36
|
|
- }
|
37
|
|
-
|
38
|
33
|
/**
|
39
|
34
|
* Receives audio level events for all send/receive streams.
|
40
|
35
|
* @param ssrc the ssrc of the stream
|
|
@@ -49,15 +44,28 @@ export default class TalkMutedDetection {
|
49
|
44
|
|
50
|
45
|
if (this.audioTrack.isMuted() && level > 0.6) {
|
51
|
46
|
this.eventFired = true;
|
52
|
|
- this.callback();
|
|
47
|
+ this._callback();
|
53
|
48
|
}
|
54
|
49
|
}
|
55
|
50
|
|
|
51
|
+ /**
|
|
52
|
+ * Adds local tracks. We are interested only in the audio one.
|
|
53
|
+ * @param track
|
|
54
|
+ * @private
|
|
55
|
+ */
|
|
56
|
+ _trackAdded(track) {
|
|
57
|
+ if (!track.isAudioTrack())
|
|
58
|
+ return;
|
|
59
|
+
|
|
60
|
+ this.audioTrack = track;
|
|
61
|
+ }
|
|
62
|
+
|
56
|
63
|
/**
|
57
|
64
|
* Mute changed for a track.
|
58
|
65
|
* @param track the track which mute state has changed.
|
|
66
|
+ * @private
|
59
|
67
|
*/
|
60
|
|
- muteChanged(track) {
|
|
68
|
+ _trackMuteChanged(track) {
|
61
|
69
|
if (track.isLocal() && track.isAudioTrack() && track.isMuted())
|
62
|
70
|
this.eventFired = false;
|
63
|
71
|
}
|