Pārlūkot izejas kodu

fix comments and docs

master
Radium Zheng 7 gadus atpakaļ
vecāks
revīzija
913c56c408

+ 5
- 5
react/features/local-recording/recording/WavAdapter.js Parādīt failu

@@ -251,8 +251,8 @@ export class WavAdapter extends AbstractAudioContextAdapter {
251 251
  * using big endianness. Required by WAVE headers.
252 252
  *
253 253
  * @param {ArrayBuffer} view - The view to memory.
254
- * @param {*} offset - Offset.
255
- * @param {*} string - The string to be written.
254
+ * @param {number} offset - Offset.
255
+ * @param {string} string - The string to be written.
256 256
  * @returns {void}
257 257
  */
258 258
 function writeUTFBytes(view, offset, string) {
@@ -267,9 +267,9 @@ function writeUTFBytes(view, offset, string) {
267 267
 /**
268 268
  * Helper function for converting Float32Array to Int16Array.
269 269
  *
270
- * @param {*} output - The output buffer.
271
- * @param {*} offset - The offset in output buffer to write from.
272
- * @param {*} inputBuffers - The input buffers.
270
+ * @param {DataView} output - View to the output buffer.
271
+ * @param {number} offset - The offset in output buffer to write from.
272
+ * @param {Float32Array[]} inputBuffers - The input buffers.
273 273
  * @returns {void}
274 274
  */
275 275
 function floatTo16BitPCM(output, offset, inputBuffers) {

+ 11
- 6
react/features/local-recording/recording/flac/FlacAdapter.js Parādīt failu

@@ -17,17 +17,20 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
17 17
 export class FlacAdapter extends AbstractAudioContextAdapter {
18 18
 
19 19
     /**
20
-     * Instance of flacEncodeWorker.
20
+     * Instance of WebWorker (flacEncodeWorker).
21 21
      */
22 22
     _encoder = null;
23 23
 
24 24
     /**
25
-     * Resolve function of the promise returned by {@code stop()}.
25
+     * Resolve function of the Promise returned by {@code stop()}.
26 26
      * This is called after the WebWorker sends back {@code WORKER_BLOB_READY}.
27 27
      */
28 28
     _stopPromiseResolver = null;
29 29
 
30
-    _initPromiseResolver = null;
30
+    /**
31
+     * Resolve function of the Promise that initializes the flacEncodeWorker.
32
+     */
33
+    _initWorkerPromiseResolver = null;
31 34
 
32 35
     /**
33 36
      * Initialization promise.
@@ -152,8 +155,10 @@ export class FlacAdapter extends AbstractAudioContextAdapter {
152 155
                 reject();
153 156
             }
154 157
 
155
-            // save the Promise's resolver to resolve it later.
156
-            this._initPromiseResolver = resolve;
158
+            // Save the Promise's resolver to resolve it later.
159
+            // This Promise is only resolved in _onWorkerMessage when we
160
+            // receive WORKER_LIBFLAC_READY from the WebWorker.
161
+            this._initWorkerPromiseResolver = resolve;
157 162
 
158 163
             // set up listener for messages from the WebWorker
159 164
             this._encoder.onmessage = this._onWorkerMessage;
@@ -220,7 +225,7 @@ export class FlacAdapter extends AbstractAudioContextAdapter {
220 225
             break;
221 226
         case WORKER_LIBFLAC_READY:
222 227
             logger.log('libflac is ready.');
223
-            this._initPromiseResolver();
228
+            this._initWorkerPromiseResolver();
224 229
             break;
225 230
         default:
226 231
             logger.error(

+ 4
- 4
react/features/local-recording/recording/flac/flacEncodeWorker.js Parādīt failu

@@ -90,8 +90,8 @@ const FLAC_COMPRESSION_LEVEL = 5;
90 90
 /**
91 91
  * Concat multiple Uint8Arrays into one.
92 92
  *
93
- * @param {Array} arrays - Array of Uint8 arrays.
94
- * @param {*} totalLength - Total length of all Uint8Arrays.
93
+ * @param {Uint8Array[]} arrays - Array of Uint8 arrays.
94
+ * @param {number} totalLength - Total length of all Uint8Arrays.
95 95
  * @returns {Uint8Array}
96 96
  */
97 97
 function mergeUint8Arrays(arrays, totalLength) {
@@ -320,8 +320,8 @@ class Encoder {
320 320
      * This is invoked by libflac.
321 321
      *
322 322
      * @private
323
-     * @param {*} buffer - The encoded Flac data.
324
-     * @param {*} bytes - Number of bytes in the data.
323
+     * @param {Uint8Array} buffer - The encoded Flac data.
324
+     * @param {number} bytes - Number of bytes in the data.
325 325
      * @returns {void}
326 326
      */
327 327
     _onEncodedData(buffer, bytes) {

+ 24
- 5
react/features/local-recording/session/SessionManager.js Parādīt failu

@@ -20,9 +20,28 @@ function highPrecisionTime(): number {
20 20
 
21 21
 // Have to use string literal here, instead of Symbols,
22 22
 // because these values need to be JSON-serializible.
23
+
24
+/**
25
+ * Types of SessionEvents.
26
+ */
23 27
 const SessionEventType = Object.freeze({
28
+    /**
29
+     * Start of local recording session. This is recorded when the
30
+     * {@code RecordingController} receives the signal to start local recording,
31
+     * before the actual adapter is engaged.
32
+     */
24 33
     SESSION_STARTED: 'SESSION_STARTED',
34
+
35
+    /**
36
+     * Start of a continuous segment. This is recorded when the adapter is
37
+     * engaged. Can happen multiple times in a local recording session,
38
+     * due to browser reloads or switching of recording device.
39
+     */
25 40
     SEGMENT_STARTED: 'SEGMENT_STARTED',
41
+
42
+    /**
43
+     * End of a continuous segment. This is recorded when the adapter unengages.
44
+     */
26 45
     SEGMENT_ENDED: 'SEGMENT_ENDED'
27 46
 });
28 47
 
@@ -169,8 +188,8 @@ class SessionManager {
169 188
     /**
170 189
      * Creates a session if not exists.
171 190
      *
172
-     * @param {string} sessionToken - .
173
-     * @param {string} format - .
191
+     * @param {string} sessionToken - The local recording session token.
192
+     * @param {string} format - The local recording format.
174 193
      * @returns {void}
175 194
      */
176 195
     createSession(sessionToken: string, format: string) {
@@ -218,7 +237,7 @@ class SessionManager {
218 237
     /**
219 238
      * Removes session metadata.
220 239
      *
221
-     * @param {*} sessionToken - The session token.
240
+     * @param {string} sessionToken - The session token.
222 241
      * @returns {void}
223 242
      */
224 243
     removeSession(sessionToken: string) {
@@ -319,7 +338,7 @@ class SessionManager {
319 338
      * {@code SessionEvent}s.
320 339
      *
321 340
      * @private
322
-     * @param {*} events - The array of {@code SessionEvent}s.
341
+     * @param {SessionEvent[]} events - The array of {@code SessionEvent}s.
323 342
      * @returns {SegmentInfo[]}
324 343
      */
325 344
     _constructSegments(events: SessionEvent[]): SegmentInfo[] {
@@ -416,5 +435,5 @@ class SessionManager {
416 435
  */
417 436
 export const sessionManager = new SessionManager();
418 437
 
419
-// For debug only. Remove later.
438
+// For debug only. To remove later.
420 439
 window.sessionManager = sessionManager;

Notiek ielāde…
Atcelt
Saglabāt