瀏覽代碼

updated api doc, additional comments

dev1
Andrei Gavrilescu 5 年之前
父節點
當前提交
e1c2a79e55

+ 5
- 0
doc/API.md 查看文件

@@ -84,6 +84,9 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
84 84
 * ```JitsiMeetJS.enumerateDevices(callback)``` - __DEPRECATED__. Use ```JitsiMeetJS.mediaDevices.enumerateDevices(callback)``` instead.
85 85
 * ```JitsiMeetJS.isDeviceChangeAvailable(deviceType)``` - __DEPRECATED__. Use ```JitsiMeetJS.mediaDevices.isDeviceChangeAvailable(deviceType)``` instead.
86 86
 * ```JitsiMeetJS.isDesktopSharingEnabled()``` - returns true if desktop sharing is supported and false otherwise. NOTE: that method can be used after ```JitsiMeetJS.init(options)``` is completed otherwise the result will be always null.
87
+* ```JitsiMeetJS.getActiveAudioDevice()``` - goes through all audio devices on the system and returns information about one that is active, i.e. has audio signal. Returns a Promise resolving to an Object with the following structure:
88
+    - deviceId - string containing the device ID of the audio track found as active.
89
+    - deviceLabel - string containing the label of the audio device.
87 90
 * ```JitsiMeetJS.getGlobalOnErrorHandler()``` - returns function that can be used to be attached to window.onerror and if options.enableWindowOnErrorHandler is enabled returns the function used by the lib. (function(message, source, lineno, colno, error)).
88 91
 
89 92
 * ```JitsiMeetJS.mediaDevices``` - JS object that contains methods for interaction with media devices. Following methods are available:
@@ -132,6 +135,8 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
132 135
         - ENDPOINT_MESSAGE_RECEIVED - notifies that a new message
133 136
         from another participant is received on a data channel.
134 137
         - TALK_WHILE_MUTED - notifies that a local user is talking while having the microphone muted.
138
+        - NO_AUDIO_INPUT - notifies that the current selected input device has no signal.
139
+        - AUDIO_INPUT_STATE_CHANGE - notifies that the current conference audio input switched between audio input states i.e. with or without audio input.
135 140
 
136 141
     2. connection
137 142
         - CONNECTION_FAILED - indicates that the server connection failed.

+ 2
- 4
modules/detection/ActiveDeviceDetector.js 查看文件

@@ -66,8 +66,7 @@ export default function getActiveAudioDevice() {
66 66
                         if (audioLevel > 0.008) {
67 67
                             stopActiveDevices(availableDevices);
68 68
                             resolve({ deviceId: device.deviceId,
69
-                                deviceLabel: device.track.label,
70
-                                audioLevel });
69
+                                deviceLabel: device.track.label });
71 70
                         }
72 71
                     });
73 72
                 }
@@ -76,8 +75,7 @@ export default function getActiveAudioDevice() {
76 75
                 setTimeout(() => {
77 76
                     stopActiveDevices(availableDevices);
78 77
                     resolve({ deviceId: '',
79
-                        deviceLabel: '',
80
-                        audioLevel: 0 });
78
+                        deviceLabel: '' });
81 79
                 }, DETECTION_TIMEOUT);
82 80
 
83 81
             });

+ 1
- 1
modules/detection/DetectionEvents.js 查看文件

@@ -1,7 +1,7 @@
1 1
 /** Event triggered by NoAudioSignalDetector when the local audio device associated with a JitsiConference goes silent
2 2
  * for a period of time, meaning that the device is either broken or hardware/software muted.
3 3
  * @event
4
- * @type {Object} - empty
4
+ * @type {void}
5 5
  */
6 6
 export const NO_AUDIO_INPUT = 'no_audio_input_detected';
7 7
 

+ 19
- 1
modules/detection/NoAudioSignalDetection.js 查看文件

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

+ 2
- 2
modules/detection/VADTalkMutedDetection.js 查看文件

@@ -1,8 +1,8 @@
1 1
 import { EventEmitter } from 'events';
2
-import { VAD_SCORE_PUBLISHED, VAD_TALK_WHILE_MUTED } from './DetectionEvents';
2
+import * as JitsiConferenceEvents from '../../JitsiConferenceEvents';
3 3
 import { getLogger } from 'jitsi-meet-logger';
4
+import { VAD_SCORE_PUBLISHED, VAD_TALK_WHILE_MUTED } from './DetectionEvents';
4 5
 import TrackVADEmitter from './TrackVADEmitter';
5
-import * as JitsiConferenceEvents from '../../JitsiConferenceEvents';
6 6
 
7 7
 const logger = getLogger(__filename);
8 8
 

Loading…
取消
儲存