Procházet zdrojové kódy

fix comments and docs

master
Radium Zheng před 7 roky
rodič
revize
913c56c408

+ 5
- 5
react/features/local-recording/recording/WavAdapter.js Zobrazit soubor

251
  * using big endianness. Required by WAVE headers.
251
  * using big endianness. Required by WAVE headers.
252
  *
252
  *
253
  * @param {ArrayBuffer} view - The view to memory.
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
  * @returns {void}
256
  * @returns {void}
257
  */
257
  */
258
 function writeUTFBytes(view, offset, string) {
258
 function writeUTFBytes(view, offset, string) {
267
 /**
267
 /**
268
  * Helper function for converting Float32Array to Int16Array.
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
  * @returns {void}
273
  * @returns {void}
274
  */
274
  */
275
 function floatTo16BitPCM(output, offset, inputBuffers) {
275
 function floatTo16BitPCM(output, offset, inputBuffers) {

+ 11
- 6
react/features/local-recording/recording/flac/FlacAdapter.js Zobrazit soubor

17
 export class FlacAdapter extends AbstractAudioContextAdapter {
17
 export class FlacAdapter extends AbstractAudioContextAdapter {
18
 
18
 
19
     /**
19
     /**
20
-     * Instance of flacEncodeWorker.
20
+     * Instance of WebWorker (flacEncodeWorker).
21
      */
21
      */
22
     _encoder = null;
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
      * This is called after the WebWorker sends back {@code WORKER_BLOB_READY}.
26
      * This is called after the WebWorker sends back {@code WORKER_BLOB_READY}.
27
      */
27
      */
28
     _stopPromiseResolver = null;
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
      * Initialization promise.
36
      * Initialization promise.
152
                 reject();
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
             // set up listener for messages from the WebWorker
163
             // set up listener for messages from the WebWorker
159
             this._encoder.onmessage = this._onWorkerMessage;
164
             this._encoder.onmessage = this._onWorkerMessage;
220
             break;
225
             break;
221
         case WORKER_LIBFLAC_READY:
226
         case WORKER_LIBFLAC_READY:
222
             logger.log('libflac is ready.');
227
             logger.log('libflac is ready.');
223
-            this._initPromiseResolver();
228
+            this._initWorkerPromiseResolver();
224
             break;
229
             break;
225
         default:
230
         default:
226
             logger.error(
231
             logger.error(

+ 4
- 4
react/features/local-recording/recording/flac/flacEncodeWorker.js Zobrazit soubor

90
 /**
90
 /**
91
  * Concat multiple Uint8Arrays into one.
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
  * @returns {Uint8Array}
95
  * @returns {Uint8Array}
96
  */
96
  */
97
 function mergeUint8Arrays(arrays, totalLength) {
97
 function mergeUint8Arrays(arrays, totalLength) {
320
      * This is invoked by libflac.
320
      * This is invoked by libflac.
321
      *
321
      *
322
      * @private
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
      * @returns {void}
325
      * @returns {void}
326
      */
326
      */
327
     _onEncodedData(buffer, bytes) {
327
     _onEncodedData(buffer, bytes) {

+ 24
- 5
react/features/local-recording/session/SessionManager.js Zobrazit soubor

20
 
20
 
21
 // Have to use string literal here, instead of Symbols,
21
 // Have to use string literal here, instead of Symbols,
22
 // because these values need to be JSON-serializible.
22
 // because these values need to be JSON-serializible.
23
+
24
+/**
25
+ * Types of SessionEvents.
26
+ */
23
 const SessionEventType = Object.freeze({
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
     SESSION_STARTED: 'SESSION_STARTED',
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
     SEGMENT_STARTED: 'SEGMENT_STARTED',
40
     SEGMENT_STARTED: 'SEGMENT_STARTED',
41
+
42
+    /**
43
+     * End of a continuous segment. This is recorded when the adapter unengages.
44
+     */
26
     SEGMENT_ENDED: 'SEGMENT_ENDED'
45
     SEGMENT_ENDED: 'SEGMENT_ENDED'
27
 });
46
 });
28
 
47
 
169
     /**
188
     /**
170
      * Creates a session if not exists.
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
      * @returns {void}
193
      * @returns {void}
175
      */
194
      */
176
     createSession(sessionToken: string, format: string) {
195
     createSession(sessionToken: string, format: string) {
218
     /**
237
     /**
219
      * Removes session metadata.
238
      * Removes session metadata.
220
      *
239
      *
221
-     * @param {*} sessionToken - The session token.
240
+     * @param {string} sessionToken - The session token.
222
      * @returns {void}
241
      * @returns {void}
223
      */
242
      */
224
     removeSession(sessionToken: string) {
243
     removeSession(sessionToken: string) {
319
      * {@code SessionEvent}s.
338
      * {@code SessionEvent}s.
320
      *
339
      *
321
      * @private
340
      * @private
322
-     * @param {*} events - The array of {@code SessionEvent}s.
341
+     * @param {SessionEvent[]} events - The array of {@code SessionEvent}s.
323
      * @returns {SegmentInfo[]}
342
      * @returns {SegmentInfo[]}
324
      */
343
      */
325
     _constructSegments(events: SessionEvent[]): SegmentInfo[] {
344
     _constructSegments(events: SessionEvent[]): SegmentInfo[] {
416
  */
435
  */
417
 export const sessionManager = new SessionManager();
436
 export const sessionManager = new SessionManager();
418
 
437
 
419
-// For debug only. Remove later.
438
+// For debug only. To remove later.
420
 window.sessionManager = sessionManager;
439
 window.sessionManager = sessionManager;

Načítá se…
Zrušit
Uložit