easyproctor 2.5.5 → 2.5.7

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/esm/index.js CHANGED
@@ -2400,6 +2400,493 @@ var require_jszip_min = __commonJS({
2400
2400
  }
2401
2401
  });
2402
2402
 
2403
+ // node_modules/fix-webm-duration/fix-webm-duration.js
2404
+ var require_fix_webm_duration = __commonJS({
2405
+ "node_modules/fix-webm-duration/fix-webm-duration.js"(exports, module) {
2406
+ (function(name, definition) {
2407
+ if (typeof define === "function" && define.amd) {
2408
+ define(definition);
2409
+ } else if (typeof module !== "undefined" && module.exports) {
2410
+ module.exports = definition();
2411
+ } else {
2412
+ window.ysFixWebmDuration = definition();
2413
+ }
2414
+ })("fix-webm-duration", function() {
2415
+ var sections = {
2416
+ 172351395: { name: "EBML", type: "Container" },
2417
+ 646: { name: "EBMLVersion", type: "Uint" },
2418
+ 759: { name: "EBMLReadVersion", type: "Uint" },
2419
+ 754: { name: "EBMLMaxIDLength", type: "Uint" },
2420
+ 755: { name: "EBMLMaxSizeLength", type: "Uint" },
2421
+ 642: { name: "DocType", type: "String" },
2422
+ 647: { name: "DocTypeVersion", type: "Uint" },
2423
+ 645: { name: "DocTypeReadVersion", type: "Uint" },
2424
+ 108: { name: "Void", type: "Binary" },
2425
+ 63: { name: "CRC-32", type: "Binary" },
2426
+ 190023271: { name: "SignatureSlot", type: "Container" },
2427
+ 16010: { name: "SignatureAlgo", type: "Uint" },
2428
+ 16026: { name: "SignatureHash", type: "Uint" },
2429
+ 16037: { name: "SignaturePublicKey", type: "Binary" },
2430
+ 16053: { name: "Signature", type: "Binary" },
2431
+ 15963: { name: "SignatureElements", type: "Container" },
2432
+ 15995: { name: "SignatureElementList", type: "Container" },
2433
+ 9522: { name: "SignedElement", type: "Binary" },
2434
+ 139690087: { name: "Segment", type: "Container" },
2435
+ 21863284: { name: "SeekHead", type: "Container" },
2436
+ 3515: { name: "Seek", type: "Container" },
2437
+ 5035: { name: "SeekID", type: "Binary" },
2438
+ 5036: { name: "SeekPosition", type: "Uint" },
2439
+ 88713574: { name: "Info", type: "Container" },
2440
+ 13220: { name: "SegmentUID", type: "Binary" },
2441
+ 13188: { name: "SegmentFilename", type: "String" },
2442
+ 1882403: { name: "PrevUID", type: "Binary" },
2443
+ 1868715: { name: "PrevFilename", type: "String" },
2444
+ 2013475: { name: "NextUID", type: "Binary" },
2445
+ 1999803: { name: "NextFilename", type: "String" },
2446
+ 1092: { name: "SegmentFamily", type: "Binary" },
2447
+ 10532: { name: "ChapterTranslate", type: "Container" },
2448
+ 10748: { name: "ChapterTranslateEditionUID", type: "Uint" },
2449
+ 10687: { name: "ChapterTranslateCodec", type: "Uint" },
2450
+ 10661: { name: "ChapterTranslateID", type: "Binary" },
2451
+ 710577: { name: "TimecodeScale", type: "Uint" },
2452
+ 1161: { name: "Duration", type: "Float" },
2453
+ 1121: { name: "DateUTC", type: "Date" },
2454
+ 15273: { name: "Title", type: "String" },
2455
+ 3456: { name: "MuxingApp", type: "String" },
2456
+ 5953: { name: "WritingApp", type: "String" },
2457
+ // 0xf43b675: { name: 'Cluster', type: 'Container' },
2458
+ 103: { name: "Timecode", type: "Uint" },
2459
+ 6228: { name: "SilentTracks", type: "Container" },
2460
+ 6359: { name: "SilentTrackNumber", type: "Uint" },
2461
+ 39: { name: "Position", type: "Uint" },
2462
+ 43: { name: "PrevSize", type: "Uint" },
2463
+ 35: { name: "SimpleBlock", type: "Binary" },
2464
+ 32: { name: "BlockGroup", type: "Container" },
2465
+ 33: { name: "Block", type: "Binary" },
2466
+ 34: { name: "BlockVirtual", type: "Binary" },
2467
+ 13729: { name: "BlockAdditions", type: "Container" },
2468
+ 38: { name: "BlockMore", type: "Container" },
2469
+ 110: { name: "BlockAddID", type: "Uint" },
2470
+ 37: { name: "BlockAdditional", type: "Binary" },
2471
+ 27: { name: "BlockDuration", type: "Uint" },
2472
+ 122: { name: "ReferencePriority", type: "Uint" },
2473
+ 123: { name: "ReferenceBlock", type: "Int" },
2474
+ 125: { name: "ReferenceVirtual", type: "Int" },
2475
+ 36: { name: "CodecState", type: "Binary" },
2476
+ 13730: { name: "DiscardPadding", type: "Int" },
2477
+ 14: { name: "Slices", type: "Container" },
2478
+ 104: { name: "TimeSlice", type: "Container" },
2479
+ 76: { name: "LaceNumber", type: "Uint" },
2480
+ 77: { name: "FrameNumber", type: "Uint" },
2481
+ 75: { name: "BlockAdditionID", type: "Uint" },
2482
+ 78: { name: "Delay", type: "Uint" },
2483
+ 79: { name: "SliceDuration", type: "Uint" },
2484
+ 72: { name: "ReferenceFrame", type: "Container" },
2485
+ 73: { name: "ReferenceOffset", type: "Uint" },
2486
+ 74: { name: "ReferenceTimeCode", type: "Uint" },
2487
+ 47: { name: "EncryptedBlock", type: "Binary" },
2488
+ 106212971: { name: "Tracks", type: "Container" },
2489
+ 46: { name: "TrackEntry", type: "Container" },
2490
+ 87: { name: "TrackNumber", type: "Uint" },
2491
+ 13253: { name: "TrackUID", type: "Uint" },
2492
+ 3: { name: "TrackType", type: "Uint" },
2493
+ 57: { name: "FlagEnabled", type: "Uint" },
2494
+ 8: { name: "FlagDefault", type: "Uint" },
2495
+ 5546: { name: "FlagForced", type: "Uint" },
2496
+ 28: { name: "FlagLacing", type: "Uint" },
2497
+ 11751: { name: "MinCache", type: "Uint" },
2498
+ 11768: { name: "MaxCache", type: "Uint" },
2499
+ 254851: { name: "DefaultDuration", type: "Uint" },
2500
+ 216698: { name: "DefaultDecodedFieldDuration", type: "Uint" },
2501
+ 209231: { name: "TrackTimecodeScale", type: "Float" },
2502
+ 4991: { name: "TrackOffset", type: "Int" },
2503
+ 5614: { name: "MaxBlockAdditionID", type: "Uint" },
2504
+ 4974: { name: "Name", type: "String" },
2505
+ 177564: { name: "Language", type: "String" },
2506
+ 6: { name: "CodecID", type: "String" },
2507
+ 9122: { name: "CodecPrivate", type: "Binary" },
2508
+ 362120: { name: "CodecName", type: "String" },
2509
+ 13382: { name: "AttachmentLink", type: "Uint" },
2510
+ 1742487: { name: "CodecSettings", type: "String" },
2511
+ 1785920: { name: "CodecInfoURL", type: "String" },
2512
+ 438848: { name: "CodecDownloadURL", type: "String" },
2513
+ 42: { name: "CodecDecodeAll", type: "Uint" },
2514
+ 12203: { name: "TrackOverlay", type: "Uint" },
2515
+ 5802: { name: "CodecDelay", type: "Uint" },
2516
+ 5819: { name: "SeekPreRoll", type: "Uint" },
2517
+ 9764: { name: "TrackTranslate", type: "Container" },
2518
+ 9980: { name: "TrackTranslateEditionUID", type: "Uint" },
2519
+ 9919: { name: "TrackTranslateCodec", type: "Uint" },
2520
+ 9893: { name: "TrackTranslateTrackID", type: "Binary" },
2521
+ 96: { name: "Video", type: "Container" },
2522
+ 26: { name: "FlagInterlaced", type: "Uint" },
2523
+ 5048: { name: "StereoMode", type: "Uint" },
2524
+ 5056: { name: "AlphaMode", type: "Uint" },
2525
+ 5049: { name: "OldStereoMode", type: "Uint" },
2526
+ 48: { name: "PixelWidth", type: "Uint" },
2527
+ 58: { name: "PixelHeight", type: "Uint" },
2528
+ 5290: { name: "PixelCropBottom", type: "Uint" },
2529
+ 5307: { name: "PixelCropTop", type: "Uint" },
2530
+ 5324: { name: "PixelCropLeft", type: "Uint" },
2531
+ 5341: { name: "PixelCropRight", type: "Uint" },
2532
+ 5296: { name: "DisplayWidth", type: "Uint" },
2533
+ 5306: { name: "DisplayHeight", type: "Uint" },
2534
+ 5298: { name: "DisplayUnit", type: "Uint" },
2535
+ 5299: { name: "AspectRatioType", type: "Uint" },
2536
+ 963876: { name: "ColourSpace", type: "Binary" },
2537
+ 1029411: { name: "GammaValue", type: "Float" },
2538
+ 230371: { name: "FrameRate", type: "Float" },
2539
+ 97: { name: "Audio", type: "Container" },
2540
+ 53: { name: "SamplingFrequency", type: "Float" },
2541
+ 14517: { name: "OutputSamplingFrequency", type: "Float" },
2542
+ 31: { name: "Channels", type: "Uint" },
2543
+ 15739: { name: "ChannelPositions", type: "Binary" },
2544
+ 8804: { name: "BitDepth", type: "Uint" },
2545
+ 98: { name: "TrackOperation", type: "Container" },
2546
+ 99: { name: "TrackCombinePlanes", type: "Container" },
2547
+ 100: { name: "TrackPlane", type: "Container" },
2548
+ 101: { name: "TrackPlaneUID", type: "Uint" },
2549
+ 102: { name: "TrackPlaneType", type: "Uint" },
2550
+ 105: { name: "TrackJoinBlocks", type: "Container" },
2551
+ 109: { name: "TrackJoinUID", type: "Uint" },
2552
+ 64: { name: "TrickTrackUID", type: "Uint" },
2553
+ 65: { name: "TrickTrackSegmentUID", type: "Binary" },
2554
+ 70: { name: "TrickTrackFlag", type: "Uint" },
2555
+ 71: { name: "TrickMasterTrackUID", type: "Uint" },
2556
+ 68: { name: "TrickMasterTrackSegmentUID", type: "Binary" },
2557
+ 11648: { name: "ContentEncodings", type: "Container" },
2558
+ 8768: { name: "ContentEncoding", type: "Container" },
2559
+ 4145: { name: "ContentEncodingOrder", type: "Uint" },
2560
+ 4146: { name: "ContentEncodingScope", type: "Uint" },
2561
+ 4147: { name: "ContentEncodingType", type: "Uint" },
2562
+ 4148: { name: "ContentCompression", type: "Container" },
2563
+ 596: { name: "ContentCompAlgo", type: "Uint" },
2564
+ 597: { name: "ContentCompSettings", type: "Binary" },
2565
+ 4149: { name: "ContentEncryption", type: "Container" },
2566
+ 2017: { name: "ContentEncAlgo", type: "Uint" },
2567
+ 2018: { name: "ContentEncKeyID", type: "Binary" },
2568
+ 2019: { name: "ContentSignature", type: "Binary" },
2569
+ 2020: { name: "ContentSigKeyID", type: "Binary" },
2570
+ 2021: { name: "ContentSigAlgo", type: "Uint" },
2571
+ 2022: { name: "ContentSigHashAlgo", type: "Uint" },
2572
+ 206814059: { name: "Cues", type: "Container" },
2573
+ 59: { name: "CuePoint", type: "Container" },
2574
+ 51: { name: "CueTime", type: "Uint" },
2575
+ 55: { name: "CueTrackPositions", type: "Container" },
2576
+ 119: { name: "CueTrack", type: "Uint" },
2577
+ 113: { name: "CueClusterPosition", type: "Uint" },
2578
+ 112: { name: "CueRelativePosition", type: "Uint" },
2579
+ 50: { name: "CueDuration", type: "Uint" },
2580
+ 4984: { name: "CueBlockNumber", type: "Uint" },
2581
+ 106: { name: "CueCodecState", type: "Uint" },
2582
+ 91: { name: "CueReference", type: "Container" },
2583
+ 22: { name: "CueRefTime", type: "Uint" },
2584
+ 23: { name: "CueRefCluster", type: "Uint" },
2585
+ 4959: { name: "CueRefNumber", type: "Uint" },
2586
+ 107: { name: "CueRefCodecState", type: "Uint" },
2587
+ 155296873: { name: "Attachments", type: "Container" },
2588
+ 8615: { name: "AttachedFile", type: "Container" },
2589
+ 1662: { name: "FileDescription", type: "String" },
2590
+ 1646: { name: "FileName", type: "String" },
2591
+ 1632: { name: "FileMimeType", type: "String" },
2592
+ 1628: { name: "FileData", type: "Binary" },
2593
+ 1710: { name: "FileUID", type: "Uint" },
2594
+ 1653: { name: "FileReferral", type: "Binary" },
2595
+ 1633: { name: "FileUsedStartTime", type: "Uint" },
2596
+ 1634: { name: "FileUsedEndTime", type: "Uint" },
2597
+ 4433776: { name: "Chapters", type: "Container" },
2598
+ 1465: { name: "EditionEntry", type: "Container" },
2599
+ 1468: { name: "EditionUID", type: "Uint" },
2600
+ 1469: { name: "EditionFlagHidden", type: "Uint" },
2601
+ 1499: { name: "EditionFlagDefault", type: "Uint" },
2602
+ 1501: { name: "EditionFlagOrdered", type: "Uint" },
2603
+ 54: { name: "ChapterAtom", type: "Container" },
2604
+ 13252: { name: "ChapterUID", type: "Uint" },
2605
+ 5716: { name: "ChapterStringUID", type: "String" },
2606
+ 17: { name: "ChapterTimeStart", type: "Uint" },
2607
+ 18: { name: "ChapterTimeEnd", type: "Uint" },
2608
+ 24: { name: "ChapterFlagHidden", type: "Uint" },
2609
+ 1432: { name: "ChapterFlagEnabled", type: "Uint" },
2610
+ 11879: { name: "ChapterSegmentUID", type: "Binary" },
2611
+ 11964: { name: "ChapterSegmentEditionUID", type: "Uint" },
2612
+ 9155: { name: "ChapterPhysicalEquiv", type: "Uint" },
2613
+ 15: { name: "ChapterTrack", type: "Container" },
2614
+ 9: { name: "ChapterTrackNumber", type: "Uint" },
2615
+ 0: { name: "ChapterDisplay", type: "Container" },
2616
+ 5: { name: "ChapString", type: "String" },
2617
+ 892: { name: "ChapLanguage", type: "String" },
2618
+ 894: { name: "ChapCountry", type: "String" },
2619
+ 10564: { name: "ChapProcess", type: "Container" },
2620
+ 10581: { name: "ChapProcessCodecID", type: "Uint" },
2621
+ 1293: { name: "ChapProcessPrivate", type: "Binary" },
2622
+ 10513: { name: "ChapProcessCommand", type: "Container" },
2623
+ 10530: { name: "ChapProcessTime", type: "Uint" },
2624
+ 10547: { name: "ChapProcessData", type: "Binary" },
2625
+ 39109479: { name: "Tags", type: "Container" },
2626
+ 13171: { name: "Tag", type: "Container" },
2627
+ 9152: { name: "Targets", type: "Container" },
2628
+ 10442: { name: "TargetTypeValue", type: "Uint" },
2629
+ 9162: { name: "TargetType", type: "String" },
2630
+ 9157: { name: "TagTrackUID", type: "Uint" },
2631
+ 9161: { name: "TagEditionUID", type: "Uint" },
2632
+ 9156: { name: "TagChapterUID", type: "Uint" },
2633
+ 9158: { name: "TagAttachmentUID", type: "Uint" },
2634
+ 10184: { name: "SimpleTag", type: "Container" },
2635
+ 1443: { name: "TagName", type: "String" },
2636
+ 1146: { name: "TagLanguage", type: "String" },
2637
+ 1156: { name: "TagDefault", type: "Uint" },
2638
+ 1159: { name: "TagString", type: "String" },
2639
+ 1157: { name: "TagBinary", type: "Binary" }
2640
+ };
2641
+ function doInherit(newClass, baseClass) {
2642
+ newClass.prototype = Object.create(baseClass.prototype);
2643
+ newClass.prototype.constructor = newClass;
2644
+ }
2645
+ function WebmBase(name, type) {
2646
+ this.name = name || "Unknown";
2647
+ this.type = type || "Unknown";
2648
+ }
2649
+ WebmBase.prototype.updateBySource = function() {
2650
+ };
2651
+ WebmBase.prototype.setSource = function(source) {
2652
+ this.source = source;
2653
+ this.updateBySource();
2654
+ };
2655
+ WebmBase.prototype.updateByData = function() {
2656
+ };
2657
+ WebmBase.prototype.setData = function(data) {
2658
+ this.data = data;
2659
+ this.updateByData();
2660
+ };
2661
+ function WebmUint(name, type) {
2662
+ WebmBase.call(this, name, type || "Uint");
2663
+ }
2664
+ doInherit(WebmUint, WebmBase);
2665
+ function padHex(hex) {
2666
+ return hex.length % 2 === 1 ? "0" + hex : hex;
2667
+ }
2668
+ WebmUint.prototype.updateBySource = function() {
2669
+ this.data = "";
2670
+ for (var i3 = 0; i3 < this.source.length; i3++) {
2671
+ var hex = this.source[i3].toString(16);
2672
+ this.data += padHex(hex);
2673
+ }
2674
+ };
2675
+ WebmUint.prototype.updateByData = function() {
2676
+ var length = this.data.length / 2;
2677
+ this.source = new Uint8Array(length);
2678
+ for (var i3 = 0; i3 < length; i3++) {
2679
+ var hex = this.data.substr(i3 * 2, 2);
2680
+ this.source[i3] = parseInt(hex, 16);
2681
+ }
2682
+ };
2683
+ WebmUint.prototype.getValue = function() {
2684
+ return parseInt(this.data, 16);
2685
+ };
2686
+ WebmUint.prototype.setValue = function(value) {
2687
+ this.setData(padHex(value.toString(16)));
2688
+ };
2689
+ function WebmFloat(name, type) {
2690
+ WebmBase.call(this, name, type || "Float");
2691
+ }
2692
+ doInherit(WebmFloat, WebmBase);
2693
+ WebmFloat.prototype.getFloatArrayType = function() {
2694
+ return this.source && this.source.length === 4 ? Float32Array : Float64Array;
2695
+ };
2696
+ WebmFloat.prototype.updateBySource = function() {
2697
+ var byteArray = this.source.reverse();
2698
+ var floatArrayType = this.getFloatArrayType();
2699
+ var floatArray = new floatArrayType(byteArray.buffer);
2700
+ this.data = floatArray[0];
2701
+ };
2702
+ WebmFloat.prototype.updateByData = function() {
2703
+ var floatArrayType = this.getFloatArrayType();
2704
+ var floatArray = new floatArrayType([this.data]);
2705
+ var byteArray = new Uint8Array(floatArray.buffer);
2706
+ this.source = byteArray.reverse();
2707
+ };
2708
+ WebmFloat.prototype.getValue = function() {
2709
+ return this.data;
2710
+ };
2711
+ WebmFloat.prototype.setValue = function(value) {
2712
+ this.setData(value);
2713
+ };
2714
+ function WebmContainer(name, type) {
2715
+ WebmBase.call(this, name, type || "Container");
2716
+ }
2717
+ doInherit(WebmContainer, WebmBase);
2718
+ WebmContainer.prototype.readByte = function() {
2719
+ return this.source[this.offset++];
2720
+ };
2721
+ WebmContainer.prototype.readUint = function() {
2722
+ var firstByte = this.readByte();
2723
+ var bytes = 8 - firstByte.toString(2).length;
2724
+ var value = firstByte - (1 << 7 - bytes);
2725
+ for (var i3 = 0; i3 < bytes; i3++) {
2726
+ value *= 256;
2727
+ value += this.readByte();
2728
+ }
2729
+ return value;
2730
+ };
2731
+ WebmContainer.prototype.updateBySource = function() {
2732
+ this.data = [];
2733
+ for (this.offset = 0; this.offset < this.source.length; this.offset = end) {
2734
+ var id = this.readUint();
2735
+ var len = this.readUint();
2736
+ var end = Math.min(this.offset + len, this.source.length);
2737
+ var data = this.source.slice(this.offset, end);
2738
+ var info = sections[id] || { name: "Unknown", type: "Unknown" };
2739
+ var ctr = WebmBase;
2740
+ switch (info.type) {
2741
+ case "Container":
2742
+ ctr = WebmContainer;
2743
+ break;
2744
+ case "Uint":
2745
+ ctr = WebmUint;
2746
+ break;
2747
+ case "Float":
2748
+ ctr = WebmFloat;
2749
+ break;
2750
+ }
2751
+ var section = new ctr(info.name, info.type);
2752
+ section.setSource(data);
2753
+ this.data.push({
2754
+ id,
2755
+ idHex: id.toString(16),
2756
+ data: section
2757
+ });
2758
+ }
2759
+ };
2760
+ WebmContainer.prototype.writeUint = function(x3, draft) {
2761
+ for (var bytes = 1, flag = 128; x3 >= flag && bytes < 8; bytes++, flag *= 128) {
2762
+ }
2763
+ if (!draft) {
2764
+ var value = flag + x3;
2765
+ for (var i3 = bytes - 1; i3 >= 0; i3--) {
2766
+ var c3 = value % 256;
2767
+ this.source[this.offset + i3] = c3;
2768
+ value = (value - c3) / 256;
2769
+ }
2770
+ }
2771
+ this.offset += bytes;
2772
+ };
2773
+ WebmContainer.prototype.writeSections = function(draft) {
2774
+ this.offset = 0;
2775
+ for (var i3 = 0; i3 < this.data.length; i3++) {
2776
+ var section = this.data[i3], content = section.data.source, contentLength = content.length;
2777
+ this.writeUint(section.id, draft);
2778
+ this.writeUint(contentLength, draft);
2779
+ if (!draft) {
2780
+ this.source.set(content, this.offset);
2781
+ }
2782
+ this.offset += contentLength;
2783
+ }
2784
+ return this.offset;
2785
+ };
2786
+ WebmContainer.prototype.updateByData = function() {
2787
+ var length = this.writeSections("draft");
2788
+ this.source = new Uint8Array(length);
2789
+ this.writeSections();
2790
+ };
2791
+ WebmContainer.prototype.getSectionById = function(id) {
2792
+ for (var i3 = 0; i3 < this.data.length; i3++) {
2793
+ var section = this.data[i3];
2794
+ if (section.id === id) {
2795
+ return section.data;
2796
+ }
2797
+ }
2798
+ return null;
2799
+ };
2800
+ function WebmFile(source) {
2801
+ WebmContainer.call(this, "File", "File");
2802
+ this.setSource(source);
2803
+ }
2804
+ doInherit(WebmFile, WebmContainer);
2805
+ WebmFile.prototype.fixDuration = function(duration, options) {
2806
+ var logger = options && options.logger;
2807
+ if (logger === void 0) {
2808
+ logger = function(message) {
2809
+ console.log(message);
2810
+ };
2811
+ } else if (!logger) {
2812
+ logger = function() {
2813
+ };
2814
+ }
2815
+ var segmentSection = this.getSectionById(139690087);
2816
+ if (!segmentSection) {
2817
+ logger("[fix-webm-duration] Segment section is missing");
2818
+ return false;
2819
+ }
2820
+ var infoSection = segmentSection.getSectionById(88713574);
2821
+ if (!infoSection) {
2822
+ logger("[fix-webm-duration] Info section is missing");
2823
+ return false;
2824
+ }
2825
+ var timeScaleSection = infoSection.getSectionById(710577);
2826
+ if (!timeScaleSection) {
2827
+ logger("[fix-webm-duration] TimecodeScale section is missing");
2828
+ return false;
2829
+ }
2830
+ var durationSection = infoSection.getSectionById(1161);
2831
+ if (durationSection) {
2832
+ if (durationSection.getValue() <= 0) {
2833
+ logger(`[fix-webm-duration] Duration section is present, but the value is ${durationSection.getValue()}`);
2834
+ durationSection.setValue(duration);
2835
+ } else {
2836
+ logger(`[fix-webm-duration] Duration section is present, and the value is ${durationSection.getValue()}`);
2837
+ return false;
2838
+ }
2839
+ } else {
2840
+ logger("[fix-webm-duration] Duration section is missing");
2841
+ durationSection = new WebmFloat("Duration", "Float");
2842
+ durationSection.setValue(duration);
2843
+ infoSection.data.push({
2844
+ id: 1161,
2845
+ data: durationSection
2846
+ });
2847
+ }
2848
+ timeScaleSection.setValue(1e6);
2849
+ infoSection.updateByData();
2850
+ segmentSection.updateByData();
2851
+ this.updateByData();
2852
+ return true;
2853
+ };
2854
+ WebmFile.prototype.toBlob = function(mimeType) {
2855
+ return new Blob([this.source.buffer], { type: mimeType || "video/webm" });
2856
+ };
2857
+ function fixWebmDuration3(blob, duration, callback, options) {
2858
+ if (typeof callback === "object") {
2859
+ options = callback;
2860
+ callback = void 0;
2861
+ }
2862
+ if (!callback) {
2863
+ return new Promise(function(resolve) {
2864
+ fixWebmDuration3(blob, duration, resolve, options);
2865
+ });
2866
+ }
2867
+ try {
2868
+ var reader = new FileReader();
2869
+ reader.onloadend = function() {
2870
+ try {
2871
+ var file = new WebmFile(new Uint8Array(reader.result));
2872
+ if (file.fixDuration(duration, options)) {
2873
+ blob = file.toBlob(blob.type);
2874
+ }
2875
+ } catch (ex) {
2876
+ }
2877
+ callback(blob);
2878
+ };
2879
+ reader.readAsArrayBuffer(blob);
2880
+ } catch (ex) {
2881
+ callback(blob);
2882
+ }
2883
+ }
2884
+ fixWebmDuration3.default = fixWebmDuration3;
2885
+ return fixWebmDuration3;
2886
+ });
2887
+ }
2888
+ });
2889
+
2403
2890
  // node_modules/file-saver/dist/FileSaver.min.js
