easyproctor-hml 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/esm/index.js +187 -108
- package/index.js +187 -108
- package/interfaces/ParamsConfig.d.ts +3 -6
- package/new-flow/proctoring/ProctoringSession.d.ts +1 -0
- package/new-flow/recorders/AlertRecorder.d.ts +5 -1
- package/new-flow/recorders/CameraRecorder.d.ts +1 -1
- package/new-flow/recorders/NoiseRecorder.d.ts +3 -0
- package/new-flow/recorders/ScreenRecorder.d.ts +8 -5
- package/package.json +1 -1
- package/plugins/recorder.d.ts +2 -1
- package/proctoring/options/ProctoringOptions.d.ts +1 -5
- package/unpkg/easyproctor.min.js +31 -31
package/index.js
CHANGED
|
@@ -30792,14 +30792,13 @@ var getDefaultProctoringOptions = {
|
|
|
30792
30792
|
captureScreen: true,
|
|
30793
30793
|
noiseLimit: 40,
|
|
30794
30794
|
// deprecated
|
|
30795
|
-
proctoringType: "
|
|
30795
|
+
proctoringType: "VIDEO",
|
|
30796
30796
|
insights: "",
|
|
30797
30797
|
onBufferSizeError: false,
|
|
30798
30798
|
useGeolocation: false,
|
|
30799
30799
|
useSpyScan: false,
|
|
30800
30800
|
useExternalCamera: false,
|
|
30801
30801
|
useChallenge: false,
|
|
30802
|
-
screenRecorderOptions: { width: 1280, height: 720 },
|
|
30803
30802
|
auto: false
|
|
30804
30803
|
};
|
|
30805
30804
|
|
|
@@ -30868,7 +30867,7 @@ var proctoringId;
|
|
|
30868
30867
|
function setRecorderProctoringId(id) {
|
|
30869
30868
|
proctoringId = id;
|
|
30870
30869
|
}
|
|
30871
|
-
function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorCallback,
|
|
30870
|
+
function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorCallback, recorderOpts) {
|
|
30872
30871
|
let resolvePromise;
|
|
30873
30872
|
let onBufferSizeInterval;
|
|
30874
30873
|
let lastEvent;
|
|
@@ -30880,9 +30879,11 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
|
|
|
30880
30879
|
let recorderOptions = {
|
|
30881
30880
|
// eslint-disable-next-line no-useless-escape
|
|
30882
30881
|
mimeType: "video/webm",
|
|
30883
|
-
videoBitsPerSecond:
|
|
30882
|
+
videoBitsPerSecond: 25e4 * ((recorderOpts == null ? void 0 : recorderOpts.quality) || 1),
|
|
30883
|
+
// 250Kbps por padrão
|
|
30884
30884
|
audioBitsPerSecond: 64 * 1e3
|
|
30885
30885
|
};
|
|
30886
|
+
console.log("recorderOptions", recorderOptions);
|
|
30886
30887
|
if (MediaRecorder.isTypeSupported("video/webm;codecs=vp9")) {
|
|
30887
30888
|
recorderOptions.mimeType = "video/webm;codecs=vp9";
|
|
30888
30889
|
} else {
|
|
@@ -30890,12 +30891,6 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
|
|
|
30890
30891
|
"vp9 codec not supported. Using default mimeType without vp9."
|
|
30891
30892
|
);
|
|
30892
30893
|
}
|
|
30893
|
-
if (audio) {
|
|
30894
|
-
recorderOptions = {
|
|
30895
|
-
mimeType: "audio/webm",
|
|
30896
|
-
audioBitsPerSecond: 64 * 1e3
|
|
30897
|
-
};
|
|
30898
|
-
}
|
|
30899
30894
|
function buildMediaRecorder(stream5, recorderOptions2) {
|
|
30900
30895
|
const tracks = stream5.getTracks();
|
|
30901
30896
|
if (tracks.length == 0) {
|
|
@@ -30966,7 +30961,7 @@ function recorder(stream4, buffer, onBufferSizeError = false, onBufferSizeErrorC
|
|
|
30966
30961
|
console.error("Timeout ao iniciar o recorder");
|
|
30967
30962
|
reject(new Error("Timeout ao iniciar o recorder"));
|
|
30968
30963
|
}
|
|
30969
|
-
},
|
|
30964
|
+
}, 5e3);
|
|
30970
30965
|
});
|
|
30971
30966
|
}
|
|
30972
30967
|
async function startRecording() {
|
|
@@ -31988,29 +31983,20 @@ var _CameraRecorder = class _CameraRecorder {
|
|
|
31988
31983
|
recordingBitrate: 128,
|
|
31989
31984
|
noiseLimit: 40
|
|
31990
31985
|
},
|
|
31991
|
-
imageBehaviourParameters: {
|
|
31992
|
-
useUploadImage: true,
|
|
31993
|
-
uploadInterval: 20,
|
|
31994
|
-
saveVideo: true
|
|
31995
|
-
},
|
|
31996
31986
|
videoBehaviourParameters: {
|
|
31997
31987
|
detectPerson: false,
|
|
31998
31988
|
detectFace: false,
|
|
31999
|
-
detectCellPhone: false
|
|
31989
|
+
detectCellPhone: false,
|
|
31990
|
+
cameraVideoQuality: 1
|
|
32000
31991
|
}
|
|
32001
31992
|
};
|
|
32002
|
-
// private imageParams: ImageParameters = {
|
|
32003
|
-
// useUploadImage: true,
|
|
32004
|
-
// uploadInterval: 20,
|
|
32005
|
-
// saveVideo: true
|
|
32006
|
-
// };
|
|
32007
31993
|
this.options = {
|
|
32008
31994
|
cameraId: void 0,
|
|
32009
31995
|
microphoneId: void 0,
|
|
32010
31996
|
onBufferSizeError: false,
|
|
32011
31997
|
onBufferSizeErrorCallback: (cameraStream) => {
|
|
32012
31998
|
},
|
|
32013
|
-
proctoringType: "
|
|
31999
|
+
proctoringType: "VIDEO",
|
|
32014
32000
|
onChangeDevicesCallback: (devices) => {
|
|
32015
32001
|
},
|
|
32016
32002
|
onRealtimeAlertsCallback: (response) => {
|
|
@@ -32317,14 +32303,15 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
32317
32303
|
await new Promise((r3) => setTimeout(r3, 300));
|
|
32318
32304
|
}
|
|
32319
32305
|
async startRecording() {
|
|
32320
|
-
var _a2, _b, _c2, _d, _e3, _f, _g, _h;
|
|
32306
|
+
var _a2, _b, _c2, _d, _e3, _f, _g, _h, _i3;
|
|
32321
32307
|
await this.startStream();
|
|
32322
32308
|
await this.attachAndWarmup(this.cameraStream);
|
|
32323
32309
|
const recorderOpts = this.isChunkEnabled ? {
|
|
32324
32310
|
timeslice: _CameraRecorder.CHUNK_TIMESLICE_MS,
|
|
32325
32311
|
onChunkAvailable: (blob, idx) => {
|
|
32326
32312
|
this.handleNewChunk(blob, idx);
|
|
32327
|
-
}
|
|
32313
|
+
},
|
|
32314
|
+
quality: (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.cameraVideoQuality
|
|
32328
32315
|
} : {};
|
|
32329
32316
|
const {
|
|
32330
32317
|
startRecording,
|
|
@@ -32341,7 +32328,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
32341
32328
|
this.blobs,
|
|
32342
32329
|
this.options.onBufferSizeError,
|
|
32343
32330
|
(e3) => this.bufferError(e3),
|
|
32344
|
-
false,
|
|
32345
32331
|
recorderOpts
|
|
32346
32332
|
);
|
|
32347
32333
|
this.recordingStart = startRecording;
|
|
@@ -32354,7 +32340,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
32354
32340
|
this.getDuration = getDuration;
|
|
32355
32341
|
this.chunkIndex = 0;
|
|
32356
32342
|
if (this.isChunkEnabled) {
|
|
32357
|
-
(
|
|
32343
|
+
(_b = this.backgroundUpload) == null ? void 0 : _b.start();
|
|
32358
32344
|
this.setupLifecycleListeners();
|
|
32359
32345
|
}
|
|
32360
32346
|
try {
|
|
@@ -32363,7 +32349,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
32363
32349
|
} catch (error) {
|
|
32364
32350
|
console.log("Camera Recorder error", error);
|
|
32365
32351
|
this.stopRecording();
|
|
32366
|
-
const maxRetries = ((
|
|
32352
|
+
const maxRetries = ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.maxRetries) || 3;
|
|
32367
32353
|
if (this.currentRetries < maxRetries) {
|
|
32368
32354
|
console.log("Camera Recorder retry", this.currentRetries);
|
|
32369
32355
|
this.currentRetries++;
|
|
@@ -32373,13 +32359,13 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
32373
32359
|
}
|
|
32374
32360
|
}
|
|
32375
32361
|
this.stopped = false;
|
|
32376
|
-
if (((
|
|
32362
|
+
if (((_d = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _d.detectPerson) || ((_e3 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _e3.detectCellPhone) || ((_f = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _f.detectFace)) {
|
|
32377
32363
|
await this.initializeDetectors();
|
|
32378
32364
|
}
|
|
32379
|
-
if ((
|
|
32365
|
+
if ((_g = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _g.detectFace) {
|
|
32380
32366
|
await this.faceDetection.enableCam(this.cameraStream);
|
|
32381
32367
|
}
|
|
32382
|
-
if (((
|
|
32368
|
+
if (((_h = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _h.detectPerson) || ((_i3 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _i3.detectCellPhone)) {
|
|
32383
32369
|
await this.objectDetection.enableCam(this.cameraStream);
|
|
32384
32370
|
}
|
|
32385
32371
|
this.filesToUpload = [];
|
|
@@ -32614,7 +32600,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
32614
32600
|
window.URL.revokeObjectURL(url2);
|
|
32615
32601
|
}
|
|
32616
32602
|
async saveOnSession(session) {
|
|
32617
|
-
var _a2
|
|
32603
|
+
var _a2;
|
|
32618
32604
|
if (this.blobs != null)
|
|
32619
32605
|
trackers.registerSaveOnSession(
|
|
32620
32606
|
this.proctoringId,
|
|
@@ -32622,37 +32608,40 @@ Setting: ${JSON.stringify(settings, null, 2)}`
|
|
|
32622
32608
|
);
|
|
32623
32609
|
const settings = this.cameraStream.getVideoTracks()[0].getSettings();
|
|
32624
32610
|
const settingsAudio = this.cameraStream.getAudioTracks()[0].getSettings();
|
|
32625
|
-
|
|
32626
|
-
|
|
32627
|
-
if (this.
|
|
32628
|
-
|
|
32629
|
-
|
|
32630
|
-
|
|
32631
|
-
|
|
32632
|
-
|
|
32633
|
-
|
|
32634
|
-
|
|
32635
|
-
|
|
32636
|
-
|
|
32637
|
-
|
|
32638
|
-
|
|
32639
|
-
|
|
32640
|
-
|
|
32611
|
+
let isUploaded = false;
|
|
32612
|
+
if (this.isChunkEnabled) {
|
|
32613
|
+
if (this.backend && this.backendToken && this.proctoringId) {
|
|
32614
|
+
const fileName = `EP_${this.proctoringId}_camera_0.webm`;
|
|
32615
|
+
const objectName = `${this.proctoringId}/${fileName}`;
|
|
32616
|
+
isUploaded = await this.backend.checkUpload(this.backendToken, objectName, "video/webm");
|
|
32617
|
+
this.chunkStorage && await this.chunkStorage.clearAllChunks(session.id);
|
|
32618
|
+
}
|
|
32619
|
+
}
|
|
32620
|
+
if (!isUploaded) {
|
|
32621
|
+
const rawBlob = new Blob(this.blobs, {
|
|
32622
|
+
type: ((_a2 = this.recorderOptions) == null ? void 0 : _a2.mimeType) || "video/webm"
|
|
32623
|
+
});
|
|
32624
|
+
let finalBlob = rawBlob;
|
|
32625
|
+
if (typeof fixWebmDuration === "function") {
|
|
32626
|
+
try {
|
|
32641
32627
|
finalBlob = await fixWebmDuration(rawBlob, this.duration);
|
|
32642
|
-
}
|
|
32643
|
-
console.warn("
|
|
32628
|
+
} catch (e3) {
|
|
32629
|
+
console.warn("Erro ao corrigir a dura\xE7\xE3o do v\xEDdeo", e3);
|
|
32630
|
+
finalBlob = rawBlob;
|
|
32644
32631
|
}
|
|
32645
|
-
|
|
32646
|
-
|
|
32632
|
+
} else {
|
|
32633
|
+
console.warn("fixWebmDuration n\xE3o dispon\xEDvel");
|
|
32634
|
+
}
|
|
32635
|
+
session.addRecording({
|
|
32636
|
+
device: `Audio
|
|
32647
32637
|
Sample Rate: ${settingsAudio.sampleRate}
|
|
32648
32638
|
Sample Size: ${settingsAudio.sampleSize}
|
|
32649
32639
|
|
|
32650
32640
|
Video:
|
|
32651
32641
|
${JSON.stringify(this.recorderOptions)}`,
|
|
32652
|
-
|
|
32653
|
-
|
|
32654
|
-
|
|
32655
|
-
}
|
|
32642
|
+
arrayBuffer: await finalBlob.arrayBuffer(),
|
|
32643
|
+
origin: "Camera" /* Camera */
|
|
32644
|
+
});
|
|
32656
32645
|
}
|
|
32657
32646
|
}
|
|
32658
32647
|
async getFile(file, name, type) {
|
|
@@ -34837,7 +34826,7 @@ Error: ${e3.message}
|
|
|
34837
34826
|
|
|
34838
34827
|
// src/new-flow/recorders/AlertRecorder.ts
|
|
34839
34828
|
var AlertRecorder = class {
|
|
34840
|
-
constructor(options, optionsProctoring) {
|
|
34829
|
+
constructor(options, optionsProctoring, screenRecorder) {
|
|
34841
34830
|
this.alerts = [];
|
|
34842
34831
|
// Variáveis para controle de inatividade
|
|
34843
34832
|
this.lastActivityTime = Date.now();
|
|
@@ -34853,29 +34842,21 @@ var AlertRecorder = class {
|
|
|
34853
34842
|
this.handleLostFocus();
|
|
34854
34843
|
}
|
|
34855
34844
|
};
|
|
34845
|
+
this.isFocused = true;
|
|
34856
34846
|
this.handleLostFocus = () => {
|
|
34847
|
+
if (this.screenRecorder && !this.screenRecorder.isRecording) {
|
|
34848
|
+
return;
|
|
34849
|
+
}
|
|
34857
34850
|
if (this.getRelativeTime() > 1e4) {
|
|
34858
|
-
|
|
34859
|
-
begin: this.getRelativeTime(),
|
|
34860
|
-
end: 0,
|
|
34861
|
-
alert: 25 /* FocusOff */,
|
|
34862
|
-
type: 3 /* Screen */
|
|
34863
|
-
};
|
|
34864
|
-
this.onLostFocusCallback(alertPayload);
|
|
34865
|
-
this.alerts.push(alertPayload);
|
|
34851
|
+
this.setFocus(false);
|
|
34866
34852
|
}
|
|
34867
34853
|
};
|
|
34868
34854
|
this.handleReturnFocus = () => {
|
|
34869
|
-
|
|
34870
|
-
|
|
34871
|
-
this.onFocusCallback({
|
|
34872
|
-
begin: lastAlert.begin,
|
|
34873
|
-
end: this.getRelativeTime(),
|
|
34874
|
-
alert: 25 /* FocusOff */,
|
|
34875
|
-
type: 3 /* Screen */
|
|
34876
|
-
});
|
|
34877
|
-
lastAlert.end = this.getRelativeTime();
|
|
34855
|
+
if (this.screenRecorder && !this.screenRecorder.isRecording) {
|
|
34856
|
+
return;
|
|
34878
34857
|
}
|
|
34858
|
+
if (this.alerts.length === 0) return;
|
|
34859
|
+
this.setFocus(true);
|
|
34879
34860
|
};
|
|
34880
34861
|
// 2. SPLIT SCREEN DETECTION
|
|
34881
34862
|
this.handleResize = () => {
|
|
@@ -34934,6 +34915,7 @@ var AlertRecorder = class {
|
|
|
34934
34915
|
this.onFocusCallback = options.onFocusCallback;
|
|
34935
34916
|
this.onRealtimeAlertCallback = options.onRealtimeAlertCallback;
|
|
34936
34917
|
this.optionsProctoring = optionsProctoring;
|
|
34918
|
+
this.screenRecorder = screenRecorder;
|
|
34937
34919
|
}
|
|
34938
34920
|
async startRecording() {
|
|
34939
34921
|
this.startTime = new Date(Date.now());
|
|
@@ -34960,6 +34942,8 @@ var AlertRecorder = class {
|
|
|
34960
34942
|
attachListeners() {
|
|
34961
34943
|
if (this.optionsProctoring.captureScreen) {
|
|
34962
34944
|
window.addEventListener("visibilitychange", this.handleVisibilityChange);
|
|
34945
|
+
window.addEventListener("blur", this.handleLostFocus);
|
|
34946
|
+
window.addEventListener("focus", this.handleReturnFocus);
|
|
34963
34947
|
window.addEventListener("resize", this.handleResize);
|
|
34964
34948
|
window.document.addEventListener("copy", this.handleCopy);
|
|
34965
34949
|
window.document.addEventListener("cut", this.handleCut);
|
|
@@ -34968,11 +34952,40 @@ var AlertRecorder = class {
|
|
|
34968
34952
|
}
|
|
34969
34953
|
detachListeners() {
|
|
34970
34954
|
window.removeEventListener("visibilitychange", this.handleVisibilityChange);
|
|
34955
|
+
window.removeEventListener("blur", this.handleLostFocus);
|
|
34956
|
+
window.removeEventListener("focus", this.handleReturnFocus);
|
|
34971
34957
|
window.removeEventListener("resize", this.handleResize);
|
|
34972
34958
|
window.document.removeEventListener("copy", this.handleCopy);
|
|
34973
34959
|
window.document.removeEventListener("cut", this.handleCut);
|
|
34974
34960
|
window.document.removeEventListener("paste", this.handlePaste);
|
|
34975
34961
|
}
|
|
34962
|
+
setFocus(focused) {
|
|
34963
|
+
if (this.isFocused === focused) {
|
|
34964
|
+
return;
|
|
34965
|
+
}
|
|
34966
|
+
this.isFocused = focused;
|
|
34967
|
+
if (focused) {
|
|
34968
|
+
const lastAlert = this.alerts[this.alerts.length - 1];
|
|
34969
|
+
if (lastAlert) {
|
|
34970
|
+
this.onFocusCallback({
|
|
34971
|
+
begin: lastAlert.begin,
|
|
34972
|
+
end: this.getRelativeTime(),
|
|
34973
|
+
alert: 25 /* FocusOff */,
|
|
34974
|
+
type: 3 /* Screen */
|
|
34975
|
+
});
|
|
34976
|
+
lastAlert.end = this.getRelativeTime();
|
|
34977
|
+
}
|
|
34978
|
+
} else {
|
|
34979
|
+
const alertPayload = {
|
|
34980
|
+
begin: this.getRelativeTime(),
|
|
34981
|
+
end: 0,
|
|
34982
|
+
alert: 25 /* FocusOff */,
|
|
34983
|
+
type: 3 /* Screen */
|
|
34984
|
+
};
|
|
34985
|
+
this.onLostFocusCallback(alertPayload);
|
|
34986
|
+
this.alerts.push(alertPayload);
|
|
34987
|
+
}
|
|
34988
|
+
}
|
|
34976
34989
|
// private startIdleChecker() {
|
|
34977
34990
|
// this.stopIdleChecker(); // Garante que não tenha duplicação
|
|
34978
34991
|
// this.idleCheckInterval = setInterval(() => {
|
|
@@ -35013,7 +35026,11 @@ var AlertRecorder = class {
|
|
|
35013
35026
|
// HELPERS
|
|
35014
35027
|
// ==========================================
|
|
35015
35028
|
getRelativeTime() {
|
|
35016
|
-
|
|
35029
|
+
var _a2;
|
|
35030
|
+
if (this.screenRecorder) {
|
|
35031
|
+
return Date.now() - (((_a2 = this.screenRecorder.getStartTime()) == null ? void 0 : _a2.getTime()) || 0);
|
|
35032
|
+
}
|
|
35033
|
+
return Date.now() - (this.startTime.getTime() || 0);
|
|
35017
35034
|
}
|
|
35018
35035
|
createAlert(category, type, description) {
|
|
35019
35036
|
this.alerts.push({
|
|
@@ -37287,7 +37304,12 @@ var NoiseRecorder = class {
|
|
|
37287
37304
|
this.MAX_PRE_ROLL_CHUNKS = 4;
|
|
37288
37305
|
this.lastNoiseTime = 0;
|
|
37289
37306
|
this.SILENCE_THRESHOLD = 3e3;
|
|
37307
|
+
this.MAX_RECORD_DURATION = 3e4;
|
|
37308
|
+
// 30 segundos
|
|
37290
37309
|
this.filesToUpload = [];
|
|
37310
|
+
// logica do mute
|
|
37311
|
+
this.acumulatedMuteTime = 0;
|
|
37312
|
+
this.startMuteTime = 0;
|
|
37291
37313
|
this.optionsProctoring = optionsProctoring;
|
|
37292
37314
|
this.proctoringSession = proctoringSession;
|
|
37293
37315
|
this.paramsConfig = paramsConfig;
|
|
@@ -37322,7 +37344,7 @@ var NoiseRecorder = class {
|
|
|
37322
37344
|
async saveOnSession(session) {
|
|
37323
37345
|
}
|
|
37324
37346
|
async onNoiseDetectedRecord() {
|
|
37325
|
-
var _a2, _b, _c2, _d, _e3, _f, _g, _h, _i3;
|
|
37347
|
+
var _a2, _b, _c2, _d, _e3, _f, _g, _h, _i3, _j, _k, _l;
|
|
37326
37348
|
if (!this.volumeMeter && this.cameraRecorder.cameraStream) {
|
|
37327
37349
|
this.volumeMeter = new VolumeMeter(this.cameraRecorder.cameraStream);
|
|
37328
37350
|
this.volumeMeter.start().catch((e3) => {
|
|
@@ -37332,6 +37354,25 @@ var NoiseRecorder = class {
|
|
|
37332
37354
|
}
|
|
37333
37355
|
let noiseLimit = ((_a2 = this.paramsConfig.audioBehaviourParameters) == null ? void 0 : _a2.noiseLimit) || 40;
|
|
37334
37356
|
const currentVolume = ((_b = this.volumeMeter) == null ? void 0 : _b.getVolume()) || 0;
|
|
37357
|
+
if (this.optionsProctoring.proctoringType == "REALTIME") {
|
|
37358
|
+
let muteThreshold = ((_c2 = this.paramsConfig.audioBehaviourParameters) == null ? void 0 : _c2.muteThreshold) || 60;
|
|
37359
|
+
if (currentVolume == 0) {
|
|
37360
|
+
if (this.acumulatedMuteTime == 0) this.startMuteTime = Date.now() - (((_d = this.cameraRecorder.getStartTime()) == null ? void 0 : _d.getTime()) || 0);
|
|
37361
|
+
this.acumulatedMuteTime = this.acumulatedMuteTime + 200;
|
|
37362
|
+
} else
|
|
37363
|
+
this.acumulatedMuteTime = 0;
|
|
37364
|
+
if (this.acumulatedMuteTime / 1e3 >= muteThreshold) {
|
|
37365
|
+
this.acumulatedMuteTime = 0;
|
|
37366
|
+
this.onRealtimeAlertsCallback({
|
|
37367
|
+
begin: this.startMuteTime,
|
|
37368
|
+
end: Date.now() - (((_e3 = this.cameraRecorder.getStartTime()) == null ? void 0 : _e3.getTime()) || 0),
|
|
37369
|
+
status: "ALERT",
|
|
37370
|
+
description: "Microfone mutado",
|
|
37371
|
+
type: "audio_muted_on_stream",
|
|
37372
|
+
category: "audio_muted_on_stream"
|
|
37373
|
+
});
|
|
37374
|
+
}
|
|
37375
|
+
}
|
|
37335
37376
|
this.isSpeech = this.isSpeech || this.hasDesiredResult(this.audioClassificationResult);
|
|
37336
37377
|
if (!this.isSpeech && !this.recordingInProgress)
|
|
37337
37378
|
noiseLimit = noiseLimit * 1.25;
|
|
@@ -37344,27 +37385,28 @@ var NoiseRecorder = class {
|
|
|
37344
37385
|
this.recordingChunks = [...this.preRollBuffer];
|
|
37345
37386
|
const totalSamplesInBuffer = this.preRollBuffer.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
37346
37387
|
const bufferDurationMs = totalSamplesInBuffer / this.SAMPLE_RATE * 1e3;
|
|
37347
|
-
const triggerTime = Date.now() - (((
|
|
37388
|
+
const triggerTime = Date.now() - (((_f = this.cameraRecorder.getStartTime()) == null ? void 0 : _f.getTime()) || 0);
|
|
37348
37389
|
this.recordingStartTime = triggerTime - bufferDurationMs;
|
|
37349
37390
|
if (this.recordingStartTime < 0) this.recordingStartTime = 0;
|
|
37350
37391
|
} else if (this.recordingInProgress) {
|
|
37351
37392
|
const silenceDuration = Date.now() - this.lastNoiseTime;
|
|
37352
37393
|
const currentRecordDuration = Date.now() - this.recordingStartTime;
|
|
37353
|
-
|
|
37394
|
+
const isMaxDurationReached = currentRecordDuration >= this.MAX_RECORD_DURATION;
|
|
37395
|
+
if (silenceDuration >= this.SILENCE_THRESHOLD && currentRecordDuration >= 3e3 && this.countLoopTimes > 4 || isMaxDurationReached) {
|
|
37354
37396
|
await this.stopSoundRecord();
|
|
37355
|
-
if (((
|
|
37397
|
+
if (((_g = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _g.detectNoise) && !this.isSpeech) {
|
|
37356
37398
|
this.onRealtimeAlertsCallback({
|
|
37357
|
-
begin: Date.now() - (((
|
|
37358
|
-
end: Date.now() - (((
|
|
37399
|
+
begin: Date.now() - (((_h = this.cameraRecorder.getStartTime()) == null ? void 0 : _h.getTime()) || 0),
|
|
37400
|
+
end: Date.now() - (((_i3 = this.cameraRecorder.getStartTime()) == null ? void 0 : _i3.getTime()) || 0),
|
|
37359
37401
|
status: "ALERT",
|
|
37360
37402
|
description: "Barulho detectado",
|
|
37361
37403
|
type: "audio_detection_on_stream"
|
|
37362
37404
|
});
|
|
37363
37405
|
}
|
|
37364
|
-
if (((
|
|
37406
|
+
if (((_j = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _j.detectSpeech) && this.isSpeech) {
|
|
37365
37407
|
this.onRealtimeAlertsCallback({
|
|
37366
|
-
begin: Date.now() - (((
|
|
37367
|
-
end: Date.now() - (((
|
|
37408
|
+
begin: Date.now() - (((_k = this.cameraRecorder.getStartTime()) == null ? void 0 : _k.getTime()) || 0),
|
|
37409
|
+
end: Date.now() - (((_l = this.cameraRecorder.getStartTime()) == null ? void 0 : _l.getTime()) || 0),
|
|
37368
37410
|
status: "ALERT",
|
|
37369
37411
|
description: "Fala detectada",
|
|
37370
37412
|
type: "audio_detection_on_stream"
|
|
@@ -37542,10 +37584,28 @@ registerProcessor("audio-processor", AudioProcessor);
|
|
|
37542
37584
|
var pkg2 = require_fix_webm_duration();
|
|
37543
37585
|
var fixWebmDuration2 = pkg2.default || pkg2;
|
|
37544
37586
|
var ScreenRecorder = class {
|
|
37545
|
-
constructor(options) {
|
|
37587
|
+
constructor(options, videoOptions, paramsConfig) {
|
|
37546
37588
|
this.blobs = [];
|
|
37547
37589
|
this.blobsFinal = [];
|
|
37590
|
+
this.isRecording = false;
|
|
37548
37591
|
this.duration = 0;
|
|
37592
|
+
this.videoOptions = {
|
|
37593
|
+
width: 640,
|
|
37594
|
+
height: 480,
|
|
37595
|
+
minWidth: 0,
|
|
37596
|
+
minHeight: 0
|
|
37597
|
+
};
|
|
37598
|
+
this.paramsConfig = {
|
|
37599
|
+
audioBehaviourParameters: {
|
|
37600
|
+
recordingBitrate: 128,
|
|
37601
|
+
noiseLimit: 40
|
|
37602
|
+
},
|
|
37603
|
+
videoBehaviourParameters: {
|
|
37604
|
+
screenVideoQuality: 3
|
|
37605
|
+
}
|
|
37606
|
+
};
|
|
37607
|
+
paramsConfig && (this.paramsConfig = paramsConfig);
|
|
37608
|
+
this.videoOptions = videoOptions;
|
|
37549
37609
|
this.options = options;
|
|
37550
37610
|
}
|
|
37551
37611
|
setProctoringId(proctoringId2) {
|
|
@@ -37553,15 +37613,16 @@ var ScreenRecorder = class {
|
|
|
37553
37613
|
setRecorderProctoringId(proctoringId2);
|
|
37554
37614
|
}
|
|
37555
37615
|
async startRecording() {
|
|
37556
|
-
|
|
37616
|
+
var _a2;
|
|
37557
37617
|
if (isMobileDevice()) return;
|
|
37558
37618
|
const { allowOnlyFirstMonitor, allowMultipleMonitors, onStopSharingScreenCallback, onBufferSizeErrorCallback } = this.options;
|
|
37559
37619
|
const complexConstraints = {
|
|
37560
37620
|
video: {
|
|
37561
37621
|
cursor: "always",
|
|
37562
|
-
width: this.
|
|
37563
|
-
height: this.
|
|
37564
|
-
displaySurface: "monitor"
|
|
37622
|
+
width: this.videoOptions.width,
|
|
37623
|
+
height: this.videoOptions.height,
|
|
37624
|
+
displaySurface: "monitor",
|
|
37625
|
+
frameRate: 15
|
|
37565
37626
|
},
|
|
37566
37627
|
audio: false
|
|
37567
37628
|
};
|
|
@@ -37617,10 +37678,24 @@ var ScreenRecorder = class {
|
|
|
37617
37678
|
});
|
|
37618
37679
|
throw NOT_SHARED_SCREEN;
|
|
37619
37680
|
}
|
|
37620
|
-
const {
|
|
37681
|
+
const {
|
|
37682
|
+
startRecording,
|
|
37683
|
+
stopRecording,
|
|
37684
|
+
getStartTime,
|
|
37685
|
+
getDuration
|
|
37686
|
+
} = recorder(
|
|
37687
|
+
this.screenStream,
|
|
37688
|
+
this.blobs,
|
|
37689
|
+
this.options.onBufferSizeError,
|
|
37690
|
+
onBufferSizeErrorCallback,
|
|
37691
|
+
{ quality: (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.screenVideoQuality }
|
|
37692
|
+
);
|
|
37621
37693
|
this.recordingStart = startRecording;
|
|
37622
37694
|
this.recordingStop = stopRecording;
|
|
37695
|
+
this.getStartTime = getStartTime;
|
|
37696
|
+
this.getDuration = getDuration;
|
|
37623
37697
|
this.recordingStart();
|
|
37698
|
+
this.isRecording = true;
|
|
37624
37699
|
}
|
|
37625
37700
|
async pauseRecording() {
|
|
37626
37701
|
}
|
|
@@ -37630,16 +37705,27 @@ var ScreenRecorder = class {
|
|
|
37630
37705
|
var _a2;
|
|
37631
37706
|
this.recordingStop && await this.recordingStop();
|
|
37632
37707
|
this.duration = Date.now() - ((_a2 = this.startTime) == null ? void 0 : _a2.getTime()) || 0;
|
|
37708
|
+
this.isRecording = false;
|
|
37633
37709
|
}
|
|
37634
37710
|
async saveOnSession(session) {
|
|
37635
37711
|
if (isMobileDevice()) return;
|
|
37636
37712
|
const rawBlob = new Blob(this.blobs, {
|
|
37637
37713
|
type: "video/webm"
|
|
37638
37714
|
});
|
|
37639
|
-
|
|
37715
|
+
let finalBlob = rawBlob;
|
|
37716
|
+
if (typeof fixWebmDuration2 === "function") {
|
|
37717
|
+
try {
|
|
37718
|
+
finalBlob = await fixWebmDuration2(rawBlob, this.duration);
|
|
37719
|
+
} catch (e3) {
|
|
37720
|
+
console.warn("Erro ao corrigir a dura\xE7\xE3o do v\xEDdeo", e3);
|
|
37721
|
+
finalBlob = rawBlob;
|
|
37722
|
+
}
|
|
37723
|
+
} else {
|
|
37724
|
+
console.warn("fixWebmDuration n\xE3o dispon\xEDvel");
|
|
37725
|
+
}
|
|
37640
37726
|
session.addRecording({
|
|
37641
37727
|
device: "",
|
|
37642
|
-
arrayBuffer: await
|
|
37728
|
+
arrayBuffer: await finalBlob.arrayBuffer(),
|
|
37643
37729
|
origin: "Screen" /* Screen */
|
|
37644
37730
|
});
|
|
37645
37731
|
}
|
|
@@ -38594,11 +38680,6 @@ var Proctoring = class {
|
|
|
38594
38680
|
recordingBitrate: 128,
|
|
38595
38681
|
noiseLimit: 40
|
|
38596
38682
|
},
|
|
38597
|
-
imageBehaviourParameters: {
|
|
38598
|
-
useUploadImage: true,
|
|
38599
|
-
uploadInterval: 20,
|
|
38600
|
-
saveVideo: true
|
|
38601
|
-
},
|
|
38602
38683
|
videoBehaviourParameters: {
|
|
38603
38684
|
detectFace: false,
|
|
38604
38685
|
detectPerson: false,
|
|
@@ -38606,7 +38687,9 @@ var Proctoring = class {
|
|
|
38606
38687
|
detectNoise: false,
|
|
38607
38688
|
detectSpeech: false,
|
|
38608
38689
|
realtimePackageSize: 10,
|
|
38609
|
-
realtimeCaptureInterval: 2
|
|
38690
|
+
realtimeCaptureInterval: 2,
|
|
38691
|
+
cameraVideoQuality: 1,
|
|
38692
|
+
screenVideoQuality: 4
|
|
38610
38693
|
}
|
|
38611
38694
|
};
|
|
38612
38695
|
this.proctoringId = "";
|
|
@@ -38742,6 +38825,8 @@ var Proctoring = class {
|
|
|
38742
38825
|
return 25 /* FocusOff */;
|
|
38743
38826
|
case "error_upload_package":
|
|
38744
38827
|
return 44 /* RealtimeOffline */;
|
|
38828
|
+
case "audio_muted_on_stream":
|
|
38829
|
+
return 95 /* NoAudioFound */;
|
|
38745
38830
|
default:
|
|
38746
38831
|
return null;
|
|
38747
38832
|
}
|
|
@@ -38805,7 +38890,7 @@ var Proctoring = class {
|
|
|
38805
38890
|
}
|
|
38806
38891
|
}
|
|
38807
38892
|
async internalOnRealtimeAlerts(response) {
|
|
38808
|
-
if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus" || response.type === "error_upload_package")) {
|
|
38893
|
+
if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus" || response.type === "error_upload_package" || response.type === "audio_muted_on_stream")) {
|
|
38809
38894
|
await this.sendPendingRealtimeAlerts();
|
|
38810
38895
|
if (response.status === "ALERT") {
|
|
38811
38896
|
if (this.allRecorders.cameraRecorder.stopped) return;
|
|
@@ -38879,18 +38964,18 @@ var Proctoring = class {
|
|
|
38879
38964
|
const screenRecorder = this.sessionOptions.captureScreen ? new ScreenRecorder({
|
|
38880
38965
|
allowOnlyFirstMonitor: (_b = this.sessionOptions.allowOnlyFirstMonitor) != null ? _b : true,
|
|
38881
38966
|
allowMultipleMonitors: (_c2 = this.sessionOptions.allowMultipleMonitors) != null ? _c2 : true,
|
|
38882
|
-
screenRecorderOptions: this.sessionOptions.screenRecorderOptions,
|
|
38883
38967
|
onStopSharingScreenCallback: () => this.onStopSharingScreenCallback(),
|
|
38884
38968
|
onBufferSizeError: this.sessionOptions.onBufferSizeError,
|
|
38885
38969
|
onBufferSizeErrorCallback: () => this.onBufferSizeErrorCallback()
|
|
38886
|
-
}) : void 0;
|
|
38970
|
+
}, this.videoOptions, this.paramsConfig) : void 0;
|
|
38887
38971
|
const alertRecorder = new AlertRecorder(
|
|
38888
38972
|
{
|
|
38889
38973
|
onFocusCallback: (response) => this.onFocusAlertRecorderCallback(response),
|
|
38890
38974
|
onLostFocusCallback: (response) => this.onLostFocusAlertRecorderCallback(response),
|
|
38891
38975
|
onRealtimeAlertCallback: (response) => this.onRealtimeAlertsCallback(response)
|
|
38892
38976
|
},
|
|
38893
|
-
options
|
|
38977
|
+
options,
|
|
38978
|
+
screenRecorder
|
|
38894
38979
|
);
|
|
38895
38980
|
const noiseRecorder = new NoiseRecorder(
|
|
38896
38981
|
options,
|
|
@@ -39074,9 +39159,7 @@ Error: ${error}`
|
|
|
39074
39159
|
this.appChecker && await this.appChecker.disconnectWebSocket();
|
|
39075
39160
|
await this.recorder.saveAllOnSession();
|
|
39076
39161
|
await this.sendPendingRealtimeAlerts();
|
|
39077
|
-
trackers.registerError(this.proctoringId, `finish this.repository.save starting`);
|
|
39078
39162
|
await this.repository.save(this.proctoringSession);
|
|
39079
|
-
trackers.registerError(this.proctoringId, `finish this.repository.save finished`);
|
|
39080
39163
|
let uploader;
|
|
39081
39164
|
let uploaderServices;
|
|
39082
39165
|
if (versionVerify() !== "1.0.0.0") {
|
|
@@ -39230,10 +39313,6 @@ Error: ` + error
|
|
|
39230
39313
|
...this.paramsConfig.audioBehaviourParameters,
|
|
39231
39314
|
...paramsConfig.audioBehaviourParameters
|
|
39232
39315
|
},
|
|
39233
|
-
imageBehaviourParameters: {
|
|
39234
|
-
...this.paramsConfig.imageBehaviourParameters,
|
|
39235
|
-
...paramsConfig.imageBehaviourParameters
|
|
39236
|
-
},
|
|
39237
39316
|
videoBehaviourParameters: {
|
|
39238
39317
|
...this.paramsConfig.videoBehaviourParameters,
|
|
39239
39318
|
...paramsConfig.videoBehaviourParameters
|
|
@@ -3,11 +3,7 @@ export type AudioBehaviourParameters = {
|
|
|
3
3
|
onlyTranscribedAudio?: boolean;
|
|
4
4
|
recordingBitrate?: number;
|
|
5
5
|
noiseLimit?: number;
|
|
6
|
-
|
|
7
|
-
export type ImageBehaviourParameters = {
|
|
8
|
-
useUploadImage?: boolean;
|
|
9
|
-
uploadInterval?: number;
|
|
10
|
-
saveVideo?: boolean;
|
|
6
|
+
muteThreshold?: number;
|
|
11
7
|
};
|
|
12
8
|
export type VideoBehaviourParameters = {
|
|
13
9
|
minAlertTimePitch?: number;
|
|
@@ -26,10 +22,11 @@ export type VideoBehaviourParameters = {
|
|
|
26
22
|
maxRetries?: number;
|
|
27
23
|
realtimePackageSize?: number;
|
|
28
24
|
realtimeCaptureInterval?: number;
|
|
25
|
+
cameraVideoQuality?: number;
|
|
26
|
+
screenVideoQuality?: number;
|
|
29
27
|
};
|
|
30
28
|
export default interface IParamsConfig {
|
|
31
29
|
audioBehaviourParameters?: AudioBehaviourParameters;
|
|
32
|
-
imageBehaviourParameters?: ImageBehaviourParameters;
|
|
33
30
|
videoBehaviourParameters?: VideoBehaviourParameters;
|
|
34
31
|
spyScanInterval?: number;
|
|
35
32
|
}
|