cat / goq
clone

turns a linux box into a private steam streaming appliance: plug in, tap your key, play from another computer

fix/release-build-and-order
goq / portal / video-capability.mjs
video-capability.mjs 1.8K
1const H264_PROBE_CONFIG = Object.freeze({2 // Sigil's proven encoder path currently emits High Profile, Level 3.1 AVC.3 // Deliberately omit coded dimensions: this tests the emitted codec contract4 // without pinning Portal's capability decision to one host resolution.5 codec: 'avc1.64001f',6 optimizeForLatency: true,7});89/**10 * Report WebCodecs only when this webview can decode Sigil's current H.26411 * format. API presence alone is insufficient on codec-stripped webviews.12 */13export async function probeH264WebCodecsSupport({14 VideoDecoder = globalThis.VideoDecoder,15 logger = console,16} = {}) {17 if (typeof VideoDecoder !== 'function'18 || typeof VideoDecoder.isConfigSupported !== 'function') return false;1920 try {21 const support = await VideoDecoder.isConfigSupported({ ...H264_PROBE_CONFIG });22 return support?.supported === true;23 } catch (error) {24 logger.warn('WebCodecs H.264 capability probe failed:', error);25 return false;26 }27}2829/** Publish one delivery mode to both halves of Portal before a connection. */30export async function detectAndPublishVideoDeliveryMode({31 invokeCommand,32 VideoDecoder = globalThis.VideoDecoder,33 logger = console,34} = {}) {35 if (typeof invokeCommand !== 'function') {36 throw new TypeError('invokeCommand must be a function');37 }3839 const available = await probeH264WebCodecsSupport({ VideoDecoder, logger });40 try {41 const effectiveAvailable = await invokeCommand('set_webcodecs_available', { available });42 if (typeof effectiveAvailable !== 'boolean') {43 throw new TypeError('native video delivery publication returned an invalid mode');44 }45 return effectiveAvailable;46 } catch (error) {47 logger.error('could not publish WebCodecs capability; connecting will fail fast:', error);48 return false;49 }50}