2404
2891
  var require_FileSaver_min = __commonJS({
2405
2892
  "node_modules/file-saver/dist/FileSaver.min.js"(exports, module) {
@@ -8658,6 +9145,7 @@ var BaseDetection = class {
8658
9145
  // objectDetection
8659
9146
  runningMode: this.runningMode
8660
9147
  });
9148
+ console.log("BaseDetection initializeDetector", this.detectorType);
8661
9149
  }
8662
9150
  stopDetection() {
8663
9151
  this.animationFrameId && clearTimeout(this.animationFrameId);
@@ -8669,6 +9157,7 @@ var BaseDetection = class {
8669
9157
  }
8670
9158
  enableCam(cameraStream) {
8671
9159
  var _a2;
9160
+ console.log("BaseDetection enableCam");
8672
9161
  if (!this.detector) {
8673
9162
  console.log("Wait! Detector not loaded yet.");
8674
9163
  return;
@@ -8693,7 +9182,6 @@ var BaseDetection = class {
8693
9182
  }
8694
9183
  cameraStream && !this.video.srcObject && (this.video.srcObject = cameraStream);
8695
9184
  this.video.play();
8696
- this.startTime = new Date(Date.now());
8697
9185
  const that = this;
8698
9186
  (_a2 = this.video) == null ? void 0 : _a2.addEventListener("loadeddata", () => that.predictWebcam());
8699
9187
  const style = document.createElement("style");
@@ -8711,6 +9199,7 @@ var BaseDetection = class {
8711
9199
  }
8712
9200
  `;
8713
9201
  document.getElementsByTagName("head")[0].appendChild(style);
9202
+ console.log("BaseDetection enableCam OK");
8714
9203
  }
8715
9204
  async predictWebcam() {
8716
9205
  if (this.lastVideoTime === -1) {
@@ -8736,8 +9225,8 @@ var BaseDetection = class {
8736
9225
  description: this.alertTranslate(description),
8737
9226
  type,
8738
9227
  category: description,
8739
- begin: Date.now() - this.startTime.getTime(),
8740
- end: Date.now() - this.startTime.getTime()
9228
+ begin: 0,
9229
+ end: 0
8741
9230
  });
8742
9231
  if (this.options.onRealtimeAlertsCallback == null)
8743
9232
  this.error && (this.error.innerText = description);
@@ -8748,8 +9237,8 @@ var BaseDetection = class {
8748
9237
  description: this.alertTranslate(description),
8749
9238
  type,
8750
9239
  category: description,
8751
- begin: Date.now() - this.startTime.getTime(),
8752
- end: Date.now() - this.startTime.getTime()
9240
+ begin: 0,
9241
+ end: 0
8753
9242
  });
8754
9243
  this.error && (this.error.innerText = "");
8755
9244
  }
@@ -8839,11 +9328,13 @@ var FaceDetection = class extends BaseDetection {
8839
9328
  );
8840
9329
  this.emmitedPositionAlert = false;
8841
9330
  this.emmitedFaceAlert = false;
9331
+ console.log("FaceDetection constructor");
9332
+ this.numFacesSent = -1;
8842
9333
  }
8843
9334
  stopDetection() {
8844
9335
  super.stopDetection();
8845
9336
  if (this.emmitedFaceAlert) {
8846
- this.handleOk("face_ok", "face_detection_on_stream");
9337
+ this.handleOk("face_stop", "face_detection_on_stream");
8847
9338
  }
8848
9339
  }
8849
9340
  // displayVideoDetections(result: { detections: any; }) {
@@ -9006,6 +9497,8 @@ var FaceDetection = class extends BaseDetection {
9006
9497
  }
9007
9498
  verify(result) {
9008
9499
  var _a2;
9500
+ console.log("this.numFacesSent", this.numFacesSent);
9501
+ console.log("result.detections.length", result.detections.length);
9009
9502
  if (((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectFace) && result.detections.length !== this.numFacesSent) {
9010
9503
  this.numFacesSent = result.detections.length;
9011
9504
  if (result.detections.length === 0) {
@@ -12209,46 +12702,6 @@ function isMobileDevice() {
12209
12702
  return /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
12210
12703
  }
12211
12704
 
12212
- // src/plugins/insights.ts
12213
- var backendService;
12214
- var init = (backend) => {
12215
- backendService = backend;
12216
- return backendService;
12217
- };
12218
- var eventNames = {
12219
- DEVICES_CHECKED: "devices_checked",
12220
- START: "start",
12221
- FINISH: "finish",
12222
- ERROR: "error",
12223
- UPLOAD: "upload",
12224
- UPLOAD_FILE: "upload_file",
12225
- DOWNLOAD_VIDEO: "download_video",
12226
- BUFFER_SIZE: "buffer_size",
12227
- ANOTHER_STREAM: "another_stream",
12228
- CHANGE_DEVICE: "change_device",
12229
- STOP_SHARING_SCREEN: "stop_sharing_screen",
12230
- ERROR_RECORDER_RTC: "error_recorder_rtc",
12231
- BROWSER_NOT_SUPPORTED: "browser_not_supported",
12232
- SAVE_ON_SESSION: "save_on_session"
12233
- };
12234
- var log = (eventName, properties) => backendService && backendService.log(eventName, properties);
12235
- var trackers = {
12236
- registerDevicesChecked: (proctoringId2, success, description) => log(eventNames.DEVICES_CHECKED, { proctoringId: proctoringId2, success, description }),
12237
- registerStart: (proctoringId2, success, description) => log(eventNames.START, { proctoringId: proctoringId2, success, description }),
12238
- registerFinish: (proctoringId2, success, description) => log(eventNames.FINISH, { proctoringId: proctoringId2, success, description }),
12239
- registerError: (proctoringId2, description) => log(eventNames.ERROR, { proctoringId: proctoringId2, description }),
12240
- registerBrowserNotSupported: (proctoringId2, description) => log(eventNames.BROWSER_NOT_SUPPORTED, { proctoringId: proctoringId2, description }),
12241
- registerUpload: (proctoringId2, success, description, serviceType, uploadTime) => log(eventNames.UPLOAD, { proctoringId: proctoringId2, success, description, serviceType, uploadTime }),
12242
- registerUploadFile: (proctoringId2, description, fileType) => log(eventNames.UPLOAD_FILE, { proctoringId: proctoringId2, description, fileType }),
12243
- registerChangeDevice: (proctoringId2, inOrOut, description) => log(eventNames.CHANGE_DEVICE, { proctoringId: proctoringId2, inOrOut, description }),
12244
- registerStopSharingScreen: (proctoringId2, description) => log(eventNames.STOP_SHARING_SCREEN, { proctoringId: proctoringId2, description }),
12245
- registerErrorRecorderRTC: (proctoringId2, description) => log(eventNames.ERROR_RECORDER_RTC, { proctoringId: proctoringId2, description }),
12246
- registerDownloadFile: (proctoringId2, description) => log(eventNames.DOWNLOAD_VIDEO, { proctoringId: proctoringId2, description }),
12247
- registerOnBufferSizeError: (proctoringId2, description) => log(eventNames.BUFFER_SIZE, { proctoringId: proctoringId2, description }),
12248
- registerAnotherStream: (proctoringId2, description) => log(eventNames.ANOTHER_STREAM, { proctoringId: proctoringId2, description }),
12249
- registerSaveOnSession: (proctoringId2, description) => log(eventNames.SAVE_ON_SESSION, { proctoringId: proctoringId2, description })
12250
- };
12251
-
12252
12705
  // src/plugins/recorder.ts
12253
12706
  var proctoringId;
12254
12707
  function setRecorderProctoringId(id) {
@@ -12261,6 +12714,7 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12261
12714
  let lastEvent;
12262
12715
  let bufferSize;
12263
12716
  bufferSize = 0;
12717
+ let startTime;
12264
12718
  let recorderOptions = {
12265
12719
  // eslint-disable-next-line no-useless-escape
12266
12720
  mimeType: "video/webm",
@@ -12280,59 +12734,106 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12280
12734
  audioBitsPerSecond: 64 * 1e3
12281
12735
  };
12282
12736
  }
12283
- const mediaRecorder = new MediaRecorder(stream, recorderOptions);
12284
- mediaRecorder.ondataavailable = (e3) => {
12285
- bufferSize = bufferSize + e3.data.size;
12286
- if (e3.data.size > 0) {
12287
- buffer.push(e3.data);
12288
- }
12289
- if (!stopped) {
12290
- if (lastEvent && e3.data.size === lastEvent.data.size || e3.data.size === 0) {
12291
- proctoringId && lastEvent && e3.data.size === lastEvent.data.size && trackers.registerOnBufferSizeError(
12292
- proctoringId,
12293
- `onBufferSizeError: Recorder size freezed: ${e3.data.size} Mb`
12294
- );
12295
- proctoringId && e3.data.size === 0 && trackers.registerOnBufferSizeError(
12296
- proctoringId,
12297
- `onBufferSizeError: Recorder size equal 0 Mb`
12298
- );
12299
- onBufferSizeErrorCallback && onBufferSizeErrorCallback();
12737
+ function buildMediaRecorder(stream2, recorderOptions2) {
12738
+ const tracks = stream2.getTracks();
12739
+ if (tracks.length == 0) {
12740
+ throw new Error("No tracks found");
12741
+ }
12742
+ const invalidTracks = tracks.find((t3) => t3.readyState != "live");
12743
+ if (invalidTracks) {
12744
+ throw new Error("Track not live: " + invalidTracks.label);
12745
+ }
12746
+ console.log("buildMediaRecorder tracks OK");
12747
+ let mediaRecorder2 = new MediaRecorder(stream2, recorderOptions2);
12748
+ console.log("buildMediaRecorder mediaRecorder OK");
12749
+ mediaRecorder2.ondataavailable = (e3) => {
12750
+ bufferSize = bufferSize + e3.data.size;
12751
+ if (e3.data.size > 0) {
12752
+ buffer.push(e3.data);
12300
12753
  }
12301
- lastEvent = e3;
12302
- } else {
12303
- if (audio && mediaRecorder.state == "inactive") {
12304
- const blob = new Blob(buffer, { type: "audio/webm" });
12305
- buffer = [blob];
12754
+ if (stopped) {
12755
+ console.log("buildMediaRecorder ondataavailable stopped");
12756
+ resolvePromise && resolvePromise();
12306
12757
  }
12307
- resolvePromise && resolvePromise();
12308
- }
12309
- };
12310
- function startRecording() {
12311
- return new Promise((resolve) => {
12312
- resolvePromise = resolve;
12313
- mediaRecorder.start();
12314
- bufferSize = 0;
12315
- stopped = false;
12316
- if (onBufferSizeError) {
12317
- onBufferSizeInterval = setInterval(async () => {
12318
- await mediaRecorder.requestData();
12319
- }, 3e4);
12758
+ };
12759
+ return mediaRecorder2;
12760
+ }
12761
+ let mediaRecorder = buildMediaRecorder(stream, recorderOptions);
12762
+ async function startRecorder(recorder2) {
12763
+ return new Promise((resolve, reject) => {
12764
+ var _a2, _b;
12765
+ let started = false;
12766
+ recorder2.onstart = () => {
12767
+ started = true;
12768
+ console.log("recorder onstart");
12769
+ resolve();
12770
+ };
12771
+ recorder2.onerror = (ev) => {
12772
+ console.error("Recorder error event:", ev);
12773
+ stream.getTracks().forEach((t3) => console.log(t3.readyState));
12774
+ if ("error" in ev) {
12775
+ const err = ev.error;
12776
+ console.error("Error name:", err == null ? void 0 : err.name);
12777
+ console.error("Error message:", err == null ? void 0 : err.message);
12778
+ reject(err || ev);
12779
+ } else {
12780
+ console.warn("Evento sem propriedade error");
12781
+ reject(ev);
12782
+ }
12783
+ };
12784
+ try {
12785
+ console.log("State antes do start:", recorder2.state);
12786
+ recorder2.start(1e4);
12787
+ startTime = new Date(Date.now());
12788
+ } catch (e3) {
12789
+ console.error("Recorder erro ao chamar start event:", e3);
12790
+ console.error("Erro real:", e3, e3 == null ? void 0 : e3.error, (_a2 = e3 == null ? void 0 : e3.error) == null ? void 0 : _a2.name, (_b = e3 == null ? void 0 : e3.error) == null ? void 0 : _b.message);
12791
+ console.error("Erro real 2:", e3, e3 == null ? void 0 : e3.message, e3 == null ? void 0 : e3.name);
12792
+ stream.getTracks().forEach((t3) => console.log(t3.readyState));
12793
+ return reject(e3);
12320
12794
  }
12795
+ setTimeout(() => {
12796
+ if (!started) {
12797
+ console.error("Timeout ao iniciar o recorder");
12798
+ reject(new Error("Timeout ao iniciar o recorder"));
12799
+ }
12800
+ }, 2e3);
12321
12801
  });
12322
12802
  }
12803
+ async function startRecording() {
12804
+ try {
12805
+ await startRecorder(mediaRecorder);
12806
+ if (mediaRecorder.state === "recording") {
12807
+ bufferSize = 0;
12808
+ stopped = false;
12809
+ return;
12810
+ } else {
12811
+ console.log("Recorder n\xE3o est\xE1 em estado recording ap\xF3s start");
12812
+ }
12813
+ } catch (e3) {
12814
+ console.error("Erro ao iniciar o recorder:", e3);
12815
+ await new Promise((r3) => setTimeout(r3, 300));
12816
+ throw e3;
12817
+ }
12818
+ return;
12819
+ }
12323
12820
  function stopRecording() {
12324
12821
  return new Promise((resolve) => {
12325
12822
  if (mediaRecorder.state == "recording") {
12823
+ console.log("stopRecording Recorder est\xE1 em estado recording, iniciando stop");
12326
12824
  resolvePromise = resolve;
12327
- mediaRecorder.stop();
12825
+ mediaRecorder.onstop = () => {
12826
+ console.log("recorder onstop");
12827
+ };
12328
12828
  stopped = true;
12329
- clearInterval(onBufferSizeInterval);
12330
- stream.getTracks().forEach((el) => {
12331
- el.stop();
12332
- });
12829
+ mediaRecorder.stop();
12333
12830
  } else {
12831
+ console.log("stopRecording Recorder n\xE3o est\xE1 em estado recording");
12334
12832
  resolve();
12335
12833
  }
12834
+ stream.getTracks().forEach((el) => {
12835
+ el.stop();
12836
+ });
12336
12837
  });
12337
12838
  }
12338
12839
  function pauseRecording() {
@@ -12358,16 +12859,60 @@ function recorder(stream, buffer, onBufferSizeError = false, onBufferSizeErrorCa
12358
12859
  function getBufferSize() {
12359
12860
  return bufferSize;
12360
12861
  }
12862
+ function getStartTime() {
12863
+ return startTime;
12864
+ }
12361
12865
  return {
12362
12866
  startRecording,
12363
12867
  stopRecording,
12364
12868
  pauseRecording,
12365
12869
  resumeRecording,
12366
12870
  recorderOptions,
12367
- getBufferSize
12871
+ getBufferSize,
12872
+ getStartTime
12368
12873
  };
12369
12874
  }
12370
12875
 
12876
+ // src/plugins/insights.ts
12877
+ var backendService;
12878
+ var init = (backend) => {
12879
+ backendService = backend;
12880
+ return backendService;
12881
+ };
12882
+ var eventNames = {
12883
+ DEVICES_CHECKED: "devices_checked",
12884
+ START: "start",
12885
+ FINISH: "finish",
12886
+ ERROR: "error",
12887
+ UPLOAD: "upload",
12888
+ UPLOAD_FILE: "upload_file",
12889
+ DOWNLOAD_VIDEO: "download_video",
12890
+ BUFFER_SIZE: "buffer_size",
12891
+ ANOTHER_STREAM: "another_stream",
12892
+ CHANGE_DEVICE: "change_device",
12893
+ STOP_SHARING_SCREEN: "stop_sharing_screen",
12894
+ ERROR_RECORDER_RTC: "error_recorder_rtc",
12895
+ BROWSER_NOT_SUPPORTED: "browser_not_supported",
12896
+ SAVE_ON_SESSION: "save_on_session"
12897
+ };
12898
+ var log = (eventName, properties) => backendService && backendService.log(eventName, properties);
12899
+ var trackers = {
12900
+ registerDevicesChecked: (proctoringId2, success, description) => log(eventNames.DEVICES_CHECKED, { proctoringId: proctoringId2, success, description }),
12901
+ registerStart: (proctoringId2, success, description) => log(eventNames.START, { proctoringId: proctoringId2, success, description }),
12902
+ registerFinish: (proctoringId2, success, description) => log(eventNames.FINISH, { proctoringId: proctoringId2, success, description }),
12903
+ registerError: (proctoringId2, description) => log(eventNames.ERROR, { proctoringId: proctoringId2, description }),
12904
+ registerBrowserNotSupported: (proctoringId2, description) => log(eventNames.BROWSER_NOT_SUPPORTED, { proctoringId: proctoringId2, description }),
12905
+ registerUpload: (proctoringId2, success, description, serviceType, uploadTime) => log(eventNames.UPLOAD, { proctoringId: proctoringId2, success, description, serviceType, uploadTime }),
12906
+ registerUploadFile: (proctoringId2, description, fileType) => log(eventNames.UPLOAD_FILE, { proctoringId: proctoringId2, description, fileType }),
12907
+ registerChangeDevice: (proctoringId2, inOrOut, description) => log(eventNames.CHANGE_DEVICE, { proctoringId: proctoringId2, inOrOut, description }),
12908
+ registerStopSharingScreen: (proctoringId2, description) => log(eventNames.STOP_SHARING_SCREEN, { proctoringId: proctoringId2, description }),
12909
+ registerErrorRecorderRTC: (proctoringId2, description) => log(eventNames.ERROR_RECORDER_RTC, { proctoringId: proctoringId2, description }),
12910
+ registerDownloadFile: (proctoringId2, description) => log(eventNames.DOWNLOAD_VIDEO, { proctoringId: proctoringId2, description }),
12911
+ registerOnBufferSizeError: (proctoringId2, description) => log(eventNames.BUFFER_SIZE, { proctoringId: proctoringId2, description }),
12912
+ registerAnotherStream: (proctoringId2, description) => log(eventNames.ANOTHER_STREAM, { proctoringId: proctoringId2, description }),
12913
+ registerSaveOnSession: (proctoringId2, description) => log(eventNames.SAVE_ON_SESSION, { proctoringId: proctoringId2, description })
12914
+ };
12915
+
12371
12916
  // src/new-flow/upload/UploadService.ts
12372
12917
  var UploadService = class {
12373
12918
  constructor(proctoringId2, backend) {
@@ -12653,12 +13198,12 @@ var VolumeMeter = class {
12653
13198
  async start(options = {}) {
12654
13199
  return new Promise((resolve, reject) => {
12655
13200
  try {
12656
- const audioContext = new AudioContext();
12657
- this.analyser = audioContext.createAnalyser();
12658
- const microphone = audioContext.createMediaStreamSource(this.stream);
13201
+ this.audioContext = new AudioContext();
13202
+ this.analyser = this.audioContext.createAnalyser();
13203
+ this.microphone = this.audioContext.createMediaStreamSource(this.stream);
12659
13204
  this.analyser.smoothingTimeConstant = 0.8;
12660
13205
  this.analyser.fftSize = 1024;
12661
- microphone.connect(this.analyser);
13206
+ this.microphone.connect(this.analyser);
12662
13207
  const processAudio = () => {
12663
13208
  const array = new Uint8Array(this.analyser.frequencyBinCount);
12664
13209
  this.analyser.getByteFrequencyData(array);
@@ -12677,9 +13222,13 @@ var VolumeMeter = class {
12677
13222
  });
12678
13223
  }
12679
13224
  stop() {
13225
+ var _a2, _b, _c2;
12680
13226
  if (this.animationFrameId !== null) {
12681
13227
  cancelAnimationFrame(this.animationFrameId);
12682
13228
  }
13229
+ (_a2 = this.audioContext) == null ? void 0 : _a2.close();
13230
+ (_b = this.microphone) == null ? void 0 : _b.disconnect();
13231
+ (_c2 = this.analyser) == null ? void 0 : _c2.disconnect();
12683
13232
  }
12684
13233
  getVolume() {
12685
13234
  return this.volume;
@@ -12691,6 +13240,7 @@ var VolumeMeter = class {
12691
13240
 
12692
13241
  // src/new-flow/recorders/CameraRecorder.ts
12693
13242
  var import_jszip_min = __toESM(require_jszip_min());
13243
+ var import_fix_webm_duration = __toESM(require_fix_webm_duration());
12694
13244
  var CameraRecorder = class {
12695
13245
  constructor(options, videoOptions, paramsConfig, backend, backendToken) {
12696
13246
  this.blobs = [];
@@ -12740,6 +13290,8 @@ var CameraRecorder = class {
12740
13290
  this.isCanvasLoopActive = false;
12741
13291
  this.hardwareStream = null;
12742
13292
  this.internalClonedStream = null;
13293
+ this.videoElement = null;
13294
+ this.duration = 0;
12743
13295
  this.currentRetries = 0;
12744
13296
  this.packageCount = 0;
12745
13297
  this.noiseWait = 20;
@@ -12760,7 +13312,12 @@ var CameraRecorder = class {
12760
13312
  if (((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectPerson) || ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectCellPhone)) {
12761
13313
  this.objectDetection = new ObjectDetection(
12762
13314
  {
12763
- onRealtimeAlertsCallback: (response) => this.options.onRealtimeAlertsCallback(response)
13315
+ onRealtimeAlertsCallback: (response) => {
13316
+ var _a3, _b2;
13317
+ response.begin = Date.now() - (((_a3 = this.getStartTime()) == null ? void 0 : _a3.getTime()) || 0);
13318
+ response.end = Date.now() - (((_b2 = this.getStartTime()) == null ? void 0 : _b2.getTime()) || 0);
13319
+ this.options.onRealtimeAlertsCallback(response);
13320
+ }
12764
13321
  },
12765
13322
  this.paramsConfig
12766
13323
  );
@@ -12769,7 +13326,12 @@ var CameraRecorder = class {
12769
13326
  if ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectFace) {
12770
13327
  this.faceDetection = new FaceDetection(
12771
13328
  {
12772
- onRealtimeAlertsCallback: (response) => this.options.onRealtimeAlertsCallback(response)
13329
+ onRealtimeAlertsCallback: (response) => {
13330
+ var _a3, _b2;
13331
+ response.begin = Date.now() - (((_a3 = this.getStartTime()) == null ? void 0 : _a3.getTime()) || 0);
13332
+ response.end = Date.now() - (((_b2 = this.getStartTime()) == null ? void 0 : _b2.getTime()) || 0);
13333
+ this.options.onRealtimeAlertsCallback(response);
13334
+ }
12773
13335
  },
12774
13336
  this.paramsConfig
12775
13337
  );
@@ -12795,25 +13357,20 @@ var CameraRecorder = class {
12795
13357
  }
12796
13358
  async bufferError(e3) {
12797
13359
  var _a2, _b;
12798
- console.log("buffer error Camera Recorder params " + this.paramsConfig.videoBehaviourParameters);
13360
+ console.log("buffer error Camera Recorder params ");
12799
13361
  const retryEnabled = ((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.retryEnabled) || false;
12800
13362
  const maxRetries = ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.maxRetries) || 3;
12801
13363
  if (retryEnabled && this.currentRetries < maxRetries) {
12802
13364
  await this.recordingStop();
12803
- await this.startRecording({
12804
- retry: true
12805
- });
13365
+ await this.startRecording();
12806
13366
  this.currentRetries++;
12807
13367
  this.options.onBufferSizeErrorCallback && this.options.onBufferSizeErrorCallback(this.cameraStream);
12808
13368
  } else {
12809
13369
  this.options.onBufferSizeErrorCallback && this.options.onBufferSizeErrorCallback();
12810
13370
  }
12811
13371
  }
12812
- async startRecording(options) {
12813
- var _a2, _b, _c2, _d, _e3, _f, _g, _h;
12814
- if ((((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.detectPerson) || ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectCellPhone) || ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectFace)) && !(options == null ? void 0 : options.retry)) {
12815
- await this.initializeDetectors();
12816
- }
13372
+ async startStream() {
13373
+ var _a2;
12817
13374
  const { cameraId, microphoneId, onBufferSizeErrorCallback } = this.options;
12818
13375
  const constraints = {
12819
13376
  audio: { deviceId: microphoneId },
@@ -12837,13 +13394,81 @@ var CameraRecorder = class {
12837
13394
  const track = this.cameraStream.getVideoTracks()[0];
12838
13395
  const settings = track.getSettings();
12839
13396
  let { width = 0, height = 0 } = settings;
13397
+ const isPortrait = (_a2 = screen.orientation) == null ? void 0 : _a2.type.includes("portrait");
13398
+ if (isPortrait && isMobileDevice()) {
13399
+ if (this.videoOptions.width == height && this.videoOptions.height == width) {
13400
+ [width, height] = [height, width];
13401
+ }
13402
+ }
13403
+ if (this.videoOptions.minWidth > width || this.videoOptions.minHeight > height) {
13404
+ throw STREAM_UNDER_MINIMUM_PERMITTED;
13405
+ } else if (this.videoOptions.width !== width || this.videoOptions.height !== height) {
13406
+ trackers.registerAnotherStream(
13407
+ this.proctoringId,
13408
+ `Maybe have another stream active
13409
+ Video Options: ${JSON.stringify(
13410
+ this.videoOptions,
13411
+ null,
13412
+ 2
13413
+ )}
13414
+ Setting: ${JSON.stringify(settings, null, 2)}`
13415
+ );
13416
+ throw ANOTHER_STREAM_ACTIVE;
13417
+ }
13418
+ }
13419
+ async stopStream() {
13420
+ if (this.cameraStream) {
13421
+ this.cameraStream.getTracks().forEach((track) => track.stop());
13422
+ }
13423
+ if (this.internalClonedStream) {
13424
+ this.internalClonedStream.getTracks().forEach((track) => track.stop());
13425
+ this.internalClonedStream = null;
13426
+ }
13427
+ if (this.hardwareStream) {
13428
+ this.hardwareStream.getTracks().forEach((track) => track.stop());
13429
+ this.hardwareStream = null;
13430
+ }
13431
+ }
13432
+ async waitForVideoFlow() {
13433
+ return new Promise((resolve) => {
13434
+ const check = () => {
13435
+ var _a2;
13436
+ if (this.videoElement && ((_a2 = this.videoElement) == null ? void 0 : _a2.readyState) >= 3) return resolve();
13437
+ else requestAnimationFrame(check);
13438
+ };
13439
+ check();
13440
+ });
13441
+ }
13442
+ async attachAndWarmup(stream) {
13443
+ this.videoElement = document.createElement("video");
13444
+ this.videoElement.srcObject = stream;
13445
+ this.videoElement.muted = true;
13446
+ await this.videoElement.play().catch((e3) => {
13447
+ });
13448
+ await new Promise((resolve) => {
13449
+ var _a2;
13450
+ if (this.videoElement && ((_a2 = this.videoElement) == null ? void 0 : _a2.readyState) >= 1) return resolve();
13451
+ if (this.videoElement)
13452
+ this.videoElement.onloadedmetadata = () => resolve();
13453
+ });
13454
+ console.log("CameraRecorder checking metadata ok");
13455
+ await this.waitForVideoFlow();
13456
+ console.log("CameraRecorder waiting for video flow ok");
13457
+ await new Promise((r3) => setTimeout(r3, 300));
13458
+ }
13459
+ async startRecording() {
13460
+ var _a2, _b, _c2, _d, _e3, _f, _g;
13461
+ console.log("CameraRecorder startRecording");
13462
+ await this.startStream();
13463
+ await this.attachAndWarmup(this.cameraStream);
12840
13464
  const {
12841
13465
  startRecording,
12842
13466
  stopRecording,
12843
13467
  pauseRecording,
12844
13468
  resumeRecording,
12845
13469
  recorderOptions,
12846
- getBufferSize
13470
+ getBufferSize,
13471
+ getStartTime
12847
13472
  } = recorder(
12848
13473
  this.cameraStream,
12849
13474
  // streamToRecord,
@@ -12858,44 +13483,50 @@ var CameraRecorder = class {
12858
13483
  this.recordingResume = resumeRecording;
12859
13484
  this.recorderOptions = recorderOptions;
12860
13485
  this.getBufferSize = getBufferSize;
12861
- this.recordingStart();
12862
- const isPortrait = (_d = screen.orientation) == null ? void 0 : _d.type.includes("portrait");
12863
- if (isPortrait && isMobileDevice()) {
12864
- if (this.videoOptions.width == height && this.videoOptions.height == width) {
12865
- [width, height] = [height, width];
13486
+ this.getStartTime = getStartTime;
13487
+ try {
13488
+ await new Promise((r3) => setTimeout(r3, 500));
13489
+ await this.recordingStart();
13490
+ } catch (error) {
13491
+ console.log("Camera Recorder error", error);
13492
+ this.stopRecording();
13493
+ const maxRetries = ((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.maxRetries) || 3;
13494
+ if (this.currentRetries < maxRetries) {
13495
+ console.log("Camera Recorder retry", this.currentRetries);
13496
+ this.currentRetries++;
13497
+ await this.startRecording();
13498
+ } else {
13499
+ throw error;
12866
13500
  }
12867
13501
  }
12868
- if (this.videoOptions.minWidth > width || this.videoOptions.minHeight > height) {
12869
- throw STREAM_UNDER_MINIMUM_PERMITTED;
12870
- } else if (this.videoOptions.width !== width || this.videoOptions.height !== height) {
12871
- trackers.registerAnotherStream(
12872
- this.proctoringId,
12873
- `Maybe have another stream active
12874
- Video Options: ${JSON.stringify(
12875
- this.videoOptions,
12876
- null,
12877
- 2
12878
- )}
12879
- Setting: ${JSON.stringify(settings, null, 2)}`
12880
- );
12881
- throw ANOTHER_STREAM_ACTIVE;
13502
+ if (((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.detectPerson) || ((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectCellPhone) || ((_d = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _d.detectFace)) {
13503
+ await this.initializeDetectors();
12882
13504
  }
12883
- ((_e3 = this.paramsConfig.imageBehaviourParameters) == null ? void 0 : _e3.useUploadImage) && this.options.proctoringType == "IMAGE" && this.photoShotsCycle();
12884
- if ((_f = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _f.detectFace) {
13505
+ if ((_e3 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _e3.detectFace) {
12885
13506
  await this.faceDetection.enableCam(this.cameraStream);
12886
13507
  }
12887
- if (((_g = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _g.detectPerson) || ((_h = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _h.detectCellPhone)) {
13508
+ if (((_f = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _f.detectPerson) || ((_g = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _g.detectCellPhone)) {
12888
13509
  await this.objectDetection.enableCam(this.cameraStream);
12889
13510
  }
12890
13511
  this.filesToUpload = [];
12891
13512
  if (this.options.proctoringType == "REALTIME") {
12892
- this.captureFrame();
13513
+ await this.startRealtimeCapture();
12893
13514
  }
12894
13515
  this.packageCount = 0;
13516
+ console.log("Camera Recorder started OK");
12895
13517
  }
12896
13518
  async stopRecording() {
13519
+ var _a2, _b, _c2, _d;
13520
+ console.log("Camera Recorder stopRecording");
12897
13521
  this.isCanvasLoopActive = false;
13522
+ this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
13523
+ this.objectDetection && this.objectDetection.detecting && this.objectDetection.stopDetection();
13524
+ clearInterval(this.imageInterval);
13525
+ clearInterval(this.sendFrameInterval);
13526
+ this.volumeMeter && this.volumeMeter.stop();
13527
+ this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
12898
13528
  this.recordingStop && await this.recordingStop();
13529
+ this.duration = Date.now() - ((_a2 = this.getStartTime()) == null ? void 0 : _a2.getTime()) || 0;
12899
13530
  try {
12900
13531
  if (this.animationFrameId) {
12901
13532
  cancelAnimationFrame(this.animationFrameId);
@@ -12912,19 +13543,23 @@ Setting: ${JSON.stringify(settings, null, 2)}`
12912
13543
  this.hardwareStream.getTracks().forEach((track) => track.stop());
12913
13544
  this.hardwareStream = null;
12914
13545
  }
13546
+ if (this.videoElement) {
13547
+ (_b = this.videoElement) == null ? void 0 : _b.remove();
13548
+ this.videoElement = null;
13549
+ }
13550
+ if (this.video) {
13551
+ (_c2 = this.video) == null ? void 0 : _c2.remove();
13552
+ }
13553
+ if (this.canvas) {
13554
+ (_d = this.canvas) == null ? void 0 : _d.remove();
13555
+ }
12915
13556
  } catch (e3) {
12916
13557
  console.error("Erro ao parar os streams de m\xEDdia.");
12917
13558
  }
12918
- this.faceDetection && this.faceDetection.detecting && this.faceDetection.stopDetection();
12919
- this.objectDetection && this.objectDetection.detecting && this.objectDetection.stopDetection();
12920
- clearInterval(this.imageInterval);
12921
- clearInterval(this.sendFrameInterval);
12922
13559
  if (this.options.proctoringType == "REALTIME" && this.upload && this.backendToken) {
12923
13560
  await this.sendPackage(this.filesToUpload);
12924
13561
  await this.filesToUpload.splice(0, this.filesToUpload.length);
12925
13562
  }
12926
- this.volumeMeter && this.volumeMeter.stop();
12927
- this.intervalNoiseDetection && clearInterval(this.intervalNoiseDetection);
12928
13563
  }
12929
13564
  async pauseRecording() {
12930
13565
  await this.recordingPause();
@@ -12932,35 +13567,6 @@ Setting: ${JSON.stringify(settings, null, 2)}`
12932
13567
  async resumeRecording() {
12933
13568
  await this.recordingResume();
12934
13569
  }
12935
- photoShotsCycle() {
12936
- let imageFile;
12937
- this.configImageCapture();
12938
- this.imageInterval = setInterval(async () => {
12939
- this.canvas.getContext("2d").drawImage(
12940
- this.video,
12941
- 0,
12942
- 0,
12943
- this.videoOptions.width,
12944
- this.videoOptions.height
12945
- );
12946
- const image_data_url = this.canvas.toDataURL("image/jpeg");
12947
- imageFile = await this.getFile(
12948
- image_data_url,
12949
- `${this.proctoringId}_${this.imageCount + 1}.jpg`,
12950
- "image/jpeg"
12951
- );
12952
- if (imageFile && this.upload && this.backendToken) {
12953
- this.upload.upload(
12954
- {
12955
- file: imageFile
12956
- },
12957
- this.backendToken,
12958
- true
12959
- );
12960
- this.imageCount++;
12961
- }
12962
- }, this.paramsConfig.imageBehaviourParameters.uploadInterval * 1e3);
12963
- }
12964
13570
  async getCurrentImageBase64() {
12965
13571
  if (!this.video || !this.canvas) {
12966
13572
  this.configImageCapture();
@@ -12991,30 +13597,35 @@ Setting: ${JSON.stringify(settings, null, 2)}`
12991
13597
  this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
12992
13598
  return this.canvas.toDataURL("image/jpeg");
12993
13599
  }
12994
- // captura um frame a cada intervalo de tempo definido no paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval!
12995
- captureFrame() {
12996
- var _a2, _b;
13600
+ async captureFrame() {
13601
+ var _a2;
12997
13602
  let imageFile;
12998
- this.configImageCapture();
12999
13603
  const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
13604
+ this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
13605
+ const image_data_url = this.canvas.toDataURL("image/jpeg");
13606
+ if (this.proctoringId == void 0) return;
13607
+ if (packSize == this.imageCount) {
13608
+ this.imageCount = 0;
13609
+ const framesToSend = [...this.filesToUpload];
13610
+ this.sendPackage(framesToSend);
13611
+ await this.filesToUpload.splice(0, this.filesToUpload.length);
13612
+ }
13613
+ let imageName = `${this.proctoringId}_${this.imageCount + 1}.jpg`;
13614
+ imageFile = await this.getFile(image_data_url, imageName, "image/jpeg");
13615
+ if (imageFile && imageFile.size > 10 && packSize > 0) {
13616
+ this.filesToUpload.push(imageFile);
13617
+ this.imageCount++;
13618
+ }
13619
+ }
13620
+ // inicia a captura de um frame a cada intervalo de tempo definido no paramsConfig.videoBehaviourParameters?.realtimeCaptureInterval!
13621
+ async startRealtimeCapture() {
13622
+ var _a2;
13623
+ this.configImageCapture();
13000
13624
  this.imageCount = 0;
13625
+ await this.captureFrame();
13001
13626
  this.imageInterval = setInterval(async () => {
13002
- this.canvas.getContext("2d").drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
13003
- const image_data_url = this.canvas.toDataURL("image/jpeg");
13004
- if (this.proctoringId == void 0) return;
13005
- if (packSize == this.imageCount) {
13006
- this.imageCount = 0;
13007
- const framesToSend = [...this.filesToUpload];
13008
- this.sendPackage(framesToSend);
13009
- await this.filesToUpload.splice(0, this.filesToUpload.length);
13010
- }
13011
- let imageName = `${this.proctoringId}_${this.imageCount + 1}.jpg`;
13012
- imageFile = await this.getFile(image_data_url, imageName, "image/jpeg");
13013
- if (imageFile && imageFile.size > 10 && packSize > 0) {
13014
- this.filesToUpload.push(imageFile);
13015
- this.imageCount++;
13016
- }
13017
- }, ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) * 1e3);
13627
+ await this.captureFrame();
13628
+ }, ((_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimeCaptureInterval) * 1e3);
13018
13629
  }
