From b4ae55894a7f02169e6d444542a049e738a7a51c Mon Sep 17 00:00:00 2001 From: JelianRadoev Date: Wed, 24 Jun 2020 10:23:42 +0300 Subject: [PATCH 1/2] NY-10777 Raise recording unsupported event, NY-10771 call recording not saved on call escalation bug --- src/EventTypes.js | 1 + src/call/CallRecorder.js | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/EventTypes.js b/src/EventTypes.js index 95bd01f..ae94f1d 100644 --- a/src/EventTypes.js +++ b/src/EventTypes.js @@ -67,6 +67,7 @@ const EventTypes = { // { roomId, ownerId, subject, startTime } EVENT_CALL_ROOM_INFO: 'call-room-info', EVENT_CALL_RECORDING_SAVED: 'call-recording-saved-event', + EVENT_CALL_RECORDING_UNSUPPORTED: 'call-recording-unsupported-event', // Calling events END // Message Events START diff --git a/src/call/CallRecorder.js b/src/call/CallRecorder.js index 57de460..16d32d4 100644 --- a/src/call/CallRecorder.js +++ b/src/call/CallRecorder.js @@ -144,9 +144,14 @@ class CallRecorder { getRecordingOptions = () => { // TODO: Change this when video recording is being implemented let options = { mimeType: RECORDING_MIME_TYPES.audioClean }; - if (!MediaRecorder.isTypeSupported(options.mimeType)) { - console.error('[CALL-RECORDING-UNSUPPORTED-MIME]', `${options.mimeType} is not supported`); - return; + + try { + if (!MediaRecorder.isTypeSupported(options.mimeType)) { + console.error('[CALL-RECORDING-UNSUPPORTED-MIME]', `${options.mimeType} is not supported`); + return; + } + } catch (e) { + retrun; } return options; @@ -175,6 +180,7 @@ class CallRecorder { * @returns {void} */ handleRecordingChunksEvent = (event) => { + const recState = this.getRecordingState(); if (event.data.size > 0) { this._indexDBManager .getItem(this._callId) @@ -186,7 +192,11 @@ class CallRecorder { chunks.push(event.data); this._indexDBManager .storeItem(this._callId, chunks) - .then(() => { }) + .then(() => { + if (recState === RECORDING_STATES.inactive || recState === RECORDING_STATES.paused) { + this.handleRecordingStopEvent(); + } + }) .catch(err => { console.log('[CALL-RECORDING-SAVE-FILE-INDEXDB-ERROR]', err); }); @@ -196,6 +206,9 @@ class CallRecorder { }); } else { console.log('[CALL-RECORDING-CHUNKS-EMPTY]', event); + if (recState === RECORDING_STATES.inactive || recState === RECORDING_STATES.paused) { + this.handleRecordingStopEvent(); + } } } @@ -227,7 +240,7 @@ class CallRecorder { initEventHandlers = () => { if (this.mediaRecorder) { this.mediaRecorder.ondataavailable = this.handleRecordingChunksEvent; - this.mediaRecorder.onstop = this.handleRecordingStopEvent; + //this.mediaRecorder.onstop = this.handleRecordingStopEvent; this.mediaRecorder.onerror = this.handleRecordingErrorEvent; } } @@ -252,6 +265,8 @@ class CallRecorder { } else { console.log('[CALL-RECORDING-ERROR]', 'No streams with tracks are added to record!'); } + } else { + this._facade.notify(EventTypes.EVENT_CALL_RECORDING_UNSUPPORTED); } } -- GitLab From 1a8a5fe53374654daaf072791df6539c90ab4677 Mon Sep 17 00:00:00 2001 From: JelianRadoev Date: Wed, 24 Jun 2020 11:30:36 +0300 Subject: [PATCH 2/2] NY-10777 Fix audiocontext crash on safari --- src/call/CallRecorder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/call/CallRecorder.js b/src/call/CallRecorder.js index 16d32d4..e161c31 100644 --- a/src/call/CallRecorder.js +++ b/src/call/CallRecorder.js @@ -85,7 +85,7 @@ class CallRecorder { * @returns {void} */ initAudioContext = () => { - this._audioContext = new AudioContext(); + this._audioContext = new (window.AudioContext || window.webkitAudioContext)(); this._destination = this.audioContext.createMediaStreamDestination(); } -- GitLab