From 34f2bd9d6cdbe56c9e549f668641e0894a15ab42 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 23 Jun 2022 16:18:30 -0400 Subject: [PATCH] fixes from testing pause/resume recording --- lib/session/call-session.js | 38 ++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index e3b28da7..d4ed03c2 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -264,19 +264,23 @@ class CallSession extends Emitter { /* check validity of request */ 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; } 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; } 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; } 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; } @@ -285,11 +289,11 @@ class CallSession extends Emitter { switch (action) { case 'startCallRecording': return await this.startRecording(); - case 'stopRecording': + case 'stopCallRecording': return await this.stopRecording(); - case 'pauseRecording': + case 'pauseCallRecording': return await this.pauseRecording(); - case 'resumeRecording': + case 'resumeCallRecording': return await this.resumeRecording(); default: throw new Error(`invalid record action ${action}`); @@ -312,7 +316,10 @@ class CallSession extends Emitter { '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}`); return false; } catch (err) { @@ -331,7 +338,10 @@ class CallSession extends Emitter { '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`); return false; } catch (err) { @@ -350,7 +360,10 @@ class CallSession extends Emitter { '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`); return false; } catch (err) { @@ -369,7 +382,10 @@ class CallSession extends Emitter { '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`); return false; } catch (err) {