13019
13630
  // envia pacote de imagens
13020
13631
  async sendPackage(framesToSend) {
@@ -13022,7 +13633,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13022
13633
  let pending = false;
13023
13634
  let undeliveredPackagesCount = 0;
13024
13635
  const packSize = (_a2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _a2.realtimePackageSize;
13025
- const packCaptureInterval = ((_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval) + 1;
13636
+ const packCaptureInterval = (_b = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _b.realtimeCaptureInterval;
13026
13637
  if (this.upload && this.backendToken && !pending && this.filesToUpload.length > 0) {
13027
13638
  undeliveredPackagesCount = 0;
13028
13639
  pending = true;
@@ -13082,6 +13693,15 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13082
13693
  const settings = this.cameraStream.getVideoTracks()[0].getSettings();
13083
13694
  const settingsAudio = this.cameraStream.getAudioTracks()[0].getSettings();
13084
13695
  if (this.options.proctoringType == "VIDEO" || this.options.proctoringType == "REALTIME" || this.options.proctoringType == "IMAGE" && ((_a2 = this.paramsConfig.imageBehaviourParameters) == null ? void 0 : _a2.saveVideo)) {
13696
+ const rawBlob = new Blob(this.blobs, {
13697
+ type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
13698
+ });
13699
+ const fixedBlob = await (0, import_fix_webm_duration.default)(rawBlob, this.duration);
13700
+ const file = new File(
13701
+ [fixedBlob],
13702
+ `EP_${session.id}_camera_0.webm`,
13703
+ { type: rawBlob.type }
13704
+ );
13085
13705
  session.addRecording({
13086
13706
  device: `Audio
13087
13707
  Sample Rate: ${settingsAudio.sampleRate}
@@ -13089,9 +13709,7 @@ Setting: ${JSON.stringify(settings, null, 2)}`
13089
13709
 
13090
13710
  Video:
13091
13711
  ${JSON.stringify(this.recorderOptions)}`,
13092
- file: new File(this.blobs, `EP_${session.id}_camera_0.webm`, {
13093
- type: ((_b = this.recorderOptions) == null ? void 0 : _b.mimeType) || "video/webm"
13094
- }),
13712
+ file,
13095
13713
  origin: "Camera" /* Camera */
13096
13714
  });
13097
13715
  }
@@ -14210,6 +14828,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14210
14828
  return this.deviceCheckResult;
14211
14829
  }
14212
14830
  async runCheckDevicesFlow(options, _videoOptions, onModalConfirm, onModalCancel, onUpdate) {
14831
+ var _a2;
14213
14832
  if (_DeviceCheckerService.isModalOpen) {
14214
14833
  return Promise.reject("Modal j\xE1 est\xE1 aberto");
14215
14834
  }
@@ -14227,7 +14846,9 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14227
14846
  options,
14228
14847
  _videoOptions
14229
14848
  );
14230
- this.checkSpyScan();
14849
+ if ((_a2 = this.options) == null ? void 0 : _a2.useSpyScan) {
14850
+ await this.checkSpyScan();
14851
+ }
14231
14852
  const returnData = { cameraStream: this.cameraRecorder.cameraStream };
14232
14853
  this.onUpdateCb = (e3) => onUpdate(e3);
14233
14854
  const resultPromise = new Promise(
@@ -14282,6 +14903,10 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14282
14903
  if (_DeviceCheckerService.isModalOpen) {
14283
14904
  return Promise.reject();
14284
14905
  }
14906
+ this.allowedAmbient = false;
14907
+ this.allowedMicrophone = false;
14908
+ this.allowedAmbient = false;
14909
+ this.allowedPositionFace = false;
14285
14910
  _DeviceCheckerService.isModalOpen = true;
14286
14911
  this.DeviceCheckerUI = new DeviceCheckerUI(options, _videoOptions);
14287
14912
  try {
@@ -14319,8 +14944,8 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14319
14944
  resolve(response);
14320
14945
  });
14321
14946
  } catch (error) {
14947
+ this.DeviceCheckerUI && this.DeviceCheckerUI.closeModal();
14322
14948
  this.closeCheckDevices();
14323
- this.DeviceCheckerUI.closeModal();
14324
14949
  return Promise.reject(error);
14325
14950
  }
14326
14951
  }
@@ -14391,7 +15016,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14391
15016
  }
14392
15017
  async changeSelectedDevice({ cameraId, microphoneId }) {
14393
15018
  var _a2;
14394
- this.cameraRecorder.stopRecording && await this.cameraRecorder.stopRecording();
15019
+ this.cameraRecorder.stopStream && await this.cameraRecorder.stopStream();
14395
15020
  (_a2 = this.volumeMeter) == null ? void 0 : _a2.stop();
14396
15021
  this.faceDetection.stopDetection();
14397
15022
  this.cameraRecorder = new CameraRecorder(
@@ -14407,7 +15032,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14407
15032
  height: this.videoOptions.height
14408
15033
  }
14409
15034
  );
14410
- await this.cameraRecorder.startRecording();
15035
+ await this.cameraRecorder.startStream();
14411
15036
  this.videoDeviceInterface(this.cameraRecorder.cameraStream);
14412
15037
  this.audioDeviceInterface(this.cameraRecorder.cameraStream);
14413
15038
  return {
@@ -14415,6 +15040,10 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14415
15040
  };
14416
15041
  }
14417
15042
  async startCheckDevices(options = getDefaultProctoringOptions, _videoOptions) {
15043
+ this.allowedAmbient = false;
15044
+ this.allowedMicrophone = false;
15045
+ this.allowedAmbient = false;
15046
+ this.allowedPositionFace = false;
14418
15047
  this.DeviceCheckerUI && this.DeviceCheckerUI.setSelectOption(
14419
15048
  options,
14420
15049
  (e3) => this.changeSelectedDevice(e3)
@@ -14434,7 +15063,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14434
15063
  height: this.videoOptions.height
14435
15064
  }
14436
15065
  );
14437
- await this.cameraRecorder.startRecording();
15066
+ await this.cameraRecorder.startStream();
14438
15067
  this.videoDeviceInterface(this.cameraRecorder.cameraStream);
14439
15068
  this.audioDeviceInterface(this.cameraRecorder.cameraStream);
14440
15069
  if (this.DeviceCheckerUI) {
@@ -14451,7 +15080,7 @@ var _DeviceCheckerService = class _DeviceCheckerService {
14451
15080
  this.faceDetection.stopDetection();
14452
15081
  (_a2 = this.volumeMeter) == null ? void 0 : _a2.stop();
14453
15082
  this.volumeMedia = Math.ceil(this.volumeSum / this.volumeCounter);
14454
- this.cameraRecorder.stopRecording && await this.cameraRecorder.stopRecording();
15083
+ this.cameraRecorder.stopStream && await this.cameraRecorder.stopStream();
14455
15084
  this.DeviceCheckerUI = void 0;
14456
15085
  this.onUpdateCb = void 0;
14457
15086
  }
@@ -14524,7 +15153,7 @@ var CapturePhoto = class {
14524
15153
  // height: 480,
14525
15154
  // }
14526
15155
  );
14527
- await this.cameraRecorder.startRecording();
15156
+ await this.cameraRecorder.startStream();
14528
15157
  cameraContainer.srcObject = this.cameraRecorder.cameraStream;
14529
15158
  cameraContainer.play();
14530
15159
  }
@@ -14764,7 +15393,7 @@ var CapturePhoto = class {
14764
15393
  });
14765
15394
  }
14766
15395
  async closeInterface() {
14767
- await this.cameraRecorder.stopRecording();
15396
+ await this.cameraRecorder.stopStream();
14768
15397
  const authPhoto = document.querySelector("#authPhoto");
14769
15398
  authPhoto == null ? void 0 : authPhoto.remove();
14770
15399
  }
@@ -15047,6 +15676,22 @@ var ProctoringUploader = class {
15047
15676
  }
15048
15677
  },
15049
15678
  token
15679
+ ).catch(
15680
+ async (e3) => {
15681
+ console.log("Upload File Error", e3), trackers.registerError(this.proctoringId, `Upload File
15682
+ Name: ${rec.file.name}
15683
+ Error: ${e3.message}
15684
+ Size: ${e3.error}`);
15685
+ await uploadService.upload(
15686
+ {
15687
+ file: rec.file,
15688
+ onProgress: (progress) => {
15689
+ if (onProgress) onProgress(progress);
15690
+ }
15691
+ },
15692
+ token
15693
+ );
15694
+ }
15050
15695
  );
15051
15696
  if (result) {
15052
15697
  let fileType = "";
@@ -15268,54 +15913,6 @@ var AlertRecorder = class {
15268
15913
  }
15269
15914
  };
15270
15915
 
15271
- // src/new-flow/recorders/AudioRecorder.ts
15272
- var AudioRecorder = class {
15273
- constructor(options, audioParams) {
15274
- this.blobs = [];
15275
- this.options = {
15276
- cameraId: void 0,
15277
- microphoneId: void 0
15278
- };
15279
- this.audioParams = {
15280
- recordingBitrate: 128
15281
- };
15282
- audioParams && (this.audioParams = audioParams);
15283
- options && (this.options = options);
15284
- }
15285
- async startRecording() {
15286
- const constraints = {
15287
- audio: { deviceId: this.options.microphoneId || "default" }
15288
- };
15289
- this.audioStream = await navigator.mediaDevices.getUserMedia(constraints);
15290
- const { startRecording, stopRecording, pauseRecording, resumeRecording } = recorder(this.audioStream, this.blobs, void 0, void 0, true);
15291
- this.recordingStart = startRecording;
15292
- this.recordingStop = stopRecording;
15293
- this.recordingPause = pauseRecording;
15294
- this.recordingResume = resumeRecording;
15295
- this.recordingStart();
15296
- }
15297
- async pauseRecording() {
15298
- }
15299
- async resumeRecording() {
15300
- }
15301
- async stopRecording() {
15302
- this.recordingStop && await this.recordingStop();
15303
- }
15304
- async saveOnSession(session, start, end) {
15305
- session.addRecording({
15306
- device: "",
15307
- file: new File(
15308
- this.blobs,
15309
- `EP_${session.id}_audio_${start && end && `${start}_${end}` || "0"}.webm`,
15310
- {
15311
- type: "audio/webm"
15312
- }
15313
- ),
15314
- origin: "Mic" /* Mic */
15315
- });
15316
- }
15317
- };
15318
-
15319
15916
  // node_modules/@mediapipe/tasks-audio/audio_bundle.mjs
15320
15917
  var t2 = "undefined" != typeof self ? self : {};
15321
15918
  function e2() {
@@ -17555,7 +18152,6 @@ var NoiseRecorder = class {
17555
18152
  this.recordingInProgress = false;
17556
18153
  this.recordIndex = 1;
17557
18154
  this.countLoopTimes = 0;
17558
- this.examStartTime = 0;
17559
18155
  this.recordingStartTime = 0;
17560
18156
  this.recordingEndTime = 0;
17561
18157
  this.isSpeech = false;
@@ -17582,12 +18178,7 @@ var NoiseRecorder = class {
17582
18178
  this.proctoringId && this.backend && (this.upload = new UploadService(this.proctoringId, this.backend));
17583
18179
  }
17584
18180
  async startRecording() {
17585
- this.examStartTime = Date.now();
17586
18181
  await this.createAudioClassifier();
17587
- this.audioRecorder = new AudioRecorder(
17588
- void 0,
17589
- this.paramsConfig.audioBehaviourParameters
17590
- );
17591
18182
  this.intervalNoiseDetection = setInterval(
17592
18183
  () => this.onNoiseDetectedRecord(),
17593
18184
  200
@@ -17599,6 +18190,7 @@ var NoiseRecorder = class {
17599
18190
  await this.stopSoundRecord();
17600
18191
  await this.volumeMeter && this.volumeMeter.stop();
17601
18192
  this.audioWorkletNode && this.audioWorkletNode.disconnect();
18193
+ this.context && this.context.close();
17602
18194
  }
17603
18195
  async pauseRecording() {
17604
18196
  }
@@ -17607,7 +18199,7 @@ var NoiseRecorder = class {
17607
18199
  async saveOnSession(session) {
17608
18200
  }
17609
18201
  async onNoiseDetectedRecord() {
17610
- var _a2, _b, _c2, _d;
18202
+ var _a2, _b, _c2, _d, _e3, _f, _g, _h, _i3;
17611
18203
  if (!this.volumeMeter && this.cameraRecorder.cameraStream) {
17612
18204
  this.volumeMeter = new VolumeMeter(this.cameraRecorder.cameraStream);
17613
18205
  this.volumeMeter.start().catch((e3) => {
@@ -17629,7 +18221,7 @@ var NoiseRecorder = class {
17629
18221
  this.recordingChunks = [...this.preRollBuffer];
17630
18222
  const totalSamplesInBuffer = this.preRollBuffer.reduce((acc, chunk) => acc + chunk.length, 0);
17631
18223
  const bufferDurationMs = totalSamplesInBuffer / this.SAMPLE_RATE * 1e3;
17632
- const triggerTime = Date.now() - this.examStartTime;
18224
+ const triggerTime = Date.now() - (((_c2 = this.cameraRecorder.getStartTime()) == null ? void 0 : _c2.getTime()) || 0);
17633
18225
  this.recordingStartTime = triggerTime - bufferDurationMs;
17634
18226
  if (this.recordingStartTime < 0) this.recordingStartTime = 0;
17635
18227
  } else if (this.recordingInProgress) {
@@ -17637,15 +18229,19 @@ var NoiseRecorder = class {
17637
18229
  const currentRecordDuration = Date.now() - this.recordingStartTime;
17638
18230
  if (silenceDuration >= this.SILENCE_THRESHOLD && currentRecordDuration >= 3e3 && this.countLoopTimes > 4) {
17639
18231
  await this.stopSoundRecord();
17640
- if (((_c2 = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _c2.detectNoise) && !this.isSpeech) {
18232
+ if (((_d = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _d.detectNoise) && !this.isSpeech) {
17641
18233
  this.onRealtimeAlertsCallback({
18234
+ begin: Date.now() - (((_e3 = this.cameraRecorder.getStartTime()) == null ? void 0 : _e3.getTime()) || 0),
18235
+ end: Date.now() - (((_f = this.cameraRecorder.getStartTime()) == null ? void 0 : _f.getTime()) || 0),
17642
18236
  status: "ALERT",
17643
18237
  description: "Barulho detectado",
17644
18238
  type: "audio_detection_on_stream"
17645
18239
  });
17646
18240
  }
17647
- if (((_d = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _d.detectSpeech) && this.isSpeech) {
18241
+ if (((_g = this.paramsConfig.videoBehaviourParameters) == null ? void 0 : _g.detectSpeech) && this.isSpeech) {
17648
18242
  this.onRealtimeAlertsCallback({
18243
+ begin: Date.now() - (((_h = this.cameraRecorder.getStartTime()) == null ? void 0 : _h.getTime()) || 0),
18244
+ end: Date.now() - (((_i3 = this.cameraRecorder.getStartTime()) == null ? void 0 : _i3.getTime()) || 0),
17649
18245
  status: "ALERT",
17650
18246
  description: "Fala detectada",
17651
18247
  type: "audio_detection_on_stream"
@@ -17660,8 +18256,9 @@ var NoiseRecorder = class {
17660
18256
  }
17661
18257
  }
17662
18258
  async stopSoundRecord() {
18259
+ var _a2;
17663
18260
  if (!this.recordingInProgress && this.recordingChunks.length === 0) return;
17664
- this.recordingEndTime = Date.now() - this.examStartTime;
18261
+ this.recordingEndTime = Date.now() - (((_a2 = this.cameraRecorder.getStartTime()) == null ? void 0 : _a2.getTime()) || 0);
17665
18262
  if (this.optionsProctoring.proctoringType !== "REALTIME") return;
17666
18263
  const wavBlob = encodeToWav(this.recordingChunks, this.SAMPLE_RATE);
17667
18264
  const file = new File(
@@ -17803,10 +18400,12 @@ registerProcessor("audio-processor", AudioProcessor);
17803
18400
  `;
17804
18401
 
17805
18402
  // src/new-flow/recorders/ScreenRecorder.ts
18403
+ var import_fix_webm_duration2 = __toESM(require_fix_webm_duration());
17806
18404
  var ScreenRecorder = class {
17807
18405
  constructor(options) {
17808
18406
  this.blobs = [];
17809
18407
  this.blobsFinal = [];
18408
+ this.duration = 0;
17810
18409
  this.options = options;
17811
18410
  }
17812
18411
  setProctoringId(proctoringId2) {
@@ -17888,14 +18487,24 @@ var ScreenRecorder = class {
17888
18487
  async resumeRecording() {
17889
18488
  }
17890
18489
  async stopRecording() {
18490
+ var _a2;
17891
18491
  this.recordingStop && await this.recordingStop();
18492
+ this.duration = Date.now() - ((_a2 = this.startTime) == null ? void 0 : _a2.getTime()) || 0;
17892
18493
  }
17893
18494
  async saveOnSession(session) {
18495
+ if (isMobileDevice()) return;
18496
+ const rawBlob = new Blob(this.blobs, {
18497
+ type: "video/webm"
18498
+ });
18499
+ const fixedBlob = await (0, import_fix_webm_duration2.default)(rawBlob, this.duration);
18500
+ const file = new File(
18501
+ [fixedBlob],
18502
+ `EP_${session.id}_screen_0.webm`,
18503
+ { type: rawBlob.type }
18504
+ );
17894
18505
  session.addRecording({
17895
18506
  device: "",
17896
- file: new File(this.blobs, `EP_${session.id}_screen_0.webm`, {
17897
- type: "video/webm"
17898
- }),
18507
+ file,
17899
18508
  origin: "Screen" /* Screen */
17900
18509
  });
17901
18510
  }
@@ -20948,7 +21557,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
20948
21557
  this.connection = null;
20949
21558
  this.context = context;
20950
21559
  this.onRealtimeAlertsCallback = onRealtimeAlertsCallback;
20951
- console.log("context -> ", context);
20952
21560
  this.backend = new BackendService({
20953
21561
  type: (context == null ? void 0 : context.type) || "prod",
20954
21562
  token: context.token
@@ -20962,7 +21570,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
20962
21570
  try {
20963
21571
  this.transmissionOk = false;
20964
21572
  const response = await this.backend.externalCameraCheckTransmission("" + this.externalSessionId);
20965
- console.log(response);
20966
21573
  let attempts = 0;
20967
21574
  while (!this.transmissionOk && attempts <= 5) {
20968
21575
  await new Promise((resolve) => setTimeout(resolve, 2e3));
@@ -20979,16 +21586,13 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
20979
21586
  try {
20980
21587
  this.proctoringId = proctoringId2;
20981
21588
  const response = await this.backend.externalCameraStartTransmission("" + this.externalSessionId, proctoringId2);
20982
- console.log(response);
20983
21589
  } catch (error) {
20984
- console.error("Erro ao iniciar transmiss\xE3o:", error);
20985
21590
  throw new Error("N\xE3o foi poss\xEDvel iniciar a transmiss\xE3o.");
20986
21591
  }
20987
21592
  }
20988
21593
  async goToPositionGuide() {
20989
21594
  try {
20990
21595
  const response = await this.backend.goToExternalCameraPositionStep("" + this.externalSessionId);
20991
- console.log(response);
20992
21596
  } catch (error) {
20993
21597
  console.error("Erro ao enviar comando de Position:", error);
20994
21598
  throw new Error("N\xE3o foi poss\xEDvel enviar comando de Position Guide.");
@@ -20998,7 +21602,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
20998
21602
  if (this.connection) {
20999
21603
  const actionMessage = new ActionMessage();
21000
21604
  actionMessage.command = "Reset";
21001
- console.log("Enviando comando 'Reset' para o aplicativo...");
21002
21605
  this.connection.invoke(
21003
21606
  "SendAction",
21004
21607
  this.externalSessionId,
@@ -21012,7 +21615,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
21012
21615
  this.onTakePictureCallback = onTakePictureCallback;
21013
21616
  const actionMessage = new ActionMessage();
21014
21617
  actionMessage.command = "Capture";
21015
- console.log("Enviando comando 'Capture' para o aplicativo...");
21016
21618
  this.connection.invoke(
21017
21619
  "SendAction",
21018
21620
  this.externalSessionId,
@@ -21031,7 +21633,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
21031
21633
  await this.reset();
21032
21634
  const response = await this.backend.externalCameraStartSession();
21033
21635
  this.externalSessionId = response.externalSessionId;
21034
- console.log(this.externalSessionId);
21035
21636
  this.currentStep = 0 /* STARTED */;
21036
21637
  const pairingObject = {
21037
21638
  externalSessionId: this.externalSessionId,
@@ -21040,7 +21641,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
21040
21641
  };
21041
21642
  const pairingDataString = JSON.stringify(pairingObject);
21042
21643
  this.qrCodeBase64Image = await import_qrcode.default.toDataURL(pairingDataString);
21043
- console.log(this.qrCodeBase64Image);
21044
21644
  return this.qrCodeBase64Image;
21045
21645
  } catch (error) {
21046
21646
  this.disconnectWebSocket();
@@ -21139,7 +21739,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
21139
21739
  var _a2;
21140
21740
  const actionMessage = new ActionMessage();
21141
21741
  actionMessage.command = "Cancel";
21142
- console.log("Enviando comando 'Cancel' para o aplicativo...");
21143
21742
  (_a2 = this.connection) == null ? void 0 : _a2.invoke(
21144
21743
  "SendAction",
21145
21744
  this.externalSessionId,
@@ -21479,8 +22078,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
21479
22078
  this.connection.on(
21480
22079
  "ReceiveMessage",
21481
22080
  (sessionId, messageStr) => {
21482
- console.log("sessionId: ", sessionId);
21483
- console.log("Message: ", messageStr);
21484
22081
  if (sessionId !== this.externalSessionId) {
21485
22082
  console.warn("Sess\xE3o diferente!");
21486
22083
  return;
@@ -21488,7 +22085,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
21488
22085
  try {
21489
22086
  const messageKey = messageStr;
21490
22087
  const message = ExternalCameraStatusEnum[messageKey];
21491
- console.log("Mensagem -> ", message);
21492
22088
  this.handleWebSocketMessage(message);
21493
22089
  } catch (e3) {
21494
22090
  console.error("Erro ao processar mensagem do WebSocket:", e3);
@@ -21498,8 +22094,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
21498
22094
  this.connection.on(
21499
22095
  "ReceiveAction",
21500
22096
  (sessionId, actionMessage) => {
21501
- console.log("sessionId: ", sessionId);
21502
- console.log("Message: ", actionMessage);
21503
22097
  if (sessionId !== this.externalSessionId) {
21504
22098
  console.warn("Sess\xE3o diferente!");
21505
22099
  return;
@@ -21513,7 +22107,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
21513
22107
  );
21514
22108
  try {
21515
22109
  await this.connection.start();
21516
- console.log("Conectado ao Hub SignalR com sucesso!");
21517
22110
  } catch (err) {
21518
22111
  console.error("Falha ao conectar ou entrar no grupo do SignalR: ", err);
21519
22112
  throw new Error("N\xE3o foi poss\xEDvel conectar ao servi\xE7o em tempo real.");
@@ -21640,7 +22233,6 @@ var _ExternalCameraChecker = class _ExternalCameraChecker {
21640
22233
  if (this.connection) {
21641
22234
  try {
21642
22235
  await this.connection.stop();
21643
- console.log("Desconectado do SignalR.");
21644
22236
  } catch (err) {
21645
22237
  console.error("Erro ao desconectar do SignalR:", err);
21646
22238
  } finally {
@@ -21711,7 +22303,8 @@ var Proctoring = class {
21711
22303
  this.onChangeDevicesCallback = (devices) => {
21712
22304
  return;
21713
22305
  };
21714
- this.onRealtimeAlertsCallback = (response) => {
22306
+ this.onRealtimeAlertsCallback = async (response) => {
22307
+ await this.internalOnRealtimeAlerts(response);
21715
22308
  return;
21716
22309
  };
21717
22310
  this.onBufferSizeErrorCallback = (cameraStream) => {
@@ -21838,10 +22431,9 @@ var Proctoring = class {
21838
22431
  begin: alert.begin,
21839
22432
  end: alert.end,
21840
22433
  warningCategoryEnum: this.convertRealtimeTypeToWarningType(alert.type),
21841
- alertImageBase64: await this.allRecorders.cameraRecorder.getCurrentImageBase64(),
22434
+ alertImageBase64: alert.description !== "face_stop" ? await this.allRecorders.cameraRecorder.getCurrentImageBase64() : "",
21842
22435
  retry: verifyCount < verifyMaxRetries - 1 ? true : false
21843
22436
  });
21844
- console.log("response stopRealtimeAlert", response);
21845
22437
  return response;
21846
22438
  } catch (error) {
21847
22439
  console.log("error stopRealtimeAlert", error);
@@ -21850,23 +22442,26 @@ var Proctoring = class {
21850
22442
  };
21851
22443
  await verifyFace(1);
21852
22444
  }
22445
+ async internalOnRealtimeAlerts(response) {
22446
+ if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus")) {
22447
+ if (response.status === "ALERT") {
22448
+ await this.backend.startRealtimeAlert({
22449
+ proctoringId: this.proctoringId,
22450
+ begin: response.begin,
22451
+ end: response.end,
22452
+ alert: this.convertRealtimeCategoryToAlertCategory(response.category)
22453
+ });
22454
+ } else if (response.status === "OK") {
22455
+ await this.stopRealtimeAlert(response);
22456
+ }
22457
+ }
22458
+ }
21853
22459
  async onRealtimeAlerts(options = {}) {
21854
22460
  this.setOnLostFocusAlertRecorderCallback();
21855
22461
  this.setOnFocusAlertRecorderCallback();
21856
22462
  this.onRealtimeAlertsCallback = async (response) => {
22463
+ await this.internalOnRealtimeAlerts(response);
21857
22464
  options.data && options.data(response);
21858
- if (this.sessionOptions.proctoringType === "REALTIME" && (response.type === "face_detection_on_stream" || response.type === "person_detection_on_stream" || response.type === "lost_focus" || response.type === "focus")) {
21859
- if (response.status === "ALERT") {
21860
- await this.backend.startRealtimeAlert({
21861
- proctoringId: this.proctoringId,
21862
- begin: response.begin,
21863
- end: response.end,
21864
- alert: this.convertRealtimeCategoryToAlertCategory(response.category)
21865
- });
21866
- } else if (response.status === "OK") {
21867
- await this.stopRealtimeAlert(response);
21868
- }
21869
- }
21870
22465
  };
21871
22466
  }
21872
22467
  setOnBufferSizeErrorCallback(cb) {
@@ -21880,9 +22475,11 @@ var Proctoring = class {
21880
22475
  setDeviceCheckData(data) {
21881
22476
  this.deviceData = data;
21882
22477
  }
21883
- createRecorders(options = getDefaultProctoringOptions) {
21884
- var _a2, _b;
22478
+ async createRecorders(options = getDefaultProctoringOptions) {
22479
+ var _a2, _b, _c2;
21885
22480
  this.onChangeDevices();
22481
+ console.log("Creating recorders");
22482
+ await ((_a2 = this.recorder) == null ? void 0 : _a2.stopAll());
21886
22483
  const cameraRecorder = new CameraRecorder(
21887
22484
  {
21888
22485
  cameraId: this.sessionOptions.cameraId,
@@ -21904,8 +22501,8 @@ var Proctoring = class {
21904
22501
  this.context.token
21905
22502
  );
21906
22503
  const screenRecorder = this.sessionOptions.captureScreen ? new ScreenRecorder({
21907
- allowOnlyFirstMonitor: (_a2 = this.sessionOptions.allowOnlyFirstMonitor) != null ? _a2 : true,
21908
- allowMultipleMonitors: (_b = this.sessionOptions.allowMultipleMonitors) != null ? _b : true,
22504
+ allowOnlyFirstMonitor: (_b = this.sessionOptions.allowOnlyFirstMonitor) != null ? _b : true,
22505
+ allowMultipleMonitors: (_c2 = this.sessionOptions.allowMultipleMonitors) != null ? _c2 : true,
21909
22506
  screenRecorderOptions: this.sessionOptions.screenRecorderOptions,
21910
22507
  onStopSharingScreenCallback: () => this.onStopSharingScreenCallback(),
21911
22508
  onBufferSizeError: this.sessionOptions.onBufferSizeError,
@@ -21930,10 +22527,12 @@ var Proctoring = class {
21930
22527
  );
21931
22528
  const recorders = [
21932
22529
  cameraRecorder,
21933
- screenRecorder,
22530
+ noiseRecorder,
21934
22531
  alertRecorder
21935
22532
  ].filter(Boolean);
21936
- recorders.push(noiseRecorder);
22533
+ if (this.sessionOptions.proctoringType != "REALTIME" && screenRecorder) {
22534
+ recorders.push(screenRecorder);
22535
+ }
21937
22536
  this.recorder = new ProctoringRecorder(this.proctoringSession, recorders);
21938
22537
  return { cameraRecorder, screenRecorder, alertRecorder, noiseRecorder };
21939
22538
  }
@@ -21973,7 +22572,7 @@ var Proctoring = class {
21973
22572
  await this.repository.clear();
21974
22573
  }
21975
22574
  this.proctoringSession = new ProctoringSession();
21976
- this.allRecorders = this.createRecorders(this.sessionOptions);
22575
+ this.allRecorders = await this.createRecorders(this.sessionOptions);
21977
22576
  const startResponse = await this.backend.confirmStart(
21978
22577
  {
21979
22578
  clientId: this.context.clientId,
@@ -22000,7 +22599,13 @@ var Proctoring = class {
22000
22599
  this.allRecorders.cameraRecorder.setProctoringId(this.proctoringId);
22001
22600
  this.allRecorders.noiseRecorder.setProctoringId(this.proctoringId);
22002
22601
  this.proctoringSession.setProctoringId(this.proctoringId);
22003
- await this.recorder.startAll();
22602
+ try {
22603
+ console.log("Starting recorders");
22604
+ await this.recorder.startAll();
22605
+ } catch (error) {
22606
+ console.log("Starting recorders error:", error);
22607
+ throw error;
22608
+ }
22004
22609
  if (options == null ? void 0 : options.useSpyScan) {
22005
22610
  this.spyCam.setProctoringId(this.proctoringId);
22006
22611
  this.spyCam.startCheckSpyCam((_a2 = this.paramsConfig.spyScanInterval) != null ? _a2 : 5, {
@@ -22031,7 +22636,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
22031
22636
  verifyingFace = true;
22032
22637
  verifyFirstFaceIntervalCount++;
22033
22638
  try {
22034
- var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 5 ? false : true);
22639
+ var response = await this.backend.verifyFace(this.proctoringId, await this.allRecorders.cameraRecorder.getCurrentImageBase64(), verifyFirstFaceIntervalCount > 2 ? false : true);
22035
22640
  verifyingFace = false;
22036
22641
  clearInterval(this.verifyFirstFaceInterval);
22037
22642
  } catch (error) {
@@ -22039,7 +22644,7 @@ Navigator: ${JSON.stringify(_navigator2)}`
22039
22644
  return;
22040
22645
  }
22041
22646
  }
22042
- }, 1500);
22647
+ }, 5e3);
22043
22648
  return startResponse;
22044
22649
  } catch (error) {
22045
22650
  console.log(error);
@@ -22161,7 +22766,6 @@ Upload Services: ${uploaderServices}`,
22161
22766
  await this.backend.finishAndSendUrls(this.context).then((finishResponse) => {
22162
22767
  var _a2, _b, _c2, _d;
22163
22768
  trackers.registerFinish(this.proctoringSession.id, true, "");
22164
- console.log("finishResponse: ", finishResponse);
22165
22769
  options.onResultAvailable && options.onResultAvailable((_a2 = finishResponse == null ? void 0 : finishResponse.score) != null ? _a2 : 100, (_b = finishResponse == null ? void 0 : finishResponse.scoreThreshold) != null ? _b : 70, (_c2 = finishResponse == null ? void 0 : finishResponse.approved) != null ? _c2 : true, (_d = finishResponse == null ? void 0 : finishResponse.justification) != null ? _d : "");
22166
22770
  }).catch((error) => {
22167
22771
  trackers.registerFinish(
@@ -22290,7 +22894,6 @@ Error: ` + error
22290
22894
  return {
22291
22895
  cameraStream: this.allRecorders.cameraRecorder.cameraStream,
22292
22896
  // recorder (pause & resume)
22293
- // audioStream: this.allRecorders.audioRecorder.audioStream,
22294
22897
  _screenStream: (_a2 = this.allRecorders.screenRecorder) == null ? void 0 : _a2.screenStream
22295
22898
  };
22296
22899
  }