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 CHANGED
@@ -263,6 +263,11 @@ const {
263
263
  token: "...",
264
264
  });
265
265
  ```
266
+ ## Release Note V 3.2.0
267
+ - Fix: melhoria na sincronizacao dos alertas de tela
268
+ - Fix: melhoria no corte do audio para analise
269
+ - Fator de qualidade parametrizavel
270
+ - Alerta de microfone mutado adicionado
266
271
 
267
272
  ## Release Note V 3.0.0
268
273
  - Envio do vídeo por partes durante o exame para o proctoring REALTIME
package/esm/index.js CHANGED
@@ -12695,14 +12695,13 @@ var getDefaultProctoringOptions = {
12695
12695
  captureScreen: true,
12696
12696
  noiseLimit: 40,
12697
12697
  // deprecated
12698
- proctoringType: "IMAGE",
12698
+ proctoringType: "VIDEO",
12699
12699
  insights: "",
12700
12700
  onBufferSizeError: false,
12701
12701
  useGeolocation: false,
12702
12702
  useSpyScan: false,
12703
12703
  useExternalCamera: false,
12704
12704
  useChallenge: false,
12705
- screenRecorderOptions: { width: 1280, height: 720 },
12706
12705
  auto: false
12707
12706
  };
12708
12707
 
@@ -12771,7 +12770,7 @@ var proctoringId;
12771
12770
  function setRecorderProctoringId(id) {
12772
12771
  proctoringId = id;
12773
12772
  }
12774
- function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCallback, audio = false, recorderOpts) {
12773
+ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCallback, recorderOpts) {
12775
12774
  let resolvePromise;
12776
12775
  let onBufferSizeInterval;
12777
12776
  let lastEvent;
@@ -12783,9 +12782,11 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12783
12782
  let recorderOptions = {
12784
12783
  // eslint-disable-next-line no-useless-escape
12785
12784
  mimeType: "video/webm",
12786
- videoBitsPerSecond: 128e3,
12785
+ videoBitsPerSecond: 25e4 * ((recorderOpts == null ? void 0 : recorderOpts.quality) || 1),
12786
+ // 250Kbps por padrão
12787
12787
  audioBitsPerSecond: 64 * 1e3
12788
12788
  };
12789
+ console.log("recorderOptions", recorderOptions);
12789
12790
  if (MediaRecorder.isTypeSupported("video/webm;codecs=vp9")) {
12790
12791
  recorderOptions.mimeType = "video/webm;codecs=vp9";
12791
12792
  } else {
@@ -12793,12 +12794,6 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12793
12794
  "vp9 codec not supported. Using default mimeType without vp9."
12794
12795
  );
12795
12796
  }
12796
- if (audio) {
12797
- recorderOptions = {
12798
- mimeType: "audio/webm",
12799
- audioBitsPerSecond: 64 * 1e3
12800
- };
12801
- }
12802
12797
  function buildMediaRecorder(stream2, recorderOptions2) {
12803
12798
  const tracks = stream2.getTracks();
12804
12799
  if (tracks.length == 0) {
@@ -12869,7 +12864,7 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12869
12864
  console.error("Timeout ao iniciar o recorder");
12870
12865
  reject(new Error("Timeout ao iniciar o recorder"));
12871
12866
  }
12872
- }, 2e3);
12867
+ }, 5e3);
12873
12868
  });
12874
12869
  }
12875
12870
  async function startRecording() {
@@ -13891,29 +13886,20 @@ var _CameraRecorder = class _CameraRecorder {
13891
13886
  recordingBitrate: 128,
13892
13887
  noiseLimit: 40
13893
13888
  },
13894
- imageBehaviourParameters: {
13895
- useUploadImage: true,
13896
- uploadInterval: 20,
13897
- saveVideo: true
13898
- },
13899
13889
  videoBehaviourParameters: {
13900
13890
  detectPerson: false,
13901
13891
  detectFace: false,
13902
- detectCellPhone: false
13892
+ detectCellPhone: false,
13893
+ cameraVideoQuality: 1
13903
13894
  }
13904
13895
  };
13905
- // private imageParams: ImageParameters = {
13906
- // useUploadImage: true,
13907
- // uploadInterval: 20,
13908
- // saveVideo: true
13909
- // };
13910
13896
  this.options = {
13911
13897
  cameraId: void 0,
13912
13898
  microphoneId: void 0,
13913
13899
  onBufferSizeError: false,
13914
13900
  onBufferSizeErrorCallback: (cameraStream) => {
13915
13901
  },
13916
- proctoringType: "IMAGE",
13902
+ proctoringType: "VIDEO",
13917
13903
  onChangeDevicesCallback: (devices) => {
13918
13904
  },
13919
13905
  onRealtimeAlertsCallback: (response) => {
@@ -14220,14 +14206,15 @@ Setting: ${JSON.stringify(settings, null, 2)}`
14220
14206
  await new Promise((r3) => setTimeout(r3, 300));
