Browse Source

feat(ts) TypeScript conversion of DetectionEvents

tags/v0.0.2
Gary Hunt 3 years ago
parent
commit
bf3c5881e6
No account linked to committer's email address

+ 0
- 60
modules/detection/DetectionEvents.js View File

@@ -1,60 +0,0 @@
1
-/**
2
- * Event triggered by a audio detector indicating that its active state has changed from active to inactive or vice
3
- * versa.
4
- * @event
5
- * @type {boolean} - true when service has changed to active false otherwise.
6
- */
7
-export const DETECTOR_STATE_CHANGE = 'detector_state_change';
8
-
9
-/** Event triggered by {@link NoAudioSignalDetector} when the local audio device associated with a JitsiConference
10
- * starts receiving audio levels with the value of 0 meaning no audio is being captured on that device, or when
11
- * it starts receiving audio levels !== 0 after being in a state of no audio.
12
- * @event
13
- * @type {boolean} - true when the current conference audio track has audio input false otherwise.
14
- */
15
-export const AUDIO_INPUT_STATE_CHANGE = 'audio_input_state_changed';
16
-
17
-/** Event triggered by NoAudioSignalDetector when the local audio device associated with a JitsiConference goes silent
18
- * for a period of time, meaning that the device is either broken or hardware/software muted.
19
- * @event
20
- * @type {void}
21
- */
22
-export const NO_AUDIO_INPUT = 'no_audio_input_detected';
23
-
24
-/**
25
- *  Event generated by {@link VADNoiseDetection} when the tracked device is considered noisy.
26
- *  @event
27
- *  @type {Object}
28
- */
29
-export const VAD_NOISY_DEVICE = 'detection.vad_noise_device';
30
-
31
-/**
32
- * Event generated by VADReportingService when if finishes creating a VAD report for the monitored devices.
33
- * The generated objects are of type Array<Object>, one score for each monitored device.
34
- * @event VAD_REPORT_PUBLISHED
35
- * @type Array<Object> with the following structure:
36
- * @property {Date} timestamp - Timestamp at which the compute took place.
37
- * @property {number} avgVAD - Average VAD score over monitored period of time.
38
- * @property {string} deviceId - Associate local audio device ID.
39
- */
40
-export const VAD_REPORT_PUBLISHED = 'vad-report-published';
41
-
42
-/**
43
- * Event generated by {@link TrackVADEmitter} when PCM sample VAD score is available.
44
- *
45
- * @event
46
- * @type {Object}
47
- * @property {Date}   timestamp - Exact time at which processed PCM sample was generated.
48
- * @property {number} score - VAD score on a scale from 0 to 1 (i.e. 0.7)
49
- * @property {Float32Array} pcmData - Raw PCM data with which the VAD score was calculated.
50
- * @property {string} deviceId - Device id of the associated track.
51
- */
52
-export const VAD_SCORE_PUBLISHED = 'detection.vad_score_published';
53
-
54
-/**
55
- *  Event generated by {@link VADTalkMutedDetection} when a user is talking while the mic is muted.
56
- *
57
- *  @event
58
- *  @type {Object}
59
- */
60
-export const VAD_TALK_WHILE_MUTED = 'detection.vad_talk_while_muted';

+ 11
- 10
modules/detection/DetectionEvents.spec.ts View File

@@ -13,7 +13,7 @@ describe( "/modules/detection/DetectionEvents members", () => {
13 13
         VAD_TALK_WHILE_MUTED,
14 14
         DetectionEvents,
15 15
         ...others
16
-    } = exported as any; // TODO: remove cast after typescript conversion
16
+    } = exported;
17 17
 
