/* * mirror-stream.js — renderer-side frame source for the phone remote's live mirror. * * Main asks for a frame over IPC ('mirror:frame-request'); this module answers with a ready-encoded * JPEG ('mirror:frame-response'). The picture comes from a getDisplayMedia stream of THIS window * (main's setDisplayMediaRequestHandler grants it with no picker), which the compositor feeds * directly — grabbing the latest video frame and encoding at ~860px takes ~20-40ms, where main's * capturePage() has a fixed ~120ms GPU-readback floor on the 4K stage window. That difference is * the phone mirror going from ~8fps to ~20fps. * * The stream is LAZY and self-stopping: it starts on the first request (so it costs nothing while * no phone is mirroring) and stops after ~8s without requests. If getDisplayMedia cannot work here, * one fatal reply tells main to stop asking and use capturePage permanently — the mirror keeps * working either way, just slower. */ (function () { 'use strict'; var ipc = window.electron && window.electron.ipcRenderer; if (!ipc || typeof ipc.on !== 'function' || typeof ipc.send !== 'function') return; var video = null; // hidden