|
|
@@ -40,10 +40,20 @@ const ControllerState = Object.freeze({
|
|
40
|
40
|
*/
|
|
41
|
41
|
IDLE: Symbol('IDLE'),
|
|
42
|
42
|
|
|
|
43
|
+ /**
|
|
|
44
|
+ * Starting.
|
|
|
45
|
+ */
|
|
|
46
|
+ STARTING: Symbol('STARTING'),
|
|
|
47
|
+
|
|
43
|
48
|
/**
|
|
44
|
49
|
* Engaged (recording).
|
|
45
|
50
|
*/
|
|
46
|
|
- RECORDING: Symbol('RECORDING')
|
|
|
51
|
+ RECORDING: Symbol('RECORDING'),
|
|
|
52
|
+
|
|
|
53
|
+ /**
|
|
|
54
|
+ * Stopping.
|
|
|
55
|
+ */
|
|
|
56
|
+ STOPPING: Symbol('STOPPING')
|
|
47
|
57
|
});
|
|
48
|
58
|
|
|
49
|
59
|
/**
|
|
|
@@ -314,6 +324,23 @@ class RecordingController {
|
|
314
|
324
|
return result;
|
|
315
|
325
|
}
|
|
316
|
326
|
|
|
|
327
|
+ _changeState: (Symbol) => void;
|
|
|
328
|
+
|
|
|
329
|
+ /**
|
|
|
330
|
+ * Changes the current state of {@code RecordingController}.
|
|
|
331
|
+ *
|
|
|
332
|
+ * @private
|
|
|
333
|
+ * @param {Symbol} newState - The new state.
|
|
|
334
|
+ * @returns {void}
|
|
|
335
|
+ */
|
|
|
336
|
+ _changeState(newState: Symbol) {
|
|
|
337
|
+ if (this._state !== newState) {
|
|
|
338
|
+ logger.log(`state change: ${this._state.toString()} -> `
|
|
|
339
|
+ + `${newState.toString()}`);
|
|
|
340
|
+ this._state = newState;
|
|
|
341
|
+ }
|
|
|
342
|
+ }
|
|
|
343
|
+
|
|
317
|
344
|
_updateStats: () => void;
|
|
318
|
345
|
|
|
319
|
346
|
/**
|
|
|
@@ -342,13 +369,19 @@ class RecordingController {
|
|
342
|
369
|
const { sessionToken, format } = value.attributes;
|
|
343
|
370
|
|
|
344
|
371
|
if (this._state === ControllerState.IDLE) {
|
|
|
372
|
+ this._changeState(ControllerState.STARTING);
|
|
345
|
373
|
this._format = format;
|
|
346
|
374
|
this._currentSessionToken = sessionToken;
|
|
|
375
|
+ logger.log(this._currentSessionToken);
|
|
347
|
376
|
this._adapters[sessionToken]
|
|
348
|
377
|
= this._createRecordingAdapter();
|
|
349
|
378
|
this._doStartRecording();
|
|
350
|
|
- } else if (this._currentSessionToken !== sessionToken) {
|
|
351
|
|
- // we need to restart the recording
|
|
|
379
|
+ } else if (this._state === ControllerState.RECORDING
|
|
|
380
|
+ && this._currentSessionToken !== sessionToken) {
|
|
|
381
|
+ // There is local recording going on, but not for the same session.
|
|
|
382
|
+ // This means the current state might be out-of-sync with the
|
|
|
383
|
+ // moderator's, so we need to restart the recording.
|
|
|
384
|
+ this._changeState(ControllerState.STOPPING);
|
|
352
|
385
|
this._doStopRecording().then(() => {
|
|
353
|
386
|
this._format = format;
|
|
354
|
387
|
this._currentSessionToken = sessionToken;
|
|
|
@@ -371,6 +404,7 @@ class RecordingController {
|
|
371
|
404
|
_onStopCommand(value) {
|
|
372
|
405
|
if (this._state === ControllerState.RECORDING
|
|
373
|
406
|
&& this._currentSessionToken === value.attributes.sessionToken) {
|
|
|
407
|
+ this._changeState(ControllerState.STOPPING);
|
|
374
|
408
|
this._doStopRecording();
|
|
375
|
409
|
}
|
|
376
|
410
|
}
|
|
|
@@ -394,12 +428,12 @@ class RecordingController {
|
|
394
|
428
|
* @returns {void}
|
|
395
|
429
|
*/
|
|
396
|
430
|
_doStartRecording() {
|
|
397
|
|
- if (this._state === ControllerState.IDLE) {
|
|
398
|
|
- this._state = ControllerState.RECORDING;
|
|
|
431
|
+ if (this._state === ControllerState.STARTING) {
|
|
399
|
432
|
const delegate = this._adapters[this._currentSessionToken];
|
|
400
|
433
|
|
|
401
|
434
|
delegate.start()
|
|
402
|
435
|
.then(() => {
|
|
|
436
|
+ this._changeState(ControllerState.RECORDING);
|
|
403
|
437
|
logger.log('Local recording engaged.');
|
|
404
|
438
|
const message = i18next.t('localRecording.messages.engaged');
|
|
405
|
439
|
|
|
|
@@ -427,13 +461,13 @@ class RecordingController {
|
|
427
|
461
|
* @returns {Promise<void>}
|
|
428
|
462
|
*/
|
|
429
|
463
|
_doStopRecording() {
|
|
430
|
|
- if (this._state === ControllerState.RECORDING) {
|
|
|
464
|
+ if (this._state === ControllerState.STOPPING) {
|
|
431
|
465
|
const token = this._currentSessionToken;
|
|
432
|
466
|
|
|
433
|
467
|
return this._adapters[this._currentSessionToken]
|
|
434
|
468
|
.stop()
|
|
435
|
469
|
.then(() => {
|
|
436
|
|
- this._state = ControllerState.IDLE;
|
|
|
470
|
+ this._changeState(ControllerState.IDLE);
|
|
437
|
471
|
logger.log('Local recording unengaged.');
|
|
438
|
472
|
this.downloadRecordedData(token);
|
|
439
|
473
|
|