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

Method drainFrames

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

Source from the content-addressed store, hash-verified

523 let draining = false;
524
525 const drainFrames = async () => {
526 draining = true;
527 while (pendingFrame && isActive) {
528 const bytes = pendingFrame;
529 pendingFrame = null; // frames arriving during this decode overwrite the slot
530 try {
531 const bitmap = await createImageBitmap(new Blob([bytes], { type: 'image/jpeg' }));
532 if (!isActive) { bitmap.close(); break; }
533
534 if (!canvasSizeInitialized && bitmap.width > 0) {
535 canvasClean.width = bitmap.width;
536 canvasClean.height = bitmap.height;
537 if (canvasPip) {
538 canvasPip.width = bitmap.width;
539 canvasPip.height = bitmap.height;
540 }
541 canvasSizeInitialized = true;
542 Logger.info("TAURI_STREAM", `Video canvas adapted to ${bitmap.width}x${bitmap.height}`);
543 }
544
545 ctxClean.drawImage(bitmap, 0, 0);
546
547 if (ctxPip && canvasPip) {
548 ctxPip.drawImage(bitmap, 0, 0);
549 if (this.pipOverlayDrawer) {
550 this.pipOverlayDrawer(ctxPip, canvasPip.width, canvasPip.height);
551 }
552 }
553 bitmap.close();
554 } catch (e) {
555 Logger.error("TAURI_STREAM", `Image decode error: ${e}`);
556 }
557 }
558 draining = false;
559 };
560
561 frameChannel.onmessage = (frameData: FrameData) => {
562 if (!isActive) return;

Callers

nothing calls this directly

Calls 2

infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected