MCPcopy Create free account
hub / github.com/Roy3838/Observer / drainFrames

Method drainFrames

app/src/utils/tauriStreamCapture.ts:547–581  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

545 let draining = false;
546
547 const drainFrames = async () => {
548 draining = true;
549 while (pendingFrame && isActive) {
550 const bytes = pendingFrame;
551 pendingFrame = null; // frames arriving during this decode overwrite the slot
552 try {
553 const bitmap = await createImageBitmap(new Blob([bytes], { type: 'image/jpeg' }));
554 if (!isActive) { bitmap.close(); break; }
555
556 if (!canvasSizeInitialized && bitmap.width > 0) {
557 canvasClean.width = bitmap.width;
558 canvasClean.height = bitmap.height;
559 if (canvasPip) {
560 canvasPip.width = bitmap.width;
561 canvasPip.height = bitmap.height;
562 }
563 canvasSizeInitialized = true;
564 Logger.info("TAURI_STREAM", `Video canvas adapted to ${bitmap.width}x${bitmap.height}`);
565 }
566
567 ctxClean.drawImage(bitmap, 0, 0);
568
569 if (ctxPip && canvasPip) {
570 ctxPip.drawImage(bitmap, 0, 0);
571 if (this.pipOverlayDrawer) {
572 this.pipOverlayDrawer(ctxPip, canvasPip.width, canvasPip.height);
573 }
574 }
575 bitmap.close();
576 } catch (e) {
577 Logger.error("TAURI_STREAM", `Image decode error: ${e}`);
578 }
579 }
580 draining = false;
581 };
582
583 frameChannel.onmessage = (frameData: FrameData) => {
584 if (!isActive) return;

Callers

nothing calls this directly

Calls 2

infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected