fixes from testing pause/resume recording

This commit is contained in:
Dave Horton
2022-06-23 16:18:30 -04:00
parent 86627e3b2f
commit 34f2bd9d6c

View File

@@ -264,19 +264,23 @@ class CallSession extends Emitter {
/* check validity of request */ /* check validity of request */
if (action == 'startCallRecording' && this.recordState !== RecordState.RecordingOff) { if (action == 'startCallRecording' && this.recordState !== RecordState.RecordingOff) {
this.logger.info('CallSession:notifyRecordOptions: recording is already started, ignoring request'); this.logger.info({recordState: this.recordState},
'CallSession:notifyRecordOptions: recording is already started, ignoring request');
return false; return false;
} }
if (action == 'stopCallRecording' && this.recordState === RecordState.RecordingOff) { if (action == 'stopCallRecording' && this.recordState === RecordState.RecordingOff) {
this.logger.info('CallSession:notifyRecordOptions: recording is already stopped, ignoring request'); this.logger.info({recordState: this.recordState},
'CallSession:notifyRecordOptions: recording is already stopped, ignoring request');
return false; return false;
} }
if (action == 'pauseCallRecording' && this.recordState !== RecordState.RecordingOn) { if (action == 'pauseCallRecording' && this.recordState !== RecordState.RecordingOn) {
this.logger.info('CallSession:notifyRecordOptions: cannot pause recording, ignoring request '); this.logger.info({recordState: this.recordState},
'CallSession:notifyRecordOptions: cannot pause recording, ignoring request ');
return false; return false;
} }
if (action == 'resumeCallRecording' && this.recordState !== RecordState.RecordingPaused) { if (action == 'resumeCallRecording' && this.recordState !== RecordState.RecordingPaused) {
this.logger.info('CallSession:notifyRecordOptions: cannot resume recording, ignoring request '); this.logger.info({recordState: this.recordState},
'CallSession:notifyRecordOptions: cannot resume recording, ignoring request ');
return false; return false;
} }
@@ -285,11 +289,11 @@ class CallSession extends Emitter {
switch (action) { switch (action) {
case 'startCallRecording': case 'startCallRecording':
return await this.startRecording(); return await this.startRecording();
case 'stopRecording': case 'stopCallRecording':
return await this.stopRecording(); return await this.stopRecording();
case 'pauseRecording': case 'pauseCallRecording':
return await this.pauseRecording(); return await this.pauseRecording();
case 'resumeRecording': case 'resumeCallRecording':
return await this.resumeRecording(); return await this.resumeRecording();
default: default:
throw new Error(`invalid record action ${action}`); throw new Error(`invalid record action ${action}`);
@@ -312,7 +316,10 @@ class CallSession extends Emitter {
'X-Application-Sid': this.applicationSid, 'X-Application-Sid': this.applicationSid,
} }
}); });
if (res.status === 200) return true; if (res.status === 200) {
this._recordState = RecordState.RecordingOn;
return true;
}
this.logger.info(`CallSession:startRecording - ${res.status} failure sending to ${siprecServerURL}`); this.logger.info(`CallSession:startRecording - ${res.status} failure sending to ${siprecServerURL}`);
return false; return false;
} catch (err) { } catch (err) {
@@ -331,7 +338,10 @@ class CallSession extends Emitter {
'X-Reason': 'stopCallRecording', 'X-Reason': 'stopCallRecording',
} }
}); });
if (res.status === 200) return true; if (res.status === 200) {
this._recordState = RecordState.RecordingOff;
return true;
}
this.logger.info(`CallSession:stopRecording - ${res.status} failure`); this.logger.info(`CallSession:stopRecording - ${res.status} failure`);
return false; return false;
} catch (err) { } catch (err) {
@@ -350,7 +360,10 @@ class CallSession extends Emitter {
'X-Reason': 'pauseCallRecording', 'X-Reason': 'pauseCallRecording',
} }
}); });
if (res.status === 200) return true; if (res.status === 200) {
this._recordState = RecordState.RecordingPaused;
return true;
}
this.logger.info(`CallSession:pauseRecording - ${res.status} failure`); this.logger.info(`CallSession:pauseRecording - ${res.status} failure`);
return false; return false;
} catch (err) { } catch (err) {
@@ -369,7 +382,10 @@ class CallSession extends Emitter {
'X-Reason': 'resumeCallRecording', 'X-Reason': 'resumeCallRecording',
} }
}); });
if (res.status === 200) return true; if (res.status === 200) {
this._recordState = RecordState.RecordingOn;
return true;
}
this.logger.info(`CallSession:resumeRecording - ${res.status} failure`); this.logger.info(`CallSession:resumeRecording - ${res.status} failure`);
return false; return false;
} catch (err) { } catch (err) {