14221
14207
  }
14222
14208
  async startRecording() {
14223
- var _a2, _b, _c2, _d, _e3, _f, _g, _h;
14209
+ var _a2, _b, _c2, _d, _e3, _f, _g, _h, _i3;
14224
14210
  await this.startStream();
14225
14211
  await this.attachAndWarmup(this.cameraStream);
14226
14212
  const recorderOpts = this.isChunkEnabled ? {
14227
14213
  timeslice: _CameraRecorder.CHUNK_TIMESLICE_MS,
14228
14214
  onChunkAvailable: (blob, idx) => {
14229
14215
  this.handleNewChunk(blob, idx);
14230
- }
14216
+ },
14217
+ quality: (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.cameraVideoQuality
14231
14218
  } : {};
14232
14219
  const {
14233
14220
  startRecording,
@@ -14244,7 +14231,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
14244
14231
  this.blobs,
14245
14232
  this.options.onBufferSizeError,
14246
14233
  (e3) => this.bufferError(e3),
14247
- false,
14248
14234
  recorderOpts
14249
14235
  );
14250
14236
  this.recordingStart = startRecording;
@@ -14257,7 +14243,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
14257
14243
  this.getDuration = getDuration;
14258
14244
  this.chunkIndex = 0;
14259
14245
  if (this.isChunkEnabled) {
14260
- (_a2 = this.backgroundUpload) == null ? void 0 : _a2.start();
14246
+ (_b = this.backgroundUpload) == null ? void 0 : _b.start();
14261
14247
  this.setupLifecycleListeners();
14262
14248
  }
14263
14249
  try {
@@ -14266,7 +14252,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
14266
14252
  } catch (error) {
14267
14253
  console.log("Camera Recorder error", error);
14268
14254
  this.stopRecording();
14269
- const maxRetries = ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.maxRetries) || 3;
14255
+ const maxRetries = ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.maxRetries) || 3;
14270
14256
  if (this.currentRetries < maxRetries) {
14271
14257
  console.log("Camera Recorder retry", this.currentRetries);
14272
14258
  this.currentRetries++;
@@ -14276,13 +14262,13 @@ Setting: ${JSON.stringify(settings, null, 2)}`
14276
14262
  }
14277
14263
  }
14278
14264
  this.stopped = false;
14279
- if (((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectPerson) || ((_d = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _d.detectCellPhone) || ((_e3 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _e3.detectFace)) {
14265
+ 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)) {
14280
14266
  await this.initializeDetectors();
14281
14267
  }
14282
- if ((_f = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _f.detectFace) {
14268
+ if ((_g = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _g.detectFace) {
14283
14269
  await this.faceDetection.enableCam(this.cameraStream);
14284
14270
  }
14285
- if (((_g = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _g.detectPerson) || ((_h = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _h.detectCellPhone)) {
14271
+ if (((_h = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _h.detectPerson) || ((_i3 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _i3.detectCellPhone)) {
14286
14272
  await this.objectDetection.enableCam(this.cameraStream);
14287
14273
  }
14288
14274
  this.filesToUpload = [];
@@ -14517,7 +14503,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
14517
14503
  window.URL.revokeObjectURL(url);
14518
14504
  }
14519
14505
  async saveOnSession(session) {
14520
- var _a2, _b;
14506
+ var _a2;
14521
14507
  if (this.blobs != null)
14522
14508
  trackers.registerSaveOnSession(
14523
14509
  this.proctoringId,
@@ -14525,37 +14511,40 @@ Setting: ${JSON.stringify(settings, null, 2)}`
14525
14511
  );
14526
14512
  const settings = this.cameraStream.getVideoTracks()[0].getSettings();