18 18
     it( "known members", () => {
19 19
         expect( DETECTOR_STATE_CHANGE ).toBe( 'detector_state_change' );
@@ -23,15 +23,16 @@ describe( "/modules/detection/DetectionEvents members", () => {
23 23
         expect( VAD_REPORT_PUBLISHED ).toBe( 'vad-report-published' );
24 24
         expect( VAD_SCORE_PUBLISHED ).toBe( 'detection.vad_score_published' );
25 25
         expect( VAD_TALK_WHILE_MUTED ).toBe( 'detection.vad_talk_while_muted' );
26
-        if ( DetectionEvents ) {
27
-            expect( DetectionEvents.DETECTOR_STATE_CHANGE ).toBe( 'detector_state_change' );
28
-            expect( DetectionEvents.AUDIO_INPUT_STATE_CHANGE ).toBe( 'audio_input_state_changed' );
29
-            expect( DetectionEvents.NO_AUDIO_INPUT ).toBe( 'no_audio_input_detected' );
30
-            expect( DetectionEvents.VAD_NOISY_DEVICE ).toBe( 'detection.vad_noise_device' );
31
-            expect( DetectionEvents.VAD_REPORT_PUBLISHED ).toBe( 'vad-report-published' );
32
-            expect( DetectionEvents.VAD_SCORE_PUBLISHED ).toBe( 'detection.vad_score_published' );
33
-            expect( DetectionEvents.VAD_TALK_WHILE_MUTED ).toBe( 'detection.vad_talk_while_muted' );
34
-        }
26
+
27
+        expect( DetectionEvents ).toBeDefined();
28
+
29
+        expect( DetectionEvents.DETECTOR_STATE_CHANGE ).toBe( 'detector_state_change' );
30
+        expect( DetectionEvents.AUDIO_INPUT_STATE_CHANGE ).toBe( 'audio_input_state_changed' );
31
+        expect( DetectionEvents.NO_AUDIO_INPUT ).toBe( 'no_audio_input_detected' );
32
+        expect( DetectionEvents.VAD_NOISY_DEVICE ).toBe( 'detection.vad_noise_device' );
33
+        expect( DetectionEvents.VAD_REPORT_PUBLISHED ).toBe( 'vad-report-published' );
34
+        expect( DetectionEvents.VAD_SCORE_PUBLISHED ).toBe( 'detection.vad_score_published' );
35
+        expect( DetectionEvents.VAD_TALK_WHILE_MUTED ).toBe( 'detection.vad_talk_while_muted' );
35 36
     } );
36 37
 
37 38
     it( "unknown members", () => {

+ 71
- 0
modules/detection/DetectionEvents.ts View File

@@ -0,0 +1,71 @@
1
+export enum DetectionEvents {
2
+    /**
3
+     * Event triggered by a audio detector indicating that its active state has changed from active to inactive or vice
4
+     * versa.
5
+     * @event
6
+     * @type {boolean} - true when service has changed to active false otherwise.
7
+     */
8
+    DETECTOR_STATE_CHANGE = 'detector_state_change',
9
+
10
+    /** Event triggered by {@link NoAudioSignalDetector} when the local audio device associated with a JitsiConference
11
+     * starts receiving audio levels with the value of 0 meaning no audio is being captured on that device, or when
12
+     * it starts receiving audio levels !== 0 after being in a state of no audio.
13
+     * @event
14
+     * @type {boolean} - true when the current conference audio track has audio input false otherwise.
15
+     */
16
+    AUDIO_INPUT_STATE_CHANGE = 'audio_input_state_changed',
17
+
18
+    /** Event triggered by NoAudioSignalDetector when the local audio device associated with a JitsiConference goes silent
19
+     * for a period of time, meaning that the device is either broken or hardware/software muted.
20
+     * @event
21
+     * @type {void}
22
+     */
23
+    NO_AUDIO_INPUT = 'no_audio_input_detected',
24
+
25
+    /**
26
+     *  Event generated by {@link VADNoiseDetection} when the tracked device is considered noisy.
27
+     *  @event
28
+     *  @type {Object}
29
+     */
30
+    VAD_NOISY_DEVICE = 'detection.vad_noise_device',
31
+
32
+    /**
33
+     * Event generated by VADReportingService when if finishes creating a VAD report for the monitored devices.
34
+     * The generated objects are of type Array<Object>, one score for each monitored device.
35
+     * @event VAD_REPORT_PUBLISHED
36
+     * @type Array<Object> with the following structure:
37
+     * @property {Date} timestamp - Timestamp at which the compute took place.
38
+     * @property {number} avgVAD - Average VAD score over monitored period of time.
39
+     * @property {string} deviceId - Associate local audio device ID.
40
+     */
41
+    VAD_REPORT_PUBLISHED = 'vad-report-published',
42
+
43
+    /**
44
+     * Event generated by {@link TrackVADEmitter} when PCM sample VAD score is available.
45
+     *
46
+     * @event
47
+     * @type {Object}
48
+     * @property {Date}   timestamp - Exact time at which processed PCM sample was generated.
49
+     * @property {number} score - VAD score on a scale from 0 to 1 (i.e. 0.7)
50
+     * @property {Float32Array} pcmData - Raw PCM data with which the VAD score was calculated.
51
+     * @property {string} deviceId - Device id of the associated track.
52
+     */
53
+    VAD_SCORE_PUBLISHED = 'detection.vad_score_published',
54
+
55
+    /**
56
+     *  Event generated by {@link VADTalkMutedDetection} when a user is talking while the mic is muted.
57
+     *
58
+     *  @event
59
+     *  @type {Object}
60
+     */
61
+    VAD_TALK_WHILE_MUTED = 'detection.vad_talk_while_muted'
62
+};
63
+
64
+// exported for backward compatibility
65
+export const DETECTOR_STATE_CHANGE = DetectionEvents.DETECTOR_STATE_CHANGE;
66
+export const AUDIO_INPUT_STATE_CHANGE = DetectionEvents.AUDIO_INPUT_STATE_CHANGE;
67
+export const NO_AUDIO_INPUT = DetectionEvents.NO_AUDIO_INPUT;
68
+export const VAD_NOISY_DEVICE = DetectionEvents.VAD_NOISY_DEVICE;
69
+export const VAD_REPORT_PUBLISHED = DetectionEvents.VAD_REPORT_PUBLISHED;
70
+export const VAD_SCORE_PUBLISHED = DetectionEvents.VAD_SCORE_PUBLISHED;
71
+export const VAD_TALK_WHILE_MUTED = DetectionEvents.VAD_TALK_WHILE_MUTED;

+ 63
- 54
types/auto/modules/detection/DetectionEvents.d.ts View File

@@ -1,54 +1,63 @@
1
-/**
2
- * Event triggered by a audio detector indicating that its active state has changed from active to inactive or vice
3
- * versa.
4
- * @event
5
- * @type {boolean} - true when service has changed to active false otherwise.
6
- */
7
-export const DETECTOR_STATE_CHANGE: boolean;
8
-/** Event triggered by {@link NoAudioSignalDetector} when the local audio device associated with a JitsiConference
9
- * starts receiving audio levels with the value of 0 meaning no audio is being captured on that device, or when
10
- * it starts receiving audio levels !== 0 after being in a state of no audio.
11
- * @event
12
- * @type {boolean} - true when the current conference audio track has audio input false otherwise.
13
- */
14
-export const AUDIO_INPUT_STATE_CHANGE: boolean;
15
-/** Event triggered by NoAudioSignalDetector when the local audio device associated with a JitsiConference goes silent
16
- * for a period of time, meaning that the device is either broken or hardware/software muted.
17
- * @event
18
- * @type {void}
19
- */
20
-export const NO_AUDIO_INPUT: void;
21
-/**
22
- *  Event generated by {@link VADNoiseDetection} when the tracked device is considered noisy.
23
- *  @event
24
- *  @type {Object}
25
- */
26
-export const VAD_NOISY_DEVICE: any;
27
-/**
28
- * Event generated by VADReportingService when if finishes creating a VAD report for the monitored devices.
29
- * The generated objects are of type Array<Object>, one score for each monitored device.
30
- * @event VAD_REPORT_PUBLISHED
31
- * @type Array<Object> with the following structure:
32
- * @property {Date} timestamp - Timestamp at which the compute took place.
33
- * @property {number} avgVAD - Average VAD score over monitored period of time.
34
- * @property {string} deviceId - Associate local audio device ID.
35
- */
36
-export const VAD_REPORT_PUBLISHED: Array<any>;
37
-/**
38
- * Event generated by {@link TrackVADEmitter} when PCM sample VAD score is available.
39
- *
40
- * @event
41
- * @type {Object}
42
- * @property {Date}   timestamp - Exact time at which processed PCM sample was generated.
43
- * @property {number} score - VAD score on a scale from 0 to 1 (i.e. 0.7)
44
- * @property {Float32Array} pcmData - Raw PCM data with which the VAD score was calculated.
45
- * @property {string} deviceId - Device id of the associated track.
46
- */
47
-export const VAD_SCORE_PUBLISHED: any;
48
-/**
49
- *  Event generated by {@link VADTalkMutedDetection} when a user is talking while the mic is muted.
50
- *
51
- *  @event
52
- *  @type {Object}
53
- */
54
-export const VAD_TALK_WHILE_MUTED: any;
1
+export declare enum DetectionEvents {
2
+    /**
3
+     * Event triggered by a audio detector indicating that its active state has changed from active to inactive or vice
4
+     * versa.
5
+     * @event
6
+     * @type {boolean} - true when service has changed to active false otherwise.
7
+     */
8
+    DETECTOR_STATE_CHANGE = "detector_state_change",
9
+    /** Event triggered by {@link NoAudioSignalDetector} when the local audio device associated with a JitsiConference
10
+     * starts receiving audio levels with the value of 0 meaning no audio is being captured on that device, or when
11
+     * it starts receiving audio levels !== 0 after being in a state of no audio.
12
+     * @event
13
+     * @type {boolean} - true when the current conference audio track has audio input false otherwise.
14
+     */
15
+    AUDIO_INPUT_STATE_CHANGE = "audio_input_state_changed",
16
+    /** Event triggered by NoAudioSignalDetector when the local audio device associated with a JitsiConference goes silent
17
+     * for a period of time, meaning that the device is either broken or hardware/software muted.
18
+     * @event
19
+     * @type {void}
20
+     */
21
+    NO_AUDIO_INPUT = "no_audio_input_detected",
22
+    /**
23
+     *  Event generated by {@link VADNoiseDetection} when the tracked device is considered noisy.
24
+     *  @event
25
+     *  @type {Object}
26
+     */
27
+    VAD_NOISY_DEVICE = "detection.vad_noise_device",
28
+    /**
29
+     * Event generated by VADReportingService when if finishes creating a VAD report for the monitored devices.
30
+     * The generated objects are of type Array<Object>, one score for each monitored device.
31
+     * @event VAD_REPORT_PUBLISHED
32
+     * @type Array<Object> with the following structure:
33
+     * @property {Date} timestamp - Timestamp at which the compute took place.
34
+     * @property {number} avgVAD - Average VAD score over monitored period of time.
35
+     * @property {string} deviceId - Associate local audio device ID.
36
+     */
37
+    VAD_REPORT_PUBLISHED = "vad-report-published",
38
+    /**
39
+     * Event generated by {@link TrackVADEmitter} when PCM sample VAD score is available.
40
+     *
41
+     * @event
42
+     * @type {Object}
43
+     * @property {Date}   timestamp - Exact time at which processed PCM sample was generated.
44
+     * @property {number} score - VAD score on a scale from 0 to 1 (i.e. 0.7)
45
+     * @property {Float32Array} pcmData - Raw PCM data with which the VAD score was calculated.
46
+     * @property {string} deviceId - Device id of the associated track.
47
+     */
48
+    VAD_SCORE_PUBLISHED = "detection.vad_score_published",
49
+    /**
50
+     *  Event generated by {@link VADTalkMutedDetection} when a user is talking while the mic is muted.
51
+     *
52
+     *  @event
53
+     *  @type {Object}
54
+     */
55
+    VAD_TALK_WHILE_MUTED = "detection.vad_talk_while_muted"
56
+}
57
+export declare const DETECTOR_STATE_CHANGE = DetectionEvents.DETECTOR_STATE_CHANGE;
58
+export declare const AUDIO_INPUT_STATE_CHANGE = DetectionEvents.AUDIO_INPUT_STATE_CHANGE;
59
+export declare const NO_AUDIO_INPUT = DetectionEvents.NO_AUDIO_INPUT;
60
+export declare const VAD_NOISY_DEVICE = DetectionEvents.VAD_NOISY_DEVICE;
61
+export declare const VAD_REPORT_PUBLISHED = DetectionEvents.VAD_REPORT_PUBLISHED;
62
+export declare const VAD_SCORE_PUBLISHED = DetectionEvents.VAD_SCORE_PUBLISHED;
63
+export declare const VAD_TALK_WHILE_MUTED = DetectionEvents.VAD_TALK_WHILE_MUTED;

Loading…
Cancel
Save