Browse Source

Use public API

Do not access JitsiConference's eventEmitter, the functionality of
interest is publicly available through other methods.
dev1
Lyubomir Marinov 9 years ago
parent
commit
6ad43f1805
1 changed files with 28 additions and 20 deletions
  1. 28
    20
      modules/talkmuted/TalkMutedDetection.js

+ 28
- 20
modules/talkmuted/TalkMutedDetection.js View File

4
     /**
4
     /**
5
      * Creates TalkMutedDetection
5
      * Creates TalkMutedDetection
6
      * @param conference the JitsiConference instance that created us.
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
      * @constructor
9
      * @constructor
10
      */
10
      */
11
     constructor(conference, callback) {
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
         conference.statistics.addAudioLevelListener(
20
         conference.statistics.addAudioLevelListener(
15
             this.audioLevelListener.bind(this));
21
             this.audioLevelListener.bind(this));
16
-        conference.eventEmitter.on(
22
+        conference.on(
17
             JitsiConferenceEvents.TRACK_MUTE_CHANGED,
23
             JitsiConferenceEvents.TRACK_MUTE_CHANGED,
18
-            this.muteChanged.bind(this));
19
-        conference.eventEmitter.on(
24
+            this._trackMuteChanged.bind(this));
25
+        conference.on(
20
             JitsiConferenceEvents.TRACK_ADDED,
26
             JitsiConferenceEvents.TRACK_ADDED,
21
-            this.onTrackAdded.bind(this));
27
+            this._trackAdded.bind(this));
22
 
28
 
23
         // we track firing the event, in order to avoid sending too many events
29
         // we track firing the event, in order to avoid sending too many events
24
         this.eventFired = false;
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
      * Receives audio level events for all send/receive streams.
34
      * Receives audio level events for all send/receive streams.
40
      * @param ssrc the ssrc of the stream
35
      * @param ssrc the ssrc of the stream
49
 
44
 
50
         if (this.audioTrack.isMuted() && level > 0.6) {
45
         if (this.audioTrack.isMuted() && level > 0.6) {
51
             this.eventFired = true;
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
      * Mute changed for a track.
64
      * Mute changed for a track.
58
      * @param track the track which mute state has changed.
65
      * @param track the track which mute state has changed.
66
+     * @private
59
      */
67
      */
60
-    muteChanged(track) {
68
+    _trackMuteChanged(track) {
61
         if (track.isLocal() && track.isAudioTrack() && track.isMuted())
69
         if (track.isLocal() && track.isAudioTrack() && track.isMuted())
62
             this.eventFired = false;
70
             this.eventFired = false;
63
     }
71
     }

Loading…
Cancel
Save