|
@@ -11,6 +11,8 @@ const SILENCE_PERIOD_MS = 4000;
|
11
|
11
|
/**
|
12
|
12
|
* Detect if there is no audio input on the current TraceAblePeerConnection selected track. The no audio
|
13
|
13
|
* state must be constant for a configured amount of time in order for the event to be triggered.
|
|
14
|
+ * @fires DetectionEvents.AUDIO_INPUT_STATE_CHANGE
|
|
15
|
+ * @fires DetectionEvents.NO_AUDIO_INPUT
|
14
|
16
|
*/
|
15
|
17
|
export default class NoAudioSignalDetection extends EventEmitter {
|
16
|
18
|
/**
|
|
@@ -41,6 +43,7 @@ export default class NoAudioSignalDetection extends EventEmitter {
|
41
|
43
|
* Generated event triggered by a change in the current conference audio input state.
|
42
|
44
|
*
|
43
|
45
|
* @param {*} audioLevel
|
|
46
|
+ * @fires DetectionEvents.AUDIO_INPUT_STATE_CHANGE
|
44
|
47
|
*/
|
45
|
48
|
_handleAudioInputStateChange(audioLevel) {
|
46
|
49
|
// Current audio input state of the active local track in the conference, true for audio input false for no
|
|
@@ -58,6 +61,13 @@ export default class NoAudioSignalDetection extends EventEmitter {
|
58
|
61
|
|
59
|
62
|
if (shouldTrigger) {
|
60
|
63
|
this._hasAudioInput = status;
|
|
64
|
+
|
|
65
|
+ /**
|
|
66
|
+ * Event fired when the audio input state of the conference changes, true for audio input false otherwise.
|
|
67
|
+ *
|
|
68
|
+ * @event DetectionEvents.AUDIO_INPUT_STATE_CHANGE
|
|
69
|
+ * @type {boolean}
|
|
70
|
+ */
|
61
|
71
|
this.emit(DetectionEvents.AUDIO_INPUT_STATE_CHANGE, this._hasAudioInput);
|
62
|
72
|
}
|
63
|
73
|
}
|
|
@@ -66,6 +76,7 @@ export default class NoAudioSignalDetection extends EventEmitter {
|
66
|
76
|
* Generate event triggered by a prolonged period of no audio input.
|
67
|
77
|
*
|
68
|
78
|
* @param {number} audioLevel - The audio level of the ssrc.
|
|
79
|
+ * @fires DetectionEvents.NO_AUDIO_INPUT
|
69
|
80
|
*/
|
70
|
81
|
_handleNoAudioInputDetection(audioLevel) {
|
71
|
82
|
if (this._eventFired) {
|
|
@@ -75,6 +86,13 @@ export default class NoAudioSignalDetection extends EventEmitter {
|
75
|
86
|
if (audioLevel === 0 && !this._timeoutTrigger) {
|
76
|
87
|
this._timeoutTrigger = setTimeout(() => {
|
77
|
88
|
this._eventFired = true;
|
|
89
|
+
|
|
90
|
+ /**
|
|
91
|
+ * Event fired when there is no audio input for a predefined period of time.
|
|
92
|
+ *
|
|
93
|
+ * @event DetectionEvents.AUDIO_INPUT_STATE_CHANGE
|
|
94
|
+ * @type {void}
|
|
95
|
+ */
|
78
|
96
|
this.emit(DetectionEvents.NO_AUDIO_INPUT);
|
79
|
97
|
}, SILENCE_PERIOD_MS);
|
80
|
98
|
} else if (audioLevel !== 0 && this._timeoutTrigger) {
|
|
@@ -92,7 +110,7 @@ export default class NoAudioSignalDetection extends EventEmitter {
|
92
|
110
|
* @param {boolean} isLocal - true for local/send streams or false for remote/receive streams.
|
93
|
111
|
*/
|
94
|
112
|
_audioLevel(tpc, ssrc, audioLevel, isLocal) {
|
95
|
|
- // We are interested in the local audio stream if the event was not triggered on this device.
|
|
113
|
+ // We are interested in the local audio streams
|
96
|
114
|
if (!isLocal || !this._audioTrack) {
|
97
|
115
|
return;
|
98
|
116
|
}
|