augnitorecorder
Advanced tools
Comparing version 1.0.18 to 1.0.19
@@ -419,4 +419,5 @@ function _regeneratorRuntime() { | ||
var arg8 = this.enableLogs; | ||
var arg9 = this.heavyOp; | ||
var workerScript = "\n (() => {\n (".concat(WorkerBlob.toString(), ")(").concat(JSON.stringify(arg1), ", ").concat(JSON.stringify(arg2), ", ").concat(JSON.stringify(arg3), ", ").concat(JSON.stringify(arg4), ", ").concat(JSON.stringify(arg5), ", ").concat(JSON.stringify(arg6), ", ").concat(JSON.stringify(arg7), ", ").concat(JSON.stringify(arg8), ", ").concat(JSON.stringify(arg9), ");\n })();\n"); | ||
var arg9 = this.shouldSendAudioDataSequence; | ||
var arg10 = this.heavyOp; | ||
var workerScript = "\n (() => {\n (".concat(WorkerBlob.toString(), ")(").concat(JSON.stringify(arg1), ", ").concat(JSON.stringify(arg2), ", ").concat(JSON.stringify(arg3), ", ").concat(JSON.stringify(arg4), ", ").concat(JSON.stringify(arg5), ", ").concat(JSON.stringify(arg6), ", ").concat(JSON.stringify(arg7), ", ").concat(JSON.stringify(arg8), ", ").concat(JSON.stringify(arg9), ", ").concat(JSON.stringify(arg10), ");\n })();\n"); | ||
this.worker = new Worker(URL.createObjectURL(new Blob([workerScript], { | ||
@@ -526,3 +527,3 @@ type: "application/javascript" | ||
}(); | ||
function WorkerBlob(doneMessage, eosMessage, connectionRetryTimeout, socketTimeoutInterval, healthcheckInterval, consumeInterval, wsUrl, enableLogs, heavyOp) { | ||
function WorkerBlob(doneMessage, eosMessage, connectionRetryTimeout, socketTimeoutInterval, healthcheckInterval, consumeInterval, wsUrl, enableLogs, shouldSendAudioDataSequence, heavyOp) { | ||
var lastConnect; | ||
@@ -532,2 +533,3 @@ var lastDataSent; | ||
var queue = []; | ||
var sentPacketsQueue = []; | ||
var ws; | ||
@@ -537,2 +539,4 @@ var isDone = false; | ||
var healthCheck; | ||
var retrySentPacket = false; | ||
var packetId = 0; | ||
function initConnect() { | ||
@@ -545,2 +549,6 @@ lastConnect = +new Date(); | ||
} | ||
if (sentPacketsQueue.length > 0) { | ||
console.log("resend packet queue is filled"); | ||
retrySentPacket = true; | ||
} | ||
}; | ||
@@ -635,2 +643,5 @@ ws.onmessage = function (message) { | ||
} else if (data.Type == "ACK") { | ||
sentPacketsQueue = sentPacketsQueue.filter(function (x) { | ||
return x.packetNumber !== data.Index; | ||
}); | ||
self.postMessage({ | ||
@@ -664,9 +675,27 @@ type: "other", | ||
consumer = setInterval(function () { | ||
while (queue.length > 0) { | ||
var data = queue.shift(); | ||
var isSent = send(data); | ||
if (!isSent) { | ||
queue.unshift(data); | ||
break; | ||
if (retrySentPacket) { | ||
for (var i = 0; i < sentPacketsQueue.length - 1; i++) { | ||
console.log("resend packet with id: ", sentPacketsQueue[i].packetNumber); | ||
var retryPacket = sentPacketsQueue[i].packetData; | ||
send(retryPacket); | ||
} | ||
retrySentPacket = false; | ||
} else { | ||
while (queue.length > 0) { | ||
var data = queue.shift(); | ||
var isSent = send(data); | ||
if (!isSent) { | ||
queue.unshift(data); | ||
break; | ||
} | ||
if (shouldSendAudioDataSequence) { | ||
var view = new DataView(data); | ||
packetId = Number(view.getBigInt64(4)); | ||
var sentPacket = { | ||
packetNumber: packetId, | ||
packetData: data | ||
}; | ||
sentPacketsQueue.push(sentPacket); | ||
} | ||
} | ||
} | ||
@@ -1123,6 +1152,11 @@ }, consumeInterval); | ||
return _createClass(AugnitoRecorder, [{ | ||
key: "initialiseStreamer", | ||
value: function initialiseStreamer() { | ||
this.streamer = new Streamer(this.WebsocketURL, this.enableLogs, this.isDebug, this.bufferInterval, this.eosMessage, this.socketTimeoutInterval, this.shouldSendAudioDataSequence, this.heavyOp, this.onFinalResultCallback.bind(this), this.onPartialResultCallback.bind(this), this.onErrorCallback.bind(this), this.onStateChangedCallback.bind(this), this.onSessionEventCallback.bind(this), this.onOtherResultCallback.bind(this)); | ||
} | ||
}, { | ||
key: "togglePauseResumeAudioStream", | ||
value: function togglePauseResumeAudioStream() { | ||
if (!this.streamer) { | ||
this.startAudio(); | ||
this.initialiseStreamer(); | ||
} else { | ||
@@ -1140,3 +1174,3 @@ if (this.streamer.IsPaused) { | ||
if (!this.streamer) { | ||
this.startAudio(); | ||
this.initialiseStreamer(); | ||
} else { | ||
@@ -1149,3 +1183,5 @@ this.stopAudio(); | ||
value: function startAudio() { | ||
this.streamer = new Streamer(this.WebsocketURL, this.enableLogs, this.isDebug, this.bufferInterval, this.eosMessage, this.socketTimeoutInterval, this.shouldSendAudioDataSequence, this.heavyOp, this.onFinalResultCallback.bind(this), this.onPartialResultCallback.bind(this), this.onErrorCallback.bind(this), this.onStateChangedCallback.bind(this), this.onSessionEventCallback.bind(this), this.onOtherResultCallback.bind(this)); | ||
if (!this.streamer) { | ||
this.initialiseStreamer(); | ||
} | ||
this.streamer.StartStream(); | ||
@@ -1194,2 +1230,6 @@ this.log("Stream Started..."); | ||
value: function onSessionEventCallback(data) { | ||
var meta = JSON.parse(data); | ||
if (meta.Event.Type === "SESSION_CREATED") { | ||
this.startAudio(); | ||
} | ||
if (this.onSessionEvent) { | ||
@@ -1196,0 +1236,0 @@ this.onSessionEvent(data); |
{ | ||
"name": "augnitorecorder", | ||
"version": "1.0.18", | ||
"version": "1.0.19", | ||
"description": "Audio recorder and streamer compatible with any browser", | ||
@@ -5,0 +5,0 @@ "main": "dist/augnitoRecorder.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124276
1388