14527
14513
  const settingsAudio = this.cameraStream.getAudioTracks()[0].getSettings();
14528
- if (this.options.proctoringType == "VIDEO" || this.options.proctoringType == "REALTIME" || this.options.proctoringType == "IMAGE" && ((_a2 = this.paramsConfig.imageBehaviourParameters) == null ? void 0 : _a2.saveVideo)) {
14529
- let isUploaded = false;
14530
- if (this.isChunkEnabled) {
14531
- if (this.backend && this.backendToken && this.proctoringId) {
14532
- const fileName = `EP_${this.proctoringId}_camera_0.webm`;
14533
- const objectName = `${this.proctoringId}/${fileName}`;
14534
- isUploaded = await this.backend.checkUpload(this.backendToken, objectName, "video/webm");
14535
- this.chunkStorage && await this.chunkStorage.clearAllChunks(session.id);
14536
- }
14537
- }
14538
- if (!isUploaded) {
14539
- const rawBlob = new Blob(this.blobs, {
14540
- type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
14541
- });
14542
- let finalBlob = rawBlob;
14543
- if (typeof fixWebmDuration === "function") {
14514
+ let isUploaded = false;
14515
+ if (this.isChunkEnabled) {
14516
+ if (this.backend && this.backendToken && this.proctoringId) {
14517
+ const fileName = `EP_${this.proctoringId}_camera_0.webm`;
14518
+ const objectName = `${this.proctoringId}/${fileName}`;
14519
+ isUploaded = await this.backend.checkUpload(this.backendToken, objectName, "video/webm");
14520
+ this.chunkStorage && await this.chunkStorage.clearAllChunks(session.id);
14521
+ }
14522
+ }
14523
+ if (!isUploaded) {
14524
+ const rawBlob = new Blob(this.blobs, {
14525
+ type: ((_a2 = this.recorderOptions) == null ? void 0 : _a2.mimeType) || "video/webm"
14526
+ });
14527
+ let finalBlob = rawBlob;
14528
+ if (typeof fixWebmDuration === "function") {
14529
+ try {
14544
14530
  finalBlob = await fixWebmDuration(rawBlob, this.duration);
14545
- } else {
14546
- console.warn("fixWebmDuration n\xE3o dispon\xEDvel");
14531
+ } catch (e3) {
14532
+ console.warn("Erro ao corrigir a dura\xE7\xE3o do v\xEDdeo", e3);
14533
+ finalBlob = rawBlob;
14547
14534
  }
14548
- session.addRecording({
14549
- device: `Audio
14535
+ } else {
14536
+ console.warn("fixWebmDuration n\xE3o dispon\xEDvel");
14537
+ }
14538
+ session.addRecording({
14539
+ device: `Audio
14550
14540
  Sample Rate: ${settingsAudio.sampleRate}
14551
14541
  Sample Size: ${settingsAudio.sampleSize}
14552
14542
 
14553
14543
  Video:
14554
14544
  ${JSON.stringify(this.recorderOptions)}`,
14555
- arrayBuffer: await finalBlob.arrayBuffer(),
14556
- origin: "Camera" /* Camera */
14557
- });
14558
- }
14545
+ arrayBuffer: await finalBlob.arrayBuffer(),
14546
+ origin: "Camera" /* Camera */
14547
+ });
14559
14548
  }
14560
14549
  }
14561
14550
  async getFile(file, name, type) {
@@ -16740,7 +16729,7 @@ Error: ${e3.message}
16740
16729
 
16741
16730
  // src/new-flow/recorders/AlertRecorder.ts
16742
16731
  var AlertRecorder = class {
16743
- constructor(options, optionsProctoring) {
16732
+ constructor(options, optionsProctoring, screenRecorder) {
16744
16733
  this.alerts = [];
16745
16734
  // Variáveis para controle de inatividade
16746
16735
  this.lastActivityTime = Date.now();
@@ -16756,29 +16745,21 @@ var AlertRecorder = class {
16756
16745
  this.handleLostFocus();
16757
16746
  }
16758
16747
  };
16748
+ this.isFocused = true;
16759
16749
  this.handleLostFocus = () => {
16750
+ if (this.screenRecorder && !this.screenRecorder.isRecording) {
16751
+ return;
16752
+ }
16760
16753
  if (this.getRelativeTime() > 1e4) {
16761
- const alertPayload = {
16762
- begin: this.getRelativeTime(),
16763
- end: 0,
16764
- alert: 25 /* FocusOff */,
16765
- type: 3 /* Screen */
16766
- };
16767
- this.onLostFocusCallback(alertPayload);
16768
- this.alerts.push(alertPayload);
16754
+ this.setFocus(false);
16769
16755
  }
16770
16756
  };
16771
16757
  this.handleReturnFocus = () => {
16772
- const lastAlert = this.alerts[this.alerts.length - 1];
16773
- if (lastAlert) {
16774
- this.onFocusCallback({
16775
- begin: lastAlert.begin,
16776
- end: this.getRelativeTime(),
16777
- alert: 25 /* FocusOff */,
16778
- type: 3 /* Screen */
16779
- });
16780
- lastAlert.end = this.getRelativeTime();
16758
+ if (this.screenRecorder && !this.screenRecorder.isRecording) {
16759
+ return;
16781
16760
  }
16761
+ if (this.alerts.length === 0) return;
16762
+ this.setFocus(true);
16782
16763
  };
16783
16764
  // 2. SPLIT SCREEN DETECTION
16784
16765
  this.handleResize = () => {
@@ -16837,6 +16818,7 @@ var AlertRecorder = class {
16837
16818
  this.onFocusCallback = options.onFocusCallback;
16838
16819
  this.onRealtimeAlertCallback = options.onRealtimeAlertCallback;
16839
16820
  this.optionsProctoring = optionsProctoring;
16821
+ this.screenRecorder = screenRecorder;
16840
16822
  }
16841
16823
  async startRecording() {
16842
16824
  this.startTime = new Date(Date.now());
@@ -16863,6 +16845,8 @@ var AlertRecorder = class {
16863
16845
  attachListeners() {
16864
16846
  if (this.optionsProctoring.captureScreen) {
16865
16847
  window.addEventListener("visibilitychange", this.handleVisibilityChange);
16848
+ window.addEventListener("blur", this.handleLostFocus);
16849
+ window.addEventListener("focus", this.handleReturnFocus);
16866
16850
  window.addEventListener("resize", this.handleResize);
16867
16851
  window.document.addEventListener("copy", this.handleCopy);
16868
16852
  window.document.addEventListener("cut", this.handleCut);
@@ -16871,11 +16855,40 @@ var AlertRecorder = class {
16871
16855
  }
16872
16856
  detachListeners() {
16873
16857
  window.removeEventListener("visibilitychange", this.handleVisibilityChange);
16858
+ window.removeEventListener("blur", this.handleLostFocus);
16859
+ window.removeEventListener("focus", this.handleReturnFocus);
16874
16860
  window.removeEventListener("resize", this.handleResize);
16875
16861
  window.document.removeEventListener("copy", this.handleCopy);
16876
16862
  window.document.removeEventListener("cut", this.handleCut);
16877
16863
  window.document.removeEventListener("paste", this.handlePaste);
16878
16864
  }
16865
+ setFocus(focused) {
16866
+ if (this.isFocused === focused) {
16867
+ return;
16868
+ }
16869
+ this.isFocused = focused;
16870
+ if (focused) {
16871
+ const lastAlert = this.alerts[this.alerts.length - 1];
16872
+ if (lastAlert) {
16873
+ this.onFocusCallback({
16874
+ begin: lastAlert.begin,
16875
+ end: this.getRelativeTime(),
16876
+ alert: 25 /* FocusOff */,
16877
+ type: 3 /* Screen */
16878
+ });
16879
+ lastAlert.end = this.getRelativeTime();
16880
+ }
16881
+ } else {
16882
+ const alertPayload = {
16883
+ begin: this.getRelativeTime(),
16884
+ end: 0,
16885
+ alert: 25 /* FocusOff */,
16886
+ type: 3 /* Screen */
16887
+ };
16888
+ this.onLostFocusCallback(alertPayload);
16889
+ this.alerts.push(alertPayload);
16890
+ }
16891
+ }
16879
16892
  // private startIdleChecker() {
16880
16893
  // this.stopIdleChecker(); // Garante que não tenha duplicação
16881
16894
  // this.idleCheckInterval = setInterval(() => {
@@ -16916,7 +16929,11 @@ var AlertRecorder = class {
16916
16929
  // HELPERS
16917
16930
  // ==========================================
16918
16931
  getRelativeTime() {
16919
- return Date.now() - this.startTime.getTime();
16932
+ var _a2;
16933
+ if (this.screenRecorder) {
16934
+ return Date.now() - (((_a2 = this.screenRecorder.getStartTime()) == null ? void 0 : _a2.getTime()) || 0);
16935
+ }
16936
+ return Date.now() - (this.startTime.getTime() || 0);
16920
16937
  }
16921
16938
  createAlert(category, type, description) {
16922
16939
  this.alerts.push({
@@ -19190,7 +19207,12 @@ var NoiseRecorder = class {
19190
19207
  this.MAX_PRE_ROLL_CHUNKS = 4;
19191
19208
  this.lastNoiseTime = 0;
19192
19209
  this.SILENCE_THRESHOLD = 3e3;
19210
+ this.MAX_RECORD_DURATION = 3e4;
19211
+ // 30 segundos
19193
19212
  this.filesToUpload = [];
19213
+ // logica do mute
19214
+ this.acumulatedMuteTime = 0;
19215
+ this.startMuteTime = 0;
19194
19216
  this.optionsProctoring = optionsProctoring;
19195
19217
  this.proctoringSession = proctoringSession;
19196
19218
  this.paramsConfig = paramsConfig;
@@ -19225,7 +19247,7 @@ var NoiseRecorder = class {
19225
19247
  async saveOnSession(session) {
19226
19248
  }
19227
19249
  async onNoiseDetectedRecord() {
19228
- var _a2, _b, _c2, _d, _e3, _f, _g, _h, _i3;
19250
+ var _a2, _b, _c2, _d, _e3, _f, _g, _h, _i3, _j, _k, _l;
19229
19251
  if (!this.volumeMeter && this.cameraRecorder.cameraStream) {
19230
19252
  this.volumeMeter = new VolumeMeter(this.cameraRecorder.cameraStream);
19231
19253
  this.volumeMeter.start().catch((e3) => {
@@ -19235,6 +19257,25 @@ var NoiseRecorder = class {
19235
19257
  }
19236
19258
  let noiseLimit = ((_a2 = this.paramsConfig.audioBehaviourParameters) == null ? void 0 : _a2.noiseLimit) || 40;
19237
19259
  const currentVolume = ((_b = this.volumeMeter) == null ? void 0 : _b.getVolume()) || 0;
19260
+ if (this.optionsProctoring.proctoringType == "REALTIME") {
19261
+ let muteThreshold = ((_c2 = this.paramsConfig.audioBehaviourParameters) == null ? void 0 : _c2.muteThreshold) || 60;
19262
+ if (currentVolume == 0) {
19263
+ if (this.acumulatedMuteTime == 0) this.startMuteTime = Date.now() - (((_d = this.cameraRecorder.getStartTime()) == null ? void 0 : _d.getTime()) || 0);
19264
+ this.acumulatedMuteTime = this.acumulatedMuteTime + 200;
19265
+ } else
19266
+ this.acumulatedMuteTime = 0;
19267
+ if (this.acumulatedMuteTime / 1e3 >= muteThreshold) {
19268
+ this.acumulatedMuteTime = 0;
19269
+ this.onRealtimeAlertsCallback({
19270
+ begin: this.startMuteTime,
19271
+ end: Date.now() - (((_e3 = this.cameraRecorder.getStartTime()) == null ? void 0 : _e3.getTime()) || 0),
19272
+ status: "ALERT",
19273
+ description: "Microfone mutado",
19274
+ type: "audio_muted_on_stream",
19275
+ category: "audio_muted_on_stream"
19276
+ });
19277
+ }
19278
+ }
19238
19279
  this.isSpeech = this.isSpeech || this.hasDesiredResult(this.audioClassificationResult);
19239
19280
  if (!this.isSpeech && !this.recordingInProgress)
19240
19281
  noiseLimit = noiseLimit * 1.25;
@@ -19247,27 +19288,28 @@ var NoiseRecorder = class {
19247
19288
  this.recordingChunks = [...this.preRollBuffer];
19248
19289
  const totalSamplesInBuffer = this.preRollBuffer.reduce((acc, chunk) => acc + chunk.length, 0);
19249
19290
  const bufferDurationMs = totalSamplesInBuffer / this.SAMPLE_RATE * 1e3;
19250
- const triggerTime = Date.now() - (((_c2 = this.cameraRecorder.getStartTime()) == null ? void 0 : _c2.getTime()) || 0);
19291
+ const triggerTime = Date.now() - (((_f = this.cameraRecorder.getStartTime()) == null ? void 0 : _f.getTime()) || 0);
19251
19292
  this.recordingStartTime = triggerTime - bufferDurationMs;
19252
19293
  if (this.recordingStartTime < 0) this.recordingStartTime = 0;
19253
19294
  } else if (this.recordingInProgress) {
19254
19295
  const silenceDuration = Date.now() - this.lastNoiseTime;
19255
19296
  const currentRecordDuration = Date.now() - this.recordingStartTime;
19256
- if (silenceDuration >= this.SILENCE_THRESHOLD && currentRecordDuration >= 3e3 && this.countLoopTimes > 4) {
19297
+ const isMaxDurationReached = currentRecordDuration >= this.MAX_RECORD_DURATION;
19298
+ if (silenceDuration >= this.SILENCE_THRESHOLD && currentRecordDuration >= 3e3 && this.countLoopTimes > 4 || isMaxDurationReached) {
19257
19299
  await this.stopSoundRecord();
19258
- if (((_d = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _d.detectNoise) && !this.isSpeech) {
19300
+ if (((_g = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _g.detectNoise) && !this.isSpeech) {
19259
19301
  this.onRealtimeAlertsCallback({
19260
- begin: Date.now() - (((_e3 = this.cameraRecorder.getStartTime()) == null ? void 0 : _e3.getTime()) || 0),
19261
- end: Date.now() - (((_f = this.cameraRecorder.getStartTime()) == null ? void 0 : _f.getTime()) || 0),
19302
+ begin: Date.now() - (((_h = this.cameraRecorder.getStartTime()) == null ? void 0 : _h.getTime()) || 0),
19303
+ end: Date.now() - (((_i3 = this.cameraRecorder.getStartTime()) == null ? void 0 : _i3.getTime()) || 0),
19262
19304
  status: "ALERT",
19263
19305
  description: "Barulho detectado",
19264
19306
  type: "audio_detection_on_stream"
19265
19307
  });
19266
19308
  }
19267
- if (((_g = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _g.detectSpeech) && this.isSpeech) {
19309
+ if (((_j = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _j.detectSpeech) && this.isSpeech) {
19268
19310
  this.onRealtimeAlertsCallback({
19269
- begin: Date.now() - (((_h = this.cameraRecorder.getStartTime()) == null ? void 0 : _h.getTime()) || 0),
19270
- end: Date.now() - (((_i3 = this.cameraRecorder.getStartTime()) == null ? void 0 : _i3.getTime()) || 0),
19311
+ begin: Date.now() - (((_k = this.cameraRecorder.getStartTime()) == null ? void 0 : _k.getTime()) || 0),
19312
+ end: Date.now() - (((_l = this.cameraRecorder.getStartTime()) == null ? void 0 : _l.getTime()) || 0),
19271
19313
  status: "ALERT",
19272
19314
  description: "Fala detectada",
19273
19315
  type: "audio_detection_on_stream"
@@ -19445,10 +19487,28 @@ registerProcessor("audio-processor", AudioProcessor);
19445
19487
  var pkg2 = require_fix_webm_duration();
19446
19488
  var fixWebmDuration2 = pkg2.default || pkg2;
19447
19489
  var ScreenRecorder = class {
19448
- constructor(options) {
19490
+ constructor(options, videoOptions, paramsConfig) {
19449
19491
  this.blobs = [];
19450
19492
  this.blobsFinal = [];
19493
+ this.isRecording = false;
19451
19494
  this.duration = 0;
19495
+ this.videoOptions = {
19496
+ width: 640,
19497
+ height: 480,
19498
+ minWidth: 0,
19499
+ minHeight: 0
19500
+ };
19501
+ this.paramsConfig = {
19502
+ audioBehaviourParameters: {
19503
+ recordingBitrate: 128,
19504
+ noiseLimit: 40
19505
+ },
19506
+ videoBehaviourParameters: {
19507
+ screenVideoQuality: 3
19508
+ }
19509
+ };
19510
+ paramsConfig && (this.paramsConfig = paramsConfig);
19511
+ this.videoOptions = videoOptions;
19452
19512
  this.options = options;
19453
19513
  }
19454
19514
  setProctoringId(proctoringId2) {
@@ -19456,15 +19516,16 @@ var ScreenRecorder = class {
19456
19516
  setRecorderProctoringId(proctoringId2);
19457
19517
  }
19458
19518
  async startRecording() {
19459
- this.startTime = new Date(Date.now());
19519
+ var _a2;
19460
19520
  if (isMobileDevice()) return;
19461
19521
  const { allowOnlyFirstMonitor, allowMultipleMonitors, onStopSharingScreenCallback, onBufferSizeErrorCallback } = this.options;
19462
19522
  const complexConstraints = {
19463
19523
  video: {
19464
19524
  cursor: "always",
19465
- width: this.options.screenRecorderOptions.width,
19466
- height: this.options.screenRecorderOptions.height,
19467
- displaySurface: "monitor"
19525
+ width: this.videoOptions.width,
19526
+ height: this.videoOptions.height,
19527
+ displaySurface: "monitor",
19528
+ frameRate: 15
19468
19529
  },
19469
19530
  audio: false
19470
19531
  };
@@ -19520,10 +19581,24 @@ var ScreenRecorder = class {
19520
19581
  });
19521
19582
  throw NOT_SHARED_SCREEN;
19522
19583
  }
19523
- const { startRecording, stopRecording } = recorder(this.screenStream, this.blobs, this.options.onBufferSizeError, onBufferSizeErrorCallback);
19584
+ const {
19585
+ startRecording,
19586
+ stopRecording,
19587
+ getStartTime,
19588
+ getDuration
19589
+ } = recorder(
19590
+ this.screenStream,
19591
+ this.blobs,
19592
+ this.options.onBufferSizeError,
19593
+ onBufferSizeErrorCallback,
19594
+ { quality: (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.screenVideoQuality }
19595
+ );
19524
19596
  this.recordingStart = startRecording;
19525
19597
  this.recordingStop = stopRecording;
19598
+ this.getStartTime = getStartTime;
19599
+ this.getDuration = getDuration;
19526
19600
  this.recordingStart();
19601
+ this.isRecording = true;
19527
19602
  }
19528
19603
  async pauseRecording() {
19529
19604
  }
@@ -19533,16 +19608,27 @@ var ScreenRecorder = class {
19533
19608
  var _a2;
19534
19609
  this.recordingStop && await this.recordingStop();
19535
19610
  this.duration = Date.now() - ((_a2 = this.startTime) == null ? void 0 : _a2.getTime()) || 0;
19611
+ this.isRecording = false;
19536
19612
  }
19537
19613
  async saveOnSession(session) {
19538
19614
  if (isMobileDevice()) return;
19539
19615
  const rawBlob = new Blob(this.blobs, {
19540
19616
  type: "video/webm"
19541
19617
  });
19542
- const fixedBlob = await fixWebmDuration2(rawBlob, this.duration);
19618
+ let finalBlob = rawBlob;
19619
+ if (typeof fixWebmDuration2 === "function") {
19620
+ try {
19621
+ finalBlob = await fixWebmDuration2(rawBlob, this.duration);
19622
+ } catch (e3) {
19623
+ console.warn("Erro ao corrigir a dura\xE7\xE3o do v\xEDdeo", e3);
19624
+ finalBlob = rawBlob;
19625
+ }
19626
+ } else {
19627
+ console.warn("fixWebmDuration n\xE3o dispon\xEDvel");
19628
+ }
19543
19629
  session.addRecording({
19544
19630
  device: "",
19545
- arrayBuffer: await fixedBlob.arrayBuffer(),
19631
+ arrayBuffer: await finalBlob.arrayBuffer(),
19546
19632
  origin: "Screen" /* Screen */
19547
19633
  });
19548
19634
  }
@@ -23345,11 +23431,6 @@ var Proctoring = class {
23345
23431
  recordingBitrate: 128,
23346
23432
  noiseLimit: 40
23347
23433
  },
23348
- imageBehaviourParameters: {
23349
- useUploadImage: true,
23350
- uploadInterval: 20,
23351
- saveVideo: true
23352
- },
23353
23434
  videoBehaviourParameters: {
23354
23435
  detectFace: false,
23355
23436
  detectPerson: false,
@@ -23357,7 +23438,9 @@ var Proctoring = class {
23357
23438
  detectNoise: false,
23358
23439
  detectSpeech: false,
23359
23440
  realtimePackageSize: 10,
23360
- realtimeCaptureInterval: 2
23441
+ realtimeCaptureInterval: 2,
23442
+ cameraVideoQuality: 1,
23443
+ screenVideoQuality: 4
23361
23444
  }
23362
23445
  };
23363
23446
  this.proctoringId = "";
@@ -23493,6 +23576,8 @@ var Proctoring = class {
23493
23576
  return 25 /* FocusOff */;
23494
23577
  case "error_upload_package":
23495
23578
  return 44 /* RealtimeOffline */;
23579
+ case "audio_muted_on_stream":
23580
+ return 95 /* NoAudioFound */;
23496
23581
  default:
23497
23582
  return null;
23498
23583
  }
@@ -23556,7 +23641,7 @@ var Proctoring = class {
23556
23641
  }
23557
23642
  }
23558
23643
  async internalOnRealtimeAlerts(response) {
23559
- 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")) {
23644
+ 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")) {
23560
23645
  await this.sendPendingRealtimeAlerts();
23561
23646
  if (response.status === "ALERT") {
23562
23647
  if (this.allRecorders.cameraRecorder.stopped) return;
@@ -23630,18 +23715,18 @@ var Proctoring = class {
23630
23715
  const screenRecorder = this.sessionOptions.captureScreen ? new ScreenRecorder({
23631
23716
  allowOnlyFirstMonitor: (_b = this.sessionOptions.allowOnlyFirstMonitor) != null ? _b : true,
23632
23717
  allowMultipleMonitors: (_c2 = this.sessionOptions.allowMultipleMonitors) != null ? _c2 : true,
23633
- screenRecorderOptions: this.sessionOptions.screenRecorderOptions,
23634
23718
  onStopSharingScreenCallback: () => this.onStopSharingScreenCallback(),
23635
23719
  onBufferSizeError: this.sessionOptions.onBufferSizeError,
23636
23720
  onBufferSizeErrorCallback: () => this.onBufferSizeErrorCallback()
23637
- }) : void 0;
23721
+ }, this.videoOptions, this.paramsConfig) : void 0;
23638
23722
  const alertRecorder = new AlertRecorder(
23639
23723
  {
23640
23724
  onFocusCallback: (response) => this.onFocusAlertRecorderCallback(response),
23641
23725
  onLostFocusCallback: (response) => this.onLostFocusAlertRecorderCallback(response),
23642
23726
  onRealtimeAlertCallback: (response) => this.onRealtimeAlertsCallback(response)
23643
23727
  },
23644
- options
23728
+ options,
23729
+ screenRecorder
23645
23730
  );
23646
23731
  const noiseRecorder = new NoiseRecorder(
23647
23732
  options,
@@ -23825,9 +23910,7 @@ Error: ${error}`
23825
23910
  this.appChecker && await this.appChecker.disconnectWebSocket();
23826
23911
  await this.recorder.saveAllOnSession();
23827
23912
  await this.sendPendingRealtimeAlerts();
23828
- trackers.registerError(this.proctoringId, `finish this.repository.save starting`);
23829
23913
  await this.repository.save(this.proctoringSession);
23830
- trackers.registerError(this.proctoringId, `finish this.repository.save finished`);
23831
23914
  let uploader;
23832
23915
  let uploaderServices;
23833
23916
  if (versionVerify() !== "1.0.0.0") {
@@ -23981,10 +24064,6 @@ Error: ` + error
23981
24064
  ...this.paramsConfig.audioBehaviourParameters,
23982
24065
  ...paramsConfig.audioBehaviourParameters
23983
24066
  },
23984
- imageBehaviourParameters: {
23985
- ...this.paramsConfig.imageBehaviourParameters,
23986
- ...paramsConfig.imageBehaviourParameters
23987
- },
23988
24067
  videoBehaviourParameters: {
23989
24068
  ...this.paramsConfig.videoBehaviourParameters,
23990
24069
  ...paramsConfig.videoBehaviourParameters