|
|
@@ -72,7 +72,12 @@ const ControllerState = Object.freeze({
|
|
72
|
72
|
/**
|
|
73
|
73
|
* Stopping.
|
|
74
|
74
|
*/
|
|
75
|
|
- STOPPING: Symbol('STOPPING')
|
|
|
75
|
+ STOPPING: Symbol('STOPPING'),
|
|
|
76
|
+
|
|
|
77
|
+ /**
|
|
|
78
|
+ * Failed, due to error during starting / stopping process.
|
|
|
79
|
+ */
|
|
|
80
|
+ FAILED: Symbol('FAILED')
|
|
76
|
81
|
});
|
|
77
|
82
|
|
|
78
|
83
|
/**
|
|
|
@@ -147,6 +152,13 @@ class RecordingController {
|
|
147
|
152
|
*/
|
|
148
|
153
|
_isMuted = false;
|
|
149
|
154
|
|
|
|
155
|
+ /**
|
|
|
156
|
+ * The ID of the active microphone.
|
|
|
157
|
+ *
|
|
|
158
|
+ * @private
|
|
|
159
|
+ */
|
|
|
160
|
+ _micDeviceId = 'default';
|
|
|
161
|
+
|
|
150
|
162
|
/**
|
|
151
|
163
|
* Current recording format. This will be in effect from the next
|
|
152
|
164
|
* recording session, i.e., if this value is changed during an on-going
|
|
|
@@ -190,14 +202,15 @@ class RecordingController {
|
|
190
|
202
|
* @returns {void}
|
|
191
|
203
|
*/
|
|
192
|
204
|
constructor() {
|
|
193
|
|
- this._updateStats = this._updateStats.bind(this);
|
|
|
205
|
+ this.registerEvents = this.registerEvents.bind(this);
|
|
|
206
|
+ this.getParticipantsStats = this.getParticipantsStats.bind(this);
|
|
194
|
207
|
this._onStartCommand = this._onStartCommand.bind(this);
|
|
195
|
208
|
this._onStopCommand = this._onStopCommand.bind(this);
|
|
196
|
209
|
this._onPingCommand = this._onPingCommand.bind(this);
|
|
197
|
210
|
this._doStartRecording = this._doStartRecording.bind(this);
|
|
198
|
211
|
this._doStopRecording = this._doStopRecording.bind(this);
|
|
199
|
|
- this.registerEvents = this.registerEvents.bind(this);
|
|
200
|
|
- this.getParticipantsStats = this.getParticipantsStats.bind(this);
|
|
|
212
|
+ this._updateStats = this._updateStats.bind(this);
|
|
|
213
|
+ this._switchToNewSession = this._switchToNewSession.bind(this);
|
|
201
|
214
|
}
|
|
202
|
215
|
|
|
203
|
216
|
registerEvents: () => void;
|
|
|
@@ -311,6 +324,34 @@ class RecordingController {
|
|
311
|
324
|
}
|
|
312
|
325
|
}
|
|
313
|
326
|
|
|
|
327
|
+ /**
|
|
|
328
|
+ * Changes the current microphone.
|
|
|
329
|
+ *
|
|
|
330
|
+ * @param {string} micDeviceId - The new microphone device ID.
|
|
|
331
|
+ * @returns {void}
|
|
|
332
|
+ */
|
|
|
333
|
+ setMicDevice(micDeviceId: string) {
|
|
|
334
|
+ if (micDeviceId !== this._micDeviceId) {
|
|
|
335
|
+ this._micDeviceId = String(micDeviceId);
|
|
|
336
|
+
|
|
|
337
|
+ if (this._state === ControllerState.RECORDING) {
|
|
|
338
|
+ // sessionManager.endSegment(this._currentSessionToken);
|
|
|
339
|
+ logger.log('Before switching microphone...');
|
|
|
340
|
+ this._adapters[this._currentSessionToken]
|
|
|
341
|
+ .setMicDevice(this._micDeviceId)
|
|
|
342
|
+ .then(() => {
|
|
|
343
|
+ logger.log('Finished switching microphone.');
|
|
|
344
|
+
|
|
|
345
|
+ // sessionManager.beginSegment(this._currentSesoken);
|
|
|
346
|
+ })
|
|
|
347
|
+ .catch(() => {
|
|
|
348
|
+ logger.error('Failed to switch microphone');
|
|
|
349
|
+ });
|
|
|
350
|
+ }
|
|
|
351
|
+ logger.log(`Switch microphone to ${this._micDeviceId}`);
|
|
|
352
|
+ }
|
|
|
353
|
+ }
|
|
|
354
|
+
|
|
314
|
355
|
/**
|
|
315
|
356
|
* Mute or unmute audio. When muted, the ongoing local recording should
|
|
316
|
357
|
* produce silence.
|
|
|
@@ -322,7 +363,7 @@ class RecordingController {
|
|
322
|
363
|
this._isMuted = Boolean(muted);
|
|
323
|
364
|
|
|
324
|
365
|
if (this._state === ControllerState.RECORDING) {
|
|
325
|
|
- this._adapters[this._currentSessionToken].setMuted(muted);
|
|
|
366
|
+ this._adapters[this._currentSessionToken].setMuted(this._isMuted);
|
|
326
|
367
|
}
|
|
327
|
368
|
}
|
|
328
|
369
|
|
|
|
@@ -442,11 +483,7 @@ class RecordingController {
|
|
442
|
483
|
|
|
443
|
484
|
if (this._state === ControllerState.IDLE) {
|
|
444
|
485
|
this._changeState(ControllerState.STARTING);
|
|
445
|
|
- this._format = format;
|
|
446
|
|
- this._currentSessionToken = sessionToken;
|
|
447
|
|
- logger.log(this._currentSessionToken);
|
|
448
|
|
- this._adapters[sessionToken]
|
|
449
|
|
- = this._createRecordingAdapter();
|
|
|
486
|
+ this._switchToNewSession(sessionToken, format);
|
|
450
|
487
|
this._doStartRecording();
|
|
451
|
488
|
} else if (this._state === ControllerState.RECORDING
|
|
452
|
489
|
&& this._currentSessionToken !== sessionToken) {
|
|
|
@@ -455,10 +492,8 @@ class RecordingController {
|
|
455
|
492
|
// moderator's, so we need to restart the recording.
|
|
456
|
493
|
this._changeState(ControllerState.STOPPING);
|
|
457
|
494
|
this._doStopRecording().then(() => {
|
|
458
|
|
- this._format = format;
|
|
459
|
|
- this._currentSessionToken = sessionToken;
|
|
460
|
|
- this._adapters[sessionToken]
|
|
461
|
|
- = this._createRecordingAdapter();
|
|
|
495
|
+ this._changeState(ControllerState.STARTING);
|
|
|
496
|
+ this._switchToNewSession(sessionToken, format);
|
|
462
|
497
|
this._doStartRecording();
|
|
463
|
498
|
});
|
|
464
|
499
|
}
|
|
|
@@ -518,7 +553,7 @@ class RecordingController {
|
|
518
|
553
|
if (this._state === ControllerState.STARTING) {
|
|
519
|
554
|
const delegate = this._adapters[this._currentSessionToken];
|
|
520
|
555
|
|
|
521
|
|
- delegate.start()
|
|
|
556
|
+ delegate.start(this._micDeviceId)
|
|
522
|
557
|
.then(() => {
|
|
523
|
558
|
this._changeState(ControllerState.RECORDING);
|
|
524
|
559
|
logger.log('Local recording engaged.');
|
|
|
@@ -587,6 +622,25 @@ class RecordingController {
|
|
587
|
622
|
|
|
588
|
623
|
}
|
|
589
|
624
|
|
|
|
625
|
+ _switchToNewSession: (string, string) => void;
|
|
|
626
|
+
|
|
|
627
|
+ /**
|
|
|
628
|
+ * Switches to a new local recording session.
|
|
|
629
|
+ *
|
|
|
630
|
+ * @param {string} sessionToken - The session Token.
|
|
|
631
|
+ * @param {string} format - The recording format for the session.
|
|
|
632
|
+ * @returns {void}
|
|
|
633
|
+ */
|
|
|
634
|
+ _switchToNewSession(sessionToken, format) {
|
|
|
635
|
+ this._format = format;
|
|
|
636
|
+ this._currentSessionToken = sessionToken;
|
|
|
637
|
+ logger.log(`New session: ${this._currentSessionToken}, `
|
|
|
638
|
+ + `format: ${this._format}`);
|
|
|
639
|
+ this._adapters[sessionToken]
|
|
|
640
|
+ = this._createRecordingAdapter();
|
|
|
641
|
+ sessionManager.createSession(sessionToken, this._format);
|
|
|
642
|
+ }
|
|
|
643
|
+
|
|
590
|
644
|
/**
|
|
591
|
645
|
* Creates a recording adapter according to the current recording format.
|
|
592
|
646
|
*
|